feat: Add consistent Scene API with module-level properties (closes #151)
Replaces module-level scene functions with more Pythonic OO interface:
Scene class changes:
- Add `scene.children` property (replaces get_ui() method)
- Add `scene.on_key` getter/setter (matches on_click pattern)
- Remove get_ui() method
Module-level properties:
- Add `mcrfpy.current_scene` (getter returns Scene, setter activates)
- Add `mcrfpy.scenes` (read-only tuple of all Scene objects)
Implementation uses custom module type (McRFPyModuleType) inheriting
from PyModule_Type with tp_setattro for property assignment support.
New usage:
scene = mcrfpy.Scene("game")
mcrfpy.current_scene = scene
scene.on_key = handler
ui = scene.children
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
de739037f0
commit
71c91e19a5
6 changed files with 406 additions and 27 deletions
|
|
@ -98,6 +98,11 @@ public:
|
|||
static void updatePythonScenes(float dt);
|
||||
static void triggerResize(int width, int height);
|
||||
|
||||
// #151: Module-level scene property accessors
|
||||
static PyObject* api_get_current_scene();
|
||||
static int api_set_current_scene(PyObject* value);
|
||||
static PyObject* api_get_scenes();
|
||||
|
||||
// Exception handling - signal game loop to exit on unhandled Python exceptions
|
||||
static std::atomic<bool> exception_occurred;
|
||||
static std::atomic<int> exit_code;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue