From d9fe0da3459c7d7dea9b693281328f27a21e23bc Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Sat, 21 Dec 2024 19:43:40 -0600 Subject: [PATCH] UI: Button to set emulator time based on system time in settings, under the time settings. Partially resolves #355. I think that wanted automatic. If automatic functionality is still desired even with this change then that will be considered. --- src/Ryujinx/UI/ViewModels/SettingsViewModel.cs | 16 ++++++++++++++++ .../UI/Views/Settings/SettingsSystemView.axaml | 15 ++++++++++++++- .../Views/Settings/SettingsSystemView.axaml.cs | 4 ++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs index a5abeb36b..8edf71a39 100644 --- a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs @@ -329,7 +329,11 @@ namespace Ryujinx.Ava.UI.ViewModels } } + //private DateTimeOffset _currentDate; + //private TimeSpan _currentTime; + public DateTimeOffset CurrentDate { get; set; } + public TimeSpan CurrentTime { get; set; } internal AvaloniaList TimeZones { get; set; } @@ -453,6 +457,18 @@ 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(); diff --git a/src/Ryujinx/UI/Views/Settings/SettingsSystemView.axaml b/src/Ryujinx/UI/Views/Settings/SettingsSystemView.axaml index e04e541c3..abb1a2e49 100644 --- a/src/Ryujinx/UI/Views/Settings/SettingsSystemView.axaml +++ b/src/Ryujinx/UI/Views/Settings/SettingsSystemView.axaml @@ -182,7 +182,20 @@ Width="350" ToolTip.Tip="{ext:Locale TimeTooltip}" /> - + + + + ViewModel.MatchSystemTime(); } }