mirror of
https://github.com/whoahq/whoa.git
synced 2026-08-05 00:14:31 +03:00
chore(ui): consolidate StringTo functions in ui
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
This commit is contained in:
parent
0163d91543
commit
7ed3475059
@ -3,9 +3,9 @@
|
|||||||
#include "db/Db.hpp"
|
#include "db/Db.hpp"
|
||||||
#include "glue/CGlueMgr.hpp"
|
#include "glue/CGlueMgr.hpp"
|
||||||
#include "glue/CRealmList.hpp"
|
#include "glue/CRealmList.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include "ui/FrameScript.hpp"
|
#include "ui/FrameScript.hpp"
|
||||||
#include "ui/Types.hpp"
|
#include "ui/Types.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
#include "ui/LoadXML.hpp"
|
#include "ui/LoadXML.hpp"
|
||||||
#include "ui/Util.hpp"
|
#include "ui/Util.hpp"
|
||||||
#include "util/CStatus.hpp"
|
#include "util/CStatus.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include <common/XML.hpp>
|
#include <common/XML.hpp>
|
||||||
#include <storm/Error.hpp>
|
#include <storm/Error.hpp>
|
||||||
|
|
||||||
|
|||||||
@ -2,11 +2,11 @@
|
|||||||
#include "gx/Coordinate.hpp"
|
#include "gx/Coordinate.hpp"
|
||||||
#include "ui/CScriptRegion.hpp"
|
#include "ui/CScriptRegion.hpp"
|
||||||
#include "ui/FrameScript_Object.hpp"
|
#include "ui/FrameScript_Object.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleFontString.hpp"
|
#include "ui/simple/CSimpleFontString.hpp"
|
||||||
#include "ui/simple/CSimpleTexture.hpp"
|
#include "ui/simple/CSimpleTexture.hpp"
|
||||||
#include "ui/simple/CSimpleTop.hpp"
|
#include "ui/simple/CSimpleTop.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <tempest/Rect.hpp>
|
#include <tempest/Rect.hpp>
|
||||||
|
|||||||
159
src/ui/Util.cpp
159
src/ui/Util.cpp
@ -1,4 +1,5 @@
|
|||||||
#include "ui/Util.hpp"
|
#include "ui/Util.hpp"
|
||||||
|
#include "util/Lua.hpp"
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <storm/String.hpp>
|
#include <storm/String.hpp>
|
||||||
|
|
||||||
@ -31,6 +32,139 @@ int32_t StringToBlendMode(const char* string, EGxBlend& blend) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t StringToBOOL(const char* string) {
|
||||||
|
return StringToBOOL(string, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StringToBOOL(const char* string, int32_t def) {
|
||||||
|
if (!string) {
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (*string) {
|
||||||
|
case '0':
|
||||||
|
case 'F':
|
||||||
|
case 'N':
|
||||||
|
case 'f':
|
||||||
|
case 'n':
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case '1':
|
||||||
|
case '2':
|
||||||
|
case '3':
|
||||||
|
case '4':
|
||||||
|
case '5':
|
||||||
|
case '6':
|
||||||
|
case '7':
|
||||||
|
case '8':
|
||||||
|
case '9':
|
||||||
|
case 'T':
|
||||||
|
case 'Y':
|
||||||
|
case 't':
|
||||||
|
case 'y':
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (!SStrCmpI(string, "off", 0x7FFFFFFFu) || !SStrCmpI(string, "disabled", 0x7FFFFFFFu)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "on", 0x7FFFFFFFu) || !SStrCmpI(string, "enabled", 0x7FFFFFFFu)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StringToBOOL(lua_State* L, int32_t idx, int32_t def) {
|
||||||
|
bool result;
|
||||||
|
const char* str;
|
||||||
|
|
||||||
|
switch (lua_type(L, idx)) {
|
||||||
|
case LUA_TNIL:
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LUA_TBOOLEAN:
|
||||||
|
result = lua_toboolean(L, idx);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LUA_TNUMBER:
|
||||||
|
result = lua_tonumber(L, idx) != 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LUA_TSTRING:
|
||||||
|
str = lua_tostring(L, idx);
|
||||||
|
result = StringToBOOL(str, def);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
result = def;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t StringToClickAction(const char* string) {
|
||||||
|
if (!string || !*string) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "LeftButtonDown", STORM_MAX_STR)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "LeftButtonUp", STORM_MAX_STR)) {
|
||||||
|
return 0x80000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "MiddleButtonDown", STORM_MAX_STR)) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "MiddleButtonUp", STORM_MAX_STR)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "RightButtonDown", STORM_MAX_STR)) {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "RightButtonUp", STORM_MAX_STR)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO remaining buttons
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t StringToDrawLayer(const char* string, int32_t& layer) {
|
||||||
|
struct LayerEntry {
|
||||||
|
int32_t layer;
|
||||||
|
const char* string;
|
||||||
|
};
|
||||||
|
|
||||||
|
static LayerEntry layerMap[] = {
|
||||||
|
{ 0, "BACKGROUND" },
|
||||||
|
{ 1, "BORDER" },
|
||||||
|
{ 2, "ARTWORK" },
|
||||||
|
{ 3, "OVERLAY" },
|
||||||
|
{ 4, "HIGHLIGHT" }
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto& entry : layerMap) {
|
||||||
|
if (!SStrCmpI(entry.string, string)) {
|
||||||
|
layer = entry.layer;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t StringToFramePoint(const char* string, FRAMEPOINT& point) {
|
int32_t StringToFramePoint(const char* string, FRAMEPOINT& point) {
|
||||||
struct FramePointEntry {
|
struct FramePointEntry {
|
||||||
FRAMEPOINT value;
|
FRAMEPOINT value;
|
||||||
@ -87,6 +221,31 @@ int32_t StringToFrameStrata(const char* string, FRAME_STRATA& strata) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t StringToJustify(const char* string, uint32_t& justify) {
|
||||||
|
struct JustifyEntry {
|
||||||
|
uint32_t value;
|
||||||
|
const char* string;
|
||||||
|
};
|
||||||
|
|
||||||
|
static JustifyEntry justifyMap[] = {
|
||||||
|
{ 0x1, "LEFT" },
|
||||||
|
{ 0x2, "CENTER" },
|
||||||
|
{ 0x4, "RIGHT" },
|
||||||
|
{ 0x8, "TOP" },
|
||||||
|
{ 0x10, "MIDDLE" },
|
||||||
|
{ 0x20, "BOTTOM" }
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto& entry : justifyMap) {
|
||||||
|
if (!SStrCmpI(entry.string, string)) {
|
||||||
|
justify = entry.value;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t StringToOrientation(const char* string, ORIENTATION& orientation) {
|
int32_t StringToOrientation(const char* string, ORIENTATION& orientation) {
|
||||||
struct OrientationEntry {
|
struct OrientationEntry {
|
||||||
ORIENTATION value;
|
ORIENTATION value;
|
||||||
|
|||||||
@ -5,14 +5,28 @@
|
|||||||
#include "ui/Types.hpp"
|
#include "ui/Types.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
struct lua_State;
|
||||||
|
|
||||||
const char* LanguageProcess(const char* string);
|
const char* LanguageProcess(const char* string);
|
||||||
|
|
||||||
int32_t StringToBlendMode(const char* string, EGxBlend& blend);
|
int32_t StringToBlendMode(const char* string, EGxBlend& blend);
|
||||||
|
|
||||||
|
int32_t StringToBOOL(const char* string);
|
||||||
|
|
||||||
|
bool StringToBOOL(const char* string, int32_t def);
|
||||||
|
|
||||||
|
bool StringToBOOL(lua_State* L, int32_t idx, int32_t def);
|
||||||
|
|
||||||
|
uint64_t StringToClickAction(const char* string);
|
||||||
|
|
||||||
|
int32_t StringToDrawLayer(const char* string, int32_t& layer);
|
||||||
|
|
||||||
int32_t StringToFramePoint(const char* string, FRAMEPOINT& point);
|
int32_t StringToFramePoint(const char* string, FRAMEPOINT& point);
|
||||||
|
|
||||||
int32_t StringToFrameStrata(const char* string, FRAME_STRATA& strata);
|
int32_t StringToFrameStrata(const char* string, FRAME_STRATA& strata);
|
||||||
|
|
||||||
|
int32_t StringToJustify(const char* string, uint32_t& justify);
|
||||||
|
|
||||||
int32_t StringToOrientation(const char* string, ORIENTATION& orientation);
|
int32_t StringToOrientation(const char* string, ORIENTATION& orientation);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -3,10 +3,10 @@
|
|||||||
#include "gx/Coordinate.hpp"
|
#include "gx/Coordinate.hpp"
|
||||||
#include "ui/FrameScript.hpp"
|
#include "ui/FrameScript.hpp"
|
||||||
#include "ui/ScriptFunctionsShared.hpp"
|
#include "ui/ScriptFunctionsShared.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/game/CGGameUI.hpp"
|
#include "ui/game/CGGameUI.hpp"
|
||||||
#include "ui/game/Types.hpp"
|
#include "ui/game/Types.hpp"
|
||||||
#include "ui/simple/CSimpleTop.hpp"
|
#include "ui/simple/CSimpleTop.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|||||||
@ -3,12 +3,12 @@
|
|||||||
#include "object/Client.hpp"
|
#include "object/Client.hpp"
|
||||||
#include "ui/FrameScript.hpp"
|
#include "ui/FrameScript.hpp"
|
||||||
#include "ui/ScriptFunctionsSystem.hpp"
|
#include "ui/ScriptFunctionsSystem.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/game/CGGameUI.hpp"
|
#include "ui/game/CGGameUI.hpp"
|
||||||
#include "ui/game/ScriptUtil.hpp"
|
#include "ui/game/ScriptUtil.hpp"
|
||||||
#include "ui/game/Types.hpp"
|
#include "ui/game/Types.hpp"
|
||||||
#include "util/GUID.hpp"
|
#include "util/GUID.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
|
|
||||||
#define NUM_SCRIPT_EVENTS 722
|
#define NUM_SCRIPT_EVENTS 722
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
#include "ui/simple/CSimpleButtonScript.hpp"
|
#include "ui/simple/CSimpleButtonScript.hpp"
|
||||||
#include "gx/Coordinate.hpp"
|
#include "gx/Coordinate.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleButton.hpp"
|
#include "ui/simple/CSimpleButton.hpp"
|
||||||
#include "ui/simple/CSimpleFont.hpp"
|
#include "ui/simple/CSimpleFont.hpp"
|
||||||
#include "ui/simple/CSimpleFontString.hpp"
|
#include "ui/simple/CSimpleFontString.hpp"
|
||||||
#include "ui/simple/CSimpleTexture.hpp"
|
#include "ui/simple/CSimpleTexture.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#include "ui/simple/CSimpleCheckbox.hpp"
|
#include "ui/simple/CSimpleCheckbox.hpp"
|
||||||
#include "ui/LoadXML.hpp"
|
#include "ui/LoadXML.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleCheckboxScript.hpp"
|
#include "ui/simple/CSimpleCheckboxScript.hpp"
|
||||||
#include "ui/simple/CSimpleTexture.hpp"
|
#include "ui/simple/CSimpleTexture.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include <common/XML.hpp>
|
#include <common/XML.hpp>
|
||||||
|
|
||||||
int32_t CSimpleCheckbox::s_metatable;
|
int32_t CSimpleCheckbox::s_metatable;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#include "ui/simple/CSimpleCheckboxScript.hpp"
|
#include "ui/simple/CSimpleCheckboxScript.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleCheckbox.hpp"
|
#include "ui/simple/CSimpleCheckbox.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#include "gx/Coordinate.hpp"
|
#include "gx/Coordinate.hpp"
|
||||||
#include "gx/Gx.hpp"
|
#include "gx/Gx.hpp"
|
||||||
#include "ui/LoadXML.hpp"
|
#include "ui/LoadXML.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleEditBoxScript.hpp"
|
#include "ui/simple/CSimpleEditBoxScript.hpp"
|
||||||
#include "ui/simple/CSimpleFontString.hpp"
|
#include "ui/simple/CSimpleFontString.hpp"
|
||||||
#include "ui/simple/CSimpleFontedFrameFont.hpp"
|
#include "ui/simple/CSimpleFontedFrameFont.hpp"
|
||||||
@ -10,7 +11,6 @@
|
|||||||
#include "util/Byte.hpp"
|
#include "util/Byte.hpp"
|
||||||
#include "util/CStatus.hpp"
|
#include "util/CStatus.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include <common/XML.hpp>
|
#include <common/XML.hpp>
|
||||||
#include <storm/String.hpp>
|
#include <storm/String.hpp>
|
||||||
#include <storm/Unicode.hpp>
|
#include <storm/Unicode.hpp>
|
||||||
|
|||||||
@ -4,9 +4,9 @@
|
|||||||
#include "ui/FrameXML.hpp"
|
#include "ui/FrameXML.hpp"
|
||||||
#include "ui/LoadXML.hpp"
|
#include "ui/LoadXML.hpp"
|
||||||
#include "ui/Types.hpp"
|
#include "ui/Types.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleFontScript.hpp"
|
#include "ui/simple/CSimpleFontScript.hpp"
|
||||||
#include "util/CStatus.hpp"
|
#include "util/CStatus.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include <common/XML.hpp>
|
#include <common/XML.hpp>
|
||||||
#include <storm/String.hpp>
|
#include <storm/String.hpp>
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,6 @@
|
|||||||
#include "ui/simple/CSimpleFrame.hpp"
|
#include "ui/simple/CSimpleFrame.hpp"
|
||||||
#include "ui/simple/CSimpleTop.hpp"
|
#include "ui/simple/CSimpleTop.hpp"
|
||||||
#include "util/CStatus.hpp"
|
#include "util/CStatus.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include <common/XML.hpp>
|
#include <common/XML.hpp>
|
||||||
#include <storm/String.hpp>
|
#include <storm/String.hpp>
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#include "ui/simple/CSimpleFontStringScript.hpp"
|
#include "ui/simple/CSimpleFontStringScript.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleFont.hpp"
|
#include "ui/simple/CSimpleFont.hpp"
|
||||||
#include "ui/simple/CSimpleFontString.hpp"
|
#include "ui/simple/CSimpleFontString.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
#include "ui/FrameScript_Object.hpp"
|
#include "ui/FrameScript_Object.hpp"
|
||||||
#include "ui/FrameXML.hpp"
|
#include "ui/FrameXML.hpp"
|
||||||
#include "ui/LoadXML.hpp"
|
#include "ui/LoadXML.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleFontString.hpp"
|
#include "ui/simple/CSimpleFontString.hpp"
|
||||||
#include "ui/simple/CSimpleFrameScript.hpp"
|
#include "ui/simple/CSimpleFrameScript.hpp"
|
||||||
#include "ui/simple/CSimpleRender.hpp"
|
#include "ui/simple/CSimpleRender.hpp"
|
||||||
@ -16,7 +17,6 @@
|
|||||||
#include "ui/simple/CSimpleTitleRegion.hpp"
|
#include "ui/simple/CSimpleTitleRegion.hpp"
|
||||||
#include "ui/simple/CSimpleTop.hpp"
|
#include "ui/simple/CSimpleTop.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include <common/XML.hpp>
|
#include <common/XML.hpp>
|
||||||
#include <storm/Error.hpp>
|
#include <storm/Error.hpp>
|
||||||
#include <storm/String.hpp>
|
#include <storm/String.hpp>
|
||||||
|
|||||||
@ -3,12 +3,12 @@
|
|||||||
#include "ui/CBackdropGenerator.hpp"
|
#include "ui/CBackdropGenerator.hpp"
|
||||||
#include "ui/FrameScript.hpp"
|
#include "ui/FrameScript.hpp"
|
||||||
#include "ui/FrameXML.hpp"
|
#include "ui/FrameXML.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleFont.hpp"
|
#include "ui/simple/CSimpleFont.hpp"
|
||||||
#include "ui/simple/CSimpleFontString.hpp"
|
#include "ui/simple/CSimpleFontString.hpp"
|
||||||
#include "ui/simple/CSimpleFrame.hpp"
|
#include "ui/simple/CSimpleFrame.hpp"
|
||||||
#include "ui/simple/CSimpleTexture.hpp"
|
#include "ui/simple/CSimpleTexture.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
#include <storm/Memory.hpp>
|
#include <storm/Memory.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
#include "ui/simple/CSimpleHTML.hpp"
|
#include "ui/simple/CSimpleHTML.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleFontString.hpp"
|
#include "ui/simple/CSimpleFontString.hpp"
|
||||||
#include "ui/simple/CSimpleFontedFrameFont.hpp"
|
#include "ui/simple/CSimpleFontedFrameFont.hpp"
|
||||||
#include "ui/simple/CSimpleHTMLScript.hpp"
|
#include "ui/simple/CSimpleHTMLScript.hpp"
|
||||||
#include "ui/simple/CSimpleTop.hpp"
|
#include "ui/simple/CSimpleTop.hpp"
|
||||||
#include "util/CStatus.hpp"
|
#include "util/CStatus.hpp"
|
||||||
#include "util/SFile.hpp"
|
#include "util/SFile.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include <common/XML.hpp>
|
#include <common/XML.hpp>
|
||||||
|
|
||||||
int32_t CSimpleHTML::s_metatable;
|
int32_t CSimpleHTML::s_metatable;
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
#include "ui/simple/CSimpleSlider.hpp"
|
#include "ui/simple/CSimpleSlider.hpp"
|
||||||
#include "math/Utils.hpp"
|
#include "math/Utils.hpp"
|
||||||
#include "ui/LoadXML.hpp"
|
#include "ui/LoadXML.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleSliderScript.hpp"
|
#include "ui/simple/CSimpleSliderScript.hpp"
|
||||||
#include "ui/simple/CSimpleTexture.hpp"
|
#include "ui/simple/CSimpleTexture.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include <common/XML.hpp>
|
#include <common/XML.hpp>
|
||||||
#include <tempest/Math.hpp>
|
#include <tempest/Math.hpp>
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
#include "ui/simple/CSimpleStatusBar.hpp"
|
#include "ui/simple/CSimpleStatusBar.hpp"
|
||||||
#include "ui/LoadXML.hpp"
|
#include "ui/LoadXML.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleStatusBarScript.hpp"
|
#include "ui/simple/CSimpleStatusBarScript.hpp"
|
||||||
#include "ui/simple/CSimpleTexture.hpp"
|
#include "ui/simple/CSimpleTexture.hpp"
|
||||||
#include "util/CStatus.hpp"
|
#include "util/CStatus.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include <common/XML.hpp>
|
#include <common/XML.hpp>
|
||||||
|
|
||||||
int32_t CSimpleStatusBar::s_metatable;
|
int32_t CSimpleStatusBar::s_metatable;
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
#include "ui/Util.hpp"
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleFrame.hpp"
|
#include "ui/simple/CSimpleFrame.hpp"
|
||||||
#include "ui/simple/CSimpleTextureScript.hpp"
|
#include "ui/simple/CSimpleTextureScript.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <common/XML.hpp>
|
#include <common/XML.hpp>
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#include "ui/simple/CSimpleTextureScript.hpp"
|
#include "ui/simple/CSimpleTextureScript.hpp"
|
||||||
#include "ui/Types.hpp"
|
#include "ui/Types.hpp"
|
||||||
|
#include "ui/Util.hpp"
|
||||||
#include "ui/simple/CSimpleTexture.hpp"
|
#include "ui/simple/CSimpleTexture.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
|||||||
@ -1,161 +0,0 @@
|
|||||||
#include "util/StringTo.hpp"
|
|
||||||
#include "util/Lua.hpp"
|
|
||||||
#include <storm/String.hpp>
|
|
||||||
|
|
||||||
uint64_t StringToClickAction(const char* actionStr) {
|
|
||||||
if (!actionStr || !*actionStr) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SStrCmpI(actionStr, "LeftButtonDown", STORM_MAX_STR)) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SStrCmpI(actionStr, "LeftButtonUp", STORM_MAX_STR)) {
|
|
||||||
return 0x80000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SStrCmpI(actionStr, "MiddleButtonDown", STORM_MAX_STR)) {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SStrCmpI(actionStr, "MiddleButtonUp", STORM_MAX_STR)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SStrCmpI(actionStr, "RightButtonDown", STORM_MAX_STR)) {
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SStrCmpI(actionStr, "RightButtonUp", STORM_MAX_STR)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO remaining buttons
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t StringToBOOL(const char* str) {
|
|
||||||
return StringToBOOL(str, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StringToBOOL(const char* str, int32_t def) {
|
|
||||||
if (!str) {
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (*str) {
|
|
||||||
case '0':
|
|
||||||
case 'F':
|
|
||||||
case 'N':
|
|
||||||
case 'f':
|
|
||||||
case 'n':
|
|
||||||
return false;
|
|
||||||
|
|
||||||
case '1':
|
|
||||||
case '2':
|
|
||||||
case '3':
|
|
||||||
case '4':
|
|
||||||
case '5':
|
|
||||||
case '6':
|
|
||||||
case '7':
|
|
||||||
case '8':
|
|
||||||
case '9':
|
|
||||||
case 'T':
|
|
||||||
case 'Y':
|
|
||||||
case 't':
|
|
||||||
case 'y':
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (!SStrCmpI(str, "off", 0x7FFFFFFFu) || !SStrCmpI(str, "disabled", 0x7FFFFFFFu)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SStrCmpI(str, "on", 0x7FFFFFFFu) || !SStrCmpI(str, "enabled", 0x7FFFFFFFu)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StringToBOOL(lua_State* L, int32_t idx, int32_t def) {
|
|
||||||
bool result;
|
|
||||||
const char* str;
|
|
||||||
|
|
||||||
switch (lua_type(L, idx)) {
|
|
||||||
case LUA_TNIL:
|
|
||||||
result = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LUA_TBOOLEAN:
|
|
||||||
result = lua_toboolean(L, idx);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LUA_TNUMBER:
|
|
||||||
result = lua_tonumber(L, idx) != 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LUA_TSTRING:
|
|
||||||
str = lua_tostring(L, idx);
|
|
||||||
result = StringToBOOL(str, def);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
result = def;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t StringToDrawLayer(const char* string, int32_t& layer) {
|
|
||||||
struct LayerEntry {
|
|
||||||
int32_t layer;
|
|
||||||
const char* string;
|
|
||||||
};
|
|
||||||
|
|
||||||
static LayerEntry layerMap[] = {
|
|
||||||
{ 0, "BACKGROUND" },
|
|
||||||
{ 1, "BORDER" },
|
|
||||||
{ 2, "ARTWORK" },
|
|
||||||
{ 3, "OVERLAY" },
|
|
||||||
{ 4, "HIGHLIGHT" }
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const auto& entry : layerMap) {
|
|
||||||
if (!SStrCmpI(entry.string, string)) {
|
|
||||||
layer = entry.layer;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t StringToJustify(const char* string, uint32_t& justify) {
|
|
||||||
struct JustifyEntry {
|
|
||||||
uint32_t value;
|
|
||||||
const char* string;
|
|
||||||
};
|
|
||||||
|
|
||||||
static JustifyEntry justifyMap[] = {
|
|
||||||
{ 0x1, "LEFT" },
|
|
||||||
{ 0x2, "CENTER" },
|
|
||||||
{ 0x4, "RIGHT" },
|
|
||||||
{ 0x8, "TOP" },
|
|
||||||
{ 0x10, "MIDDLE" },
|
|
||||||
{ 0x20, "BOTTOM" }
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const auto& entry : justifyMap) {
|
|
||||||
if (!SStrCmpI(entry.string, string)) {
|
|
||||||
justify = entry.value;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
#ifndef UTIL_STRING_TO_HPP
|
|
||||||
#define UTIL_STRING_TO_HPP
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
struct lua_State;
|
|
||||||
|
|
||||||
uint64_t StringToClickAction(const char* actionStr);
|
|
||||||
|
|
||||||
int32_t StringToBOOL(const char*);
|
|
||||||
|
|
||||||
bool StringToBOOL(const char*, int32_t);
|
|
||||||
|
|
||||||
bool StringToBOOL(lua_State*, int32_t, int32_t);
|
|
||||||
|
|
||||||
int32_t StringToDrawLayer(const char*, int32_t&);
|
|
||||||
|
|
||||||
int32_t StringToJustify(const char*, uint32_t&);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Loading…
Reference in New Issue
Block a user