broken ui system
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <psyqo/fixed-point.hh>
|
||||
#include <psyqo/soft-math.hh>
|
||||
#include <psyqo/trigonometry.hh>
|
||||
#include "uisystem.hh"
|
||||
|
||||
namespace psxsplash {
|
||||
|
||||
@@ -14,7 +15,8 @@ static bool cs_streq(const char* a, const char* b) {
|
||||
return *a == *b;
|
||||
}
|
||||
|
||||
void CutscenePlayer::init(Cutscene* cutscenes, int count, Camera* camera, AudioManager* audio) {
|
||||
void CutscenePlayer::init(Cutscene* cutscenes, int count, Camera* camera, AudioManager* audio,
|
||||
UISystem* uiSystem) {
|
||||
m_cutscenes = cutscenes;
|
||||
m_count = count;
|
||||
m_active = nullptr;
|
||||
@@ -22,6 +24,7 @@ void CutscenePlayer::init(Cutscene* cutscenes, int count, Camera* camera, AudioM
|
||||
m_nextAudio = 0;
|
||||
m_camera = camera;
|
||||
m_audio = audio;
|
||||
m_uiSystem = uiSystem;
|
||||
}
|
||||
|
||||
bool CutscenePlayer::play(const char* name) {
|
||||
@@ -68,6 +71,38 @@ bool CutscenePlayer::play(const char* name) {
|
||||
track.initialValues[0] = track.target->isActive() ? 1 : 0;
|
||||
}
|
||||
break;
|
||||
case TrackType::UICanvasVisible:
|
||||
if (m_uiSystem) {
|
||||
track.initialValues[0] = m_uiSystem->isCanvasVisible(track.uiHandle) ? 1 : 0;
|
||||
}
|
||||
break;
|
||||
case TrackType::UIElementVisible:
|
||||
if (m_uiSystem) {
|
||||
track.initialValues[0] = m_uiSystem->isElementVisible(track.uiHandle) ? 1 : 0;
|
||||
}
|
||||
break;
|
||||
case TrackType::UIProgress:
|
||||
if (m_uiSystem) {
|
||||
track.initialValues[0] = m_uiSystem->getProgress(track.uiHandle);
|
||||
}
|
||||
break;
|
||||
case TrackType::UIPosition:
|
||||
if (m_uiSystem) {
|
||||
int16_t px, py;
|
||||
m_uiSystem->getPosition(track.uiHandle, px, py);
|
||||
track.initialValues[0] = px;
|
||||
track.initialValues[1] = py;
|
||||
}
|
||||
break;
|
||||
case TrackType::UIColor:
|
||||
if (m_uiSystem) {
|
||||
uint8_t cr, cg, cb;
|
||||
m_uiSystem->getColor(track.uiHandle, cr, cg, cb);
|
||||
track.initialValues[0] = cr;
|
||||
track.initialValues[1] = cg;
|
||||
track.initialValues[2] = cb;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +139,7 @@ void CutscenePlayer::tick() {
|
||||
|
||||
// Advance frame
|
||||
m_frame++;
|
||||
if (m_frame >= m_active->totalFrames) {
|
||||
if (m_frame > m_active->totalFrames) {
|
||||
m_active = nullptr; // Cutscene finished
|
||||
}
|
||||
}
|
||||
@@ -296,6 +331,63 @@ void CutscenePlayer::applyTrack(CutsceneTrack& track) {
|
||||
track.target->setActive(activeVal != 0);
|
||||
break;
|
||||
}
|
||||
|
||||
// ── UI track types ──
|
||||
|
||||
case TrackType::UICanvasVisible: {
|
||||
if (!m_uiSystem) return;
|
||||
CutsceneKeyframe* kf = track.keyframes;
|
||||
uint8_t count = track.keyframeCount;
|
||||
int16_t val = (count > 0 && m_frame < kf[0].getFrame())
|
||||
? track.initialValues[0] : kf[0].values[0];
|
||||
for (uint8_t i = 0; i < count; i++) {
|
||||
if (kf[i].getFrame() <= m_frame) val = kf[i].values[0];
|
||||
else break;
|
||||
}
|
||||
m_uiSystem->setCanvasVisible(track.uiHandle, val != 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case TrackType::UIElementVisible: {
|
||||
if (!m_uiSystem) return;
|
||||
CutsceneKeyframe* kf = track.keyframes;
|
||||
uint8_t count = track.keyframeCount;
|
||||
int16_t val = (count > 0 && m_frame < kf[0].getFrame())
|
||||
? track.initialValues[0] : kf[0].values[0];
|
||||
for (uint8_t i = 0; i < count; i++) {
|
||||
if (kf[i].getFrame() <= m_frame) val = kf[i].values[0];
|
||||
else break;
|
||||
}
|
||||
m_uiSystem->setElementVisible(track.uiHandle, val != 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case TrackType::UIProgress: {
|
||||
if (!m_uiSystem) return;
|
||||
lerpKeyframes(track.keyframes, track.keyframeCount, track.initialValues, out);
|
||||
int16_t v = out[0];
|
||||
if (v < 0) v = 0;
|
||||
if (v > 100) v = 100;
|
||||
m_uiSystem->setProgress(track.uiHandle, (uint8_t)v);
|
||||
break;
|
||||
}
|
||||
|
||||
case TrackType::UIPosition: {
|
||||
if (!m_uiSystem) return;
|
||||
lerpKeyframes(track.keyframes, track.keyframeCount, track.initialValues, out);
|
||||
m_uiSystem->setPosition(track.uiHandle, out[0], out[1]);
|
||||
break;
|
||||
}
|
||||
|
||||
case TrackType::UIColor: {
|
||||
if (!m_uiSystem) return;
|
||||
lerpKeyframes(track.keyframes, track.keyframeCount, track.initialValues, out);
|
||||
uint8_t cr = (out[0] < 0) ? 0 : ((out[0] > 255) ? 255 : (uint8_t)out[0]);
|
||||
uint8_t cg = (out[1] < 0) ? 0 : ((out[1] > 255) ? 255 : (uint8_t)out[1]);
|
||||
uint8_t cb = (out[2] < 0) ? 0 : ((out[2] > 255) ? 255 : (uint8_t)out[2]);
|
||||
m_uiSystem->setColor(track.uiHandle, cr, cg, cb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user