UI: Match System Time is now an active setting which you can toggle on/off.

This commit is contained in:
Evan Husted 2025-02-02 23:46:55 -06:00 committed by KeatonTheBot
parent d640f50203
commit 299b4cfe1d
6 changed files with 46 additions and 28 deletions

View file

@ -16,7 +16,7 @@ namespace Ryujinx.UI.Common.Configuration
/// <summary>
/// The current version of the file format
/// </summary>
public const int CurrentVersion = 57;
public const int CurrentVersion = 58;
/// <summary>
/// Version of the configuration file format
@ -143,6 +143,11 @@ namespace Ryujinx.UI.Common.Configuration
/// </summary>
public long SystemTimeOffset { get; set; }
/// <summary>
/// Instead of setting the time via configuration, use the values provided by the system.
/// </summary>
public bool MatchSystemTime { get; set; }
/// <summary>
/// Enables or disables Docked Mode
/// </summary>

View file

@ -325,6 +325,11 @@ namespace Ryujinx.UI.Common.Configuration
/// </summary>
public ReactiveObject<long> SystemTimeOffset { get; private set; }
/// <summary>
/// Instead of setting the time via configuration, use the values provided by the system.
/// </summary>
public ReactiveObject<bool> MatchSystemTime { get; private set; }
/// <summary>
/// Enables or disables Docked Mode
/// </summary>
@ -391,6 +396,9 @@ namespace Ryujinx.UI.Common.Configuration
Region = new ReactiveObject<Region>();
TimeZone = new ReactiveObject<string>();
SystemTimeOffset = new ReactiveObject<long>();
SystemTimeOffset.Event += static (sender, e) => LogValueChange(e, nameof(SystemTimeOffset));
MatchSystemTime = new ReactiveObject<bool>();
MatchSystemTime.Event += static (sender, e) => LogValueChange(e, nameof(MatchSystemTime));
EnableDockedMode = new ReactiveObject<bool>();
EnableDockedMode.Event += static (sender, e) => LogValueChange(e, nameof(EnableDockedMode));
EnablePtc = new ReactiveObject<bool>();
@ -749,6 +757,7 @@ namespace Ryujinx.UI.Common.Configuration
SystemRegion = System.Region,
SystemTimeZone = System.TimeZone,
SystemTimeOffset = System.SystemTimeOffset,
MatchSystemTime = System.MatchSystemTime,
DockedMode = System.EnableDockedMode,
EnableDiscordIntegration = EnableDiscordIntegration,
CheckUpdatesOnStart = CheckUpdatesOnStart,
@ -1630,6 +1639,15 @@ namespace Ryujinx.UI.Common.Configuration
configurationFileUpdated = true;
}
if (configurationFileFormat.Version < 58)
{
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 58.");
configurationFileFormat.MatchSystemTime = false;
configurationFileUpdated = true;
}
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
Graphics.ResScale.Value = configurationFileFormat.ResScale;
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
@ -1656,6 +1674,7 @@ namespace Ryujinx.UI.Common.Configuration
System.Region.Value = configurationFileFormat.SystemRegion;
System.TimeZone.Value = configurationFileFormat.SystemTimeZone;
System.SystemTimeOffset.Value = configurationFileFormat.SystemTimeOffset;
System.MatchSystemTime.Value = configurationFileFormat.MatchSystemTime;
System.EnableDockedMode.Value = configurationFileFormat.DockedMode;
EnableDiscordIntegration.Value = configurationFileFormat.EnableDiscordIntegration;
CheckUpdatesOnStart.Value = configurationFileFormat.CheckUpdatesOnStart;

View file

@ -923,7 +923,9 @@ namespace Ryujinx.Ava
ConfigurationState.Instance.System.EnableInternetAccess,
ConfigurationState.Instance.System.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None,
ConfigurationState.Instance.System.FsGlobalAccessLogMode,
ConfigurationState.Instance.System.SystemTimeOffset,
ConfigurationState.Instance.System.MatchSystemTime
? 0
: ConfigurationState.Instance.System.SystemTimeOffset,
ConfigurationState.Instance.System.TimeZone,
ConfigurationState.Instance.System.MemoryManagerMode,
ConfigurationState.Instance.System.IgnoreMissingServices,

