Close #4865: Offer an option to disable inhibiting the monitor power (#13243)

Co-authored-by: Aaron van Geffen <aaron@aaronweb.net>
Co-authored-by: Hielke Morsink <hielke.morsink@gmail.com>
This commit is contained in:
Łukasz Pękalski 2020-10-20 22:02:44 +02:00 committed by GitHub
parent 853f718aee
commit 9dcbf6d4e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 1 deletions

View file

@ -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 #

View file

@ -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.

View file

@ -669,6 +669,8 @@ private:
SDLException::Throw("SDL_CreateWindow(...)");
}
ApplyScreenSaverLockSetting();
SDL_SetWindowMinimumSize(_window, 720, 480);
SetCursorTrap(gConfigGeneral.trap_cursor);
_platformUiContext->SetWindowIcon(_window);

View file

@ -11,6 +11,7 @@
#include "Theme.h"
#include <SDL.h>
#include <algorithm>
#include <openrct2/Context.h>
#include <openrct2/Input.h>
@ -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

View file

@ -13,3 +13,4 @@
#include <openrct2/interface/Window_internal.h>
void window_all_wheel_input();
void ApplyScreenSaverLockSetting();

View file

@ -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];

View file

@ -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);

View file

@ -42,6 +42,7 @@ struct GeneralConfiguration
bool show_fps;
bool multithreading;
bool minimize_fullscreen_focus_loss;
bool disable_screensaver;
// Map rendering
bool landscape_smoothing;

View file

@ -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
};