feat(intro/outro): panel translúcid sota el rètol amb easing del text
This commit is contained in:
1 parent
0752df0f62
commit
8243e95ef1
4 files changed
+93
-11
No files matched your search
@@ -640,6 +640,10 @@ void GameScene::renderRoomFade() {
|
||||
Screen::get().blendRect(0, 0, GameCanvas::WIDTH, GameCanvas::HEIGHT, 0x00000000U, ALPHA);
|
||||
}
|
||||
|
||||
// TEMPORAL — al pròxim commit s'extrauen compute_x, compute_panel_height,
|
||||
// draw_panel i draw_line a mètodes privats; aquest NOLINT és només per
|
||||
// "guardar feina" mentre encara estem fent ajustos visuals.
|
||||
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||
void GameScene::renderRoomText() {
|
||||
// Text de la transició de sala. Font dedicada (`room_text_font_`,
|
||||
// CaesarDressing per defecte) — la pausa té la seua i no es barregen.
|
||||
@@ -699,6 +703,41 @@ void GameScene::renderRoomText() {
|
||||
return GameCanvas::CENTER_X;
|
||||
};
|
||||
|
||||
// Panel translúcid sota el rètol: l'altura s'anima de 0 a
|
||||
// `text_panel_height_px` durant l'enter (amb la mateixa
|
||||
// text_enter_curve que els textos), es manté plena durant el hold
|
||||
// i decreix durant l'exit. Cada estat (INTRO, OUTRO) li passa la
|
||||
// tripleta de fases (enter, hold, exit) i les seues durades.
|
||||
auto compute_panel_height = [&](int p_enter, int p_hold, int p_exit, int d_enter, int d_exit) -> int {
|
||||
const int MAX = transition_config_.text_panel_height_px;
|
||||
if (transition_.phase == p_enter) {
|
||||
const float T = (d_enter > 0)
|
||||
? std::clamp(static_cast<float>(transition_.elapsed_ms) / static_cast<float>(d_enter), 0.0F, 1.0F)
|
||||
: 1.0F;
|
||||
const auto CURVE = (transition_config_.text_enter_curve != nullptr) ? transition_config_.text_enter_curve : &Easing::linear;
|
||||
return Easing::lerpInt(0, MAX, CURVE(T));
|
||||
}
|
||||
if (transition_.phase == p_hold) { return MAX; }
|
||||
if (transition_.phase == p_exit) {
|
||||
const float T = (d_exit > 0)
|
||||
? std::clamp(static_cast<float>(transition_.elapsed_ms) / static_cast<float>(d_exit), 0.0F, 1.0F)
|
||||
: 1.0F;
|
||||
const auto CURVE = (transition_config_.text_exit_curve != nullptr) ? transition_config_.text_exit_curve : &Easing::linear;
|
||||
return Easing::lerpInt(MAX, 0, CURVE(T));
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
auto draw_panel = [&](int panel_height) {
|
||||
if (panel_height <= 0 || transition_config_.text_panel_alpha == 0) { return; }
|
||||
Screen::get().blendRect(0,
|
||||
PLAY_CENTER_Y - (panel_height / 2),
|
||||
GameCanvas::WIDTH,
|
||||
panel_height,
|
||||
transition_config_.text_panel_color,
|
||||
transition_config_.text_panel_alpha);
|
||||
};
|
||||
|
||||
auto draw_line = [&](const std::string& text, int x, int y) {
|
||||
room_text_font_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG | Text::STROKE4_FLAG,
|
||||
x,
|
||||
@@ -711,6 +750,9 @@ void GameScene::renderRoomText() {
|
||||
};
|
||||
|
||||
if (state_ == RoomFsm::State::ROOM_INTRO && transition_.phase >= 2 && transition_.phase <= 4) {
|
||||
// Panel primer (queda sota el text gràcies a l'ordre de blits).
|
||||
draw_panel(compute_panel_height(2, 3, 4, transition_config_.intro_text_enter_ms, transition_config_.intro_text_exit_ms));
|
||||
|
||||
const auto& mgr = Levels::LevelManager::get();
|
||||
const std::string LINE_PYRAMID = RoomFsm::formatIntroPyramidLine(mgr.currentPyramid());
|
||||
const std::string LINE_ROOM = RoomFsm::formatIntroRoomLine(mgr.currentRoom());
|
||||
@@ -735,6 +777,8 @@ void GameScene::renderRoomText() {
|
||||
draw_line(LINE_PYRAMID, X_PYRAMID, Y_PYRAMID);
|
||||
draw_line(LINE_ROOM, X_ROOM, Y_ROOM);
|
||||
} else if (state_ == RoomFsm::State::ROOM_OUTRO && transition_.phase >= 0 && transition_.phase <= 2) {
|
||||
draw_panel(compute_panel_height(0, 1, 2, transition_config_.outro_text_enter_ms, transition_config_.outro_text_exit_ms));
|
||||
|
||||
// Mateix patró que l'INTRO: dues línies en direccions oposades.
|
||||
// Línia 1 ("Fase") per l'esquerra, línia 2 ("Completada") per
|
||||
// la dreta; surten cap al costat oposat del que han entrat.
|
||||
|
||||
Reference in new issue
Block a user