From 80b7d86cd84fe50b89aaf75c469639a1402bda43 Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Tue, 24 Jul 2018 11:35:52 +0300 Subject: [PATCH] Added: color user variable, //$UserReinterpret for color control on integer user variable --- Source/Core/Properties/AssemblyInfo.cs | 4 +-- Source/Core/ZDoom/ZScriptActorStructure.cs | 31 ++++++++++++++++++- .../BuilderModes/Properties/AssemblyInfo.cs | 2 +- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Source/Core/Properties/AssemblyInfo.cs b/Source/Core/Properties/AssemblyInfo.cs index 80c2ea18..b4fce0ad 100755 --- a/Source/Core/Properties/AssemblyInfo.cs +++ b/Source/Core/Properties/AssemblyInfo.cs @@ -30,6 +30,6 @@ using CodeImp.DoomBuilder; // Build Number // Revision // -[assembly: AssemblyVersion("2.3.0.3036")] +[assembly: AssemblyVersion("2.3.0.3037")] [assembly: NeutralResourcesLanguageAttribute("en")] -[assembly: AssemblyHash("74e31b6")] +[assembly: AssemblyHash("04dc210")] diff --git a/Source/Core/ZDoom/ZScriptActorStructure.cs b/Source/Core/ZDoom/ZScriptActorStructure.cs index c9da2b74..ed68f51b 100755 --- a/Source/Core/ZDoom/ZScriptActorStructure.cs +++ b/Source/Core/ZDoom/ZScriptActorStructure.cs @@ -786,6 +786,23 @@ namespace CodeImp.DoomBuilder.ZDoom continue; // go read next field } + UniversalType utype_reinterpret = utype; + if (var_props.ContainsKey("$userreinterpret")) + { + string sp = var_props["$userreinterpret"][0].Trim().ToLowerInvariant(); + switch (sp) + { + case "color": + if (utype != UniversalType.Integer) + { + parser.LogWarning("Cannot use $UserReinterpret Color with non-integers"); + break; + } + utype_reinterpret = UniversalType.Color; + break; + } + } + if (var_props.ContainsKey("$userdefaultvalue")) { string sp = var_props["$userdefaultvalue"][0]; @@ -809,6 +826,18 @@ namespace CodeImp.DoomBuilder.ZDoom int i; if (!int.TryParse(sp, out i)) { + if (utype_reinterpret == UniversalType.Color) + { + sp = sp.ToLowerInvariant(); + Rendering.PixelColor pc; + if (!ZDTextParser.GetColorFromString(sp, out pc)) + { + parser.LogWarning("Incorrect color default from string \"" + sp + "\""); + break; + } + udefault = pc.ToInt()&0xFFFFFF; + break; + } if (type == "bool") { sp = sp.ToLowerInvariant(); @@ -835,7 +864,7 @@ namespace CodeImp.DoomBuilder.ZDoom if (!name.StartsWith("user_")) continue; // we don't process non-user_ fields (because ZScript won't pick them up anyway) // parent class is not guaranteed to be loaded already, so handle collisions later - uservars.Add(name, utype); + uservars.Add(name, utype_reinterpret); if (udefault != null) uservar_defaults.Add(name, udefault); } diff --git a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs index f15adc58..414e2c01 100755 --- a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs +++ b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Resources; // Build Number // Revision // -[assembly: AssemblyVersion("2.3.0.3036")] +[assembly: AssemblyVersion("2.3.0.3037")] [assembly: NeutralResourcesLanguageAttribute("en")]