Starsector API
Loading...
Searching...
No Matches
TutorialWelcomeDialogPluginImpl.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.rules.MemoryAPI;
14import com.fs.starfarer.api.combat.EngagementResultAPI;
15import com.fs.starfarer.api.impl.campaign.ids.Abilities;
16import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
17import com.fs.starfarer.api.loading.AbilitySpecAPI;
18import com.fs.starfarer.api.util.Misc;
19
20public class TutorialWelcomeDialogPluginImpl implements InteractionDialogPlugin {
21
22 public static enum OptionId {
23 INIT,
24 CONT1,
25 CONT2,
26 //LEAVE,
27 ;
28 }
29
30 protected InteractionDialogAPI dialog;
31 protected TextPanelAPI textPanel;
32 protected OptionPanelAPI options;
33 protected VisualPanelAPI visual;
34
35 protected CampaignFleetAPI playerFleet;
36
37 public void init(InteractionDialogAPI dialog) {
38 this.dialog = dialog;
39 textPanel = dialog.getTextPanel();
40 options = dialog.getOptionPanel();
41 visual = dialog.getVisualPanel();
42
43 playerFleet = Global.getSector().getPlayerFleet();
44
45 //visual.showImagePortion("illustrations", "jump_point_hyper", 640, 400, 0, 0, 480, 300);
46 visual.showFleetInfo("Your fleet", playerFleet, null, null);
47
48 //dialog.setOptionOnEscape("Leave", OptionId.LEAVE);
49
50 optionSelected(null, OptionId.INIT);
51 }
52
53 public Map<String, MemoryAPI> getMemoryMap() {
54 return null;
55 }
56
57 public void backFromEngagement(EngagementResultAPI result) {
58 // no combat here, so this won't get called
59 }
60
61 public void optionSelected(String text, Object optionData) {
62 if (optionData == null) return;
63
64 OptionId option = (OptionId) optionData;
65
66 if (text != null) {
67 //textPanel.addParagraph(text, Global.getSettings().getColor("buttonText"));
68 dialog.addOptionSelectedText(option);
69 }
70
71 switch (option) {
72 case INIT:
73 textPanel.addParagraph("Welcome to the Persean Sector! " +
74 "Your fleet is in the middle of nowhere and critically low on supplies.");
75
76 textPanel.addParagraph("If you don't acquire more supplies, " +
77 "your fleet will suffer through a slow but ultimately fatal decline.");
78
79 options.clearOptions();
80 options.addOption("Continue", OptionId.CONT1, null);
81 break;
82 case CONT1:
83
84 AbilitySpecAPI ability = Global.getSettings().getAbilitySpec(Abilities.SCAVENGE);
85 textPanel.addPara("Fortunately, there's a debris field nearby. " +
86 "Move up into it and activate your %s ability to search it for useful cargo.",
87 Misc.getHighlightColor(),
88 "\"" + ability.getName() + "\"");
89
90 //textPanel.addParagraph("It's possible to scavenge through the same debris field multiple times, but there are diminishing returns and increased risk with each attempt. Only scavenge once here.");
91 textPanel.addParagraph("Scavenging requires Heavy Machinery, but there is some in your cargo holds.");
92
93 Global.getSector().getCharacterData().addAbility(ability.getId());
94 AbilitySlotsAPI slots = Global.getSector().getUIData().getAbilitySlotsAPI();
95 slots.setCurrBarIndex(0);
96
97 int slotIndex = 5;
98 slots.getCurrSlotsCopy().get(slotIndex).setAbilityId(ability.getId());
99 AddRemoveCommodity.addAbilityGainText(ability.getId(), textPanel);
100
101 textPanel.addParagraph("Make sure to take all of the supplies and any other valuable cargo, but feel free to leave the cheap and bulky metals behind.");
102 textPanel.addParagraph("To get your fleet moving, click on empty space in the direction you want to move.");
103
104 options.clearOptions();
105 options.addOption("Finish", OptionId.CONT2, null);
106 break;
107 case CONT2:
108 Global.getSector().setPaused(false);
109 dialog.dismiss();
110 break;
111 }
112 }
113
114
115
116
117 public void optionMousedOver(String optionText, Object optionData) {
118
119 }
120
121 public void advance(float amount) {
122
123 }
124
125 public Object getContext() {
126 return null;
127 }
128}
129
130
131
static SettingsAPI getSettings()
Definition Global.java:51
static SectorAPI getSector()
Definition Global.java:59
AbilitySpecAPI getAbilitySpec(String abilityId)