mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-14 13:34:52 -04:00
Add setting to memorize window size (#2025)
* Add "Memorize Window Size" setting * Code review #2025 * memorize -> remember, helpText revision --------- Co-authored-by: Irastris <irastris15@gmail.com>
This commit is contained in:
@@ -134,6 +134,9 @@ struct UserSettings {
|
||||
ConfigVar<bool> enableFpsOverlay;
|
||||
ConfigVar<int> fpsOverlayCorner;
|
||||
ConfigVar<int> maxFrameRate;
|
||||
ConfigVar<bool> rememberWindowSize;
|
||||
ConfigVar<int> lastWindowWidth;
|
||||
ConfigVar<int> lastWindowHeight;
|
||||
} video;
|
||||
|
||||
struct {
|
||||
|
||||
@@ -11,6 +11,9 @@ UserSettings g_userSettings = {
|
||||
.enableFpsOverlay {"game.enableFpsOverlay", false},
|
||||
.fpsOverlayCorner {"game.fpsOverlayCorner", 0},
|
||||
.maxFrameRate {"video.maxFrameRate", 240},
|
||||
.rememberWindowSize {"video.rememberWindowSize", false},
|
||||
.lastWindowWidth {"video.lastWindowWidth", 0},
|
||||
.lastWindowHeight {"video.lastWindowHeight", 0},
|
||||
},
|
||||
|
||||
.audio = {
|
||||
@@ -200,6 +203,9 @@ void registerSettings() {
|
||||
Register(g_userSettings.video.enableFpsOverlay);
|
||||
Register(g_userSettings.video.fpsOverlayCorner);
|
||||
Register(g_userSettings.video.maxFrameRate);
|
||||
Register(g_userSettings.video.rememberWindowSize);
|
||||
Register(g_userSettings.video.lastWindowWidth);
|
||||
Register(g_userSettings.video.lastWindowHeight);
|
||||
|
||||
// Audio
|
||||
Register(g_userSettings.audio.masterVolume);
|
||||
|
||||
@@ -802,6 +802,21 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
|
||||
pane.add_rml(
|
||||
"<br/>Display the current framerate in a corner of the screen while playing.");
|
||||
});
|
||||
config_bool_select(leftPane, rightPane, getSettings().video.rememberWindowSize,
|
||||
{
|
||||
.key = "Remember Window Size",
|
||||
.helpText = "Save and restore the previous session's window size when opening Dusklight.",
|
||||
.onChange =
|
||||
[](bool value) {
|
||||
if (value && !dusk::getSettings().video.enableFullscreen) {
|
||||
const auto windowSize = aurora::window::get_window_size();
|
||||
dusk::getSettings().video.lastWindowWidth.setValue(windowSize.width);
|
||||
dusk::getSettings().video.lastWindowHeight.setValue(windowSize.height);
|
||||
dusk::config::Save();
|
||||
}
|
||||
},
|
||||
.isDisabled = [] { return IsMobile; },
|
||||
});
|
||||
leftPane.add_section("Resolution");
|
||||
graphics_tuner_control(*this, leftPane, rightPane,
|
||||
getSettings().game.internalResolutionScale,
|
||||
|
||||
+19
-2
@@ -259,6 +259,13 @@ void main01(void) {
|
||||
dusk::ui::handle_event(event->sdl);
|
||||
dusk::g_imguiConsole.HandleSDLEvent(event->sdl);
|
||||
break;
|
||||
case AURORA_WINDOW_RESIZED:
|
||||
if (dusk::getSettings().video.rememberWindowSize && !dusk::getSettings().video.enableFullscreen) {
|
||||
dusk::getSettings().video.lastWindowWidth.setValue(event->windowSize.width);
|
||||
dusk::getSettings().video.lastWindowHeight.setValue(event->windowSize.height);
|
||||
dusk::config::Save();
|
||||
}
|
||||
break;
|
||||
case AURORA_DISPLAY_SCALE_CHANGED:
|
||||
dusk::ImGuiEngine_Initialize(event->windowSize.scale);
|
||||
break;
|
||||
@@ -584,8 +591,18 @@ int game_main(int argc, char* argv[]) {
|
||||
config.startFullscreen = dusk::getSettings().video.enableFullscreen;
|
||||
config.windowPosX = -1;
|
||||
config.windowPosY = -1;
|
||||
config.windowWidth = defaultWindowWidth * 2;
|
||||
config.windowHeight = defaultWindowHeight * 2;
|
||||
|
||||
const int lastWindowWidth = dusk::getSettings().video.lastWindowWidth.getValue();
|
||||
const int lastWindowHeight = dusk::getSettings().video.lastWindowHeight.getValue();
|
||||
|
||||
if (dusk::getSettings().video.rememberWindowSize && lastWindowWidth > 0 && lastWindowHeight > 0) {
|
||||
config.windowWidth = lastWindowWidth;
|
||||
config.windowHeight = lastWindowHeight;
|
||||
} else {
|
||||
config.windowWidth = defaultWindowWidth * 2;
|
||||
config.windowHeight = defaultWindowHeight * 2;
|
||||
}
|
||||
|
||||
config.desiredBackend = ResolveDesiredBackend(parsed_arg_options);
|
||||
config.logCallback = &aurora_log_callback;
|
||||
config.logLevel = startupLogLevel;
|
||||
|
||||
Reference in New Issue
Block a user