feat(logo,menu): reiniciar des de servei → LOGO amb reset (atura música) i logo_jailgames.gif centrat

This commit is contained in:
JailDesigner committed 2026-05-06 19:54:30 +02:00
1 parent 8eaa91f309
commit f7ab6a641a
7 files changed
+92 -35

No files matched your search

+19 -22
View File
@@ -5,26 +5,23 @@
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>
#include <utility>
#include "core/audio/audio.hpp"
#include "core/input/global_inputs.hpp"
#include "core/rendering/notifier.hpp"
#include "core/rendering/render_info.hpp"
#include "core/rendering/screen.hpp"
#include "core/rendering/text.hpp"
#include "core/rendering/surface.hpp"
#include "core/system/event_buffer.hpp"
#include "core/ui/ui_config.hpp"
#include "game/options.hpp"
#include "game/scenes/placeholder_input.hpp"
#include "game/scenes/scene_flow.hpp"
#include "utils/defaults.hpp"
#include "utils/defines.hpp"
namespace {
constexpr int NAME_Y_OFFSET = -8;
constexpr int TIMER_Y_OFFSET = 8;
// TODO: migrar a un logger unificat quan es decideixi (veure INC-03 a
// docs/audit-core-rendering.md). De moment std::cout per rastrejar el
// flux d'escenes als smoke runs.
@@ -32,9 +29,19 @@ namespace {
} // namespace
LogoScene::LogoScene(std::shared_ptr<Text> font)
: font_(std::move(font)) {
std::cout << "[scene] " << SCENE_NAME << " start\n";
LogoScene::LogoScene(std::shared_ptr<Surface> logo, bool reset)
: logo_(std::move(logo)) {
std::cout << "[scene] " << SCENE_NAME << (reset ? " start (reset)\n" : " start\n");
// RESET = "Reiniciar" del menú: tornem al punt zero del joc, així que
// qualsevol música o so en marxa (la del joc, els sons d'UI, etc.) ha
// d'apagar-se abans que el LOGO comenci. En el flux normal no toquem
// res — la música de TITLE pot seguir sonant durant l'attract-out.
if (reset) {
if (auto* audio = Audio::get(); audio != nullptr) {
audio->stopMusic();
audio->stopAllSounds();
}
}
}
LogoScene::~LogoScene() = default;
@@ -64,20 +71,10 @@ void LogoScene::render() {
constexpr std::uint32_t BLACK_ARGB = 0xFF000000U;
Screen::get().fillRect(0, 0, GameCanvas::WIDTH, GameCanvas::HEIGHT, BLACK_ARGB);
if (font_) {
const int SECS_LEFT = std::max(1, (timer_ms_ + 999) / 1000);
font_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG,
GameCanvas::CENTER_X,
GameCanvas::CENTER_Y + NAME_Y_OFFSET,
SCENE_NAME,
1,
UiConfig::get().notificationText());
font_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG,
GameCanvas::CENTER_X,
GameCanvas::CENTER_Y + TIMER_Y_OFFSET,
std::to_string(SECS_LEFT),
1,
UiConfig::get().notificationText());
if (logo_) {
const int X = (GameCanvas::WIDTH - logo_->getWidth()) / 2;
const int Y = (GameCanvas::HEIGHT - logo_->getHeight()) / 2;
logo_->render(X, Y);
}
Notifier::get().render();