Modal save/load window

Modal options window
master
vakhoir 2019-11-19 21:13:39 +01:00 committed by Karl F
parent a718a46753
commit f04ea1e0eb
2 changed files with 20 additions and 5 deletions

View File

@ -17,6 +17,7 @@ local player = nil
local colors = ui.theme.colors
local icons = ui.theme.icons
local pionillium = ui.fonts.pionillium
local popupOpened = false
local mainButtonSize = Vector2(40,40) * (ui.screenHeight / 1200)
local optionButtonSize = Vector2(125,40) * (ui.screenHeight / 1200)
@ -80,7 +81,7 @@ local function showSaveFiles()
table.sort(files, function(a,b) return (a.mtime.timestamp > b.mtime.timestamp) end)
ui.columns(2,"##saved_games",true)
for _,f in pairs(files) do
if ui.selectable(f.name, f.name == selectedSave, {"SpanAllColumns"}) then
if ui.selectable(f.name, f.name == selectedSave, {"SpanAllColumns", "DontClosePopups"}) then
selectedSave = f.name
end
if Engine.pigui.IsItemHovered() then
@ -97,8 +98,10 @@ local function showSaveFiles()
end
local function closeAndClearCache()
ui.closeCurrentPopup()
ui.showSavedGameWindow = nil
saveFileCache = {}
popupOpened = false
end
local function closeAndLoadOrSave()
@ -114,10 +117,14 @@ end
local function savedGameWindow()
if ui.showSavedGameWindow then
if not popupOpened then
popupOpened = true
ui.openPopup("LoadGame")
end
ui.setNextWindowPosCenter('Always')
ui.withStyleColors({["WindowBg"] = Color(20, 20, 80, 230)}, function()
-- TODO: this window should be ShowBorders
ui.window("LoadGame", {"NoTitleBar", "NoResize", "AlwaysAutoResize"}, function()
ui.withStyleColorsAndVars({WindowBg = Color(20, 20, 80, 230)}, {WindowBorderSize = 1}, function()
ui.popupModal("LoadGame", {"NoTitleBar", "NoResize", "AlwaysAutoResize"}, function()
local mode
mode = ui.showSavedGameWindow == 'SAVE' and lui.SAVE or lui.LOAD
optionTextButton(mode, nil, selectedSave~=nil, closeAndLoadOrSave)

View File

@ -509,12 +509,18 @@ local optionsTabs = {
["controls"]=showControlsOptions
}
local optionModalOpen = false
local function optionsWindow()
if ui.showOptionsWindow then
if not optionModalOpen then
ui.openPopup("Options")
end
ui.setNextWindowSize(optionsWinSize, 'Always')
ui.setNextWindowPosCenter('Always')
ui.withStyleColorsAndVars({["WindowBg"] = Color(20, 20, 80, 230)}, {WindowBorderSize = 1}, function()
ui.window("Options", {"NoTitleBar", "NoResize"}, function()
ui.popupModal("Options", {"NoTitleBar", "NoResize"}, function()
mainButton(icons.view_sidereal, lui.VIDEO, showTab=='video', function()
showTab = 'video'
end)
@ -567,6 +573,8 @@ local function optionsWindow()
if showKeyCapture then
captureBinding(keyCaptureId, keyCaptureNum)
end
elseif optionModalOpen then
ui.closeCurrentPopup()
end
end