Skip to content

Commit

Permalink
Add overload for opcode IMGUI_BEGIN_CHILD
Browse files Browse the repository at this point in the history
  • Loading branch information
user-grinch committed Jun 22, 2024
1 parent 7206103 commit 989e0cb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
40 changes: 37 additions & 3 deletions src/opcodemgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,24 @@ static RTN_TYPE RUNTIME_API ImGuiNewLine(RUNTIME_CONTEXT ctx) {

static RTN_TYPE RUNTIME_API ImGuiColumns(RUNTIME_CONTEXT ctx) {
int count = wGetIntParam(ctx);
count = max(count, 1);
ScriptExData* data = ScriptExData::Get();
data->imgui += [=]() {
ImGui::Columns(count, NULL, false);
};
return RTN_CONTINUE;
}

static RTN_TYPE RUNTIME_API ImGuiSetColumnWidth(RUNTIME_CONTEXT ctx) {
int idx = wGetIntParam(ctx);
float width = wGetFloatParam(ctx);
ScriptExData* data = ScriptExData::Get();
data->imgui += [=]() {
ImGui::SetColumnWidth(idx, width);
};
return RTN_CONTINUE;
}

static RTN_TYPE RUNTIME_API ImGuiNextColumn(RUNTIME_CONTEXT ctx) {
ScriptExData* data = ScriptExData::Get();
data->imgui += [=]() {
Expand Down Expand Up @@ -488,9 +499,11 @@ static RTN_TYPE RUNTIME_API ImGuiGetWindowSize(RUNTIME_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);
MONITORINFO info = {sizeof(info)};
GetMonitorInfo(MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY), &info);

wSetFloatParam(ctx, info.rcMonitor.right - info.rcMonitor.left);
wSetFloatParam(ctx, info.rcMonitor.bottom - info.rcMonitor.top);
return RTN_CONTINUE;
}

Expand Down Expand Up @@ -608,6 +621,25 @@ static RTN_TYPE RUNTIME_API ImGuiBeginChild(RUNTIME_CONTEXT ctx) {
return RTN_CONTINUE;
}

static RTN_TYPE RUNTIME_API ImGuiBeginChildEx(RUNTIME_CONTEXT ctx) {
char buf[RUNTIME_STR_LEN];
float szX = 0, szY = 0;
bool border = false;
int flags = 0;
wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN);
szX = wGetFloatParam(ctx);
szY = wGetFloatParam(ctx);
border = wGetIntParam(ctx);
flags = wGetIntParam(ctx);

ScriptExData* data = ScriptExData::Get();
data->imgui += [=]() {
ImGui::BeginChild(buf, {szX, szY}, border, flags);
};

return RTN_CONTINUE;
}

static RTN_TYPE RUNTIME_API ImGuiEndChild(RUNTIME_CONTEXT ctx) {
ScriptExData* data = ScriptExData::Get();
data->imgui += [=]() {
Expand Down Expand Up @@ -1321,4 +1353,6 @@ void OpcodeMgr::RegisterCommands() {
wRegisterCommand("IMGUI_GET_DISPLAY_SIZE", ImGuiGetDisplaySize);
wRegisterCommand("IMGUI_SET_NEXT_WINDOW_TRANSPARENCY", ImGuiSetNextWindowTransparency);
wRegisterCommand("IMGUI_SET_MESSAGE", ImGuiSetMessage);
wRegisterCommand("IMGUI_SETCOLUMN_WIDTH", ImGuiSetColumnWidth);
wRegisterCommand("IMGUI_BEGIN_CHILD", ImGuiBeginChildEx);
}
1 change: 0 additions & 1 deletion src/pch.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once
#define _CRT_SECURE_NO_WARNINGS
#define IMGUI_REDUX_VERSION 2.0f

#include "imgui.h"
#include "imgui_stdlib.h"
#include "scriptextender.hpp"
Expand Down

0 comments on commit 989e0cb

Please sign in to comment.