001package com.fs.starfarer.api.impl.campaign.intel.misc;
002
003import java.util.Set;
004
005import java.awt.Color;
006
007import com.fs.starfarer.api.Global;
008import com.fs.starfarer.api.campaign.FactionAPI;
009import com.fs.starfarer.api.campaign.SectorEntityToken;
010import com.fs.starfarer.api.campaign.StarSystemAPI;
011import com.fs.starfarer.api.impl.campaign.ids.Tags;
012import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
013import com.fs.starfarer.api.impl.campaign.procgen.themes.RemnantThemeGenerator.RemnantSystemType;
014import com.fs.starfarer.api.loading.Description;
015import com.fs.starfarer.api.loading.Description.Type;
016import com.fs.starfarer.api.ui.SectorMapAPI;
017import com.fs.starfarer.api.ui.TooltipMakerAPI;
018import com.fs.starfarer.api.util.Misc;
019
020public class WarningBeaconIntel extends BaseIntelPlugin {
021
022        protected SectorEntityToken beacon;
023        
024        public WarningBeaconIntel(SectorEntityToken beacon) {
025                this.beacon = beacon;
026                //Global.getSector().getIntelManager().addIntel(this);
027        }
028        
029        protected RemnantSystemType getRemnantType() {
030                RemnantSystemType remnantType = null;
031                if (beacon.getMemoryWithoutUpdate().contains(RemnantSystemType.DESTROYED.getBeaconFlag())) {
032                        remnantType = RemnantSystemType.DESTROYED;
033                } else if (beacon.getMemoryWithoutUpdate().contains(RemnantSystemType.SUPPRESSED.getBeaconFlag())) {
034                        remnantType = RemnantSystemType.SUPPRESSED;
035                } else if (beacon.getMemoryWithoutUpdate().contains(RemnantSystemType.RESURGENT.getBeaconFlag())) {
036                        remnantType = RemnantSystemType.RESURGENT;
037                }
038                return remnantType;
039        }
040        
041        protected boolean isLow() {
042                return beacon.hasTag(Tags.BEACON_LOW);
043        }
044        protected boolean isMedium() {
045                return beacon.hasTag(Tags.BEACON_MEDIUM);
046        }
047        protected boolean isHigh() {
048                return beacon.hasTag(Tags.BEACON_HIGH);
049        }
050        
051        protected void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode) {
052                
053                Color h = Misc.getHighlightColor();
054                Color g = Misc.getGrayColor();
055                float pad = 3f;
056                float opad = 10f;
057                
058                float initPad = pad;
059                if (mode == ListInfoMode.IN_DESC) initPad = opad;
060                
061                Color tc = getBulletColorForMode(mode);
062                
063                bullet(info);
064                boolean isUpdate = getListInfoParam() != null;
065                
066                String danger = null;
067                Color dangerColor = null;
068                if (isLow()) {
069                        danger = "low";
070                        dangerColor = Misc.getPositiveHighlightColor();
071                } else if (isMedium()) {
072                        danger = "medium";
073                        dangerColor = h;
074                } else if (isHigh()) {
075                        danger = "high";
076                        dangerColor = Misc.getNegativeHighlightColor();
077                }
078                
079                if (danger != null) {
080                        info.addPara("Danger level: " + danger, initPad, tc, dangerColor, danger);
081                        initPad = 0f;
082                }
083                
084                unindent(info);
085        }
086        
087        
088        @Override
089        public void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode) {
090                Color c = getTitleColor(mode);
091                info.addPara(getName(), c, 0f);
092                addBulletPoints(info, mode);
093        }
094        
095        @Override
096        public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
097                Color h = Misc.getHighlightColor();
098                Color g = Misc.getGrayColor();
099                Color tc = Misc.getTextColor();
100                float pad = 3f;
101                float opad = 10f;
102                
103                
104                Description desc = Global.getSettings().getDescription("warning_beacon", Type.CUSTOM);
105                info.addPara(desc.getText1FirstPara(), opad);
106                
107                addBulletPoints(info, ListInfoMode.IN_DESC);
108                
109                if (beacon.isInHyperspace()) {
110                        StarSystemAPI system = Misc.getNearbyStarSystem(beacon, 1f);
111                        if (system != null) {
112                                info.addPara("This beacon is located near the " + system.getNameWithLowercaseType() + 
113                                                ", warning of dangers that presumably lie within.", opad);
114                                
115                        }
116                }
117        }
118        
119        @Override
120        public String getIcon() {
121                if (isLow()) {
122                        return Global.getSettings().getSpriteName("intel", "beacon_low");
123                } else if (isMedium()) {
124                        return Global.getSettings().getSpriteName("intel", "beacon_medium");
125                } else if (isHigh()) {
126                        return Global.getSettings().getSpriteName("intel", "beacon_high");
127                }
128                return Global.getSettings().getSpriteName("intel", "beacon_low");
129        }
130        
131        @Override
132        public Set<String> getIntelTags(SectorMapAPI map) {
133                Set<String> tags = super.getIntelTags(map);
134                tags.add(Tags.INTEL_BEACON);
135                
136//              if (getRemnantType() != null) {
137//                      tags.add(Factions.REMNANTS);
138//              }
139                
140                return tags;
141        }
142        
143        public String getSortString() {
144                if (isLow()) {
145                        return "Warning Beacon 3";
146                } else if (isMedium()) {
147                        return "Warning Beacon 2";
148                } else if (isHigh()) {
149                        return "Warning Beacon 1";
150                }
151                return "Warning Beacon 0";
152        }
153        
154        public String getName() {
155//              if (isLow()) {
156//                      return "Warning Beacon (Low)";
157//              } else if (isMedium()) {
158//                      return "Warning Beacon (Medium)";
159//              } else if (isHigh()) {
160//                      return "Warning Beacon (High)";
161//              }
162                return "Warning Beacon";
163        }
164        
165        @Override
166        public FactionAPI getFactionForUIColors() {
167                return super.getFactionForUIColors();
168        }
169
170        public String getSmallDescriptionTitle() {
171                return getName();
172        }
173
174        @Override
175        public SectorEntityToken getMapLocation(SectorMapAPI map) {
176                if (beacon.isInHyperspace() && false) {
177                        StarSystemAPI system = Misc.getNearbyStarSystem(beacon, 1f);
178                        if (system != null) {
179                                return system.getHyperspaceAnchor();
180                        }
181                }
182                return beacon;
183        }
184        
185        @Override
186        public boolean shouldRemoveIntel() {
187                return false;
188        }
189
190        @Override
191        public String getCommMessageSound() {
192                return "ui_discovered_entity";
193        }
194        
195        
196        
197}
198
199
200
201
202
203
204