Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added cache clearing, updated logging and code cleanup #243

Merged
merged 25 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
160842d
Renamed, moved files for common huds
CriticalFlaw Aug 28, 2024
fb3d2f2
Replace local TGASharpLib with nuget packages
CriticalFlaw Aug 28, 2024
bbd6ff9
Split all model classes
CriticalFlaw Aug 29, 2024
559bd0b
Organized resource files
CriticalFlaw Aug 29, 2024
679f846
Renamed Options window
CriticalFlaw Aug 29, 2024
befcc49
Added a border to the main window
CriticalFlaw Aug 30, 2024
766cf54
Update common.json
CriticalFlaw Aug 30, 2024
62fdbc1
Added a custom title bar
CriticalFlaw Aug 31, 2024
833a445
Disabled screen resizing
CriticalFlaw Aug 31, 2024
0ea1732
Default to a background image instead of a flat color
CriticalFlaw Aug 31, 2024
cd99afc
Updated settings window to use new title bar
CriticalFlaw Aug 31, 2024
a5e864e
Fixed links to external site images
CriticalFlaw Aug 31, 2024
1ea62fb
Merge branch 'master' into dev
CriticalFlaw Aug 31, 2024
f9af9d4
Set the default background to use
CriticalFlaw Sep 1, 2024
3a7c2c9
Updated logging
CriticalFlaw Sep 1, 2024
105cee6
Merge branch 'master' into dev
CriticalFlaw Sep 9, 2024
171c3fe
Added a clear cache button
CriticalFlaw Sep 9, 2024
ee158e3
Spell checked tokenize
CriticalFlaw Sep 9, 2024
9f6d90d
Cleaned up project file
CriticalFlaw Sep 9, 2024
5564cdc
Fixed schema clean-up, replaced schema auto-check
CriticalFlaw Sep 9, 2024
b1c412f
Updated logging
CriticalFlaw Sep 9, 2024
71e9289
Update HUDCustomizations.cs
CriticalFlaw Sep 9, 2024
59dc2f2
Updated logging
CriticalFlaw Sep 9, 2024
95e48ac
Formatting changes
CriticalFlaw Sep 10, 2024
a12210f
Perform a package creation on PRs
CriticalFlaw Sep 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: package

on:
workflow_dispatch:
pull_request:

