diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 0a77b8a605..6395882756 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3649,6 +3649,8 @@ STR_6392 :Could not find {STRING} at this path. STR_6393 :Objective Selection STR_6394 :Objective STR_6395 :Maintenance +STR_6396 :Disable screensaver and monitor power saving +STR_6397 :{SMALLFONT}{BLACK}If checked, screensaver and other monitor power saving features will be inhibited while OpenRCT2 is running. ############# # Scenarios # diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 3001bc6cc3..37fb9ea947 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -11,6 +11,7 @@ - Fix: [#3200] Close Construction window upon selecting vehicle page. - Fix: [#4022] Fix Mac cursor offset on launch - Fix: [#4041] Garbled park option on scenario editor with custom theme. +- Fix: [#4865] Offer an option to disable inhibiting the monitor power. - Fix: [#5178] Lighting effects cannot be disabled in software mode - Fix: [#5904] Empty errors on tile inspector base height change. - Fix: [#6086] Cannot install existing track design with another name. diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index a96a68b458..9458d52045 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -669,6 +669,8 @@ private: SDLException::Throw("SDL_CreateWindow(...)"); } + ApplyScreenSaverLockSetting(); + SDL_SetWindowMinimumSize(_window, 720, 480); SetCursorTrap(gConfigGeneral.trap_cursor); _platformUiContext->SetWindowIcon(_window); diff --git a/src/openrct2-ui/interface/Window.cpp b/src/openrct2-ui/interface/Window.cpp index c958a00200..a2ddbbec65 100644 --- a/src/openrct2-ui/interface/Window.cpp +++ b/src/openrct2-ui/interface/Window.cpp @@ -11,6 +11,7 @@ #include "Theme.h" +#include #include #include #include @@ -537,6 +538,11 @@ void window_all_wheel_input() } } +void ApplyScreenSaverLockSetting() +{ + gConfigGeneral.disable_screensaver ? SDL_DisableScreenSaver() : SDL_EnableScreenSaver(); +} + /** * Initialises scroll widgets to their virtual size. * rct2: 0x006EAEB8 diff --git a/src/openrct2-ui/interface/Window.h b/src/openrct2-ui/interface/Window.h index 95e4dc8ef4..1ba92c9720 100644 --- a/src/openrct2-ui/interface/Window.h +++ b/src/openrct2-ui/interface/Window.h @@ -13,3 +13,4 @@ #include void window_all_wheel_input(); +void ApplyScreenSaverLockSetting(); diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index c4f6ccc9f4..1427616b10 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -88,6 +88,7 @@ enum WINDOW_OPTIONS_WIDGET_IDX { WIDX_MULTITHREADING_CHECKBOX, WIDX_USE_VSYNC_CHECKBOX, WIDX_MINIMIZE_FOCUS_LOSS, + WIDX_DISABLE_SCREENSAVER_LOCK, // Rendering WIDX_RENDERING_GROUP = WIDX_PAGE_START, @@ -205,7 +206,7 @@ static constexpr const int32_t WH = 332; static rct_widget window_options_display_widgets[] = { MAIN_OPTIONS_WIDGETS, - MakeWidget ({ 5, 53}, {300, 155}, WWT_GROUPBOX, WindowColour::Secondary, STR_HARDWARE_GROUP ), // Hardware group + MakeWidget ({ 5, 53}, {300, 170}, WWT_GROUPBOX, WindowColour::Secondary, STR_HARDWARE_GROUP ), // Hardware group MakeWidget ({155, 68}, {145, 12}, WWT_DROPDOWN, WindowColour::Secondary ), // Fullscreen MakeWidget ({288, 69}, { 11, 10}, WWT_BUTTON, WindowColour::Secondary, STR_DROPDOWN_GLYPH, STR_FULLSCREEN_MODE_TIP ), MakeWidget ({155, 83}, {145, 12}, WWT_DROPDOWN, WindowColour::Secondary, STR_ARG_16_RESOLUTION_X_BY_Y ), // Resolution @@ -221,6 +222,7 @@ static rct_widget window_options_display_widgets[] = { MakeWidget ({155, 176}, {136, 12}, WWT_CHECKBOX, WindowColour::Secondary, STR_MULTITHREADING, STR_MULTITHREADING_TIP ), // Multithreading MakeWidget ({ 11, 176}, {143, 12}, WWT_CHECKBOX, WindowColour::Secondary, STR_USE_VSYNC, STR_USE_VSYNC_TIP ), // Use vsync MakeWidget ({ 11, 191}, {280, 12}, WWT_CHECKBOX, WindowColour::Secondary, STR_MINIMISE_FULLSCREEN_ON_FOCUS_LOSS, STR_MINIMISE_FULLSCREEN_ON_FOCUS_LOSS_TIP), // Minimise fullscreen focus loss + MakeWidget ({ 11, 206}, {280, 12}, WWT_CHECKBOX, WindowColour::Secondary, STR_DISABLE_SCREENSAVER, STR_DISABLE_SCREENSAVER_TIP ), // Disable screensaver { WIDGETS_END }, }; @@ -449,6 +451,7 @@ static uint64_t window_options_page_enabled_widgets[] = { (1 << WIDX_MULTITHREADING_CHECKBOX) | (1 << WIDX_MINIMIZE_FOCUS_LOSS) | (1 << WIDX_STEAM_OVERLAY_PAUSE) | + (1 << WIDX_DISABLE_SCREENSAVER_LOCK) | (1 << WIDX_SCALE) | (1 << WIDX_SCALE_UP) | (1 << WIDX_SCALE_DOWN) | @@ -636,6 +639,12 @@ static void window_options_display_mouseup(rct_window* w, rct_widgetindex widget config_save_default(); w->Invalidate(); break; + case WIDX_DISABLE_SCREENSAVER_LOCK: + gConfigGeneral.disable_screensaver ^= 1; + ApplyScreenSaverLockSetting(); + config_save_default(); + w->Invalidate(); + break; } } @@ -857,6 +866,7 @@ static void window_options_display_invalidate(rct_window* w) widget_set_checkbox_value(w, WIDX_MULTITHREADING_CHECKBOX, gConfigGeneral.multithreading); widget_set_checkbox_value(w, WIDX_MINIMIZE_FOCUS_LOSS, gConfigGeneral.minimize_fullscreen_focus_loss); widget_set_checkbox_value(w, WIDX_STEAM_OVERLAY_PAUSE, gConfigGeneral.steam_overlay_pause); + widget_set_checkbox_value(w, WIDX_DISABLE_SCREENSAVER_LOCK, gConfigGeneral.disable_screensaver); // Dropdown captions for straightforward strings. window_options_display_widgets[WIDX_FULLSCREEN].text = window_options_fullscreen_mode_names[gConfigGeneral.fullscreen_mode]; diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 40c7f76841..fe8a3cdc59 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -184,6 +184,7 @@ namespace Config model->invert_viewport_drag = reader->GetBoolean("invert_viewport_drag", false); model->load_save_sort = reader->GetInt32("load_save_sort", SORT_NAME_ASCENDING); model->minimize_fullscreen_focus_loss = reader->GetBoolean("minimize_fullscreen_focus_loss", true); + model->disable_screensaver = reader->GetBoolean("disable_screensaver", true); // Default config setting is false until the games canvas can be separated from the effect model->day_night_cycle = reader->GetBoolean("day_night_cycle", false); @@ -263,6 +264,7 @@ namespace Config writer->WriteBoolean("invert_viewport_drag", model->invert_viewport_drag); writer->WriteInt32("load_save_sort", model->load_save_sort); writer->WriteBoolean("minimize_fullscreen_focus_loss", model->minimize_fullscreen_focus_loss); + writer->WriteBoolean("disable_screensaver", model->disable_screensaver); writer->WriteBoolean("day_night_cycle", model->day_night_cycle); writer->WriteBoolean("enable_light_fx", model->enable_light_fx); writer->WriteBoolean("enable_light_fx_for_vehicles", model->enable_light_fx_for_vehicles); diff --git a/src/openrct2/config/Config.h b/src/openrct2/config/Config.h index 9c0f28b3f4..17c95d3f24 100644 --- a/src/openrct2/config/Config.h +++ b/src/openrct2/config/Config.h @@ -42,6 +42,7 @@ struct GeneralConfiguration bool show_fps; bool multithreading; bool minimize_fullscreen_focus_loss; + bool disable_screensaver; // Map rendering bool landscape_smoothing; diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index b82f63cef7..058fe1104a 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3899,6 +3899,8 @@ enum STR_CHEAT_OBJECTIVE_GROUP = 6394, STR_CHEAT_MAINTENANCE_GROUP = 6395, + STR_DISABLE_SCREENSAVER = 6396, + STR_DISABLE_SCREENSAVER_TIP = 6397, // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working /* MAX_STR_COUNT = 32768 */ // MAX_STR_COUNT - upper limit for number of strings, not the current count strings };