feat: Add Sound/Music classes, keyboard state, version (#66, #160, #164)
Replace module-level audio functions with proper OOP API:
- mcrfpy.Sound: Wraps sf::SoundBuffer + sf::Sound for short effects
- mcrfpy.Music: Wraps sf::Music for streaming long tracks
- Both support: volume, loop, playing, duration, play/pause/stop
- Music adds position property for seeking
Add mcrfpy.keyboard singleton for real-time modifier state:
- shift, ctrl, alt, system properties (bool, read-only)
- Queries sf::Keyboard::isKeyPressed() directly
Add mcrfpy.__version__ = "1.0.0" for version identity
Remove old audio API entirely (no deprecation - unused in codebase):
- createSoundBuffer, loadMusic, playSound
- setMusicVolume, getMusicVolume, setSoundVolume, getSoundVolume
closes #66, closes #160, closes #164
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 16:24:27 -05:00
|
|
|
#pragma once
|
|
|
|
|
#include "Common.h"
|
|
|
|
|
#include "Python.h"
|
|
|
|
|
|
|
|
|
|
// Singleton keyboard state object
|
|
|
|
|
typedef struct {
|
|
|
|
|
PyObject_HEAD
|
|
|
|
|
} PyKeyboardObject;
|
|
|
|
|
|
|
|
|
|
class PyKeyboard
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
// Python getters - query real-time keyboard state via SFML
|
|
|
|
|
static PyObject* get_shift(PyObject* self, void* closure);
|
|
|
|
|
static PyObject* get_ctrl(PyObject* self, void* closure);
|
|
|
|
|
static PyObject* get_alt(PyObject* self, void* closure);
|
|
|
|
|
static PyObject* get_system(PyObject* self, void* closure);
|
|
|
|
|
|
|
|
|
|
static PyObject* repr(PyObject* obj);
|
|
|
|
|
static PyGetSetDef getsetters[];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
namespace mcrfpydef {
|
2026-02-16 20:58:09 -05:00
|
|
|
inline PyTypeObject PyKeyboardType = {
|
feat: Add Sound/Music classes, keyboard state, version (#66, #160, #164)
Replace module-level audio functions with proper OOP API:
- mcrfpy.Sound: Wraps sf::SoundBuffer + sf::Sound for short effects
- mcrfpy.Music: Wraps sf::Music for streaming long tracks
- Both support: volume, loop, playing, duration, play/pause/stop
- Music adds position property for seeking
Add mcrfpy.keyboard singleton for real-time modifier state:
- shift, ctrl, alt, system properties (bool, read-only)
- Queries sf::Keyboard::isKeyPressed() directly
Add mcrfpy.__version__ = "1.0.0" for version identity
Remove old audio API entirely (no deprecation - unused in codebase):
- createSoundBuffer, loadMusic, playSound
- setMusicVolume, getMusicVolume, setSoundVolume, getSoundVolume
closes #66, closes #160, closes #164
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 16:24:27 -05:00
|
|
|
.ob_base = {.ob_base = {.ob_refcnt = 1, .ob_type = NULL}, .ob_size = 0},
|
|
|
|
|
.tp_name = "mcrfpy.Keyboard",
|
|
|
|
|
.tp_basicsize = sizeof(PyKeyboardObject),
|
|
|
|
|
.tp_itemsize = 0,
|
|
|
|
|
.tp_repr = PyKeyboard::repr,
|
|
|
|
|
.tp_flags = Py_TPFLAGS_DEFAULT,
|
|
|
|
|
.tp_doc = PyDoc_STR("Keyboard state singleton for checking modifier keys"),
|
|
|
|
|
.tp_getset = PyKeyboard::getsetters,
|
|
|
|
|
.tp_new = PyType_GenericNew,
|
|
|
|
|
};
|
|
|
|
|
}
|