Starsector API
Loading...
Searching...
No Matches
ShowDefaultVisual.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.rulecmd;
2
3import java.util.List;
4import java.util.Map;
5
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.campaign.BattleAPI;
8import com.fs.starfarer.api.campaign.CampaignFleetAPI;
9import com.fs.starfarer.api.campaign.InteractionDialogAPI;
10import com.fs.starfarer.api.campaign.PlanetAPI;
11import com.fs.starfarer.api.campaign.SectorEntityToken;
12import com.fs.starfarer.api.campaign.rules.MemoryAPI;
13import com.fs.starfarer.api.impl.campaign.FleetEncounterContext;
14import com.fs.starfarer.api.util.Misc;
15import com.fs.starfarer.api.util.Misc.Token;
16
18
20
21 }
22
23 public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
24
25 SectorEntityToken target = dialog.getInteractionTarget();
26
27 if (target.getCustomInteractionDialogImageVisual() != null) {
28 dialog.getVisualPanel().showImageVisual(target.getCustomInteractionDialogImageVisual());
29 } else {
30 if (target.getMarket() != null) {
31 target = target.getMarket().getPlanetEntity();
32 }
33 if (target instanceof PlanetAPI) {
34 //Global.getSettings().setBoolean("3dPlanetBGInInteractionDialog", true);
35 if (!Global.getSettings().getBoolean("3dPlanetBGInInteractionDialog")) {
36 dialog.getVisualPanel().showPlanetInfo((PlanetAPI) target);
37 }
38 //dialog.getVisualPanel().showLargePlanet((PlanetAPI) target);
39
40 } else if (target instanceof CampaignFleetAPI) {
41 CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet();
42 CampaignFleetAPI otherFleet = (CampaignFleetAPI) target;
43 //dialog.getVisualPanel().setVisualFade(0.25f, 0.25f);
44 //dialog.getVisualPanel().showFleetInfo((String)null, playerFleet, (String)null, otherFleet, null);
45 showFleetInfo(dialog, playerFleet, otherFleet);
46
47 //if (otherFleet )
48 }
49// else if (target instanceof XXXXX) {
50// dialog.getVisualPanel().showXXXXX((XXXXX) target);
51// }
52 }
53
54 return true;
55 }
56
57 protected void showFleetInfo(InteractionDialogAPI dialog, CampaignFleetAPI player, CampaignFleetAPI other) {
58 BattleAPI b = player.getBattle();
59 if (b == null) b = other.getBattle();
60 if (b != null && b.isPlayerInvolved()) {
61 String titleOne = "Your forces";
62 if (b.isPlayerInvolved() && b.getPlayerSide().size() > 1) {
63 titleOne += ", with allies";
64 }
65 if (!Global.getSector().getPlayerFleet().isValidPlayerFleet()) {
66 titleOne = "Allied forces";
67 }
68 String titleTwo = null;
69 if (b.getPrimary(b.getNonPlayerSide()) != null) {
70 titleTwo = b.getPrimary(b.getNonPlayerSide()).getNameWithFactionKeepCase();
71 }
72 if (b.getNonPlayerSide().size() > 1) titleTwo += ", with allies";
73 dialog.getVisualPanel().showFleetInfo(titleOne, b.getPlayerCombined(), Misc.ucFirst(titleTwo), b.getNonPlayerCombined(), null);
74 } else {
75 if (b != null) {
76 String titleOne = b.getPrimary(b.getSideOne()).getNameWithFactionKeepCase();
77 if (b.getSideOne().size() > 1) titleOne += ", with allies";
78 String titleTwo = b.getPrimary(b.getSideTwo()).getNameWithFactionKeepCase();
79 if (b.getSideTwo().size() > 1) titleTwo += ", with allies";
80
82 fake.setBattle(b);
83 dialog.getVisualPanel().showPreBattleJoinInfo(null, player, Misc.ucFirst(titleOne), Misc.ucFirst(titleTwo), fake);
84 } else {
85 dialog.getVisualPanel().showFleetInfo((String)null, player, (String)null, other, null);
86 }
87 }
88 }
89
90}
91
92
static SettingsAPI getSettings()
Definition Global.java:51
static SectorAPI getSector()
Definition Global.java:59
boolean execute(String ruleId, InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)
void showFleetInfo(InteractionDialogAPI dialog, CampaignFleetAPI player, CampaignFleetAPI other)
boolean getBoolean(String key)