mirror of
https://github.com/whoahq/whoa.git
synced 2026-08-05 00:14:31 +03:00
Compare commits
13 Commits
5fd2461dc6
...
8edad0b65e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8edad0b65e | ||
|
|
57fbf42475 | ||
|
|
7ed3475059 | ||
|
|
0163d91543 | ||
|
|
dd3a0f6a81 | ||
|
|
8935c520c0 | ||
|
|
7cf7127810 | ||
|
|
8fb51991e0 | ||
|
|
7fdd22545f | ||
|
|
15eafe92d7 | ||
|
|
1ad3679f90 | ||
|
|
81970958a8 | ||
|
|
a9cad5238d |
@ -32,6 +32,8 @@ if(WHOA_SYSTEM_MAC)
|
|||||||
"-framework AppKit"
|
"-framework AppKit"
|
||||||
"-framework Carbon"
|
"-framework Carbon"
|
||||||
"-framework IOKit"
|
"-framework IOKit"
|
||||||
|
"-framework Metal"
|
||||||
|
"-framework QuartzCore"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mac/MainMenu.nib DESTINATION "bin")
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mac/MainMenu.nib DESTINATION "bin")
|
||||||
|
|||||||
9
src/app/mac/EngineMTLLayerView.h
Normal file
9
src/app/mac/EngineMTLLayerView.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef APP_MAC_ENGINE_MTL_LAYER_VIEW_H
|
||||||
|
#define APP_MAC_ENGINE_MTL_LAYER_VIEW_H
|
||||||
|
|
||||||
|
#include "app/mac/EngineGLLayerView.h"
|
||||||
|
|
||||||
|
@interface EngineMTLLayerView : EngineGLLayerView
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
36
src/app/mac/EngineMTLLayerView.mm
Normal file
36
src/app/mac/EngineMTLLayerView.mm
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#include "app/mac/EngineMTLLayerView.h"
|
||||||
|
#import <QuartzCore/CAMetalLayer.h>
|
||||||
|
|
||||||
|
@implementation EngineMTLLayerView
|
||||||
|
|
||||||
|
- (CALayer*)makeBackingLayer {
|
||||||
|
return [CAMetalLayer layer];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)initWithFrame:(NSRect)frame glWindow:(GLWindow*)window {
|
||||||
|
self = [super initWithFrame:frame glWindow:window];
|
||||||
|
|
||||||
|
if (self) {
|
||||||
|
[self setWantsLayer:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)drawRect:(NSRect)dirtyRect {
|
||||||
|
// Rendering is driven by CGxDeviceMTL.
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)update {
|
||||||
|
[super update];
|
||||||
|
|
||||||
|
if (![self.layer isKindOfClass:[CAMetalLayer class]]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAMetalLayer* layer = (CAMetalLayer*)self.layer;
|
||||||
|
CGSize size = [self convertSizeToBacking:self.bounds.size];
|
||||||
|
layer.drawableSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@ -1,7 +1,9 @@
|
|||||||
#include "app/mac/View.h"
|
#include "app/mac/View.h"
|
||||||
#include "app/mac/EngineGLLayerView.h"
|
#include "app/mac/EngineGLLayerView.h"
|
||||||
|
#include "app/mac/EngineMTLLayerView.h"
|
||||||
#include "app/mac/WindowCallbacks.h"
|
#include "app/mac/WindowCallbacks.h"
|
||||||
#include "gx/gll/GLWindow.h"
|
#include "gx/gll/GLWindow.h"
|
||||||
|
#include "gx/Device.hpp"
|
||||||
|
|
||||||
GLWindowCallbacks EngineViewCallbacks = {
|
GLWindowCallbacks EngineViewCallbacks = {
|
||||||
&MacOnResized,
|
&MacOnResized,
|
||||||
@ -23,5 +25,9 @@ void AssignEngineViewCallbacks(GLWindowCallbacks* callbacks) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Class GetEngineViewClass() {
|
Class GetEngineViewClass() {
|
||||||
|
if (GxDevApi() == GxApi_Metal) {
|
||||||
|
return [EngineMTLLayerView class];
|
||||||
|
}
|
||||||
|
|
||||||
return [EngineGLLayerView class];
|
return [EngineGLLayerView class];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#include "app/mac/MacClient.h"
|
#include "app/mac/MacClient.h"
|
||||||
#include "event/Input.hpp"
|
#include "event/Input.hpp"
|
||||||
#include "gx/gll/CGxDeviceGLL.hpp"
|
#include "gx/gll/CGxDeviceGLL.hpp"
|
||||||
|
#include "gx/mtl/CGxDeviceMTL.hpp"
|
||||||
#include "gx/Device.hpp"
|
#include "gx/Device.hpp"
|
||||||
#include "gx/Window.hpp"
|
#include "gx/Window.hpp"
|
||||||
#include <bc/Debug.hpp>
|
#include <bc/Debug.hpp>
|
||||||
@ -171,7 +172,11 @@ void MacOnResized(int32_t width, int32_t height, bool a3) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GxDevApi() == GxApi_GLL) {
|
||||||
static_cast<CGxDeviceGLL*>(g_theGxDevicePtr)->Resize(width, height);
|
static_cast<CGxDeviceGLL*>(g_theGxDevicePtr)->Resize(width, height);
|
||||||
|
} else if (GxDevApi() == GxApi_Metal) {
|
||||||
|
static_cast<CGxDeviceMTL*>(g_theGxDevicePtr)->Resize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
OsQueuePut(OS_INPUT_SIZE, width, height, 0, 0);
|
OsQueuePut(OS_INPUT_SIZE, width, height, 0, 0);
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
#include "gx/Adapter.hpp"
|
#include "gx/Adapter.hpp"
|
||||||
#include "gx/Device.hpp"
|
#include "gx/Device.hpp"
|
||||||
#include <storm/Array.hpp>
|
#include <storm/Array.hpp>
|
||||||
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
static CGxDevice* s_device;
|
static CGxDevice* s_device;
|
||||||
@ -417,6 +418,13 @@ void ConsoleDeviceInitialize(const char* title) {
|
|||||||
api = GxApi_GLL;
|
api = GxApi_GLL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WHOA_SYSTEM_MAC)
|
||||||
|
const char* apiOverride = getenv("WHOA_GX_API");
|
||||||
|
if (apiOverride && !strcmp(apiOverride, "metal")) {
|
||||||
|
api = GxApi_Metal;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
s_device = GxDevCreate(api, OsWindowProc, format);
|
s_device = GxDevCreate(api, OsWindowProc, format);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#if defined(WHOA_SYSTEM_MAC)
|
#if defined(WHOA_SYSTEM_MAC)
|
||||||
#include "gx/gll/CGxDeviceGLL.hpp"
|
#include "gx/gll/CGxDeviceGLL.hpp"
|
||||||
|
#include "gx/mtl/CGxDeviceMTL.hpp"
|
||||||
#include "gx/mac/Display.hpp"
|
#include "gx/mac/Display.hpp"
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
@ -117,6 +118,8 @@ int32_t CGxDevice::AdapterFormats(EGxApi api, TSGrowableArray<CGxFormat>& adapte
|
|||||||
CGxDevice::OpenGlAdapterFormats(adapterFormats);
|
CGxDevice::OpenGlAdapterFormats(adapterFormats);
|
||||||
} else if (api == GxApi_GLL) {
|
} else if (api == GxApi_GLL) {
|
||||||
CGxDevice::GLLAdapterFormats(adapterFormats);
|
CGxDevice::GLLAdapterFormats(adapterFormats);
|
||||||
|
} else if (api == GxApi_Metal) {
|
||||||
|
CGxDevice::OpenGlAdapterFormats(adapterFormats);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(WHOA_SYSTEM_LINUX)
|
#elif defined(WHOA_SYSTEM_LINUX)
|
||||||
@ -228,6 +231,11 @@ CGxDevice* CGxDevice::NewGLL() {
|
|||||||
auto m = SMemAlloc(sizeof(CGxDeviceGLL), __FILE__, __LINE__, 0x0);
|
auto m = SMemAlloc(sizeof(CGxDeviceGLL), __FILE__, __LINE__, 0x0);
|
||||||
return new (m) CGxDeviceGLL();
|
return new (m) CGxDeviceGLL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGxDevice* CGxDevice::NewMTL() {
|
||||||
|
auto m = SMemAlloc(sizeof(CGxDeviceMTL), __FILE__, __LINE__, 0x0);
|
||||||
|
return new (m) CGxDeviceMTL();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CGxDevice* CGxDevice::NewOpenGl() {
|
CGxDevice* CGxDevice::NewOpenGl() {
|
||||||
|
|||||||
@ -77,6 +77,7 @@ class CGxDevice {
|
|||||||
#endif
|
#endif
|
||||||
#if defined(WHOA_SYSTEM_MAC)
|
#if defined(WHOA_SYSTEM_MAC)
|
||||||
static CGxDevice* NewGLL();
|
static CGxDevice* NewGLL();
|
||||||
|
static CGxDevice* NewMTL();
|
||||||
#endif
|
#endif
|
||||||
static CGxDevice* NewOpenGl();
|
static CGxDevice* NewOpenGl();
|
||||||
static void OpenGlAdapterFormats(TSGrowableArray<CGxFormat>& adapterFormats);
|
static void OpenGlAdapterFormats(TSGrowableArray<CGxFormat>& adapterFormats);
|
||||||
|
|||||||
@ -20,6 +20,7 @@ if(WHOA_SYSTEM_MAC)
|
|||||||
file(GLOB MAC_SOURCES
|
file(GLOB MAC_SOURCES
|
||||||
"gll/*.cpp"
|
"gll/*.cpp"
|
||||||
"gll/*.mm"
|
"gll/*.mm"
|
||||||
|
"mtl/*.mm"
|
||||||
"mac/*.cpp"
|
"mac/*.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,8 @@ CGxDevice* GxDevCreate(EGxApi api, int32_t (*windowProc)(void* window, uint32_t
|
|||||||
device = CGxDevice::NewOpenGl();
|
device = CGxDevice::NewOpenGl();
|
||||||
} else if (api == GxApi_GLL) {
|
} else if (api == GxApi_GLL) {
|
||||||
device = CGxDevice::NewGLL();
|
device = CGxDevice::NewGLL();
|
||||||
|
} else if (api == GxApi_Metal) {
|
||||||
|
device = CGxDevice::NewMTL();
|
||||||
} else {
|
} else {
|
||||||
// Error
|
// Error
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,8 @@ enum EGxApi {
|
|||||||
GxApi_D3d10 = 3,
|
GxApi_D3d10 = 3,
|
||||||
GxApi_D3d11 = 4,
|
GxApi_D3d11 = 4,
|
||||||
GxApi_GLL = 5,
|
GxApi_GLL = 5,
|
||||||
GxApis_Last = 6
|
GxApi_Metal = 6,
|
||||||
|
GxApis_Last = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EGxBlend {
|
enum EGxBlend {
|
||||||
|
|||||||
81
src/gx/mtl/CGxDeviceMTL.hpp
Normal file
81
src/gx/mtl/CGxDeviceMTL.hpp
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#ifndef GX_MTL_C_GX_DEVICE_MTL_HPP
|
||||||
|
#define GX_MTL_C_GX_DEVICE_MTL_HPP
|
||||||
|
|
||||||
|
#include "gx/CGxDevice.hpp"
|
||||||
|
#include "gx/gll/GLWindow.h"
|
||||||
|
|
||||||
|
class CGxBatch;
|
||||||
|
class CGxShader;
|
||||||
|
|
||||||
|
class CGxDeviceMTL : public CGxDevice {
|
||||||
|
public:
|
||||||
|
// Member variables
|
||||||
|
GLWindow m_window;
|
||||||
|
|
||||||
|
// Virtual member functions
|
||||||
|
void ITexMarkAsUpdated(CGxTex*) override;
|
||||||
|
void IRsSendToHw(EGxRenderState) override;
|
||||||
|
int32_t DeviceCreate(int32_t (*windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam), const CGxFormat&) override;
|
||||||
|
int32_t DeviceSetFormat(const CGxFormat&) override;
|
||||||
|
void* DeviceWindow() override;
|
||||||
|
void DeviceWM(EGxWM wm, uintptr_t param1, uintptr_t param2) override {};
|
||||||
|
void CapsWindowSize(CRect&) override;
|
||||||
|
void CapsWindowSizeInScreenCoords(CRect& dst) override;
|
||||||
|
void ScenePresent() override;
|
||||||
|
void SceneClear(uint32_t, CImVector) override;
|
||||||
|
void Draw(CGxBatch* batch, int32_t indexed) override;
|
||||||
|
void PoolSizeSet(CGxPool*, uint32_t) override;
|
||||||
|
char* BufLock(CGxBuf*) override;
|
||||||
|
int32_t BufUnlock(CGxBuf*, uint32_t) override;
|
||||||
|
void BufData(CGxBuf* buf, const void* data, size_t size, uintptr_t offset) override;
|
||||||
|
void TexDestroy(CGxTex* texId) override;
|
||||||
|
void IShaderCreate(CGxShader*) override;
|
||||||
|
void ShaderCreate(CGxShader*[], EGxShTarget, const char*, const char*, int32_t) override;
|
||||||
|
int32_t StereoEnabled(void) override;
|
||||||
|
void XformSetProjection(const C44Matrix& matrix) override;
|
||||||
|
|
||||||
|
// Member functions
|
||||||
|
CGxDeviceMTL();
|
||||||
|
void Resize(uint32_t width, uint32_t height);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ISetCaps(const CGxFormat& format);
|
||||||
|
void EnsureLibrary();
|
||||||
|
void BeginFrame();
|
||||||
|
void* GetPipeline(EGxVertexBufferFormat format, bool useColor, bool useSkin, bool useTex, int32_t blendMode);
|
||||||
|
void* GetPoolBuffer(CGxPool* pool);
|
||||||
|
void ITexCreate(CGxTex* texId);
|
||||||
|
void ITexUpload(CGxTex* texId);
|
||||||
|
void* GetTexture(CGxTex* texId);
|
||||||
|
void* GetSampler(CGxTex* texId);
|
||||||
|
void EnsureFallbackTexture();
|
||||||
|
void EnsureDepthTexture(uint32_t width, uint32_t height);
|
||||||
|
void* GetDepthState(bool depthTest, bool depthWrite, uint32_t depthFunc);
|
||||||
|
void* m_device = nullptr;
|
||||||
|
void* m_commandQueue = nullptr;
|
||||||
|
void* m_layer = nullptr;
|
||||||
|
void* m_shaderLibrary = nullptr;
|
||||||
|
void* m_pipelineColor[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||||
|
void* m_pipelineSolid[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||||
|
void* m_pipelineSkin[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||||
|
void* m_pipelineColorTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||||
|
void* m_pipelineSolidTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||||
|
void* m_pipelineSkinTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||||
|
void* m_pipelineColorTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||||
|
void* m_pipelineSolidTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||||
|
void* m_pipelineSkinTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||||
|
void* m_frameCommandBuffer = nullptr;
|
||||||
|
void* m_frameEncoder = nullptr;
|
||||||
|
void* m_frameDrawable = nullptr;
|
||||||
|
uint32_t m_frameHasDraw = 0;
|
||||||
|
uint32_t m_clearMask = 0;
|
||||||
|
uint32_t m_clearColor = 0;
|
||||||
|
void* m_fallbackTexture = nullptr;
|
||||||
|
void* m_fallbackSampler = nullptr;
|
||||||
|
void* m_depthTexture = nullptr;
|
||||||
|
uint32_t m_depthWidth = 0;
|
||||||
|
uint32_t m_depthHeight = 0;
|
||||||
|
void* m_depthStates[2][2][4] = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
1855
src/gx/mtl/CGxDeviceMTL.mm
Normal file
1855
src/gx/mtl/CGxDeviceMTL.mm
Normal file
File diff suppressed because it is too large
Load Diff
@ -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>
|
||||||
|
|||||||
239
src/ui/Util.cpp
239
src/ui/Util.cpp
@ -1,5 +1,5 @@
|
|||||||
#include "ui/Util.hpp"
|
#include "ui/Util.hpp"
|
||||||
#include <type_traits>
|
#include "util/Lua.hpp"
|
||||||
#include <storm/String.hpp>
|
#include <storm/String.hpp>
|
||||||
|
|
||||||
const char* LanguageProcess(const char* string) {
|
const char* LanguageProcess(const char* string) {
|
||||||
@ -9,101 +9,248 @@ const char* LanguageProcess(const char* string) {
|
|||||||
|
|
||||||
int32_t StringToBlendMode(const char* string, EGxBlend& blend) {
|
int32_t StringToBlendMode(const char* string, EGxBlend& blend) {
|
||||||
struct BlendEntry {
|
struct BlendEntry {
|
||||||
EGxBlend value;
|
|
||||||
const char* string;
|
const char* string;
|
||||||
|
EGxBlend value;
|
||||||
};
|
};
|
||||||
|
|
||||||
static BlendEntry blendMap[] = {
|
static BlendEntry blendMap[] = {
|
||||||
{ GxBlend_Opaque, "DISABLE" },
|
{ "DISABLE", GxBlend_Opaque },
|
||||||
{ GxBlend_Alpha, "BLEND" },
|
{ "BLEND", GxBlend_Alpha },
|
||||||
{ GxBlend_AlphaKey, "ALPHAKEY" },
|
{ "ALPHAKEY", GxBlend_AlphaKey },
|
||||||
{ GxBlend_Add, "ADD" },
|
{ "ADD", GxBlend_Add },
|
||||||
{ GxBlend_Mod, "MOD" }
|
{ "MOD", GxBlend_Mod },
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int32_t i = 0; i < std::extent<decltype(blendMap)>::value; i++) {
|
for (const auto& entry : blendMap) {
|
||||||
if (!SStrCmpI(blendMap[i].string, string, 0x7FFFFFFFu)) {
|
if (!SStrCmpI(entry.string, string)) {
|
||||||
blend = blendMap[i].value;
|
blend = entry.value;
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t StringToBOOL(const char* string) {
|
||||||
|
return StringToBOOL(string, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
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") || !SStrCmpI(string, "disabled")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "on") || !SStrCmpI(string, "enabled")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StringToBOOL(lua_State* L, int32_t idx, int32_t def) {
|
||||||
|
switch (lua_type(L, idx)) {
|
||||||
|
case LUA_TNIL:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case LUA_TBOOLEAN:
|
||||||
|
return lua_toboolean(L, idx);
|
||||||
|
|
||||||
|
case LUA_TNUMBER:
|
||||||
|
return lua_tonumber(L, idx) != 0;
|
||||||
|
|
||||||
|
case LUA_TSTRING:
|
||||||
|
return StringToBOOL(lua_tostring(L, idx), def);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t StringToClickAction(const char* string) {
|
||||||
|
if (!string || !*string) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "LeftButtonDown")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "LeftButtonUp")) {
|
||||||
|
return 0x80000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "MiddleButtonDown")) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "MiddleButtonUp")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "RightButtonDown")) {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(string, "RightButtonUp")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO remaining buttons
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t StringToDrawLayer(const char* string, int32_t& layer) {
|
||||||
|
struct LayerEntry {
|
||||||
|
const char* string;
|
||||||
|
int32_t layer;
|
||||||
|
};
|
||||||
|
|
||||||
|
static LayerEntry layerMap[] = {
|
||||||
|
{ "BACKGROUND", DRAWLAYER_BACKGROUND },
|
||||||
|
{ "BORDER", DRAWLAYER_BACKGROUND_BORDER },
|
||||||
|
{ "ARTWORK", DRAWLAYER_ARTWORK },
|
||||||
|
{ "OVERLAY", DRAWLAYER_ARTWORK_OVERLAY },
|
||||||
|
{ "HIGHLIGHT", DRAWLAYER_HIGHLIGHT },
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto& entry : layerMap) {
|
||||||
|
if (!SStrCmpI(string, entry.string)) {
|
||||||
|
layer = entry.layer;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t StringToFramePoint(const char* string, FRAMEPOINT& point) {
|
int32_t StringToFramePoint(const char* string, FRAMEPOINT& point) {
|
||||||
struct FramePointEntry {
|
struct FramePointEntry {
|
||||||
FRAMEPOINT value;
|
|
||||||
const char* string;
|
const char* string;
|
||||||
|
FRAMEPOINT value;
|
||||||
};
|
};
|
||||||
|
|
||||||
static FramePointEntry framePointMap[] = {
|
static FramePointEntry framePointMap[] = {
|
||||||
{ FRAMEPOINT_BOTTOM, "BOTTOM" },
|
{ "BOTTOM", FRAMEPOINT_BOTTOM },
|
||||||
{ FRAMEPOINT_BOTTOMLEFT, "BOTTOMLEFT" },
|
{ "BOTTOMLEFT", FRAMEPOINT_BOTTOMLEFT },
|
||||||
{ FRAMEPOINT_BOTTOMRIGHT, "BOTTOMRIGHT" },
|
{ "BOTTOMRIGHT", FRAMEPOINT_BOTTOMRIGHT },
|
||||||
{ FRAMEPOINT_CENTER, "CENTER" },
|
{ "CENTER", FRAMEPOINT_CENTER },
|
||||||
{ FRAMEPOINT_TOP, "TOP" },
|
{ "TOP", FRAMEPOINT_TOP },
|
||||||
{ FRAMEPOINT_TOPRIGHT, "TOPRIGHT" },
|
{ "TOPRIGHT", FRAMEPOINT_TOPRIGHT },
|
||||||
{ FRAMEPOINT_TOPLEFT, "TOPLEFT" },
|
{ "TOPLEFT", FRAMEPOINT_TOPLEFT },
|
||||||
{ FRAMEPOINT_LEFT, "LEFT" },
|
{ "LEFT", FRAMEPOINT_LEFT },
|
||||||
{ FRAMEPOINT_RIGHT, "RIGHT" }
|
{ "RIGHT", FRAMEPOINT_RIGHT },
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int32_t i = 0; i < std::extent<decltype(framePointMap)>::value; i++) {
|
for (const auto& entry : framePointMap) {
|
||||||
if (!SStrCmpI(framePointMap[i].string, string, 0x7FFFFFFFu)) {
|
if (!SStrCmpI(entry.string, string)) {
|
||||||
point = framePointMap[i].value;
|
point = entry.value;
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t StringToFrameStrata(const char* string, FRAME_STRATA& strata) {
|
int32_t StringToFrameStrata(const char* string, FRAME_STRATA& strata) {
|
||||||
struct FrameStrataEntry {
|
struct FrameStrataEntry {
|
||||||
FRAME_STRATA value;
|
|
||||||
const char* string;
|
const char* string;
|
||||||
|
FRAME_STRATA value;
|
||||||
};
|
};
|
||||||
|
|
||||||
// FRAME_STRATA_WORLD is hardcoded
|
// FRAME_STRATA_WORLD is hardcoded
|
||||||
static FrameStrataEntry frameStrataMap[] = {
|
static FrameStrataEntry frameStrataMap[] = {
|
||||||
{ FRAME_STRATA_BACKGROUND, "BACKGROUND" },
|
{ "BACKGROUND", FRAME_STRATA_BACKGROUND },
|
||||||
{ FRAME_STRATA_LOW, "LOW" },
|
{ "LOW", FRAME_STRATA_LOW },
|
||||||
{ FRAME_STRATA_MEDIUM, "MEDIUM" },
|
{ "MEDIUM", FRAME_STRATA_MEDIUM },
|
||||||
{ FRAME_STRATA_HIGH, "HIGH" },
|
{ "HIGH", FRAME_STRATA_HIGH },
|
||||||
{ FRAME_STRATA_DIALOG, "DIALOG" },
|
{ "DIALOG", FRAME_STRATA_DIALOG },
|
||||||
{ FRAME_STRATA_FULLSCREEN, "FULLSCREEN" },
|
{ "FULLSCREEN", FRAME_STRATA_FULLSCREEN },
|
||||||
{ FRAME_STRATA_FULLSCREEN_DIALOG, "FULLSCREEN_DIALOG" },
|
{ "FULLSCREEN_DIALOG", FRAME_STRATA_FULLSCREEN_DIALOG },
|
||||||
{ FRAME_STRATA_TOOLTIP, "TOOLTIP" }
|
{ "TOOLTIP", FRAME_STRATA_TOOLTIP },
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int32_t i = 0; i < std::extent<decltype(frameStrataMap)>::value; i++) {
|
for (const auto& entry : frameStrataMap) {
|
||||||
if (!SStrCmpI(frameStrataMap[i].string, string, 0x7FFFFFFFu)) {
|
if (!SStrCmpI(entry.string, string)) {
|
||||||
strata = frameStrataMap[i].value;
|
strata = entry.value;
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t StringToJustify(const char* string, uint32_t& justify) {
|
||||||
|
struct JustifyEntry {
|
||||||
|
const char* string;
|
||||||
|
uint32_t value;
|
||||||
|
};
|
||||||
|
|
||||||
|
static JustifyEntry justifyMap[] = {
|
||||||
|
{ "LEFT", 0x1 },
|
||||||
|
{ "CENTER", 0x2 },
|
||||||
|
{ "RIGHT", 0x4 },
|
||||||
|
{ "TOP", 0x8 },
|
||||||
|
{ "MIDDLE", 0x10 },
|
||||||
|
{ "BOTTOM", 0x20 },
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto& entry : justifyMap) {
|
||||||
|
if (!SStrCmpI(entry.string, string)) {
|
||||||
|
justify = entry.value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t StringToOrientation(const char* string, ORIENTATION& orientation) {
|
int32_t StringToOrientation(const char* string, ORIENTATION& orientation) {
|
||||||
struct OrientationEntry {
|
struct OrientationEntry {
|
||||||
ORIENTATION value;
|
|
||||||
const char* string;
|
const char* string;
|
||||||
|
ORIENTATION value;
|
||||||
};
|
};
|
||||||
|
|
||||||
static OrientationEntry orientationMap[] = {
|
static OrientationEntry orientationMap[] = {
|
||||||
{ ORIENTATION_HORIZONTAL, "HORIZONTAL" },
|
{ "HORIZONTAL", ORIENTATION_HORIZONTAL },
|
||||||
{ ORIENTATION_VERTICAL, "VERTICAL" },
|
{ "VERTICAL", ORIENTATION_VERTICAL },
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto& entry : orientationMap) {
|
for (const auto& entry : orientationMap) {
|
||||||
if (!SStrCmpI(entry.string, string)) {
|
if (!SStrCmpI(entry.string, string)) {
|
||||||
orientation = entry.value;
|
orientation = entry.value;
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 drawlayer {
|
|
||||||
int32_t layer;
|
|
||||||
const char* string;
|
|
||||||
};
|
|
||||||
|
|
||||||
static drawlayer array_drawlayer[5] = {
|
|
||||||
{ 0, "BACKGROUND" },
|
|
||||||
{ 1, "BORDER" },
|
|
||||||
{ 2, "ARTWORK" },
|
|
||||||
{ 3, "OVERLAY" },
|
|
||||||
{ 4, "HIGHLIGHT" }
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < 5; i++) {
|
|
||||||
if (!SStrCmpI(array_drawlayer[i].string, string, 0x7FFFFFFFu)) {
|
|
||||||
layer = array_drawlayer[i].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[6] = {
|
|
||||||
{ 0x1, "LEFT" },
|
|
||||||
{ 0x2, "CENTER" },
|
|
||||||
{ 0x4, "RIGHT" },
|
|
||||||
{ 0x8, "TOP" },
|
|
||||||
{ 0x10, "MIDDLE" },
|
|
||||||
{ 0x20, "BOTTOM" }
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < 5; i++) {
|
|
||||||
if (!SStrCmpI(justifyMap[i].string, string, 0x7FFFFFFFu)) {
|
|
||||||
justify = justifyMap[i].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
|
|
||||||
@ -23,6 +23,8 @@ if(WHOA_SYSTEM_MAC)
|
|||||||
"-framework AppKit"
|
"-framework AppKit"
|
||||||
"-framework Carbon"
|
"-framework Carbon"
|
||||||
"-framework IOKit"
|
"-framework IOKit"
|
||||||
|
"-framework Metal"
|
||||||
|
"-framework QuartzCore"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user