mirror of
https://github.com/ZuneDev/ZuneModdingHelper.git
synced 2026-07-27 13:12:21 -07:00
Implement settings save/load
This commit is contained in:
@@ -42,7 +42,7 @@ namespace ZuneModdingHelper
|
||||
services.AddSingleton(github);
|
||||
|
||||
services.AddSingleton<IModCoreConfig>(Settings.Default);
|
||||
services.AddSingleton<OwlCore.ComponentModel.SettingsBase>(Settings.Default);
|
||||
services.AddSingleton(Settings.Default);
|
||||
|
||||
Ioc.Default.ConfigureServices(services.BuildServiceProvider());
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Animation;
|
||||
using ZuneModCore;
|
||||
using ZuneModdingHelper.Controls;
|
||||
using ZuneModdingHelper.Messages;
|
||||
using ZuneModdingHelper.Pages;
|
||||
using ZuneModdingHelper.Services;
|
||||
|
||||
namespace ZuneModdingHelper
|
||||
{
|
||||
@@ -27,6 +27,7 @@ namespace ZuneModdingHelper
|
||||
|
||||
private readonly Type[] _pages = [typeof(ModsPage), typeof(SettingsPage), typeof(AboutPage)];
|
||||
private readonly Storyboard _dialogExitAnimation;
|
||||
private readonly Settings _settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
|
||||
public AppWindow()
|
||||
{
|
||||
@@ -40,11 +41,13 @@ namespace ZuneModdingHelper
|
||||
WeakReferenceMessenger.Default.Register<CloseDialogMessage>(this);
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
private async void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await _settings.LoadAsync();
|
||||
|
||||
// Show a warning if Zune is running
|
||||
Process[] procs = Process.GetProcessesByName("Zune");
|
||||
string zuneExePath = System.IO.Path.Combine(Mod.DefaultZuneInstallDir, "Zune.exe");
|
||||
string zuneExePath = System.IO.Path.Combine(_settings.ZuneInstallDir, "Zune.exe");
|
||||
if (procs.Length > 0 && procs.Any(p => p.MainModule.FileName == zuneExePath))
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new ShowDialogMessage(new()
|
||||
|
||||
@@ -11,16 +11,6 @@
|
||||
d:DesignHeight="350" d:DesignWidth="750"
|
||||
d:Background="White">
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="AboutTextBlockStyle" TargetType="TextBlock" BasedOn="{StaticResource ZuneTextBlock}">
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="TextWrapping" Value="Wrap"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource ZuneMediumTextBrush}"/>
|
||||
</Style>
|
||||
<Style x:Key="HeaderTextStyle" TargetType="Run">
|
||||
<Setter Property="FontSize" Value="20"/>
|
||||
<Setter Property="FontFamily" Value="Segoe UI"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
</Style>
|
||||
<Style TargetType="Hyperlink" BasedOn="{StaticResource {x:Type Hyperlink}}">
|
||||
<Setter Property="Foreground" Value="{StaticResource ZuneMediumTextBrush}"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
@@ -38,8 +28,8 @@
|
||||
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel>
|
||||
<TextBlock Style="{StaticResource AboutTextBlockStyle}">
|
||||
<Run Text="Version" Style="{StaticResource HeaderTextStyle}"/><LineBreak/>
|
||||
<TextBlock Style="{StaticResource ZuneBodyTextBlockStyle}">
|
||||
<Run Text="Version" Style="{StaticResource ZuneHeaderTextStyle}"/><LineBreak/>
|
||||
<Run Text="{x:Static zmh:App.VersionStr}"/><LineBreak/>
|
||||
<Hyperlink NavigateUri="{x:Static zmh:App.VersionUri}" RequestNavigate="Link_RequestNavigate">
|
||||
<Run Text="" FontFamily="{StaticResource ZMHIcons}"/>
|
||||
@@ -50,8 +40,8 @@
|
||||
Margin="0,8,0,12" Padding="8,0" HorizontalAlignment="Left"
|
||||
Style="{StaticResource ActionButtonStyle}"/>
|
||||
|
||||
<TextBlock Style="{StaticResource AboutTextBlockStyle}">
|
||||
<Run Text="Community" Style="{StaticResource HeaderTextStyle}"/><LineBreak/>
|
||||
<TextBlock Style="{StaticResource ZuneBodyTextBlockStyle}">
|
||||
<Run Text="Community" Style="{StaticResource ZuneHeaderTextStyle}"/><LineBreak/>
|
||||
<Hyperlink NavigateUri="https://reddit.com/r/Zune" RequestNavigate="Link_RequestNavigate">
|
||||
<Run Text="" FontFamily="{StaticResource ZMHIcons}"/>
|
||||
<Run Text="join r/zune subreddit"/>
|
||||
@@ -62,8 +52,8 @@
|
||||
</Hyperlink><LineBreak/>
|
||||
</TextBlock>
|
||||
|
||||
<TextBlock Style="{StaticResource AboutTextBlockStyle}">
|
||||
<Run Text="Development" Style="{StaticResource HeaderTextStyle}"/><LineBreak/>
|
||||
<TextBlock Style="{StaticResource ZuneBodyTextBlockStyle}">
|
||||
<Run Text="Development" Style="{StaticResource ZuneHeaderTextStyle}"/><LineBreak/>
|
||||
<Run Text="by Joshua "Yoshi" Askharoun." FontWeight="SemiBold"/>
|
||||
<Run Text="Mods included with authors' permission."/><LineBreak/>
|
||||
<LineBreak/>
|
||||
|
||||
@@ -4,9 +4,20 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:ZuneModdingHelper.Pages"
|
||||
xmlns:zmhs="clr-namespace:ZuneModdingHelper.Services"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<TextBlock Text="SETTINGS" FontSize="50" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Grid>
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
Unloaded="SettingsPage_Unloaded"
|
||||
DataContext="{x:Static zmhs:Settings.Default}">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel>
|
||||
<TextBlock Style="{StaticResource ZuneBodyTextBlockStyle}">
|
||||
<Run Text="Zune" Style="{StaticResource ZuneHeaderTextStyle}"/>
|
||||
</TextBlock>
|
||||
<TextBlock Text="Choose the directory where the Zune software is installed." Margin="0,8"
|
||||
Style="{StaticResource ZuneBodyTextBlockStyle}" />
|
||||
<TextBox VerticalAlignment="Top"
|
||||
Text="{Binding ZuneInstallDir}"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using ZuneModdingHelper.Services;
|
||||
|
||||
namespace ZuneModdingHelper.Pages
|
||||
{
|
||||
@@ -23,6 +12,12 @@ namespace ZuneModdingHelper.Pages
|
||||
public SettingsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = Settings.Default;
|
||||
}
|
||||
|
||||
private async void SettingsPage_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Settings.Default.SaveAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,18 @@
|
||||
<Setter Property="Typography.StylisticSet1" Value="True"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ZuneBodyTextBlockStyle" TargetType="TextBlock" BasedOn="{StaticResource ZuneTextBlock}">
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="TextWrapping" Value="Wrap"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource ZuneMediumTextBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ZuneHeaderTextStyle" TargetType="Run">
|
||||
<Setter Property="FontSize" Value="20"/>
|
||||
<Setter Property="FontFamily" Value="Segoe UI"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ActionButtonStyle" TargetType="Button">
|
||||
<Style.Resources>
|
||||
<!-- Border -->
|
||||
|
||||
Reference in New Issue
Block a user