Skip to content

Commit

Permalink
Merge pull request #243 from CriticalFlaw/dev
Browse files Browse the repository at this point in the history
Added cache clearing, updated logging and code cleanup
  • Loading branch information
CriticalFlaw authored Sep 13, 2024
2 parents 993e69d + a12210f commit dc348a9
Show file tree
Hide file tree
Showing 37 changed files with 658 additions and 763 deletions.
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

0 comments on commit dc348a9

Please sign in to comment.