Procházet zdrojové kódy

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.
Evan Husted před 1 rokem
rodič
revize
d9fe0da345

+ 16 - 0
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 DateTimeOffset CurrentDate { get; set; }
+
         public TimeSpan CurrentTime { get; set; }
         public TimeSpan CurrentTime { get; set; }
 
 
         internal AvaloniaList<TimeZone> TimeZones { get; set; }
         internal AvaloniaList<TimeZone> TimeZones { get; set; }
@@ -453,6 +457,18 @@ namespace Ryujinx.Ava.UI.ViewModels
             Dispatcher.UIThread.Post(() => OnPropertyChanged(nameof(PreferredGpuIndex)));
             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()
         public async Task LoadTimeZones()
         {
         {
             _timeZoneContentManager = new TimeZoneContentManager();
             _timeZoneContentManager = new TimeZoneContentManager();

+ 14 - 1
src/Ryujinx/UI/Views/Settings/SettingsSystemView.axaml

@@ -182,7 +182,20 @@
                             Width="350"
                             Width="350"
                             ToolTip.Tip="{ext:Locale TimeTooltip}" />
                             ToolTip.Tip="{ext:Locale TimeTooltip}" />
                     </StackPanel>
                     </StackPanel>
-                    <StackPanel Margin="0,0,0,10"
+                    <StackPanel
+                        Margin="250,0,0,10"
+                        Orientation="Horizontal">
+                        <Button
+                            VerticalAlignment="Center"
+                            Click="MatchSystemTime_OnClick"
+                            Background="{DynamicResource SystemAccentColor}"
+                            Width="350"
+                            ToolTip.Tip="{ext:Locale TimeTooltip}">
+                            <TextBlock Text="Match System Time" />
+                        </Button>
+                    </StackPanel>
+                    <Separator />
+                    <StackPanel Margin="0,10,0,10"
                                 Orientation="Horizontal">
                                 Orientation="Horizontal">
                         <TextBlock
                         <TextBlock
                             VerticalAlignment="Center"
                             VerticalAlignment="Center"

+ 4 - 0
src/Ryujinx/UI/Views/Settings/SettingsSystemView.axaml.cs

@@ -1,5 +1,7 @@
 using Avalonia.Controls;
 using Avalonia.Controls;
+using Avalonia.Interactivity;
 using Ryujinx.Ava.UI.ViewModels;
 using Ryujinx.Ava.UI.ViewModels;
+using System;
 using TimeZone = Ryujinx.Ava.UI.Models.TimeZone;
 using TimeZone = Ryujinx.Ava.UI.Models.TimeZone;
 
 
 namespace Ryujinx.Ava.UI.Views.Settings
 namespace Ryujinx.Ava.UI.Views.Settings
@@ -33,5 +35,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
                 ViewModel.ValidateAndSetTimeZone(timeZone.Location);
                 ViewModel.ValidateAndSetTimeZone(timeZone.Location);
             }
             }
         }
         }
+
+        private void MatchSystemTime_OnClick(object sender, RoutedEventArgs e) => ViewModel.MatchSystemTime();
     }
     }
 }
 }