Starsector API
Loading...
Searching...
No Matches
DuelDialogDelegate.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.eventide;
2
3import java.util.Map;
4
5import com.fs.starfarer.api.campaign.CustomUIPanelPlugin;
6import com.fs.starfarer.api.campaign.CustomVisualDialogDelegate;
7import com.fs.starfarer.api.campaign.InteractionDialogAPI;
8import com.fs.starfarer.api.campaign.rules.MemKeys;
9import com.fs.starfarer.api.campaign.rules.MemoryAPI;
10import com.fs.starfarer.api.impl.campaign.rulecmd.FireBest;
11import com.fs.starfarer.api.ui.CustomPanelAPI;
12
13public class DuelDialogDelegate implements CustomVisualDialogDelegate {
14 protected DialogCallbacks callbacks;
15 protected float endDelay = 2f;
16 protected boolean finished = false;
17
18 protected String musicId;
20 protected InteractionDialogAPI dialog;
21 protected Map<String, MemoryAPI> memoryMap;
22 protected boolean tutorialMode;
23
24
25 public DuelDialogDelegate(@Deprecated String musicId, DuelPanel duelPanel, InteractionDialogAPI dialog,
26 Map<String, MemoryAPI> memoryMap, boolean tutorialMode) {
27 this.musicId = musicId;
28 this.duelPanel = duelPanel;
29 this.dialog = dialog;
30 this.memoryMap = memoryMap;
31 this.tutorialMode = tutorialMode;
32 }
33 public CustomUIPanelPlugin getCustomPanelPlugin() {
34 return duelPanel;
35 }
36 public void init(CustomPanelAPI panel, DialogCallbacks callbacks) {
37 this.callbacks = callbacks;
38 callbacks.getPanelFader().setDurationOut(2f);
40// if (musicId != null && !musicId.isEmpty()) {
41// Global.getSoundPlayer().setSuspendDefaultMusicPlayback(true);
42// Global.getSoundPlayer().playCustomMusic(1, 1, musicId);
43// } else {
44// Global.getSoundPlayer().pauseMusic();
45// Global.getSoundPlayer().setSuspendDefaultMusicPlayback(true);
46// }
47 }
48 public float getNoiseAlpha() {
49 return 0;
50 }
51 public void advance(float amount) {
52 if (!finished &&
54 endDelay -= amount;
55 if (endDelay <= 0f) {
56 callbacks.getPanelFader().fadeOut();
57 if (callbacks.getPanelFader().isFadedOut()) {
58 callbacks.dismissDialog();
59 finished = true;
60 }
61 }
62 }
63 }
64 public void reportDismissed(int option) {
65// Global.getSoundPlayer().setSuspendDefaultMusicPlayback(false);
66// Global.getSoundPlayer().restartCurrentMusic();
67
68 if (memoryMap != null) { // null when called from the test dialog
69 if (!tutorialMode) {
70 if (duelPanel.getPlayer().health > 0) {
71 memoryMap.get(MemKeys.LOCAL).set("$soe_playerWonDuel", true, 0);
72 } else {
73 memoryMap.get(MemKeys.LOCAL).set("$soe_playerLostDuel", true, 0);
74 }
75 FireBest.fire(null, dialog, memoryMap, "SOEDuelFinished");
76 } else {
77 FireBest.fire(null, dialog, memoryMap, "SOETutorialFinished");
78 }
79 }
80 }
81}
82
void init(CustomPanelAPI panel, DialogCallbacks callbacks)
DuelDialogDelegate(@Deprecated String musicId, DuelPanel duelPanel, InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap, boolean tutorialMode)
void init(CustomPanelAPI panel, DialogCallbacks callbacks, InteractionDialogAPI dialog)