added ability to change save paths for RPC and Key files
This commit is contained in:
parent
b95fb58925
commit
287dffbb5d
11 changed files with 176 additions and 14 deletions
|
@ -58,12 +58,38 @@ namespace WeeXnes
|
||||||
SaveSettingsHandler.Data.KeyManager.Section,
|
SaveSettingsHandler.Data.KeyManager.Section,
|
||||||
SaveSettingsHandler.Data.KeyManager.CensorKeys));
|
SaveSettingsHandler.Data.KeyManager.CensorKeys));
|
||||||
|
|
||||||
|
//Load paths
|
||||||
|
|
||||||
|
string customRpcPath = SettingsView.Data.settingsFile.GetValue(
|
||||||
|
SaveSettingsHandler.Data.General.Section,
|
||||||
|
SaveSettingsHandler.Data.General.RpcFilesPath
|
||||||
|
);
|
||||||
|
if (!String.IsNullOrEmpty(customRpcPath))
|
||||||
|
{
|
||||||
|
Global.AppDataPathRPC.Value = customRpcPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Global.AppDataPathRPC.Value = Global.Defaults.DefaultPathRPC;
|
||||||
|
}
|
||||||
|
string customKeyPath = SettingsView.Data.settingsFile.GetValue(
|
||||||
|
SaveSettingsHandler.Data.General.Section,
|
||||||
|
SaveSettingsHandler.Data.General.KeyFilesPath
|
||||||
|
);
|
||||||
|
if (!String.IsNullOrEmpty(customKeyPath))
|
||||||
|
{
|
||||||
|
Global.AppDataPathKEY.Value = customKeyPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Global.AppDataPathKEY.Value = Global.Defaults.DefaultPathKEY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadFiles()
|
private void LoadFiles()
|
||||||
{
|
{
|
||||||
Functions.CheckFolderAndCreate(Global.AppDataPathRPC);
|
Functions.CheckFolderAndCreate(Global.AppDataPathRPC.Value);
|
||||||
DirectoryInfo rpcDirectoryInfo = new DirectoryInfo(Global.AppDataPathRPC);
|
DirectoryInfo rpcDirectoryInfo = new DirectoryInfo(Global.AppDataPathRPC.Value);
|
||||||
foreach (var file in rpcDirectoryInfo.GetFiles("*.rpc"))
|
foreach (var file in rpcDirectoryInfo.GetFiles("*.rpc"))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -78,8 +104,8 @@ namespace WeeXnes
|
||||||
MessageBox.Show(file.Name + ": " + ex.Message);
|
MessageBox.Show(file.Name + ": " + ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Functions.CheckFolderAndCreate(Global.AppDataPathKEY);
|
Functions.CheckFolderAndCreate(Global.AppDataPathKEY.Value);
|
||||||
DirectoryInfo keyDirectoryInfo = new DirectoryInfo(Global.AppDataPathKEY);
|
DirectoryInfo keyDirectoryInfo = new DirectoryInfo(Global.AppDataPathKEY.Value);
|
||||||
foreach (var file in keyDirectoryInfo.GetFiles("*.wx"))
|
foreach (var file in keyDirectoryInfo.GetFiles("*.wx"))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace WeeXnes.Core
|
namespace WeeXnes.Core
|
||||||
{
|
{
|
||||||
public class Information
|
public class Information
|
||||||
{
|
{
|
||||||
public const string Version = "4.2.0";
|
public const string Version = "4.2.1";
|
||||||
public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
|
public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
|
||||||
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
|
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
|
||||||
}
|
}
|
||||||
|
@ -14,8 +16,18 @@ namespace WeeXnes.Core
|
||||||
public class Global
|
public class Global
|
||||||
{
|
{
|
||||||
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes");
|
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes");
|
||||||
public static string AppDataPathRPC = Path.Combine(AppDataPath, "RPC");
|
public static UpdateVar<string> AppDataPathRPC = new UpdateVar<string>();
|
||||||
public static string AppDataPathKEY = Path.Combine(AppDataPath, "Keys");
|
public static UpdateVar<string> AppDataPathKEY = new UpdateVar<string>();
|
||||||
public static string SettingsFile = "settings.ini";
|
public static string SettingsFile = "settings.ini";
|
||||||
|
public class Defaults
|
||||||
|
{
|
||||||
|
public static string DefaultPathRPC = Path.Combine(AppDataPath, "RPC");
|
||||||
|
public static string DefaultPathKEY = Path.Combine(AppDataPath, "Keys");
|
||||||
|
}
|
||||||
|
public static void ForceClose()
|
||||||
|
{
|
||||||
|
System.Windows.Forms.Application.Restart();
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,8 @@
|
||||||
using System.Collections.Specialized;
|
using System;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Net.Mime;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Windows;
|
||||||
using WeeXnes.Views.KeyManager;
|
using WeeXnes.Views.KeyManager;
|
||||||
using WeeXnes.Views.Settings;
|
using WeeXnes.Views.Settings;
|
||||||
|
|
||||||
|
@ -12,6 +16,8 @@ namespace WeeXnes.Core
|
||||||
public static class General
|
public static class General
|
||||||
{
|
{
|
||||||
public const string Section = "GENERAL";
|
public const string Section = "GENERAL";
|
||||||
|
public const string RpcFilesPath = "RpcFilesPath";
|
||||||
|
public const string KeyFilesPath = "KeyFilesPath";
|
||||||
}
|
}
|
||||||
public static class KeyManager
|
public static class KeyManager
|
||||||
{
|
{
|
||||||
|
@ -42,6 +48,22 @@ namespace WeeXnes.Core
|
||||||
KeyManagerView.Data.censorKeys.Value.ToString()
|
KeyManagerView.Data.censorKeys.Value.ToString()
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Global.AppDataPathRPC.ValueChanged += () =>
|
||||||
|
{
|
||||||
|
SettingsView.Data.settingsFile.SetValue(
|
||||||
|
Data.General.Section,
|
||||||
|
Data.General.RpcFilesPath,
|
||||||
|
Global.AppDataPathRPC.Value
|
||||||
|
);
|
||||||
|
};
|
||||||
|
Global.AppDataPathKEY.ValueChanged += () =>
|
||||||
|
{
|
||||||
|
SettingsView.Data.settingsFile.SetValue(
|
||||||
|
Data.General.Section,
|
||||||
|
Data.General.KeyFilesPath,
|
||||||
|
Global.AppDataPathKEY.Value
|
||||||
|
);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -55,7 +55,7 @@ namespace WeeXnes.Views.DiscordRPC
|
||||||
if(selectedCache == null)
|
if(selectedCache == null)
|
||||||
return;
|
return;
|
||||||
Data.Games.Remove(selectedCache);
|
Data.Games.Remove(selectedCache);
|
||||||
File.Delete(Global.AppDataPathRPC + "\\" + selectedCache.UUID + ".rpc");
|
File.Delete(Global.AppDataPathRPC.Value + "\\" + selectedCache.UUID + ".rpc");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ namespace WeeXnes.Views.DiscordRPC
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
INIFile rpcFile = new INIFile(Global.AppDataPathRPC + "\\" + this.UUID + ".rpc", true);
|
INIFile rpcFile = new INIFile(Global.AppDataPathRPC.Value + "\\" + this.UUID + ".rpc", true);
|
||||||
rpcFile.SetValue(
|
rpcFile.SetValue(
|
||||||
SaveSettingsHandler.Data.DiscordRpcFiles.Section,
|
SaveSettingsHandler.Data.DiscordRpcFiles.Section,
|
||||||
SaveSettingsHandler.Data.DiscordRpcFiles.ProcessName,
|
SaveSettingsHandler.Data.DiscordRpcFiles.ProcessName,
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace WeeXnes.Views.KeyManager
|
||||||
tb_keyvalue.Text
|
tb_keyvalue.Text
|
||||||
);
|
);
|
||||||
WXFile wxFile = new WXFile(
|
WXFile wxFile = new WXFile(
|
||||||
Global.AppDataPathKEY + "\\" + newKey.Filename);
|
Global.AppDataPathKEY.Value + "\\" + newKey.Filename);
|
||||||
WXFile.Methods.WriteFile(newKey, wxFile);
|
WXFile.Methods.WriteFile(newKey, wxFile);
|
||||||
Data.KeyItemsList.Add(newKey);
|
Data.KeyItemsList.Add(newKey);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ namespace WeeXnes.Views.KeyManager
|
||||||
Data.KeyItemsList.Remove(removeItem);
|
Data.KeyItemsList.Remove(removeItem);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Delete(Global.AppDataPathKEY + "\\" + removeItem.Filename);
|
File.Delete(Global.AppDataPathKEY.Value + "\\" + removeItem.Filename);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
49
WeeXnes/Views/Settings/ChangePathsView.xaml
Normal file
49
WeeXnes/Views/Settings/ChangePathsView.xaml
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<Page x:Class="WeeXnes.Views.Settings.ChangePathsView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:WeeXnes.Views.Settings"
|
||||||
|
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="ChangePathsView" Height="Auto" Width="Auto"
|
||||||
|
Loaded="ChangePathsView_OnLoaded">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="45"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<ScrollViewer Grid.Row="0">
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<TextBlock Text="Requires Restart after changing!!!" Foreground="White"
|
||||||
|
HorizontalAlignment="Center"/>
|
||||||
|
|
||||||
|
<TextBlock Text="(will auto close after saving)" FontSize="10" Foreground="White"
|
||||||
|
HorizontalAlignment="Center"/>
|
||||||
|
<ui:TextBox Name="TextboxKeyPath" PlaceholderText="Key Files Path" Margin="0,4"/>
|
||||||
|
<ui:TextBox Name="TextboxRPCPath" PlaceholderText="Client ID" Margin="0,4"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
|
<Grid Grid.Row="1">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ui:Button
|
||||||
|
Padding="24,6"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Content="Cancel"
|
||||||
|
Icon="CaretLeft24"
|
||||||
|
Name="ButtonCancelDialog"
|
||||||
|
Click="ButtonCancelDialog_OnClick"/>
|
||||||
|
<ui:Button Grid.Column="1"
|
||||||
|
Padding="24,6"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Content="Save"
|
||||||
|
Icon="SaveMultiple24"
|
||||||
|
Name="ButtonSaveDialog"
|
||||||
|
Click="ButtonSaveDialog_OnClick"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
33
WeeXnes/Views/Settings/ChangePathsView.xaml.cs
Normal file
33
WeeXnes/Views/Settings/ChangePathsView.xaml.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using WeeXnes.Core;
|
||||||
|
|
||||||
|
namespace WeeXnes.Views.Settings
|
||||||
|
{
|
||||||
|
public partial class ChangePathsView : Page
|
||||||
|
{
|
||||||
|
public ChangePathsView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangePathsView_OnLoaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
TextboxKeyPath.Text = Global.AppDataPathKEY.Value;
|
||||||
|
TextboxRPCPath.Text = Global.AppDataPathRPC.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancelDialog_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
NavigationService.Navigate(new Uri("/Views/Settings/SettingsView.xaml",UriKind.Relative));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSaveDialog_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Global.AppDataPathRPC.Value = TextboxRPCPath.Text;
|
||||||
|
Global.AppDataPathKEY.Value = TextboxKeyPath.Text;
|
||||||
|
Global.ForceClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,7 +29,7 @@
|
||||||
<ui:CardAction Icon="LinkSquare20"
|
<ui:CardAction Icon="LinkSquare20"
|
||||||
Name="ButtonCreateStartMenuShortcut"
|
Name="ButtonCreateStartMenuShortcut"
|
||||||
Click="ButtonCreateStartMenuShortcut_OnClick"
|
Click="ButtonCreateStartMenuShortcut_OnClick"
|
||||||
Margin="0,10">
|
Margin="0,10,0,0">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="0,0,0,4"
|
Margin="0,0,0,4"
|
||||||
|
@ -38,6 +38,18 @@
|
||||||
/>
|
/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ui:CardAction>
|
</ui:CardAction>
|
||||||
|
<ui:CardAction Icon="Folder32"
|
||||||
|
Name="ChangePathsButton"
|
||||||
|
Click="ChangePathsButton_OnClick"
|
||||||
|
Margin="0,10">
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock
|
||||||
|
Margin="0,0,0,4"
|
||||||
|
FontWeight="Medium"
|
||||||
|
Text="Change paths for Key and RPC files"
|
||||||
|
/>
|
||||||
|
</StackPanel>
|
||||||
|
</ui:CardAction>
|
||||||
<TextBlock Text="Key Manager"
|
<TextBlock Text="Key Manager"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Foreground="White"/>
|
Foreground="White"/>
|
||||||
|
|
|
@ -105,5 +105,9 @@ namespace WeeXnes.Views.Settings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ChangePathsButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
NavigationService.Navigate(new Uri("/Views/Settings/ChangePathsView.xaml",UriKind.Relative));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<Version>4.2.0</Version>
|
<Version>4.2.1</Version>
|
||||||
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
|
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>WeeXnes</RootNamespace>
|
<RootNamespace>WeeXnes</RootNamespace>
|
||||||
|
@ -91,6 +91,9 @@
|
||||||
<DependentUpon>KeyManagerView.xaml</DependentUpon>
|
<DependentUpon>KeyManagerView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Views\Settings\ApiResponse.cs" />
|
<Compile Include="Views\Settings\ApiResponse.cs" />
|
||||||
|
<Compile Include="Views\Settings\ChangePathsView.xaml.cs">
|
||||||
|
<DependentUpon>ChangePathsView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\Settings\SettingsView.xaml.cs">
|
<Compile Include="Views\Settings\SettingsView.xaml.cs">
|
||||||
<DependentUpon>SettingsView.xaml</DependentUpon>
|
<DependentUpon>SettingsView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -119,6 +122,7 @@
|
||||||
<Page Include="Views\DiscordRPC\RunRPCView.xaml" />
|
<Page Include="Views\DiscordRPC\RunRPCView.xaml" />
|
||||||
<Page Include="Views\Home\HomeView.xaml" />
|
<Page Include="Views\Home\HomeView.xaml" />
|
||||||
<Page Include="Views\KeyManager\KeyManagerView.xaml" />
|
<Page Include="Views\KeyManager\KeyManagerView.xaml" />
|
||||||
|
<Page Include="Views\Settings\ChangePathsView.xaml" />
|
||||||
<Page Include="Views\Settings\SettingsView.xaml" />
|
<Page Include="Views\Settings\SettingsView.xaml" />
|
||||||
<Page Include="Views\Settings\UpdateFoundView.xaml" />
|
<Page Include="Views\Settings\UpdateFoundView.xaml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
Loading…
Add table
Reference in a new issue