1
1
package org.lazywizard.console.overlay.v2.panels
2
2
3
3
import com.fs.graphics.util.Fader
4
+ import com.fs.starfarer.api.EveryFrameScript
4
5
import com.fs.starfarer.api.GameState
5
6
import com.fs.starfarer.api.Global
6
7
import com.fs.starfarer.api.campaign.BaseCustomUIPanelPlugin
7
8
import com.fs.starfarer.api.campaign.InteractionDialogAPI
8
9
import com.fs.starfarer.api.campaign.InteractionDialogPlugin
9
10
import com.fs.starfarer.api.campaign.rules.MemoryAPI
10
11
import com.fs.starfarer.api.combat.EngagementResultAPI
12
+ import com.fs.starfarer.api.impl.MusicPlayerPluginImpl
13
+ import com.fs.starfarer.api.impl.campaign.ids.Factions
11
14
import com.fs.starfarer.api.input.InputEventAPI
12
15
import com.fs.starfarer.api.ui.CustomPanelAPI
13
16
import com.fs.starfarer.api.ui.TooltipMakerAPI
@@ -35,6 +38,7 @@ import org.lazywizard.console.overlay.v2.elements.ConsoleTextfield
35
38
import org.lazywizard.console.overlay.v2.font.ConsoleFont
36
39
import org.lazywizard.console.overlay.v2.misc.ReflectionUtils
37
40
import org.lazywizard.console.overlay.v2.misc.clearChildren
41
+ import org.lazywizard.console.overlay.v2.misc.getChildrenCopy
38
42
import org.lazywizard.console.overlay.v2.misc.getParent
39
43
import org.lazywizard.console.overlay.v2.settings.ConsoleV2Settings
40
44
import org.lazywizard.lazylib.JSONUtils
@@ -141,7 +145,7 @@ class ConsoleOverlayPanel(private val context: CommandContext) : BaseCustomUIPan
141
145
142
146
var requiresRecreation = false
143
147
144
- var placeHolderDialog: InteractionDialogAPI ? = null
148
+ var placeHolderDialog: UIPanelAPI ? = null
145
149
146
150
var compileScope = CoroutineScope (Dispatchers .Default )
147
151
var compileJob: Job ? = null
@@ -165,11 +169,32 @@ class ConsoleOverlayPanel(private val context: CommandContext) : BaseCustomUIPan
165
169
166
170
instance = this
167
171
172
+ if (Global .getCurrentState() == GameState .COMBAT ) {
173
+ wasPaused = Global .getCombatEngine().isPaused
174
+ // Global.getCombatEngine().viewport.isExternalControl = true //Prevent moving screen with dragging
175
+ Global .getCombatEngine().isPaused = true
176
+ }
177
+
178
+ if (Global .getCurrentState() == GameState .CAMPAIGN ) {
179
+ wasPaused = Global .getSector().isPaused
180
+ Global .getSector().isPaused = true ;
181
+ }
182
+
168
183
// Open a dialog to prevent input from most other mods
169
184
if (context.isInCampaign) {
170
185
if (! Global .getSector().campaignUI.isShowingDialog) {
171
- Global .getSector().campaignUI.showInteractionDialog(PlaceholderDialog (), Global .getSector().playerFleet)
172
- placeHolderDialog = Global .getSector().campaignUI.currentInteractionDialog
186
+ var ui = Global .getSector().campaignUI
187
+
188
+ // Use message dialog instead of InteractionDialog, as it doesnt hide campaign UI and doesnt mess with pause behaviour
189
+ ui.showMessageDialog(" " )
190
+ val screenPanel = ReflectionUtils .get(" screenPanel" , ui) as UIPanelAPI
191
+ placeHolderDialog = screenPanel.getChildrenCopy().find { ReflectionUtils .hasMethodOfName(" getOptionMap" , it) } as ? UIPanelAPI
192
+ if (placeHolderDialog != null ) {
193
+ ReflectionUtils .invoke(" setOpacity" , placeHolderDialog!! , 0f )
194
+ ReflectionUtils .invoke(" setBackgroundDimAmount" , placeHolderDialog!! , 0f )
195
+ ReflectionUtils .invoke(" setAbsorbOutsideEvents" , placeHolderDialog!! , false )
196
+ ReflectionUtils .invoke(" makeOptionInstant" , placeHolderDialog!! , 0f )
197
+ }
173
198
}
174
199
}
175
200
@@ -186,18 +211,6 @@ class ConsoleOverlayPanel(private val context: CommandContext) : BaseCustomUIPan
186
211
var state = AppDriver .getInstance().currentState
187
212
var screenPanel = ReflectionUtils .invoke(" getScreenPanel" , state) as UIPanelAPI
188
213
189
- if (Global .getCurrentState() == GameState .COMBAT ) {
190
- wasPaused = Global .getCombatEngine().isPaused
191
- // Global.getCombatEngine().viewport.isExternalControl = true //Prevent moving screen with dragging
192
- Global .getCombatEngine().isPaused = true
193
- }
194
-
195
- if (Global .getCurrentState() == GameState .CAMPAIGN ) {
196
- wasPaused = Global .getSector().isPaused
197
- Global .getSector().isPaused = true ;
198
- }
199
-
200
-
201
214
202
215
parent = Global .getSettings().createCustom(screenPanel.position.width, screenPanel.position.height, null )
203
216
screenPanel.addComponent(parent)
@@ -1292,7 +1305,13 @@ class ConsoleOverlayPanel(private val context: CommandContext) : BaseCustomUIPan
1292
1305
1293
1306
compileScope.cancel()
1294
1307
1295
- var state = AppDriver .getInstance().currentState
1308
+ /* placeHolderDialog?.dismiss()
1309
+ placeHolderDialog = null*/
1310
+
1311
+ if (placeHolderDialog != null ) {
1312
+ ReflectionUtils .invoke(" dismiss" , placeHolderDialog!! , 0 )
1313
+ placeHolderDialog = null
1314
+ }
1296
1315
1297
1316
if (Global .getCurrentState() == GameState .COMBAT ) {
1298
1317
if (! wasPaused) Global .getCombatEngine().isPaused = false
@@ -1301,12 +1320,9 @@ class ConsoleOverlayPanel(private val context: CommandContext) : BaseCustomUIPan
1301
1320
}
1302
1321
1303
1322
if (Global .getCurrentState() == GameState .CAMPAIGN ) {
1304
- if ( ! wasPaused) Global .getSector().isPaused = false ;
1323
+ Global .getSector().isPaused = wasPaused ;
1305
1324
}
1306
1325
1307
- placeHolderDialog?.dismiss()
1308
- placeHolderDialog = null
1309
-
1310
1326
instance = null
1311
1327
parent.getParent()?.removeComponent(parent)
1312
1328
}
@@ -1353,47 +1369,4 @@ class ConsoleOverlayPanel(private val context: CommandContext) : BaseCustomUIPan
1353
1369
val percent = DecimalFormat .getPercentInstance().format(used / Math .max(max, committed).toDouble())
1354
1370
" $percent (${asString(used)} /${asString(Math .max(max, committed))} )"
1355
1371
}
1356
-
1357
- class PlaceholderDialog () : InteractionDialogPlugin {
1358
-
1359
- var dialog: InteractionDialogAPI ? = null
1360
-
1361
- override fun init (dialog : InteractionDialogAPI ? ) {
1362
- this .dialog = dialog
1363
-
1364
- dialog!! .promptText = " Test"
1365
- /* if (dialog is UIPanelAPI) {
1366
- dialog.opacity = 0f
1367
- //var fader =ReflectionUtils.invoke("getFader", dialog) as Fader
1368
- }*/
1369
- }
1370
-
1371
- override fun optionSelected (optionText : String? , optionData : Any? ) {
1372
-
1373
- }
1374
-
1375
- override fun optionMousedOver (optionText : String? , optionData : Any? ) {
1376
-
1377
- }
1378
-
1379
- override fun advance (amount : Float ) {
1380
- // ReflectionUtils.invoke("setOpacity", dialog!!, 0f)
1381
- var fader = ReflectionUtils .invoke(" getFader" , dialog!! .visualPanel) as Fader
1382
- fader.brightness = 0f
1383
- }
1384
-
1385
- override fun backFromEngagement (battleResult : EngagementResultAPI ? ) {
1386
-
1387
- }
1388
-
1389
- override fun getContext (): Any? {
1390
- return null
1391
- }
1392
-
1393
- override fun getMemoryMap (): MutableMap <String , MemoryAPI > {
1394
- return hashMapOf()
1395
- }
1396
-
1397
- }
1398
-
1399
1372
}
0 commit comments