jobs:
package:
Expand Down
134 changes: 67 additions & 67 deletions src/TF2HUD.Editor/App.config
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="HUDEditor.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="HUDEditor.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<HUDEditor.Properties.Settings>
<setting name="hud_selected" serializeAs="String">
<value />
</setting>
<setting name="hud_directory" serializeAs="String">
<value />
</setting>
<setting name="user_language" serializeAs="String">
<value>en-US</value>
</setting>
<setting name="app_update_auto" serializeAs="String">
<value>True</value>
</setting>
<setting name="app_xhair_persist" serializeAs="String">
<value>False</value>
</setting>
<setting name="app_xhair_enabled" serializeAs="String">
<value>False</value>
</setting>
<setting name="app_xhair_style" serializeAs="String">
<value>$</value>
</setting>
<setting name="app_xhair_color" serializeAs="String">
<value />
</setting>
<setting name="app_xhair_size" serializeAs="String">
<value>0</value>
</setting>
<setting name="app_default_bg" serializeAs="String">
<value>https://user-images.githubusercontent.com/6818236/220803776-12f85855-a409-4555-8f76-e3877d04bab9.png</value>
</setting>
</HUDEditor.Properties.Settings>
</userSettings>
<applicationSettings>
<HUDEditor.Properties.Settings>
<setting name="app_docs" serializeAs="String">
<value>https://criticalflaw.ca/TF2HUD.Editor/</value>
</setting>
<setting name="json_file" serializeAs="String">
<value>https://raw.githubusercontent.com/CriticalFlaw/TF2HUD.Editor/master/src/TF2HUD.Editor/JSON/{0}</value>
</setting>
<setting name="json_list" serializeAs="String">
<value>https://api.github.com/repos/CriticalFlaw/TF2HUD.Editor/contents/src/TF2HUD.Editor/JSON</value>
</setting>
<setting name="app_tracker" serializeAs="String">
<value>https://github.com/CriticalFlaw/TF2HUD.Editor/issues</value>
</setting>
<setting name="app_update" serializeAs="String">
<value>https://github.com/CriticalFlaw/TF2HUD.Editor/releases/latest</value>
</setting>
<setting name="mastercomfig_vpk" serializeAs="String">
<value>https://github.com/mastercomfig/mastercomfig/releases/download/9.5.2/mastercomfig-transparent-viewmodels-addon.vpk</value>
</setting>
<setting name="tf2_hud_crosshairs_zip" serializeAs="String">
<value>https://github.com/Hypnootize/TF2-HUD-Crosshairs/archive/refs/heads/master.zip</value>
</setting>
</HUDEditor.Properties.Settings>
</applicationSettings>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="HUDEditor.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="HUDEditor.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<HUDEditor.Properties.Settings>
<setting name="hud_selected" serializeAs="String">
<value />
</setting>
<setting name="hud_directory" serializeAs="String">
<value />
</setting>
<setting name="user_language" serializeAs="String">
<value>en-US</value>
</setting>
<setting name="app_update_auto" serializeAs="String">
<value>True</value>
</setting>
<setting name="app_xhair_persist" serializeAs="String">
<value>False</value>
</setting>
<setting name="app_xhair_enabled" serializeAs="String">
<value>False</value>
</setting>
<setting name="app_xhair_style" serializeAs="String">
<value>$</value>
</setting>
<setting name="app_xhair_color" serializeAs="String">
<value />
</setting>
<setting name="app_xhair_size" serializeAs="String">
<value>0</value>
</setting>
<setting name="app_default_bg" serializeAs="String">
<value>https://user-images.githubusercontent.com/6818236/220803776-12f85855-a409-4555-8f76-e3877d04bab9.png</value>
</setting>
</HUDEditor.Properties.Settings>
</userSettings>
<applicationSettings>
<HUDEditor.Properties.Settings>
<setting name="app_docs" serializeAs="String">
<value>https://criticalflaw.ca/TF2HUD.Editor/</value>
</setting>
<setting name="json_file" serializeAs="String">
<value>https://raw.githubusercontent.com/CriticalFlaw/TF2HUD.Editor/master/src/TF2HUD.Editor/JSON/{0}</value>
</setting>
<setting name="json_list" serializeAs="String">
<value>https://api.github.com/repos/CriticalFlaw/TF2HUD.Editor/contents/src/TF2HUD.Editor/JSON</value>
</setting>
<setting name="app_tracker" serializeAs="String">
<value>https://github.com/CriticalFlaw/TF2HUD.Editor/issues</value>
</setting>
<setting name="app_update" serializeAs="String">
<value>https://github.com/CriticalFlaw/TF2HUD.Editor/releases/latest</value>
</setting>
<setting name="mastercomfig_vpk" serializeAs="String">
<value>https://github.com/mastercomfig/mastercomfig/releases/download/9.5.2/mastercomfig-transparent-viewmodels-addon.vpk</value>
</setting>
<setting name="tf2_hud_crosshairs_zip" serializeAs="String">
<value>https://github.com/Hypnootize/TF2-HUD-Crosshairs/archive/refs/heads/master.zip</value>
</setting>
</HUDEditor.Properties.Settings>
</applicationSettings>
</configuration>
10 changes: 5 additions & 5 deletions src/TF2HUD.Editor/Classes/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace HUDEditor.Classes
public class NullCheckConverter : IValueConverter
{
/// <summary>
/// Returns true if the provided value is not null or empty.
/// Returns true if the provided value is not null or empty.
/// </summary>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Expand All @@ -36,7 +36,7 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
public class NotNullCheckConverter : IValueConverter
{
/// <summary>
/// Returns true if the provided value is null.
/// Returns true if the provided value is null.
/// </summary>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Expand Down Expand Up @@ -144,18 +144,18 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
var hud = (HUD)value;
if (hud is not null)
{
MainWindow.Logger.Info($"User selected {hud.Name}");
MainWindow.Logger.Info($"User selected: {hud.Name}");
if (Directory.Exists($"{Settings.Default.hud_directory}\\{hud.Name}"))
{
MainWindow.Logger.Info($"{hud.Name} is installed");
return Utilities.GetLocalizedString("ui_reinstall") ?? "Reinstall";
}

MainWindow.Logger.Info($"{hud.Name} is not installed");
MainWindow.Logger.Warn($"{hud.Name} is not installed");
return Utilities.GetLocalizedString("ui_install") ?? "Install";
}

MainWindow.Logger.Warn("User selected HUD is null");
MainWindow.Logger.Warn("User selected HUD is null. Returning to the main menu");
return Utilities.GetLocalizedString("ui_install") ?? "Install";
}

Expand Down
94 changes: 49 additions & 45 deletions src/TF2HUD.Editor/Classes/HUD/HUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,44 @@ public partial class HUD
{
private Grid Controls = new();
private HUDBackground HudBackground;
private bool isRendered;
private bool IsRendered;
private string[][] Layout;

#region HUD PROPERTIES

public string Name { get; set; }
public HUDSettings Settings { get; set; }
public double Opacity { get; set; }
public bool Maximize { get; set; }
public string Thumbnail { get; set; }
public string Background { get; set; }
public string Description { get; set; }
public string Author { get; set; }
public string CustomizationsFolder { get; set; }
public string EnabledFolder { get; set; }
public Download[] Download;
public string GitHubUrl { get; set; }
public string TF2HudsUrl { get; set; }
public string ComfigHudsUrl { get; set; }
public string SteamUrl { get; set; }
public string DiscordUrl { get; set; }
public Dictionary<string, Controls[]> ControlOptions;
public readonly string[] LayoutOptions;
public List<string> DirtyControls;
public bool Unique;
public readonly bool InstallCrosshairs;
public string[] Screenshots { get; set; }

#endregion HUD PROPERTIES

/// <summary>
/// Initialize the HUD object with values from the JSON schema.
/// Initializes the HUD object with values from the schema.
/// </summary>
/// <param name="name">Name of the HUD object.</param>
/// <param name="schema">Contents of the HUD's schema file.</param>
/// <param name="unique">Flags the HUD as having unique customizations.</param>
public HUD(string name, HudJson schema, bool unique)
/// <param name="name">HUD object name.</param>
/// <param name="schema">HUD schema contents.</param>
/// <param name="isUnique">Marks the HUD as having unique customizations.</param>
public HUD(string name, HudJson schema, bool isUnique)
{
// Basic Schema Properties.
Name = schema.Name ?? name;
Settings = new HUDSettings(Name);
Opacity = schema.Opacity;
Expand All @@ -43,21 +69,25 @@ public HUD(string name, HudJson schema, bool unique)
ControlOptions = schema.Controls;
LayoutOptions = schema.Layout;
DirtyControls = new List<string>();
Unique = unique;
Unique = isUnique;
InstallCrosshairs = schema.InstallCrosshairs;
Screenshots = schema.Screenshots;
}

/// <summary>
/// Changes the preset on a given HUD.
/// </summary>
/// <param name="preset"></param>
public void SetPreset(Preset preset)
{
Settings.Preset = preset;
isRendered = false;
IsRendered = false;
Controls = new Grid();
MainWindow.Logger.Info($"Changed preset for {Name} to HUDSettingsPreset.{Settings.Preset}");
MainWindow.Logger.Info($"Changing {Name} to Preset-{Settings.Preset}");
}

/// <summary>
/// Reset all user-settings to the default values defined in the HUD schema.
/// Resets all user settings to their default values as defined in the schema.
/// </summary>
public void ResetAll()
{
Expand All @@ -67,7 +97,7 @@ public void ResetAll()
}

/// <summary>
/// Reset selected group of user-settings to the default values defined in the HUD schema.
/// Resets a group of user settings to their default values as defined in the schema.
/// </summary>
private void ResetSection(string selection)
{
Expand All @@ -76,7 +106,7 @@ private void ResetSection(string selection)
}

/// <summary>
/// Reset user-settings to the default values defined in the HUD schema.
/// Resets a user setting to its default value as defined in the schema.
/// </summary>
private void ResetControl(Controls control)
{
Expand All @@ -90,11 +120,6 @@ private void ResetControl(Controls control)
Logger.Info($"Reset {control.Name} to {value}");
break;

case TextBox text:
text.Text = control.Value;
Logger.Info($"Reset {control.Name} to \"{control.Value}\"");
break;

case ColorPicker color:
color.SelectedColor = Utilities.ConvertToColor(control.Value);
Logger.Info($"Reset {control.Name} to {color.SelectedColor}");
Expand All @@ -110,6 +135,12 @@ private void ResetControl(Controls control)

case IntegerUpDown integer:
integer.Text = control.Value;
Logger.Info($"Reset {control.Name} to \"{control.Value}\"");
break;

case TextBox text:
text.Text = control.Value;
Logger.Info($"Reset {control.Name} to \"{control.Value}\"");
break;
}
}
Expand All @@ -120,32 +151,5 @@ private void ResetControl(Controls control)
throw;
}
}

#region HUD PROPERTIES

public string Name { get; set; }
public HUDSettings Settings { get; set; }
public double Opacity { get; set; }
public bool Maximize { get; set; }
public string Thumbnail { get; set; }
public string Background { get; set; }
public string Description { get; set; }
public string Author { get; set; }
public string CustomizationsFolder { get; set; }
public string EnabledFolder { get; set; }
public Download[] Download;
public string GitHubUrl { get; set; }
public string TF2HudsUrl { get; set; }
public string ComfigHudsUrl { get; set; }
public string SteamUrl { get; set; }
public string DiscordUrl { get; set; }
public Dictionary<string, Controls[]> ControlOptions;
public readonly string[] LayoutOptions;
public List<string> DirtyControls;
public string[] Screenshots { get; set; }
public bool Unique;
public readonly bool InstallCrosshairs;

#endregion HUD PROPERTIES
}
}
Loading