Starsector API
Loading...
Searching...
No Matches
HIOrdersInteractionDialogPluginImpl.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.inspection;
2
3import java.awt.Color;
4import java.util.Map;
5
6import org.lwjgl.input.Keyboard;
7
8import com.fs.starfarer.api.Global;
9import com.fs.starfarer.api.campaign.CampaignFleetAPI;
10import com.fs.starfarer.api.campaign.InteractionDialogAPI;
11import com.fs.starfarer.api.campaign.InteractionDialogPlugin;
12import com.fs.starfarer.api.campaign.OptionPanelAPI;
13import com.fs.starfarer.api.campaign.TextPanelAPI;
14import com.fs.starfarer.api.campaign.VisualPanelAPI;
15import com.fs.starfarer.api.campaign.rules.MemoryAPI;
16import com.fs.starfarer.api.combat.EngagementResultAPI;
17import com.fs.starfarer.api.impl.campaign.ids.Sounds;
18import com.fs.starfarer.api.impl.campaign.intel.events.HegemonyHostileActivityFactor;
19import com.fs.starfarer.api.impl.campaign.intel.inspection.HegemonyInspectionIntel.AntiInspectionOrders;
20import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
21import com.fs.starfarer.api.impl.campaign.rulecmd.SetStoryOption;
22import com.fs.starfarer.api.ui.IntelUIAPI;
23import com.fs.starfarer.api.util.Misc;
24
25public class HIOrdersInteractionDialogPluginImpl implements InteractionDialogPlugin {
26
27 //public static float BRIBE_BASE = 0;
28 public static int BRIBE_MULT = 200000;
29 public static int BRIBE_MAX = 500000;
30
31 private static enum OptionId {
32 INIT,
33 COMPLY,
34 BRIBE,
35 RESIST,
36 LEAVE,
37
38 CONFIRM,
39 CANCEL,
40
41 HIDE, // too similar to "bribe"; not adding
42 }
43
44 protected InteractionDialogAPI dialog;
45 protected TextPanelAPI textPanel;
46 protected OptionPanelAPI options;
47 protected VisualPanelAPI visual;
48
49 protected CampaignFleetAPI playerFleet;
50
52 protected IntelUIAPI ui;
53
55 this.intel = intel;
56 this.ui = ui;
57 }
58
59 public void init(InteractionDialogAPI dialog) {
60 this.dialog = dialog;
61 textPanel = dialog.getTextPanel();
62 options = dialog.getOptionPanel();
63 visual = dialog.getVisualPanel();
64
65 playerFleet = Global.getSector().getPlayerFleet();
66
67 visual.setVisualFade(0.25f, 0.25f);
68 //visual.showImagePortion("illustrations", "quartermaster", 640, 400, 0, 0, 480, 300);
69 visual.showPlanetInfo(intel.getTarget().getPrimaryEntity());
70
71 dialog.setOptionOnEscape("Leave", OptionId.LEAVE);
72
73 optionSelected(null, OptionId.INIT);
74 }
75
76 public Map<String, MemoryAPI> getMemoryMap() {
77 return null;
78 }
79
80 public void backFromEngagement(EngagementResultAPI result) {
81 // no combat here, so this won't get called
82 }
83
84 protected int computeBribeAmount() {
85// float threshold = HegemonyInspectionManager.getInstance().getThreshold();
86// int bribe = (int) Math.round(BRIBE_BASE + threshold * BRIBE_MULT);
87// return bribe;
88
89 //int bribe = (int) (Math.pow(1.5f, HegemonyInspectionManager.getInstance().getNumAttempts()) * BRIBE_MULT);
90 int bribe = (int) (Math.pow(1.5f, HegemonyHostileActivityFactor.getInspectionAttempts()) * BRIBE_MULT);
91 if (bribe > BRIBE_MAX) bribe = BRIBE_MAX;
92 return bribe;
93
94// int bribe = 20000;
95// for (String id : intel.getExpectedCores()) {
96// CommoditySpecAPI spec = Global.getSettings().getCommoditySpec(id);
97// bribe += spec.getBasePrice() * 2;
98// }
99// return bribe;
100 }
101
102 protected void printOptionDesc(AntiInspectionOrders orders, boolean inConfirm) {
103 switch (orders) {
104 case BRIBE:
105 int bribe = computeBribeAmount();
106 textPanel.addPara("Sufficient funding allocated to proper official and unofficial actors should " +
107 "ensure that the inspection reaches a satisfactory outcome.");
108
109 if (inConfirm) {
110 textPanel.addPara("Once this order is given and the funds and agents dispatched, it can not be " +
111 "rescinded.");
112
113 int credits = (int) playerFleet.getCargo().getCredits().get();
114 Color costColor = Misc.getHighlightColor();
115 if (bribe > credits) costColor = Misc.getNegativeHighlightColor();
116
117// textPanel.addPara("A total of %s should be enough to get the job done. " +
118// "It's more expensive than the cores involved, " +
119// "but guarantees that your standing with the Hegemony will not suffer.", costColor,
120// Misc.getDGSCredits(bribe));
121 textPanel.addPara("A total of %s should be enough to get the job done. " +
122 "and guarantees that your standing with the Hegemony will not suffer.", costColor,
123 Misc.getDGSCredits(bribe));
124
125 textPanel.addPara("You have %s available.", Misc.getHighlightColor(),
126 Misc.getDGSCredits(credits));
127 } else {
128 textPanel.addPara("You've allocated %s to the task and have otherwise committed to this course of action.",
129 Misc.getHighlightColor(), Misc.getDGSCredits(bribe));
130// textPanel.addPara("You've allocated %s to the task. Giving different orders will allow you to recover these funds.", Misc.getHighlightColor(),
131// Misc.getDGSCredits(bribe));
132 }
133 break;
134 case COMPLY:
135 textPanel.addPara("The local authorities will comply with the inspection. This will result " +
136 "in all AI cores being found and confiscated, and will cause your standing with the Hegemony " +
137 "to fall based on the nuber of AI cores found.");
138 textPanel.addPara("If AI cores currently in use are removed or moved off-planet, this activity will " +
139 "surely leave traces for inspectors to find, inspiring them to much greater zeal.");
140 break;
141 case RESIST:
142 textPanel.addPara("All space and ground forces available will resist the inspection.");
143 textPanel.addPara("If the inspection reaches the surface, " +
144 "the ground defense strength will determine whether " +
145 "they're able to confiscate any AI cores.");
146 textPanel.addPara("The Hegemony will become aware of this - and hostile - when the inspection task force " +
147 "enters the star system.");
148 break;
149 }
150 }
151
152 protected void addChoiceOptions() {
153 options.clearOptions();
154
155 AntiInspectionOrders curr = intel.getOrders();
156 if (curr != AntiInspectionOrders.BRIBE) {
157 options.addOption("Order the local authorities to comply with the inspection", OptionId.COMPLY, null);
158 options.addOption("Allocate sufficient funds to bribe or otherwise handle the inspectors", OptionId.BRIBE, null);
159 options.addOption("Order your local forces to resist the inspection", OptionId.RESIST, null);
160
161 dialog.setOptionColor(OptionId.BRIBE, Misc.getStoryOptionColor());
162 }
163
164 options.addOption("Dismiss", OptionId.LEAVE, null);
165 options.setShortcut(OptionId.LEAVE, Keyboard.KEY_ESCAPE, false, false, false, true);
166
167 if (curr == AntiInspectionOrders.COMPLY) {
168 options.setEnabled(OptionId.COMPLY, false);
169 }
170 if (curr == AntiInspectionOrders.BRIBE) {
171 options.setEnabled(OptionId.BRIBE, false);
172 }
173 if (curr == AntiInspectionOrders.RESIST) {
174 options.setEnabled(OptionId.RESIST, false);
175 }
176 }
177
178 protected AntiInspectionOrders beingConfirmed = null;
179 protected void addConfirmOptions() {
180 if (beingConfirmed == null) return;
181
182 options.clearOptions();
183
185
186 options.addOption("Confirm your orders", OptionId.CONFIRM, null);
187 options.addOption("Never mind", OptionId.CANCEL, null);
188 options.setShortcut(OptionId.CANCEL, Keyboard.KEY_ESCAPE, false, false, false, true);
189
190 if (beingConfirmed == AntiInspectionOrders.BRIBE) {
191 int bribe = computeBribeAmount();
192 if (bribe > playerFleet.getCargo().getCredits().get()) {
193 options.setEnabled(OptionId.CONFIRM, false);
194 options.setTooltip(OptionId.CONFIRM, "Not enough credits.");
195 }
196
197 SetStoryOption.set(dialog, 1, OptionId.CONFIRM, "bribeAICoreInspection", Sounds.STORY_POINT_SPEND_TECHNOLOGY,
198 "Issued bribe to prevent " + intel.getFaction().getDisplayName() + " AI core inspection");
199// StoryOptionParams params = new StoryOptionParams(OptionId.BRIBE, 1, "bribeAICoreInspection", Sounds.STORY_POINT_SPEND_TECHNOLOGY);
200// SetStoryOption.set(dialog, params, new BaseOptionStoryPointActionDelegate(dialog, params) {
201// @Override
202// public void createDescription(TooltipMakerAPI info) {
203// float opad = 10f;
204// info.setParaInsigniaLarge();
205// info.addPara("Virtually guarantees that the inspection will not find any AI cores.",
206// -opad);
207// info.addSpacer(opad * 2f);
208// addActionCostSection(info);
209// }
210// });
211 }
212 }
213
214
215
216 public void optionSelected(String text, Object optionData) {
217 if (optionData == null) return;
218
219 OptionId option = (OptionId) optionData;
220
221 if (text != null) {
222 //textPanel.addParagraph(text, Global.getSettings().getColor("buttonText"));
223 dialog.addOptionSelectedText(option);
224 }
225
226 switch (option) {
227 case INIT:
230 break;
231 case COMPLY:
232 beingConfirmed = AntiInspectionOrders.COMPLY;
234 break;
235 case BRIBE:
236 beingConfirmed = AntiInspectionOrders.BRIBE;
238 break;
239 case RESIST:
240 beingConfirmed = AntiInspectionOrders.RESIST;
242 break;
243 case CONFIRM:
244 int invested = intel.getInvestedCredits();
245 if (invested > 0) {
246 AddRemoveCommodity.addCreditsGainText(invested, textPanel);
247 playerFleet.getCargo().getCredits().add(invested);
249 }
250
252 if (beingConfirmed == AntiInspectionOrders.BRIBE) {
253 int bribe = computeBribeAmount();
255 AddRemoveCommodity.addCreditsLossText(bribe, textPanel);
256 playerFleet.getCargo().getCredits().subtract(bribe);
257 } else {
258
259 }
260
262 //leave();
263 break;
264 case CANCEL:
266 break;
267 case LEAVE:
268 leave();
269 break;
270 }
271 }
272
273 protected void leave() {
274 dialog.dismiss();
275 if (ui != null) ui.updateUIForItem(intel);
276 }
277
278
279 public void optionMousedOver(String optionText, Object optionData) {
280
281 }
282
283 public void advance(float amount) {
284
285 }
286
287 public Object getContext() {
288 return null;
289 }
290}
291
292
293
static SectorAPI getSector()
Definition Global.java:59