001package com.fs.starfarer.api.impl.campaign.intel.misc;
002
003import java.util.ArrayList;
004import java.util.List;
005import java.util.Set;
006
007import java.awt.Color;
008
009import com.fs.starfarer.api.Global;
010import com.fs.starfarer.api.campaign.FactionAPI;
011import com.fs.starfarer.api.campaign.SectorEntityToken;
012import com.fs.starfarer.api.impl.campaign.ids.Tags;
013import com.fs.starfarer.api.ui.SectorMapAPI;
014import com.fs.starfarer.api.ui.TooltipMakerAPI;
015import com.fs.starfarer.api.util.Misc;
016
017public class BreadcrumbIntel extends FleetLogIntel {
018
019        protected SectorEntityToken foundAt;
020        protected SectorEntityToken target;
021        
022        protected String title;
023        protected String text;
024        
025        protected Boolean showSpecificEntity = null;
026        
027        public BreadcrumbIntel(SectorEntityToken foundAt, SectorEntityToken target) {
028                if (foundAt != null) {
029                        this.foundAt = makeDoubleWithSameOrbit(foundAt);
030                }
031                this.target = makeDoubleWithSameOrbit(target);
032                target.getContainingLocation().addEntity(target);
033                setRemoveTrigger(target);
034                
035                
036//              String targetName = BreadcrumbSpecial.getNameWithAOrAn(target, null, true);
037//              String targetNameUC = BreadcrumbSpecial.getNameWithAOrAn(target, null, false);
038//              //String entityName = getNameWithAOrAn(entity, null);
039//              String located = BreadcrumbSpecial.getLocatedString(target);
040//              
041//              String subject = "Location: " + Misc.ucFirst(targetNameUC.substring(targetNameUC.indexOf(" ") + 1)) + "");
042//              String text1ForIntel = Misc.getStringWithTokenReplacement("While exploring $aOrAn $nameInText, " +
043//                                                         "your crews found a partially accessible memory bank " + 
044//                                                         "containing information that indicates " + targetName + " is " + located + ".", 
045//                                                         foundAt, null);
046        }
047        
048        @Override
049        public void reportRemovedIntel() {
050                super.reportRemovedIntel();
051                target.getContainingLocation().removeEntity(target);
052        }
053
054
055
056        public static SectorEntityToken makeDoubleWithSameOrbit(SectorEntityToken entity) {
057                SectorEntityToken copy = entity.getContainingLocation().createToken(entity.getLocation().x, entity.getLocation().y);
058                if (entity.getOrbit() != null) {
059                        copy.setOrbit(entity.getOrbit().makeCopy());
060                }
061                return copy;
062        }
063        
064        
065        public String getTitle() {
066                return title;
067        }
068
069        public void setTitle(String title) {
070                this.title = title;
071        }
072
073        public String getText() {
074                return text;
075        }
076
077        public void setText(String text) {
078                this.text = text;
079        }
080
081        @Override
082        public void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode) {
083                Color c = getTitleColor(mode);
084                info.addPara(getName(), c, 0f);
085        }
086
087        @Override
088        public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
089                Color h = Misc.getHighlightColor();
090                Color g = Misc.getGrayColor();
091                Color tc = Misc.getTextColor();
092                float pad = 3f;
093                float opad = 10f;
094
095                info.addImage(Global.getSettings().getSpriteName("illustrations", "space_wreckage"), width, opad);
096                
097                info.addPara(text, opad);
098                
099                //target.getOrbit().updateLocation();
100                
101//              float days = getDaysSincePlayerVisible();
102//              if (days >= 1) {
103//                      addDays(info, "ago.", days, tc, opad);
104//              }
105                addLogTimestamp(info, tc, opad);
106                
107//              LuddicPathBaseIntel base = new LuddicPathBaseIntel((StarSystemAPI) Global.getSector().getCurrentLocation(), Factions.LUDDIC_PATH);
108//              Global.getSector().addScript(base);
109//              MemoryAPI mem = base.getEntity().getMemoryWithoutUpdate();
110//              mem.set("$blah", t
111                
112                addDeleteButton(info, width);
113        }
114
115        @Override
116        public String getIcon() {
117                return super.getIcon();
118        }
119
120        @Override
121        public Set<String> getIntelTags(SectorMapAPI map) {
122                Set<String> tags = super.getIntelTags(map);
123                tags.remove(Tags.INTEL_FLEET_LOG);
124                tags.add(Tags.INTEL_EXPLORATION);
125                return tags;
126        }
127
128        public String getSortString() {
129                //return "Location";
130                return super.getSortString();
131        }
132
133        public String getName() {
134                return title;
135        }
136
137        @Override
138        public FactionAPI getFactionForUIColors() {
139                return super.getFactionForUIColors();
140        }
141
142        public String getSmallDescriptionTitle() {
143                return getName();
144        }
145
146        @Override
147        public SectorEntityToken getMapLocation(SectorMapAPI map) {
148                if (target.getStarSystem() != null && showSpecificEntity == null) {
149                        return target.getStarSystem().createToken(0, 0);
150                        //return target.getStarSystem().getCenter();
151                }
152                return target;
153        }
154
155        @Override
156        public boolean shouldRemoveIntel() {
157                return super.shouldRemoveIntel();
158        }
159
160        @Override
161        public String getCommMessageSound() {
162                if (sound != null) return sound;
163                return getSoundMinorMessage();
164        }
165        
166        public Boolean getShowSpecificEntity() {
167                return showSpecificEntity;
168        }
169
170        public void setShowSpecificEntity(Boolean showPlanet) {
171                if (showPlanet != null && !showPlanet) showPlanet = null;
172                
173                this.showSpecificEntity = showPlanet;
174        }
175
176        public List<ArrowData> getArrowData(SectorMapAPI map) {
177                if (true) return null;
178                
179                if (foundAt == null) return null;
180                
181                List<ArrowData> result = new ArrayList<ArrowData>();
182                
183                if (foundAt.getContainingLocation() == target.getContainingLocation() &&
184                                foundAt.getContainingLocation() != null &&
185                                !foundAt.getContainingLocation().isHyperspace()) {
186                        return null;
187                }
188                
189//              SectorEntityToken entityFrom = foundLocation;
190//              if (map != null) {
191//                      SectorEntityToken iconEntity = map.getIntelIconEntity(this);
192//                      if (iconEntity != null) {
193//                              entityFrom = iconEntity;
194//                      }
195//              }
196//              
197//              ArrowData arrow = new ArrowData(entityFrom, targetLocation);
198                ArrowData arrow = new ArrowData(foundAt, target);
199                
200                arrow.color = getFactionForUIColors().getBaseUIColor();
201                result.add(arrow);
202                
203                return result;
204        }
205
206
207
208
209}