Path setting now works!

What does it do:
Well you know you can set your paths!
Checks on programm Startup if set folders still exist, if not it will not allow you to inject, since without those essential paths, it will not work.

TODO:
CustomBase in Loadiine format
CustomBase in NUS Format
Base Download
Inject Proccess revamp
Packing/Loadiine output

Should be ready for beta test then
This commit is contained in:
NicoAICP 2020-04-02 21:45:24 +02:00
parent 3ac026aa8f
commit 720cffa4cb
10 changed files with 329 additions and 6 deletions

View file

@ -22,6 +22,12 @@
<setting name="Ckey" serializeAs="String">
<value />
</setting>
<setting name="SetBaseOnce" serializeAs="String">
<value>False</value>
</setting>
<setting name="SetOutOnce" serializeAs="String">
<value>False</value>
</setting>
</UWUVCI_AIO_WPF.Properties.Settings>
</userSettings>
</configuration>

View file

@ -6,6 +6,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using UWUVCI_AIO_WPF.Classes;
using UWUVCI_AIO_WPF.Properties;
using UWUVCI_AIO_WPF.UI.Windows;
@ -71,6 +72,28 @@ namespace UWUVCI_AIO_WPF
}
}
private string baseStore;
public string BaseStore
{
get { return baseStore; }
set { baseStore = value;
OnPropertyChanged();
}
}
private string injectStore;
public string InjectStore
{
get { return injectStore; }
set { injectStore = value;
OnPropertyChanged();
}
}
private List<GameBases> lBases = new List<GameBases>();
public List<GameBases> LBases
@ -136,13 +159,63 @@ namespace UWUVCI_AIO_WPF
GameConfiguration = new GameConfig();
UpdatePathSet(Properties.Settings.Default.PathsSet);
if (!ValidatePathsStillExist() && Settings.Default.SetBaseOnce && Settings.Default.SetOutOnce)
{
MessageBox.Show("One of your added Paths seems to not exist anymore. Please check the paths in the Path menu!", "Issue", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
UpdatePathSet();
GetAllBases();
}
public void UpdatePathSet(bool newValue)
public void UpdatePathSet()
{
PathsSet = newValue;
PathsSet = Settings.Default.PathsSet;
if(BaseStore != Settings.Default.BasePath)
{
BaseStore = Settings.Default.BasePath;
}
if (InjectStore != Settings.Default.BasePath)
{
InjectStore = Settings.Default.OutPath;
}
}
public bool ValidatePathsStillExist()
{
bool ret = false;
bool basep = false;
try
{
if (Directory.Exists(Settings.Default.BasePath))
{
basep = true;
}
else
{
Settings.Default.BasePath = string.Empty;
Settings.Default.PathsSet = false;
Settings.Default.Save();
}
if (Directory.Exists(Settings.Default.OutPath))
{
if (basep)
{
ret = true;
}
}
else
{
Settings.Default.OutPath = string.Empty;
Settings.Default.PathsSet = false;
Settings.Default.Save();
}
}
catch (Exception)
{
ret = false;
}
return ret;
}
public void GetBases(GameConsoles Console)
@ -377,5 +450,117 @@ namespace UWUVCI_AIO_WPF
}
return info;
}
public void SetInjectPath()
{
using (var dialog = new System.Windows.Forms.FolderBrowserDialog())
{
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
if(result == DialogResult.OK)
{
try
{
if (DirectoryIsEmpty(dialog.SelectedPath))
{
Settings.Default.OutPath = dialog.SelectedPath;
Settings.Default.SetOutOnce = true;
Settings.Default.Save();
UpdatePathSet();
}
else
{
DialogResult r = MessageBox.Show("Folder contains Files or Subfolders, do you really want to use this folder as the Inject Folder?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (r == DialogResult.Yes)
{
Settings.Default.OutPath = dialog.SelectedPath;
Settings.Default.SetOutOnce = true;
Settings.Default.Save();
UpdatePathSet();
}
else
{
SetInjectPath();
}
}
}catch(Exception e)
{
Console.WriteLine(e.Message);
MessageBox.Show("An Error occured, please try again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
ArePathsSet();
}
public void SetBasePath()
{
using (var dialog = new System.Windows.Forms.FolderBrowserDialog())
{
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
if (result == DialogResult.OK)
{
try
{
if (DirectoryIsEmpty(dialog.SelectedPath))
{
Settings.Default.BasePath = dialog.SelectedPath;
Settings.Default.SetBaseOnce = true;
Settings.Default.Save();
UpdatePathSet();
}
else
{
DialogResult r = MessageBox.Show("Folder contains Files or Subfolders, do you really want to use this folder as the Base Folder?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (r == DialogResult.Yes)
{
Settings.Default.BasePath = dialog.SelectedPath;
Settings.Default.SetBaseOnce = true;
Settings.Default.Save();
UpdatePathSet();
}
else
{
SetBasePath();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
MessageBox.Show("An Error occured, please try again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
ArePathsSet();
}
public void ArePathsSet()
{
if (ValidatePathsStillExist())
{
Settings.Default.PathsSet = true;
Settings.Default.Save();
}
UpdatePathSet();
}
public bool DirectoryIsEmpty(string path)
{
int fileCount = Directory.GetFiles(path).Length;
if (fileCount > 0)
{
return false;
}
string[] dirs = Directory.GetDirectories(path);
foreach (string dir in dirs)
{
if (!DirectoryIsEmpty(dir))
{
return false;
}
}
return true;
}
}
}

View file

@ -70,5 +70,29 @@ namespace UWUVCI_AIO_WPF.Properties {
this["Ckey"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool SetBaseOnce {
get {
return ((bool)(this["SetBaseOnce"]));
}
set {
this["SetBaseOnce"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool SetOutOnce {
get {
return ((bool)(this["SetOutOnce"]));
}
set {
this["SetOutOnce"] = value;
}
}
}
}

View file

@ -14,5 +14,11 @@
<Setting Name="Ckey" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="SetBaseOnce" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="SetOutOnce" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

View file

@ -0,0 +1,20 @@
<Page x:Class="UWUVCI_AIO_WPF.UI.Frames.Path.Paths"
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:UWUVCI_AIO_WPF.UI.Frames.Path"
mc:Ignorable="d"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
d:DesignHeight="480" d:DesignWidth="1130"
Title="Paths">
<Grid DataContext="{StaticResource mvm}">
<TextBox materialDesign:HintAssist.Hint="PATH TO STORE DOWNLOADED BASES" Style="{StaticResource MaterialDesignFloatingHintTextBox}" Margin="180,139,474,296" Background="{x:Null}" Foreground="Black" SelectionBrush="#FF00C3D7" CaretBrush="#FF21C3F3" FontSize="18" IsReadOnly="True" Focusable="False" Text="{Binding BaseStore}"/>
<TextBox materialDesign:HintAssist.Hint="PATH TO STORE INJECTS" Style="{StaticResource MaterialDesignFloatingHintTextBox}" Margin="180,212,474,222" Background="{x:Null}" Foreground="Black" SelectionBrush="#FF00C3D7" CaretBrush="#FF21C3F3" FontSize="18" IsReadOnly="True" Focusable="False" Text="{Binding InjectStore}"/>
<Button Content="Set Path" HorizontalAlignment="Left" Margin="700,152,0,0" VerticalAlignment="Top" Width="126" Click="Button_Click"/>
<Button Content="Set Path" HorizontalAlignment="Left" Margin="700,226,0,0" VerticalAlignment="Top" Width="127" Click="Button_Click_1"/>
<Button Content="Back" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="82" Click="Button_Click_2"/>
</Grid>
</Page>

View file

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;
namespace UWUVCI_AIO_WPF.UI.Frames.Path
{
/// <summary>
/// Interaktionslogik für Paths.xaml
/// </summary>
public partial class Paths : Page, IDisposable
{
MainWindow parent;
MainViewModel mvm;
public Paths(MainWindow mw)
{
InitializeComponent();
parent = mw;
mvm = FindResource("mvm") as MainViewModel;
}
public void Dispose()
{
}
private void Button_Click(object sender, RoutedEventArgs e)
{
mvm.SetBasePath();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
mvm.SetInjectPath();
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
parent.paths(true);
}
}
}

View file

@ -16,7 +16,7 @@
<RadioButton Content="Light Theme" HorizontalAlignment="Left" Margin="494,286,0,0" VerticalAlignment="Top" GroupName="theme" x:Name="rblight" IsChecked="True"/>
<Button Content="Change Theme" HorizontalAlignment="Left" Margin="605,283,0,0" VerticalAlignment="Top" Width="145" RenderTransformOrigin="-0.099,0.116"/>
<Button Content="Open CK Menu" HorizontalAlignment="Left" Margin="605,174,0,0" VerticalAlignment="Top" Width="145" RenderTransformOrigin="-0.099,0.116" Click="Button_Click_1"/>
<Button Content="Open Path Menu" HorizontalAlignment="Left" Margin="605,127,0,0" VerticalAlignment="Top" Width="145" RenderTransformOrigin="-0.099,0.116"/>
<Button Content="Open Path Menu" HorizontalAlignment="Left" Margin="605,127,0,0" VerticalAlignment="Top" Width="145" RenderTransformOrigin="-0.099,0.116" Click="Button_Click_2"/>
<Button Content="Open TK Menu" HorizontalAlignment="Left" Margin="605,223,0,0" VerticalAlignment="Top" Width="145" RenderTransformOrigin="-0.099,0.116" Click="Button_Click"/>
</Grid>

View file

@ -21,9 +21,11 @@ namespace UWUVCI_AIO_WPF.UI.Frames
/// </summary>
public partial class SettingsFrame : Page, IDisposable
{
public SettingsFrame()
MainWindow parent;
public SettingsFrame(MainWindow mw)
{
InitializeComponent();
parent = mw;
}
public void Dispose()
{
@ -41,5 +43,10 @@ namespace UWUVCI_AIO_WPF.UI.Frames
MainViewModel mvm = FindResource("mvm") as MainViewModel;
mvm.EnterKey(true);
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
parent.paths(false);
}
}
}

View file

@ -15,6 +15,7 @@ using System.Windows.Shapes;
using UWUVCI_AIO_WPF.UI.Frames;
using GameBaseClassLibrary;
using UWUVCI_AIO_WPF.UI.Frames.Path;
namespace UWUVCI_AIO_WPF
{
@ -90,10 +91,25 @@ namespace UWUVCI_AIO_WPF
case 5:
DestroyFrame();
tbTitleBar.Text = "UWUVCI AIO - SETTINGS";
load_frame.Content = new SettingsFrame();
load_frame.Content = new SettingsFrame(this);
break;
}
}
public void paths(bool remove)
{
load_frame.Content = null;
if (remove)
{
load_frame.Content = new SettingsFrame(this);
}
else
{
load_frame.Content = new Paths(this);
}
}
private void Window_Close(object sender, RoutedEventArgs e)
{
this.Close();

View file

@ -50,6 +50,7 @@
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
@ -73,6 +74,9 @@
<Compile Include="UI\Frames\KeyFrame\TKFrame.xaml.cs">
<DependentUpon>TKFrame.xaml</DependentUpon>
</Compile>
<Compile Include="UI\Frames\Path\Paths.xaml.cs">
<DependentUpon>Paths.xaml</DependentUpon>
</Compile>
<Compile Include="UI\Windows\EnterKey.xaml.cs">
<DependentUpon>EnterKey.xaml</DependentUpon>
</Compile>
@ -107,6 +111,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UI\Frames\Path\Paths.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UI\Frames\SettingsFrame.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>