Skip to content

Commit 2918fa0

Browse files
committed
Merge branch 'event_test2'
2 parents 14177db + 3765bfb commit 2918fa0

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

Diff for: src/core/modules/events/events.h

+21-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
// Includes.
3232
//-----------------------------------------------------------------------------
3333
#include "igameevents.h"
34+
#include "modules/keyvalues/keyvalues.h"
3435

3536

3637
//-----------------------------------------------------------------------------
@@ -44,14 +45,33 @@
4445
//-----------------------------------------------------------------------------
4546
// IGameEvent extension class.
4647
//-----------------------------------------------------------------------------
47-
class IGameEventExt
48+
class IGameEventExt: public IGameEvent
4849
{
4950
public:
5051
static PyObject* GetString(IGameEvent* pEvent, const char* szKey, const char* szDefault)
5152
{
5253
const char* szValue = pEvent->GetString(szKey, szDefault);
5354
return PyUnicode_DecodeUTF8(szValue, strlen(szValue), "ignore");
5455
}
56+
57+
static KeyValues* GetVariables(IGameEvent* pEvent)
58+
{
59+
return ((IGameEventExt *) pEvent)->m_pVariables;
60+
}
61+
62+
static object __getitem__(IGameEvent* pEvent, const char* item)
63+
{
64+
return KeyValuesExt::__getitem__(GetVariables(pEvent), item);
65+
}
66+
67+
static void __setitem__(IGameEvent* pEvent, const char* item, object value)
68+
{
69+
KeyValuesExt::__setitem__(GetVariables(pEvent), item, value);
70+
}
71+
72+
public:
73+
void* m_pDescriptor;
74+
KeyValues* m_pVariables;
5575
};
5676

5777
//-----------------------------------------------------------------------------

Diff for: src/core/modules/events/events_wrap.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ void export_igameevent(scope _events)
133133
args("key_name", "value")
134134
)
135135

136+
.add_property("variables",
137+
make_function(IGameEventExt::GetVariables, reference_existing_object_policy())
138+
)
139+
140+
.def("__getitem__",
141+
&IGameEventExt::__getitem__
142+
)
143+
144+
.def("__setitem__",
145+
&IGameEventExt::__setitem__
146+
)
147+
136148
ADD_MEM_TOOLS(IGameEvent)
137149
;
138150

0 commit comments

Comments
 (0)