Starsector API
Loading...
Searching...
No Matches
LuddicShrineIntel.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.misc;
2
3import java.awt.Color;
4import java.util.ArrayList;
5import java.util.List;
6import java.util.Set;
7
8import org.lwjgl.input.Keyboard;
9
10import com.fs.starfarer.api.Global;
11import com.fs.starfarer.api.campaign.FactionAPI;
12import com.fs.starfarer.api.campaign.SectorEntityToken;
13import com.fs.starfarer.api.campaign.TextPanelAPI;
14import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin;
15import com.fs.starfarer.api.campaign.econ.MarketAPI;
16import com.fs.starfarer.api.impl.campaign.ids.Factions;
17import com.fs.starfarer.api.impl.campaign.ids.Tags;
18import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
19import com.fs.starfarer.api.impl.campaign.missions.luddic.LuddicPilgrimsPath;
20import com.fs.starfarer.api.loading.Description;
21import com.fs.starfarer.api.loading.Description.Type;
22import com.fs.starfarer.api.ui.ButtonAPI;
23import com.fs.starfarer.api.ui.IntelUIAPI;
24import com.fs.starfarer.api.ui.SectorMapAPI;
25import com.fs.starfarer.api.ui.TooltipMakerAPI;
26import com.fs.starfarer.api.util.Misc;
27
28public class LuddicShrineIntel extends BaseIntelPlugin {
29
30 public static String VISITED = "$visitedShrine";
31
32
33 protected SectorEntityToken entity;
34
35 public static void addShrineIntelIfNeeded(String id, TextPanelAPI text) {
37 }
38 public static void addShrineIntelIfNeeded(SectorEntityToken entity, TextPanelAPI text) {
39 addShrineIntelIfNeeded(entity, text, false);
40 }
41 public static void addShrineIntelIfNeeded(SectorEntityToken entity, TextPanelAPI text, boolean quiet) {
42 if (getShrineIntel(entity) == null) {
44 Global.getSector().getIntelManager().addIntel(intel, quiet, text);
45 }
46 }
47
48 public static void setVisited(SectorEntityToken entity, TextPanelAPI text) {
49 if (isVisited(entity)) return;
50
51 entity.getMemoryWithoutUpdate().set(VISITED, true);
52 if (text != null) {
54 if (intel != null) {
55 Global.getSector().getIntelManager().addIntelToTextPanel(intel, text);
56 }
57 }
58 }
59
60 public static boolean isVisited(SectorEntityToken entity) {
61 return entity.getMemoryWithoutUpdate().getBoolean(VISITED) ||
62 (entity.getMarket() != null &&
63 entity.getMarket().getMemoryWithoutUpdate().getBoolean(VISITED));
64 }
65
66
67 public static LuddicShrineIntel getShrineIntel(SectorEntityToken entity) {
68 for (IntelInfoPlugin intel : Global.getSector().getIntelManager().getIntel(LuddicShrineIntel.class)) {
69 if (((LuddicShrineIntel)intel).getEntity() == entity) return (LuddicShrineIntel)intel;
70 }
71 return null;
72 }
73
74 public static SectorEntityToken getEntity(String id) {
75 MarketAPI market = Global.getSector().getEconomy().getMarket(id);
76 if (market != null) {
77 if (market.getPlanetEntity() != null) {
78 return market.getPlanetEntity();
79 }
80 return market.getPrimaryEntity();
81 } else {
82 return Global.getSector().getEntityById(id);
83 }
84 }
85
86
87 public LuddicShrineIntel(SectorEntityToken entity) {
88 this.entity = entity;
89 }
90
91
92 protected void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode) {
93
94 Color h = Misc.getHighlightColor();
95 Color g = Misc.getGrayColor();
96 float pad = 3f;
97 float opad = 10f;
98
99 float initPad = pad;
100 if (mode == ListInfoMode.IN_DESC) initPad = opad;
101
102 Color tc = getBulletColorForMode(mode);
103
104 bullet(info);
105 boolean isUpdate = getListInfoParam() != null;
106
107// if (mode == ListInfoMode.INTEL) {
108// info.addPara("Located in the " + gate.getContainingLocation().getNameWithLowercaseTypeShort(), tc, initPad);
109// initPad = 0f;
110// }
111
112 boolean visited = isVisited(entity);
113
114 if (visited) {
115 Color c = Global.getSector().getFaction(Factions.LUDDIC_CHURCH).getBaseUIColor();
116 info.addPara("Visited", c, initPad);
117 initPad = 0f;
118 } else {
119 info.addPara("Not visited", tc, initPad);
120 initPad = 0f;
121 }
122
123 if (mode == ListInfoMode.INTEL) {
124 // not sure if this is needed
125 //info.addPara("In the " + entity.getContainingLocation().getNameWithLowercaseType(), tc, 0f);
126 }
127
128 unindent(info);
129 }
130
131
132 @Override
133 public void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode) {
134 String pre = "";
135 String post = "";
136 if (mode == ListInfoMode.MESSAGES) {
137 pre = "Discovered: ";
138 }
139 if (mode == ListInfoMode.INTEL) {
140 //post = " - " + entity.getContainingLocation().getNameWithTypeShort();
141 }
142
143 Color c = getTitleColor(mode);
144 info.addPara(pre + getName() + post, c, 0f);
145 addBulletPoints(info, mode);
146 }
147
148 @Override
149 public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
150 Color h = Misc.getHighlightColor();
151 Color g = Misc.getGrayColor();
152 Color tc = Misc.getTextColor();
153 float pad = 3f;
154 float opad = 10f;
155
156 String id = entity.getId();
157 if (entity.getMarket() != null && !entity.getMarket().isPlanetConditionMarketOnly()) {
158 id = entity.getMarket().getId();
159 }
160
161 boolean visited = isVisited(entity);
162
163 if (id.equals("jangala")) {
164 if (visited) {
165 info.addImage(Global.getSettings().getSpriteName("illustrations", "jangala_shrine"), width, opad);
166 }
167 Description desc = Global.getSettings().getDescription("shrine_jangala", Type.CUSTOM);
168 info.addPara(desc.getText1(), opad);
169 } else if (id.equals("volturn")) {
170 if (visited) {
171 info.addImage(Global.getSettings().getSpriteName("illustrations", "volturn_shrine_fake"), width, opad);
172 }
173 Description desc = Global.getSettings().getDescription("shrine_volturn", Type.CUSTOM);
174 info.addPara(desc.getText1(), opad);
175 } else if (id.equals("hesperus")) {
176 if (visited) {
177 info.addImage(Global.getSettings().getSpriteName("illustrations", "hesperus_shrine"), width, opad);
178 }
179 Description desc = Global.getSettings().getDescription("shrine_hesperus", Type.CUSTOM);
180 info.addPara(desc.getText1(), opad);
181 } else if (id.equals("gilead")) {
182 if (visited) {
183 info.addImage(Global.getSettings().getSpriteName("illustrations", "gilead"), width, opad);
184 }
185 Description desc = Global.getSettings().getDescription("shrine_gilead", Type.CUSTOM);
186 info.addPara(desc.getText1(), opad);
187 } else if (id.equals("beholder_station")) {
188 if (visited) {
189 info.addImage(Global.getSettings().getSpriteName("illustrations", "luddic_shrine"), width, opad);
190 //info.addImage(entity.getCustomInteractionDialogImageVisual().getSpriteName(), width, opad);
191 }
192
193 // this is probably fine for Beholder Station, but would just get the market description for
194 // shrines that are on actual colonies
195 Description desc = Global.getSettings().getDescription("shrine_beholder", Type.CUSTOM);
196 info.addPara(desc.getText1(), opad);
197
198 } else if (id.equals("killa")) {
199 if (visited) {
200 info.addImage(Global.getSettings().getSpriteName("illustrations", "killa_shrine"), width, opad);
201 //info.addImage(entity.getCustomInteractionDialogImageVisual().getSpriteName(), width, opad);
202 }
203 Description desc = Global.getSettings().getDescription("shrine_killa", Type.CUSTOM);
204 info.addPara(desc.getText1(), opad);
205 }
206
207
208// String buttonText = "Show shrines";
209// if (info.getIntelUI().isShowingCustomIntelSubset()) {
210// buttonText = "Go back";
211// }
212//
213// info.addSpacer(height - info.getHeightSoFar() - 20f - 20f);
214// ButtonAPI button = addGenericButton(info, width, buttonText, BUTTON_SHOW_SHRINES);
215// button.setShortcut(Keyboard.KEY_T, true);
216 addShowShrinesButton(this, width, height, info);
217
218 //addBulletPoints(info, ListInfoMode.IN_DESC);
219
220 }
221
222 @Override
223 public String getIcon() {
224 return Global.getSettings().getSpriteName("intel", "luddic_shrine");
225 }
226
227 @Override
228 public Set<String> getIntelTags(SectorMapAPI map) {
229 Set<String> tags = super.getIntelTags(map);
230 tags.add(Tags.INTEL_SHRINES);
231 return tags;
232 }
233
234 public String getSortString() {
235 return getName();
236 }
237
238 public String getName() {
239// String onOrAt = "on";
240// if (entity.getMarket() != null && !entity.getMarket().isPlanetConditionMarketOnly()) {
241// onOrAt = entity.getMarket().getOnOrAt();
242// }
243// return "Luddic Shrine " + onOrAt + " " + entity.getName();
244 return "Luddic Shrine - " + entity.getName();
245 }
246
247 @Override
248 public FactionAPI getFactionForUIColors() {
249 return Global.getSector().getFaction(Factions.LUDDIC_CHURCH);
250 }
251
252 public String getSmallDescriptionTitle() {
253 //return getName() + " - " + entity.getContainingLocation().getNameWithTypeShort();
254 return getName();
255 }
256
257 @Override
258 public SectorEntityToken getMapLocation(SectorMapAPI map) {
259 return entity;
260 }
261
262 @Override
263 public boolean shouldRemoveIntel() {
264 return false;
265 }
266
267 @Override
268 public String getCommMessageSound() {
269 return "ui_discovered_entity";
270 }
271
272 public SectorEntityToken getEntity() {
273 return entity;
274 }
275
276
277 public static String BUTTON_SHOW_SHRINES = "button_show_shrines";
278 public void buttonPressConfirmed(Object buttonId, IntelUIAPI ui) {
279 if (buttonId == BUTTON_SHOW_SHRINES) {
280 toggleShrineList(this, ui);
281 return;
282 }
283 super.buttonPressConfirmed(buttonId, ui);
284 }
285
286 public static void addShowShrinesButton(IntelInfoPlugin curr, float width, float height, TooltipMakerAPI info) {
287 if (!Global.getSector().getIntelManager().hasIntelOfClass(LuddicPilgrimsPath.class)) return;
288
289 if (!info.getIntelUI().isShowingCustomIntelSubset() &&
290 curr instanceof LuddicShrineIntel) {
291 return;
292 }
293
294 String buttonText = "Show shrines";
295 if (info.getIntelUI().isShowingCustomIntelSubset()) {
296 buttonText = "Go back";
297 }
298
299 info.addSpacer(height - info.getHeightSoFar() - 20f - 20f);
300 ButtonAPI button = ((BaseIntelPlugin)curr).addGenericButton(info, width, buttonText, BUTTON_SHOW_SHRINES);
301 button.setShortcut(Keyboard.KEY_T, true);
302 }
303
304 public static void toggleShrineList(IntelInfoPlugin curr, IntelUIAPI ui) {
305 if (ui.isShowingCustomIntelSubset()) {
306 ui.updateIntelList(true);
307 ui.updateUIForItem(curr);
308 //for (IntelInfoPlugin intel : Global.getSector().getIntelManager().getIntel(LuddicShrineIntel.class)) {
309 for (IntelInfoPlugin intel : Global.getSector().getIntelManager().getIntel(LuddicPilgrimsPath.class)) {
310 ui.selectItem(intel);
311 break;
312 }
313 } else {
314 List<IntelInfoPlugin> show = new ArrayList<IntelInfoPlugin>();
315 for (IntelInfoPlugin intel : Global.getSector().getIntelManager().getIntel(LuddicPilgrimsPath.class)) {
316 show.add(intel);
317 }
318 for (IntelInfoPlugin intel : Global.getSector().getIntelManager().getIntel(LuddicShrineIntel.class)) {
319 show.add(intel);
320 }
321 Global.getSector().getIntelManager().sortIntel(show);
322 ui.updateIntelList(true, show);
323 ui.updateUIForItem(curr);
324 }
325 return;
326 }
327
328}
static SettingsAPI getSettings()
Definition Global.java:51
static SectorAPI getSector()
Definition Global.java:59
static void setVisited(SectorEntityToken entity, TextPanelAPI text)
void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode)
static void addShrineIntelIfNeeded(SectorEntityToken entity, TextPanelAPI text)
static LuddicShrineIntel getShrineIntel(SectorEntityToken entity)
void createSmallDescription(TooltipMakerAPI info, float width, float height)
static void addShowShrinesButton(IntelInfoPlugin curr, float width, float height, TooltipMakerAPI info)
static void addShrineIntelIfNeeded(String id, TextPanelAPI text)
static void toggleShrineList(IntelInfoPlugin curr, IntelUIAPI ui)
void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode)
static void addShrineIntelIfNeeded(SectorEntityToken entity, TextPanelAPI text, boolean quiet)
Description getDescription(String id, Type type)
String getSpriteName(String category, String id)