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.rules.MemoryAPI; 014import com.fs.starfarer.api.combat.EngagementResultAPI; 015import com.fs.starfarer.api.impl.campaign.ids.Abilities; 016import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity; 017import com.fs.starfarer.api.loading.AbilitySpecAPI; 018import com.fs.starfarer.api.util.Misc; 019 020public class TutorialWelcomeDialogPluginImpl implements InteractionDialogPlugin { 021 022 public static enum OptionId { 023 INIT, 024 CONT1, 025 CONT2, 026 //LEAVE, 027 ; 028 } 029 030 protected InteractionDialogAPI dialog; 031 protected TextPanelAPI textPanel; 032 protected OptionPanelAPI options; 033 protected VisualPanelAPI visual; 034 035 protected CampaignFleetAPI playerFleet; 036 037 public void init(InteractionDialogAPI dialog) { 038 this.dialog = dialog; 039 textPanel = dialog.getTextPanel(); 040 options = dialog.getOptionPanel(); 041 visual = dialog.getVisualPanel(); 042 043 playerFleet = Global.getSector().getPlayerFleet(); 044 045 //visual.showImagePortion("illustrations", "jump_point_hyper", 640, 400, 0, 0, 480, 300); 046 visual.showFleetInfo("Your fleet", playerFleet, null, null); 047 048 //dialog.setOptionOnEscape("Leave", OptionId.LEAVE); 049 050 optionSelected(null, OptionId.INIT); 051 } 052 053 public Map<String, MemoryAPI> getMemoryMap() { 054 return null; 055 } 056 057 public void backFromEngagement(EngagementResultAPI result) { 058 // no combat here, so this won't get called 059 } 060 061 public void optionSelected(String text, Object optionData) { 062 if (optionData == null) return; 063 064 OptionId option = (OptionId) optionData; 065 066 if (text != null) { 067 //textPanel.addParagraph(text, Global.getSettings().getColor("buttonText")); 068 dialog.addOptionSelectedText(option); 069 } 070 071 switch (option) { 072 case INIT: 073 textPanel.addParagraph("Welcome to the Persean Sector! " + 074 "Your fleet is in the middle of nowhere and critically low on supplies."); 075 076 textPanel.addParagraph("If you don't acquire more supplies, " + 077 "your fleet will suffer through a slow but ultimately fatal decline."); 078 079 options.clearOptions(); 080 options.addOption("Continue", OptionId.CONT1, null); 081 break; 082 case CONT1: 083 084 AbilitySpecAPI ability = Global.getSettings().getAbilitySpec(Abilities.SCAVENGE); 085 textPanel.addPara("Fortunately, there's a debris field nearby. " + 086 "Move up into it and activate your %s ability to search it for useful cargo.", 087 Misc.getHighlightColor(), 088 "\"" + ability.getName() + "\""); 089 090 //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."); 091 textPanel.addParagraph("Scavenging requires Heavy Machinery, but there is some in your cargo holds."); 092 093 Global.getSector().getCharacterData().addAbility(ability.getId()); 094 AbilitySlotsAPI slots = Global.getSector().getUIData().getAbilitySlotsAPI(); 095 slots.setCurrBarIndex(0); 096 097 int slotIndex = 5; 098 slots.getCurrSlotsCopy().get(slotIndex).setAbilityId(ability.getId()); 099 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