From 1b90ffca9ef5d3c1b47808841bcf20c55a73cb4d Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 18 Mar 2023 23:48:42 -0700 Subject: [PATCH] extract a function --- source.lua | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/source.lua b/source.lua index 5c8bb82..0fdd7f6 100644 --- a/source.lua +++ b/source.lua @@ -105,16 +105,7 @@ end function source.load_settings() local settings = Settings.source love.graphics.setFont(love.graphics.newFont(settings.font_height)) - -- maximize window to determine maximum allowable dimensions - App.screen.resize(0, 0) -- maximize - Display_width, Display_height, App.screen.flags = App.screen.size() - -- set up desired window dimensions - App.screen.flags.resizable = true - App.screen.flags.minwidth = math.min(Display_width, 200) - App.screen.flags.minheight = math.min(Display_height, 200) - App.screen.width, App.screen.height = settings.width, settings.height ---? print('setting window from settings:', App.screen.width, App.screen.height) - App.screen.resize(App.screen.width, App.screen.height, App.screen.flags) + source.resize_window_from_settings(settings) --? print('loading source position', settings.x, settings.y, settings.displayindex) source.set_window_position_from_settings(settings) Show_log_browser_side = settings.show_log_browser_side @@ -136,6 +127,19 @@ function source.load_settings() end end +function source.resize_window_from_settings(settings) + -- maximize window to determine maximum allowable dimensions + App.screen.resize(0, 0) -- maximize + Display_width, Display_height, App.screen.flags = App.screen.size() + -- set up desired window dimensions + App.screen.flags.resizable = true + App.screen.flags.minwidth = math.min(Display_width, 200) + App.screen.flags.minheight = math.min(Display_height, 200) + App.screen.width, App.screen.height = settings.width, settings.height +--? print('setting window from settings:', App.screen.width, App.screen.height) + App.screen.resize(App.screen.width, App.screen.height, App.screen.flags) +end + function source.set_window_position_from_settings(settings) -- love.window.setPosition doesn't quite seem to do what is asked of it on Linux. App.screen.move(settings.x, settings.y-37, settings.displayindex)