Skip to content

Commit

Permalink
Merge pull request #205 from CriticalFlaw/#194
Browse files Browse the repository at this point in the history
3.2
  • Loading branch information
CriticalFlaw committed Jul 29, 2023
2 parents 0e8be23 + a9a5179 commit 7812e95
Show file tree
Hide file tree
Showing 19 changed files with 1,418 additions and 219 deletions.
6 changes: 3 additions & 3 deletions Update.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>3.1.0.0</version>
<url>https://github.com/CriticalFlaw/TF2HUD.Editor/releases/download/3.1/tf2hud-editor-x64.zip</url>
<changelog>https://github.com/CriticalFlaw/TF2HUD.Editor/releases/tag/3.1</changelog>
<version>3.2.0.0</version>
<url>https://github.com/CriticalFlaw/TF2HUD.Editor/releases/download/3.2/tf2hud-editor-x64.zip</url>
<changelog>https://github.com/CriticalFlaw/TF2HUD.Editor/releases/tag/3.2</changelog>
<mandatory>true</mandatory>
</item>
62 changes: 44 additions & 18 deletions src/TF2HUD.Editor/Classes/HUD/HUDCustomizations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,10 @@ private void MoveCustomizationFiles(Dictionary<string, Controls[]>.ValueCollecti
if (option.RenameFile.OldName.EndsWith('/'))
{
if (Directory.Exists(path + option.RenameFile.NewName))
Directory.Move(path + option.RenameFile.NewName,
path + option.RenameFile.OldName);
Directory.Move(path + option.RenameFile.NewName, path + option.RenameFile.OldName);

if (string.Equals(option.Value, setting.Value))
Directory.Move(path + option.RenameFile.OldName,
path + option.RenameFile.NewName);
Directory.Move(path + option.RenameFile.OldName, path + option.RenameFile.NewName);
}
else
{
Expand All @@ -250,25 +248,26 @@ private void MoveCustomizationFiles(Dictionary<string, Controls[]>.ValueCollecti
// Move every file assigned to this control back to the customization folder first.
foreach (string file in fileNames)
{
var name = file.Replace(".res", string.Empty);
if (Directory.Exists(enabled + $"\\{name}"))
Directory.Move(enabled + $"\\{name}", custom + $"\\{name}");
else if (File.Exists(enabled + $"\\{name}.res"))
File.Move(enabled + $"\\{name}.res", custom + $"\\{name}.res", true);
var dir = file.Replace(".res", string.Empty);
if (Directory.Exists(enabled + $"\\{dir}"))
Directory.Move(enabled + $"\\{dir}", custom + $"\\{dir}");
else if (File.Exists(enabled + $"\\{file}"))
File.Move(enabled + $"\\{file}", custom + $"\\{file}", true);
}

// Only move the files for the control option selected by the user.
if (!string.Equals(setting.Value, "0"))
{
var name = control.Options[int.Parse(setting.Value)].FileName;
if (string.IsNullOrWhiteSpace(name)) break;
var name = control.Options[int.Parse(setting.Value)].FileName;
if (string.IsNullOrWhiteSpace(name)) break;

name = name.Replace(".res", string.Empty);
if (Directory.Exists(custom + $"\\{name}"))
name = name.Replace(".res", string.Empty);
if (Directory.Exists(custom + $"\\{name}"))
{
if (control.ComboDirectories is not null)
CopyDirectory(custom + $"\\{name}", enabled);
else
Directory.Move(custom + $"\\{name}", enabled + $"\\{name}");
else if (File.Exists(custom + $"\\{name}.res"))
File.Move(custom + $"\\{name}.res", enabled + $"\\{name}.res", true);
}
else if (File.Exists(custom + $"\\{name}.res"))
File.Move(custom + $"\\{name}.res", enabled + $"\\{name}.res", true);

break;
}
Expand Down Expand Up @@ -786,5 +785,32 @@ private async void CopyTransparentViewmodelAddon(bool enable = false)
MainWindow.ShowMessageBox(MessageBoxImage.Error, string.Format(Utilities.GetLocalizedString("error_transparent_vm"), e.Message));
}
}

/// <summary>
/// Function for copying multiple files and subdirectories, recursively.
/// </summary>
static void CopyDirectory(string source, string destination)
{
// Get information about the source directory.
var dir = new DirectoryInfo(source);

// Cache directories before we start copying.
var dirs = dir.GetDirectories();

// Get the files in the source directory and copy to the destination directory
foreach (var file in dir.GetFiles())
{
string targetFilePath = Path.Combine(destination, file.Name);
if (file.Name.Contains(".jpg") || file.Name.Contains(".png")) continue;
file.CopyTo(targetFilePath, true);
}

// Recursively call this method copy subdirectories.
foreach (var subDir in dirs)
{
string newDestinationDir = Path.Combine(destination, subDir.Name);
CopyDirectory(subDir.FullName, newDestinationDir);
}
}
}
}
2 changes: 1 addition & 1 deletion src/TF2HUD.Editor/Classes/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ internal static dynamic GetFileNames(Controls control)
{
if (!string.IsNullOrWhiteSpace(control.FileName))
return control.FileName.Replace(".res", string.Empty);
return control.ComboFiles;
return (control.ComboDirectories is not null) ? control.ComboDirectories : control.ComboFiles;
}

