File save updates

This commit is contained in:
BubbaGumpShrump 2024-12-04 22:41:56 -05:00
parent d74a14948d
commit 10e88866f5
6 changed files with 55 additions and 17 deletions

View file

@ -17,8 +17,10 @@
<None Remove="Assets\NW.png" />
<None Remove="Assets\VOX.png" />
<None Remove="Assets\WRITH.jpg" />
<None Remove="config.ini" />
<None Remove="Fonts\Orbitron-Bold.ttf" />
<None Remove="Fonts\Roboto-Regular.ttf" />
<None Remove="kill-log.csv" />
<None Remove="KillTrackR_MainScript.ps1" />
</ItemGroup>
@ -45,12 +47,14 @@
<Resource Include="Assets\WRITH.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="config.ini" />
<Resource Include="Fonts\Orbitron-Bold.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Fonts\Roboto-Regular.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="kill-log.csv" />
<EmbeddedResource Include="KillTrackR_MainScript.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>

View file

@ -350,11 +350,20 @@ namespace AutoTrackR2
private void SaveButton_Click(object sender, RoutedEventArgs e)
{
// Get the directory of the running executable
string exeDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
// Get the directory for the user's local application data
string appDataDirectory = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"AutoTrackR2"
);
// Combine the executable directory with the config file name
string configFilePath = Path.Combine(exeDirectory, "config.ini");
// Ensure the directory exists
if (!Directory.Exists(appDataDirectory))
{
Directory.CreateDirectory(appDataDirectory);
}
// Combine the app data directory with the config file name
string configFilePath = Path.Combine(appDataDirectory, "config.ini");
using (StreamWriter writer = new StreamWriter(configFilePath))
{

View file

@ -1,7 +1,8 @@
$TrackRver = "2.0"
# Path to the config file
$scriptFolder = Split-Path -Parent $MyInvocation.MyCommand.Path
$appName = "AutoTrackR2"
$scriptFolder = Join-Path -Path (Join-Path -Path $env:LOCALAPPDATA -ChildPath $appName)
$configFile = Join-Path -Path $scriptFolder -ChildPath "config.ini"
# Read the config file into a hashtable

View file

@ -188,8 +188,12 @@ namespace AutoTrackR2
public static void LoadConfig()
{
string exeDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string configFilePath = Path.Combine(exeDirectory, "config.ini");
// Define the config file path in a writable location
string configDirectory = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"AutoTrackR2"
);
string configFilePath = Path.Combine(configDirectory, "config.ini");
if (File.Exists(configFilePath))
{
@ -217,19 +221,31 @@ namespace AutoTrackR2
public static void SaveConfig()
{
string exeDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string configFilePath = Path.Combine(exeDirectory, "config.ini");
// Define the config file path in a writable location
string configDirectory = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"YourAppName"
);
// Ensure the directory exists
if (!Directory.Exists(configDirectory))
{
Directory.CreateDirectory(configDirectory);
}
string configFilePath = Path.Combine(configDirectory, "config.ini");
// Write the configuration to the file
using (StreamWriter writer = new StreamWriter(configFilePath))
{
writer.WriteLine($"LogFile=\"{LogFile}\"");
writer.WriteLine($"ApiUrl=\"{ApiUrl}\"");
writer.WriteLine($"ApiKey=\"{ApiKey}\"");
writer.WriteLine($"VideoPath=\"{VideoPath}\"");
writer.WriteLine($"VisorWipe=\"{VisorWipe}\"");
writer.WriteLine($"VideoRecord=\"{VideoRecord}\"");
writer.WriteLine($"OfflineMode=\"{OfflineMode}\"");
writer.WriteLine($"Theme=\"{Theme}\"");
writer.WriteLine($"LogFile={LogFile}");
writer.WriteLine($"ApiUrl={ApiUrl}");
writer.WriteLine($"ApiKey={ApiKey}");
writer.WriteLine($"VideoPath={VideoPath}");
writer.WriteLine($"VisorWipe={VisorWipe}");
writer.WriteLine($"VideoRecord={VideoRecord}");
writer.WriteLine($"OfflineMode={OfflineMode}");
writer.WriteLine($"Theme={Theme}");
}
}
}

8
AutoTrackR2/config.ini Normal file
View file

@ -0,0 +1,8 @@
LogFile=
ApiUrl=
ApiKey=
VideoPath=
VisorWipe=0
VideoRecord=0
OfflineMode=0
Theme=0

0
AutoTrackR2/kill-log.csv Normal file
View file