Starsector API
Loading...
Searching...
No Matches
TutorialTransponderDialogPluginImpl.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.tutorial;
2
3import java.util.Map;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.campaign.CampaignFleetAPI;
7import com.fs.starfarer.api.campaign.InteractionDialogAPI;
8import com.fs.starfarer.api.campaign.InteractionDialogPlugin;
9import com.fs.starfarer.api.campaign.OptionPanelAPI;
10import com.fs.starfarer.api.campaign.TextPanelAPI;
11import com.fs.starfarer.api.campaign.VisualPanelAPI;
12import com.fs.starfarer.api.campaign.PersistentUIDataAPI.AbilitySlotsAPI;
13import com.fs.starfarer.api.campaign.econ.MarketAPI;
14import com.fs.starfarer.api.campaign.rules.MemoryAPI;
15import com.fs.starfarer.api.combat.EngagementResultAPI;
16import com.fs.starfarer.api.impl.campaign.ids.Abilities;
17import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
18import com.fs.starfarer.api.loading.AbilitySpecAPI;
19import com.fs.starfarer.api.util.Misc;
20
21public class TutorialTransponderDialogPluginImpl implements InteractionDialogPlugin {
22
23 public static enum OptionId {
24 INIT,
25 CONT1,
26 CONT2,
27 CONT3,
28 CONT4,
29 CONT5,
30 CONT6,
31 ;
32 }
33
34 protected InteractionDialogAPI dialog;
35 protected TextPanelAPI textPanel;
36 protected OptionPanelAPI options;
37 protected VisualPanelAPI visual;
38
39 protected CampaignFleetAPI playerFleet;
40
41 protected MarketAPI ancyra;
42
44 this.ancyra = ancyra;
45 }
46
47 public void init(InteractionDialogAPI dialog) {
48 this.dialog = dialog;
49 textPanel = dialog.getTextPanel();
50 options = dialog.getOptionPanel();
51 visual = dialog.getVisualPanel();
52
53 playerFleet = Global.getSector().getPlayerFleet();
54
55 //visual.showImagePortion("illustrations", "jump_point_hyper", 640, 400, 0, 0, 480, 300);
56 visual.showFleetInfo("Your fleet", playerFleet, null, null);
57
58 //dialog.setOptionOnEscape("Leave", OptionId.LEAVE);
59
60 optionSelected(null, OptionId.INIT);
61 }
62
63 public Map<String, MemoryAPI> getMemoryMap() {
64 return null;
65 }
66
67 public void backFromEngagement(EngagementResultAPI result) {
68 // no combat here, so this won't get called
69 }
70
71 public void optionSelected(String text, Object optionData) {
72 if (optionData == null) return;
73
74 OptionId option = (OptionId) optionData;
75
76 if (text != null) {
77 //textPanel.addParagraph(text, Global.getSettings().getColor("buttonText"));
78 dialog.addOptionSelectedText(option);
79 }
80
81
82 String name = ancyra.getName();
83
84 switch (option) {
85 case INIT:
86 textPanel.addParagraph("Your fleet is getting closer to " + name + ", which is controlled by the Hegemony - " +
87 "a major militaristic faction in the Sector.");
88
89 textPanel.addParagraph("While in Hegemony space, a fleet is required by law to identify itself by keeping its transponder turned on. " +
90 "This is a view shared by most, though not all, major factions.");
91
92 options.clearOptions();
93 options.addOption("Continue", OptionId.CONT1, null);
94 break;
95 case CONT1:
96 textPanel.addParagraph("Turning on the transponder makes your fleet highly visible, " +
97 "and everyone seeing it will know who you are - unlike that pirate fleet you fought earlier, " +
98 "which had to be very close to positively identify.");
99 options.clearOptions();
100 options.addOption("Continue", OptionId.CONT2, null);
101 break;
102 case CONT2:
103 textPanel.addParagraph("Keeping your transponder on is a crippling disadvantage in hostile space, " +
104 "but as we're getting closer to port and we'd like to dock there, it's a good idea to turn it on.");
105
106 AbilitySpecAPI ability = Global.getSettings().getAbilitySpec(Abilities.TRANSPONDER);
107 Global.getSector().getCharacterData().addAbility(ability.getId());
108 AbilitySlotsAPI slots = Global.getSector().getUIData().getAbilitySlotsAPI();
109 slots.setCurrBarIndex(0);
110
111 int slotIndex = 0;
112 slots.getCurrSlotsCopy().get(slotIndex).setAbilityId(ability.getId());
113 AddRemoveCommodity.addAbilityGainText(ability.getId(), textPanel);
114
115 options.clearOptions();
116 options.addOption("Continue", OptionId.CONT3, null);
117 case CONT3:
118 ability = Global.getSettings().getAbilitySpec(Abilities.TRANSPONDER);
119 textPanel.addPara("Activate the %s before getting closer to " + ancyra.getName() + ", both to " +
120 "avoid unwanted attention from patrols and to receive docking clearance.",
121 Misc.getHighlightColor(),
122 "\"" + ability.getName() + "\"");
123
124 textPanel.addPara("Since turning it on and off has major consequences, " +
125 "it requires a double-tap to turn on or off - once to prime, and once more to confirm.",
126 Misc.getHighlightColor(),
127 "double-tap");
128
129 options.clearOptions();
130 options.addOption("Finish", OptionId.CONT4, null);
131 break;
132 case CONT4:
133 Global.getSector().setPaused(false);
134 dialog.dismiss();
135 break;
136 }
137 }
138
139
140
141
142 public void optionMousedOver(String optionText, Object optionData) {
143
144 }
145
146 public void advance(float amount) {
147
148 }
149
150 public Object getContext() {
151 return null;
152 }
153}
154
155
156
static SettingsAPI getSettings()
Definition Global.java:51
static SectorAPI getSector()
Definition Global.java:59
AbilitySpecAPI getAbilitySpec(String abilityId)