From aa1e4f02054af431e7aac6c94ddf6c95d64cacc3 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Wed, 21 Feb 2024 01:11:29 +0500 Subject: [PATCH] Return removed CUIScriptWnd functionality from CS (#382) --- src/xrGame/ui/UIScriptWnd.cpp | 8 ++++++++ src/xrGame/ui/UIScriptWnd.h | 1 + src/xrGame/ui/UIScriptWnd_script.cpp | 19 +++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/xrGame/ui/UIScriptWnd.cpp b/src/xrGame/ui/UIScriptWnd.cpp index 997d6453bcf..19d72749b8b 100644 --- a/src/xrGame/ui/UIScriptWnd.cpp +++ b/src/xrGame/ui/UIScriptWnd.cpp @@ -33,6 +33,14 @@ SCallbackInfo* CUIDialogWndEx::NewCallback() return m_callbacks.back(); } +void CUIDialogWndEx::AddCallback(LPCSTR control_id, s16 evt, const luabind::functor &lua_function) +{ + SCallbackInfo* c = NewCallback (); + c->m_callback.set(lua_function); + c->m_control_name = control_id; + c->m_event = evt; +} + void CUIDialogWndEx::AddCallback(pcstr control_id, s16 evt, const luabind::functor& functor, const luabind::object& object) { SCallbackInfo* c = NewCallback(); diff --git a/src/xrGame/ui/UIScriptWnd.h b/src/xrGame/ui/UIScriptWnd.h index bff00978157..16e96ae1370 100644 --- a/src/xrGame/ui/UIScriptWnd.h +++ b/src/xrGame/ui/UIScriptWnd.h @@ -24,6 +24,7 @@ class CUIDialogWndEx : public CUIDialogWnd, public FactoryObjectBase CUIDialogWndEx(); ~CUIDialogWndEx() override; + void AddCallback(pcstr control_id, s16 event, const luabind::functor& lua_function); void AddCallback(pcstr control_id, s16 event, const luabind::functor& functor, const luabind::object& object); template diff --git a/src/xrGame/ui/UIScriptWnd_script.cpp b/src/xrGame/ui/UIScriptWnd_script.cpp index ebd727568a1..3b6ee495705 100644 --- a/src/xrGame/ui/UIScriptWnd_script.cpp +++ b/src/xrGame/ui/UIScriptWnd_script.cpp @@ -4,6 +4,10 @@ #include "xrUICore/ListWnd/UIListWnd.h" #include "xrUICore/TabControl/UITabControl.h" +#include "xrUICore/Buttons/UICheckButton.h" +#include "xrUICore/Buttons/UIRadioButton.h" +#include "xrUICore/MessageBox/UIMessageBox.h" +#include "xrUICore/PropertiesBox/UIPropertiesBox.h" #include "xrScriptEngine/ScriptExporter.hpp" @@ -206,13 +210,24 @@ SCRIPT_EXPORT(CUIDialogWndEx, (CUIDialogWnd, IFactoryObject), [ class_, luabind::default_holder, WrapType>("CUIScriptWnd") .def(constructor<>()) - .def("AddCallback", &BaseType::AddCallback) - .def("Register", (void (BaseType::*)(CUIWindow*, pcstr)) & BaseType::Register) + + .def("AddCallback", (void(BaseType::*)(pcstr, s16, const luabind::functor&)) &BaseType::AddCallback) + .def("AddCallback", (void(BaseType::*)(pcstr, s16, const luabind::functor&, const luabind::object&)) &BaseType::AddCallback) + + .def("Register", (void (BaseType::*)(CUIWindow*)) &BaseType::Register) + .def("Register", (void (BaseType::*)(CUIWindow*, pcstr)) &BaseType::Register) + .def("OnKeyboard", &BaseType::OnKeyboardAction, &WrapType::OnKeyboard_static) .def("Update", &BaseType::Update, &WrapType::Update_static) .def("Dispatch", &BaseType::Dispatch, &WrapType::Dispatch_static) .def("Load", &BaseType::Load) + .def("GetButton", &BaseType::GetControl) + .def("GetMessageBox", &BaseType::GetControl) + .def("GetPropertiesBox",&BaseType::GetControl) + .def("GetCheckButton", &BaseType::GetControl) + .def("GetRadioButton", &BaseType::GetControl) + // .def("GetRadioGroup", &BaseType::GetControl) .def("GetStatic", &BaseType::GetControl) .def("GetEditBox", &BaseType::GetControl) .def("GetDialogWnd", &BaseType::GetControl)