From a0935ba604d0fcf37ba29813bdcc84f6f323ddab Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Fri, 3 Jun 2022 02:55:52 +0800 Subject: [PATCH] If arg0str is used for a spotlight's color, convert that string to an int and pass that value as the light color. UDB's color picker interface uses the arg0str field for spotlight color. --- src/level/doomdata.h | 2 ++ src/level/level_light.cpp | 17 ++++++++++++++++- src/level/level_udmf.cpp | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/level/doomdata.h b/src/level/doomdata.h index bafb47c..cd619ad 100644 --- a/src/level/doomdata.h +++ b/src/level/doomdata.h @@ -3,6 +3,7 @@ #include "framework/tarray.h" #include "framework/templates.h" +#include "framework/zstring.h" #include "math/mathlib.h" #include #include @@ -237,6 +238,7 @@ struct IntThing short flags; int special; int args[5]; + FString arg0str; short pitch; // UDMF float height; // UDMF diff --git a/src/level/level_light.cpp b/src/level/level_light.cpp index 97ef666..bd60d96 100644 --- a/src/level/level_light.cpp +++ b/src/level/level_light.cpp @@ -116,6 +116,15 @@ void FLevel::SetupLights() // sun color lightcolor = thing->args[0]; + /* + // disabled for now, because I'm unsure if UDB will use the color picker interface for the sun color + if (thing->arg0str.Len() > 0) + { + FString hex = "0x" + thing->arg0str; + int rgb = hex.ToULong(); + lightcolor = (uint32_t)rgb; + } + */ // sample distance Samples = thing->args[1]; @@ -306,8 +315,14 @@ void FLevel::CreateLights() { lightcolor = (uint32_t)thing->args[0]; - // to do: UDB's color picker will assign the color as a hex string, stored + // UDB's color picker will assign the color as a hex string, stored // in the arg0str field. detect this, so that it can be converted into an int + if (thing->arg0str.Len() > 0) + { + FString hex = "0x" + thing->arg0str; + int rgb = hex.ToULong(); + lightcolor = (uint32_t)rgb; + } innerAngleCos = std::cos((float)thing->args[1] * 3.14159265359f / 180.0f); outerAngleCos = std::cos((float)thing->args[2] * 3.14159265359f / 180.0f); diff --git a/src/level/level_udmf.cpp b/src/level/level_udmf.cpp index e82708e..669d4a2 100644 --- a/src/level/level_udmf.cpp +++ b/src/level/level_udmf.cpp @@ -224,6 +224,11 @@ void FProcessor::ParseThing(IntThing *th) { th->alpha = CheckFloat(key); } + if (!stricmp(key, "arg0str")) + { + th->arg0str = value; + th->arg0str.StripChars("\""); + } // now store the key in its unprocessed form UDMFKey k = {key, value};