001package com.fs.starfarer.api.impl.campaign.tutorial;
002
003import java.util.Map;
004
005import com.fs.starfarer.api.Global;
006import com.fs.starfarer.api.campaign.CampaignFleetAPI;
007import com.fs.starfarer.api.campaign.InteractionDialogAPI;
008import com.fs.starfarer.api.campaign.InteractionDialogPlugin;
009import com.fs.starfarer.api.campaign.OptionPanelAPI;
010import com.fs.starfarer.api.campaign.TextPanelAPI;
011import com.fs.starfarer.api.campaign.VisualPanelAPI;
012import com.fs.starfarer.api.campaign.PersistentUIDataAPI.AbilitySlotsAPI;
013import com.fs.starfarer.api.campaign.econ.MarketAPI;
014import com.fs.starfarer.api.campaign.rules.MemoryAPI;
015import com.fs.starfarer.api.combat.EngagementResultAPI;
016import com.fs.starfarer.api.impl.campaign.ids.Abilities;
017import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
018import com.fs.starfarer.api.loading.AbilitySpecAPI;
019import com.fs.starfarer.api.util.Misc;
020
021public class TutorialTransponderDialogPluginImpl implements InteractionDialogPlugin {
022
023        public static enum OptionId {
024                INIT,
025                CONT1,
026                CONT2,
027                CONT3,
028                CONT4,
029                CONT5,
030                CONT6,
031                ;
032        }
033        
034        protected InteractionDialogAPI dialog;
035        protected TextPanelAPI textPanel;
036        protected OptionPanelAPI options;
037        protected VisualPanelAPI visual;
038        
039        protected CampaignFleetAPI playerFleet;
040        
041        protected MarketAPI ancyra;
042        
043        public TutorialTransponderDialogPluginImpl(MarketAPI ancyra) {
044                this.ancyra = ancyra;
045        }
046
047        public void init(InteractionDialogAPI dialog) {
048                this.dialog = dialog;
049                textPanel = dialog.getTextPanel();
050                options = dialog.getOptionPanel();
051                visual = dialog.getVisualPanel();
052
053                playerFleet = Global.getSector().getPlayerFleet();
054                
055                //visual.showImagePortion("illustrations", "jump_point_hyper", 640, 400, 0, 0, 480, 300);
056                visual.showFleetInfo("Your fleet", playerFleet, null, null);
057        
058                //dialog.setOptionOnEscape("Leave", OptionId.LEAVE);
059                
060                optionSelected(null, OptionId.INIT);
061        }
062        
063        public Map<String, MemoryAPI> getMemoryMap() {
064                return null;
065        }
066        
067        public void backFromEngagement(EngagementResultAPI result) {
068                // no combat here, so this won't get called
069        }
070        
071        public void optionSelected(String text, Object optionData) {
072                if (optionData == null) return;
073                
074                OptionId option = (OptionId) optionData;
075                
076                if (text != null) {
077                        //textPanel.addParagraph(text, Global.getSettings().getColor("buttonText"));
078                        dialog.addOptionSelectedText(option);
079                }
080                
081                
082                String name = ancyra.getName();
083                
084                switch (option) {
085                case INIT:
086                        textPanel.addParagraph("Your fleet is getting closer to " + name + ", which is controlled by the Hegemony - " +
087                                        "a major militaristic faction in the Sector.");
088                        
089                        textPanel.addParagraph("While in Hegemony space, a fleet is required by law to identify itself by keeping its transponder turned on. " +
090                                        "This is a view shared by most, though not all, major factions.");
091                        
092                        options.clearOptions();
093                        options.addOption("Continue", OptionId.CONT1, null);
094                        break;
095                case CONT1:
096                        textPanel.addParagraph("Turning on the transponder makes your fleet highly visible, " +
097                                        "and everyone seeing it will know who you are - unlike that pirate fleet you fought earlier, " +
098                                        "which had to be very close to positively identify.");
099                        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