From 5c7e2fdde99c395ed53ad5eee27d73ae0f3cf900 Mon Sep 17 00:00:00 2001 From: NLTP_ASHES <65969659+nltp-ashes@users.noreply.github.com> Date: Sun, 15 Feb 2026 17:27:27 +0100 Subject: [PATCH 01/11] Add DrawCustomShape --- src/xrGame/ui/UIActorMenu_script.cpp | 3 +- src/xrGame/ui/UIMainIngameWnd.cpp | 60 ++++++++++++++++++++++++++++ src/xrGame/ui/UIMainIngameWnd.h | 4 ++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/xrGame/ui/UIActorMenu_script.cpp b/src/xrGame/ui/UIActorMenu_script.cpp index 58f9460cd3..ebae542ab2 100644 --- a/src/xrGame/ui/UIActorMenu_script.cpp +++ b/src/xrGame/ui/UIActorMenu_script.cpp @@ -368,7 +368,8 @@ void CUIActorMenu::script_register(lua_State* L) .def_readonly("m_QuickSlotText1", &CUIMainIngameWnd::m_QuickSlotText1) .def_readonly("m_QuickSlotText2", &CUIMainIngameWnd::m_QuickSlotText2) .def_readonly("m_QuickSlotText3", &CUIMainIngameWnd::m_QuickSlotText3) - .def_readonly("m_QuickSlotText4", &CUIMainIngameWnd::m_QuickSlotText4), + .def_readonly("m_QuickSlotText4", &CUIMainIngameWnd::m_QuickSlotText4) + .def("SetCustomShape", &CUIMainIngameWnd::SetCustomShape), class_("CUIZoneMap") .def(constructor<>()) diff --git a/src/xrGame/ui/UIMainIngameWnd.cpp b/src/xrGame/ui/UIMainIngameWnd.cpp index 9adc49aa2f..1dfe914c08 100644 --- a/src/xrGame/ui/UIMainIngameWnd.cpp +++ b/src/xrGame/ui/UIMainIngameWnd.cpp @@ -312,8 +312,68 @@ void CUIMainIngameWnd::Draw() UIMotionIcon->Show(tmp); RenderQuickInfos(); + DrawCustomShape(); } +void CUIMainIngameWnd::SetCustomShape(const ::luabind::object& pts) +{ + custom_shape_pts.clear(); + + size_t table_size = 0; + for (auto i = pts.begin(); i != pts.end(); ++i) { + table_size++; + } + + for (int i = 1; i <= table_size; i++) { + Fvector2 pt = ::luabind::object_cast(pts[i]); + custom_shape_pts.push_back(pt); + } +} + +void CUIMainIngameWnd::DrawCustomShape() +{ + size_t point_count = custom_shape_pts.size(); + if (point_count < 3) { + return; + } + + // Find bounding box + float min_x = custom_shape_pts[0].x, max_x = custom_shape_pts[0].x; + float min_y = custom_shape_pts[0].y, max_y = custom_shape_pts[0].y; + for (size_t i = 1; i < point_count; ++i) { + if (custom_shape_pts[i].x < min_x) min_x = custom_shape_pts[i].x; + if (custom_shape_pts[i].x > max_x) max_x = custom_shape_pts[i].x; + if (custom_shape_pts[i].y < min_y) min_y = custom_shape_pts[i].y; + if (custom_shape_pts[i].y > max_y) max_y = custom_shape_pts[i].y; + } + float width = max_x - min_x; + float height = max_y - min_y; + + // Precompute UVs + std::vector uvs(point_count); + for (size_t i = 0; i < point_count; ++i) { + uvs[i].x = (custom_shape_pts[i].x - min_x) / width; + uvs[i].y = (custom_shape_pts[i].y - min_y) / height; + } + + ui_shader shader; + LPCSTR res_shname = UIRender->UpdateShaderName("ui\\ui_global_map", "hud\\default"); + shader->create(res_shname, "ui\\ui_global_map"); + UIRender->SetShader(*shader); + + UIRender->StartPrimitive(point_count * 3, IUIRender::ePrimitiveType::ptTriList, IUIRender::ePointType::pttTL); + + u32 color = color_rgba(255, 255, 255, 127); + + for (u32 idx = 0; idx < point_count - 2; ++idx) + { + UIRender->PushPoint(custom_shape_pts[0].x, custom_shape_pts[0].y, 0, color, uvs[0].x, uvs[0].y); + UIRender->PushPoint(custom_shape_pts[idx + 2].x, custom_shape_pts[idx + 2].y, 0, color, uvs[idx + 2].x, uvs[idx + 2].y); + UIRender->PushPoint(custom_shape_pts[idx + 1].x, custom_shape_pts[idx + 1].y, 0, color, uvs[idx + 1].x, uvs[idx + 1].y); + } + + UIRender->FlushPrimitive(); +} void CUIMainIngameWnd::SetMPChatLog(CUIWindow* pChat, CUIWindow* pLog) { diff --git a/src/xrGame/ui/UIMainIngameWnd.h b/src/xrGame/ui/UIMainIngameWnd.h index 456fbb0cde..1127823b70 100644 --- a/src/xrGame/ui/UIMainIngameWnd.h +++ b/src/xrGame/ui/UIMainIngameWnd.h @@ -68,6 +68,10 @@ class CUIMainIngameWnd : public CUIWindow CUITextWnd* m_QuickSlotText3; CUITextWnd* m_QuickSlotText4; + std::vector custom_shape_pts; + void SetCustomShape(const ::luabind::object& pts); + void DrawCustomShape(); + protected: // 5 статиков для отображения иконок: // - сломанного оружия(only mp) From 3c5c52e76d394851611b66f4a34be4da61c9c44e Mon Sep 17 00:00:00 2001 From: NLTP_ASHES <65969659+nltp-ashes@users.noreply.github.com> Date: Sun, 15 Feb 2026 19:23:35 +0100 Subject: [PATCH 02/11] Move from CUIMainIngameWnd to CUIGameCustom --- src/xrGame/UIGameCustom.cpp | 71 ++++++++++++++++++++++++++++ src/xrGame/UIGameCustom.h | 4 ++ src/xrGame/UIGameCustom_script.cpp | 1 + src/xrGame/ui/UIActorMenu_script.cpp | 3 +- src/xrGame/ui/UIMainIngameWnd.cpp | 61 ------------------------ src/xrGame/ui/UIMainIngameWnd.h | 5 -- 6 files changed, 77 insertions(+), 68 deletions(-) diff --git a/src/xrGame/UIGameCustom.cpp b/src/xrGame/UIGameCustom.cpp index cda19a3a30..c03d220078 100644 --- a/src/xrGame/UIGameCustom.cpp +++ b/src/xrGame/UIGameCustom.cpp @@ -105,10 +105,81 @@ void CUIGameCustom::Render() if (GameIndicatorsShown() && psHUD_Flags.is(HUD_DRAW | HUD_DRAW_RT)) UIMainIngameWnd->Draw(); } + DrawCustomShapes(); m_pMessagesWnd->Draw(); DoRenderDialogs(); } +void CUIGameCustom::AddCustomShapeToRender(const ::luabind::object& pts) +{ + int table_size = 0; + for (auto i = pts.begin(); i != pts.end(); ++i) { + table_size++; + } + + sPoly2D poly; + poly.resize(table_size); + + // Correct for aspect ration + Fvector2 scale; + scale.set(float(Device.dwWidth) / UI_BASE_WIDTH, float(Device.dwHeight) / UI_BASE_HEIGHT); + + for (int i = 1; i <= table_size; i++) { + Fvector2 pt = ::luabind::object_cast(pts[i]); + poly[i - 1].pt.x = pt.x * scale.x; + poly[i - 1].pt.y = pt.y * scale.y; + } + + // Find bounding box + float min_x = poly[0].pt.x, max_x = poly[0].pt.x; + float min_y = poly[0].pt.y, max_y = poly[0].pt.y; + for (int i = 0; i < table_size; ++i) { + if (poly[i].pt.x < min_x) min_x = poly[i].pt.x; + if (poly[i].pt.x > max_x) max_x = poly[i].pt.x; + if (poly[i].pt.y < min_y) min_y = poly[i].pt.y; + if (poly[i].pt.y > max_y) max_y = poly[i].pt.y; + } + float width = max_x - min_x; + float height = max_y - min_y; + + // Compute UVs + for (int i = 0; i < table_size; ++i) { + poly[i].uv.x = (poly[i].pt.x - min_x) / width; + poly[i].uv.y = (poly[i].pt.y - min_y) / height; + } + + custom_shapes.push_back(poly); +} + +void CUIGameCustom::DrawCustomShapes() +{ + int poly_count = custom_shapes.size(); + + for (int i = 0; i < poly_count; i++) { + sPoly2D poly = custom_shapes[i]; + + ui_shader shader; + LPCSTR res_shname = UIRender->UpdateShaderName("ui\\ui_global_map", "hud\\default"); + shader->create(res_shname, "ui\\ui_global_map"); + UIRender->SetShader(*shader); + + UIRender->StartPrimitive(poly.size() * 3, IUIRender::ePrimitiveType::ptTriList, IUIRender::ePointType::pttTL); + + u32 color = color_rgba(255, 255, 255, 127); + + for (u32 idx = 0; idx < poly.size() - 2; ++idx) + { + UIRender->PushPoint(poly[0].pt.x, poly[0].pt.y, 0, color, poly[0].uv.x, poly[0].uv.y); + UIRender->PushPoint(poly[idx + 2].pt.x, poly[idx + 2].pt.y, 0, color, poly[idx + 2].uv.x, poly[idx + 2].uv.y); + UIRender->PushPoint(poly[idx + 1].pt.x, poly[idx + 1].pt.y, 0, color, poly[idx + 1].uv.x, poly[idx + 1].uv.y); + } + + UIRender->FlushPrimitive(); + } + + custom_shapes.clear(); +} + StaticDrawableWrapper* CUIGameCustom::AddCustomStatic(const char* id, bool singleInstance) { if (singleInstance) diff --git a/src/xrGame/UIGameCustom.h b/src/xrGame/UIGameCustom.h index fd95fd4451..0130b2ea48 100644 --- a/src/xrGame/UIGameCustom.h +++ b/src/xrGame/UIGameCustom.h @@ -131,6 +131,10 @@ class CUIGameCustom : void RemoveCustomStatic(const char* id); void CommonMessageOut(const char* text); + std::vector custom_shapes; + void AddCustomShapeToRender(const ::luabind::object& pts); + void DrawCustomShapes(); + virtual void ChangeTotalMoneyIndicator(const char* newMoneyString) { } diff --git a/src/xrGame/UIGameCustom_script.cpp b/src/xrGame/UIGameCustom_script.cpp index bdff0f98af..3f265f428d 100644 --- a/src/xrGame/UIGameCustom_script.cpp +++ b/src/xrGame/UIGameCustom_script.cpp @@ -24,6 +24,7 @@ void CUIGameCustom::script_register(lua_State* L) .def("RemoveDialogToRender", &CUIGameCustom::RemoveDialogToRender) .def("AddCustomStatic", &CUIGameCustom::AddCustomStatic) .def("RemoveCustomStatic", &CUIGameCustom::RemoveCustomStatic) + .def("AddCustomShapeToRender", &CUIGameCustom::AddCustomShapeToRender) .def("HideActorMenu", &CUIGameCustom::HideActorMenu) //Alundaio .def("UpdateActorMenu", &CUIGameCustom::UpdateActorMenu) diff --git a/src/xrGame/ui/UIActorMenu_script.cpp b/src/xrGame/ui/UIActorMenu_script.cpp index ebae542ab2..58f9460cd3 100644 --- a/src/xrGame/ui/UIActorMenu_script.cpp +++ b/src/xrGame/ui/UIActorMenu_script.cpp @@ -368,8 +368,7 @@ void CUIActorMenu::script_register(lua_State* L) .def_readonly("m_QuickSlotText1", &CUIMainIngameWnd::m_QuickSlotText1) .def_readonly("m_QuickSlotText2", &CUIMainIngameWnd::m_QuickSlotText2) .def_readonly("m_QuickSlotText3", &CUIMainIngameWnd::m_QuickSlotText3) - .def_readonly("m_QuickSlotText4", &CUIMainIngameWnd::m_QuickSlotText4) - .def("SetCustomShape", &CUIMainIngameWnd::SetCustomShape), + .def_readonly("m_QuickSlotText4", &CUIMainIngameWnd::m_QuickSlotText4), class_("CUIZoneMap") .def(constructor<>()) diff --git a/src/xrGame/ui/UIMainIngameWnd.cpp b/src/xrGame/ui/UIMainIngameWnd.cpp index 1dfe914c08..15f9dd1d54 100644 --- a/src/xrGame/ui/UIMainIngameWnd.cpp +++ b/src/xrGame/ui/UIMainIngameWnd.cpp @@ -312,67 +312,6 @@ void CUIMainIngameWnd::Draw() UIMotionIcon->Show(tmp); RenderQuickInfos(); - DrawCustomShape(); -} - -void CUIMainIngameWnd::SetCustomShape(const ::luabind::object& pts) -{ - custom_shape_pts.clear(); - - size_t table_size = 0; - for (auto i = pts.begin(); i != pts.end(); ++i) { - table_size++; - } - - for (int i = 1; i <= table_size; i++) { - Fvector2 pt = ::luabind::object_cast(pts[i]); - custom_shape_pts.push_back(pt); - } -} - -void CUIMainIngameWnd::DrawCustomShape() -{ - size_t point_count = custom_shape_pts.size(); - if (point_count < 3) { - return; - } - - // Find bounding box - float min_x = custom_shape_pts[0].x, max_x = custom_shape_pts[0].x; - float min_y = custom_shape_pts[0].y, max_y = custom_shape_pts[0].y; - for (size_t i = 1; i < point_count; ++i) { - if (custom_shape_pts[i].x < min_x) min_x = custom_shape_pts[i].x; - if (custom_shape_pts[i].x > max_x) max_x = custom_shape_pts[i].x; - if (custom_shape_pts[i].y < min_y) min_y = custom_shape_pts[i].y; - if (custom_shape_pts[i].y > max_y) max_y = custom_shape_pts[i].y; - } - float width = max_x - min_x; - float height = max_y - min_y; - - // Precompute UVs - std::vector uvs(point_count); - for (size_t i = 0; i < point_count; ++i) { - uvs[i].x = (custom_shape_pts[i].x - min_x) / width; - uvs[i].y = (custom_shape_pts[i].y - min_y) / height; - } - - ui_shader shader; - LPCSTR res_shname = UIRender->UpdateShaderName("ui\\ui_global_map", "hud\\default"); - shader->create(res_shname, "ui\\ui_global_map"); - UIRender->SetShader(*shader); - - UIRender->StartPrimitive(point_count * 3, IUIRender::ePrimitiveType::ptTriList, IUIRender::ePointType::pttTL); - - u32 color = color_rgba(255, 255, 255, 127); - - for (u32 idx = 0; idx < point_count - 2; ++idx) - { - UIRender->PushPoint(custom_shape_pts[0].x, custom_shape_pts[0].y, 0, color, uvs[0].x, uvs[0].y); - UIRender->PushPoint(custom_shape_pts[idx + 2].x, custom_shape_pts[idx + 2].y, 0, color, uvs[idx + 2].x, uvs[idx + 2].y); - UIRender->PushPoint(custom_shape_pts[idx + 1].x, custom_shape_pts[idx + 1].y, 0, color, uvs[idx + 1].x, uvs[idx + 1].y); - } - - UIRender->FlushPrimitive(); } void CUIMainIngameWnd::SetMPChatLog(CUIWindow* pChat, CUIWindow* pLog) diff --git a/src/xrGame/ui/UIMainIngameWnd.h b/src/xrGame/ui/UIMainIngameWnd.h index 1127823b70..6551b277fe 100644 --- a/src/xrGame/ui/UIMainIngameWnd.h +++ b/src/xrGame/ui/UIMainIngameWnd.h @@ -67,11 +67,6 @@ class CUIMainIngameWnd : public CUIWindow CUITextWnd* m_QuickSlotText2; CUITextWnd* m_QuickSlotText3; CUITextWnd* m_QuickSlotText4; - - std::vector custom_shape_pts; - void SetCustomShape(const ::luabind::object& pts); - void DrawCustomShape(); - protected: // 5 статиков для отображения иконок: // - сломанного оружия(only mp) From ec0b6cc18706b1f69ae2e9d8c614b38a4f36c0c4 Mon Sep 17 00:00:00 2001 From: NLTP_ASHES <65969659+nltp-ashes@users.noreply.github.com> Date: Sun, 15 Feb 2026 20:13:12 +0100 Subject: [PATCH 03/11] Port as much code as possible to lua --- src/xrGame/UIGameCustom.cpp | 63 +++++++++++++------------------------ src/xrGame/UIGameCustom.h | 2 +- src/xrGame/ui_defs.h | 8 +++++ 3 files changed, 31 insertions(+), 42 deletions(-) diff --git a/src/xrGame/UIGameCustom.cpp b/src/xrGame/UIGameCustom.cpp index c03d220078..c4b5ae3a0e 100644 --- a/src/xrGame/UIGameCustom.cpp +++ b/src/xrGame/UIGameCustom.cpp @@ -110,45 +110,28 @@ void CUIGameCustom::Render() DoRenderDialogs(); } -void CUIGameCustom::AddCustomShapeToRender(const ::luabind::object& pts) +void CUIGameCustom::AddCustomShapeToRender(const ::luabind::object& lua_shape) { + CustomShape shape; + shape.shader_name = ::luabind::object_cast(lua_shape["shader"]); + shape.texture_name = ::luabind::object_cast(lua_shape["texture"]); + shape.texture_color = ::luabind::object_cast(lua_shape["color"]); + + ::luabind::object lua_poly = lua_shape["poly"]; + int table_size = 0; - for (auto i = pts.begin(); i != pts.end(); ++i) { + for (auto i = lua_poly.begin(); i != lua_poly.end(); ++i) { table_size++; } - - sPoly2D poly; - poly.resize(table_size); - - // Correct for aspect ration - Fvector2 scale; - scale.set(float(Device.dwWidth) / UI_BASE_WIDTH, float(Device.dwHeight) / UI_BASE_HEIGHT); + shape.poly.resize(table_size); for (int i = 1; i <= table_size; i++) { - Fvector2 pt = ::luabind::object_cast(pts[i]); - poly[i - 1].pt.x = pt.x * scale.x; - poly[i - 1].pt.y = pt.y * scale.y; + ::luabind::object lua_point = lua_poly[i]; + shape.poly[i - 1].pt = ::luabind::object_cast(lua_point["pt"]); + shape.poly[i - 1].uv = ::luabind::object_cast(lua_point["uv"]); } - // Find bounding box - float min_x = poly[0].pt.x, max_x = poly[0].pt.x; - float min_y = poly[0].pt.y, max_y = poly[0].pt.y; - for (int i = 0; i < table_size; ++i) { - if (poly[i].pt.x < min_x) min_x = poly[i].pt.x; - if (poly[i].pt.x > max_x) max_x = poly[i].pt.x; - if (poly[i].pt.y < min_y) min_y = poly[i].pt.y; - if (poly[i].pt.y > max_y) max_y = poly[i].pt.y; - } - float width = max_x - min_x; - float height = max_y - min_y; - - // Compute UVs - for (int i = 0; i < table_size; ++i) { - poly[i].uv.x = (poly[i].pt.x - min_x) / width; - poly[i].uv.y = (poly[i].pt.y - min_y) / height; - } - - custom_shapes.push_back(poly); + custom_shapes.push_back(shape); } void CUIGameCustom::DrawCustomShapes() @@ -156,22 +139,20 @@ void CUIGameCustom::DrawCustomShapes() int poly_count = custom_shapes.size(); for (int i = 0; i < poly_count; i++) { - sPoly2D poly = custom_shapes[i]; + CustomShape shape = custom_shapes[i]; ui_shader shader; - LPCSTR res_shname = UIRender->UpdateShaderName("ui\\ui_global_map", "hud\\default"); - shader->create(res_shname, "ui\\ui_global_map"); + LPCSTR res_shname = UIRender->UpdateShaderName(shape.texture_name, shape.shader_name); + shader->create(res_shname, shape.texture_name); UIRender->SetShader(*shader); - UIRender->StartPrimitive(poly.size() * 3, IUIRender::ePrimitiveType::ptTriList, IUIRender::ePointType::pttTL); - - u32 color = color_rgba(255, 255, 255, 127); + UIRender->StartPrimitive(shape.poly.size() * 3, IUIRender::ePrimitiveType::ptTriList, IUIRender::ePointType::pttTL); - for (u32 idx = 0; idx < poly.size() - 2; ++idx) + for (u32 idx = 0; idx < shape.poly.size() - 2; ++idx) { - UIRender->PushPoint(poly[0].pt.x, poly[0].pt.y, 0, color, poly[0].uv.x, poly[0].uv.y); - UIRender->PushPoint(poly[idx + 2].pt.x, poly[idx + 2].pt.y, 0, color, poly[idx + 2].uv.x, poly[idx + 2].uv.y); - UIRender->PushPoint(poly[idx + 1].pt.x, poly[idx + 1].pt.y, 0, color, poly[idx + 1].uv.x, poly[idx + 1].uv.y); + UIRender->PushPoint(shape.poly[0].pt.x, shape.poly[0].pt.y, 0, shape.texture_color, shape.poly[0].uv.x, shape.poly[0].uv.y); + UIRender->PushPoint(shape.poly[idx + 2].pt.x, shape.poly[idx + 2].pt.y, 0, shape.texture_color, shape.poly[idx + 2].uv.x, shape.poly[idx + 2].uv.y); + UIRender->PushPoint(shape.poly[idx + 1].pt.x, shape.poly[idx + 1].pt.y, 0, shape.texture_color, shape.poly[idx + 1].uv.x, shape.poly[idx + 1].uv.y); } UIRender->FlushPrimitive(); diff --git a/src/xrGame/UIGameCustom.h b/src/xrGame/UIGameCustom.h index 0130b2ea48..eeb1f00132 100644 --- a/src/xrGame/UIGameCustom.h +++ b/src/xrGame/UIGameCustom.h @@ -131,7 +131,7 @@ class CUIGameCustom : void RemoveCustomStatic(const char* id); void CommonMessageOut(const char* text); - std::vector custom_shapes; + std::vector custom_shapes; void AddCustomShapeToRender(const ::luabind::object& pts); void DrawCustomShapes(); diff --git a/src/xrGame/ui_defs.h b/src/xrGame/ui_defs.h index 6b36ab52b7..c41e554739 100644 --- a/src/xrGame/ui_defs.h +++ b/src/xrGame/ui_defs.h @@ -52,6 +52,14 @@ struct S2DVert #define UI_FRUSTUM_SAFE (UI_FRUSTUM_MAXPLANES*4) typedef svector sPoly2D; +struct CustomShape +{ + sPoly2D poly; + LPCSTR shader_name; + LPCSTR texture_name; + u32 texture_color; +}; + class C2DFrustum { svector planes; From 36e8af7507d604d9ca96d9be57d165378c95d724 Mon Sep 17 00:00:00 2001 From: NLTP_ASHES <65969659+nltp-ashes@users.noreply.github.com> Date: Mon, 16 Feb 2026 01:09:30 +0100 Subject: [PATCH 04/11] Removed useless UpdateShaderName --- src/xrGame/UIGameCustom.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/xrGame/UIGameCustom.cpp b/src/xrGame/UIGameCustom.cpp index c4b5ae3a0e..e83487b84d 100644 --- a/src/xrGame/UIGameCustom.cpp +++ b/src/xrGame/UIGameCustom.cpp @@ -119,13 +119,13 @@ void CUIGameCustom::AddCustomShapeToRender(const ::luabind::object& lua_shape) ::luabind::object lua_poly = lua_shape["poly"]; - int table_size = 0; + int poly_size = 0; for (auto i = lua_poly.begin(); i != lua_poly.end(); ++i) { - table_size++; + poly_size++; } - shape.poly.resize(table_size); + shape.poly.resize(poly_size); - for (int i = 1; i <= table_size; i++) { + for (int i = 1; i <= poly_size; i++) { ::luabind::object lua_point = lua_poly[i]; shape.poly[i - 1].pt = ::luabind::object_cast(lua_point["pt"]); shape.poly[i - 1].uv = ::luabind::object_cast(lua_point["uv"]); @@ -142,8 +142,7 @@ void CUIGameCustom::DrawCustomShapes() CustomShape shape = custom_shapes[i]; ui_shader shader; - LPCSTR res_shname = UIRender->UpdateShaderName(shape.texture_name, shape.shader_name); - shader->create(res_shname, shape.texture_name); + shader->create(shape.shader_name, shape.texture_name); UIRender->SetShader(*shader); UIRender->StartPrimitive(shape.poly.size() * 3, IUIRender::ePrimitiveType::ptTriList, IUIRender::ePointType::pttTL); From 0de01226f863e43f24fe80747fb217a820719a96 Mon Sep 17 00:00:00 2001 From: NLTP_ASHES <65969659+nltp-ashes@users.noreply.github.com> Date: Mon, 16 Feb 2026 12:00:32 +0100 Subject: [PATCH 05/11] Dummy change to trigger CI --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 8d764d7004..31c550a08f 100644 --- a/README.md +++ b/README.md @@ -1742,4 +1742,3 @@ override = true * Exported distance_to_xz_sqr() function of Fvector * Redesigned duplicate section error, it will additionally print what file adds the section in the first place in addition to the file that has the duplicate - From 34cb537468e1307fab6b08993fd1e2d839a9b7a5 Mon Sep 17 00:00:00 2001 From: NLTP_ASHES <65969659+nltp-ashes@users.noreply.github.com> Date: Sun, 1 Mar 2026 20:31:38 +0100 Subject: [PATCH 06/11] Made CustomShapes persistant through runtime and added state management --- src/xrGame/UIGameCustom.cpp | 73 +++++++++++++++++++----------- src/xrGame/UIGameCustom.h | 7 ++- src/xrGame/UIGameCustom_script.cpp | 3 ++ src/xrGame/ui_defs.h | 5 +- 4 files changed, 57 insertions(+), 31 deletions(-) diff --git a/src/xrGame/UIGameCustom.cpp b/src/xrGame/UIGameCustom.cpp index e83487b84d..f6620d0100 100644 --- a/src/xrGame/UIGameCustom.cpp +++ b/src/xrGame/UIGameCustom.cpp @@ -110,54 +110,73 @@ void CUIGameCustom::Render() DoRenderDialogs(); } -void CUIGameCustom::AddCustomShapeToRender(const ::luabind::object& lua_shape) +void CUIGameCustom::AddCustomShapeToRender(LPCSTR name, ::luabind::object lua_shape) { - CustomShape shape; + CustomShape shape{}; shape.shader_name = ::luabind::object_cast(lua_shape["shader"]); shape.texture_name = ::luabind::object_cast(lua_shape["texture"]); shape.texture_color = ::luabind::object_cast(lua_shape["color"]); + shape.shader->create(shape.shader_name.c_str(), shape.texture_name.c_str()); - ::luabind::object lua_poly = lua_shape["poly"]; + custom_shapes.emplace(name, shape); +} - int poly_size = 0; - for (auto i = lua_poly.begin(); i != lua_poly.end(); ++i) { - poly_size++; - } - shape.poly.resize(poly_size); +void CUIGameCustom::RemoveCustomShapeToRender(LPCSTR name) +{ + auto it = custom_shapes.find(name); + if (it != custom_shapes.end()) + custom_shapes.erase(it); +} - for (int i = 1; i <= poly_size; i++) { - ::luabind::object lua_point = lua_poly[i]; - shape.poly[i - 1].pt = ::luabind::object_cast(lua_point["pt"]); - shape.poly[i - 1].uv = ::luabind::object_cast(lua_point["uv"]); - } +bool CUIGameCustom::HasCustomShape(LPCSTR name) +{ + auto it = custom_shapes.find(name); + return it != custom_shapes.end(); +} - custom_shapes.push_back(shape); +void CUIGameCustom::UpdateCustomShape(LPCSTR name, ::luabind::object lua_poly) +{ + CustomShape shape = custom_shapes[name]; + + int poly_size = 0; + for (auto i = lua_poly.begin(); i != lua_poly.end(); ++i) { + poly_size++; + } + shape.poly.resize(poly_size); + + for (int i = 1; i <= poly_size; i++) { + ::luabind::object lua_point = lua_poly[i]; + shape.poly[i - 1].pt = ::luabind::object_cast(lua_point["pt"]); + shape.poly[i - 1].uv = ::luabind::object_cast(lua_point["uv"]); + } + custom_shapes[name] = shape; } void CUIGameCustom::DrawCustomShapes() { - int poly_count = custom_shapes.size(); + for (const auto& pair : custom_shapes) + { + CustomShape shape = pair.second; + sPoly2D poly = shape.poly; - for (int i = 0; i < poly_count; i++) { - CustomShape shape = custom_shapes[i]; + if (poly.empty()) + { + continue; + } - ui_shader shader; - shader->create(shape.shader_name, shape.texture_name); - UIRender->SetShader(*shader); + UIRender->SetShader(*shape.shader); - UIRender->StartPrimitive(shape.poly.size() * 3, IUIRender::ePrimitiveType::ptTriList, IUIRender::ePointType::pttTL); + UIRender->StartPrimitive(poly.size() * 3, IUIRender::ePrimitiveType::ptTriList, IUIRender::ePointType::pttTL); - for (u32 idx = 0; idx < shape.poly.size() - 2; ++idx) + for (u32 idx = 0; idx < poly.size() - 2; ++idx) { - UIRender->PushPoint(shape.poly[0].pt.x, shape.poly[0].pt.y, 0, shape.texture_color, shape.poly[0].uv.x, shape.poly[0].uv.y); - UIRender->PushPoint(shape.poly[idx + 2].pt.x, shape.poly[idx + 2].pt.y, 0, shape.texture_color, shape.poly[idx + 2].uv.x, shape.poly[idx + 2].uv.y); - UIRender->PushPoint(shape.poly[idx + 1].pt.x, shape.poly[idx + 1].pt.y, 0, shape.texture_color, shape.poly[idx + 1].uv.x, shape.poly[idx + 1].uv.y); + UIRender->PushPoint(poly[0].pt.x, poly[0].pt.y, 0, shape.texture_color, poly[0].uv.x, poly[0].uv.y); + UIRender->PushPoint(poly[idx + 2].pt.x, poly[idx + 2].pt.y, 0, shape.texture_color, poly[idx + 2].uv.x, poly[idx + 2].uv.y); + UIRender->PushPoint(poly[idx + 1].pt.x, poly[idx + 1].pt.y, 0, shape.texture_color, poly[idx + 1].uv.x, poly[idx + 1].uv.y); } UIRender->FlushPrimitive(); } - - custom_shapes.clear(); } StaticDrawableWrapper* CUIGameCustom::AddCustomStatic(const char* id, bool singleInstance) diff --git a/src/xrGame/UIGameCustom.h b/src/xrGame/UIGameCustom.h index eeb1f00132..ddc6aafa32 100644 --- a/src/xrGame/UIGameCustom.h +++ b/src/xrGame/UIGameCustom.h @@ -131,8 +131,11 @@ class CUIGameCustom : void RemoveCustomStatic(const char* id); void CommonMessageOut(const char* text); - std::vector custom_shapes; - void AddCustomShapeToRender(const ::luabind::object& pts); + std::map custom_shapes; + void AddCustomShapeToRender(LPCSTR name, ::luabind::object lua_shape); + void RemoveCustomShapeToRender(LPCSTR name); + bool HasCustomShape(LPCSTR name); + void UpdateCustomShape(LPCSTR name, ::luabind::object lua_poly); void DrawCustomShapes(); virtual void ChangeTotalMoneyIndicator(const char* newMoneyString) diff --git a/src/xrGame/UIGameCustom_script.cpp b/src/xrGame/UIGameCustom_script.cpp index 3f265f428d..3f64c98430 100644 --- a/src/xrGame/UIGameCustom_script.cpp +++ b/src/xrGame/UIGameCustom_script.cpp @@ -25,6 +25,9 @@ void CUIGameCustom::script_register(lua_State* L) .def("AddCustomStatic", &CUIGameCustom::AddCustomStatic) .def("RemoveCustomStatic", &CUIGameCustom::RemoveCustomStatic) .def("AddCustomShapeToRender", &CUIGameCustom::AddCustomShapeToRender) + .def("RemoveCustomShapeToRender", &CUIGameCustom::RemoveCustomShapeToRender) + .def("HasCustomShape", &CUIGameCustom::HasCustomShape) + .def("UpdateCustomShape", &CUIGameCustom::UpdateCustomShape) .def("HideActorMenu", &CUIGameCustom::HideActorMenu) //Alundaio .def("UpdateActorMenu", &CUIGameCustom::UpdateActorMenu) diff --git a/src/xrGame/ui_defs.h b/src/xrGame/ui_defs.h index c41e554739..fd8179d999 100644 --- a/src/xrGame/ui_defs.h +++ b/src/xrGame/ui_defs.h @@ -55,8 +55,9 @@ typedef svector sPoly2D; struct CustomShape { sPoly2D poly; - LPCSTR shader_name; - LPCSTR texture_name; + ui_shader shader; + std::string shader_name; + std::string texture_name; u32 texture_color; }; From e63cac52378d3034a48fdd54b2d3d0f03d8f6b58 Mon Sep 17 00:00:00 2001 From: NLTP_ASHES <65969659+nltp-ashes@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:06:58 +0200 Subject: [PATCH 07/11] feature(find-child): expose find-child to lua --- src/xrGame/ui/UIWindow.cpp | 2 +- src/xrGame/ui/UIWindow.h | 2 +- src/xrGame/ui/UIWindow_script.cpp | 13 +------------ 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/xrGame/ui/UIWindow.cpp b/src/xrGame/ui/UIWindow.cpp index 5840c89f68..7ec1b46f33 100644 --- a/src/xrGame/ui/UIWindow.cpp +++ b/src/xrGame/ui/UIWindow.cpp @@ -612,7 +612,7 @@ bool CUIWindow::IsChild(CUIWindow* pPossibleChild) const } -CUIWindow* CUIWindow::FindChild(const shared_str name) +CUIWindow* CUIWindow::FindChild(const LPCSTR name) { if (WindowName() == name) return this; diff --git a/src/xrGame/ui/UIWindow.h b/src/xrGame/ui/UIWindow.h index 881f3763b1..2a5d8800c2 100644 --- a/src/xrGame/ui/UIWindow.h +++ b/src/xrGame/ui/UIWindow.h @@ -240,7 +240,7 @@ class CUIWindow : public CUISimpleWindow const shared_str WindowName() const { return m_windowName; } void SetWindowName(LPCSTR wn) { m_windowName = wn; } LPCSTR WindowName_script() { return m_windowName.c_str(); } - CUIWindow* FindChild(const shared_str name); + CUIWindow* FindChild(const LPCSTR name); IC bool CursorOverWindow() const { return m_bCursorOverWindow; } IC u32 FocusReceiveTime() const { return m_dwFocusReceiveTime; } diff --git a/src/xrGame/ui/UIWindow_script.cpp b/src/xrGame/ui/UIWindow_script.cpp index 82d4650a1c..86ac681d1b 100644 --- a/src/xrGame/ui/UIWindow_script.cpp +++ b/src/xrGame/ui/UIWindow_script.cpp @@ -166,6 +166,7 @@ void CUIWindow::script_register(lua_State* L) .def("AttachChild", &CUIWindow::AttachChild, adopt<2>()) .def("AttachChildKeepOwner", &CUIWindow::AttachChild) .def("DetachChild", &CUIWindow::DetachChild) + .def("FindChild", &CUIWindow::FindChild) .def("SetAutoDelete", &CUIWindow::SetAutoDelete) .def("IsAutoDelete", &CUIWindow::IsAutoDelete) @@ -173,18 +174,6 @@ void CUIWindow::script_register(lua_State* L) .def("FocusReceiveTime", &CUIWindow::FocusReceiveTime) .def("GetAbsoluteRect", &CUIWindow::GetAbsoluteRect) - /* - .def("DisableHint", &CUIWindow::DisableHint) - .def("EnableHint", &CUIWindow::EnableHint) - .def("SetHintDelay", &CUIWindow::SetHintDelay) - .def("GetHintDelay", &CUIWindow::GetHintDelay) - .def("RemoveHint", &CUIWindow::RemoveHint) - .def("SetHintWnd", &CUIWindow::SetHintWnd) - .def("GetHintWnd", &CUIWindow::GetHintWnd) - .def("SetHintText", &CUIWindow::SetHintText) - .def("GetHintText", &CUIWindow::GetHintText) - */ - .def("SetWndRect", (void (CUIWindow::*)(Frect))&CUIWindow::SetWndRect_script) .def("SetWndPos", (void (CUIWindow::*)(Fvector2))&CUIWindow::SetWndPos_script) .def("SetWndSize", (void (CUIWindow::*)(Fvector2))&CUIWindow::SetWndSize_script) From 8d8a6555f07d598941253bfa3d22503326667ce6 Mon Sep 17 00:00:00 2001 From: NLTP_ASHES <65969659+nltp-ashes@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:31:26 +0200 Subject: [PATCH 08/11] feature(find-child): add macro to cast ui classes --- src/xrGame/ui/UIWindow_script.cpp | 118 +++++++++++++++++++++++++++--- 1 file changed, 109 insertions(+), 9 deletions(-) diff --git a/src/xrGame/ui/UIWindow_script.cpp b/src/xrGame/ui/UIWindow_script.cpp index 86ac681d1b..a67241800a 100644 --- a/src/xrGame/ui/UIWindow_script.cpp +++ b/src/xrGame/ui/UIWindow_script.cpp @@ -1,18 +1,50 @@ #include "pch_script.h" #include "UIWindow.h" -#include "UIFrameWindow.h" -#include "UIFrameLineWnd.h" -#include "UIDialogWnd.h" #include "UIDialogHolder.h" -#include "../GamePersistent.h" -//#include "UILabel.h" -#include "UIMMShniaga.h" #include "UITextureMaster.h" -#include "UIScrollView.h" -#include "UIHint.h" +#include "../GamePersistent.h" #include "../ScriptXMLInit.h" #include "../UICursor.h" +// Sub-classes of CUIWindow exported to the script engine (see UI_WINDOW_SUBCLASSES) +#include "ServerList.h" +#include "UI3tButton.h" +#include "UIActorMenu.h" +#include "UIAnimatedStatic.h" +#include "UIButton.h" +#include "UICheckButton.h" +#include "UIComboBox.h" +#include "UICustomEdit.h" +#include "UICustomSpin.h" +#include "UIDialogWnd.h" +#include "UIEditBox.h" +#include "UIFrameLineWnd.h" +#include "UIFrameWindow.h" +#include "UIHint.h" +#include "UIHudStatesWnd.h" +#include "UIListBox.h" +#include "UIListBoxItem.h" +#include "UIListBoxItemMsgChain.h" +#include "UIMainIngameWnd.h" +#include "UIMapInfo.h" +#include "UIMapList.h" +#include "UIMessageBox.h" +#include "UIMessageBoxEx.h" +#include "UIMessagesWindow.h" +#include "UIMMShniaga.h" +#include "UIMotionIcon.h" +#include "UIPdaWnd.h" +#include "UIProgressBar.h" +#include "UIPropertiesBox.h" +#include "UIScriptWnd.h" +#include "UIScrollView.h" +#include "UISpinNum.h" +#include "UISpinText.h" +#include "UIStatic.h" +#include "UITabButton.h" +#include "UITabControl.h" +#include "UITrackBar.h" + CFontManager& mngr() { return UI().Font(); @@ -131,6 +163,69 @@ void SetCursorPosition_script(Fvector2& pos) GetUICursor().SetUICursorPosition(pos); } +// ----------------------------------------------------------------------------- +// Every sub-class of CUIWindow exported to the script engine gets a +// CUIWindow:cast_() method, so that a window obtained as a plain +// CUIWindow (through FindChild for instance) can be used as what it really is. +// The cast returns nil when the window is not of that type. +// To expose one more sub-class, add it to the list below and include its header. +// ----------------------------------------------------------------------------- +#define UI_WINDOW_SUBCLASSES(op) \ + op(3tButton, CUI3tButton) \ + op(ActorMenu, CUIActorMenu) \ + op(Button, CUIButton) \ + op(CheckButton, CUICheckButton) \ + op(ComboBox, CUIComboBox) \ + op(CustomEdit, CUICustomEdit) \ + op(CustomSpin, CUICustomSpin) \ + op(DialogWnd, CUIDialogWnd) \ + op(EditBox, CUIEditBox) \ + op(FrameLineWnd, CUIFrameLineWnd) \ + op(FrameWindow, CUIFrameWindow) \ + op(Hint, UIHint) \ + op(HudStatesWnd, CUIHudStatesWnd) \ + op(ListBox, CUIListBox) \ + op(ListBoxItem, CUIListBoxItem) \ + op(ListBoxItemMsgChain, CUIListBoxItemMsgChain) \ + op(MainIngameWnd, CUIMainIngameWnd) \ + op(MapInfo, CUIMapInfo) \ + op(MapList, CUIMapList) \ + op(MessageBox, CUIMessageBox) \ + op(MessageBoxEx, CUIMessageBoxEx) \ + op(MessagesWindow, CUIMessagesWindow) \ + op(MMShniaga, CUIMMShniaga) \ + op(MotionIcon, CUIMotionIcon) \ + op(PdaWnd, CUIPdaWnd) \ + op(ProgressBar, CUIProgressBar) \ + op(PropertiesBox, CUIPropertiesBox) \ + op(ScriptWnd, CUIDialogWndEx) \ + op(ScrollView, CUIScrollView) \ + op(ServerList, CServerList) \ + op(SleepStatic, CUISleepStatic) \ + op(SpinFlt, CUISpinFlt) \ + op(SpinNum, CUISpinNum) \ + op(SpinText, CUISpinText) \ + op(Static, CUIStatic) \ + op(TabButton, CUITabButton) \ + op(TabControl, CUITabControl) \ + op(TextWnd, CUITextWnd) \ + op(TrackBar, CUITrackBar) + +namespace +{ +#define UI_WINDOW_DEFINE_CAST(name, class_name) \ + class_name* cast_##name(CUIWindow* window) \ + { \ + return smart_cast(window); \ + } + + UI_WINDOW_SUBCLASSES(UI_WINDOW_DEFINE_CAST) + +#undef UI_WINDOW_DEFINE_CAST +} + +#define UI_WINDOW_EXPORT_CAST(name, class_name) .def("cast_" #name, &cast_##name) + using namespace luabind; #pragma optimize("s",on) void CUIWindow::script_register(lua_State* L) @@ -166,7 +261,7 @@ void CUIWindow::script_register(lua_State* L) .def("AttachChild", &CUIWindow::AttachChild, adopt<2>()) .def("AttachChildKeepOwner", &CUIWindow::AttachChild) .def("DetachChild", &CUIWindow::DetachChild) - .def("FindChild", &CUIWindow::FindChild) + .def("FindChild", &CUIWindow::FindChild) .def("SetAutoDelete", &CUIWindow::SetAutoDelete) .def("IsAutoDelete", &CUIWindow::IsAutoDelete) @@ -190,6 +285,8 @@ void CUIWindow::script_register(lua_State* L) .def("SetWindowName", &CUIWindow::SetWindowName) .def("SetPPMode", &CUIWindow::SetPPMode) .def("ResetPPMode", &CUIWindow::ResetPPMode) + + UI_WINDOW_SUBCLASSES(UI_WINDOW_EXPORT_CAST) ]; module(L) @@ -311,3 +408,6 @@ void CUIWindow::script_register(lua_State* L) ] ]; } + +#undef UI_WINDOW_EXPORT_CAST +#undef UI_WINDOW_SUBCLASSES From c35b22542593e9952cb0439457df205e9c37c21a Mon Sep 17 00:00:00 2001 From: NLTP_ASHES <65969659+nltp-ashes@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:44:24 +0200 Subject: [PATCH 09/11] feature(find-child): rewrite macro - rewrite code to make the macro behave more like what people are used to with script exports --- src/xrGame/ui/UIWindow_script.cpp | 108 ++++++++++++------------------ 1 file changed, 44 insertions(+), 64 deletions(-) diff --git a/src/xrGame/ui/UIWindow_script.cpp b/src/xrGame/ui/UIWindow_script.cpp index a67241800a..2d99d66278 100644 --- a/src/xrGame/ui/UIWindow_script.cpp +++ b/src/xrGame/ui/UIWindow_script.cpp @@ -5,8 +5,6 @@ #include "../GamePersistent.h" #include "../ScriptXMLInit.h" #include "../UICursor.h" - -// Sub-classes of CUIWindow exported to the script engine (see UI_WINDOW_SUBCLASSES) #include "ServerList.h" #include "UI3tButton.h" #include "UIActorMenu.h" @@ -163,68 +161,13 @@ void SetCursorPosition_script(Fvector2& pos) GetUICursor().SetUICursorPosition(pos); } -// ----------------------------------------------------------------------------- -// Every sub-class of CUIWindow exported to the script engine gets a -// CUIWindow:cast_() method, so that a window obtained as a plain -// CUIWindow (through FindChild for instance) can be used as what it really is. -// The cast returns nil when the window is not of that type. -// To expose one more sub-class, add it to the list below and include its header. -// ----------------------------------------------------------------------------- -#define UI_WINDOW_SUBCLASSES(op) \ - op(3tButton, CUI3tButton) \ - op(ActorMenu, CUIActorMenu) \ - op(Button, CUIButton) \ - op(CheckButton, CUICheckButton) \ - op(ComboBox, CUIComboBox) \ - op(CustomEdit, CUICustomEdit) \ - op(CustomSpin, CUICustomSpin) \ - op(DialogWnd, CUIDialogWnd) \ - op(EditBox, CUIEditBox) \ - op(FrameLineWnd, CUIFrameLineWnd) \ - op(FrameWindow, CUIFrameWindow) \ - op(Hint, UIHint) \ - op(HudStatesWnd, CUIHudStatesWnd) \ - op(ListBox, CUIListBox) \ - op(ListBoxItem, CUIListBoxItem) \ - op(ListBoxItemMsgChain, CUIListBoxItemMsgChain) \ - op(MainIngameWnd, CUIMainIngameWnd) \ - op(MapInfo, CUIMapInfo) \ - op(MapList, CUIMapList) \ - op(MessageBox, CUIMessageBox) \ - op(MessageBoxEx, CUIMessageBoxEx) \ - op(MessagesWindow, CUIMessagesWindow) \ - op(MMShniaga, CUIMMShniaga) \ - op(MotionIcon, CUIMotionIcon) \ - op(PdaWnd, CUIPdaWnd) \ - op(ProgressBar, CUIProgressBar) \ - op(PropertiesBox, CUIPropertiesBox) \ - op(ScriptWnd, CUIDialogWndEx) \ - op(ScrollView, CUIScrollView) \ - op(ServerList, CServerList) \ - op(SleepStatic, CUISleepStatic) \ - op(SpinFlt, CUISpinFlt) \ - op(SpinNum, CUISpinNum) \ - op(SpinText, CUISpinText) \ - op(Static, CUIStatic) \ - op(TabButton, CUITabButton) \ - op(TabControl, CUITabControl) \ - op(TextWnd, CUITextWnd) \ - op(TrackBar, CUITrackBar) - -namespace +template +T* ui_window_cast(CUIWindow* window) { -#define UI_WINDOW_DEFINE_CAST(name, class_name) \ - class_name* cast_##name(CUIWindow* window) \ - { \ - return smart_cast(window); \ - } - - UI_WINDOW_SUBCLASSES(UI_WINDOW_DEFINE_CAST) - -#undef UI_WINDOW_DEFINE_CAST + return smart_cast(window); } -#define UI_WINDOW_EXPORT_CAST(name, class_name) .def("cast_" #name, &cast_##name) +#define UI_WINDOW_CAST(class_name) &ui_window_cast using namespace luabind; #pragma optimize("s",on) @@ -286,7 +229,45 @@ void CUIWindow::script_register(lua_State* L) .def("SetPPMode", &CUIWindow::SetPPMode) .def("ResetPPMode", &CUIWindow::ResetPPMode) - UI_WINDOW_SUBCLASSES(UI_WINDOW_EXPORT_CAST) + .def("cast_3tButton", UI_WINDOW_CAST(CUI3tButton)) + .def("cast_ActorMenu", UI_WINDOW_CAST(CUIActorMenu)) + .def("cast_Button", UI_WINDOW_CAST(CUIButton)) + .def("cast_CheckButton", UI_WINDOW_CAST(CUICheckButton)) + .def("cast_ComboBox", UI_WINDOW_CAST(CUIComboBox)) + .def("cast_CustomEdit", UI_WINDOW_CAST(CUICustomEdit)) + .def("cast_CustomSpin", UI_WINDOW_CAST(CUICustomSpin)) + .def("cast_DialogWnd", UI_WINDOW_CAST(CUIDialogWnd)) + .def("cast_EditBox", UI_WINDOW_CAST(CUIEditBox)) + .def("cast_FrameLineWnd", UI_WINDOW_CAST(CUIFrameLineWnd)) + .def("cast_FrameWindow", UI_WINDOW_CAST(CUIFrameWindow)) + .def("cast_Hint", UI_WINDOW_CAST(UIHint)) + .def("cast_HudStatesWnd", UI_WINDOW_CAST(CUIHudStatesWnd)) + .def("cast_ListBox", UI_WINDOW_CAST(CUIListBox)) + .def("cast_ListBoxItem", UI_WINDOW_CAST(CUIListBoxItem)) + .def("cast_ListBoxItemMsgChain", UI_WINDOW_CAST(CUIListBoxItemMsgChain)) + .def("cast_MMShniaga", UI_WINDOW_CAST(CUIMMShniaga)) + .def("cast_MainIngameWnd", UI_WINDOW_CAST(CUIMainIngameWnd)) + .def("cast_MapInfo", UI_WINDOW_CAST(CUIMapInfo)) + .def("cast_MapList", UI_WINDOW_CAST(CUIMapList)) + .def("cast_MessageBox", UI_WINDOW_CAST(CUIMessageBox)) + .def("cast_MessageBoxEx", UI_WINDOW_CAST(CUIMessageBoxEx)) + .def("cast_MessagesWindow", UI_WINDOW_CAST(CUIMessagesWindow)) + .def("cast_MotionIcon", UI_WINDOW_CAST(CUIMotionIcon)) + .def("cast_PdaWnd", UI_WINDOW_CAST(CUIPdaWnd)) + .def("cast_ProgressBar", UI_WINDOW_CAST(CUIProgressBar)) + .def("cast_PropertiesBox", UI_WINDOW_CAST(CUIPropertiesBox)) + .def("cast_ScriptWnd", UI_WINDOW_CAST(CUIDialogWndEx)) + .def("cast_ScrollView", UI_WINDOW_CAST(CUIScrollView)) + .def("cast_ServerList", UI_WINDOW_CAST(CServerList)) + .def("cast_SleepStatic", UI_WINDOW_CAST(CUISleepStatic)) + .def("cast_SpinFlt", UI_WINDOW_CAST(CUISpinFlt)) + .def("cast_SpinNum", UI_WINDOW_CAST(CUISpinNum)) + .def("cast_SpinText", UI_WINDOW_CAST(CUISpinText)) + .def("cast_Static", UI_WINDOW_CAST(CUIStatic)) + .def("cast_TabButton", UI_WINDOW_CAST(CUITabButton)) + .def("cast_TabControl", UI_WINDOW_CAST(CUITabControl)) + .def("cast_TextWnd", UI_WINDOW_CAST(CUITextWnd)) + .def("cast_TrackBar", UI_WINDOW_CAST(CUITrackBar)) ]; module(L) @@ -409,5 +390,4 @@ void CUIWindow::script_register(lua_State* L) ]; } -#undef UI_WINDOW_EXPORT_CAST -#undef UI_WINDOW_SUBCLASSES +#undef UI_WINDOW_CAST From 9bd8aebea3fcde802d5f5488e0dcf31ae4ea6210 Mon Sep 17 00:00:00 2001 From: NLTP_ASHES <65969659+nltp-ashes@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:54:33 +0200 Subject: [PATCH 10/11] feature(find-child): remove custom shape code - wth is it even doing on this branch ffs --- src/xrGame/UIGameCustom.cpp | 70 ------------------------------ src/xrGame/UIGameCustom.h | 7 --- src/xrGame/UIGameCustom_script.cpp | 4 -- src/xrGame/ui_defs.h | 9 ---- 4 files changed, 90 deletions(-) diff --git a/src/xrGame/UIGameCustom.cpp b/src/xrGame/UIGameCustom.cpp index f6620d0100..cda19a3a30 100644 --- a/src/xrGame/UIGameCustom.cpp +++ b/src/xrGame/UIGameCustom.cpp @@ -105,80 +105,10 @@ void CUIGameCustom::Render() if (GameIndicatorsShown() && psHUD_Flags.is(HUD_DRAW | HUD_DRAW_RT)) UIMainIngameWnd->Draw(); } - DrawCustomShapes(); m_pMessagesWnd->Draw(); DoRenderDialogs(); } -void CUIGameCustom::AddCustomShapeToRender(LPCSTR name, ::luabind::object lua_shape) -{ - CustomShape shape{}; - shape.shader_name = ::luabind::object_cast(lua_shape["shader"]); - shape.texture_name = ::luabind::object_cast(lua_shape["texture"]); - shape.texture_color = ::luabind::object_cast(lua_shape["color"]); - shape.shader->create(shape.shader_name.c_str(), shape.texture_name.c_str()); - - custom_shapes.emplace(name, shape); -} - -void CUIGameCustom::RemoveCustomShapeToRender(LPCSTR name) -{ - auto it = custom_shapes.find(name); - if (it != custom_shapes.end()) - custom_shapes.erase(it); -} - -bool CUIGameCustom::HasCustomShape(LPCSTR name) -{ - auto it = custom_shapes.find(name); - return it != custom_shapes.end(); -} - -void CUIGameCustom::UpdateCustomShape(LPCSTR name, ::luabind::object lua_poly) -{ - CustomShape shape = custom_shapes[name]; - - int poly_size = 0; - for (auto i = lua_poly.begin(); i != lua_poly.end(); ++i) { - poly_size++; - } - shape.poly.resize(poly_size); - - for (int i = 1; i <= poly_size; i++) { - ::luabind::object lua_point = lua_poly[i]; - shape.poly[i - 1].pt = ::luabind::object_cast(lua_point["pt"]); - shape.poly[i - 1].uv = ::luabind::object_cast(lua_point["uv"]); - } - custom_shapes[name] = shape; -} - -void CUIGameCustom::DrawCustomShapes() -{ - for (const auto& pair : custom_shapes) - { - CustomShape shape = pair.second; - sPoly2D poly = shape.poly; - - if (poly.empty()) - { - continue; - } - - UIRender->SetShader(*shape.shader); - - UIRender->StartPrimitive(poly.size() * 3, IUIRender::ePrimitiveType::ptTriList, IUIRender::ePointType::pttTL); - - for (u32 idx = 0; idx < poly.size() - 2; ++idx) - { - UIRender->PushPoint(poly[0].pt.x, poly[0].pt.y, 0, shape.texture_color, poly[0].uv.x, poly[0].uv.y); - UIRender->PushPoint(poly[idx + 2].pt.x, poly[idx + 2].pt.y, 0, shape.texture_color, poly[idx + 2].uv.x, poly[idx + 2].uv.y); - UIRender->PushPoint(poly[idx + 1].pt.x, poly[idx + 1].pt.y, 0, shape.texture_color, poly[idx + 1].uv.x, poly[idx + 1].uv.y); - } - - UIRender->FlushPrimitive(); - } -} - StaticDrawableWrapper* CUIGameCustom::AddCustomStatic(const char* id, bool singleInstance) { if (singleInstance) diff --git a/src/xrGame/UIGameCustom.h b/src/xrGame/UIGameCustom.h index ddc6aafa32..fd95fd4451 100644 --- a/src/xrGame/UIGameCustom.h +++ b/src/xrGame/UIGameCustom.h @@ -131,13 +131,6 @@ class CUIGameCustom : void RemoveCustomStatic(const char* id); void CommonMessageOut(const char* text); - std::map custom_shapes; - void AddCustomShapeToRender(LPCSTR name, ::luabind::object lua_shape); - void RemoveCustomShapeToRender(LPCSTR name); - bool HasCustomShape(LPCSTR name); - void UpdateCustomShape(LPCSTR name, ::luabind::object lua_poly); - void DrawCustomShapes(); - virtual void ChangeTotalMoneyIndicator(const char* newMoneyString) { } diff --git a/src/xrGame/UIGameCustom_script.cpp b/src/xrGame/UIGameCustom_script.cpp index 3f64c98430..bdff0f98af 100644 --- a/src/xrGame/UIGameCustom_script.cpp +++ b/src/xrGame/UIGameCustom_script.cpp @@ -24,10 +24,6 @@ void CUIGameCustom::script_register(lua_State* L) .def("RemoveDialogToRender", &CUIGameCustom::RemoveDialogToRender) .def("AddCustomStatic", &CUIGameCustom::AddCustomStatic) .def("RemoveCustomStatic", &CUIGameCustom::RemoveCustomStatic) - .def("AddCustomShapeToRender", &CUIGameCustom::AddCustomShapeToRender) - .def("RemoveCustomShapeToRender", &CUIGameCustom::RemoveCustomShapeToRender) - .def("HasCustomShape", &CUIGameCustom::HasCustomShape) - .def("UpdateCustomShape", &CUIGameCustom::UpdateCustomShape) .def("HideActorMenu", &CUIGameCustom::HideActorMenu) //Alundaio .def("UpdateActorMenu", &CUIGameCustom::UpdateActorMenu) diff --git a/src/xrGame/ui_defs.h b/src/xrGame/ui_defs.h index 1cf930c77c..21b31cbe17 100644 --- a/src/xrGame/ui_defs.h +++ b/src/xrGame/ui_defs.h @@ -52,15 +52,6 @@ struct S2DVert #define UI_FRUSTUM_SAFE (UI_FRUSTUM_MAXPLANES*4) typedef svector sPoly2D; -struct CustomShape -{ - sPoly2D poly; - ui_shader shader; - std::string shader_name; - std::string texture_name; - u32 texture_color; -}; - class C2DFrustum { svector planes; From 0cfd3954d601c8c18306d9f8ad80aa5694a3663e Mon Sep 17 00:00:00 2001 From: NLTP_ASHES <65969659+nltp-ashes@users.noreply.github.com> Date: Sun, 30 Aug 2026 12:27:43 +0200 Subject: [PATCH 11/11] feature(find-child): update lua help --- gamedata/scripts/lua_help_ex.script | 54 +++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/gamedata/scripts/lua_help_ex.script b/gamedata/scripts/lua_help_ex.script index 97d0205257..b604f14fee 100644 --- a/gamedata/scripts/lua_help_ex.script +++ b/gamedata/scripts/lua_help_ex.script @@ -185,12 +185,6 @@ bool dltx_is_override(string sec, string line) } - // UI hud - // get_hud():GetWindow() - get_hud() { - CUIWindow GetWindow() - } - // Player hud // get_player_hud():set_hands("actor_hud_cs_exo") get_player_hud() { @@ -213,6 +207,54 @@ property dest_position // Fvector } + class CUIWindow { + CUIWindow FindChild() + + CUI3tButton cast_3tButton() + CUIActorMenu cast_ActorMenu() + CUIButton cast_Button() + CUICheckButton cast_CheckButton() + CUIComboBox cast_ComboBox() + CUICustomEdit cast_CustomEdit() + CUICustomSpin cast_CustomSpin() + CUIDialogWnd cast_DialogWnd() + CUIEditBox cast_EditBox() + CUIFrameLineWnd cast_FrameLineWnd() + CUIFrameWindow cast_FrameWindow() + UIHint cast_Hint() + CUIHudStatesWnd cast_HudStatesWnd() + CUIListBox cast_ListBox() + CUIListBoxItem cast_ListBoxItem() + CUIListBoxItemMsgChain cast_ListBoxItemMsgChain() + CUIMMShniaga cast_MMShniaga() + CUIMainIngameWnd cast_MainIngameWnd() + CUIMapInfo cast_MapInfo() + CUIMapList cast_MapList() + CUIMessageBox cast_MessageBox() + CUIMessageBoxEx cast_MessageBoxEx() + CUIMessagesWindow cast_MessagesWindow() + CUIMotionIcon cast_MotionIcon() + CUIPdaWnd cast_PdaWnd() + CUIProgressBar cast_ProgressBar() + CUIPropertiesBox cast_PropertiesBox() + CUIDialogWndEx cast_ScriptWnd() + CUIScrollView cast_ScrollView() + CServerList cast_ServerList() + CUISleepStatic cast_SleepStatic() + CUISpinFlt cast_SpinFlt() + CUISpinNum cast_SpinNum() + CUISpinText cast_SpinText() + CUIStatic cast_Static() + CUITabButton cast_TabButton() + CUITabControl cast_TabControl() + CUITextWnd cast_TextWnd() + CUITrackBar cast_TrackBar() + } + + class CUIGameCustom { + CUIWindow GetWindow() // get_hud():GetWindow() + } + class CUIProgressBar { CUIStatic GetProgressStatic() bool GetSnapNoDelay() Get the status of "SnapNoDelay"