cutscene system
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "gameobject.hh"
|
||||
#include "controls.hh"
|
||||
#include "camera.hh"
|
||||
#include "cutscene.hh"
|
||||
|
||||
#include <psyqo/soft-math.hh>
|
||||
#include <psyqo/trigonometry.hh>
|
||||
@@ -13,6 +14,7 @@ namespace psxsplash {
|
||||
|
||||
// Static member
|
||||
SceneManager* LuaAPI::s_sceneManager = nullptr;
|
||||
CutscenePlayer* LuaAPI::s_cutscenePlayer = nullptr;
|
||||
|
||||
// Scale factor: FixedPoint<12> stores 1.0 as raw 4096.
|
||||
// Lua scripts work in world-space units (1 = one unit), so we convert.
|
||||
@@ -34,8 +36,9 @@ static psyqo::Trig<> s_trig;
|
||||
// REGISTRATION
|
||||
// ============================================================================
|
||||
|
||||
void LuaAPI::RegisterAll(psyqo::Lua& L, SceneManager* scene) {
|
||||
void LuaAPI::RegisterAll(psyqo::Lua& L, SceneManager* scene, CutscenePlayer* cutscenePlayer) {
|
||||
s_sceneManager = scene;
|
||||
s_cutscenePlayer = cutscenePlayer;
|
||||
|
||||
// ========================================================================
|
||||
// ENTITY API
|
||||
@@ -262,6 +265,22 @@ void LuaAPI::RegisterAll(psyqo::Lua& L, SceneManager* scene) {
|
||||
L.setField(-2, "Set");
|
||||
|
||||
L.setGlobal("Persist");
|
||||
|
||||
// ========================================================================
|
||||
// CUTSCENE API
|
||||
// ========================================================================
|
||||
L.newTable(); // Cutscene table
|
||||
|
||||
L.push(Cutscene_Play);
|
||||
L.setField(-2, "Play");
|
||||
|
||||
L.push(Cutscene_Stop);
|
||||
L.setField(-2, "Stop");
|
||||
|
||||
L.push(Cutscene_IsPlaying);
|
||||
L.setField(-2, "IsPlaying");
|
||||
|
||||
L.setGlobal("Cutscene");
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@@ -1382,4 +1401,40 @@ void LuaAPI::PersistClear() {
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// CUTSCENE API IMPLEMENTATION
|
||||
// ============================================================================
|
||||
|
||||
int LuaAPI::Cutscene_Play(lua_State* L) {
|
||||
psyqo::Lua lua(L);
|
||||
|
||||
if (!s_cutscenePlayer || !lua.isString(1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* name = lua.toString(1);
|
||||
s_cutscenePlayer->play(name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaAPI::Cutscene_Stop(lua_State* L) {
|
||||
psyqo::Lua lua(L);
|
||||
|
||||
if (s_cutscenePlayer) {
|
||||
s_cutscenePlayer->stop();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaAPI::Cutscene_IsPlaying(lua_State* L) {
|
||||
psyqo::Lua lua(L);
|
||||
|
||||
if (s_cutscenePlayer) {
|
||||
lua.push(s_cutscenePlayer->isPlaying());
|
||||
} else {
|
||||
lua.push(false);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
} // namespace psxsplash
|
||||
|
||||
Reference in New Issue
Block a user