Skip to content

Commit d8819b0

Browse files
committed
Revert "Luabind: Force correct order of loading of CUIScriptWnd dependencies and remove wrapper that doesn't do anything"
This reverts commit 331b084.
1 parent 89393a9 commit d8819b0

File tree

3 files changed

+78
-10
lines changed

3 files changed

+78
-10
lines changed

src/xrGame/ui/UIScriptWnd_script.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,26 @@
22

33
// UI-controls
44
#include "UIScriptWnd.h"
5+
#include "uiscriptwnd_script.h"
56
#include "xrScriptEngine/ScriptExporter.hpp"
67
#include "xrScriptEngine/Functor.hpp"
78

89
using namespace luabind;
910

10-
SCRIPT_EXPORT(CUIDialogWndEx, (CUIDialogWnd, IFactoryObject), {
11-
module(luaState)[class_<CUIDialogWndEx, bases<CUIDialogWnd, IFactoryObject>>("CUIScriptWnd")
12-
.def("OnKeyboard", &CUIDialogWndEx::OnKeyboardAction)
13-
.def("Update", &CUIDialogWndEx::Update)
14-
.def("Dispatch", &CUIDialogWndEx::Dispatch)
15-
.def("AddCallback", (void (CUIDialogWndEx::*)(LPCSTR, s16, const functor<void>&, const object&)) &
16-
CUIDialogWndEx::AddCallback)
17-
.def("Register", (void (CUIDialogWndEx::*)(CUIWindow*, LPCSTR)) &CUIDialogWndEx::Register)
18-
.def("Load", &CUIDialogWndEx::Load)
19-
];
11+
extern export_class& script_register_ui_window1(export_class&);
12+
extern export_class& script_register_ui_window2(export_class&);
13+
14+
SCRIPT_EXPORT(CUIDialogWndEx, (), {
15+
export_class instance("CUIScriptWnd");
16+
17+
module(luaState)[script_register_ui_window2(script_register_ui_window1(instance)).def("Load", &BaseType::Load)];
2018
});
2119

20+
export_class& script_register_ui_window1(export_class& instance)
21+
{
22+
instance.def(constructor<>())
23+
.def("AddCallback", (void (BaseType::*)(LPCSTR, s16, const luabind::functor<void>&, const luabind::object&)) &
24+
BaseType::AddCallback)
25+
.def("Register", (void (BaseType::*)(CUIWindow*, LPCSTR)) & BaseType::Register);
26+
return (instance);
27+
}

src/xrGame/ui/uiscriptwnd_script.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#pragma once
2+
3+
template <typename T>
4+
struct CWrapperBase : public T, public luabind::wrap_base
5+
{
6+
typedef T inherited;
7+
typedef CWrapperBase<T> self_type;
8+
9+
virtual bool OnKeyboardAction(int dik, EUIMessages keyboard_action)
10+
{
11+
return luabind::call_member<bool>(this, "OnKeyboard", dik, keyboard_action);
12+
}
13+
static bool OnKeyboard_static(inherited* ptr, int dik, EUIMessages keyboard_action)
14+
{
15+
return ptr->self_type::inherited::OnKeyboardAction(dik, keyboard_action);
16+
}
17+
18+
virtual void Update() { luabind::call_member<void>(this, "Update"); }
19+
static void Update_static(inherited* ptr) { ptr->self_type::inherited::Update(); }
20+
virtual bool Dispatch(int cmd, int param) { return luabind::call_member<bool>(this, "Dispatch", cmd, param); }
21+
static bool Dispatch_static(inherited* ptr, int cmd, int param)
22+
{
23+
return ptr->self_type::inherited::Dispatch(cmd, param);
24+
}
25+
};
26+
27+
typedef CWrapperBase<CUIDialogWndEx> WrapType;
28+
typedef CUIDialogWndEx BaseType;
29+
30+
typedef luabind::class_<CUIDialogWndEx, luabind::bases<CUIDialogWnd, IFactoryObject>, luabind::default_holder, WrapType>
31+
export_class;

src/xrGame/ui/uiscriptwnd_script2.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "pch_script.h"
2+
3+
// UI-controls
4+
5+
#include "UIScriptWnd.h"
6+
#include "xrUICore/Buttons/UIButton.h"
7+
#include "xrUICore/MessageBox/UIMessageBox.h"
8+
#include "xrUICore/PropertiesBox/UIPropertiesBox.h"
9+
#include "xrUICore/Buttons/UICheckButton.h"
10+
#include "xrUICore/Buttons/UIRadioButton.h"
11+
#include "xrUICore/Static/UIStatic.h"
12+
#include "xrUICore/EditBox/UIEditBox.h"
13+
#include "xrUICore/Windows/UIFrameWindow.h"
14+
#include "xrUICore/Windows/UIFrameLineWnd.h"
15+
#include "xrUICore/ProgressBar/UIProgressBar.h"
16+
#include "xrUICore/TabControl/UITabControl.h"
17+
18+
#include "uiscriptwnd_script.h"
19+
20+
using namespace luabind;
21+
22+
#pragma optimize("s", on)
23+
export_class& script_register_ui_window2(export_class& instance)
24+
{
25+
instance.def("OnKeyboard", &BaseType::OnKeyboardAction, &WrapType::OnKeyboard_static)
26+
.def("Update", &BaseType::Update, &WrapType::Update_static)
27+
.def("Dispatch", &BaseType::Dispatch, &WrapType::Dispatch_static)
28+
29+
;
30+
return (instance);
31+
}

0 commit comments

Comments
 (0)