Skip to content

Commit

Permalink
Pause menu sets last time acceleration
Browse files Browse the repository at this point in the history
The pause menu now sets the last time acceleration that was before it was opened. Its behavior will be the same as when setting up time acceleration without pressing CTRL.
Changed behaviour of Close button in settings-window.lua. Now it will not set time acceleration and not enable input bindings.
  • Loading branch information
Max5377 committed Oct 15, 2023
1 parent 86153e7 commit 288efb5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 0 additions & 4 deletions data/pigui/modules/settings-window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,6 @@ ui.optionsWindow = ModalWindow.New("Options", function()
Engine.SetStarFieldStarSizeFactor(starFieldStarSizeFactor/100)
needBackgroundStarRefresh = false
end
if Game.player then
Game.SetTimeAcceleration("1x")
Input.EnableBindings();
end
if selectedJoystick then
Input.SaveJoystickConfig(selectedJoystick)
end
Expand Down
15 changes: 11 additions & 4 deletions data/pigui/views/game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ local colors = ui.theme.colors
local reticuleCircleRadius = math.min(ui.screenWidth, ui.screenHeight) / 8
local reticuleCircleThickness = 2.0

local lastTimeAcceleration
local settingsMenuWasOpened

-- for modules
ui.reticuleCircleRadius = reticuleCircleRadius
ui.reticuleCircleThickness = reticuleCircleThickness
Expand Down Expand Up @@ -285,19 +288,23 @@ ui.registerHandler('game', function(delta_t)
-- TODO: dispatch escape key to views and let them handle it
if currentView == "world" and ui.escapeKeyReleased(true) then
if not ui.optionsWindow.isOpen then
lastTimeAcceleration = Game.GetTimeAcceleration() ~= Game.GetRequestedTimeAcceleration() and Game.GetRequestedTimeAcceleration() or Game.GetTimeAcceleration()
Game.SetTimeAcceleration("paused")
ui.optionsWindow:open()
Input.EnableBindings(false)
settingsMenuWasOpened = true
else
ui.optionsWindow:close()
if not ui.optionsWindow.isOpen then
Game.SetTimeAcceleration("1x")
Input.EnableBindings()
end
end
end

callModules('modal')

if settingsMenuWasOpened and not ui.optionsWindow.isOpen then
settingsMenuWasOpened = false
Game.SetTimeAcceleration((lastTimeAcceleration == "paused") and "1x" or lastTimeAcceleration)
Input.EnableBindings()
end

if ui.ctrlHeld() and ui.isKeyReleased(ui.keys.delete) then
gameView.debugReload()
Expand Down

0 comments on commit 288efb5

Please sign in to comment.