From 9c0a77a3baadc58405049e7059e7de26894091d6 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Wed, 24 Jul 2024 06:58:55 -0600 Subject: [PATCH] Update scripts --- .vscode/launch.json | 19 ++++++++-------- .vscode/settings.json | 3 ++- src/opcodemgr.cpp | 51 +++++++++++++++++++++++++++++++++---------- tools/Debug.bat | 8 +++---- tools/Debug64.bat | 8 +++---- tools/DebugCleo.bat | 8 +++---- tools/Release.bat | 4 ++-- tools/Release64.bat | 4 ++-- tools/ReleaseCleo.bat | 4 ++-- tools/Setup.bat | 49 ++++++++++++++++++++++++++++++++++++----- 10 files changed, 112 insertions(+), 46 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 9005be3..30396da 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,15 +4,14 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ - { - "name": "Launch Game", + "name": "Launch SS", "type": "cppvsdbg", "request": "launch", - "program": "D:/Games/Bully/Bully.exe", + "program": "${env:GTA_SS_DIR}/gta_sa.exe", "args": [], "stopAtEntry": false, - "cwd": "D:/Games/Bully/", + "cwd": "${env:GTA_SS_DIR}", "environment": [], "console": "internalConsole" }, @@ -20,10 +19,10 @@ "name": "Launch SA", "type": "cppvsdbg", "request": "launch", - "program": "H:/GTA San Andreas/gta_sa.exe", + "program": "${env:GTA_SA_DIR}/gta_sa.exe", "args": [], "stopAtEntry": false, - "cwd": "H:/GTA San Andreas/", + "cwd": "${env:GTA_SA_DIR}", "environment": [], "console": "internalConsole" }, @@ -31,10 +30,10 @@ "name": "Launch VC", "type": "cppvsdbg", "request": "launch", - "program": "E:/GTA Vice City/gta-vc.exe", + "program": "${env:GTA_VC_DIR}/gta-vc.exe", "args": [], "stopAtEntry": false, - "cwd": "F:/GTASanAndreas/", + "cwd": "${env:GTA_VC_DIR}", "environment": [], "console": "internalConsole" }, @@ -42,10 +41,10 @@ "name": "Launch III", "type": "cppvsdbg", "request": "launch", - "program": "E:/GTA3/Gta3.exe", + "program": "${env:GTA_III_DIR}/Gta3.exe", "args": [], "stopAtEntry": false, - "cwd": "F:/GTASanAndreas/", + "cwd": "${env:GTA_III_DIR}", "environment": [], "console": "internalConsole" }, diff --git a/.vscode/settings.json b/.vscode/settings.json index 85f3d18..efc9c6b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -76,6 +76,7 @@ "xutility": "cpp", "*.rh": "cpp", "any": "cpp", - "deque": "cpp" + "deque": "cpp", + "stack": "cpp" } } \ No newline at end of file diff --git a/src/opcodemgr.cpp b/src/opcodemgr.cpp index fdaa958..dfd8c76 100644 --- a/src/opcodemgr.cpp +++ b/src/opcodemgr.cpp @@ -25,14 +25,51 @@ static RTN_TYPE RUNTIME_API ImGuiBegin(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); data->imgui += [=]() { bool isOpen = openFlag; - ImGui::Begin(label, &isOpen, flags); - data->SetData(label, 0, isOpen); + if (isOpen) { + ImGui::Begin(label, &isOpen, flags); + data->SetData(label, 0, isOpen); + } }; data->imgui.lastScriptCall = time(NULL); - wUpdateCompareFlag(ctx, data->GetData(label, 0, true)); + wUpdateCompareFlag(ctx, data->GetData(label, 0, false)); return RTN_CONTINUE; } +static RTN_TYPE RUNTIME_API ImGuiEnd(RUNTIME_CONTEXT ctx) { + ScriptExData* data = ScriptExData::Get(); + data->imgui += [=]() { + ImGui::End(); + }; + return RTN_CONTINUE; +} + +// static RTN_TYPE RUNTIME_API ImGuiBegin(RUNTIME_CONTEXT ctx) { +// char label[RUNTIME_STR_LEN]; + +// 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; +// ImGui::Begin(label, &isOpen, flags); +// data->SetData(label, 0, isOpen); +// }; +// data->imgui.lastScriptCall = time(NULL); +// wSetIntParam(ctx, data->GetData(label, 0, true)); +// return RTN_CONTINUE; +// } + static RTN_TYPE RUNTIME_API ImGuiButton(RUNTIME_CONTEXT ctx) { char buf[RUNTIME_STR_LEN]; ImVec2 size; @@ -205,14 +242,6 @@ static RTN_TYPE RUNTIME_API ImGuiCheckbox(RUNTIME_CONTEXT ctx) { return RTN_CONTINUE; } -static RTN_TYPE RUNTIME_API ImGuiEnd(RUNTIME_CONTEXT ctx) { - ScriptExData* data = ScriptExData::Get(); - data->imgui += [=]() { - ImGui::End(); - }; - return RTN_CONTINUE; -} - static RTN_TYPE RUNTIME_API ImGuiSameLine(RUNTIME_CONTEXT ctx) { ScriptExData* data = ScriptExData::Get(); diff --git a/tools/Debug.bat b/tools/Debug.bat index dc32a7d..776705c 100644 --- a/tools/Debug.bat +++ b/tools/Debug.bat @@ -5,7 +5,7 @@ echo -------------------------------------------------- echo[ call "tools\Setup.bat" MsBuild ImGuiRedux.sln /property:Configuration=Debug /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 "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\ImGuiReduxWin32.cleo" /Q +del "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\ImGuiReduxWin32.pdb" /Q +xcopy /s "bin\ImGuiReduxWin32.cleo" "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\" /K /D /H /Y +xcopy /s "bin\ImGuiReduxWin32.pdb" "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\" /K /D /H /Y diff --git a/tools/Debug64.bat b/tools/Debug64.bat index d6bf355..469d80d 100644 --- a/tools/Debug64.bat +++ b/tools/Debug64.bat @@ -5,7 +5,7 @@ echo -------------------------------------------------- echo[ call "tools\Setup.bat" MsBuild ImGuiRedux.sln /property:Configuration=Release /t:ImGuiRedux /property:Platform=Win64 -del %OUT_DIR%"\cleo\CLEO_PLUGINS\ImGuiReduxWin64.cleo" /Q -del %OUT_DIR%"\cleo\CLEO_PLUGINS\ImGuiReduxWin64.pdb" /Q -xcopy /s "bin\ImGuiReduxWin64.cleo" %OUT_DIR%"\cleo\CLEO_PLUGINS\" /K /D /H /Y -xcopy /s "bin\ImGuiReduxWin64.pdb" %OUT_DIR%"\cleo\CLEO_PLUGINS\" /K /D /H /Y +del "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\ImGuiReduxWin64.cleo" /Q +del "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\ImGuiReduxWin64.pdb" /Q +xcopy /s "bin\ImGuiReduxWin64.cleo" "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\" /K /D /H /Y +xcopy /s "bin\ImGuiReduxWin64.pdb" "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\" /K /D /H /Y diff --git a/tools/DebugCleo.bat b/tools/DebugCleo.bat index 9f94159..c5c9cd5 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\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 +del "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\ImGuiCleoWin32.cleo" /Q +del "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\ImGuiCleoWin32.pdb" /Q +xcopy /s "bin\ImGuiCleoWin32.cleo" "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\" /K /D /H /Y +xcopy /s "bin\ImGuiCleoWin32.pdb" "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\" /K /D /H /Y diff --git a/tools/Release.bat b/tools/Release.bat index b6c712a..5c82e12 100644 --- a/tools/Release.bat +++ b/tools/Release.bat @@ -5,5 +5,5 @@ echo -------------------------------------------------- echo[ call "tools\Setup.bat" MsBuild ImGuiRedux.sln /property:Configuration=Release /t:ImGuiRedux /property:Platform=Win32 -del %OUT_DIR%"\cleo\CLEO_PLUGINS\ImGuiReduxWin32.cleo" /Q -xcopy /s "bin\ImGuiReduxWin32.cleo" %OUT_DIR%"\cleo\CLEO_PLUGINS\" /K /D /H /Y +del "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\ImGuiReduxWin32.cleo" /Q +xcopy /s "bin\ImGuiReduxWin32.cleo" "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\" /K /D /H /Y diff --git a/tools/Release64.bat b/tools/Release64.bat index 389227d..a926dc2 100644 --- a/tools/Release64.bat +++ b/tools/Release64.bat @@ -5,5 +5,5 @@ echo -------------------------------------------------- echo[ call "tools\Setup.bat" MsBuild ImGuiRedux.sln /property:Configuration=Release /t:ImGuiRedux /property:Platform=Win64 -del %OUT_DIR%"\cleo\CLEO_PLUGINS\ImGuiReduxWin64.cleo" /Q -xcopy /s "bin\ImGuiReduxWin64.cleo" %OUT_DIR%"\cleo\CLEO_PLUGINS\" /K /D /H /Y +del "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\ImGuiReduxWin64.cleo" /Q +xcopy /s "bin\ImGuiReduxWin64.cleo" "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\" /K /D /H /Y diff --git a/tools/ReleaseCleo.bat b/tools/ReleaseCleo.bat index bdd211d..49cd68b 100644 --- a/tools/ReleaseCleo.bat +++ b/tools/ReleaseCleo.bat @@ -5,5 +5,5 @@ echo -------------------------------------------------- echo[ call "tools\Setup.bat" MsBuild ImGuiRedux.sln /property:Configuration=ReleaseCleo /t:ImGuiRedux /property:Platform=Win32 -del %OUT_DIR%"\cleo\CLEO_PLUGINS\ImGuiReduxWin32.cleo" /Q -xcopy /s "bin\ImGuiReduxWin32.cleo" %OUT_DIR%"\cleo\CLEO_PLUGINS\" /K /D /H /Y +del "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\ImGuiReduxWin32.cleo" /Q +xcopy /s "bin\ImGuiReduxWin32.cleo" "%GTA_SA_DIR%\cleo\CLEO_PLUGINS\" /K /D /H /Y diff --git a/tools/Setup.bat b/tools/Setup.bat index 74df4b2..c406e72 100644 --- a/tools/Setup.bat +++ b/tools/Setup.bat @@ -1,10 +1,47 @@ -rem Generate visual studio files and run the devcmd init @echo off +set "projectdir=%CD%" +set "PLUGIN_NAME="GrinchTrainer"" -rem Set game paths below -set "OUT_DIR="H:/GTA San Andreas"" +:find_vs_path +set "vs_path=" +for %%d in (Community Preview Professional) do ( + for /d %%e in ("C:\Program Files\Microsoft Visual Studio\2022\%%d") do ( + if exist "%%e\Common7\Tools\VsDevCmd.bat" ( + set "vs_path=%%e" + goto :check_game_path + ) + ) +) +goto :eof -cd tools +:check_game_path +if "%GTA_SA_DIR%"=="" ( + echo Error: GTA_SA_DIR environment variable is not set. +) + +if "%GTA_VC_DIR%"=="" ( + echo Error: GTA_VC_DIR environment variable is not set. +) + +if "%GTA_III_DIR%"=="" ( + echo Error: GTA_III_DIR environment variable is not set. +) + +if "%GTA_SS_DIR%"=="" ( + echo Error: GTA_SS_DIR environment variable is not set. +) +echo[ + +:vs_install_found +if not defined vs_path ( + echo Error: Visual Studio installation not found. + exit /b 1 +) + +:run_premake +cd "%projectdir%\tools" premake5.exe vs2022 -cd ../build -call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" + +:run_dev +cd "%projectdir%\build" +call %vs_path%"\Common7\Tools\VsDevCmd.bat" \ No newline at end of file