Skip to content

Commit

Permalink
Bug fixes with ButtonImage
Browse files Browse the repository at this point in the history
  • Loading branch information
user-grinch committed Nov 22, 2023
1 parent 1c36b69 commit d6d3cf2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"name": "Launch SA",
"type": "cppvsdbg",
"request": "launch",
"program": "F:/GTA San Andreas/gta_sa.exe",
"program": "D:/Games/GTA San Andreas/gta_sa.exe",
"args": [],
"stopAtEntry": false,
"cwd": "F:/GTA San Andreas/",
"cwd": "D:/Games/GTA San Andreas/",
"environment": [],
"console": "internalConsole"
},
Expand Down
9 changes: 7 additions & 2 deletions src/opcodemgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <time.h>
#include "texturemgr.h"
#include "wrapper.hpp"
#include "imgui_internal.h"

static RTN_TYPE RUNTIME_API ImGuiBegin(RUNTIME_CONTEXT ctx) {
char label[RUNTIME_STR_LEN];
Expand Down Expand Up @@ -61,13 +62,17 @@ static RTN_TYPE RUNTIME_API ImGuiImageButton(RUNTIME_CONTEXT ctx) {

// FIX:
// Due to an issue textures aren't loaded in LoadImage but on ImageButton first call
if (pInfo && TextureMgr::Exists(pInfo)) {

if (!pInfo->pTexture && TextureMgr::Exists(pInfo)) {
TextureMgr::LoadTexture(*pInfo);
}

ScriptExData* data = ScriptExData::Get();
data->imgui += [=]() {
bool isPressed = ImGui::ImageButton(pInfo->pTexture, ImVec2(size.x, size.y), ImVec2(0, 0), ImVec2(1, 1), 0, data->imgui.m_ImGCol.m_fBgCol, data->imgui.m_ImGCol.m_fTintCol);
ImGui::PushID(buf);
const ImGuiID id = ImGui::GetID(buf);
bool isPressed = ImGui::ImageButtonEx(id, pInfo->pTexture, size, {0.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 0.0f}, data->imgui.m_ImGCol.m_fBgCol, data->imgui.m_ImGCol.m_fTintCol);
ImGui::PopID();
data->SetData(buf, 0, isPressed);
};

Expand Down
3 changes: 2 additions & 1 deletion src/texturemgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ TextureInfo* TextureMgr::LoadTextureFromPath(const char *path) {
TextureInfo info;
info.path = std::string(path);
info.pTexture = nullptr;
LoadTexture(info);
// FIX ME
// LoadTexture(info);
textureList.push_back(std::move(info));
return &textureList.back();
}
Expand Down
2 changes: 1 addition & 1 deletion tools/Setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ rem Generate visual studio files and run the devcmd init
@echo off

rem Set game paths below
set "OUT_DIR="F:/GTA San Andreas/""
set "OUT_DIR="D:/Games/GTA San Andreas/""

cd tools
premake5.exe vs2022
Expand Down

0 comments on commit d6d3cf2

Please sign in to comment.