Skip to content

Commit 596e2b9

Browse files
author
nitrocaster
committed
Add script-specific CUIDialogWndEx::AddCallback overload.
1 parent 2f5ae7c commit 596e2b9

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

src/xrGame/ui/UIScriptWnd.cpp

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,60 +8,64 @@ CUIDialogWndEx::CUIDialogWndEx()
88

99
CUIDialogWndEx::~CUIDialogWndEx()
1010
{
11-
delete_data(m_callbacks);
11+
delete_data(m_callbacks);
1212
}
1313

14-
void CUIDialogWndEx::Register (CUIWindow* pChild)
14+
void CUIDialogWndEx::Register (CUIWindow* pChild)
1515
{
16-
pChild->SetMessageTarget(this);
16+
pChild->SetMessageTarget(this);
1717
}
1818

1919
void CUIDialogWndEx::Register(CUIWindow* pChild, LPCSTR name)
2020
{
21-
pChild->SetWindowName(name);
22-
pChild->SetMessageTarget(this);
21+
pChild->SetWindowName(name);
22+
pChild->SetMessageTarget(this);
2323
}
2424

2525
void CUIDialogWndEx::SendMessage(CUIWindow* pWnd, s16 msg, void* pData)
2626
{
27-
event_comparer ec(pWnd,msg);
27+
event_comparer ec(pWnd,msg);
2828

29-
CALLBACK_IT it = std::find_if(m_callbacks.begin(),m_callbacks.end(),ec);
30-
if(it==m_callbacks.end())
31-
return inherited::SendMessage(pWnd, msg, pData);
29+
CALLBACK_IT it = std::find_if(m_callbacks.begin(),m_callbacks.end(),ec);
30+
if(it==m_callbacks.end())
31+
return inherited::SendMessage(pWnd, msg, pData);
3232

33-
((*it)->m_callback)();
33+
((*it)->m_callback)();
3434

35-
// if ( (*it)->m_cpp_callback )
36-
// (*it)->m_cpp_callback(pData);
35+
// if ( (*it)->m_cpp_callback )
36+
// (*it)->m_cpp_callback(pData);
3737
}
3838

3939
bool CUIDialogWndEx::Load(LPCSTR xml_name)
4040
{
41-
return true;
41+
return true;
4242
}
4343

44-
SCallbackInfo* CUIDialogWndEx::NewCallback ()
44+
SCallbackInfo* CUIDialogWndEx::NewCallback ()
4545
{
46-
m_callbacks.push_back( xr_new<SCallbackInfo>() );
47-
return m_callbacks.back();
46+
m_callbacks.push_back( xr_new<SCallbackInfo>() );
47+
return m_callbacks.back();
4848
}
4949

50-
void CUIDialogWndEx::AddCallback (LPCSTR control_id, s16 evt, const luabind::functor<void> &functor, const luabind::object &object)
50+
void CUIDialogWndEx::AddCallback(LPCSTR control_id, s16 evt, const luabind::functor<void> &functor, const luabind::object &object)
51+
{ AddCallback(control_id, evt, functor, object); }
52+
53+
void CUIDialogWndEx::AddCallback(LPCSTR control_id, s16 evt,
54+
const luabind::object &functor, const luabind::object &object)
5155
{
52-
SCallbackInfo* c = NewCallback ();
53-
c->m_callback.set (functor,object);
54-
c->m_control_name = control_id;
55-
c->m_event = evt;
56+
SCallbackInfo* c = NewCallback ();
57+
c->m_callback.set (functor,object);
58+
c->m_control_name = control_id;
59+
c->m_event = evt;
5660
}
5761

5862

5963

6064
bool CUIDialogWndEx::OnKeyboardAction(int dik, EUIMessages keyboard_action)
6165
{
62-
return inherited::OnKeyboardAction(dik,keyboard_action);
66+
return inherited::OnKeyboardAction(dik,keyboard_action);
6367
}
6468
void CUIDialogWndEx::Update()
6569
{
66-
inherited::Update();
70+
inherited::Update();
6771
}

src/xrGame/ui/UIScriptWnd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ typedef CALLBACKS::iterator CALLBACK_IT;
2121
void Register (CUIWindow* pChild, LPCSTR name);
2222
CUIDialogWndEx ();
2323
virtual ~CUIDialogWndEx ();
24+
// XXX: declaration without implementation
2425
void AddCallback (LPCSTR control_id, s16 event, const luabind::functor<void> &lua_function);
2526
void AddCallback (LPCSTR control_id, s16 event, const luabind::functor<void> &functor, const luabind::object &object);
27+
void AddCallback(const char *controlId, s16 event, const luabind::object &functor, const luabind::object &object);
2628
virtual void Update ();
2729
virtual bool OnKeyboardAction (int dik, EUIMessages keyboard_action);
2830
virtual bool Dispatch (int cmd, int param) {return true;}

src/xrGame/ui/UIScriptWnd_script.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export_class &script_register_ui_window1(export_class &instance)
4040
{
4141
instance
4242
.def( constructor<>())
43-
.def("AddCallback", (void(BaseType::*)(LPCSTR, s16, const luabind::functor<void>&, const luabind::object&))&BaseType::AddCallback)
43+
.def("AddCallback", (void(BaseType::*)(LPCSTR, s16, const luabind::object&, const luabind::object&))&BaseType::AddCallback)
4444
.def("Register", (void (BaseType::*)(CUIWindow*,LPCSTR))&BaseType::Register);
4545
return (instance);
4646
}

0 commit comments

Comments
 (0)