add __ne__ support to enum types for input
This commit is contained in:
parent
b093e087e1
commit
322beeaf78
5 changed files with 46 additions and 6 deletions
|
|
@ -37,6 +37,9 @@
|
|||
#include "3d/Model3D.h" // 3D model resource
|
||||
#include "3d/Billboard.h" // Billboard sprites
|
||||
#include "3d/PyVoxelGrid.h" // Voxel grid for 3D structures (Milestone 9)
|
||||
#include "tiled/PyTileSetFile.h" // Tiled tileset loading
|
||||
#include "tiled/PyTileMapFile.h" // Tiled tilemap loading
|
||||
#include "tiled/PyWangSet.h" // Wang auto-tile sets
|
||||
#include "McRogueFaceVersion.h"
|
||||
#include "GameEngine.h"
|
||||
// ImGui is only available for SFML builds
|
||||
|
|
@ -486,6 +489,11 @@ PyObject* PyInit_mcrfpy()
|
|||
&mcrfpydef::PyPropertyBindingType,
|
||||
&mcrfpydef::PyCallableBindingType,
|
||||
|
||||
/*tiled map/tileset loading*/
|
||||
&mcrfpydef::PyTileSetFileType,
|
||||
&mcrfpydef::PyTileMapFileType,
|
||||
&mcrfpydef::PyWangSetType,
|
||||
|
||||
nullptr};
|
||||
|
||||
// Types that are used internally but NOT exported to module namespace (#189)
|
||||
|
|
@ -559,6 +567,14 @@ PyObject* PyInit_mcrfpy()
|
|||
// Set up PyUniformCollectionType methods (#106)
|
||||
mcrfpydef::PyUniformCollectionType.tp_methods = ::PyUniformCollectionType::methods;
|
||||
|
||||
// Set up Tiled types methods and getsetters
|
||||
mcrfpydef::PyTileSetFileType.tp_methods = PyTileSetFile::methods;
|
||||
mcrfpydef::PyTileSetFileType.tp_getset = PyTileSetFile::getsetters;
|
||||
mcrfpydef::PyTileMapFileType.tp_methods = PyTileMapFile::methods;
|
||||
mcrfpydef::PyTileMapFileType.tp_getset = PyTileMapFile::getsetters;
|
||||
mcrfpydef::PyWangSetType.tp_methods = PyWangSet::methods;
|
||||
mcrfpydef::PyWangSetType.tp_getset = PyWangSet::getsetters;
|
||||
|
||||
// Set up weakref support for all types that need it
|
||||
PyTimerType.tp_weaklistoffset = offsetof(PyTimerObject, weakreflist);
|
||||
PyUIFrameType.tp_weaklistoffset = offsetof(PyUIFrameObject, weakreflist);
|
||||
|
|
|
|||
|
|
@ -69,6 +69,14 @@ def _InputState_eq(self, other):
|
|||
return int.__eq__(int(self), other)
|
||||
|
||||
InputState.__eq__ = _InputState_eq
|
||||
|
||||
def _InputState_ne(self, other):
|
||||
result = type(self).__eq__(self, other)
|
||||
if result is NotImplemented:
|
||||
return result
|
||||
return not result
|
||||
|
||||
InputState.__ne__ = _InputState_ne
|
||||
InputState.__hash__ = lambda self: hash(int(self))
|
||||
InputState.__repr__ = lambda self: f"{type(self).__name__}.{self.name}"
|
||||
InputState.__str__ = lambda self: self.name
|
||||
|
|
|
|||
|
|
@ -217,6 +217,14 @@ def _Key_eq(self, other):
|
|||
return int.__eq__(int(self), other)
|
||||
|
||||
Key.__eq__ = _Key_eq
|
||||
|
||||
def _Key_ne(self, other):
|
||||
result = type(self).__eq__(self, other)
|
||||
if result is NotImplemented:
|
||||
return result
|
||||
return not result
|
||||
|
||||
Key.__ne__ = _Key_ne
|
||||
Key.__hash__ = lambda self: hash(int(self))
|
||||
Key.__repr__ = lambda self: f"{type(self).__name__}.{self.name}"
|
||||
Key.__str__ = lambda self: self.name
|
||||
|
|
|
|||
|
|
@ -89,6 +89,14 @@ def _MouseButton_eq(self, other):
|
|||
return int.__eq__(int(self), other)
|
||||
|
||||
MouseButton.__eq__ = _MouseButton_eq
|
||||
|
||||
def _MouseButton_ne(self, other):
|
||||
result = type(self).__eq__(self, other)
|
||||
if result is NotImplemented:
|
||||
return result
|
||||
return not result
|
||||
|
||||
MouseButton.__ne__ = _MouseButton_ne
|
||||
MouseButton.__hash__ = lambda self: hash(int(self))
|
||||
MouseButton.__repr__ = lambda self: f"{type(self).__name__}.{self.name}"
|
||||
MouseButton.__str__ = lambda self: self.name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue