Changed Config Formatting

Fixed an issue with the video path looking for a file when it needed to be defined as a folder...  https://www.youtube.com/watch?v=ahKH19iN2SM
This commit is contained in:
Heavy Bob 2025-04-09 08:52:17 +10:00
parent 1f35e0a9e6
commit daf6954e74
2 changed files with 61 additions and 47 deletions

View file

@ -26,7 +26,7 @@
VerticalAlignment="Center" VerticalAlignment="Center"
Height="389"> Height="389">
<!-- Log File --> <!-- Log File -->
<StackPanel Margin="0,10,0,15" <StackPanel Margin="0,5,0,10"
Orientation="Horizontal"> Orientation="Horizontal">
<TextBlock Text="ⓘ" <TextBlock Text="ⓘ"
ToolTip="Set this to the Game.log file in your StarCitizen\LIVE directory." ToolTip="Set this to the Game.log file in your StarCitizen\LIVE directory."
@ -55,7 +55,7 @@
</StackPanel> </StackPanel>
<!-- API URL --> <!-- API URL -->
<StackPanel Margin="0,0,0,15" <StackPanel Margin="0,0,0,10"
Orientation="Horizontal"> Orientation="Horizontal">
<TextBlock Text="ⓘ" <TextBlock Text="ⓘ"
ToolTip="Need a URL? No idea what to do? Contact heavy_bob on Discord!" ToolTip="Need a URL? No idea what to do? Contact heavy_bob on Discord!"
@ -83,7 +83,7 @@
</StackPanel> </StackPanel>
<!-- API Key --> <!-- API Key -->
<StackPanel Margin="0,0,0,15" <StackPanel Margin="0,0,0,10"
Orientation="Horizontal"> Orientation="Horizontal">
<TextBlock Text="ⓘ" <TextBlock Text="ⓘ"
ToolTip="Need a key? No idea what to do? Contact heavy_bob on Discord!" ToolTip="Need a key? No idea what to do? Contact heavy_bob on Discord!"
@ -102,7 +102,7 @@
</StackPanel> </StackPanel>
<!-- Video Path --> <!-- Video Path -->
<StackPanel Margin="0,0,0,15" <StackPanel Margin="0,0,0,10"
Orientation="Horizontal"> Orientation="Horizontal">
<TextBlock Text="ⓘ" <TextBlock Text="ⓘ"
ToolTip="The directory where your clipping software saves kills. Check the README." ToolTip="The directory where your clipping software saves kills. Check the README."
@ -129,18 +129,31 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<!-- Visor Wipe Toggle Slider --> <!-- Toggle Settings Grid -->
<StackPanel Margin="0,0,0,15" <Grid Margin="0,0,0,10">
Orientation="Horizontal"> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Visor Wipe Toggle -->
<StackPanel Grid.Column="0" Grid.Row="0"
Orientation="Horizontal"
Margin="0,0,5,5">
<TextBlock Text="ⓘ" <TextBlock Text="ⓘ"
ToolTip="Perform a Visor Wipe animation on player kill. Requires AHKv2." ToolTip="Perform a Visor Wipe animation on player kill. Requires AHKv2."
Foreground="{DynamicResource TextBrush}" Foreground="{DynamicResource TextBrush}"
FontSize="20" FontSize="20"
Margin="0,4,3,5"/> Margin="0,4,3,0"/>
<TextBlock Text="Visor Wipe:" <TextBlock Text="Visor Wipe:"
Foreground="{DynamicResource TextBrush}" Foreground="{DynamicResource TextBrush}"
FontSize="16" FontSize="16"
Margin="0,7,0,5"/> Margin="0,7,0,0"/>
<Slider Name="VisorWipeSlider" <Slider Name="VisorWipeSlider"
Minimum="0" Minimum="0"
Maximum="1" Maximum="1"
@ -148,22 +161,24 @@
IsSnapToTickEnabled="True" IsSnapToTickEnabled="True"
Value="0" Value="0"
Style="{StaticResource ToggleSliderStyle}" Style="{StaticResource ToggleSliderStyle}"
Margin="27,-4,0,0" Margin="10,-4,0,0"
Width="100"
ValueChanged="VisorWipeSlider_ValueChanged"/> ValueChanged="VisorWipeSlider_ValueChanged"/>
</StackPanel> </StackPanel>
<!-- Video Record Toggle Slider --> <!-- Video Record Toggle -->
<StackPanel Margin="0,0,0,15" <StackPanel Grid.Column="1" Grid.Row="0"
Orientation="Horizontal"> Orientation="Horizontal"
Margin="5,0,0,5">
<TextBlock Text="ⓘ" <TextBlock Text="ⓘ"
ToolTip="Automatically clip your last kill. Check the README for more info." ToolTip="Automatically clip your last kill. Check the README for more info."
Foreground="{DynamicResource TextBrush}" Foreground="{DynamicResource TextBrush}"
FontSize="20" FontSize="20"
Margin="0,4,3,5"/> Margin="0,4,3,0"/>
<TextBlock Text="Video Record:" <TextBlock Text="Video Record:"
Foreground="{DynamicResource TextBrush}" Foreground="{DynamicResource TextBrush}"
FontSize="16" FontSize="16"
Margin="0,7,0,5"/> Margin="0,7,0,0"/>
<Slider Name="VideoRecordSlider" <Slider Name="VideoRecordSlider"
Minimum="0" Minimum="0"
Maximum="1" Maximum="1"
@ -172,21 +187,23 @@
Value="0" Value="0"
Style="{StaticResource ToggleSliderStyle}" Style="{StaticResource ToggleSliderStyle}"
Margin="10,-4,0,0" Margin="10,-4,0,0"
Width="100"
ValueChanged="VideoRecordSlider_ValueChanged"/> ValueChanged="VideoRecordSlider_ValueChanged"/>
</StackPanel> </StackPanel>
<!-- Offline Mode Toggle Slider --> <!-- Offline Mode Toggle -->
<StackPanel Margin="0,0,0,10" <StackPanel Grid.Column="0" Grid.Row="1"
Orientation="Horizontal"> Orientation="Horizontal"
Margin="0,0,5,5">
<TextBlock Text="ⓘ" <TextBlock Text="ⓘ"
ToolTip="With Offline Mode enabled, kills will not be submitted to the configured API." ToolTip="With Offline Mode enabled, kills will not be submitted to the configured API."
Foreground="{DynamicResource TextBrush}" Foreground="{DynamicResource TextBrush}"
FontSize="20" FontSize="20"
Margin="0,4,3,5"/> Margin="0,4,3,0"/>
<TextBlock Text="Offline Mode:" <TextBlock Text="Offline Mode:"
Foreground="{DynamicResource TextBrush}" Foreground="{DynamicResource TextBrush}"
FontSize="16" FontSize="16"
Margin="0,7,0,5"/> Margin="0,7,0,0"/>
<Slider Name="OfflineModeSlider" <Slider Name="OfflineModeSlider"
Minimum="0" Minimum="0"
Maximum="1" Maximum="1"
@ -194,17 +211,20 @@
IsSnapToTickEnabled="True" IsSnapToTickEnabled="True"
Value="0" Value="0"
Style="{StaticResource ToggleSliderStyle}" Style="{StaticResource ToggleSliderStyle}"
Margin="12,-4,0,0" Margin="10,-4,0,0"
Width="100"
ValueChanged="OfflineModeSlider_ValueChanged"/> ValueChanged="OfflineModeSlider_ValueChanged"/>
</StackPanel> </StackPanel>
<!-- 3-Position Toggle Slider --> <!-- Theme Slider -->
<StackPanel Margin="0,0,0,15" <StackPanel Grid.Column="0" Grid.Row="2"
Orientation="Horizontal"> Grid.ColumnSpan="2"
Orientation="Horizontal"
Margin="0,0,0,5">
<TextBlock Text="Theme:" <TextBlock Text="Theme:"
Foreground="{DynamicResource TextBrush}" Foreground="{DynamicResource TextBrush}"
FontSize="16" FontSize="16"
Margin="0,7,0,5"/> Margin="0,7,10,0"/>
<Slider x:Name="ThemeSlider" <Slider x:Name="ThemeSlider"
Minimum="0" Minimum="0"
Value="0" Value="0"
@ -213,8 +233,8 @@
ValueChanged="ThemeSlider_ValueChanged" ValueChanged="ThemeSlider_ValueChanged"
Width="447" Width="447"
Style="{StaticResource ThreePositionSlider}"/> Style="{StaticResource ThreePositionSlider}"/>
</StackPanel> </StackPanel>
</Grid>
</StackPanel> </StackPanel>
<!-- Save Button --> <!-- Save Button -->

View file

@ -39,7 +39,6 @@ public partial class ConfigPage : UserControl
ApplyToggleModeStyle(OfflineModeSlider.Value, VisorWipeSlider.Value, VideoRecordSlider.Value); ApplyToggleModeStyle(OfflineModeSlider.Value, VisorWipeSlider.Value, VideoRecordSlider.Value);
const string themeJsonPath = "themes.json"; const string themeJsonPath = "themes.json";
var themeJson = File.ReadAllText(themeJsonPath); var themeJson = File.ReadAllText(themeJsonPath);
_themes = JsonSerializer.Deserialize<Dictionary<string, Theme>>(themeJson); _themes = JsonSerializer.Deserialize<Dictionary<string, Theme>>(themeJson);
@ -78,23 +77,19 @@ public partial class ConfigPage : UserControl
} }
// This method will set the loaded config values to the UI controls // This method will set the loaded config values to the UI controls
public void SetConfigValues(string logFile, string apiUrl, string apiKey, string videoPath, public void SetConfigValues(string logFile, string apiUrl, string apiKey, string videoPath, int visorWipe, int videoRecord, int offlineMode, int theme)
int visorWipe, int videoRecord, int offlineMode, int theme)
{ {
// Set the textboxes with the loaded values
LogFilePath.Text = logFile; LogFilePath.Text = logFile;
ApiUrl.Text = apiUrl; ApiUrl.Text = apiUrl;
ApiKey.Password = apiKey; ApiKey.Password = apiKey;
VideoPath.Text = videoPath; VideoPath.Text = videoPath;
// Set the sliders with the loaded values
VideoRecordSlider.Value = videoRecord;
VisorWipeSlider.Value = visorWipe; VisorWipeSlider.Value = visorWipe;
VideoRecordSlider.Value = videoRecord;
OfflineModeSlider.Value = offlineMode; OfflineModeSlider.Value = offlineMode;
ThemeSlider.Value = theme;
// Handle themes // Handle themes
ApplyTheme(theme); ApplyTheme(theme);
} }
private void ApplyToggleModeStyle(double offlineModeValue, double visorWipeValue, double videoRecordValue) private void ApplyToggleModeStyle(double offlineModeValue, double visorWipeValue, double videoRecordValue)
@ -202,18 +197,18 @@ public partial class ConfigPage : UserControl
// Video Path Browse Button Handler // Video Path Browse Button Handler
private void VideoPathBrowseButton_Click(object sender, RoutedEventArgs e) private void VideoPathBrowseButton_Click(object sender, RoutedEventArgs e)
{ {
var dialog = new OpenFileDialog(); var dialog = new Microsoft.Win32.OpenFileDialog();
dialog.CheckFileExists = false;
dialog.ValidateNames = false; dialog.ValidateNames = false;
dialog.Filter = "All files|*.*"; dialog.CheckFileExists = false;
dialog.CheckPathExists = true;
if (dialog.ShowDialog() == true && dialog.FileName != null) dialog.FileName = "Folder Selection";
if (dialog.ShowDialog() == true)
{ {
// Extract only the directory path from the file
string? selectedFolder = Path.GetDirectoryName(dialog.FileName); string? selectedFolder = Path.GetDirectoryName(dialog.FileName);
if (selectedFolder != null) if (selectedFolder != null)
{ {
VideoPath.Text = selectedFolder; // Set the folder path VideoPath.Text = selectedFolder;
} }
} }
} }
@ -320,10 +315,8 @@ public partial class ConfigPage : UserControl
} }
} }
private void SaveButton_Click(object sender, RoutedEventArgs e) private void SaveButton_Click(object sender, RoutedEventArgs e)
{ {
ConfigManager.ApiKey = ApiKey.Password; ConfigManager.ApiKey = ApiKey.Password;
ConfigManager.ApiUrl = ApiUrl.Text; ConfigManager.ApiUrl = ApiUrl.Text;
ConfigManager.LogFile = LogFilePath.Text; ConfigManager.LogFile = LogFilePath.Text;
@ -332,6 +325,7 @@ public partial class ConfigPage : UserControl
ConfigManager.VideoRecord = (int)VideoRecordSlider.Value; ConfigManager.VideoRecord = (int)VideoRecordSlider.Value;
ConfigManager.OfflineMode = (int)OfflineModeSlider.Value; ConfigManager.OfflineMode = (int)OfflineModeSlider.Value;
ConfigManager.Theme = (int)ThemeSlider.Value; ConfigManager.Theme = (int)ThemeSlider.Value;
// Save the current config values // Save the current config values
ConfigManager.SaveConfig(); ConfigManager.SaveConfig();
// Start the flashing effect // Start the flashing effect