mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
Adjust the GetColor function to use the new method of receiving formatted strings.
This commit is contained in:
parent
e7b4462a68
commit
6522889492
@ -324,12 +324,18 @@ const Color3 & GetRandomColor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Color3 GetColor(CSStr name)
|
Color3 GetColor(const StackStrF & name)
|
||||||
|
{
|
||||||
|
return name.mLen <= 0 ? Color3() : GetColorStr(name.mPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Color3 GetColorStr(CSStr name)
|
||||||
{
|
{
|
||||||
// See if we actually have something to search for
|
// See if we actually have something to search for
|
||||||
if(!name || *name == 0)
|
if(!name || *name == '\0')
|
||||||
{
|
{
|
||||||
STHROWF("Cannot extract values from an empty string");
|
return Color3::NIL; // Use default color
|
||||||
}
|
}
|
||||||
// Clone the string into an editable version
|
// Clone the string into an editable version
|
||||||
CSStr str = StrJustAlphaNum(name);
|
CSStr str = StrJustAlphaNum(name);
|
||||||
@ -337,7 +343,7 @@ Color3 GetColor(CSStr name)
|
|||||||
// See if we still have a valid name after the cleanup
|
// See if we still have a valid name after the cleanup
|
||||||
if(!str || *str == '\0')
|
if(!str || *str == '\0')
|
||||||
{
|
{
|
||||||
STHROWF("Cannot extract values from an invalid string: %s", name);
|
return Color3::NIL; // Use default color
|
||||||
}
|
}
|
||||||
// Calculate the name length
|
// Calculate the name length
|
||||||
const Uint32 len = std::strlen(str);
|
const Uint32 len = std::strlen(str);
|
||||||
|
@ -211,7 +211,12 @@ const Color3 & GetRandomColor();
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Attempt to identify the color in the specified name and return it.
|
* Attempt to identify the color in the specified name and return it.
|
||||||
*/
|
*/
|
||||||
Color3 GetColor(CSStr name);
|
Color3 GetColorStr(CSStr name);
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Attempt to identify the color in the specified name and return it.
|
||||||
|
*/
|
||||||
|
Color3 GetColor(const StackStrF & name);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Throw the last system error as an exception.
|
* Throw the last system error as an exception.
|
||||||
|
Loading…
Reference in New Issue
Block a user