Timer System Refactor: Stopwatch-like semantics and mcrfpy.timers collection #173
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#173
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Refactor the Timer system to provide cleaner, more intuitive semantics before v1.0 release. The current timer implementation has confusing state management where cancelled/one-shot timers become unusable husks.
Current Problems
cancel()destroys the callback and resets the shared_ptr, making the timer object uselessmcrfpy.timerslike we canmcrfpy.scenesactiveis read-only: Can't usetimer.active = Trueto start/resumestart=Falseoption: Can't create a timer in stopped statesetTimer()/delTimer()andTimer()objects existProposed Design
New State Machine
Key Principle
Decouple "is timer in engine tick loop" from "does timer data exist". A stopped timer keeps its callback and can be restarted.
API Changes
Implementation Details
stoppedflag - replaces "callback is None" as removal signalstop()preserves callback - only removes from map and sets stopped=truestart()adds to map - handles name collision by replacing existing timertestTimers()checks stopped flag - removes stopped timers from mapFiles to Modify
src/Timer.h- Add stopped flagsrc/Timer.cpp- Update stop/start/test methodssrc/PyTimer.h- Add start(), set_active(), update docstringssrc/PyTimer.cpp- Implement new semanticssrc/McRFPy_API.cpp- Add timers collection, remove setTimer/delTimersrc/GameEngine.cpp- Update testTimers() cleanup logictests/- Update test suite for new behaviorRelated Issues
This is pre-v1.0 API cleanup work.