From 43d4af46131f492fa8accf281f7fe82f80fdc5eb Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Fri, 3 Nov 2023 15:56:45 -0700 Subject: [PATCH] Fix issues --- .vscode/c_cpp_properties.json | 3 +- include/cleo/CLEO.h | 423 +++++++++++++++++ include/cleo/cleo_sdk.h | 145 ------ lib/CLEO.lib | Bin 8062 -> 10440 bytes lib/{cleo_redux.lib => cleo_redux.lib222} | Bin src/dllmain.cpp | 57 +-- src/hook.cpp | 106 ++--- src/opcodemgr.cpp | 530 +++++++++++----------- src/pch.h | 23 - src/scriptextender.hpp | 1 - src/wrapper.hpp | 135 +++--- tools/DebugCleo.bat | 8 +- tools/premake5.lua | 5 +- 13 files changed, 855 insertions(+), 581 deletions(-) create mode 100644 include/cleo/CLEO.h delete mode 100644 include/cleo/cleo_sdk.h rename lib/{cleo_redux.lib => cleo_redux.lib222} (100%) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 80e7255..b5dee91 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -9,7 +9,8 @@ ], "defines": [ "_DEBUG", - "_DX9_SDK_INSTALLED" + "_DX9_SDK_INSTALLED", + "RUNTIME_CLEO" ], "windowsSdkVersion": "10.0.19041.0", "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe", diff --git a/include/cleo/CLEO.h b/include/cleo/CLEO.h new file mode 100644 index 0000000..9c961e7 --- /dev/null +++ b/include/cleo/CLEO.h @@ -0,0 +1,423 @@ +/* + CLEO 5 header file + Copyright (c) 2023 Alien, Deji, Junior_Djjr, Miran, Seemann + + 5.0.0-alpha.23 + Please note that new exports order or callback ids may still change in alpha builds +*/ +#pragma once + +#include + +#define CLEO_VERSION_MAIN 5 +#define CLEO_VERSION_MAJOR 0 +#define CLEO_VERSION_MINOR 0 + +#define CLEO_VERSION ((CLEO_VERSION_MAIN << 24)|(CLEO_VERSION_MAJOR << 16)|(CLEO_VERSION_MINOR << 8)) // 0x0v0v0v00 + +#define __TO_STR(x) #x +#define TO_STR(x) __TO_STR(x) +#define CLEO_VERSION_STR TO_STR(CLEO_VERSION_MAIN.CLEO_VERSION_MAJOR.CLEO_VERSION_MINOR) // "v.v.v" + +namespace CLEO +{ +// result of CLEO_GetScriptVersion +enum eCLEO_Version : DWORD +{ + CLEO_VER_3 = 0x03000000, + CLEO_VER_4_MIN = 0x04000000, + CLEO_VER_4_2 = 0x04020000, + CLEO_VER_4_3 = 0x04030000, + CLEO_VER_4_4 = 0x04040000, + CLEO_VER_4 = CLEO_VER_4_4, + CLEO_VER_CUR = CLEO_VERSION +}; + +// result of CLEO_GetGameVersion +enum eGameVersion : int +{ + GV_US10 = 0, // 1.0 us + GV_US11 = 1, // 1.01 us - not supported + GV_EU10 = 2, // 1.0 eu + GV_EU11 = 3, // 1.01 eu + GV_STEAM, + GV_TOTAL, + GV_UNK = -1 // any other +}; + +// operand types +enum eDataType : int +{ + DT_END, + DT_DWORD, // imm32 + DT_VAR, // globalVar $ + DT_LVAR, // localVar @ + DT_BYTE, // imm8 + DT_WORD, // imm16 + DT_FLOAT, // imm32f + DT_VAR_ARRAY, // globalArr $(,) + DT_LVAR_ARRAY, // localArr @(,) + DT_TEXTLABEL, // sstring '' + DT_VAR_TEXTLABEL, // globalVarSString s$ + DT_LVAR_TEXTLABEL, // localVarSString @s + DT_VAR_TEXTLABEL_ARRAY, + DT_LVAR_TEXTLABEL_ARRAY, + DT_VARLEN_STRING, // vstring "" + DT_STRING, + DT_VAR_STRING, // globalVarVString v$ + DT_LVAR_STRING, // localVarVString @v + DT_VAR_STRING_ARRAY, + DT_LVAR_STRING_ARRAY +}; +static const char* ToStr(eDataType type) +{ + switch (type) + { + case DT_END: return "VArgEnd"; break; + case DT_DWORD: return "Int32"; break; + case DT_VAR: return "GlobVar"; break; + case DT_LVAR: return "LocVar"; break; + case DT_BYTE: return "Int8"; break; + case DT_WORD: return "Int16"; break; + case DT_FLOAT: return "Float32"; break; + case DT_VAR_ARRAY: return "GlobVarArr"; break; + case DT_LVAR_ARRAY: return "LocVarArr"; break; + case DT_TEXTLABEL: return "STxt"; break; + case DT_VAR_TEXTLABEL: return "GlobVarSTxt"; break; + case DT_LVAR_TEXTLABEL: return "LocVarSTxt"; break; + case DT_VAR_TEXTLABEL_ARRAY: return "GlobVarSTxtArr"; break; + case DT_LVAR_TEXTLABEL_ARRAY: return "LocVarSTxtArr"; break; + case DT_VARLEN_STRING: return "Txt"; break; + case DT_STRING: return "LTxt"; break; + case DT_VAR_STRING: return "GlobVarLTxt"; break; + case DT_LVAR_STRING: return "LocVarLTxt"; break; + case DT_VAR_STRING_ARRAY: return "GlobVarLTxtArr"; break; + case DT_LVAR_STRING_ARRAY: return "LocVarLTxtArr"; break; + default: return "corrupted"; + } +} +static const char* ToKindStr(eDataType type) +{ + switch (type) + { + case DT_BYTE: + case DT_WORD: + case DT_DWORD: + return "int"; break; + + case DT_FLOAT: + return "float"; break; + + case DT_STRING: + case DT_TEXTLABEL: + case DT_LVAR_TEXTLABEL: + case DT_LVAR_TEXTLABEL_ARRAY: + case DT_LVAR_STRING: + case DT_LVAR_STRING_ARRAY: + case DT_VAR_TEXTLABEL: + case DT_VAR_TEXTLABEL_ARRAY: + case DT_VAR_STRING: + case DT_VAR_STRING_ARRAY: + case DT_VARLEN_STRING: + return "string"; break; + + case DT_VAR: + case DT_VAR_ARRAY: + case DT_LVAR: + case DT_LVAR_ARRAY: + return "variable"; break; + + case DT_END: + return "varArgEnd"; break; + + default: + return "corrupted"; break; + } +} + +const size_t MAX_STR_LEN = 0xff; // max length of string type parameter + +union SCRIPT_VAR +{ + DWORD dwParam; + short wParam; + WORD usParam; + BYTE ucParam; + char cParam; + bool bParam; + int nParam; + float fParam; + void* pParam; + char* pcParam; +}; + +enum eLogicalOperation : WORD +{ + NONE = 0, // just replace + + AND_2 = 1, // AND operation on results of next two conditional opcodes + AND_3, + AND_4, + AND_5, + AND_6, + AND_7, + AND_END, + + OR_2 = 21, // OR operation on results of next two conditional opcodes + OR_3, + OR_4, + OR_5, + OR_6, + OR_7, + OR_END, +}; +static eLogicalOperation& operator--(eLogicalOperation& o) +{ + if (o == eLogicalOperation::NONE) return o; // can not be decremented anymore + if (o == eLogicalOperation::OR_2) return o = eLogicalOperation::NONE; + + auto val = static_cast(o); // to number + val--; + return o = static_cast(val); +} + +// CLEO virtual path prefixes. Expandable with CLEO_ResolvePath +const char DIR_GAME[] = "root:"; // game root directory +const char DIR_USER[] = "userfiles:"; // game save directory +const char DIR_SCRIPT[] = "."; // current script directory +const char DIR_CLEO[] = "cleo:"; // game\cleo directory +const char DIR_MODULES[] = "modules:"; // game\cleo\modules directory + +// argument of CLEO_RegisterCallback +enum class eCallbackId : DWORD +{ + ScmInit1, // void WINAPI OnScmInit1(); + ScmInit2, // void WINAPI OnScmInit2(); + ScmInit3, // void WINAPI OnScmInit3(); + ScriptsLoaded, // void WINAPI OnScriptsLoaded(); + ScriptsFinalize, // void WINAPI OnScriptsFinalize(); + ScriptRegister, // void WINAPI OnScriptRegister(CRunningScript* pScript); // called after script creation + ScriptUnregister, // void WINAPI OnScriptUnregister(CRunningScript* pScript); // called before script deletion + ScriptProcess, // bool WINAPI OnScriptProcess(CRunningScript* pScript); // return false to skip this script processing + ScriptOpcodeProcess, // OpcodeResult WINAPI OnScriptOpcodeProcess(CRunningScript* pScript, DWORD opcode); // return other than OR_NONE to signal that opcode was handled in the callback + ScriptOpcodeProcessFinished, // OpcodeResult WINAPI OnScriptOpcodeProcessFinished(CRunningScript* pScript, DWORD opcode, OpcodeResult result); // return other than OR_NONE to overwrite original result + ScriptDraw, // void WINAPI OnScriptDraw(bool beforeFade); + DrawingFinished, // void WINAPI OnDrawingFinished(); // called after game rendered everything and before presenting screen buffer + Log, // void OnLog(eLogLevel level, const char* msg); +}; + +// used by CLEO_Log and Log callback +enum class eLogLevel : DWORD +{ + None, + Error, // errors and warnings + Debug, // debug mode related + Default // all +}; + +typedef int SCRIPT_HANDLE; +typedef SCRIPT_HANDLE HANDLE_ACTOR, ACTOR, HACTOR, PED, HPED, HANDLE_PED; +typedef SCRIPT_HANDLE HANDLE_CAR, CAR, HCAR, VEHICLE, HVEHICLE, HANDLE_VEHICLE; +typedef SCRIPT_HANDLE HANDLE_OBJECT, OBJECT, HOBJECT; +typedef SCRIPT_HANDLE HSTREAM; + +#pragma pack(push,1) +#ifdef __cplusplus +class CRunningScript +{ +protected: +#else +struct CRunningScript +{ +#endif + CRunningScript* Next; // 0x00 next script in queue + CRunningScript* Previous; // 0x04 previous script in queue + char Name[8]; // 0x08 name of script, given by 03A4 opcode + void* BaseIP; // 0x10 pointer to begin of script in memory + BYTE* CurrentIP; // 0x14 current instruction pointer + BYTE* Stack[8]; // 0x18 return stack for 0050, 0051 + WORD SP; // 0x38 current item in stack + BYTE _pad3A[2]; // 0x3A padding + SCRIPT_VAR LocalVar[32]; // 0x3C script's local variables + DWORD Timers[2]; // 0xBC script's timers + bool bIsActive; // 0xC4 is script active + bool bCondResult; // 0xC5 condition result + bool bUseMissionCleanup; // 0xC6 clean mission + bool bIsExternal; // 0xC7 is thread external (from script.img) + bool bTextBlockOverride; // 0xC8 + BYTE bExternalType; // 0xC9 + BYTE _padCA[2]; // 0xCA padding + DWORD WakeTime; // 0xCC time, when script starts again after 0001 opcode + eLogicalOperation LogicalOp;// 0xD0 opcode 00D6 parameter + bool NotFlag; // 0xD2 opcode & 0x8000 != 0 + bool bWastedBustedCheck; // 0xD3 wasted_or_busted check flag + bool bWastedOrBusted; // 0xD4 is player wasted or busted + char _padD5[3]; // 0xD5 padding + void* SceneSkipIP; // 0xD8 scene skip label ptr + bool bIsMission; // 0xDC is this script mission + WORD ScmFunction; // 0xDD CLEO's previous scmFunction id + bool bIsCustom; // 0xDF is this CLEO script + +#ifdef __cplusplus +public: + CRunningScript() + { + strcpy(Name, "noname"); + BaseIP = 0; + Previous = 0; + Next = 0; + CurrentIP = 0; + memset(Stack, 0, sizeof(Stack)); + SP = 0; + WakeTime = 0; + bIsActive = 0; + bCondResult = 0; + bUseMissionCleanup = 0; + bIsExternal = 0; + bTextBlockOverride = 0; + bExternalType = -1; + memset(LocalVar, 0, sizeof(LocalVar)); + LogicalOp = eLogicalOperation::NONE; + NotFlag = 0; + bWastedBustedCheck = 1; + bWastedOrBusted = 0; + SceneSkipIP = 0; + bIsMission = 0; + ScmFunction = 0; + bIsCustom = 0; + } + + bool IsActive() const { return bIsActive; } + bool IsExternal() const { return bIsExternal; } + bool IsMission() const { return bIsMission; } + bool IsCustom() const { return bIsCustom; } // is this CLEO Script? + const char* GetName() const { return Name; } + BYTE* GetBasePointer() const { return (BYTE*)BaseIP; } + BYTE* GetBytePointer() const { return CurrentIP; } + void SetIp(void* ip) { CurrentIP = (BYTE*)ip; } + void SetBaseIp(void* ip) { BaseIP = ip; } + CRunningScript* GetNext() const { return Next; } + CRunningScript* GetPrev() const { return Previous; } + void SetIsExternal(bool b) { bIsExternal = b; } + void SetActive(bool b) { bIsActive = b; } + void SetNext(CRunningScript* v) { Next = v; } + void SetPrev(CRunningScript* v) { Previous = v; } + SCRIPT_VAR* GetVarPtr() { return LocalVar; } + SCRIPT_VAR* GetVarPtr(int i) { return &LocalVar[i]; } + int* GetIntVarPtr(int i) { return (int*)&LocalVar[i].dwParam; } + int GetIntVar(int i) const { return LocalVar[i].dwParam; } + void SetIntVar(int i, int v) { LocalVar[i].dwParam = v; } + void SetFloatVar(int i, float v) { LocalVar[i].fParam = v; } + char GetByteVar(int i) const { return LocalVar[i].bParam; } + bool GetConditionResult() const { return bCondResult != 0; } + bool GetNotFlag() const { return NotFlag; } + void SetNotFlag(bool state) { NotFlag = state; } + + char ReadDataType() { return ReadDataByte(); } + short ReadDataVarIndex() { return ReadDataWord(); } + short ReadDataArrayOffset() { return ReadDataWord(); } + short ReadDataArrayIndex() { return ReadDataWord(); } + short ReadDataArraySize() { return ReadDataByte(); } + short ReadDataArrayFlags() { return ReadDataByte(); } + + void IncPtr(int n = 1) { CurrentIP += n; } + int ReadDataByte() { char b = *CurrentIP; ++CurrentIP; return b; } + short ReadDataWord() { short v = *(short*)CurrentIP; CurrentIP += 2; return v; } + int ReadDataInt() { int i = *(int*)CurrentIP; CurrentIP += 4; return i; } + + void PushStack(BYTE* ptr) { Stack[SP++] = ptr; } + BYTE* PopStack() { return Stack[--SP]; } + + WORD GetScmFunction() const { return ScmFunction; } + void SetScmFunction(WORD id) { ScmFunction = id; } + +#endif // __cplusplus +}; +#pragma pack(pop) +static_assert(sizeof(CRunningScript) == 0xE0, "Invalid size of CRunningScript!"); + +// alias for legacy use +#ifdef __cplusplus + typedef class CRunningScript CScriptThread; +#else + typedef struct CRunningScript CScriptThread; +#endif + +enum OpcodeResult : char +{ + OR_NONE = -2, + OR_ERROR = -1, + OR_CONTINUE = 0, + OR_INTERRUPT = 1, +}; + +typedef OpcodeResult (CALLBACK* _pOpcodeHandler)(CRunningScript*); +typedef void(*FuncScriptDeleteDelegateT) (CRunningScript*); + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +DWORD WINAPI CLEO_GetVersion(); +eGameVersion WINAPI CLEO_GetGameVersion(); + +BOOL WINAPI CLEO_RegisterOpcode(WORD opcode, _pOpcodeHandler callback); +void WINAPI CLEO_RegisterCallback(eCallbackId id, void* func); + + +// script utils +void WINAPI CLEO_GetScriptInfoStr(CRunningScript* thread, bool currLineInfo, char* buf, DWORD bufSize); // short text for displaying in error\log messages +eCLEO_Version WINAPI CLEO_GetScriptVersion(const CRunningScript* thread); // compatibility mode + +void WINAPI CLEO_SetThreadCondResult(CRunningScript* thread, BOOL result); +void WINAPI CLEO_ThreadJumpAtLabelPtr(CRunningScript* thread, int labelPtr); + +eDataType WINAPI CLEO_GetOperandType(const CRunningScript* thread); // peek parameter data type +DWORD WINAPI CLEO_GetVarArgCount(CRunningScript* thread); // peek remaining var-args count + +extern SCRIPT_VAR* opcodeParams; +extern SCRIPT_VAR* missionLocals; + +// param read +SCRIPT_VAR* WINAPI CLEO_GetPointerToScriptVariable(CRunningScript* thread); // get pointer to the variable data. Advances script to next param +void WINAPI CLEO_RetrieveOpcodeParams(CRunningScript* thread, int count); // read multiple params. Stored in opcodeParams array +DWORD WINAPI CLEO_GetIntOpcodeParam(CRunningScript* thread); +float WINAPI CLEO_GetFloatOpcodeParam(CRunningScript* thread); +LPSTR WINAPI CLEO_ReadStringOpcodeParam(CRunningScript* thread, char* buf = nullptr, int bufSize = 0); +LPSTR WINAPI CLEO_ReadStringPointerOpcodeParam(CRunningScript* thread, char* buf = nullptr, int bufSize = 0); // exactly same as CLEO_ReadStringOpcodeParam +char* WINAPI CLEO_ReadParamsFormatted(CRunningScript* thread, const char* format, char* buf = nullptr, int bufSize = 0); // consumes all var-arg params and terminator + +// param skip without reading +void WINAPI CLEO_SkipOpcodeParams(CRunningScript* thread, int count); +void WINAPI CLEO_SkipUnusedVarArgs(CRunningScript* thread); // for var-args opcodes. Should be called even when all params were read (to skip var-arg terminator) + +// param write +void WINAPI CLEO_RecordOpcodeParams(CRunningScript* thread, int count); // write multiple params from opcodeParams array +void WINAPI CLEO_SetIntOpcodeParam(CRunningScript* thread, DWORD value); +void WINAPI CLEO_SetFloatOpcodeParam(CRunningScript* thread, float value); +void WINAPI CLEO_WriteStringOpcodeParam(CRunningScript* thread, const char* str); + + +BOOL WINAPI CLEO_GetScriptDebugMode(const CRunningScript* thread); // debug mode features enabled for this script? +void WINAPI CLEO_SetScriptDebugMode(CRunningScript* thread, BOOL enabled); + +CRunningScript* WINAPI CLEO_CreateCustomScript(CRunningScript* fromThread, const char* script_name, int label); +CRunningScript* WINAPI CLEO_GetLastCreatedCustomScript(); + +// scripts deletion callback +void WINAPI CLEO_AddScriptDeleteDelegate(FuncScriptDeleteDelegateT func); +void WINAPI CLEO_RemoveScriptDeleteDelegate(FuncScriptDeleteDelegateT func); + +DWORD WINAPI CLEO_GetScriptTextureById(CRunningScript* thread, int id); // ret RwTexture * + +HSTREAM WINAPI CLEO_GetInternalAudioStream(CRunningScript* thread, DWORD stream); // arg CAudioStream * + +void WINAPI CLEO_ResolvePath(CRunningScript* thread, char* inOutPath, DWORD pathMaxLen); // convert to absolute (file system) path + +void WINAPI CLEO_Log(eLogLevel level, const char* msg); // add message to log + +#ifdef __cplusplus +} +#endif //__cplusplus + +} // CLEO namespace diff --git a/include/cleo/cleo_sdk.h b/include/cleo/cleo_sdk.h deleted file mode 100644 index 7eaa39d..0000000 --- a/include/cleo/cleo_sdk.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - CLEO 4.4 header file; - Copyright (c) 2020 Alien, Deji, Junior_Djjr; -*/ -#pragma once - -#include - -#define CLEO_VERSION 0x04040400 -#define CLEO_VERSIONTEXT "4.4.4" - -//result of CLEO_GetGameVersion() -#define GV_US10 0 //1.0 us -#define GV_US11 1 //1.01 us - not supported -#define GV_EU10 2 //1.0 eu -#define GV_EU11 3 //1.01 eu -#define GV_UNK -1 //any other - -typedef union -{ - DWORD dwParam; - int nParam; - float fParam; - void * pParam; - char * szParam; -} SCRIPT_VAR; - -//operand types -#define globalVar 2 //$ -#define localVar 3 //@ -#define globalArr 7 //$(,) -#define localArr 8 //@(,) -#define imm8 4 //char -#define imm16 5 //short -#define imm32 1 //long, unsigned long -#define imm32f 6 //float -#define vstring 0x0E //"" -#define sstring 9 //'' -#define globalVarVString 0x10 //v$ -#define localVarVString 0x11 //@v -#define globalVarSString 0x0A //s$ -#define localVarSString 0x0B //@s - - -typedef int SCRIPT_HANDLE; -typedef SCRIPT_HANDLE HANDLE_ACTOR, ACTOR, HACTOR, PED, HPED, HANDLE_PED; -typedef SCRIPT_HANDLE HANDLE_CAR, CAR, HCAR, VEHICLE, HVEHICLE, HANDLE_VEHICLE; -typedef SCRIPT_HANDLE HANDLE_OBJECT, OBJECT, HOBJECT; -typedef SCRIPT_HANDLE HSTREAM; - -typedef struct CScriptThread CScriptThread; - -#pragma pack(push,1) -struct CScriptThread -{ - CScriptThread *next; //next script in queue - CScriptThread *prev; //previous script in queue - char threadName[8]; //name of thread, given by 03A4 opcode - BYTE *baseIp; //pointer to begin of script in memory - BYTE *ip; //current index pointer - BYTE *stack[8]; //return stack for 0050, 0051 - WORD sp; //current item in stack - WORD _f3A; //padding - SCRIPT_VAR tls[34]; //thread's local variables - BYTE isActive; //is current thread active - char condResult; //condition result (true or false) - char missionCleanupFlag; //clean mission - char external; //is thread external (from script.img) - BYTE _fC8; //unknown - BYTE _fC9; //unknown - BYTE _fCA; //unknown - BYTE _fCB; //unknown - DWORD wakeTime; //time, when script starts again after 0001 opcode - WORD logicalOp; //00D6 parameter - BYTE notFlag; //opcode & 0x8000 != 0 - BYTE wbCheckEnabled; //wasted_or_busted check flag - BYTE wastedOrBusted; //is player wasted or busted - BYTE _fD5; //unknown - WORD _fD6; //unknown - DWORD sceneSkip; //scene skip label ptr - BYTE missionFlag; //is mission thread - BYTE _fDD[3]; //padding -}; -#pragma pack(pop) - -#define OR_CONTINUE 0 -#define OR_INTERRUPT 1 - -typedef int OpcodeResult; - -typedef OpcodeResult (CALLBACK* _pOpcodeHandler)(CScriptThread*); -typedef void(*FuncScriptDeleteDelegateT) (CScriptThread*); - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -DWORD WINAPI CLEO_GetVersion(); -int WINAPI CLEO_GetGameVersion(); - -BOOL WINAPI CLEO_RegisterOpcode(WORD opcode, _pOpcodeHandler callback); - -DWORD WINAPI CLEO_GetIntOpcodeParam(CScriptThread* thread); -float WINAPI CLEO_GetFloatOpcodeParam(CScriptThread* thread); - -void WINAPI CLEO_SetIntOpcodeParam(CScriptThread* thread, DWORD value); -void WINAPI CLEO_SetFloatOpcodeParam(CScriptThread* thread, float value); - -LPSTR WINAPI CLEO_ReadStringOpcodeParam(CScriptThread* thread, LPSTR buf, int size); -LPSTR WINAPI CLEO_ReadStringPointerOpcodeParam(CScriptThread* thread, LPSTR buf, int size); -void WINAPI CLEO_WriteStringOpcodeParam(CScriptThread* thread, LPCSTR str); - -void WINAPI CLEO_SetThreadCondResult(CScriptThread* thread, BOOL result); - -void WINAPI CLEO_SkipOpcodeParams(CScriptThread* thread, int count); - -void WINAPI CLEO_ThreadJumpAtLabelPtr(CScriptThread* thread, int labelPtr); - -int WINAPI CLEO_GetOperandType(CScriptThread* thread); - -extern SCRIPT_VAR *opcodeParams; - -extern SCRIPT_VAR *missionLocals; - -//intermediate data is stored in opcodeParams array -void WINAPI CLEO_RetrieveOpcodeParams(CScriptThread *thread, int count); -void WINAPI CLEO_RecordOpcodeParams(CScriptThread *thread, int count); - -SCRIPT_VAR * WINAPI CLEO_GetPointerToScriptVariable(CScriptThread *thread); - -DWORD WINAPI CLEO_GetScriptTextureById(CScriptThread* thread, int id); // ret RwTexture * - -HSTREAM WINAPI CLEO_GetInternalAudioStream(CScriptThread* thread, DWORD stream); // arg CAudioStream * - -CScriptThread* WINAPI CLEO_CreateCustomScript(CScriptThread* fromThread, const char *script_name, int label); - -CScriptThread* WINAPI CLEO_GetLastCreatedCustomScript(); - -void WINAPI CLEO_AddScriptDeleteDelegate(FuncScriptDeleteDelegateT func); - -void WINAPI CLEO_RemoveScriptDeleteDelegate(FuncScriptDeleteDelegateT func); - -#ifdef __cplusplus -} -#endif //__cplusplus diff --git a/lib/CLEO.lib b/lib/CLEO.lib index 548cf4ff6a4b4683c48055e12b028c29cd7db24e..70f64d4d1ee757c868cc6b964f167c7650369c9e 100644 GIT binary patch delta 2284 zcmbW2Urbwd6vw|8I@T5nrNy@NKc#<&n;S4B$Ov}gFixfn9A;cmS zHDNItwzI^z7neQEs4s^4q!?X77GLHP-h6|&EEAJ0nOQ=ji0AgUrME3FHu>b<^!)#w zbAI>V-d|2Fb*0)nx?0_t->4SA8-Q^WFsT7^572li%VT~r){u;O42b1t}5D6Do;R?~q z)$QpKp|vU%?i)D%R(MF9h$fO^ye~2}H5NHH8SFwh9G#vG?=8;Qy(T6{BJpGKiN4s} zOfuM^uqqX1Y=$SJv!`d~65=?Urr0)7WT#Nb$+Kxj#s?$u$aJDV7N3qJlj3-=ty2+n zNGz|COLzEOJUW{k5#xzyY$n)|QW$f_MRLdokQcl@^KNW78841nR-R2c5u3Uw4n~sa zgKh1KXhUKmmMWAfb9_}Co0~Wp8yAa?Cm&0pkg*-k<-aRZHnK#)BTB8#7!SlIirOy! zb5-5S+xAj^+XB39n?^uw0(#8ArAFW}6S4w#ZNO6}(Cr4=n|OphK)e}v#Du&+zYkbp zZt;{_*wGTR#f-K9opxZE?QS@LHTG4(K2NZ}MGI0`WJkBz;Q~89#Kx;GK+o@fR#vg| zWj0>p03rUL?*iCig$nyng+|!0A13(F3=2GPL5%>Kpn(}$I8hA;yr_W=weX`3dbm*! z0|Zp$y}bCp+@wEO2L#`4D|kDU9o`)#`c@P0?>Tyk6{C9^t0&v5jJxs^PwSePI=9Z$ zt36&*IENIrIcciWLHD(4`cZ4GlVj&|rHx8A{i$^}l-osmU)7sFR()AGkk{X9L<=hX zrsl}Ok_rp%7#?e7oxj%j50}nl`D(L!MH?D7)#^rf3$LkcB7LQfCimOurmj|b2w&*t zN($eu^ixai^TslT(?yk!-m86}Ir#mBttx>xfW9(x(kFGZDi7|=lc0a6;?8{ftll7~ zu4DUmnyvpJCkc?#pk^tZ)m!NmLulXE+QkQJbfMlwtA>wrS~i+7=Csn+jB_g5Xf*nt zES&k9N1JCC#S>J}09rR4r5Ef*--lnC@9{?P7?-FQwBu?+4_$E>$!ZxRlcT|_yS}|C z1>pTD4wAntImDZum5&bJmt6D0?J6oew{GgDdCSy+jyCxV?RHDw=$##4KsXip?62q8 zR4S<8-l1$hEkCrK{+aii7c(a>-*Fl=AEh0KG5wF_j6i0G(evH2%MYar_{zw7F8-=f z(9%Oza|4~X{&pmLpB3h|^XdE(DK6hLc@K)Mk&c)TE&aCbq#(7%Tdn!&p;U=<-f}f1 lH>{Y6dei<#ra9fwYg>{sUt2kY!q1`nwUZ7beZ}!i_zzM#dSUjkOB)wcnY6J;w9Bi{##Gxp(f*@FmU{G+7wqywu7i)(O zE-G)w4z6OUfrHYaRIy7@EETaJIEiHFP;e;-L47V4ii-z7p8LN0-uJ$D_r~w>XSGKc zY8PvT?o*Ef7y}X-kg5RbI$*4Z%rwxo#3bu57G3%08iGQdz4NalcL>QG}4Xwx*C?9oIXSSQN^ zW^AC!ngixBdzIODp8eKz^kIdK#^h7fv>o*03~WRZgNp&gp&@~!q++@Mee-X{&METC z)#Qq&%Wk9~Q}OF^l#0rB{Jgv`nX+}tl@YBdmsCR*wY;=c$KTgpghg+X3E7Usq(u)| zbSKqd@nyM|zAyXfaT(S->bvHTZ!&DWQeEscWyHzJku@NyS&i&8{ZTWmoWA>d;pc`t zwmq4(?)`hr;1N;n1@-fv%12qWPkNMs+MCW(RX(^)DSEU1gTkC5URIae#jo7d{f*L; SA}=$#JURQNyU{LxSN;OU1epE+ diff --git a/lib/cleo_redux.lib b/lib/cleo_redux.lib222 similarity index 100% rename from lib/cleo_redux.lib rename to lib/cleo_redux.lib222 diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 4ded0dc..f9222e5 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -2,8 +2,12 @@ #include #include "opcodemgr.h" #include "hook.h" -#include "injector.hpp" + +#ifdef RUNTIME_REDUX +#include "wrapper.hpp" +#else #include "MinHook.h" +#include "injector.hpp" void f_GTA_SPCheck() { std::string moduleName = "SilentPatchSA.asi"; @@ -21,8 +25,11 @@ void f_GTA_SPCheck() { return; } } +#endif void ImGuiThread(void* param) { + +#ifdef RUNTIME_CLEO /* Need SP for mouse fixes Only need for classics @@ -37,6 +44,7 @@ void ImGuiThread(void* param) { MH_CreateHook((void*)addr, f_GTA_SPCheck, &ptr); MH_EnableHook(ptr); } +#endif Sleep(5000); @@ -51,45 +59,22 @@ void ImGuiThread(void* param) { BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) { if (nReason == DLL_PROCESS_ATTACH) { +#ifdef RUNTIME_CLEO auto gvm = injector::game_version_manager(); gvm.Detect(); - + if (gvm.GetMajorVersion() == 1 && gvm.GetMinorVersion() == 0) { - if (gvm.IsIII()) { - gGameVer = eGameVer::III; - } - - if (gvm.IsVC()) { - gGameVer = eGameVer::VC; - } - - if (gvm.IsSA()) { - gGameVer = eGameVer::SA; - } + if (gvm.IsIII()) gGameVer = eGameVer::III; + if (gvm.IsVC()) gGameVer = eGameVer::VC; + if (gvm.IsSA()) gGameVer = eGameVer::SA; } - - if constexpr (gRunTime == eRunTime::Redux) { - HostId id = GetHostId(); - switch (id) { - case HostId::GTA3_UNREAL: { - gGameVer = eGameVer::III_DE; - break; - } - case HostId::VC_UNREAL: { - gGameVer = eGameVer::VC_DE; - break; - } - case HostId::SA_UNREAL: { - gGameVer = eGameVer::SA_DE; - break; - } - case HostId::BULLY: { - gGameVer = eGameVer::BullySE; - break; - } - } - } - +#else + auto id = GetHostId(); + if (id == HostId::GTA3_UNREAL) gGameVer = eGameVer::III_DE; + if (id == HostId::VC_UNREAL) gGameVer = eGameVer::VC_DE; + if (id == HostId::SA_UNREAL) gGameVer = eGameVer::SA_DE; + if (id == HostId::BULLY) gGameVer = eGameVer::BullySE; +#endif OpcodeMgr::RegisterCommands(); CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&ImGuiThread, nullptr, NULL, nullptr); } diff --git a/src/hook.cpp b/src/hook.cpp index 5d66904..9fce374 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -51,13 +51,11 @@ LRESULT Hook::hkWndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam); if (ImGui::GetIO().WantTextInput|| (gGameVer > eGameVer::SA && mouseVisible)) { - - if constexpr (gArch == eArch::Win32) { - if (gGameVer == eGameVer::SA) { - reinterpret_cast(0x53F1E0)(); // CPad::ClearKeyboardHistory - } +#ifndef _WIN64 + if (gGameVer == eGameVer::SA) { + reinterpret_cast(0x53F1E0)(); // CPad::ClearKeyboardHistory } - +#endif return 1; } @@ -77,6 +75,7 @@ void Hook::ProcessFrame(void* ptr) { // Scale the menu if game resolution changed static int height, width, RsGlobal; +#ifdef RUNTIME_CLEO if (gGameVer == eGameVer::III) { RsGlobal = 0x8F4360; width = injector::ReadMemory(RsGlobal + 4, 0); // width @@ -95,7 +94,12 @@ void Hook::ProcessFrame(void* ptr) { width = rect.right - rect.left; height = rect.bottom - rect.top; } - +#else + RECT rect; + GetWindowRect(hwnd, &rect); + width = rect.right - rect.left; + height = rect.bottom - rect.top; +#endif static ImVec2 fScreenSize = ImVec2(-1, -1); if (fScreenSize.x != width && fScreenSize.y != height) { if (gRenderer == eRenderer::Dx9) { @@ -263,55 +267,55 @@ void Hook::ProcessMouse() { Skip mouse patches on unknown host ImGui menus should be interactive on game menu */ - if (gArch == eArch::Win32) { - if (gGameVer == eGameVer::SA) { - if (ImGui::GetIO().MouseDrawCursor) { - injector::WriteMemory(0x6194A0, 0xC3, true); - injector::MakeNOP(0x541DD7, 5, true); - } else { - injector::WriteMemory(0x6194A0, 0xE9, true); - injector::WriteMemoryRaw(0x541DD7, (char*)"\xE8\xE4\xD5\xFF\xFF", 5, true); - } - - // ClearMouseStates - injector::WriteMemory(0xB73418 + 12, 0, true); // X - injector::WriteMemory(0xB73418 + 16, 0, true); // Y - - reinterpret_cast(0x541BD0)(); // CPad::ClearMouseHistory(); - reinterpret_cast(0x541DD0)(); // CPad::UpdatePads(); - } else if (gGameVer == eGameVer::VC) { - if (ImGui::GetIO().MouseDrawCursor) { - injector::WriteMemory(0x6020A0, 0xC3, true); - injector::MakeNOP(0x4AB6CA, 5, true); - } else { - injector::WriteMemory(0x6020A0, 0x53, true); - injector::WriteMemoryRaw(0x4AB6CA, (char*)"\xE8\x51\x21\x00\x00", 5, true); - } +#ifndef _WIN64 + if (gGameVer == eGameVer::SA) { + if (ImGui::GetIO().MouseDrawCursor) { + injector::WriteMemory(0x6194A0, 0xC3, true); + injector::MakeNOP(0x541DD7, 5, true); + } else { + injector::WriteMemory(0x6194A0, 0xE9, true); + injector::WriteMemoryRaw(0x541DD7, (char*)"\xE8\xE4\xD5\xFF\xFF", 5, true); + } - // ClearMouseStates - injector::WriteMemory(0x94D788 + 8, 0, true); // X - injector::WriteMemory(0x94D788 + 12, 0, true);// Y - - reinterpret_cast(0x4ADB30)(); // CPad::ClearMouseHistory(); - reinterpret_cast(0x4AB6C0)(); // CPad::UpdatePads(); - } else if (gGameVer == eGameVer::III) { - if (ImGui::GetIO().MouseDrawCursor) { - injector::WriteMemory(0x580D20, 0xC3, true); - injector::MakeNOP(0x49272F, 5, true); - } else { - injector::WriteMemory(0x580D20, 0x53, true); - injector::WriteMemoryRaw(0x49272F, (char*)"\xE8\x6C\xF5\xFF\xFF", 5, true); - } + // ClearMouseStates + injector::WriteMemory(0xB73418 + 12, 0, true); // X + injector::WriteMemory(0xB73418 + 16, 0, true); // Y - // ClearMouseStates - injector::WriteMemory(0x8809F0 + 8, 0, true); // X - injector::WriteMemory(0x8809F0 + 12, 0, true);// Y + reinterpret_cast(0x541BD0)(); // CPad::ClearMouseHistory(); + reinterpret_cast(0x541DD0)(); // CPad::UpdatePads(); + } else if (gGameVer == eGameVer::VC) { + if (ImGui::GetIO().MouseDrawCursor) { + injector::WriteMemory(0x6020A0, 0xC3, true); + injector::MakeNOP(0x4AB6CA, 5, true); + } else { + injector::WriteMemory(0x6020A0, 0x53, true); + injector::WriteMemoryRaw(0x4AB6CA, (char*)"\xE8\x51\x21\x00\x00", 5, true); + } - int pad = reinterpret_cast(0x492F60)(NULL); // CPad::GetPads(); - reinterpret_cast(0x491B50)(pad); // CPad::ClearMouseHistory(); - reinterpret_cast(0x492720)(); // CPad::UpdatePads(); + // ClearMouseStates + injector::WriteMemory(0x94D788 + 8, 0, true); // X + injector::WriteMemory(0x94D788 + 12, 0, true);// Y + + reinterpret_cast(0x4ADB30)(); // CPad::ClearMouseHistory(); + reinterpret_cast(0x4AB6C0)(); // CPad::UpdatePads(); + } else if (gGameVer == eGameVer::III) { + if (ImGui::GetIO().MouseDrawCursor) { + injector::WriteMemory(0x580D20, 0xC3, true); + injector::MakeNOP(0x49272F, 5, true); + } else { + injector::WriteMemory(0x580D20, 0x53, true); + injector::WriteMemoryRaw(0x49272F, (char*)"\xE8\x6C\xF5\xFF\xFF", 5, true); } + + // ClearMouseStates + injector::WriteMemory(0x8809F0 + 8, 0, true); // X + injector::WriteMemory(0x8809F0 + 12, 0, true);// Y + + int pad = reinterpret_cast(0x492F60)(NULL); // CPad::GetPads(); + reinterpret_cast(0x491B50)(pad); // CPad::ClearMouseHistory(); + reinterpret_cast(0x492720)(); // CPad::UpdatePads(); } +#endif curState = mouseVisible; } diff --git a/src/opcodemgr.cpp b/src/opcodemgr.cpp index 911c61d..6c9f502 100644 --- a/src/opcodemgr.cpp +++ b/src/opcodemgr.cpp @@ -4,22 +4,22 @@ #include "texturemgr.h" #include "wrapper.hpp" -static HandlerResult ImGuiBegin(Context ctx) { - char label[STR_MAX_LEN]; +static RTN_TYPE RUNTIME_API ImGuiBegin(RUNTIME_CONTEXT ctx) { + char label[RUNTIME_STR_LEN]; - wGetStringWithFrame(ctx, label, STR_MAX_LEN); - bool openFlag = static_cast(wGetIntParam(ctx)); - bool noTitleBar = static_cast(wGetIntParam(ctx)); - bool noResize = static_cast(wGetIntParam(ctx)); - bool noMove = static_cast(wGetIntParam(ctx)); - bool autoResize = static_cast(wGetIntParam(ctx)); + wGetStringWithFrame(ctx, label, RUNTIME_STR_LEN); + bool openFlag = wGetBoolParam(ctx); + bool noTitleBar = wGetBoolParam(ctx); + bool noResize = wGetBoolParam(ctx); + bool noMove = wGetBoolParam(ctx); + bool autoResize = wGetBoolParam(ctx); ImGuiWindowFlags flags = ImGuiWindowFlags_NoCollapse; if (noTitleBar) flags |= ImGuiWindowFlags_NoTitleBar; if (noResize) flags |= ImGuiWindowFlags_NoResize; if (noMove) flags |= ImGuiWindowFlags_NoMove; if (autoResize) flags |= ImGuiWindowFlags_AlwaysAutoResize; - + ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { bool isOpen = openFlag; @@ -28,14 +28,14 @@ static HandlerResult ImGuiBegin(Context ctx) { }; data->imgui.lastScriptCall = time(NULL); wSetIntParam(ctx, data->GetData(label, 0, true)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiButton(Context ctx) { - char buf[STR_MAX_LEN]; +static RTN_TYPE RUNTIME_API ImGuiButton(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; ImVec2 size; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); size.x = wGetFloatParam(ctx); size.y = wGetFloatParam(ctx); @@ -47,14 +47,14 @@ static HandlerResult ImGuiButton(Context ctx) { bool rtn = data->GetData(buf, 0, false); wUpdateCompareFlag(ctx, rtn); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiImageButton(Context ctx) { - char buf[STR_MAX_LEN]; +static RTN_TYPE RUNTIME_API ImGuiImageButton(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; ImVec2 size; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); TextureInfo *pInfo = reinterpret_cast(wGetIntParam(ctx)); size.x = wGetFloatParam(ctx); size.y = wGetFloatParam(ctx); @@ -73,10 +73,10 @@ static HandlerResult ImGuiImageButton(Context ctx) { bool rtn = data->GetData(buf, 0, false); wUpdateCompareFlag(ctx, rtn); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSetImageTintColor(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiSetImageTintColor(RUNTIME_CONTEXT ctx) { ImVec4 col; col.x = wGetFloatParam(ctx); col.y = wGetFloatParam(ctx); @@ -85,10 +85,10 @@ static HandlerResult ImGuiSetImageTintColor(Context ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui.m_ImGCol.m_fTintCol = col; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSetImageBgColor(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiSetImageBgColor(RUNTIME_CONTEXT ctx) { ImVec4 col; col.x = wGetFloatParam(ctx); col.y = wGetFloatParam(ctx); @@ -97,30 +97,30 @@ static HandlerResult ImGuiSetImageBgColor(Context ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui.m_ImGCol.m_fBgCol = col; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiLoadImage(Context ctx) { - char fullPath[STR_MAX_LEN*2], path[STR_MAX_LEN]; - wGetStringParam(ctx, path, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiLoadImage(RUNTIME_CONTEXT ctx) { + char fullPath[RUNTIME_STR_LEN*2], path[RUNTIME_STR_LEN]; + wGetStringParam(ctx, path, RUNTIME_STR_LEN); // ResolvePath(path, fullPath); wSetIntParam(ctx, reinterpret_cast(TextureMgr::LoadTextureFromPath(fullPath))); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiFreeImage(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiFreeImage(RUNTIME_CONTEXT ctx) { TextureInfo *pInfo = reinterpret_cast(wGetIntParam(ctx)); TextureMgr::FreeTexture(pInfo); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiArrowButton(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiArrowButton(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); int side = wGetIntParam(ctx); if (side < ImGuiDir_Left || side > ImGuiDir_Down) { wUpdateCompareFlag(ctx, false); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } ScriptExData* data = ScriptExData::Get(); @@ -131,14 +131,14 @@ static HandlerResult ImGuiArrowButton(Context ctx) { bool rtn = data->GetData(buf, 0, false); wUpdateCompareFlag(ctx, rtn); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiInvisibleButton(Context ctx) { - char buf[STR_MAX_LEN]; +static RTN_TYPE RUNTIME_API ImGuiInvisibleButton(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; ImVec2 size; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); size.x = wGetFloatParam(ctx); size.y = wGetFloatParam(ctx); @@ -150,16 +150,16 @@ static HandlerResult ImGuiInvisibleButton(Context ctx) { bool rtn = data->GetData(buf, 0, false); wUpdateCompareFlag(ctx, rtn); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiColorButton(Context ctx) { - char buf[STR_MAX_LEN]; +static RTN_TYPE RUNTIME_API ImGuiColorButton(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; ImVec4 rgba; ImVec2 size; // label, r, g, b, a, width, height - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); rgba.x = wGetFloatParam(ctx); rgba.y = wGetFloatParam(ctx); rgba.z = wGetFloatParam(ctx); @@ -175,13 +175,13 @@ static HandlerResult ImGuiColorButton(Context ctx) { bool rtn = data->GetData(buf, 0, false); wUpdateCompareFlag(ctx, rtn); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiCheckbox(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); - bool state = static_cast(wGetIntParam(ctx)); +static RTN_TYPE RUNTIME_API ImGuiCheckbox(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); + bool state = wGetBoolParam(ctx); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -201,85 +201,85 @@ static HandlerResult ImGuiCheckbox(Context ctx) { wSetIntParam(ctx, state); } - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiEnd(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiEnd(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::End(); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSameLine(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiSameLine(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::SameLine(); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiNewLine(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiNewLine(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += []() { ImGui::NewLine(); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiColumns(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiColumns(RUNTIME_CONTEXT ctx) { int count = wGetIntParam(ctx); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::Columns(count, NULL, false); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiNextColumn(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiNextColumn(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::NextColumn(); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSpacing(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiSpacing(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::Spacing(); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSeparator(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiSeparator(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::Separator(); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiGetFramerate(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiGetFramerate(RUNTIME_CONTEXT ctx) { wSetIntParam(ctx, ScriptExData::GetGameFPS()); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiGetVersion(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiGetVersion(RUNTIME_CONTEXT ctx) { char* buf = const_cast(ImGui::GetVersion()); unsigned char len = static_cast(strlen(buf)); wSetStringParam(ctx, buf); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiGetPluginVersion(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiGetPluginVersion(RUNTIME_CONTEXT ctx) { wSetFloatParam(ctx, IMGUI_REDUX_VERSION); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSetNextWindowPos(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiSetNextWindowPos(RUNTIME_CONTEXT ctx) { ImVec2 pos; pos.x = wGetFloatParam(ctx); pos.y = wGetFloatParam(ctx); @@ -290,10 +290,10 @@ static HandlerResult ImGuiSetNextWindowPos(Context ctx) { ImGui::SetNextWindowPos(pos, cond); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSetNextWindowTransparency(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiSetNextWindowTransparency(RUNTIME_CONTEXT ctx) { float alpha = wGetFloatParam(ctx); ScriptExData* data = ScriptExData::Get(); @@ -301,10 +301,10 @@ static HandlerResult ImGuiSetNextWindowTransparency(Context ctx) { ImGui::SetNextWindowBgAlpha(alpha); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSetWindowPos(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiSetWindowPos(RUNTIME_CONTEXT ctx) { ImVec2 pos; pos.x = wGetFloatParam(ctx); pos.y = wGetFloatParam(ctx); @@ -315,10 +315,10 @@ static HandlerResult ImGuiSetWindowPos(Context ctx) { ImGui::SetWindowPos(pos, cond); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSetNextWindowSize(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiSetNextWindowSize(RUNTIME_CONTEXT ctx) { ImVec2 size; size.x = wGetFloatParam(ctx); size.y = wGetFloatParam(ctx); @@ -329,10 +329,10 @@ static HandlerResult ImGuiSetNextWindowSize(Context ctx) { ImGui::SetNextWindowSize(size, cond); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSetWindowSize(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiSetWindowSize(RUNTIME_CONTEXT ctx) { ImVec2 size; size.x = wGetFloatParam(ctx); size.y = wGetFloatParam(ctx); @@ -343,10 +343,10 @@ static HandlerResult ImGuiSetWindowSize(Context ctx) { ImGui::SetWindowSize(size, cond); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiDummy(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiDummy(RUNTIME_CONTEXT ctx) { ImVec2 size; size.x = wGetFloatParam(ctx); size.y = wGetFloatParam(ctx); @@ -356,23 +356,23 @@ static HandlerResult ImGuiDummy(Context ctx) { ImGui::Dummy(size); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiText(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringParam(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiText(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringParam(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::TextUnformatted(buf); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiTextCentered(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringParam(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiTextCentered(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringParam(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -382,45 +382,45 @@ static HandlerResult ImGuiTextCentered(Context ctx) { ImGui::SameLine(width/2); ImGui::TextUnformatted(buf); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiTextDisabled(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringParam(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiTextDisabled(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringParam(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::TextDisabled(buf); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiTextWrapped(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringParam(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiTextWrapped(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringParam(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::TextWrapped(buf); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiBulletText(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringParam(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiBulletText(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringParam(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::BulletText(buf); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiTextColored(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringParam(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiTextColored(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringParam(ctx, buf, RUNTIME_STR_LEN); ImVec4 col; col.x = wGetFloatParam(ctx); col.y = wGetFloatParam(ctx); @@ -431,22 +431,22 @@ static HandlerResult ImGuiTextColored(Context ctx) { data->imgui += [=]() { ImGui::TextColored(col, buf); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSetTooltip(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringParam(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiSetTooltip(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringParam(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::SetTooltip(buf); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSetCursorVisible(Context ctx) { - bool flag = static_cast(wGetIntParam(ctx)); +static RTN_TYPE RUNTIME_API ImGuiSetCursorVisible(RUNTIME_CONTEXT ctx) { + bool flag = wGetBoolParam(ctx); // Only update if cursor needs to be shown // Hidden by default @@ -457,21 +457,21 @@ static HandlerResult ImGuiSetCursorVisible(Context ctx) { }; } - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiGetFrameHeight(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiGetFrameHeight(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { data->SetData("__frameHeight__", 0, ImGui::GetFrameHeight()); }; wSetFloatParam(ctx, data->GetData("__frameHeight__", 0, 0.0f)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiGetWindowSize(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiGetWindowSize(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -483,20 +483,20 @@ static HandlerResult ImGuiGetWindowSize(Context ctx) { ImVec2 size = { data->GetData(buf, 0, 0.0f), data->GetData(buf, 1, 0.0f) }; wSetFloatParam(ctx, size.x); wSetFloatParam(ctx, size.y); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiGetDisplaySize(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiGetDisplaySize(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); ImVec2 size = ImGui::GetIO().DisplaySize; wSetFloatParam(ctx, size.x); wSetFloatParam(ctx, size.y); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiGetWindowPos(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiGetWindowPos(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -508,12 +508,12 @@ static HandlerResult ImGuiGetWindowPos(Context ctx) { ImVec2 pos = { data->GetData(buf, 0, 0.0f), data->GetData(buf, 1, 0.0f) }; wSetFloatParam(ctx, pos.x); wSetFloatParam(ctx, pos.y); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiCalcTextSize(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiCalcTextSize(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -525,12 +525,12 @@ static HandlerResult ImGuiCalcTextSize(Context ctx) { ImVec2 size = { data->GetData(buf, 0, 0.0f), data->GetData(buf, 1, 0.0f) }; wSetFloatParam(ctx, size.x); wSetFloatParam(ctx, size.y); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiGetWindowContentRegionWidth(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiGetWindowContentRegionWidth(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -539,12 +539,12 @@ static HandlerResult ImGuiGetWindowContentRegionWidth(Context ctx) { }; wSetFloatParam(ctx, data->GetData(buf, 0, 0.0f)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiBeginMainMenuBar(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiBeginMainMenuBar(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -553,23 +553,23 @@ static HandlerResult ImGuiBeginMainMenuBar(Context ctx) { }; wSetIntParam(ctx, data->GetData(buf, 0, false)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiEndMainMenuBar(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiEndMainMenuBar(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::EndMainMenuBar(); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiMenuItem(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); - bool selected = static_cast(wGetIntParam(ctx)); - bool enabled = static_cast(wGetIntParam(ctx)); +static RTN_TYPE RUNTIME_API ImGuiMenuItem(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); + bool selected = wGetBoolParam(ctx); + bool enabled = wGetBoolParam(ctx); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -578,13 +578,13 @@ static HandlerResult ImGuiMenuItem(Context ctx) { }; wSetIntParam(ctx, data->GetData(buf, 0, false)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSelectable(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); - bool selected = static_cast(wGetIntParam(ctx)); +static RTN_TYPE RUNTIME_API ImGuiSelectable(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); + bool selected = wGetBoolParam(ctx); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -593,32 +593,32 @@ static HandlerResult ImGuiSelectable(Context ctx) { }; wSetIntParam(ctx, data->GetData(buf, 0, false)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiBeginChild(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiBeginChild(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::BeginChild(buf); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiEndChild(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiEndChild(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::EndChild(); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiPushItemWidth(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiPushItemWidth(RUNTIME_CONTEXT ctx) { float width = wGetFloatParam(ctx); ScriptExData* data = ScriptExData::Get(); @@ -626,21 +626,21 @@ static HandlerResult ImGuiPushItemWidth(Context ctx) { ImGui::PushItemWidth(width); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiPopItemWidth(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiPopItemWidth(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::PopItemWidth(); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiCollapsingHeader(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiCollapsingHeader(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -649,45 +649,45 @@ static HandlerResult ImGuiCollapsingHeader(Context ctx) { }; wSetIntParam(ctx, data->GetData(buf, 0, false)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSetWidgetInt(Context ctx) { - char id[STR_MAX_LEN]; - wGetStringWithFrame(ctx, id, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiSetWidgetInt(RUNTIME_CONTEXT ctx) { + char id[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, id, RUNTIME_STR_LEN); int val = wGetIntParam(ctx); ScriptExData* data = ScriptExData::Get(); data->SetData(id, 0, val); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSetWidgetFloat(Context ctx) { - char id[STR_MAX_LEN]; - wGetStringWithFrame(ctx, id, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiSetWidgetFloat(RUNTIME_CONTEXT ctx) { + char id[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, id, RUNTIME_STR_LEN); float val = wGetFloatParam(ctx); ScriptExData* data = ScriptExData::Get(); data->SetData(id, 0, val); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSetWidgetText(Context ctx) { - char id[STR_MAX_LEN], text[STR_MAX_LEN]; - wGetStringWithFrame(ctx, id, STR_MAX_LEN); - wGetStringWithFrame(ctx, text, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiSetWidgetText(RUNTIME_CONTEXT ctx) { + char id[RUNTIME_STR_LEN], text[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, id, RUNTIME_STR_LEN); + wGetStringWithFrame(ctx, text, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->SetData(id, 0, text); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSliderInt(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiSliderInt(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); int initVal = wGetIntParam(ctx); int min = wGetIntParam(ctx); int max = wGetIntParam(ctx); @@ -701,12 +701,12 @@ static HandlerResult ImGuiSliderInt(Context ctx) { int value = data->GetData(buf, 0, initVal); wSetIntParam(ctx, value); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSliderFloat(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiSliderFloat(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); float initVal = wGetFloatParam(ctx); float min = wGetFloatParam(ctx); float max = wGetFloatParam(ctx); @@ -720,12 +720,12 @@ static HandlerResult ImGuiSliderFloat(Context ctx) { float value = data->GetData(buf, 0, initVal); wSetFloatParam(ctx, value); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiInputFloat(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiInputFloat(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); float initVal = wGetFloatParam(ctx); float min = wGetFloatParam(ctx); float max = wGetFloatParam(ctx); @@ -748,12 +748,12 @@ static HandlerResult ImGuiInputFloat(Context ctx) { float value = data->GetData(buf, 0, initVal); wSetFloatParam(ctx, value); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiInputInt(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiInputInt(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); int initVal = wGetIntParam(ctx); int min = wGetIntParam(ctx); int max = wGetIntParam(ctx); @@ -776,12 +776,12 @@ static HandlerResult ImGuiInputInt(Context ctx) { int value = data->GetData(buf, 0, initVal); wSetIntParam(ctx, value); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiInputText(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiInputText(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -793,12 +793,12 @@ static HandlerResult ImGuiInputText(Context ctx) { std::string value = data->GetData(buf, 0, std::string("")); wSetStringParam(ctx, static_cast(&value[0])); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiColorPicker(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiColorPicker(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -825,12 +825,12 @@ static HandlerResult ImGuiColorPicker(Context ctx) { wSetIntParam(ctx, g); wSetIntParam(ctx, b); wSetIntParam(ctx, a); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiRadioButton(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiRadioButton(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); int curSelectedBtn = wGetIntParam(ctx); int btnNo = wGetIntParam(ctx); @@ -856,29 +856,29 @@ static HandlerResult ImGuiRadioButton(Context ctx) { } else { wSetIntParam(ctx, curSelectedBtn); } - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiBeginFrame(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiBeginFrame(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData::SetCurrentScript(std::string(buf)); ScriptExData *data = ScriptExData::Get(); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiEndFrame(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiEndFrame(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui.m_bRender = true; ScriptExData::SetCurrentScript(""); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiCombo(Context ctx) { - char buf[STR_MAX_LEN], options[256]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiCombo(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN], options[256]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); // fill for (unsigned i = 0; i < 255; ++i) { options[i] = '\0'; @@ -914,12 +914,12 @@ static HandlerResult ImGuiCombo(Context ctx) { } else { wSetIntParam(ctx, selectedOption); } - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiIsItemActive(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiIsItemActive(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -927,12 +927,12 @@ static HandlerResult ImGuiIsItemActive(Context ctx) { }; wSetIntParam(ctx, data->GetData(buf, 0, false)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiIsItemHovered(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiIsItemHovered(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -941,12 +941,12 @@ static HandlerResult ImGuiIsItemHovered(Context ctx) { wSetIntParam(ctx, data->GetData(buf, 0, false)); wUpdateCompareFlag(ctx, data->GetData(buf, 0, 0)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiIsItemClicked(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiIsItemClicked(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -954,12 +954,12 @@ static HandlerResult ImGuiIsItemClicked(Context ctx) { }; wSetIntParam(ctx, data->GetData(buf, 0, false)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiIsItemFocused(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiIsItemFocused(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -967,26 +967,26 @@ static HandlerResult ImGuiIsItemFocused(Context ctx) { }; wSetIntParam(ctx, data->GetData(buf, 0, false)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiBullet(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiBullet(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::Bullet(); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiSetMessage(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiSetMessage(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); // Remove everything after # // Also split the text if longer than window width float windowWidth = ImGui::GetIO().DisplaySize.x / 5.0f; const char* _start = buf; - for (size_t i = 0; i < STR_MAX_LEN; ++i) { + for (size_t i = 0; i < RUNTIME_STR_LEN; ++i) { if (buf[i] == '\0') break; if (buf[i] == '#') { @@ -1008,12 +1008,12 @@ static HandlerResult ImGuiSetMessage(Context ctx) { } NotifiyPopup::AddToQueue(std::string(buf)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiGetScalingSize(Context ctx) { - char buf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiGetScalingSize(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); int count = wGetIntParam(ctx); int spacing = wGetIntParam(ctx); @@ -1045,20 +1045,20 @@ static HandlerResult ImGuiGetScalingSize(Context ctx) { wSetFloatParam(ctx, data->GetData(buf, 0, 10.0f)); wSetFloatParam(ctx, data->GetData(buf, 1, 10.0f)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiPushStyleVar(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiPushStyleVar(RUNTIME_CONTEXT ctx) { int idx = wGetIntParam(ctx); float val = wGetFloatParam(ctx); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::PushStyleVar(idx, val); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiPushStyleVar2(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiPushStyleVar2(RUNTIME_CONTEXT ctx) { int idx = wGetIntParam(ctx); float x = wGetFloatParam(ctx); float y = wGetFloatParam(ctx); @@ -1066,19 +1066,19 @@ static HandlerResult ImGuiPushStyleVar2(Context ctx) { data->imgui += [=]() { ImGui::PushStyleVar(idx, ImVec2(x, y)); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiPopStyleVar(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiPopStyleVar(RUNTIME_CONTEXT ctx) { int count = wGetIntParam(ctx); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::PopStyleVar(count); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiPushStyleColor(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiPushStyleColor(RUNTIME_CONTEXT ctx) { int idx = wGetIntParam(ctx); int r = wGetIntParam(ctx); int g = wGetIntParam(ctx); @@ -1089,19 +1089,19 @@ static HandlerResult ImGuiPushStyleColor(Context ctx) { data->imgui += [=]() { ImGui::PushStyleColor(idx, IM_COL32(r, g, b, a)); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiPopStyleColor(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiPopStyleColor(RUNTIME_CONTEXT ctx) { int count = wGetIntParam(ctx); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImGui::PopStyleColor(count); }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiGetWindowDrawList(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiGetWindowDrawList(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImDrawList *drawList = ImGui::GetWindowDrawList(); @@ -1109,10 +1109,10 @@ static HandlerResult ImGuiGetWindowDrawList(Context ctx) { }; wSetIntParam(ctx, data->GetData("__WindowDrawlist__", 0, 0)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiGetBackgroundDrawList(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiGetBackgroundDrawList(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImDrawList *drawList = ImGui::GetBackgroundDrawList(); @@ -1120,10 +1120,10 @@ static HandlerResult ImGuiGetBackgroundDrawList(Context ctx) { }; wSetIntParam(ctx, data->GetData("__BackgroundDrawlist__", 0, 0)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiGetForegroundDrawList(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiGetForegroundDrawList(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { ImDrawList *drawList = ImGui::GetForegroundDrawList(); @@ -1131,10 +1131,10 @@ static HandlerResult ImGuiGetForegroundDrawList(Context ctx) { }; wSetIntParam(ctx, data->GetData("__ForegroundDrawlist__", 0, 0)); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiDrawListAddText(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiDrawListAddText(RUNTIME_CONTEXT ctx) { ImVec2 pos; ImVec4 col; ImDrawList *pDrawList = reinterpret_cast(wGetIntParam(ctx)); @@ -1146,8 +1146,8 @@ static HandlerResult ImGuiDrawListAddText(Context ctx) { col.z = wGetIntParam(ctx) / 255.0f; col.w = wGetIntParam(ctx) / 255.0f; - char text[STR_MAX_LEN]; - wGetStringWithFrame(ctx, text, STR_MAX_LEN); + char text[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, text, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { @@ -1156,10 +1156,10 @@ static HandlerResult ImGuiDrawListAddText(Context ctx) { } }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiDrawListAddLine(Context ctx) { +static RTN_TYPE RUNTIME_API ImGuiDrawListAddLine(RUNTIME_CONTEXT ctx) { ImVec2 p1, p2; ImVec4 col; ImDrawList *pDrawList = reinterpret_cast(wGetIntParam(ctx)); @@ -1182,14 +1182,14 @@ static HandlerResult ImGuiDrawListAddLine(Context ctx) { } }; - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } -static HandlerResult ImGuiTabs(Context ctx) { - char buf[STR_MAX_LEN], itemsBuf[STR_MAX_LEN]; - wGetStringWithFrame(ctx, buf, STR_MAX_LEN); +static RTN_TYPE RUNTIME_API ImGuiTabs(RUNTIME_CONTEXT ctx) { + char buf[RUNTIME_STR_LEN], itemsBuf[RUNTIME_STR_LEN]; + wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN); ScriptExData* data = ScriptExData::Get(); - wGetStringParam(ctx, itemsBuf, STR_MAX_LEN); + wGetStringParam(ctx, itemsBuf, RUNTIME_STR_LEN); std::vector items; std::string temp; @@ -1220,7 +1220,7 @@ static HandlerResult ImGuiTabs(Context ctx) { int val = data->GetData(buf, 0, 0); wSetIntParam(ctx, val); - return HandlerResult::CONTINUE; + return RTN_CONTINUE; } void OpcodeMgr::RegisterCommands() { diff --git a/src/pch.h b/src/pch.h index 39fe0d7..c431e87 100644 --- a/src/pch.h +++ b/src/pch.h @@ -28,29 +28,6 @@ enum class eGameVer { Unknown }; -enum class eRunTime { - Cleo, - Redux, -}; - -enum class eArch { - Win32, - Win64, -}; - extern eRenderer gRenderer; extern eGameVer gGameVer; - -#ifdef RUNTIME_CLEO -constexpr eRunTime gRunTime = eRunTime::Cleo; -#else // RUNTIME_REDUX -constexpr eRunTime gRunTime = eRunTime::Redux; -#endif - -#ifdef _WIN64 -constexpr eArch gArch = eArch::Win64; -#else // RUNTIME_REDUX -constexpr eArch gArch = eArch::Win32; -#endif - extern void* gD3DDevice; diff --git a/src/scriptextender.hpp b/src/scriptextender.hpp index 75b7b44..28b2e67 100644 --- a/src/scriptextender.hpp +++ b/src/scriptextender.hpp @@ -1,7 +1,6 @@ #pragma once #include #include -#include "cleo_redux_sdk.h" #include "table.hpp" #include "hook.h" #include diff --git a/src/wrapper.hpp b/src/wrapper.hpp index 2d4c166..14f351f 100644 --- a/src/wrapper.hpp +++ b/src/wrapper.hpp @@ -1,81 +1,108 @@ #pragma once -#include "../cleo/cleo_redux_sdk.h" -#include "../cleo/cleo_sdk.h" +#include "pch.h" -static void wGetStringParam(Context ctx, char* label, unsigned char length) { - if constexpr (gRunTime == eRunTime::Cleo) { - CLEO_ReadStringOpcodeParam(reinterpret_cast(ctx), label, length); - } else { - GetStringParam(ctx, label, length); - } +#ifdef RUNTIME_CLEO +#include "../include/cleo/CLEO.h" +#define RTN_CONTINUE CLEO::OR_CONTINUE +#define RTN_TYPE CLEO::OpcodeResult +#define RUNTIME_API WINAPI +#define RUNTIME_CONTEXT CLEO::CRunningScript* +#define CMD_DEF CLEO::_pOpcodeHandler +#define INT int +#else +#include "../include/cleo/cleo_redux_sdk.h" +#define RTN_CONTINUE HandlerResult::CONTINUE +#define RTN_TYPE HandlerResult +#define RUNTIME_API +#define RUNTIME_CONTEXT Context +#define CMD_DEF CommandHandler +#define INT isize +#endif + +#define RUNTIME_STR_LEN 128 + + +static void wGetStringParam(RUNTIME_CONTEXT ctx, char* label, unsigned char length) { +#ifdef RUNTIME_CLEO + CLEO_ReadStringOpcodeParam(reinterpret_cast(ctx), label, length); +#else + GetStringParam(ctx, label, length); +#endif } /* Appending BeginFrame uniqueID to widget names This ensures scripts won't clash with each other */ -static void wGetStringWithFrame(Context ctx, char* label, unsigned char length) { +static void wGetStringWithFrame(RUNTIME_CONTEXT ctx, char* label, unsigned char length) { wGetStringParam(ctx, label, length); strcat(label, "##"); strcat(label, ScriptExData::GetCurrentScript().c_str()); } -static void wSetIntParam(Context ctx, isize value) { - if constexpr (gRunTime == eRunTime::Cleo) { - CLEO_SetIntOpcodeParam(reinterpret_cast(ctx), value); - } else { - SetIntParam(ctx, value); - } +static void wSetIntParam(RUNTIME_CONTEXT ctx, INT value) { +#ifdef RUNTIME_CLEO + CLEO_SetIntOpcodeParam(reinterpret_cast(ctx), value); +#else + SetIntParam(ctx, value); +#endif +} + +static void wSetFloatParam(RUNTIME_CONTEXT ctx, float value) { +#ifdef RUNTIME_CLEO + CLEO_SetFloatOpcodeParam(reinterpret_cast(ctx), value); +#else + SetFloatParam(ctx, value); +#endif } -static void wSetFloatParam(Context ctx, float value) { - if constexpr (gRunTime == eRunTime::Cleo) { - CLEO_SetFloatOpcodeParam(reinterpret_cast(ctx), value); - } else { - SetFloatParam(ctx, value); - } +static INT wGetIntParam(RUNTIME_CONTEXT ctx) { +#ifdef RUNTIME_CLEO + return CLEO_GetIntOpcodeParam(reinterpret_cast(ctx)); +#else + return GetIntParam(ctx); +#endif } -static isize wGetIntParam(Context ctx) { - if constexpr (gRunTime == eRunTime::Cleo) { - return CLEO_GetIntOpcodeParam(reinterpret_cast(ctx)); - } else { - return GetIntParam(ctx); - } - return -1; +static bool wGetBoolParam(RUNTIME_CONTEXT ctx) { +#ifdef RUNTIME_CLEO + return static_cast(CLEO_GetIntOpcodeParam(reinterpret_cast(ctx))); +#else + return static_cast(GetIntParam(ctx)); +#endif } -static float wGetFloatParam(Context ctx) { - if constexpr (gRunTime == eRunTime::Cleo) { - return CLEO_GetFloatOpcodeParam(reinterpret_cast(ctx)); - } else { - return GetFloatParam(ctx); - } +static float wGetFloatParam(RUNTIME_CONTEXT ctx) { +#ifdef RUNTIME_CLEO + return CLEO_GetFloatOpcodeParam(reinterpret_cast(ctx)); +#else + return GetFloatParam(ctx); +#endif return -1.0f; } -static void wUpdateCompareFlag(Context ctx, bool flag) { - if constexpr (gRunTime == eRunTime::Cleo) { - ((void(*)(Context, bool))0x4859D0)(ctx, flag); // CRunningScript::UpdateCompareFlag(); - } else { - UpdateCompareFlag(ctx, flag); - } +static void wUpdateCompareFlag(RUNTIME_CONTEXT ctx, bool flag) { +#ifdef RUNTIME_CLEO + ((void(*)(RUNTIME_CONTEXT, bool))0x4859D0)(ctx, flag); // CRunningScript::UpdateCompareFlag(); +#else + UpdateCompareFlag(ctx, flag); +#endif } -static void wRegisterCommand(const char *name, CommandHandler handler) { - static size_t startOpcode = 0x2100; - if constexpr (gRunTime == eRunTime::Cleo) { - CLEO_RegisterOpcode(startOpcode, reinterpret_cast<_pOpcodeHandler>(handler)); - startOpcode++; - } else { - RegisterCommand(name, handler); - } +static void wRegisterCommand(const char *name, CMD_DEF handler) { +#ifdef RUNTIME_CLEO + static size_t opcode = 0x0C00; + CLEO_RegisterOpcode(opcode, handler); + opcode++; +#else + RegisterCommand(name, handler); +#endif } -static void wSetStringParam(Context ctx, const char* buf) { - if constexpr (gRunTime == eRunTime::Cleo) { - CLEO_WriteStringOpcodeParam(reinterpret_cast(ctx), buf); - } else { - SetStringParam(ctx, buf); - } +static void wSetStringParam(RUNTIME_CONTEXT ctx, const char* buf) { +#ifdef RUNTIME_CLEO + CLEO_WriteStringOpcodeParam(reinterpret_cast(ctx), buf); +#else + SetStringParam(ctx, buf); +#endif } \ No newline at end of file diff --git a/tools/DebugCleo.bat b/tools/DebugCleo.bat index 6a5c926..9f94159 100644 --- a/tools/DebugCleo.bat +++ b/tools/DebugCleo.bat @@ -5,7 +5,7 @@ echo -------------------------------------------------- echo[ call "tools\Setup.bat" MsBuild ImGuiRedux.sln /property:Configuration=DebugCleo /t:ImGuiRedux /property:Platform=Win32 -del %OUT_DIR%"\cleo\CLEO_PLUGINS\ImGuiReduxWin32.cleo" /Q -del %OUT_DIR%"\cleo\CLEO_PLUGINS\ImGuiReduxWin32.pdb" /Q -xcopy /s "bin\ImGuiReduxWin32.cleo" %OUT_DIR%"\cleo\CLEO_PLUGINS\" /K /D /H /Y -xcopy /s "bin\ImGuiReduxWin32.pdb" %OUT_DIR%"\cleo\CLEO_PLUGINS\" /K /D /H /Y +del %OUT_DIR%"\cleo\CLEO_PLUGINS\ImGuiCleoWin32.cleo" /Q +del %OUT_DIR%"\cleo\CLEO_PLUGINS\ImGuiCleoWin32.pdb" /Q +xcopy /s "bin\ImGuiCleoWin32.cleo" %OUT_DIR%"\cleo\CLEO_PLUGINS\" /K /D /H /Y +xcopy /s "bin\ImGuiCleoWin32.pdb" %OUT_DIR%"\cleo\CLEO_PLUGINS\" /K /D /H /Y diff --git a/tools/premake5.lua b/tools/premake5.lua index 055ce87..ceda40d 100644 --- a/tools/premake5.lua +++ b/tools/premake5.lua @@ -30,7 +30,6 @@ workspace "ImGuiRedux" project "ImGuiRedux" filter { "platforms:Win32" } - targetname "ImGuiReduxWin32" architecture "x86" links { "d3d9", @@ -42,6 +41,7 @@ project "ImGuiRedux" "dxguid.lib" } filter "configurations:DebugCleo" + targetname "ImGuiCleoWin32" symbols "On" defines { "RUNTIME_CLEO" @@ -51,6 +51,7 @@ project "ImGuiRedux" } filter "configurations:ReleaseCleo" + targetname "ImGuiCleoWin32" optimize "On" defines { "NDEBUG", @@ -61,6 +62,7 @@ project "ImGuiRedux" } filter "configurations:Debug" + targetname "ImGuiReduxWin32" symbols "On" defines { "RUNTIME_REDUX" @@ -70,6 +72,7 @@ project "ImGuiRedux" } filter "configurations:Release" + targetname "ImGuiReduxWin32" optimize "On" defines { "NDEBUG",