Skip to content

Commit

Permalink
Revert "Luabind: Force correct order of loading of CUIScriptWnd depen…
Browse files Browse the repository at this point in the history
…dencies and remove wrapper that doesn't do anything"

This reverts commit 331b084.
  • Loading branch information
Xottab-DUTY committed Oct 11, 2018
1 parent 89393a9 commit d8819b0
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/xrGame/ui/UIScriptWnd_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@

// UI-controls
#include "UIScriptWnd.h"
#include "uiscriptwnd_script.h"
#include "xrScriptEngine/ScriptExporter.hpp"
#include "xrScriptEngine/Functor.hpp"

using namespace luabind;

SCRIPT_EXPORT(CUIDialogWndEx, (CUIDialogWnd, IFactoryObject), {
module(luaState)[class_<CUIDialogWndEx, bases<CUIDialogWnd, IFactoryObject>>("CUIScriptWnd")
.def("OnKeyboard", &CUIDialogWndEx::OnKeyboardAction)
.def("Update", &CUIDialogWndEx::Update)
.def("Dispatch", &CUIDialogWndEx::Dispatch)
.def("AddCallback", (void (CUIDialogWndEx::*)(LPCSTR, s16, const functor<void>&, const object&)) &
CUIDialogWndEx::AddCallback)
.def("Register", (void (CUIDialogWndEx::*)(CUIWindow*, LPCSTR)) &CUIDialogWndEx::Register)
.def("Load", &CUIDialogWndEx::Load)
];
extern export_class& script_register_ui_window1(export_class&);
extern export_class& script_register_ui_window2(export_class&);

SCRIPT_EXPORT(CUIDialogWndEx, (), {
export_class instance("CUIScriptWnd");

module(luaState)[script_register_ui_window2(script_register_ui_window1(instance)).def("Load", &BaseType::Load)];
});

export_class& script_register_ui_window1(export_class& instance)
{
instance.def(constructor<>())
.def("AddCallback", (void (BaseType::*)(LPCSTR, s16, const luabind::functor<void>&, const luabind::object&)) &
BaseType::AddCallback)
.def("Register", (void (BaseType::*)(CUIWindow*, LPCSTR)) & BaseType::Register);
return (instance);
}
31 changes: 31 additions & 0 deletions src/xrGame/ui/uiscriptwnd_script.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

template <typename T>
struct CWrapperBase : public T, public luabind::wrap_base
{
typedef T inherited;
typedef CWrapperBase<T> self_type;

virtual bool OnKeyboardAction(int dik, EUIMessages keyboard_action)
{
return luabind::call_member<bool>(this, "OnKeyboard", dik, keyboard_action);
}
static bool OnKeyboard_static(inherited* ptr, int dik, EUIMessages keyboard_action)
{
return ptr->self_type::inherited::OnKeyboardAction(dik, keyboard_action);
}

virtual void Update() { luabind::call_member<void>(this, "Update"); }
static void Update_static(inherited* ptr) { ptr->self_type::inherited::Update(); }
virtual bool Dispatch(int cmd, int param) { return luabind::call_member<bool>(this, "Dispatch", cmd, param); }
static bool Dispatch_static(inherited* ptr, int cmd, int param)
{
return ptr->self_type::inherited::Dispatch(cmd, param);
}
};

typedef CWrapperBase<CUIDialogWndEx> WrapType;
typedef CUIDialogWndEx BaseType;

typedef luabind::class_<CUIDialogWndEx, luabind::bases<CUIDialogWnd, IFactoryObject>, luabind::default_holder, WrapType>
export_class;
31 changes: 31 additions & 0 deletions src/xrGame/ui/uiscriptwnd_script2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "pch_script.h"

// UI-controls

#include "UIScriptWnd.h"
#include "xrUICore/Buttons/UIButton.h"
#include "xrUICore/MessageBox/UIMessageBox.h"
#include "xrUICore/PropertiesBox/UIPropertiesBox.h"
#include "xrUICore/Buttons/UICheckButton.h"
#include "xrUICore/Buttons/UIRadioButton.h"
#include "xrUICore/Static/UIStatic.h"
#include "xrUICore/EditBox/UIEditBox.h"
#include "xrUICore/Windows/UIFrameWindow.h"
#include "xrUICore/Windows/UIFrameLineWnd.h"
#include "xrUICore/ProgressBar/UIProgressBar.h"
#include "xrUICore/TabControl/UITabControl.h"

#include "uiscriptwnd_script.h"

using namespace luabind;

#pragma optimize("s", on)
export_class& script_register_ui_window2(export_class& instance)
{
instance.def("OnKeyboard", &BaseType::OnKeyboardAction, &WrapType::OnKeyboard_static)
.def("Update", &BaseType::Update, &WrapType::Update_static)
.def("Dispatch", &BaseType::Dispatch, &WrapType::Dispatch_static)

;
return (instance);
}

0 comments on commit d8819b0

Please sign in to comment.