View file

@ -331,6 +331,8 @@ namespace Ryujinx.Ava.UI.ViewModels
//private DateTimeOffset _currentDate;
//private TimeSpan _currentTime;
public bool MatchSystemTime { get; set; }
public DateTimeOffset CurrentDate { get; set; }
public TimeSpan CurrentTime { get; set; }
@ -456,18 +458,6 @@ namespace Ryujinx.Ava.UI.ViewModels
Dispatcher.UIThread.Post(() => OnPropertyChanged(nameof(PreferredGpuIndex)));
}
public void MatchSystemTime()
{
var dto = DateTimeOffset.Now;
CurrentDate = new DateTimeOffset(dto.Year, dto.Month, dto.Day, 0, 0, 0, dto.Offset);
CurrentTime = dto.TimeOfDay;
OnPropertyChanged(nameof(CurrentDate));
OnPropertyChanged(nameof(CurrentTime));
}
public async Task LoadTimeZones()
{
_timeZoneContentManager = new TimeZoneContentManager();
@ -569,7 +559,9 @@ namespace Ryujinx.Ava.UI.ViewModels
CurrentDate = currentDateTime.Date;
CurrentTime = currentDateTime.TimeOfDay;
EnableCustomVSyncInterval = config.Graphics.EnableCustomVSyncInterval.Value;
MatchSystemTime = config.System.MatchSystemTime;
EnableCustomVSyncInterval = config.Graphics.EnableCustomVSyncInterval;
CustomVSyncInterval = config.Graphics.CustomVSyncInterval;
VSyncMode = config.Graphics.VSyncMode;
EnableFsIntegrityChecks = config.System.EnableFsIntegrityChecks;
@ -675,6 +667,7 @@ namespace Ryujinx.Ava.UI.ViewModels
config.System.TimeZone.Value = TimeZone;
}
config.System.MatchSystemTime.Value = MatchSystemTime;
config.System.SystemTimeOffset.Value = Convert.ToInt64((CurrentDate.ToUnixTimeSeconds() + CurrentTime.TotalSeconds) - DateTimeOffset.Now.ToUnixTimeSeconds());
config.Graphics.VSyncMode.Value = VSyncMode;
config.Graphics.EnableCustomVSyncInterval.Value = EnableCustomVSyncInterval;

View file

@ -167,6 +167,7 @@
Width="250"/>
<DatePicker
VerticalAlignment="Center"
IsEnabled="{Binding !MatchSystemTime}"
SelectedDate="{Binding CurrentDate}"
ToolTip.Tip="{locale:Locale TimeTooltip}"
Width="350" />
@ -177,21 +178,21 @@
<TimePicker
VerticalAlignment="Center"
ClockIdentifier="24HourClock"
IsEnabled="{Binding !MatchSystemTime}"
SelectedTime="{Binding CurrentTime}"
Width="350"
ToolTip.Tip="{locale:Locale TimeTooltip}" />
</StackPanel>
<StackPanel
Margin="250,0,0,10"
Orientation="Horizontal">
<Button
<StackPanel Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
Click="MatchSystemTime_OnClick"
Background="{DynamicResource SystemAccentColor}"
Width="350"
ToolTip.Tip="{locale:Locale MatchTimeTooltip}">
<TextBlock Text="{locale:Locale SettingsTabSystemSystemTimeMatch}" />
</Button>
Text="{locale:Locale SettingsTabSystemSystemTimeMatch}"
ToolTip.Tip="{locale:Locale MatchTimeTooltip}"
Width="250"/>
<CheckBox
VerticalAlignment="Center"
IsChecked="{Binding MatchSystemTime}"
ToolTip.Tip="{locale:Locale MatchTimeTooltip}"/>
</StackPanel>
<Separator />
<StackPanel Margin="0,10,0,10"

View file

@ -35,7 +35,5 @@ namespace Ryujinx.Ava.UI.Views.Settings
ViewModel.ValidateAndSetTimeZone(timeZone.Location);
}
}
private void MatchSystemTime_OnClick(object sender, RoutedEventArgs e) => ViewModel.MatchSystemTime();
}
}