From 08d02868181321bdf8d1fcb29a21b515507cf6d2 Mon Sep 17 00:00:00 2001 From: NLTP_ASHES <65969659+nltp-ashes@users.noreply.github.com> Date: Thu, 10 Sep 2026 22:30:14 +0200 Subject: [PATCH 1/2] feature(lua-pp-exports): export pp functions to lua - Created and exported extra functions regarding PPEs; - Fixed broken links in lua_help_ex and lua_help_imgui; --- gamedata/scripts/lua_help_ex.script | 11 +++++- gamedata/scripts/lua_help_imgui.script | 2 +- src/xrGame/PostprocessAnimator.cpp | 5 +++ src/xrGame/PostprocessAnimator.h | 1 + src/xrGame/level_script.cpp | 54 ++++++++++++++++++-------- 5 files changed, 54 insertions(+), 19 deletions(-) diff --git a/gamedata/scripts/lua_help_ex.script b/gamedata/scripts/lua_help_ex.script index 97d0205257..5866ff623c 100644 --- a/gamedata/scripts/lua_help_ex.script +++ b/gamedata/scripts/lua_help_ex.script @@ -320,6 +320,7 @@ sphere, box, } + debug_render { DBG_ScriptObject* add_object(u32 id, DebugRenderType type) DBG_ScriptObject* add_object(LPCSTR id, DebugRenderType type) @@ -383,6 +384,7 @@ eDXE_BC7 = 3, eDXE_undefined = 4, } + level { float get_music_volume() void set_music_volume(float) @@ -463,13 +465,18 @@ // } // level.add_bullet(t) - // Script Attachments + // Script Attachments function add_attachment(string, string) function get_attachment(string) function remove_attachment(string) function remove_attachment(script_attachment) function iterate_attachments(function) + // Post-Process Effectors + float get_pp_effector_factor(int id) + float get_pp_effector_length(int id) + bool check_pp_effector(int id) + // MT only function scheduler_flush(bool) } @@ -1195,5 +1202,5 @@ property userdata } - Script Attachment Guide: https://igigog.github.io/anomaly-modding-book/tutorials/scripting/script-attachments.html + Script Attachment Guide: https://anomaly-modding-book.netlify.app/docs/tutorials/scripting/script-attachments --]] diff --git a/gamedata/scripts/lua_help_imgui.script b/gamedata/scripts/lua_help_imgui.script index 8c72902e35..bc1f1d9b2d 100644 --- a/gamedata/scripts/lua_help_imgui.script +++ b/gamedata/scripts/lua_help_imgui.script @@ -1,4 +1,4 @@ --- Basic ImGui scripting guide: https://igigog.github.io/anomaly-modding-book/tutorials/scripting/imgui.html +-- Basic ImGui scripting guide: https://anomaly-modding-book.netlify.app/docs/tutorials/scripting/imgui --[[ namespace ImGui { diff --git a/src/xrGame/PostprocessAnimator.cpp b/src/xrGame/PostprocessAnimator.cpp index d84f254b04..da44af208d 100644 --- a/src/xrGame/PostprocessAnimator.cpp +++ b/src/xrGame/PostprocessAnimator.cpp @@ -173,6 +173,11 @@ void CPostprocessAnimator::SetDesiredFactor(float f, float sp) VERIFY(_valid(m_dest_factor)); }; +float CPostprocessAnimator::GetCurrentFactor() +{ + return m_factor; +}; + void CPostprocessAnimator::SetCurrentFactor(float f) { m_factor = f; diff --git a/src/xrGame/PostprocessAnimator.h b/src/xrGame/PostprocessAnimator.h index cb29fb92d4..a7d31681a7 100644 --- a/src/xrGame/PostprocessAnimator.h +++ b/src/xrGame/PostprocessAnimator.h @@ -175,6 +175,7 @@ class CPostprocessAnimator IC LPCSTR Name() { return *m_Name; } virtual void Stop(float speed); void SetDesiredFactor(float f, float sp); + float GetCurrentFactor(); void SetCurrentFactor(float f); void SetCyclic(bool b) { m_bCyclic = b; } float GetLength(); diff --git a/src/xrGame/level_script.cpp b/src/xrGame/level_script.cpp index 63dcf5466e..23edc74a50 100644 --- a/src/xrGame/level_script.cpp +++ b/src/xrGame/level_script.cpp @@ -1033,16 +1033,38 @@ void remove_pp_effector(int id) void set_pp_effector_factor(int id, float f, float f_sp) { - CPostprocessAnimator* pp = smart_cast(Actor()->Cameras().GetPPEffector((EEffectorPPType)id)); + CPostprocessAnimator* pp = smart_cast(Actor()->Cameras().GetPPEffector((EEffectorPPType)id)); - if (pp) pp->SetDesiredFactor(f, f_sp); + if (pp) pp->SetDesiredFactor(f, f_sp); } void set_pp_effector_factor2(int id, float f) { - CPostprocessAnimator* pp = smart_cast(Actor()->Cameras().GetPPEffector((EEffectorPPType)id)); + CPostprocessAnimator* pp = smart_cast(Actor()->Cameras().GetPPEffector((EEffectorPPType)id)); + + if (pp) pp->SetCurrentFactor(f); +} + +bool check_pp_effector(int id) +{ + CPostprocessAnimator* pp = smart_cast(Actor()->Cameras().GetPPEffector((EEffectorPPType)id)); + if (pp) + { + return pp->Valid(); + } + return false; +} - if (pp) pp->SetCurrentFactor(f); +float get_pp_effector_factor(int id) +{ + CPostprocessAnimator* pp = smart_cast(Actor()->Cameras().GetPPEffector((EEffectorPPType)id)); + return pp ? pp->GetCurrentFactor() : 0.0f; +} + +float get_pp_effector_length(int id) +{ + CPostprocessAnimator* pp = smart_cast(Actor()->Cameras().GetPPEffector((EEffectorPPType)id)); + return pp ? pp->GetLength() : 0.0f; } #include "relation_registry.h" @@ -2532,7 +2554,6 @@ void CLevel::script_register(lua_State* L) def("map_add_object_spot_ser", map_add_object_spot_ser), def("map_add_object_spot", map_add_object_spot), - //- def("map_add_object_spot_complex", map_add_object_spot_complex), def("map_remove_object_spot", map_remove_object_spot), def("map_has_object_spot", map_has_object_spot), def("map_change_spot_hint", map_change_spot_hint), @@ -2554,13 +2575,10 @@ void CLevel::script_register(lua_State* L) def("show_indicators", show_indicators), def("show_weapon", show_weapon), def("add_call", ((void (*)(const ::luabind::functor&, const ::luabind::functor&))&add_call)), - def("add_call", ((void (*)(const ::luabind::object&, const ::luabind::functor&, - const ::luabind::functor&))&add_call)), + def("add_call", ((void (*)(const ::luabind::object&, const ::luabind::functor&, const ::luabind::functor&))&add_call)), def("add_call", ((void (*)(const ::luabind::object&, LPCSTR, LPCSTR))&add_call)), def("remove_call", ((void (*)(const ::luabind::functor&, const ::luabind::functor&))&remove_call)), - def("remove_call", - ((void (*)(const ::luabind::object&, const ::luabind::functor&, const ::luabind::functor&))& - remove_call)), + def("remove_call", ((void (*)(const ::luabind::object&, const ::luabind::functor&, const ::luabind::functor&))&remove_call)), def("remove_call", ((void (*)(const ::luabind::object&, LPCSTR, LPCSTR))&remove_call)), def("remove_calls_for_object", remove_calls_for_object), def("present", is_level_present), @@ -2578,10 +2596,6 @@ void CLevel::script_register(lua_State* L) def("set_snd_volume", &set_snd_volume), def("get_music_volume", &get_music_volume), def("set_music_volume", &set_music_volume), - def("add_cam_effector", ((float (*)(LPCSTR, int, bool, LPCSTR))&add_cam_effector)), - def("add_cam_effector", ((float (*)(LPCSTR, int, bool, LPCSTR, float))&add_cam_effector)), - def("add_cam_effector", ((float (*)(LPCSTR, int, bool, LPCSTR, float, bool))&add_cam_effector)), - def("add_cam_effector", ((float (*)(LPCSTR, int, bool, LPCSTR, float, bool, float))&add_cam_effector)), // demonized: Set custom camera position and direction with movement smoothing (for cutscenes, etc) def("set_cam_custom_position_direction", ((void (*)(Fvector&, Fvector&, unsigned int, bool, bool))& set_cam_position_direction)), @@ -2591,15 +2605,23 @@ void CLevel::script_register(lua_State* L) def("set_cam_custom_position_direction", ((void (*)(Fvector&, Fvector&))&set_cam_position_direction)), def("remove_cam_custom_position_direction", &remove_cam_position_direction), + def("add_cam_effector", ((float (*)(LPCSTR, int, bool, LPCSTR))& add_cam_effector)), + def("add_cam_effector", ((float (*)(LPCSTR, int, bool, LPCSTR, float))& add_cam_effector)), + def("add_cam_effector", ((float (*)(LPCSTR, int, bool, LPCSTR, float, bool))& add_cam_effector)), + def("add_cam_effector", ((float (*)(LPCSTR, int, bool, LPCSTR, float, bool, float))& add_cam_effector)), def("remove_cam_effector", &remove_cam_effector), def("set_cam_effector_factor", &set_cam_effector_factor), def("get_cam_effector_factor", &get_cam_effector_factor), def("get_cam_effector_length", &get_cam_effector_length), def("check_cam_effector", &check_cam_effector), + def("add_pp_effector", &add_pp_effector), + def("remove_pp_effector", &remove_pp_effector), def("set_pp_effector_factor", &set_pp_effector_factor), - def("set_pp_effector_factor", &set_pp_effector_factor2), - def("remove_pp_effector", &remove_pp_effector), + def("set_pp_effector_factor", &set_pp_effector_factor2), + def("get_pp_effector_factor", &get_pp_effector_factor), + def("get_pp_effector_length", &get_pp_effector_length), + def("check_pp_effector", &check_pp_effector), def("add_complex_effector", &add_complex_effector), def("remove_complex_effector", &remove_complex_effector), From 762cd38ee0af74c325921c82e7c2def936e7c597 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 2/2] 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;