File tree 2 files changed +33
-1
lines changed
2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 31
31
// Includes.
32
32
// -----------------------------------------------------------------------------
33
33
#include " igameevents.h"
34
+ #include " modules/keyvalues/keyvalues.h"
34
35
35
36
36
37
// -----------------------------------------------------------------------------
44
45
// -----------------------------------------------------------------------------
45
46
// IGameEvent extension class.
46
47
// -----------------------------------------------------------------------------
47
- class IGameEventExt
48
+ class IGameEventExt : public IGameEvent
48
49
{
49
50
public:
50
51
static PyObject* GetString (IGameEvent* pEvent, const char * szKey, const char * szDefault)
51
52
{
52
53
const char * szValue = pEvent->GetString (szKey, szDefault);
53
54
return PyUnicode_DecodeUTF8 (szValue, strlen (szValue), " ignore" );
54
55
}
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;
55
75
};
56
76
57
77
// -----------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -133,6 +133,18 @@ void export_igameevent(scope _events)
133
133
args (" key_name" , " value" )
134
134
)
135
135
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
+
136
148
ADD_MEM_TOOLS (IGameEvent)
137
149
;
138
150
You can’t perform that action at this time.
0 commit comments