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>
|
||||
/// The current version of the file format
|
||||
/// </summary>
|
||||
public const int CurrentVersion = 50;
|
||||
public const int CurrentVersion = 51;
|
||||
|
||||
/// <summary>
|
||||
/// Version of the configuration file format
|
||||
|
@ -162,6 +162,11 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
/// </summary>
|
||||
public bool ShowConfirmExit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables save window size, position and state on close.
|
||||
/// </summary>
|
||||
public bool RememberWindowState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enables hardware-accelerated rendering for Avalonia
|
||||
/// </summary>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using LibHac.Tools.Npdm;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Configuration.Hid;
|
||||
|
@ -626,6 +627,11 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
/// </summary>
|
||||
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>
|
||||
/// Enables hardware-accelerated rendering for Avalonia
|
||||
/// </summary>
|
||||
|
@ -647,6 +653,7 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
EnableDiscordIntegration = new ReactiveObject<bool>();
|
||||
CheckUpdatesOnStart = new ReactiveObject<bool>();
|
||||
ShowConfirmExit = new ReactiveObject<bool>();
|
||||
RememberWindowState = new ReactiveObject<bool>();
|
||||
EnableHardwareAcceleration = new ReactiveObject<bool>();
|
||||
HideCursor = new ReactiveObject<HideCursorMode>();
|
||||
}
|
||||
|
@ -684,6 +691,7 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
EnableDiscordIntegration = EnableDiscordIntegration,
|
||||
CheckUpdatesOnStart = CheckUpdatesOnStart,
|
||||
ShowConfirmExit = ShowConfirmExit,
|
||||
RememberWindowState = RememberWindowState,
|
||||
EnableHardwareAcceleration = EnableHardwareAcceleration,
|
||||
HideCursor = HideCursor,
|
||||
EnableVsync = Graphics.EnableVsync,
|
||||
|
@ -792,6 +800,7 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
EnableDiscordIntegration.Value = true;
|
||||
CheckUpdatesOnStart.Value = true;
|
||||
ShowConfirmExit.Value = true;
|
||||
RememberWindowState.Value = true;
|
||||
EnableHardwareAcceleration.Value = true;
|
||||
HideCursor.Value = HideCursorMode.OnIdle;
|
||||
Graphics.EnableVsync.Value = true;
|
||||
|
@ -1459,6 +1468,15 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
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;
|
||||
Graphics.ResScale.Value = configurationFileFormat.ResScale;
|
||||
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
|
||||
|
@ -1489,6 +1507,7 @@ namespace Ryujinx.UI.Common.Configuration
|
|||
EnableDiscordIntegration.Value = configurationFileFormat.EnableDiscordIntegration;
|
||||
CheckUpdatesOnStart.Value = configurationFileFormat.CheckUpdatesOnStart;
|
||||
ShowConfirmExit.Value = configurationFileFormat.ShowConfirmExit;
|
||||
RememberWindowState.Value = configurationFileFormat.RememberWindowState;
|
||||
EnableHardwareAcceleration.Value = configurationFileFormat.EnableHardwareAcceleration;
|
||||
HideCursor.Value = configurationFileFormat.HideCursor;
|
||||
Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync;
|
||||
|
|
|
@ -92,6 +92,7 @@
|
|||
"SettingsTabGeneralEnableDiscordRichPresence": "Enable Discord Rich Presence",
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "Check for Updates on Launch",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "Show \"Confirm Exit\" Dialog",
|
||||
"SettingsTabGeneralRememberWindowState": "Remember Window Size/Position",
|
||||
"SettingsTabGeneralHideCursor": "Hide Cursor:",
|
||||
"SettingsTabGeneralHideCursorNever": "Never",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "On Idle",
|
||||
|
|
|
@ -131,6 +131,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
public bool EnableDiscordIntegration { get; set; }
|
||||
public bool CheckUpdatesOnStart { get; set; }
|
||||
public bool ShowConfirmExit { get; set; }
|
||||
public bool RememberWindowState { get; set; }
|
||||
public int HideCursor { get; set; }
|
||||
public bool EnableDockedMode { get; set; }
|
||||
public bool EnableKeyboard { get; set; }
|
||||
|
@ -390,6 +391,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
EnableDiscordIntegration = config.EnableDiscordIntegration;
|
||||
CheckUpdatesOnStart = config.CheckUpdatesOnStart;
|
||||
ShowConfirmExit = config.ShowConfirmExit;
|
||||
RememberWindowState = config.RememberWindowState;
|
||||
HideCursor = (int)config.HideCursor.Value;
|
||||
|
||||
GameDirectories.Clear();
|
||||
|
@ -474,6 +476,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
config.EnableDiscordIntegration.Value = EnableDiscordIntegration;
|
||||
config.CheckUpdatesOnStart.Value = CheckUpdatesOnStart;
|
||||
config.ShowConfirmExit.Value = ShowConfirmExit;
|
||||
config.RememberWindowState.Value = RememberWindowState;
|
||||
config.HideCursor.Value = (HideCursorMode)HideCursor;
|
||||
|
||||
if (_directoryChanged)
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
<CheckBox IsChecked="{Binding ShowConfirmExit}">
|
||||
<TextBlock Text="{locale:Locale SettingsTabGeneralShowConfirmExitDialog}" />
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding RememberWindowState}">
|
||||
<TextBlock Text="{locale:Locale SettingsTabGeneralRememberWindowState}" />
|
||||
</CheckBox>
|
||||
<StackPanel Margin="0, 15, 0, 0" Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{locale:Locale SettingsTabGeneralHideCursor}"
|
||||
|
|
|
@ -324,6 +324,23 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
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,
|
||||
ConfigurationState.Instance.UI.WindowStartup.WindowPositionY);
|
||||
|
||||
|
@ -338,8 +355,10 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
}
|
||||
else
|
||||
{
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
Position = windowCenter;
|
||||
}
|
||||
|
||||
Console.WriteLine($"{ViewModel.WindowWidth}, {ViewModel.WindowHeight}, {WindowState}, {Position}");
|
||||
}
|
||||
|
||||
private bool CheckScreenBounds(PixelPoint configPoint)
|
||||
|
@ -481,7 +500,10 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
return;
|
||||
}
|
||||
|
||||
SaveWindowSizePosition();
|
||||
if (ConfigurationState.Instance.RememberWindowState)
|
||||
{
|
||||
SaveWindowSizePosition();
|
||||
}
|
||||
|
||||
ApplicationLibrary.CancelLoading();
|
||||
InputManager.Dispose();
|
||||
|
|
Loading…
Add table
Reference in a new issue