Skip to content

Commit

Permalink
Add begin/end disabled, begin/end menu
Browse files Browse the repository at this point in the history
  • Loading branch information
user-grinch committed Jun 28, 2024
1 parent 7b24470 commit d2ff94c
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion src/opcodemgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static RTN_TYPE RUNTIME_API ImGuiBegin(RUNTIME_CONTEXT ctx) {
data->SetData(label, 0, isOpen);
};
data->imgui.lastScriptCall = time(NULL);
wSetIntParam(ctx, data->GetData(label, 0, true));
wUpdateCompareFlag(ctx, data->GetData(label, 0, true));
return RTN_CONTINUE;
}

Expand Down Expand Up @@ -593,6 +593,47 @@ static RTN_TYPE RUNTIME_API ImGuiBeginMainMenuBar(RUNTIME_CONTEXT ctx) {
return RTN_CONTINUE;
}

static RTN_TYPE RUNTIME_API ImGuiBeginDisabled(RUNTIME_CONTEXT ctx) {
bool flag = wGetIntParam(ctx);

ScriptExData* data = ScriptExData::Get();
data->imgui += [=]() {
ImGui::BeginDisabled(flag);
};

return RTN_CONTINUE;
}

static RTN_TYPE RUNTIME_API ImGuiEndDisabled(RUNTIME_CONTEXT ctx) {
ScriptExData* data = ScriptExData::Get();
data->imgui += [=]() {
ImGui::EndDisabled();
};
return RTN_CONTINUE;
}

static RTN_TYPE RUNTIME_API ImGuiBeginMenu(RUNTIME_CONTEXT ctx) {
char buf[RUNTIME_STR_LEN];
wGetStringWithFrame(ctx, buf, RUNTIME_STR_LEN);
bool enabled = wGetIntParam(ctx);

ScriptExData* data = ScriptExData::Get();
data->imgui += [=]() {
bool state = ImGui::BeginMenu(buf, enabled);
data->SetData(buf, 0, state);
};
wUpdateCompareFlag(ctx, data->GetData(buf, 0, false));
return RTN_CONTINUE;
}

static RTN_TYPE RUNTIME_API ImGuiEndMenu(RUNTIME_CONTEXT ctx) {
ScriptExData* data = ScriptExData::Get();
data->imgui += [=]() {
ImGui::EndMenu();
};
return RTN_CONTINUE;
}

static RTN_TYPE RUNTIME_API ImGuiEndMainMenuBar(RUNTIME_CONTEXT ctx) {
ScriptExData* data = ScriptExData::Get();
data->imgui += [=]() {
Expand Down Expand Up @@ -1386,4 +1427,8 @@ void OpcodeMgr::RegisterCommands() {
wRegisterCommand("IMGUI_SET_MESSAGE", ImGuiSetMessage);
wRegisterCommand("IMGUI_SETCOLUMN_WIDTH", ImGuiSetColumnWidth);
wRegisterCommand("IMGUI_BEGIN_CHILDEX", ImGuiBeginChildEx);
wRegisterCommand("IMGUI_BEGIN_DISABLED", ImGuiBeginDisabled);
wRegisterCommand("IMGUI_END_DISABLED", ImGuiEndDisabled);
wRegisterCommand("IMGUI_BEGIN_MENU", ImGuiBeginMenu);
wRegisterCommand("IMGUI_END_MENU", ImGuiEndMenu);
}

0 comments on commit d2ff94c

Please sign in to comment.