Skip to content

Commit

Permalink
Return removed CUIScriptWnd functionality from CS (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Feb 22, 2024
1 parent c6397dc commit aa1e4f0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/xrGame/ui/UIScriptWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ SCallbackInfo* CUIDialogWndEx::NewCallback()
return m_callbacks.back();
}

void CUIDialogWndEx::AddCallback(LPCSTR control_id, s16 evt, const luabind::functor<void> &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<void>& functor, const luabind::object& object)
{
SCallbackInfo* c = NewCallback();
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/ui/UIScriptWnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class CUIDialogWndEx : public CUIDialogWnd, public FactoryObjectBase
CUIDialogWndEx();
~CUIDialogWndEx() override;

void AddCallback(pcstr control_id, s16 event, const luabind::functor<void>& lua_function);
void AddCallback(pcstr control_id, s16 event, const luabind::functor<void>& functor, const luabind::object& object);

template <typename T>
Expand Down
19 changes: 17 additions & 2 deletions src/xrGame/ui/UIScriptWnd_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -206,13 +210,24 @@ SCRIPT_EXPORT(CUIDialogWndEx, (CUIDialogWnd, IFactoryObject),
[
class_<CUIDialogWndEx, luabind::bases<CUIDialogWnd, IFactoryObject>, 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<void>&)) &BaseType::AddCallback)
.def("AddCallback", (void(BaseType::*)(pcstr, s16, const luabind::functor<void>&, 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<CUIButton>)
.def("GetMessageBox", &BaseType::GetControl<CUIMessageBox>)
.def("GetPropertiesBox",&BaseType::GetControl<CUIPropertiesBox>)
.def("GetCheckButton", &BaseType::GetControl<CUICheckButton>)
.def("GetRadioButton", &BaseType::GetControl<CUIRadioButton>)
// .def("GetRadioGroup", &BaseType::GetControl<CUIRadioGroup>)
.def("GetStatic", &BaseType::GetControl<CUIStatic>)
.def("GetEditBox", &BaseType::GetControl<CUIEditBox>)
.def("GetDialogWnd", &BaseType::GetControl<CUIDialogWnd>)
Expand Down

0 comments on commit aa1e4f0

Please sign in to comment.