Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 42 additions & 42 deletions RaycastEngine/module_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ void init_imgui_module(lua_State* L)
.endClass()
.beginClass<ImDrawList>("ImDrawList")
.addFunction("AddRectFilled", +[](ImDrawList* draw_list, const ImVec2& p_min, const ImVec2& p_max, ImU32 col, luabridge::LuaRef rounding, luabridge::LuaRef flags)
{ draw_list->AddRectFilled(p_min, p_max, col, rounding ? rounding : 0.0f, flags ? flags : 0); })
{ draw_list->AddRectFilled(p_min, p_max, col, rounding ? rounding : 0.0f, flags ? static_cast<int>(flags) : 0); })
.endClass()
.beginClass<ImGuiViewport>("ImGuiViewport")
.addProperty("ID", &ImGuiViewport::ID, &ImGuiViewport::ID)
Expand Down Expand Up @@ -739,47 +739,47 @@ void init_imgui_module(lua_State* L)
// window
.addFunction("GetMainViewport", ImGui::GetMainViewport)
.addFunction("SetNextWindowPos", +[](const ImVec2& pos, luabridge::LuaRef cond, luabridge::LuaRef pivot)
{ ImGui::SetNextWindowPos(pos, cond ? cond : 0, pivot ? pivot : ImVec2(0, 0)); })
{ ImGui::SetNextWindowPos(pos, cond ? static_cast<int>(cond) : 0, pivot ? pivot : ImVec2(0, 0)); })
.addFunction("SetNextWindowSize", +[](const ImVec2& pos, luabridge::LuaRef cond)
{ ImGui::SetNextWindowSize(pos, cond ? cond : 0); })
{ ImGui::SetNextWindowSize(pos, cond ? static_cast<int>(cond) : 0); })
.addFunction("SetNextWindowViewport", ImGui::SetNextWindowViewport)
.addFunction("DockSpace", +[](ImGuiID dockspace_id, luabridge::LuaRef size, luabridge::LuaRef flags)
{ ImGui::DockSpace(dockspace_id, size ? size : ImVec2(0, 0), flags ? flags : 0); })
{ ImGui::DockSpace(dockspace_id, size ? size : ImVec2(0, 0), flags ? static_cast<int>(flags) : 0); })
.addFunction("Begin", +[](const char* name, luabridge::LuaRef open, luabridge::LuaRef flags)
{ return ImGui::Begin(name, open.isNil() ? nullptr : &open.cast<Bool*>().value()->val, flags.isNil() ? 0 : flags); })
{ return ImGui::Begin(name, open.isNil() ? nullptr : &open.cast<Bool*>().value()->val, flags.isNil() ? 0 : static_cast<int>(flags)); })
.addFunction("End", ImGui::End)
.addFunction("BeginChild", +[](const char* str_id, luabridge::LuaRef size, luabridge::LuaRef child_flgas, luabridge::LuaRef window_flags)
{ return ImGui::BeginChild(str_id, size ? size : ImVec2(0, 0), child_flgas ? child_flgas : 0, window_flags ? window_flags : 0); })
{ return ImGui::BeginChild(str_id, size ? size : ImVec2(0, 0), child_flgas ? static_cast<int>(child_flgas) : 0, window_flags ? static_cast<int>(window_flags) : 0); })
.addFunction("EndChild", ImGui::EndChild)
.addFunction("BeginTooltip", ImGui::BeginTooltip)
.addFunction("EndTooltip", ImGui::EndTooltip)
.addFunction("OpenPopup", +[](const char* str_id, luabridge::LuaRef flags) { ImGui::OpenPopup(str_id, flags ? flags : 0); })
.addFunction("BeginPopup", +[](const char* str_id, luabridge::LuaRef flags) { return ImGui::BeginPopup(str_id, flags ? flags : 0); })
.addFunction("OpenPopup", +[](const char* str_id, luabridge::LuaRef flags) { ImGui::OpenPopup(str_id, flags ? static_cast<int>(flags) : 0); })
.addFunction("BeginPopup", +[](const char* str_id, luabridge::LuaRef flags) { return ImGui::BeginPopup(str_id, flags ? static_cast<int>(flags) : 0); })
.addFunction("EndPopup", ImGui::EndPopup)
.addFunction("CollapsingHeader", +[](const char* label, luabridge::LuaRef flags) { return ImGui::CollapsingHeader(label, flags ? flags : 0);})
.addFunction("CollapsingHeader", +[](const char* label, luabridge::LuaRef flags) { return ImGui::CollapsingHeader(label, flags ? static_cast<int>(flags) : 0);})
// interaction
.addFunction("IsItemHovered", +[](luabridge::LuaRef flags) { return ImGui::IsItemHovered(flags ? flags : 0); })
.addFunction("IsItemHovered", +[](luabridge::LuaRef flags) { return ImGui::IsItemHovered(flags ? static_cast<int>(flags) : 0); })
.addFunction("IsAnyItemHovered", ImGui::IsAnyItemHovered)
.addFunction("IsAnyItemActive", ImGui::IsAnyItemActive)
.addFunction("IsKeyPressed", +[](int key, luabridge::LuaRef repeat) { return ImGui::IsKeyPressed((ImGuiKey)key, repeat.isNil() ? true : repeat); })
.addFunction("IsKeyReleased", +[](int key) { return ImGui::IsKeyReleased((ImGuiKey)key); })
.addFunction("IsWindowHovered", +[](luabridge::LuaRef flags) { return ImGui::IsWindowHovered(flags ? flags : 0); })
.addFunction("IsWindowHovered", +[](luabridge::LuaRef flags) { return ImGui::IsWindowHovered(flags ? static_cast<int>(flags) : 0); })
.addFunction("BeginDisabled", +[](luabridge::LuaRef disabled, lua_State* L) { ImGui::BeginDisabled(lua_gettop(L) == 0 ? true : disabled); })
.addFunction("EndDisabled", ImGui::EndDisabled)
.addFunction("IsItemDeactivated", ImGui::IsItemDeactivated)
.addFunction("IsItemDeactivatedAfterEdit", ImGui::IsItemDeactivatedAfterEdit)
.addFunction("BeginDragDropSource", +[](luabridge::LuaRef flags) { return ImGui::BeginDragDropSource(flags ? flags : 0); })
.addFunction("BeginDragDropSource", +[](luabridge::LuaRef flags) { return ImGui::BeginDragDropSource(flags ? static_cast<int>(flags) : 0); })
.addFunction("EndDragDropSource", ImGui::EndDragDropSource)
.addFunction("BeginDragDropTarget", ImGui::BeginDragDropTarget)
.addFunction("EndDragDropTarget", ImGui::EndDragDropTarget)
.addFunction("SetDragDropPayload", +[](const char* type, luabridge::LuaRef payload, luabridge::LuaRef cond)
{
CustomPayload* custom_payload = new CustomPayload(payload);
return ImGui::SetDragDropPayload(type, &custom_payload, sizeof(CustomPayload*), cond ? cond : 0);
return ImGui::SetDragDropPayload(type, &custom_payload, sizeof(CustomPayload*), cond ? static_cast<int>(cond) : 0);
})
.addFunction("AcceptDragDropPayload", +[](const char* type, luabridge::LuaRef flags, lua_State* L)
{
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(type, flags ? flags : 0))
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(type, flags ? static_cast<int>(flags) : 0))
{
CustomPayload* custom_payload = *((CustomPayload**)payload->Data);
luabridge::LuaRef val = custom_payload->payload;
Expand Down Expand Up @@ -814,58 +814,58 @@ void init_imgui_module(lua_State* L)
{ ImGui::Image(texture, size, uv0 ? uv0 : ImVec2(0, 0), uv1 ? uv1 : ImVec2(1, 1), tint_col ? tint_col : ImVec4(1, 1, 1, 1), border_col ? border_col : ImVec4(0, 0, 0, 0)); },
+[](const Texture& texture, const ImVec2& size, luabridge::LuaRef uv0, luabridge::LuaRef uv1, luabridge::LuaRef tint_col, luabridge::LuaRef border_col)
{ ImGui::Image(texture.id, size, uv0 ? uv0 : ImVec2(0, 0), uv1 ? uv1 : ImVec2(1, 1), tint_col ? tint_col : ImVec4(1, 1, 1, 1), border_col ? border_col : ImVec4(0, 0, 0, 0)); })
.addFunction("InputText", +[](const char* label, CString* str, luabridge::LuaRef flags) { return ImGui::InputText(label, &str->val, flags ? flags : 0); })
.addFunction("InputTextMultiline", +[](const char* label, CString* str, const ImVec2& size, luabridge::LuaRef flags) { return ImGui::InputTextMultiline(label, &str->val, size, flags ? flags : 0); })
.addFunction("InputText", +[](const char* label, CString* str, luabridge::LuaRef flags) { return ImGui::InputText(label, &str->val, flags ? static_cast<int>(flags) : 0); })
.addFunction("InputTextMultiline", +[](const char* label, CString* str, const ImVec2& size, luabridge::LuaRef flags) { return ImGui::InputTextMultiline(label, &str->val, size, flags ? static_cast<int>(flags) : 0); })
.addFunction("InputFloat", +[](const char* label, Float* val, luabridge::LuaRef step, luabridge::LuaRef step_fast, luabridge::LuaRef format, luabridge::LuaRef flags)
{ return ImGui::InputFloat(label, &val->val, step ? step : 0.0f, step_fast ? step_fast : 0.0f, format ? format.cast<const char*>().value() : "%.3f", flags ? flags : 0); })
{ return ImGui::InputFloat(label, &val->val, step ? step : 0.0f, step_fast ? step_fast : 0.0f, format ? format.cast<const char*>().value() : "%.3f", flags ? static_cast<int>(flags) : 0); })
.addFunction("InputFloat2", +[](const char* label, ImVec2* val, luabridge::LuaRef format, luabridge::LuaRef flags)
{ return ImGui::InputFloat2(label, &val->x, format ? format.cast<const char*>().value() : "%.3f", flags ? flags : 0); },
{ return ImGui::InputFloat2(label, &val->x, format ? format.cast<const char*>().value() : "%.3f", flags ? static_cast<int>(flags) : 0); },
+ [](const char* label, Float* val_1, Float* val_2, luabridge::LuaRef format, luabridge::LuaRef flags)
{
float val[] = { val_1->val, val_2->val };
bool result = ImGui::InputFloat2(label, val, format ? format.cast<const char*>().value() : "%.3f", flags ? flags : 0);
bool result = ImGui::InputFloat2(label, val, format ? format.cast<const char*>().value() : "%.3f", flags ? static_cast<int>(flags) : 0);
val_1->val = val[0], val_2->val = val[1];
return result;
})
.addFunction("InputInt", +[](const char* label, Int* val, luabridge::LuaRef step, luabridge::LuaRef step_fast, luabridge::LuaRef format, luabridge::LuaRef flags)
{ return ImGui::InputInt(label, &val->val, step ? step : 1, step_fast ? step_fast : 100, flags ? flags : 0); })
.addFunction("InputInt", +[](const char* label, Int* val, luabridge::LuaRef step, luabridge::LuaRef step_fast, luabridge::LuaRef, luabridge::LuaRef flags)
{ return ImGui::InputInt(label, &val->val, step ? step : 1, step_fast ? step_fast : 100, flags ? static_cast<int>(flags) : 0); })
.addFunction("DragInt", +[](const char* label, Int* val, luabridge::LuaRef speed, luabridge::LuaRef v_min, luabridge::LuaRef v_max, luabridge::LuaRef format, luabridge::LuaRef flags)
{ return ImGui::DragInt(label, &val->val, speed ? speed : 1.0f, v_min ? v_min : 0, v_max ? v_max : 0, format ? format.cast<const char*>().value() : "%d", flags ? flags : 0); })
{ return ImGui::DragInt(label, &val->val, speed ? speed : 1.0f, v_min ? static_cast<int>(v_min) : 0, v_max ? static_cast<int>(v_max) : 0, format ? format.cast<const char*>().value() : "%d", flags ? static_cast<int>(flags) : 0); })
.addFunction("DragInt2", +[](const char* label, Int* val_1, Int* val_2, luabridge::LuaRef speed, luabridge::LuaRef v_min, luabridge::LuaRef v_max, luabridge::LuaRef format, luabridge::LuaRef flags)
{
int val[] = { val_1->val, val_2->val };
bool result = ImGui::DragInt2(label, val, speed ? speed : 1.0f, v_min.isNil() ? 0 : v_min, v_max.isNil() ? 0 : v_max,
format ? format.cast<const char*>().value() : "%d", flags ? flags : 0);
bool result = ImGui::DragInt2(label, val, speed ? speed : 1.0f, v_min.isNil() ? 0 : static_cast<int>(v_min), v_max.isNil() ? 0 : static_cast<int>(v_max),
format ? format.cast<const char*>().value() : "%d", flags ? static_cast<int>(flags) : 0);
val_1->val = val[0], val_2->val = val[1];
return result;
})
.addFunction("SliderInt", +[](const char* label, Int* val, luabridge::LuaRef v_min, luabridge::LuaRef v_max, luabridge::LuaRef format, luabridge::LuaRef flags)
{ return ImGui::SliderInt(label, &val->val, v_min ? v_min : 0, v_max ? v_max : 0, format ? format.cast<const char*>().value() : "%d", flags ? flags : 0); })
.addFunction("Selectable", +[](const char* label, bool selected, luabridge::LuaRef flags, luabridge::LuaRef size)
{ return ImGui::Selectable(label, selected, flags ? flags : 0, size ? size : ImVec2(0, 0)); })
.addFunction("BeginTabBar", +[](const char* str_id, luabridge::LuaRef flags) { return ImGui::BeginTabBar(str_id, flags ? flags : 0); })
.addFunction("SliderInt", [](const char* label, Int* val, luabridge::LuaRef v_min, luabridge::LuaRef v_max, luabridge::LuaRef format, luabridge::LuaRef flags)
{ return ImGui::SliderInt(label, &val->val, v_min ? static_cast<int>(v_min) : 0, v_max ? static_cast<int>(v_max) : 0, format ? format.cast<const char*>().value() : "%d", flags ? static_cast<int>(flags) : 0); })
.addFunction("Selectable", [](const char* label, bool selected, luabridge::LuaRef flags, luabridge::LuaRef size)
{ return ImGui::Selectable(label, selected, flags ? static_cast<int>(flags) : 0, size ? size : ImVec2(0, 0)); })
.addFunction("BeginTabBar", [](const char* str_id, luabridge::LuaRef flags) { return ImGui::BeginTabBar(str_id, flags ? static_cast<int>(flags) : 0); })
.addFunction("EndTabBar", ImGui::EndTabBar)
.addFunction("BeginTabItem", +[](const char* str_id, luabridge::LuaRef open, luabridge::LuaRef flags)
{ return ImGui::BeginTabItem(str_id, open ? &open.cast<Bool*>().value()->val : nullptr, flags ? flags : 0); })
.addFunction("BeginTabItem", [](const char* str_id, luabridge::LuaRef open, luabridge::LuaRef flags)
{ return ImGui::BeginTabItem(str_id, open ? &open.cast<Bool*>().value()->val : nullptr, flags ? static_cast<int>(flags) : 0); })
.addFunction("EndTabItem", ImGui::EndTabItem)
.addFunction("BeginMainMenuBar", ImGui::BeginMainMenuBar)
.addFunction("EndMainMenuBar", ImGui::EndMainMenuBar)
.addFunction("BeginMenuBar", ImGui::BeginMenuBar)
.addFunction("EndMenuBar", ImGui::EndMenuBar)
.addFunction("BeginMenu", +[](const char* label, luabridge::LuaRef enable) { return ImGui::BeginMenu(label, enable.isNil() ? true : enable); })
.addFunction("BeginMenu", [](const char* label, luabridge::LuaRef enable) { return ImGui::BeginMenu(label, enable.isNil() ? true : enable); })
.addFunction("EndMenu", ImGui::EndMenu)
.addFunction("MenuItem", +[](const char* label, luabridge::LuaRef shortcut, luabridge::LuaRef selected, luabridge::LuaRef enabled)
.addFunction("MenuItem", [](const char* label, luabridge::LuaRef shortcut, luabridge::LuaRef selected, luabridge::LuaRef enabled)
{ return ImGui::MenuItem(label, shortcut.isNil() ? nullptr : shortcut.cast<const char*>().value(), selected.isNil() ? false : selected, enabled.isNil() ? true : enabled); })
.addFunction("TreeNode", +[](const char* label) { return ImGui::TreeNode(label); }, +[](const char* label, int flags){ return ImGui::TreeNodeEx(label, flags); })
.addFunction("TreeNode", [](const char* label) { return ImGui::TreeNode(label); }, +[](const char* label, int flags){ return ImGui::TreeNodeEx(label, flags); })
.addFunction("TreePop", ImGui::TreePop)
.addFunction("ColorEdit4", +[](const char* label, ImColor& color, luabridge::LuaRef flags) { return ImGui::ColorEdit4(label, &color.Value.x, flags ? flags : 0); })
.addFunction("ColorPicker4", +[](const char* label, ImColor& color, luabridge::LuaRef flags) { return ImGui::ColorPicker4(label, &color.Value.x, flags ? flags : 0); })
.addFunction("ColorEdit4", [](const char* label, ImColor& color, luabridge::LuaRef flags) { return ImGui::ColorEdit4(label, &color.Value.x, flags ? static_cast<int>(flags) : 0); })
.addFunction("ColorPicker4", [](const char* label, ImColor& color, luabridge::LuaRef flags) { return ImGui::ColorPicker4(label, &color.Value.x, flags ? static_cast<int>(flags) : 0); })
// style
.addFunction("GetStyle", ImGui::GetStyle)
.addFunction("PushStyleVar", luabridge::overload<ImGuiStyleVar, float>(ImGui::PushStyleVar), luabridge::overload<ImGuiStyleVar, const ImVec2&>(ImGui::PushStyleVar))
.addFunction("PopStyleVar", +[](luabridge::LuaRef count) { ImGui::PopStyleVar(count ? count : 1); })
.addFunction("PopStyleVar", [](luabridge::LuaRef count) { ImGui::PopStyleVar(count ? count : 1); })
.addFunction("PushStyleColor", luabridge::overload<ImGuiCol, const ImVec4&>(ImGui::PushStyleColor), luabridge::overload<ImGuiCol, ImU32>(ImGui::PushStyleColor))
.addFunction("PopStyleColor", +[](luabridge::LuaRef count) { ImGui::PopStyleColor(count ? count : 1); })
.addFunction("PopStyleColor", [](luabridge::LuaRef count) { ImGui::PopStyleColor(count ? count : 1); })
.addFunction("SetNextItemWidth", ImGui::SetNextItemWidth)
.addFunction("PushTextWrapPos", ImGui::PushTextWrapPos)
.addFunction("PopTextWrapPos", ImGui::PopTextWrapPos)
Expand All @@ -877,15 +877,15 @@ void init_imgui_module(lua_State* L)
.addFunction("GetCursorScreenPos", ImGui::GetCursorScreenPos)
.addFunction("GetItemRectMin", ImGui::GetItemRectMin)
.addFunction("GetItemRectMax", ImGui::GetItemRectMax)
.addFunction("SetWindowSize", +[](const ImVec2& size, luabridge::LuaRef cond) { ImGui::SetWindowSize(size, cond ? cond : 0); },
+[](const char* name, const ImVec2& size, luabridge::LuaRef cond) { ImGui::SetWindowSize(name, size, cond ? cond : 0); })
.addFunction("SetWindowSize", [](const ImVec2& size, luabridge::LuaRef cond) { ImGui::SetWindowSize(size, cond ? static_cast<int>(cond) : 0); },
+[](const char* name, const ImVec2& size, luabridge::LuaRef cond) { ImGui::SetWindowSize(name, size, cond ? static_cast<int>(cond) : 0); })
.addFunction("GetWindowSize", ImGui::GetWindowSize)
.addFunction("GetContentRegionAvail", ImGui::GetContentRegionAvail)
.addFunction("GetTextLineHeight", ImGui::GetTextLineHeight)
.addFunction("GetTextLineHeightWithSpacing", ImGui::GetTextLineHeightWithSpacing)
.addFunction("CalcTextSize", +[](const char* text, luabridge::LuaRef hide_text_after_double_hash, luabridge::LuaRef wrap_width)
.addFunction("CalcTextSize", [](const char* text, luabridge::LuaRef hide_text_after_double_hash, luabridge::LuaRef wrap_width)
{ return ImGui::CalcTextSize(text, 0, hide_text_after_double_hash ? hide_text_after_double_hash : false, wrap_width ? wrap_width : -1.0f); })
.addFunction("SameLine", +[](luabridge::LuaRef offset_from_start_x, luabridge::LuaRef spacing_w)
.addFunction("SameLine", [](luabridge::LuaRef offset_from_start_x, luabridge::LuaRef spacing_w)
{ ImGui::SameLine(offset_from_start_x.isNil() ? 0.0f : offset_from_start_x, spacing_w.isNil() ? -1.0f : spacing_w); })
.addFunction("BeginGroup", ImGui::BeginGroup)
.addFunction("EndGroup", ImGui::EndGroup)
Expand Down