forked from jaildesigner-jailgames/jaildoctors_dilemma
opcions per amagar la pantalla de carrega
This commit is contained in:
@@ -645,14 +645,20 @@ namespace Resource {
|
||||
|
||||
// Muestra el progreso de carga
|
||||
void Cache::renderProgress() {
|
||||
Screen::get()->start();
|
||||
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||
|
||||
// Si show=false: pantalla negra y salir
|
||||
if (!Options::loading.show) {
|
||||
Screen::get()->render();
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr float X_PADDING = 60.0F;
|
||||
constexpr float Y_PADDING = 10.0F;
|
||||
constexpr float BAR_HEIGHT = 5.0F;
|
||||
|
||||
const float BAR_POSITION = Options::game.height - BAR_HEIGHT - Y_PADDING;
|
||||
Screen::get()->start();
|
||||
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||
|
||||
auto surface = Screen::get()->getRendererSurface();
|
||||
const auto LOADING_TEXT_COLOR = static_cast<Uint8>(PaletteColor::BRIGHT_WHITE);
|
||||
const auto BAR_COLOR = static_cast<Uint8>(PaletteColor::WHITE);
|
||||
@@ -686,13 +692,15 @@ namespace Resource {
|
||||
SDL_FRect rect_full = {.x = X_PADDING, .y = BAR_POSITION, .w = FULL_BAR_WIDTH, .h = BAR_HEIGHT};
|
||||
surface->fillRect(&rect_full, BAR_COLOR);
|
||||
|
||||
// Mostra el nom del recurs que està a punt de carregar-se, centrat sobre la barra
|
||||
if (!current_loading_name_.empty()) {
|
||||
// Mostra el nom del recurs (o missatge d'espera si ja ha acabat i wait_for_input=true)
|
||||
const bool WAITING_FOR_INPUT = isLoadDone() && Options::loading.wait_for_input;
|
||||
const std::string OVER_BAR_TEXT = WAITING_FOR_INPUT ? "PRESS ANY KEY TO CONTINUE" : current_loading_name_;
|
||||
if ((Options::loading.show_resource_name || WAITING_FOR_INPUT) && !OVER_BAR_TEXT.empty()) {
|
||||
const float TEXT_Y = BAR_POSITION - static_cast<float>(TEXT_HEIGHT) - 2.0F;
|
||||
loading_text_->writeColored(
|
||||
CENTER_X - (loading_text_->length(current_loading_name_) / 2),
|
||||
CENTER_X - (loading_text_->length(OVER_BAR_TEXT) / 2),
|
||||
static_cast<int>(TEXT_Y),
|
||||
current_loading_name_,
|
||||
OVER_BAR_TEXT,
|
||||
LOADING_TEXT_COLOR);
|
||||
}
|
||||
|
||||
|
||||
@@ -438,7 +438,11 @@ auto Director::iterate() -> SDL_AppResult {
|
||||
// per veure la barra avançar suau i processar events del WM/ESC,
|
||||
// i evita el 50% d'ineficiència que provocaria un budget < vsync.
|
||||
if (Resource::Cache::get()->loadStep(50 /*ms*/)) {
|
||||
finishBoot();
|
||||
if (Options::loading.show && Options::loading.wait_for_input) {
|
||||
boot_waiting_for_input_ = true; // Esperar tecla antes de continuar
|
||||
} else {
|
||||
finishBoot();
|
||||
}
|
||||
boot_loading_ = false;
|
||||
// finishBoot() ja ha fixat SceneManager::current a LOGO (o la que
|
||||
// digui Debug). El canvi d'escena es fa just a sota.
|
||||
@@ -472,6 +476,17 @@ auto Director::handleEvent(const SDL_Event& event) -> SDL_AppResult {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Si estamos esperando input tras la carga: consumir tecla/botón y arrancar
|
||||
if (boot_waiting_for_input_) {
|
||||
const bool IS_KEY = event.type == SDL_EVENT_KEY_DOWN && !event.key.repeat;
|
||||
const bool IS_BUTTON = event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN;
|
||||
if (IS_KEY || IS_BUTTON) {
|
||||
boot_waiting_for_input_ = false;
|
||||
finishBoot();
|
||||
}
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
if (active_scene_) {
|
||||
active_scene_->handleEvent(event);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ class Director {
|
||||
|
||||
std::unique_ptr<Scene> active_scene_; // Escena activa
|
||||
SceneManager::Scene current_scene_{SceneManager::Scene::BOOT_LOADER}; // Tipus d'escena activa
|
||||
bool boot_loading_{true}; // True mientras Cache::loadStep() no haya acabado
|
||||
bool boot_loading_{true}; // True mientras Cache::loadStep() no haya acabado
|
||||
bool boot_waiting_for_input_{false}; // True si la carga acabó y Options::loading.wait_for_input está activo
|
||||
|
||||
// --- Funciones ---
|
||||
void createSystemFolder(const std::string& folder); // Crea la carpeta del sistema donde guardar datos
|
||||
|
||||
Reference in New Issue
Block a user