From dfda870eacb364e4664fd4e5657f2ead080e5e19 Mon Sep 17 00:00:00 2001 From: That_One_Nerd Date: Tue, 16 May 2023 08:05:13 -0400 Subject: [PATCH] Added final tweaks to parsing mod info (for now). --- SrcMod/Shell/Mod.cs | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/SrcMod/Shell/Mod.cs b/SrcMod/Shell/Mod.cs index 5386868..fef57fb 100644 --- a/SrcMod/Shell/Mod.cs +++ b/SrcMod/Shell/Mod.cs @@ -6,7 +6,7 @@ public class Mod public string? Developer { get; set; } public string? DeveloperUrl { get; set; } - public Dictionary SearchPaths { get; set; } // TODO: Replace the keys with a flags enum. + public Dictionary SearchPaths { get; set; } public string? ManualUrl { get; set; } public string? FgdDataPath { get; set; } @@ -68,7 +68,7 @@ public class Mod _ => throw new ArgumentException($"Unknown type \"{info.Type}\"") }, RootDirectory = root, - SearchPaths = info.FileSystem.SearchPaths, + SearchPaths = new(), ShowDifficultyMenu = info.NoDifficulty is null || !info.NoDifficulty.Value, ShowModelMenu = info.NoModels is null || !info.NoModels.Value, ShowPortalMenu = info.HasPortals is not null && info.HasPortals.Value, @@ -91,6 +91,24 @@ public class Mod if (info.SupportsXBox360 is not null && info.SupportsXBox360.Value) curMod.SupportingFlags |= SupportFlags.XBox360; + foreach (KeyValuePair pair in info.FileSystem.SearchPaths) + { + SearchPathType type = SearchPathType.Unknown; + string[] parts = pair.Key.Trim().ToLower().Split('+'); + foreach (string part in parts) type |= part switch + { + "game" => SearchPathType.Game, + "game_write" => SearchPathType.GameWrite, + "gamebin" => SearchPathType.GameBinaries, + "platform" => SearchPathType.Platform, + "mod" => SearchPathType.Mod, + "mod_write" => SearchPathType.ModWrite, + "default_write_path" => SearchPathType.DefaultWritePath, + "vpk" => SearchPathType.Vpk, + _ => SearchPathType.Unknown + }; + } + return curMod; } @@ -138,6 +156,20 @@ public class Mod XBox360 = 4 } + [Flags] + public enum SearchPathType + { + Unknown = 0, + Game = 1, + GameWrite = 2, + GameBinaries = 4, + Platform = 8, + Mod = 16, + ModWrite = 32, + DefaultWritePath = 64, + Vpk = 128 + } + public enum PlayerType { Singleplayer = 1,