mirror of
https://github.com/minetest/minetest.git
synced 2024-12-28 08:57:30 +01:00
Save minetest screen width/height options when modified (#5683)
* Save minetest screen width/height options when modified * Add autosave_screensize setting (default true) * Fix @SmallJoker comments
This commit is contained in:
parent
d6cf5450a8
commit
21e0a049f8
@ -190,7 +190,7 @@ local function formspec(tabview, name, tabdata)
|
||||
.. getSettingIndex.NodeHighlighting() .. "]" ..
|
||||
"dropdown[0.25,3.6;3.3;dd_leaves_style;" .. dd_options.leaves[1] .. ";"
|
||||
.. getSettingIndex.Leaves() .. "]" ..
|
||||
"box[3.75,0;3.75,3.45;#999999]" ..
|
||||
"box[3.75,0;3.75,4.45;#999999]" ..
|
||||
"label[3.85,0.1;" .. fgettext("Texturing:") .. "]" ..
|
||||
"dropdown[3.85,0.55;3.85;dd_filters;" .. dd_options.filters[1] .. ";"
|
||||
.. getSettingIndex.Filter() .. "]" ..
|
||||
@ -199,6 +199,9 @@ local function formspec(tabview, name, tabdata)
|
||||
"label[3.85,2.15;" .. fgettext("Antialiasing:") .. "]" ..
|
||||
"dropdown[3.85,2.6;3.85;dd_antialiasing;" .. dd_options.antialiasing[1] .. ";"
|
||||
.. getSettingIndex.Antialiasing() .. "]" ..
|
||||
"label[3.85,3.45;" .. fgettext("Screen:") .. "]" ..
|
||||
"checkbox[3.85,3.6;cb_autosave_screensize;" .. fgettext("Autosave screen size") .. ";"
|
||||
.. dump(core.setting_getbool("autosave_screensize")) .. "]" ..
|
||||
"box[7.75,0;4,4.4;#999999]" ..
|
||||
"checkbox[8,0;cb_shaders;" .. fgettext("Shaders") .. ";"
|
||||
.. dump(core.setting_getbool("enable_shaders")) .. "]"
|
||||
@ -290,6 +293,10 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
|
||||
core.setting_set("connected_glass", fields["cb_connected_glass"])
|
||||
return true
|
||||
end
|
||||
if fields["cb_autosave_screensize"] then
|
||||
core.setting_set("autosave_screensize", fields["cb_autosave_screensize"])
|
||||
return true
|
||||
end
|
||||
if fields["cb_shaders"] then
|
||||
if (core.setting_get("video_driver") == "direct3d8" or
|
||||
core.setting_get("video_driver") == "direct3d9") then
|
||||
|
@ -459,6 +459,9 @@ screenW (Screen width) int 800
|
||||
# Height component of the initial window size.
|
||||
screenH (Screen height) int 600
|
||||
|
||||
# Save window size automatically when modified.
|
||||
autosave_screensize (Autosave Screen Size) bool true
|
||||
|
||||
# Fullscreen mode.
|
||||
fullscreen (Full screen) bool false
|
||||
|
||||
|
@ -526,6 +526,10 @@
|
||||
# type: int
|
||||
# screenH = 600
|
||||
|
||||
# Save the window size automatically when modified.
|
||||
# type: bool
|
||||
# autosave_screensize = true
|
||||
|
||||
# Fullscreen mode.
|
||||
# type: bool
|
||||
# fullscreen = false
|
||||
|
@ -121,6 +121,7 @@ void set_default_settings(Settings *settings)
|
||||
settings->setDefault("viewing_range", "100");
|
||||
settings->setDefault("screenW", "800");
|
||||
settings->setDefault("screenH", "600");
|
||||
settings->setDefault("autosave_screensize", "true");
|
||||
settings->setDefault("fullscreen", "false");
|
||||
settings->setDefault("fullscreen_bpp", "24");
|
||||
settings->setDefault("vsync", "false");
|
||||
|
16
src/game.cpp
16
src/game.cpp
@ -1629,10 +1629,26 @@ void Game::run()
|
||||
&& client->checkPrivilege("fast");
|
||||
#endif
|
||||
|
||||
irr::core::dimension2d<u32> previous_screen_size(g_settings->getU16("screenW"),
|
||||
g_settings->getU16("screenH"));
|
||||
|
||||
while (device->run()
|
||||
&& !(*kill || g_gamecallback->shutdown_requested
|
||||
|| (server && server->getShutdownRequested()))) {
|
||||
|
||||
const irr::core::dimension2d<u32> ¤t_screen_size =
|
||||
device->getVideoDriver()->getScreenSize();
|
||||
// Verify if window size has changed and save it if it's the case
|
||||
// Ensure evaluating settings->getBool after verifying screensize
|
||||
// First condition is cheaper
|
||||
if (previous_screen_size != current_screen_size &&
|
||||
current_screen_size != irr::core::dimension2d<u32>(0,0) &&
|
||||
g_settings->getBool("autosave_screensize")) {
|
||||
g_settings->setU16("screenW", current_screen_size.Width);
|
||||
g_settings->setU16("screenH", current_screen_size.Height);
|
||||
previous_screen_size = current_screen_size;
|
||||
}
|
||||
|
||||
/* Must be called immediately after a device->run() call because it
|
||||
* uses device->getTimer()->getTime()
|
||||
*/
|
||||
|
@ -262,8 +262,24 @@ void GUIEngine::run()
|
||||
|
||||
unsigned int text_height = g_fontengine->getTextHeight();
|
||||
|
||||
while(m_device->run() && (!m_startgame) && (!m_kill))
|
||||
{
|
||||
irr::core::dimension2d<u32> previous_screen_size(g_settings->getU16("screenW"),
|
||||
g_settings->getU16("screenH"));
|
||||
|
||||
while (m_device->run() && (!m_startgame) && (!m_kill)) {
|
||||
|
||||
const irr::core::dimension2d<u32> ¤t_screen_size =
|
||||
m_device->getVideoDriver()->getScreenSize();
|
||||
// Verify if window size has changed and save it if it's the case
|
||||
// Ensure evaluating settings->getBool after verifying screensize
|
||||
// First condition is cheaper
|
||||
if (previous_screen_size != current_screen_size &&
|
||||
current_screen_size != irr::core::dimension2d<u32>(0,0) &&
|
||||
g_settings->getBool("autosave_screensize")) {
|
||||
g_settings->setU16("screenW", current_screen_size.Width);
|
||||
g_settings->setU16("screenH", current_screen_size.Height);
|
||||
previous_screen_size = current_screen_size;
|
||||
}
|
||||
|
||||
//check if we need to update the "upper left corner"-text
|
||||
if (text_height != g_fontengine->getTextHeight()) {
|
||||
updateTopLeftTextSize();
|
||||
|
Loading…
Reference in New Issue
Block a user