granera con sarna no pica
This commit is contained in:
@@ -42,14 +42,13 @@ static auto parseTokens(const std::string& input) -> std::vector<std::string> {
|
||||
|
||||
// Calcula la altura total de la consola para N líneas de mensaje (+ 1 línea de input)
|
||||
static auto calcTargetHeight(int num_msg_lines) -> float {
|
||||
constexpr int TEXT_SIZE = 6;
|
||||
constexpr int PADDING_IN_V = TEXT_SIZE / 2;
|
||||
return static_cast<float>((TEXT_SIZE * (num_msg_lines + 1)) + (PADDING_IN_V * 2));
|
||||
constexpr int PADDING_IN_V = Console::TEXT_SIZE / 2;
|
||||
return static_cast<float>((Console::TEXT_SIZE * (num_msg_lines + 1)) + (PADDING_IN_V * 2));
|
||||
}
|
||||
|
||||
// Divide text en líneas respetando los \n existentes y haciendo word-wrap por ancho en píxeles
|
||||
auto Console::wrapText(const std::string& text) const -> std::vector<std::string> {
|
||||
constexpr int PADDING_IN_H = 6; // TEXT_SIZE; simétrico a ambos lados
|
||||
constexpr int PADDING_IN_H = TEXT_SIZE; // Simétrico a ambos lados
|
||||
const int MAX_PX = static_cast<int>(Options::game.width) - (2 * PADDING_IN_H);
|
||||
|
||||
std::vector<std::string> result;
|
||||
@@ -132,7 +131,6 @@ void Console::buildSurface() {
|
||||
// Redibuja el texto dinámico sobre la surface (fondo + borde + líneas)
|
||||
void Console::redrawText() {
|
||||
const float WIDTH = Options::game.width;
|
||||
constexpr int TEXT_SIZE = 6;
|
||||
constexpr int PADDING_IN_H = TEXT_SIZE;
|
||||
constexpr int PADDING_IN_V = TEXT_SIZE / 2;
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@ class Console {
|
||||
void toggle();
|
||||
void handleEvent(const SDL_Event& event);
|
||||
|
||||
// Constantes públicas
|
||||
static constexpr int TEXT_SIZE = 6; // Tamaño de carácter del font de la consola
|
||||
|
||||
// Consultas
|
||||
auto isActive() -> bool; // true si RISING, ACTIVE o VANISHING
|
||||
auto getVisibleHeight() -> int; // Píxeles visibles actuales (0 = oculta, height_ = totalmente visible)
|
||||
|
||||
@@ -857,41 +857,6 @@ static auto cmdCheat(const std::vector<std::string>& args) -> std::string { //
|
||||
return "usage: cheat [infinite lives|invincibility]";
|
||||
}
|
||||
|
||||
// PLAYER SKIN / PLAYER COLOR
|
||||
static auto cmdPlayer(const std::vector<std::string>& args) -> std::string {
|
||||
if (SceneManager::current != SceneManager::Scene::GAME) { return "Only available in GAME scene"; }
|
||||
|
||||
// PLAYER SKIN <name>
|
||||
if (args.size() >= 2 && args[0] == "SKIN") {
|
||||
if (!GameControl::change_player_skin) { return "Game not initialized"; }
|
||||
std::string skin_name = args[1];
|
||||
std::ranges::transform(skin_name, skin_name.begin(), ::tolower);
|
||||
GameControl::change_player_skin(skin_name);
|
||||
return "Player skin: " + skin_name;
|
||||
}
|
||||
|
||||
// PLAYER COLOR DEFAULT
|
||||
if (args.size() >= 2 && args[0] == "COLOR" && args[1] == "DEFAULT") {
|
||||
if (!GameControl::change_player_color) { return "Game not initialized"; }
|
||||
GameControl::change_player_color(-1);
|
||||
return "Player color: default";
|
||||
}
|
||||
|
||||
// PLAYER COLOR <0-15>
|
||||
if (args.size() >= 2 && args[0] == "COLOR") {
|
||||
int color = -1;
|
||||
try {
|
||||
color = std::stoi(args[1]);
|
||||
} catch (...) {}
|
||||
if (color < 0 || color > 15) { return "usage: player color <0-15>|default"; }
|
||||
if (!GameControl::change_player_color) { return "Game not initialized"; }
|
||||
GameControl::change_player_color(color);
|
||||
return "Player color: " + std::to_string(color);
|
||||
}
|
||||
|
||||
return "usage: player skin <name> | player color <0-15>|default";
|
||||
}
|
||||
|
||||
// RESTART
|
||||
static auto cmdRestart(const std::vector<std::string>& /*unused*/) -> std::string {
|
||||
SceneManager::current = SceneManager::Scene::LOGO;
|
||||
@@ -954,7 +919,6 @@ void CommandRegistry::registerHandlers() { // NOLINT(readability-function-cogni
|
||||
handlers_["cmd_show"] = cmdShow;
|
||||
handlers_["cmd_hide"] = cmdHide;
|
||||
handlers_["cmd_cheat"] = cmdCheat;
|
||||
handlers_["cmd_player"] = cmdPlayer;
|
||||
handlers_["cmd_restart"] = cmdRestart;
|
||||
handlers_["cmd_kiosk"] = cmdKiosk;
|
||||
handlers_["cmd_exit"] = cmdExit;
|
||||
@@ -1006,8 +970,6 @@ void CommandRegistry::registerHandlers() { // NOLINT(readability-function-cogni
|
||||
}
|
||||
return result;
|
||||
};
|
||||
dynamic_providers_["SET COLOR"] = color_provider;
|
||||
dynamic_providers_["SET BGCOLOR"] = color_provider;
|
||||
dynamic_providers_["EDIT MAPBG"] = color_provider;
|
||||
dynamic_providers_["EDIT MAPCONN"] = color_provider;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ const Notifier::Style Notifier::Style::DEFAULT = {
|
||||
.shape = Notifier::Shape::SQUARED,
|
||||
.text_align = Notifier::TextAlign::CENTER,
|
||||
.duration = 2.0F,
|
||||
.sound_file = "notify.wav",
|
||||
.sound_file = Defaults::Sound::Files::NOTIFY,
|
||||
.play_sound = false};
|
||||
|
||||
const Notifier::Style Notifier::Style::CHEEVO = {
|
||||
@@ -40,7 +40,7 @@ const Notifier::Style Notifier::Style::CHEEVO = {
|
||||
.shape = Notifier::Shape::SQUARED,
|
||||
.text_align = Notifier::TextAlign::CENTER,
|
||||
.duration = 4.0F,
|
||||
.sound_file = "notify.wav",
|
||||
.sound_file = Defaults::Sound::Files::NOTIFY,
|
||||
.play_sound = true};
|
||||
|
||||
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||
@@ -160,7 +160,7 @@ void Notifier::show(std::vector<std::string> texts, const Style& style, int icon
|
||||
}
|
||||
|
||||
// Inicializa variables
|
||||
const int TEXT_SIZE = 6;
|
||||
constexpr float TEXT_SIZE = LINE_HEIGHT;
|
||||
const auto PADDING_IN_H = TEXT_SIZE;
|
||||
const auto PADDING_IN_V = TEXT_SIZE / 2;
|
||||
const int ICON_SPACE = icon >= 0 ? ICON_SIZE + PADDING_IN_H : 0;
|
||||
@@ -205,16 +205,16 @@ void Notifier::show(std::vector<std::string> texts, const Style& style, int icon
|
||||
// Dibuja el fondo de la notificación
|
||||
SDL_FRect rect;
|
||||
if (SHAPE == Shape::ROUNDED) {
|
||||
rect = {.x = 4, .y = 0, .w = WIDTH - (4 * 2), .h = HEIGHT};
|
||||
rect = {.x = static_cast<float>(CORNER_RADIUS), .y = 0, .w = WIDTH - (CORNER_RADIUS * 2), .h = HEIGHT};
|
||||
n.surface->fillRect(&rect, style.bg_color);
|
||||
|
||||
rect = {.x = 4 / 2, .y = 1, .w = WIDTH - 4, .h = HEIGHT - 2};
|
||||
rect = {.x = static_cast<float>(CORNER_RADIUS / 2), .y = static_cast<float>(BORDER_INSET), .w = WIDTH - CORNER_RADIUS, .h = HEIGHT - (BORDER_INSET * 2)};
|
||||
n.surface->fillRect(&rect, style.bg_color);
|
||||
|
||||
rect = {.x = 1, .y = 4 / 2, .w = WIDTH - 2, .h = HEIGHT - 4};
|
||||
rect = {.x = static_cast<float>(BORDER_INSET), .y = static_cast<float>(CORNER_RADIUS / 2), .w = WIDTH - (BORDER_INSET * 2), .h = HEIGHT - CORNER_RADIUS};
|
||||
n.surface->fillRect(&rect, style.bg_color);
|
||||
|
||||
rect = {.x = 0, .y = 4, .w = WIDTH, .h = HEIGHT - (4 * 2)};
|
||||
rect = {.x = 0, .y = static_cast<float>(CORNER_RADIUS), .w = WIDTH, .h = HEIGHT - (CORNER_RADIUS * 2)};
|
||||
n.surface->fillRect(&rect, style.bg_color);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,9 @@ class Notifier {
|
||||
static constexpr float ICON_SIZE = 16.0F;
|
||||
static constexpr float PADDING_OUT = 0.0F;
|
||||
static constexpr float SLIDE_SPEED = 120.0F; // Pixels per second for slide animations
|
||||
static constexpr float LINE_HEIGHT = 6.0F; // Alto de línea fijo para el layout de notificaciones
|
||||
static constexpr int CORNER_RADIUS = 4; // Radio de las esquinas redondeadas
|
||||
static constexpr int BORDER_INSET = 1; // Inset del borde interior
|
||||
|
||||
// [SINGLETON] Objeto notifier
|
||||
static Notifier* notifier;
|
||||
|
||||
Reference in New Issue
Block a user