001package com.fs.starfarer.api.impl.campaign.rulecmd; 002 003import java.util.List; 004import java.util.Map; 005 006import com.fs.starfarer.api.Global; 007import com.fs.starfarer.api.campaign.BattleAPI; 008import com.fs.starfarer.api.campaign.CampaignFleetAPI; 009import com.fs.starfarer.api.campaign.InteractionDialogAPI; 010import com.fs.starfarer.api.campaign.PlanetAPI; 011import com.fs.starfarer.api.campaign.SectorEntityToken; 012import com.fs.starfarer.api.campaign.rules.MemoryAPI; 013import com.fs.starfarer.api.impl.campaign.FleetEncounterContext; 014import com.fs.starfarer.api.util.Misc; 015import com.fs.starfarer.api.util.Misc.Token; 016 017public class ShowDefaultVisual extends BaseCommandPlugin { 018 019 public ShowDefaultVisual() { 020 021 } 022 023 public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) { 024 025 SectorEntityToken target = dialog.getInteractionTarget(); 026 027 if (target.getCustomInteractionDialogImageVisual() != null) { 028 dialog.getVisualPanel().showImageVisual(target.getCustomInteractionDialogImageVisual()); 029 } else { 030 if (target.getMarket() != null) { 031 target = target.getMarket().getPlanetEntity(); 032 } 033 if (target instanceof PlanetAPI) { 034 //Global.getSettings().setBoolean("3dPlanetBGInInteractionDialog", true); 035 if (!Global.getSettings().getBoolean("3dPlanetBGInInteractionDialog")) { 036 dialog.getVisualPanel().showPlanetInfo((PlanetAPI) target); 037 } 038 //dialog.getVisualPanel().showLargePlanet((PlanetAPI) target); 039 040 } else if (target instanceof CampaignFleetAPI) { 041 CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet(); 042 CampaignFleetAPI otherFleet = (CampaignFleetAPI) target; 043 //dialog.getVisualPanel().setVisualFade(0.25f, 0.25f); 044 //dialog.getVisualPanel().showFleetInfo((String)null, playerFleet, (String)null, otherFleet, null); 045 showFleetInfo(dialog, playerFleet, otherFleet); 046 047 //if (otherFleet ) 048 } 049// else if (target instanceof XXXXX) { 050// dialog.getVisualPanel().showXXXXX((XXXXX) target); 051// } 052 } 053 054 return true; 055 } 056 057 protected void showFleetInfo(InteractionDialogAPI dialog, CampaignFleetAPI player, CampaignFleetAPI other) { 058 BattleAPI b = player.getBattle(); 059 if (b == null) b = other.getBattle(); 060 if (b != null && b.isPlayerInvolved()) { 061 String titleOne = "Your forces"; 062 if (b.isPlayerInvolved() && b.getPlayerSide().size() > 1) { 063 titleOne += ", with allies"; 064 } 065 if (!Global.getSector().getPlayerFleet().isValidPlayerFleet()) { 066 titleOne = "Allied forces"; 067 } 068 String titleTwo = null; 069 if (b.getPrimary(b.getNonPlayerSide()) != null) { 070 titleTwo = b.getPrimary(b.getNonPlayerSide()).getNameWithFactionKeepCase(); 071 } 072 if (b.getNonPlayerSide().size() > 1) titleTwo += ", with allies"; 073 dialog.getVisualPanel().showFleetInfo(titleOne, b.getPlayerCombined(), Misc.ucFirst(titleTwo), b.getNonPlayerCombined(), null); 074 } else { 075 if (b != null) { 076 String titleOne = b.getPrimary(b.getSideOne()).getNameWithFactionKeepCase(); 077 if (b.getSideOne().size() > 1) titleOne += ", with allies"; 078 String titleTwo = b.getPrimary(b.getSideTwo()).getNameWithFactionKeepCase(); 079 if (b.getSideTwo().size() > 1) titleTwo += ", with allies"; 080 081 FleetEncounterContext fake = new FleetEncounterContext(); 082 fake.setBattle(b); 083 dialog.getVisualPanel().showPreBattleJoinInfo(null, player, Misc.ucFirst(titleOne), Misc.ucFirst(titleTwo), fake); 084 } else { 085 dialog.getVisualPanel().showFleetInfo((String)null, player, (String)null, other, null); 086 } 087 } 088 } 089 090} 091 092