Starsector API
Loading...
Searching...
No Matches
LuddicChurchImmigrationDeal.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel;
2
3import java.awt.Color;
4import java.util.Set;
5
6import org.lwjgl.input.Keyboard;
7
8import com.fs.starfarer.api.Global;
9import com.fs.starfarer.api.campaign.FactionAPI;
10import com.fs.starfarer.api.campaign.InteractionDialogAPI;
11import com.fs.starfarer.api.campaign.SectorEntityToken;
12import com.fs.starfarer.api.campaign.TextPanelAPI;
13import com.fs.starfarer.api.impl.campaign.ids.Factions;
14import com.fs.starfarer.api.impl.campaign.ids.Tags;
15import com.fs.starfarer.api.impl.campaign.intel.events.LuddicChurchHostileActivityFactor;
16import com.fs.starfarer.api.impl.campaign.rulecmd.HA_CMD;
17import com.fs.starfarer.api.ui.ButtonAPI;
18import com.fs.starfarer.api.ui.IntelUIAPI;
19import com.fs.starfarer.api.ui.SectorMapAPI;
20import com.fs.starfarer.api.ui.TooltipMakerAPI;
21import com.fs.starfarer.api.util.Misc;
22
24
25 public static enum AgreementEndingType {
26 BROKEN,
27 }
28
29 public static float REP_FOR_BREAKING_DEAL = 0.25f;
30
31 public static String KEY = "$luddicChurchDeal_ref";
35
36 public static String BUTTON_END = "End";
37
38 public static String UPDATE_PARAM_ACCEPTED = "update_param_accepted";
39
40 protected FactionAPI faction = null;
41 protected AgreementEndingType endType = null;
42
45
46 setImportant(true);
48
49 TextPanelAPI text = null;
50 if (dialog != null) text = dialog.getTextPanel();
51
52 //Global.getSector().getListenerManager().addListener(this);
54
56
58
60 }
61
62 @Override
63 protected void notifyEnding() {
64 super.notifyEnding();
65
68 }
69
70 @Override
71 protected void notifyEnded() {
72 super.notifyEnded();
73 }
74
75 protected Object readResolve() {
76 return this;
77 }
78
79 public String getBaseName() {
80 return "Luddic Church Immigration Controls";
81 }
82
83 public String getAcceptedPostfix() {
84 return "Accepted";
85 }
86
87 public String getBrokenPostfix() {
88 return "Ended";
89
90 }
91
92 public String getName() {
93 String postfix = "";
94 if (isEnding() && endType != null) {
95 switch (endType) {
96 case BROKEN:
97 postfix = " - " + getBrokenPostfix();
98 break;
99 }
100 }
102 postfix = " - " + getAcceptedPostfix();
103 }
104 return getBaseName() + postfix;
105 }
106
107 @Override
109 return faction;
110 }
111
112 public String getSmallDescriptionTitle() {
113 return getName();
114 }
115
116 protected void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode) {
117 Color h = Misc.getHighlightColor();
118 Color g = Misc.getGrayColor();
119 float pad = 3f;
120 float opad = 10f;
121
122 float initPad = pad;
123 if (mode == ListInfoMode.IN_DESC) initPad = opad;
124
125 Color tc = getBulletColorForMode(mode);
126
127 bullet(info);
128 boolean isUpdate = getListInfoParam() != null;
129
130// if (getListInfoParam() == UPDATE_PARAM_ACCEPTED) {
131// return;
132// }
133
134
135
136 unindent(info);
137 }
138
139
140 public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
141 Color h = Misc.getHighlightColor();
142 Color g = Misc.getGrayColor();
143 Color tc = Misc.getTextColor();
144 float pad = 3f;
145 float opad = 10f;
146
147 info.addImage(getFaction().getLogo(), width, 128, opad);
148
149 if (isEnding() || isEnded()) {
150 info.addPara("You are no longer abiding by your agreement with the Luddic Church.", opad);
151 return;
152 }
153
154 info.addPara("You've made an agreement with the Luddic Church, curtailing "
155 + "excessive immigration from their worlds. In exchange, the Knights of Ludd \"protector\" "
156 + "fleets no longer operate in your volume.",
157 opad, faction.getBaseUIColor(), "Luddic Church", "Knights of Ludd");
158
159 info.addPara("You can end this agreement, but there "
160 + "would be no possibility of re-negotiating a similar agreement after "
161 + "demonstrating such faithlessness.", opad);
162
163 ButtonAPI button = info.addButton("End the agreement", BUTTON_END,
164 getFactionForUIColors().getBaseUIColor(), getFactionForUIColors().getDarkUIColor(),
165 (int)(width), 20f, opad * 1f);
166 button.setShortcut(Keyboard.KEY_U, true);
167
168 }
169
170
171 public String getIcon() {
172 return faction.getCrest();
173 }
174
175 public Set<String> getIntelTags(SectorMapAPI map) {
176 Set<String> tags = super.getIntelTags(map);
177 tags.add(Tags.INTEL_AGREEMENTS);
178 tags.add(faction.getId());
179 return tags;
180 }
181
182 @Override
183 public String getImportantIcon() {
184 return Global.getSettings().getSpriteName("intel", "important_accepted_mission");
185 }
186
187 @Override
189 return null;
190 }
191
192
194 return faction;
195 }
196
197 public void endAgreement(AgreementEndingType type, InteractionDialogAPI dialog) {
198 if (!isEnded() && !isEnding()) {
199 endType = type;
200 setImportant(false);
201 //endAfterDelay();
203
204 if (dialog != null) {
205 sendUpdate(new Object(), dialog.getTextPanel());
206 }
207
208 if (type == AgreementEndingType.BROKEN) {
211 TextPanelAPI text = dialog == null ? null : dialog.getTextPanel();
213 }
214 }
215 }
216
217
218 @Override
219 public void buttonPressConfirmed(Object buttonId, IntelUIAPI ui) {
220 if (buttonId == BUTTON_END) {
221 endAgreement(AgreementEndingType.BROKEN, null);
222 }
223 super.buttonPressConfirmed(buttonId, ui);
224 }
225
226
227 @Override
228 public void createConfirmationPrompt(Object buttonId, TooltipMakerAPI prompt) {
229 if (buttonId == BUTTON_END) {
230 prompt.addPara("You can end this agreement, but taking this action would "
231 + "hurt your standing with the %s, and there "
232 + "would be no possibility of re-negotiating a similar agreement after "
233 + "demonstrating such faithlessness.", 0f,
235 }
236
237 }
238
239 @Override
240 public boolean doesButtonHaveConfirmDialog(Object buttonId) {
241 if (buttonId == BUTTON_END) {
242 return true;
243 }
244 return super.doesButtonHaveConfirmDialog(buttonId);
245 }
246
247
248}
249
250
251
252
253
254
static SettingsAPI getSettings()
Definition Global.java:57
static SectorAPI getSector()
Definition Global.java:65
void sendUpdate(Object listInfoParam, TextPanelAPI textPanel)
void endAgreement(AgreementEndingType type, InteractionDialogAPI dialog)
void createSmallDescription(TooltipMakerAPI info, float width, float height)
static Color getTextColor()
Definition Misc.java:839
static void incrUntrustwortyCount()
Definition Misc.java:6622
static Color getGrayColor()
Definition Misc.java:826
static void adjustRep(float repChangeFaction, RepLevel limit, String factionId, float repChangePerson, RepLevel personLimit, PersonAPI person, TextPanelAPI text)
Definition Misc.java:3884
static Color getHighlightColor()
Definition Misc.java:792
String getSpriteName(String category, String id)
FactionAPI getFaction(String factionId)
void set(String key, Object value)
void setShortcut(int key, boolean putLast)
void addImage(String spriteName, float pad)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)
ButtonAPI addButton(String text, Object data, float width, float height, float pad)