window_message: provant el redimensionat i les animacions

This commit is contained in:
2025-08-07 13:31:49 +02:00
parent 100b7265d5
commit 8d2c24deb9
4 changed files with 288 additions and 80 deletions

View File

@@ -15,7 +15,6 @@
DefineButtons::DefineButtons()
: input_(Input::get()) {
clearButtons();
auto gamepads = input_->getGamepads();
@@ -24,18 +23,26 @@ DefineButtons::DefineButtons()
}
// Crear la ventana de mensaje
WindowMessage::Config config;
config.bg_color = Color{20, 30, 50, 224}; // Fondo azul oscuro semi-transparente
config.border_color = Color{100, 150, 200, 255}; // Borde azul claro
config.title_color = Color{100, 150, 200, 255}; // Titulo azul claro
config.text_color = Color{220, 220, 220, 255}; // Texto gris claro
config.padding = 15.0f;
config.line_spacing = 5.0f;
config.title_separator_spacing = 15;
config.min_width = 250.0f;
config.text_safety_margin = 15.0f;
config.min_width = 100;
config.min_height = 32;
auto text_renderer = Resource::get()->getText("04b_25_flat");
window_message_ = std::make_unique<WindowMessage>(
text_renderer,
Lang::getText("[DEFINE_BUTTONS] TITLE"),
Color{20, 30, 50, 208}, // Fondo azul oscuro semi-transparente
Color{100, 150, 200, 255}, // Borde azul claro
Color{100, 150, 200, 255}, // Titulo azul claro
Color{220, 220, 220, 255} // Texto gris claro
config
);
window_message_->setPadding(0.0f);
window_message_->setLineSpacing(0.0f);
window_message_->setPosition(param.game.game_area.center_x, param.game.game_area.center_y, WindowMessage::PositionMode::CENTERED);
}
void DefineButtons::render() {
@@ -73,13 +80,12 @@ auto DefineButtons::enable(Options::Gamepad *options_gamepad) -> bool {
index_button_ = 0;
clearButtons();
updateWindowMessage();
if (window_message_) {
window_message_->autoSize();
window_message_->centerOnScreen();
window_message_->show();
}
return true;
}
return false;
@@ -88,7 +94,7 @@ auto DefineButtons::enable(Options::Gamepad *options_gamepad) -> bool {
void DefineButtons::disable() {
enabled_ = false;
finished_ = false;
if (window_message_) {
window_message_->hide();
}
@@ -146,7 +152,7 @@ void DefineButtons::checkEnd() {
bindButtons(options_gamepad_);
input_->saveGamepadConfigFromGamepad(options_gamepad_->instance);
input_->resetInputStates();
// Mostrar mensaje de finalización brevemente
if (window_message_) {
window_message_->clearTexts();
@@ -154,7 +160,7 @@ void DefineButtons::checkEnd() {
window_message_->autoSize();
window_message_->centerOnScreen();
}
// Se deshabilitará desde el ServiceMenu después de un breve delay
}
}
@@ -163,31 +169,31 @@ void DefineButtons::updateWindowMessage() {
if (!window_message_ || !options_gamepad_) {
return;
}
// Configurar título
std::string title = Lang::getText("[DEFINE_BUTTONS] CONFIGURING") + ": " + options_gamepad_->name;
window_message_->setTitle(title);
// Limpiar textos anteriores
window_message_->clearTexts();
if (index_button_ < buttons_.size()) {
// Mostrar progreso
/*std::string progress = "(" + std::to_string(index_button_ + 1) + "/" +
/*std::string progress = "(" + std::to_string(index_button_ + 1) + "/" +
std::to_string(buttons_.size()) + ")";
window_message_->addText(progress);
window_message_->addText("");*/
// Instrucción actual
std::string instruction = Lang::getText("[DEFINE_BUTTONS] PRESS_BUTTON_FOR") + ":";
window_message_->addText(instruction);
window_message_->addText(buttons_.at(index_button_).label);
// Botones ya configurados
/*if (index_button_ > 0) {
window_message_->addText("");
window_message_->addText(Lang::getText("[DEFINE_BUTTONS] CONFIGURED") + ":");
for (size_t i = 0; i < index_button_; ++i) {
std::string configured = "✓ " + buttons_[i].label;
window_message_->addText(configured);