Implement option to disable window size/position memory.
This commit is contained in:
parent
4062f4a4d3
commit
c1b0fd3246
6 changed files with 56 additions and 3 deletions
|
@ -15,7 +15,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current version of the file format
|
/// The current version of the file format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int CurrentVersion = 50;
|
public const int CurrentVersion = 51;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version of the configuration file format
|
/// Version of the configuration file format
|
||||||
|
@ -162,6 +162,11 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ShowConfirmExit { get; set; }
|
public bool ShowConfirmExit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enables or disables save window size, position and state on close.
|
||||||
|
/// </summary>
|
||||||
|
public bool RememberWindowState { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enables hardware-accelerated rendering for Avalonia
|
/// Enables hardware-accelerated rendering for Avalonia
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using LibHac.Tools.Npdm;
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
using Ryujinx.Common.Configuration;
|
using Ryujinx.Common.Configuration;
|
||||||
using Ryujinx.Common.Configuration.Hid;
|
using Ryujinx.Common.Configuration.Hid;
|
||||||
|
@ -626,6 +627,11 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ReactiveObject<bool> ShowConfirmExit { get; private set; }
|
public ReactiveObject<bool> ShowConfirmExit { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enables or disables save window size, position and state on close.
|
||||||
|
/// </summary>
|
||||||
|
public ReactiveObject<bool> RememberWindowState { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enables hardware-accelerated rendering for Avalonia
|
/// Enables hardware-accelerated rendering for Avalonia
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -647,6 +653,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
EnableDiscordIntegration = new ReactiveObject<bool>();
|
EnableDiscordIntegration = new ReactiveObject<bool>();
|
||||||
CheckUpdatesOnStart = new ReactiveObject<bool>();
|
CheckUpdatesOnStart = new ReactiveObject<bool>();
|
||||||
ShowConfirmExit = new ReactiveObject<bool>();
|
ShowConfirmExit = new ReactiveObject<bool>();
|
||||||
|
RememberWindowState = new ReactiveObject<bool>();
|
||||||
EnableHardwareAcceleration = new ReactiveObject<bool>();
|
EnableHardwareAcceleration = new ReactiveObject<bool>();
|
||||||
HideCursor = new ReactiveObject<HideCursorMode>();
|
HideCursor = new ReactiveObject<HideCursorMode>();
|
||||||
}
|
}
|
||||||
|
@ -684,6 +691,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
EnableDiscordIntegration = EnableDiscordIntegration,
|
EnableDiscordIntegration = EnableDiscordIntegration,
|
||||||
CheckUpdatesOnStart = CheckUpdatesOnStart,
|
CheckUpdatesOnStart = CheckUpdatesOnStart,
|
||||||
ShowConfirmExit = ShowConfirmExit,
|
ShowConfirmExit = ShowConfirmExit,
|
||||||
|
RememberWindowState = RememberWindowState,
|
||||||
EnableHardwareAcceleration = EnableHardwareAcceleration,
|
EnableHardwareAcceleration = EnableHardwareAcceleration,
|
||||||
HideCursor = HideCursor,
|
HideCursor = HideCursor,
|
||||||
EnableVsync = Graphics.EnableVsync,
|
EnableVsync = Graphics.EnableVsync,
|
||||||
|
@ -792,6 +800,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
EnableDiscordIntegration.Value = true;
|
EnableDiscordIntegration.Value = true;
|
||||||
CheckUpdatesOnStart.Value = true;
|
CheckUpdatesOnStart.Value = true;
|
||||||
ShowConfirmExit.Value = true;
|
ShowConfirmExit.Value = true;
|
||||||
|
RememberWindowState.Value = true;
|
||||||
EnableHardwareAcceleration.Value = true;
|
EnableHardwareAcceleration.Value = true;
|
||||||
HideCursor.Value = HideCursorMode.OnIdle;
|
HideCursor.Value = HideCursorMode.OnIdle;
|
||||||
Graphics.EnableVsync.Value = true;
|
Graphics.EnableVsync.Value = true;
|
||||||
|
@ -1459,6 +1468,15 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
configurationFileUpdated = true;
|
configurationFileUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (configurationFileFormat.Version < 51)
|
||||||
|
{
|
||||||
|
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 51.");
|
||||||
|
|
||||||
|
configurationFileFormat.RememberWindowState = true;
|
||||||
|
|
||||||
|
configurationFileUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
|
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
|
||||||
Graphics.ResScale.Value = configurationFileFormat.ResScale;
|
Graphics.ResScale.Value = configurationFileFormat.ResScale;
|
||||||
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
|
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
|
||||||
|
@ -1489,6 +1507,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
EnableDiscordIntegration.Value = configurationFileFormat.EnableDiscordIntegration;
|
EnableDiscordIntegration.Value = configurationFileFormat.EnableDiscordIntegration;
|
||||||
CheckUpdatesOnStart.Value = configurationFileFormat.CheckUpdatesOnStart;
|
CheckUpdatesOnStart.Value = configurationFileFormat.CheckUpdatesOnStart;
|
||||||
ShowConfirmExit.Value = configurationFileFormat.ShowConfirmExit;
|
ShowConfirmExit.Value = configurationFileFormat.ShowConfirmExit;
|
||||||
|
RememberWindowState.Value = configurationFileFormat.RememberWindowState;
|
||||||
EnableHardwareAcceleration.Value = configurationFileFormat.EnableHardwareAcceleration;
|
EnableHardwareAcceleration.Value = configurationFileFormat.EnableHardwareAcceleration;
|
||||||
HideCursor.Value = configurationFileFormat.HideCursor;
|
HideCursor.Value = configurationFileFormat.HideCursor;
|
||||||
Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync;
|
Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync;
|
||||||
|
|
|
@ -92,6 +92,7 @@
|
||||||
"SettingsTabGeneralEnableDiscordRichPresence": "Enable Discord Rich Presence",
|
"SettingsTabGeneralEnableDiscordRichPresence": "Enable Discord Rich Presence",
|
||||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "Check for Updates on Launch",
|
"SettingsTabGeneralCheckUpdatesOnLaunch": "Check for Updates on Launch",
|
||||||
"SettingsTabGeneralShowConfirmExitDialog": "Show \"Confirm Exit\" Dialog",
|
"SettingsTabGeneralShowConfirmExitDialog": "Show \"Confirm Exit\" Dialog",
|
||||||
|
"SettingsTabGeneralRememberWindowState": "Remember Window Size/Position",
|
||||||
"SettingsTabGeneralHideCursor": "Hide Cursor:",
|
"SettingsTabGeneralHideCursor": "Hide Cursor:",
|
||||||
"SettingsTabGeneralHideCursorNever": "Never",
|
"SettingsTabGeneralHideCursorNever": "Never",
|
||||||
"SettingsTabGeneralHideCursorOnIdle": "On Idle",
|
"SettingsTabGeneralHideCursorOnIdle": "On Idle",
|
||||||
|
|
|
@ -131,6 +131,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
public bool EnableDiscordIntegration { get; set; }
|
public bool EnableDiscordIntegration { get; set; }
|
||||||
public bool CheckUpdatesOnStart { get; set; }
|
public bool CheckUpdatesOnStart { get; set; }
|
||||||
public bool ShowConfirmExit { get; set; }
|
public bool ShowConfirmExit { get; set; }
|
||||||
|
public bool RememberWindowState { get; set; }
|
||||||
public int HideCursor { get; set; }
|
public int HideCursor { get; set; }
|
||||||
public bool EnableDockedMode { get; set; }
|
public bool EnableDockedMode { get; set; }
|
||||||
public bool EnableKeyboard { get; set; }
|
public bool EnableKeyboard { get; set; }
|
||||||
|
@ -390,6 +391,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
EnableDiscordIntegration = config.EnableDiscordIntegration;
|
EnableDiscordIntegration = config.EnableDiscordIntegration;
|
||||||
CheckUpdatesOnStart = config.CheckUpdatesOnStart;
|
CheckUpdatesOnStart = config.CheckUpdatesOnStart;
|
||||||
ShowConfirmExit = config.ShowConfirmExit;
|
ShowConfirmExit = config.ShowConfirmExit;
|
||||||
|
RememberWindowState = config.RememberWindowState;
|
||||||
HideCursor = (int)config.HideCursor.Value;
|
HideCursor = (int)config.HideCursor.Value;
|
||||||
|
|
||||||
GameDirectories.Clear();
|
GameDirectories.Clear();
|
||||||
|
@ -474,6 +476,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
config.EnableDiscordIntegration.Value = EnableDiscordIntegration;
|
config.EnableDiscordIntegration.Value = EnableDiscordIntegration;
|
||||||
config.CheckUpdatesOnStart.Value = CheckUpdatesOnStart;
|
config.CheckUpdatesOnStart.Value = CheckUpdatesOnStart;
|
||||||
config.ShowConfirmExit.Value = ShowConfirmExit;
|
config.ShowConfirmExit.Value = ShowConfirmExit;
|
||||||
|
config.RememberWindowState.Value = RememberWindowState;
|
||||||
config.HideCursor.Value = (HideCursorMode)HideCursor;
|
config.HideCursor.Value = (HideCursorMode)HideCursor;
|
||||||
|
|
||||||
if (_directoryChanged)
|
if (_directoryChanged)
|
||||||
|
|
|
@ -36,6 +36,9 @@
|
||||||
<CheckBox IsChecked="{Binding ShowConfirmExit}">
|
<CheckBox IsChecked="{Binding ShowConfirmExit}">
|
||||||
<TextBlock Text="{locale:Locale SettingsTabGeneralShowConfirmExitDialog}" />
|
<TextBlock Text="{locale:Locale SettingsTabGeneralShowConfirmExitDialog}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
<CheckBox IsChecked="{Binding RememberWindowState}">
|
||||||
|
<TextBlock Text="{locale:Locale SettingsTabGeneralRememberWindowState}" />
|
||||||
|
</CheckBox>
|
||||||
<StackPanel Margin="0, 15, 0, 0" Orientation="Horizontal">
|
<StackPanel Margin="0, 15, 0, 0" Orientation="Horizontal">
|
||||||
<TextBlock VerticalAlignment="Center"
|
<TextBlock VerticalAlignment="Center"
|
||||||
Text="{locale:Locale SettingsTabGeneralHideCursor}"
|
Text="{locale:Locale SettingsTabGeneralHideCursor}"
|
||||||
|
|
|
@ -324,6 +324,23 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
|
|
||||||
private void SetWindowSizePosition()
|
private void SetWindowSizePosition()
|
||||||
{
|
{
|
||||||
|
// WindowStartupLocation is unable to be used after the MainWindow is created.
|
||||||
|
// To center a window manually we need the raw display dimensions.
|
||||||
|
PixelPoint windowCenter = new(Screens.Primary.Bounds.Width / 4, Screens.Primary.Bounds.Height / 4);
|
||||||
|
|
||||||
|
if (!ConfigurationState.Instance.RememberWindowState)
|
||||||
|
{
|
||||||
|
ViewModel.WindowHeight = 777 * Program.WindowScaleFactor;
|
||||||
|
ViewModel.WindowWidth = 1280 * Program.WindowScaleFactor;
|
||||||
|
WindowState = WindowState.Normal;
|
||||||
|
|
||||||
|
Position = windowCenter;
|
||||||
|
|
||||||
|
Console.WriteLine($"{ViewModel.WindowWidth}, {ViewModel.WindowHeight}, {WindowState}, {Position}");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PixelPoint savedPoint = new(ConfigurationState.Instance.UI.WindowStartup.WindowPositionX,
|
PixelPoint savedPoint = new(ConfigurationState.Instance.UI.WindowStartup.WindowPositionX,
|
||||||
ConfigurationState.Instance.UI.WindowStartup.WindowPositionY);
|
ConfigurationState.Instance.UI.WindowStartup.WindowPositionY);
|
||||||
|
|
||||||
|
@ -338,8 +355,10 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
Position = windowCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"{ViewModel.WindowWidth}, {ViewModel.WindowHeight}, {WindowState}, {Position}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CheckScreenBounds(PixelPoint configPoint)
|
private bool CheckScreenBounds(PixelPoint configPoint)
|
||||||
|
@ -481,7 +500,10 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveWindowSizePosition();
|
if (ConfigurationState.Instance.RememberWindowState)
|
||||||
|
{
|
||||||
|
SaveWindowSizePosition();
|
||||||
|
}
|
||||||
|
|
||||||
ApplicationLibrary.CancelLoading();
|
ApplicationLibrary.CancelLoading();
|
||||||
InputManager.Dispose();
|
InputManager.Dispose();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue