From 8d52ad839ce2f35856c8d6869b8a79095dd6ab13 Mon Sep 17 00:00:00 2001 From: nitrocaster Date: Thu, 26 Nov 2015 15:15:10 +0300 Subject: [PATCH] Revert "Add script-specific CUIDialogWndEx::AddCallback overload." No need for this overload since lua function can be implicitly converted to luabind::functor. This reverts commit 596e2b98c4502c74f612dd71cca8ea420c11559e. --- src/xrGame/ui/UIScriptWnd.cpp | 50 +++++++++++++--------------- src/xrGame/ui/UIScriptWnd.h | 2 -- src/xrGame/ui/UIScriptWnd_script.cpp | 2 +- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/xrGame/ui/UIScriptWnd.cpp b/src/xrGame/ui/UIScriptWnd.cpp index 57c3f8a5bdb..12ee2221410 100644 --- a/src/xrGame/ui/UIScriptWnd.cpp +++ b/src/xrGame/ui/UIScriptWnd.cpp @@ -8,64 +8,60 @@ CUIDialogWndEx::CUIDialogWndEx() CUIDialogWndEx::~CUIDialogWndEx() { - delete_data(m_callbacks); + delete_data(m_callbacks); } -void CUIDialogWndEx::Register (CUIWindow* pChild) +void CUIDialogWndEx::Register (CUIWindow* pChild) { - pChild->SetMessageTarget(this); + pChild->SetMessageTarget(this); } void CUIDialogWndEx::Register(CUIWindow* pChild, LPCSTR name) { - pChild->SetWindowName(name); - pChild->SetMessageTarget(this); + pChild->SetWindowName(name); + pChild->SetMessageTarget(this); } void CUIDialogWndEx::SendMessage(CUIWindow* pWnd, s16 msg, void* pData) { - event_comparer ec(pWnd,msg); + event_comparer ec(pWnd,msg); - CALLBACK_IT it = std::find_if(m_callbacks.begin(),m_callbacks.end(),ec); - if(it==m_callbacks.end()) - return inherited::SendMessage(pWnd, msg, pData); + CALLBACK_IT it = std::find_if(m_callbacks.begin(),m_callbacks.end(),ec); + if(it==m_callbacks.end()) + return inherited::SendMessage(pWnd, msg, pData); - ((*it)->m_callback)(); + ((*it)->m_callback)(); -// if ( (*it)->m_cpp_callback ) -// (*it)->m_cpp_callback(pData); +// if ( (*it)->m_cpp_callback ) +// (*it)->m_cpp_callback(pData); } bool CUIDialogWndEx::Load(LPCSTR xml_name) { - return true; + return true; } -SCallbackInfo* CUIDialogWndEx::NewCallback () +SCallbackInfo* CUIDialogWndEx::NewCallback () { - m_callbacks.push_back( xr_new() ); - return m_callbacks.back(); + m_callbacks.push_back( xr_new() ); + return m_callbacks.back(); } -void CUIDialogWndEx::AddCallback(LPCSTR control_id, s16 evt, const luabind::functor &functor, const luabind::object &object) -{ AddCallback(control_id, evt, functor, object); } - -void CUIDialogWndEx::AddCallback(LPCSTR control_id, s16 evt, - const luabind::object &functor, const luabind::object &object) +void CUIDialogWndEx::AddCallback (LPCSTR control_id, s16 evt, const luabind::functor &functor, const luabind::object &object) { - SCallbackInfo* c = NewCallback (); - c->m_callback.set (functor,object); - c->m_control_name = control_id; - c->m_event = evt; + SCallbackInfo* c = NewCallback (); + c->m_callback.set (functor,object); + c->m_control_name = control_id; + c->m_event = evt; } bool CUIDialogWndEx::OnKeyboardAction(int dik, EUIMessages keyboard_action) { - return inherited::OnKeyboardAction(dik,keyboard_action); + return inherited::OnKeyboardAction(dik,keyboard_action); } void CUIDialogWndEx::Update() { - inherited::Update(); + inherited::Update(); } diff --git a/src/xrGame/ui/UIScriptWnd.h b/src/xrGame/ui/UIScriptWnd.h index c4dfd5f67f0..901f3307b34 100644 --- a/src/xrGame/ui/UIScriptWnd.h +++ b/src/xrGame/ui/UIScriptWnd.h @@ -21,10 +21,8 @@ typedef CALLBACKS::iterator CALLBACK_IT; void Register (CUIWindow* pChild, LPCSTR name); CUIDialogWndEx (); virtual ~CUIDialogWndEx (); - // XXX: declaration without implementation void AddCallback (LPCSTR control_id, s16 event, const luabind::functor &lua_function); void AddCallback (LPCSTR control_id, s16 event, const luabind::functor &functor, const luabind::object &object); - void AddCallback(const char *controlId, s16 event, const luabind::object &functor, const luabind::object &object); virtual void Update (); virtual bool OnKeyboardAction (int dik, EUIMessages keyboard_action); virtual bool Dispatch (int cmd, int param) {return true;} diff --git a/src/xrGame/ui/UIScriptWnd_script.cpp b/src/xrGame/ui/UIScriptWnd_script.cpp index b2dd3d46f6d..795c31476fc 100644 --- a/src/xrGame/ui/UIScriptWnd_script.cpp +++ b/src/xrGame/ui/UIScriptWnd_script.cpp @@ -40,7 +40,7 @@ export_class &script_register_ui_window1(export_class &instance) { instance .def( constructor<>()) - .def("AddCallback", (void(BaseType::*)(LPCSTR, s16, const luabind::object&, const luabind::object&))&BaseType::AddCallback) + .def("AddCallback", (void(BaseType::*)(LPCSTR, s16, const luabind::functor&, const luabind::object&))&BaseType::AddCallback) .def("Register", (void (BaseType::*)(CUIWindow*,LPCSTR))&BaseType::Register); return (instance); }