Restore typed fullscreen panel behavior
ober
4f20edad19f5d7d3f735712ceb4e7aab29ab83ef
--- a/templates/original-tactics-parts/MainActivity.kt.ss +++ b/templates/original-tactics-parts/MainActivity.kt.ss @@ -1075,16 +1075,11 @@ (setFireGroup "beta" betaFireSelectionInput FIRE_GROUP_PHASER))))) (maAddButtonRow this content (list-of Button - (button "Map" (lambda () - (maSelfOpenPanel this "Tactical Map" (maMapAsView tacticalMap)))) - (button "Bridge" (lambda () - (maSelfOpenPanel this "Bridge HUD" (maBridgeAsView bridgeHud)))) - (button "Intel" (lambda () - (maSelfOpenPanel this "Intel" (maIntelAsView sfc2Intel)))) - (button "SSD" (lambda () - (maSelfOpenPanel this "SSD Damage" (maSsdAsView ssdDamage)))) - (button "Log" (lambda () - (maSelfOpenPanel this "Combat Log" (maLogAsView combatLog)))))) + (button "Map" (lambda () (openTacticalMapPanel))) + (button "Bridge" (lambda () (openBridgePanel))) + (button "Intel" (lambda () (openIntelPanel))) + (button "SSD" (lambda () (openSsdPanel))) + (button "Log" (lambda () (openLogPanel))))) (maViewMinimumHeight (maMapAsView tacticalMap) (dp (int32 420))) (maLayoutAddView content (maMapAsView tacticalMap)) (maViewMinimumHeight (maBridgeAsView bridgeHud) (dp (int32 300))) @@ -1101,13 +1096,41 @@ (def (openPanel (title : String) (panel : View)) : Unit (modifiers private) - (let ((dialog (maDialog this)) (frame (maFrameLayout this))) + (let ((dialog (maDialog this)) (layout (maColumn this)) + (header (maRow this))) (begin (maSelfRefreshPanel this panel) (set! activeFullscreenView (nullable-some panel)) - (maFrameAddView frame panel) + (maViewBackgroundColor (maLinearAsView layout) UI_BG) + (maViewPadding (maLinearAsView layout) + (dp (int32 10)) (dp (int32 10)) + (dp (int32 10)) (dp (int32 10))) + (maAddWeighted header + (maTextAsView (maNewText this title (float32 20.0) #t)) + (float32 1.0)) + (maLayoutAddView header + (maButtonAsView + (button "<" + (lambda () + (begin + (maDialogDismiss dialog) + (openAdjacentPanel title (int32 -1))))))) + (maLayoutAddView header + (maButtonAsView + (button ">" + (lambda () + (begin + (maDialogDismiss dialog) + (openAdjacentPanel title (int32 1))))))) + (maLayoutAddView header + (maButtonAsView + (button "Close" (lambda () (maDialogDismiss dialog))))) + (maLayoutAddView layout (maLinearAsView header)) + (maLayoutAddViewParams layout panel + (maWeightedLayoutParams + (maMatchParent) (int32 0) (float32 1.0))) (maDialogSetTitle dialog title) - (maDialogSetContent dialog (maFrameAsView frame)) + (maDialogSetContent dialog (maLinearAsView layout)) (maDialogShow dialog) (let ((window (maDialogWindow dialog))) (if (nullable-null? window) (begin) @@ -1116,6 +1139,28 @@ (maColorDrawable (maColorTransparent))) (maWindowLayout (nullable-get window) (maMatchParent) (maMatchParent)))))))) + (def (openAdjacentPanel (title : String) (delta : Int32)) : Unit + (modifiers private) + (let ((index + (if (equal? title "Tactical Map") (int32 0) + (if (equal? title "Bridge HUD") (int32 1) + (if (equal? title "Battle Command") (int32 2) + (if (equal? title "SSD Damage") (int32 3) + (if (equal? title "Intel") (int32 4) + (if (equal? title "Combat Log") + (int32 5) (int32 0))))))))) + (let ((next (+ index delta))) + (openPanelAtIndex + (if (< next (int32 0)) (int32 5) + (if (> next (int32 5)) (int32 0) next)))))) + (def (openPanelAtIndex (index : Int32)) : Unit + (modifiers private) + (if (= index (int32 0)) (openTacticalMapPanel) + (if (= index (int32 1)) (openBridgePanel) + (if (= index (int32 2)) (openCommandPanel) + (if (= index (int32 3)) (openSsdPanel) + (if (= index (int32 4)) (openIntelPanel) + (openLogPanel))))))) (def (refreshPanelView (view : View)) : Unit (modifiers private) (begin @@ -1654,17 +1699,40 @@ (list-of View (maCommandAsView battleCommand) (maAvailabilityAsView commandAvailability)))) (def (openTacticalMapPanel) : Unit (modifiers private) - (maSelfOpenPanel this "Tactical Map" (maMapAsView tacticalMap))) + (let ((panel (maTacticalMap this))) + (begin + (maMapSetGame panel currentGame lastEvents) + (maMapSetStatus panel lastStatusReport) + (maMapSetDashboard panel lastDashboardReport) + (maSelfOpenPanel this "Tactical Map" (maMapAsView panel))))) (def (openBridgePanel) : Unit (modifiers private) - (maSelfOpenPanel this "Bridge HUD" (maBridgeAsView bridgeHud))) + (let ((panel (maBridgeHud this))) + (begin + (maBridgeSetData panel currentGame lastDashboardReport lastEvents) + (maSelfOpenPanel this "Bridge HUD" (maBridgeAsView panel))))) (def (openIntelPanel) : Unit (modifiers private) - (maSelfOpenPanel this "Intel" (maIntelAsView sfc2Intel))) + (let ((panel (maIntel this))) + (begin + (if (nullable-null? lastDashboardReport) + (maIntelSetStatus panel lastStatusReport) + (maIntelSetDashboard panel lastDashboardReport)) + (maIntelSetTruth panel alphaTruthReport betaTruthReport) + (maSelfOpenPanel this "Intel" (maIntelAsView panel))))) (def (openLogPanel) : Unit (modifiers private) - (maSelfOpenPanel this "Combat Log" (maLogAsView combatLog))) + (let ((panel (maCombatLog this))) + (begin + (maLogSetData panel currentGame lastEvents lastDashboardReport) + (maSelfOpenPanel this "Combat Log" (maLogAsView panel))))) (def (openSsdPanel) : Unit (modifiers private) - (maSelfOpenPanel this "SSD Damage" (maSsdAsView ssdDamage))) + (let ((panel (maSsdDamage this))) + (begin + (maSsdSetData panel currentGame alphaTruthReport betaTruthReport) + (maSelfOpenPanel this "SSD Damage" (maSsdAsView panel))))) (def (openCommandPanel) : Unit (modifiers private) - (maSelfOpenPanel this "Battle Command" (maCommandAsView battleCommand))) + (let ((panel (maBattleCommand this))) + (begin + (maCommandSetGame panel currentGame lastEvents lastStatusReport) + (maSelfOpenPanel this "Battle Command" (maCommandAsView panel))))) (def (installPanelZoom (panel : View) (title : String) (consumeTouch : Bool) (factory : (-> View))) : Unit