/// <summary>
Expand Down
11 changes: 6 additions & 5 deletions src/TF2HUD.Editor/HUDEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<Company>CriticalFlaw</Company>
<Copyright>CriticalFlaw</Copyright>
<PackageProjectUrl>http:https://criticalflaw.ca/TF2HUD.Editor/</PackageProjectUrl>
<AssemblyVersion>3.1.0.0</AssemblyVersion>
<FileVersion>3.1.0.0</FileVersion>
<Version>3.1.0</Version>
<AssemblyVersion>3.2.0.0</AssemblyVersion>
<FileVersion>3.2.0.0</FileVersion>
<Version>3.2.0</Version>
<RepositoryUrl>https://github.com/CriticalFlaw/TF2HUD.Editor</RepositoryUrl>
<PackageIcon>logo.png</PackageIcon>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
Expand Down Expand Up @@ -42,6 +42,7 @@
<None Remove="JSON\hud-fixes.json" />
<None Remove="JSON\hypnotize-hud.json" />
<None Remove="JSON\kbnhud.json" />
<None Remove="JSON\m0rehud.json" />
<None Remove="JSON\rayshud.json" />
<None Remove="JSON\zeeshud.json" />
<None Remove="log4net.config" />
Expand All @@ -62,12 +63,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageReference Include="CountryFlag" Version="2.1.0" />
<PackageReference Include="DotNetProjects.Extended.Wpf.Toolkit" Version="5.0.103" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Octokit" Version="6.2.1" />
<PackageReference Include="Octokit" Version="7.1.0" />
<PackageReference Include="WPFLocalizeExtension" Version="3.10.0" />
</ItemGroup>

Expand Down
6 changes: 6 additions & 0 deletions src/TF2HUD.Editor/JSON/Schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@
"type": "string"
}
},
"ComboDirectories": {
"type": "array",
"items": {
"type": "string"
}
},
"Restart": {
"type": "boolean"
},
Expand Down
23 changes: 0 additions & 23 deletions src/TF2HUD.Editor/JSON/Shared/shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,6 @@
"https://i.ibb.co/cQ79f5R/tournament-spec.jpg"
]
},
{
"Name": "m0rehud",
"Description": "Clean, functional and minimalistic HUD created by m0re.",
"Author": "Hypnotize",
"Thumbnail": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/m0rehud/m0rehud-banner.webp",
"Links": {
"Update": "https://github.com/Hypnootize/m0rehud/archive/refs/heads/master.zip", // TODO: Remove
"GitHub": "https://github.com/Hypnootize/m0rehud",
"TF2Huds": "https://tf2huds.dev/hud/m0re-Hud",
"Download": [
{
"Source": "GitHub",
"Link": "https://github.com/Hypnootize/m0rehud/archive/refs/heads/master.zip"
}
]
},
"Screenshots": [
"https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/m0rehud/m0rehud-menu.webp",
"https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/m0rehud/m0rehud-buff.webp",
"https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/m0rehud/m0rehud-scoreboard.webp",
"https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/m0rehud/m0rehud-spectator.webp"
]
},
{
"Name": "7HUD",
"Description": "Originally based off an old yA version. Hope you guys like it. Updates are typically delayed because I'm a full-time student, but I love TF2 and can't live without this HUD anymore, so you can always expect an update at some point. You should grab 4Plug to take full advantage of the customization of this hud.",
Expand Down
1 change: 0 additions & 1 deletion src/TF2HUD.Editor/JSON/berryhud.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"0 3 4 4"
],
"Links": {
"Update": "https://github.com/hexereii/BerryHUD/archive/refs/heads/main.zip",
"GitHub": "https://github.com/hexereii/BerryHUD",
"TF2Huds": "https://tf2huds.dev/hud/BerryHUD",
"Download": [
Expand Down
1 change: 0 additions & 1 deletion src/TF2HUD.Editor/JSON/budhud.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"4 7 7 7"
],
"Links": {
"Update": "https://github.com/rbjaxter/budhud/archive/master.zip", // TODO: Remove
"GitHub": "https://github.com/rbjaxter/budhud",
"TF2Huds": "https://tf2huds.dev/hud/budhud",
"ComfigHuds": "https://comfig.app/huds/page/budhud/",
Expand Down
Loading

0 comments on commit 7812e95

Please sign in to comment.