Skip to content

Commit

Permalink
Save custom replay length in user settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ColonelChocomel committed Apr 26, 2022
1 parent b283583 commit 471ca53
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
1 change: 0 additions & 1 deletion ACCBroadcaster/Classes/ACCService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ namespace ACCBroadcaster.Classes
public static class ACCService
{
public static ACCUdpRemoteClient Client;
public static int CustomReplayLength = 5;
}
}
12 changes: 12 additions & 0 deletions ACCBroadcaster/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ACCBroadcaster/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
<Setting Name="LoginRemembered" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="CustomReplayLength" Type="System.Int32" Scope="User">
<Value Profile="(Default)">5</Value>
</Setting>
</Settings>
</SettingsFile>
3 changes: 2 additions & 1 deletion ACCBroadcaster/Views/Broadcasting/CarListView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using ACCBroadcaster.Properties;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand Down Expand Up @@ -275,7 +276,7 @@ private void OnCarContextReplayClicked(object sender, RoutedEventArgs e)
float length;
if (item.Name == "Custom")
{
length = ACCService.CustomReplayLength;
length = Settings.Default.CustomReplayLength;
}
else
{
Expand Down
1 change: 0 additions & 1 deletion ACCBroadcaster/Views/Broadcasting/InstantReplayView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<TextBlock>Custom length:</TextBlock>
<StackPanel Orientation="Horizontal">
<NumberBox x:Name="CustomLengthNumberBox"
Value="5"
SpinButtonPlacementMode="Inline"
SmallChange="5"
Margin="10"
Expand Down
7 changes: 5 additions & 2 deletions ACCBroadcaster/Views/Broadcasting/InstantReplayView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using ACCBroadcaster.Properties;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand All @@ -30,6 +31,7 @@ public InstantReplayView()
{
ACCService.Client.MessageHandler.OnRealtimeUpdate += OnRealtimeUpdate;
this.InitializeComponent();
CustomLengthNumberBox.Value = Settings.Default.CustomReplayLength;
}

private void StartInstantReplay(object sender, RoutedEventArgs e)
Expand All @@ -38,7 +40,7 @@ private void StartInstantReplay(object sender, RoutedEventArgs e)
float length;
if (button.CommandParameter == null)
{
length = ACCService.CustomReplayLength;
length = Settings.Default.CustomReplayLength;
} else
{
length = (float)Convert.ToDouble(button.CommandParameter);
Expand All @@ -61,7 +63,8 @@ private void OnRealtimeUpdate(string sender, RealtimeUpdate update)

private void CustomLengthNumberBox_ValueChanged(NumberBox sender, NumberBoxValueChangedEventArgs args)
{
ACCService.CustomReplayLength = (int)sender.Value;
Settings.Default.CustomReplayLength = (int)sender.Value;
Settings.Default.Save();
}
}
}

0 comments on commit 471ca53

Please sign in to comment.