Camera API, improved cutscene API

This commit is contained in:
Jan Racek
2026-03-28 20:13:12 +01:00
parent 68cf8a7460
commit 561ee9dd64
6 changed files with 160 additions and 29 deletions

View File

@@ -9,6 +9,8 @@
#include "gameobject.hh"
#include "audiomanager.hh"
#include <psyqo-lua/lua.hh>
namespace psxsplash {
class UISystem; // Forward declaration
@@ -86,7 +88,8 @@ public:
UISystem* uiSystem = nullptr);
/// Play cutscene by name. Returns false if not found.
bool play(const char* name);
/// If loop is true, the cutscene replays from the start when it ends.
bool play(const char* name, bool loop = false);
/// Stop the current cutscene immediately.
void stop();
@@ -94,6 +97,15 @@ public:
/// True if a cutscene is currently active.
bool isPlaying() const { return m_active != nullptr; }
/// Set a Lua registry reference to call when the cutscene finishes.
/// Pass LUA_NOREF to clear. The callback is called ONCE when the
/// cutscene ends (not on each loop iteration - only when it truly stops).
void setOnCompleteRef(int ref) { m_onCompleteRef = ref; }
int getOnCompleteRef() const { return m_onCompleteRef; }
/// Set the lua_State for callbacks. Must be called before play().
void setLuaState(lua_State* L) { m_luaState = L; }
/// Advance one frame. Call once per frame. Does nothing when idle.
void tick();
@@ -103,15 +115,19 @@ private:
Cutscene* m_active = nullptr;
uint16_t m_frame = 0;
uint8_t m_nextAudio = 0;
bool m_loop = false;
Camera* m_camera = nullptr;
AudioManager* m_audio = nullptr;
UISystem* m_uiSystem = nullptr;
lua_State* m_luaState = nullptr;
int m_onCompleteRef = LUA_NOREF;
psyqo::Trig<> m_trig;
void applyTrack(CutsceneTrack& track);
void lerpKeyframes(CutsceneKeyframe* kf, uint8_t count, const int16_t initial[3], int16_t out[3]);
void lerpAngles(CutsceneKeyframe* kf, uint8_t count, const int16_t initial[3], int16_t out[3]);
void fireOnComplete();
};
} // namespace psxsplash