Starsector API
Loading...
Searching...
No Matches
BaseIntelPlugin.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel;
2
3import java.util.ArrayList;
4import java.util.LinkedHashSet;
5import java.util.List;
6import java.util.Map;
7import java.util.Set;
8
9import java.awt.Color;
10
11import org.lwjgl.input.Keyboard;
12import org.lwjgl.util.vector.Vector2f;
13
14import com.fs.starfarer.api.EveryFrameScript;
15import com.fs.starfarer.api.Global;
16import com.fs.starfarer.api.campaign.CampaignClockAPI;
17import com.fs.starfarer.api.campaign.FactionAPI;
18import com.fs.starfarer.api.campaign.InteractionDialogAPI;
19import com.fs.starfarer.api.campaign.LocationAPI;
20import com.fs.starfarer.api.campaign.SectorEntityToken;
21import com.fs.starfarer.api.campaign.StoryPointActionDelegate;
22import com.fs.starfarer.api.campaign.TextPanelAPI;
23import com.fs.starfarer.api.campaign.comm.CommMessageAPI.MessageClickAction;
24import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin;
25import com.fs.starfarer.api.campaign.econ.MarketAPI;
26import com.fs.starfarer.api.campaign.rules.MemoryAPI;
27import com.fs.starfarer.api.impl.campaign.CommRelayEntityPlugin.CommSnifferReadableIntel;
28import com.fs.starfarer.api.impl.campaign.ids.Tags;
29import com.fs.starfarer.api.impl.campaign.rulecmd.CallEvent.CallableEvent;
30import com.fs.starfarer.api.impl.campaign.tutorial.TutorialMissionIntel;
31import com.fs.starfarer.api.ui.ButtonAPI;
32import com.fs.starfarer.api.ui.CustomPanelAPI;
33import com.fs.starfarer.api.ui.IntelUIAPI;
34import com.fs.starfarer.api.ui.LabelAPI;
35import com.fs.starfarer.api.ui.SectorMapAPI;
36import com.fs.starfarer.api.ui.TooltipMakerAPI;
37import com.fs.starfarer.api.util.Misc;
38import com.fs.starfarer.api.util.Misc.Token;
39
45public class BaseIntelPlugin implements IntelInfoPlugin, CallableEvent, EveryFrameScript, CommSnifferReadableIntel {
46
47 public static final String BULLET = " - ";
48 public static final String INDENT = " ";
49
50 public static String BUTTON_DELETE = "button_delete";
51
52 protected Boolean important;
53 protected Long timestamp;
54 protected Boolean neverClicked = true;
55
56 transient protected Object listInfoParam = null;
57
58 protected Boolean ended = null;
59 protected Boolean ending = null;
60 protected Float endingTimeRemaining = null;
61
63 protected Float postingRangeLY = null;
64
65 protected transient Set<String> tagsForSort = null;
66
67 public BaseIntelPlugin() {
68 }
69
70
71 public void advance(float amount) {
72 if (isEnded()) return;
73
74 float days = Global.getSector().getClock().convertToDays(amount);
75 if (isEnding()) {
76 endingTimeRemaining -= days;
77 if (endingTimeRemaining <= 0) {
78 ended = true;
80 }
81 return;
82 }
83
84 advanceImpl(amount);
85 }
86
88
89 }
90
91 protected void advanceImpl(float amount) {}
92
93 protected void notifyEnding() {
94
95 }
96
97 protected void notifyEnded() {
98 //Global.getSector().getIntelManager().removeIntel(this);
99 }
100
101 public void endImmediately() {
102 endAfterDelay(0f);
103 }
104 public void endAfterDelay() {
106 }
107 public void endAfterDelay(float days) {
108 endingTimeRemaining = days;
109 boolean wasEnding = isEnding();
110 ending = true;
111 if (!wasEnding) {
112 notifyEnding();
113 }
114 if (endingTimeRemaining <= 0) {
115 ended = true;
116 notifyEnded();
117 }
118 }
119
120 protected float getBaseDaysAfterEnd() {
121 return 3f;
122 }
123
124 public boolean isDone() {
125 return isEnded();
126 }
127
128 public boolean runWhilePaused() {
129 return false;
130 }
131
132 public boolean isEnding() {
133 return ending != null && ending;
134 }
135
136 public boolean isEnded() {
137 return ended != null && ended;
138 }
139
140
146 public Object getListInfoParam() {
147 return listInfoParam;
148 }
149
150 public void setListInfoParam(Object listInfoParam) {
151 this.listInfoParam = listInfoParam;
152 }
153
154
155 public boolean isSendingUpdate() {
156 return listInfoParam != null;
157 }
158
159 public void sendUpdate(Object listInfoParam, TextPanelAPI textPanel) {
160 this.listInfoParam = listInfoParam;
162 this.listInfoParam = null;
163 }
164
166 if (textPanel == null) {
168 } else {
169 sendUpdate(listInfoParam, textPanel);
170 }
171 }
172
173 public void sendUpdateIfPlayerHasIntel(Object listInfoParam, boolean onlyIfImportant) {
174 sendUpdateIfPlayerHasIntel(listInfoParam, onlyIfImportant, false);
175 }
176 public void sendUpdateIfPlayerHasIntel(Object listInfoParam, boolean onlyIfImportant, boolean sendIfHidden) {
177 if (timestamp == null) return;
178
179 if (onlyIfImportant && !isImportant()) return;
180
181 if (!sendIfHidden && isHidden()) return;
182
183 this.listInfoParam = listInfoParam;
184 Global.getSector().getCampaignUI().addMessage(this, MessageClickAction.INTEL_TAB, this);
185 this.listInfoParam = null;
186 }
187
188
189 public boolean canTurnImportantOff() {
190 return true;
191 }
192
193 public String getImportantIcon() {
194 return null;
195 }
196
197 public boolean hasImportantButton() {
198 return true;
199 }
200
201// public void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode) {
202// info.addPara("Override .createIntelInfo()", Misc.getNegativeHighlightColor(), 0f);
203// }
204
205 protected void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode) {
206 float pad = 3f;
207 float opad = 10f;
208
209 float initPad = pad;
210 if (mode == ListInfoMode.IN_DESC) initPad = opad;
211
212 Color tc = getBulletColorForMode(mode);
213
214 boolean isUpdate = getListInfoParam() != null;
215
216 bullet(info);
217 addBulletPoints(info, mode, isUpdate, tc, initPad);
218 unindent(info);
219 }
220
221 protected void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate,
222 Color tc, float initPad) {
223
224 }
225
226 public void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode) {
227 if (getName() != null) {
228 Color c = getTitleColor(mode);
229 info.addPara(getName(), c, 0f);
230 }
231 addBulletPoints(info, mode);
232 }
233
234 protected String getName() {
235 return null;
236 }
237
238
239 public boolean hasSmallDescription() {
240 return true;
241 }
242
243 public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
244 info.addPara("Override .createSmallDescription()", Misc.getNegativeHighlightColor(), 0f);
245 }
246
247 public boolean hasLargeDescription() {
248 return false;
249 }
250
251 public void createLargeDescription(CustomPanelAPI panel, float width, float height) {
252 TooltipMakerAPI desc = panel.createUIElement(width, height, true);
253 desc.addPara("Override .createLargeDescription()", Misc.getNegativeHighlightColor(), 0f);
254 panel.addUIElement(desc).inTL(0, 0);
255 }
256
257 public String getIcon() {
258 return null;
259 }
260
261// public float getIconBrightness() {
262// if (isEnding() || isEnded()) return 0.5f;
263// return 1f;
264// }
265
266 public Color getBackgroundGlowColor() {
267 return null;
268 }
269
270 public boolean shouldRemoveIntel() {
271// if (this instanceof CommSnifferIntel) {
272// System.out.println("wefwefe");
273// }
274// if (isImportant()) return false;
275
276 if (timestamp == null && isEnding()) {
277 return true; // already ending, and not yet player-visible; remove
278 }
279 return isEnded();
280 }
281
282 public Set<String> getIntelTags(SectorMapAPI map) {
283 Set<String> tags = new LinkedHashSet<String>();
284 if (isImportant()) {
285 tags.add(Tags.INTEL_IMPORTANT);
286 }
287 if (isNew()) {
288 tags.add(Tags.INTEL_NEW);
289 }
290 if (map != null) {
292 if (loc != null) {
293 float max = Global.getSettings().getFloat("maxRelayRangeInHyperspace");
295 if (dist <= max) {
296 tags.add(Tags.INTEL_LOCAL);
297 }
298 }
299 }
300
301// FactionAPI faction = getFactionForUIColors();
302// if (faction != null && !faction.isPlayerFaction()) {
303// if (faction.isHostileTo(Factions.PLAYER)) {
304// tags.add(Tags.INTEL_HOSTILE);
305// } else {
306// tags.add(Tags.INTEL_NOT_HOSTILE);
307// }
308// }
309
310 return tags;
311 }
312
313
314 public boolean isImportant() {
315 return important != null && important;
316 }
317
318 public void setImportant(Boolean important) {
319 this.important = important;
320 if (this.important != null && !this.important) {
321 this.important = null;
322 }
323 }
324
328
329 public boolean doesButtonHaveConfirmDialog(Object buttonId) {
330 if (buttonId == BUTTON_DELETE) {
331 return true;
332 }
333 return false;
334 }
335 public float getConfirmationPromptWidth(Object buttonId) {
336 return 550f;
337 }
338
340 prompt.addPara("Are you sure you want to permanently delete this fleet log entry?", Misc.getTextColor(), 0f);
341 }
342
343 public void createConfirmationPrompt(Object buttonId, TooltipMakerAPI prompt) {
344 if (buttonId == BUTTON_DELETE) {
346 }
347 }
348
349 public String getConfirmText(Object buttonId) {
350 return "Confirm";
351 }
352
353 public String getCancelText(Object buttonId) {
354 return "Cancel";
355 }
356
357 protected void addDeleteButton(TooltipMakerAPI info, float width) {
358 addDeleteButton(info, width, "Delete log entry");
359 }
360 protected void addDeleteButton(TooltipMakerAPI info, float width, String delete) {
361 float opad = 10f;
362 ButtonAPI button = info.addButton(delete, BUTTON_DELETE,
363 getFactionForUIColors().getBaseUIColor(), getFactionForUIColors().getDarkUIColor(),
364 (int)(width), 20f, opad * 2f);
365 button.setShortcut(Keyboard.KEY_G, true);
366 }
367
368 public void buttonPressConfirmed(Object buttonId, IntelUIAPI ui) {
369 if (buttonId == BUTTON_DELETE) {
371 ui.recreateIntelUI();
372 return;
373 }
374 ui.updateUIForItem(this);
375 }
376
377// public void buttonPressConfirmed(Object buttonId, IntelUIAPI ui) {
378// ui.updateUIForItem(this);
379// }
380
381 public void buttonPressCancelled(Object buttonId, IntelUIAPI ui) {
382 }
383
384 public boolean isPlayerVisible() {
385 if (isHidden()) return false;
386 if (isEnded()) return false;
387 return timestamp != null;
388 }
389
391 return timestamp;
392 }
393
395 this.timestamp = timestamp;
396 }
397
399 long ts = Global.getSector().getClock().getTimestamp();
400 if (timestamp != null) ts = timestamp;
402 }
403
404 public void reportPlayerClickedOn() {
405 neverClicked = null; // makes it lose "new" status
406 }
407
408 public boolean isNew() {
409 Long ts = getPlayerVisibleTimestamp();
410 if (ts == null) ts = 0L;
411 float days = Global.getSector().getClock().getElapsedDaysSince(ts);
412 return neverClicked != null && neverClicked && days < NEW_DAYS;
413 }
414
415 public void setNew(boolean isNew) {
416 if (isNew) {
417 neverClicked = true;
418 } else {
419 neverClicked = null;
420 }
421 }
422
423 public IntelSortTier getSortTier() {
424 if (isEnding()) {
425 return IntelSortTier.TIER_COMPLETED;
426 }
427 return IntelSortTier.TIER_3;
428 }
429
430 public String getSortString() {
433 }
434 return getName();
435 //return getName();
436 //return null;
437 }
438
439 public boolean autoAddCampaignMessage() {
440 return !isHidden();
441 }
442
443 public String getCommMessageSound() {
444 if (isSendingUpdate()) {
445 return getSoundStandardUpdate();
446 }
448 }
449
450
451 protected Boolean hidden = null;
452 public boolean isHidden() {
453 // never mind; handled by making comm relay in Galatia non-functional until the jump-point is stabilized
454 // but procurement missions etc generated inside Galatia still show up, so: need to do this
456 //return hidden != null;
457 }
458
459
460 public void setHidden(boolean hidden) {
461 if (hidden) {
462 this.hidden = hidden;
463 } else {
464 this.hidden = null;
465 }
466 }
467
468
470
471 }
472
473 protected float getCommRelayRange() {
474 return Global.getSettings().getFloat("maxRelayRangeInHyperspace");
475 }
476
477 public boolean canMakeVisibleToPlayer(boolean playerInRelayRange) {
478 return canMakeVisible(playerInRelayRange,
481 }
482
483 public boolean canMakeVisibleToCommSniffer(boolean playerInRelayRange, SectorEntityToken relay) {
484 return canMakeVisible(playerInRelayRange, relay.getContainingLocation(),
485 relay.getLocationInHyperspace(), true);
486 }
487
488 public boolean canMakeVisible(boolean playerInRelayRange, LocationAPI conLoc, Vector2f hyperLoc,
489 boolean commSniffer) {
490 if (isEnding()) return false;
491
492 if (postingLocation != null) {
493 float rangeLY = 0f;
494 if (postingRangeLY != null) {
495 rangeLY = postingRangeLY;
496 } else { // unless a range of 0 is specified, get local messages when nearing system
497 rangeLY = getCommRelayRange();
498 }
499
500 float commRange = 0f;
502 commRange = getCommRelayRange();
503 rangeLY = Math.max(rangeLY, commRange);
504 }
505
506 boolean sameLoc = postingLocation.getContainingLocation() != null &&
508 conLoc;
509 if (rangeLY <= 0 && !sameLoc) {
510 return false;
511 }
512
513 if (playerInRelayRange) {
515 hyperLoc);
516 return dist <= rangeLY;
517 } else {
520 hyperLoc);
521 return dist < commRange && (!commSniffer || playerInRelayRange);
522 } else {
523 return sameLoc && (!commSniffer || playerInRelayRange);
524 }
525 }
526 }
527
528 return playerInRelayRange;
529 }
530
534
536 this.postingLocation = postingLocation;
537 }
538
539 public Float getPostingRangeLY() {
540 return postingRangeLY;
541 }
542
545 }
546 public void setPostingRangeLY(Float postingRangeLY, boolean ensureVisibleOutsideSystem) {
547 if (ensureVisibleOutsideSystem) {
548 if (postingRangeLY == null) postingRangeLY = 0f;
550 }
551 this.postingRangeLY = postingRangeLY;
552 }
553
554
555 public void reportRemovedIntel() {
556
557 }
558
560 return null;
561 }
562
563
564 protected void bullet(TooltipMakerAPI info) {
565 info.setBulletedListMode(" - ");
566 if (listInfoParam != null && false) {
567 info.setTextWidthOverride(0);
568 } else {
570 }
571 }
572 protected void indent(TooltipMakerAPI info) {
573 info.setBulletedListMode(" ");
574 if (listInfoParam != null && false) {
575 info.setTextWidthOverride(0);
576 } else {
578 }
579 }
580 protected void unindent(TooltipMakerAPI info) {
581 info.setBulletedListMode(null);
582 info.setTextWidthOverride(0);
583 }
584
585 protected void addDays(TooltipMakerAPI info, String after, float days) {
586 addDays(info, after, days, null);
587 }
588 protected void addDays(TooltipMakerAPI info, String after, float days, Color c) {
589 addDays(info, after, days, c, 0f);
590 }
591 protected void addDays(TooltipMakerAPI info, String after, float days, Color c, float pad) {
592 addDays(info, "", after, days, c, pad);
593 }
594 protected void addDays(TooltipMakerAPI info, String before, String after, float days, Color c, float pad) {
595 String pre = "";
596 if (info.getBulletedListPrefix() != null) {
597 pre = "";
598 }
599
600 int d = (int) Math.round(days);
601 String daysStr = "days";
602 if (d <= 1) {
603 d = 1;
604 daysStr = "day";
605 }
606 if (c == null) c = Misc.getGrayColor();
607 info.addPara(before + pre + "%s " + daysStr + " " + after, pad, c,
608 Misc.getHighlightColor(), "" + d);
609 }
610
611 protected String getDays(float days) {
612 return "" + (int) Math.round(days);
613 }
614 public static String getDaysString(float days) {
615 int d = (int) Math.round(days);
616 String daysStr = "days";
617 if (d == 1) {
618 d = 1;
619 daysStr = "day";
620 }
621 return daysStr;
622 }
623
624 public String getSmallDescriptionTitle() {
625 return getName();
626 }
627
628 public Color getTitleColor(ListInfoMode mode) {
629 boolean isUpdate = getListInfoParam() != null;
630 if (isEnding() && !isUpdate && mode != ListInfoMode.IN_DESC) {
631 return Misc.getGrayColor();
632 }
634 }
635
636// public static Color getListMessageBulletColor() {
637// //return Misc.getGrayColor();
638// return Misc.getTextColor();
639// }
640//
641// public static Color getIntelListBulletColor() {
642// return Misc.getGrayColor();
643// //return Misc.getTextColor();
644// }
645
646 protected Color getBulletColorForMode(ListInfoMode mode) {
647 //boolean isUpdate = getListInfoParam() != null;
648 Color tc = Misc.getTextColor();
649 //if (true) return tc;
650 Color g = Misc.getGrayColor();
651 switch (mode) {
652 case INTEL: return g;
653 case MAP_TOOLTIP: return tc;
654 case IN_DESC: return tc;
655 case MESSAGES: return tc;
656 }
657
658 return g;
659 }
660
661
662 public boolean callEvent(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
663 return false;
664 }
665
666
667 public static String getSoundStandardPosting() {
668 return "ui_intel_something_posted";
669 }
670
671 public static String getSoundStandardUpdate() {
672 return "ui_intel_update";
673 }
674
675 public static String getSoundMajorPosting() {
676 return "ui_intel_major_posted";
677 }
678
679 public static String getSoundColonyThreat() {
680 return "colony_threat";
681 }
682
683 public static String getSoundLogUpdate() {
684 return "ui_intel_log_update";
685 }
686
687 public static String getSoundMinorMessage() {
688 return "ui_intel_minor_message";
689 }
690
691 public List<ArrowData> getArrowData(SectorMapAPI map) {
692 return null;
693 }
694
695
697 return 0;
698 }
699
700
701 public ButtonAPI addGenericButton(TooltipMakerAPI info, float width, String text, Object data) {
702 return addGenericButton(info, width,
703 getFactionForUIColors().getBaseUIColor(), getFactionForUIColors().getDarkUIColor(), text, data);
704 }
705 public ButtonAPI addGenericButton(TooltipMakerAPI info, float width, Color tc, Color bg, String text, Object data) {
706 float opad = 10f;
707 ButtonAPI button = info.addButton(text, data, tc, bg,
708 (int)(width), 20f, opad * 2f);
709 return button;
710 }
711
712
713 protected Boolean forceAdd = null;
714 public boolean forceAddNextFrame() {
715 return forceAdd != null;
716 }
717
718 public void setForceAddNextFrame(boolean add) {
719 if (add) {
720 forceAdd = true;
721 } else {
722 forceAdd = null;
723 }
724 }
725
726 public static void addMarketToList(TooltipMakerAPI info, MarketAPI market, float pad) {
727 addMarketToList(info, market, pad, null);
728 }
729
730 public static void addMarketToList(TooltipMakerAPI info, MarketAPI market, float pad, Color tc) {
731 if (tc == null) tc = Misc.getTextColor();
733 if (info.getBulletedListPrefix() != null) indent = "";
734 LabelAPI label = info.addPara(indent + market.getName() + " (size %s, %s)",
735 //faction.getPersonNamePrefixAOrAn() + " %s colony.",
736 pad, tc, market.getFaction().getBaseUIColor(),
737 "" + (int) market.getSize(),
738 market.getFaction().getDisplayName());
739
740 label.setHighlight("" + (int) market.getSize(), market.getFaction().getDisplayName());
742 }
743
744 public static void addMarketTable(TooltipMakerAPI info, Color base, Color dark, Color bright, List<MarketAPI> markets, float width, float pad) {
745 Color h = Misc.getHighlightColor();
747 info.beginTable(base, dark, bright, 20f, "Colony", 130f, "Faction", 130f, "Size", width - 260f);
748 for (MarketAPI market : markets) {
749 //info.addRow(Misc.getTextColor(), market.getName(),
750 info.addRow(market.getFaction().getBaseUIColor(), market.getName(),
751 market.getFaction().getBaseUIColor(), market.getFaction().getDisplayName(),
752 h, "" + market.getSize());
753 }
754
755 info.addTable("None", 0, pad);
756 info.addSpacer(5f);
757 }
758
760 return null;
761 }
762
763 public void storyActionConfirmed(Object buttonId, IntelUIAPI ui) {
764
765 }
766
768 // TODO Auto-generated method stub
769 return null;
770 }
771
772 public void tableRowClicked(IntelUIAPI ui, TableRowClickData data) {
773
774 }
775
776 public void addLogTimestamp(TooltipMakerAPI info, Color tc, float opad) {
777
778// if (!getTagsForSort().contains(Tags.INTEL_FLEET_LOG) && !getTagsForSort().contains(Tags.INTEL_EXPLORATION)) {
779 if (!getTagsForSort().contains(Tags.INTEL_FLEET_LOG) &&
780 !getTagsForSort().contains(Tags.INTEL_MARKER)) {
781 return;
782 }
783
784// {
785// float days = getDaysSincePlayerVisible();
786// if (days >= 1) {
787// addDays(info, "Log entry added ", "ago.", days, tc, opad);
788// } else {
789// info.addPara("Log entry added less than a day ago.", opad);
790// }
791// }
792
793 Color h = Misc.getHighlightColor();
794
795 long ts = Global.getSector().getClock().getTimestamp();
796 if (timestamp != null) ts = timestamp;
798
799// String dateStr = "Logged on c." + clock.getCycle() + ", " + clock.getShortMonthString() + " " + clock.getDay();
800// //tc = Misc.getGrayColor();
801// info.addPara(dateStr, opad, tc, h, "c." + clock.getCycle(), "" + clock.getDay());
802
803 long msPerMin = 60L * 1000L;
804 long msPerHour = msPerMin * 60L;
805 long msPerDay = msPerHour * 24L;
806 //long msPerWeek = msPerDay * 7L;
807 long msPerMonth = msPerDay * 30L;
808 long msPerCycle = msPerDay * 365L;
809
810 long diff = Global.getSector().getClock().getTimestamp() - ts;
811
812
813 String agoStr = "";
814 List<String> highlights = new ArrayList<>();
815// highlights.add("c." + clock.getCycle());
816// highlights.add("" + clock.getDay());
817 if (diff < msPerHour && false) {
818 long minutes = diff / msPerMin;
819 agoStr = "" + minutes + " " + (minutes == 1 ? "minute" : "minutes");
820 } else if (diff < msPerDay && false) {
821 long hours = diff / msPerHour;
822 agoStr = "" + hours + " " + (hours == 1 ? "hour" : "hours");
823 long rem = diff - hours * msPerHour;
824 long minutes = rem / msPerMin;
825 agoStr += " " + minutes + " " + (minutes == 1 ? "minute" : "minutes");
826 } else if (diff < msPerMonth) {
827 long days = diff / msPerDay;
828 agoStr = "" + days + " " + (days == 1 ? "day" : "days");
829 highlights.add("" + days);
830// long rem = diff - days * msPerDay;
831// long hours = rem / msPerHour;
832// agoStr += " " + hours + " " + (hours == 1 ? "hour" : "hours");
833 } else if (diff < msPerCycle) {
834 long months = diff / msPerMonth;
835 agoStr = "" + months + " " + (months == 1 ? "month" : "months");
836 long rem = diff - months * msPerMonth;
837 long days = rem / msPerDay;
838 agoStr += " and " + days + " " + (days == 1 ? "day" : "days");
839 highlights.add("" + months);
840 highlights.add("" + days);
841 } else {
842 long cycles = diff / msPerCycle;
843 agoStr = "" + cycles + " " + (cycles == 1 ? "cycle" : "cycles");
844 long rem = diff - cycles * msPerCycle;
845 long months = rem / msPerMonth;
846 agoStr += " and " + months + " " + (months == 1 ? "month" : "months");
847 highlights.add("" + cycles);
848 highlights.add("" + months);
849 }
850
851
852 //String dateStr = "Logged on c." + clock.getCycle() + ", " + clock.getShortMonthString() + " " + clock.getDay();
853 //tc = Misc.getGrayColor();
854 //info.addPara(dateStr + ", " + agoStr + " ago.", opad, tc, h, highlights.toArray(new String[0]));
855 long days = diff / msPerDay;
856 if (days >= 1) {
857 info.addPara("Log entry added " + agoStr + " ago.", opad, tc, h, highlights.toArray(new String[0]));
858 } else {
859 info.addPara("Log entry added less than a day ago.", opad);
860 }
861
862 //ago = Label.create(agoStr, Misc.getGrayColor());
863 }
864
865
866 public String getSortStringNewestFirst() {
867 return getSortStringNewestFirst("zzz");
868 }
869 public String getSortStringNewestFirst(String prefix) {
870 return prefix + String.format("%1$20s", "" + getPlayerVisibleTimestamp()).replace(' ', '0');
871 //return "Fleet Log " + getPlayerVisibleTimestamp();
872 }
873
874 @Override
875 public Set<String> getTagsForSort() {
876 if (tagsForSort == null) {
877 tagsForSort = new LinkedHashSet<>();
878 }
879 return tagsForSort;
880 }
881
882 @Override
883 public void setTagsForSort(Set<String> tagsForSort) {
884 this.tagsForSort = tagsForSort;
885 }
886
887
888}
889
890
891
892
893
894
static SettingsAPI getSettings()
Definition Global.java:57
static SectorAPI getSector()
Definition Global.java:65
void addDays(TooltipMakerAPI info, String before, String after, float days, Color c, float pad)
void buttonPressCancelled(Object buttonId, IntelUIAPI ui)
void addLogTimestamp(TooltipMakerAPI info, Color tc, float opad)
void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
static void addMarketTable(TooltipMakerAPI info, Color base, Color dark, Color bright, List< MarketAPI > markets, float width, float pad)
void createLargeDescription(CustomPanelAPI panel, float width, float height)
void sendUpdate(Object listInfoParam, TextPanelAPI textPanel)
void setPostingLocation(SectorEntityToken postingLocation)
ButtonAPI addGenericButton(TooltipMakerAPI info, float width, String text, Object data)
void addDays(TooltipMakerAPI info, String after, float days)
void addDeleteButton(TooltipMakerAPI info, float width, String delete)
void createConfirmationPrompt(Object buttonId, TooltipMakerAPI prompt)
boolean canMakeVisibleToCommSniffer(boolean playerInRelayRange, SectorEntityToken relay)
void addDays(TooltipMakerAPI info, String after, float days, Color c, float pad)
boolean callEvent(String ruleId, InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)
void storyActionConfirmed(Object buttonId, IntelUIAPI ui)
static void addMarketToList(TooltipMakerAPI info, MarketAPI market, float pad, Color tc)
void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode)
void sendUpdateIfPlayerHasIntel(Object listInfoParam, boolean onlyIfImportant)
void addDeleteButton(TooltipMakerAPI info, float width)
void buttonPressConfirmed(Object buttonId, IntelUIAPI ui)
void createSmallDescription(TooltipMakerAPI info, float width, float height)
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
StoryPointActionDelegate getButtonStoryPointActionDelegate(Object buttonId)
void sendUpdateIfPlayerHasIntel(Object listInfoParam, boolean onlyIfImportant, boolean sendIfHidden)
ButtonAPI addGenericButton(TooltipMakerAPI info, float width, Color tc, Color bg, String text, Object data)
boolean canMakeVisible(boolean playerInRelayRange, LocationAPI conLoc, Vector2f hyperLoc, boolean commSniffer)
void tableRowClicked(IntelUIAPI ui, TableRowClickData data)
void addDays(TooltipMakerAPI info, String after, float days, Color c)
static void addMarketToList(TooltipMakerAPI info, MarketAPI market, float pad)
boolean canMakeVisibleToPlayer(boolean playerInRelayRange)
void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode)
void setPostingRangeLY(Float postingRangeLY, boolean ensureVisibleOutsideSystem)
static Color getTextColor()
Definition Misc.java:839
static float getDistanceLY(SectorEntityToken from, SectorEntityToken to)
Definition Misc.java:602
static Color getNegativeHighlightColor()
Definition Misc.java:802
static Color getGrayColor()
Definition Misc.java:826
static Color getHighlightColor()
Definition Misc.java:792
CampaignClockAPI createClock(long timestamp)
void addIntelToTextPanel(IntelInfoPlugin plugin, TextPanelAPI textPanel)
void setShortcut(int key, boolean putLast)
TooltipMakerAPI createUIElement(float width, float height, boolean withScroller)
PositionAPI addUIElement(TooltipMakerAPI element)
void updateUIForItem(IntelInfoPlugin plugin)
void setHighlight(int start, int end)
void setHighlightColors(Color ... colors)
PositionAPI inTL(float xPad, float yPad)
void addTable(String emptyText, int andMore, float pad)
UIPanelAPI beginTable(FactionAPI faction, float itemHeight, Object ... columns)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)
UIComponentAPI addSpacer(float height)
void setTextWidthOverride(float textWidthOverride)
ButtonAPI addButton(String text, Object data, float width, float height, float pad)
void setBulletedListMode(String itemPrefix)