This commit is contained in:
2026-04-11 16:25:56 +02:00
parent 5b2f986d32
commit bb38600aac
57 changed files with 371 additions and 347 deletions

View File

@@ -64,9 +64,16 @@ auto Console::wrapText(const std::string& text) const -> std::vector<std::string
std::istringstream word_stream(segment);
std::string word;
while (word_stream >> word) {
const std::string TEST = current_line.empty() ? word : (current_line + ' ' + word);
if (text_->length(TEST) <= MAX_PX) {
current_line = TEST;
std::string test;
if (current_line.empty()) {
test = word;
} else {
test = current_line;
test += ' ';
test += word;
}
if (text_->length(test) <= MAX_PX) {
current_line = test;
} else {
if (!current_line.empty()) { result.push_back(current_line); }
current_line = word;
@@ -381,7 +388,10 @@ void Console::handleEvent(const SDL_Event& event) { // NOLINT(readability-funct
const auto OPTS = registry_.getCompletions(BASE_CMD);
for (const auto& arg : OPTS) {
if (SUB_PREFIX.empty() || std::string_view{arg}.starts_with(SUB_PREFIX)) {
tab_matches_.emplace_back(BASE_CMD + " " + arg);
std::string match = BASE_CMD;
match += ' ';
match += arg;
tab_matches_.emplace_back(std::move(match));
}
}
}

View File

@@ -2,6 +2,7 @@
#include <SDL3/SDL.h>
#include <cstdint>
#include <deque> // Para deque (historial)
#include <functional> // Para function
#include <memory> // Para shared_ptr
@@ -46,7 +47,7 @@ class Console {
std::function<void(bool)> on_toggle;
private:
enum class Status {
enum class Status : std::uint8_t {
HIDDEN,
RISING,
ACTIVE,

View File

@@ -32,7 +32,7 @@
// Toggle genérico para comandos booleanos ON/OFF (reemplaza macro BOOL_TOGGLE_CMD)
static auto boolToggle(
const std::string& label,
bool& option,
const bool& option,
const std::function<void()>& toggle_fn,
const std::vector<std::string>& args) -> std::string {
if (args.empty()) {
@@ -259,7 +259,9 @@ static auto cmdZoom(const std::vector<std::string>& args) -> std::string {
if (N == Options::window.zoom) { return "Zoom already " + std::to_string(N); }
Screen::get()->setWindowZoom(N);
return "Zoom " + std::to_string(Options::window.zoom);
} catch (...) {}
} catch (...) {
// @INTENTIONAL: argumento no numérico → mostrar usage
}
return "usage: zoom [up|down|<1-" + std::to_string(Screen::getMaxZoom()) + ">]";
}
@@ -704,7 +706,7 @@ static auto cmdEdit(const std::vector<std::string>& args) -> std::string { // N
if ((args[0] == "SHOW" || args[0] == "HIDE") && args.size() >= 2) {
if ((MapEditor::get() == nullptr) || !MapEditor::get()->isActive()) { return "Editor not active"; }
bool show = (args[0] == "SHOW");
if (args[1] == "INFO") { return MapEditor::get()->showInfo(show); }
if (args[1] == "INFO") { return MapEditor::showInfo(show); }
if (args[1] == "GRID") { return MapEditor::get()->showGrid(show); }
}
// EDIT DRAW / EDIT COLLISION
@@ -878,6 +880,7 @@ static auto cmdCheat(const std::vector<std::string>& args) -> std::string { //
auto& cheat = Options::cheats.infinite_lives;
using State = Options::Cheat::State;
const std::vector<std::string> REST(args.begin() + 2, args.end());
// cppcheck-suppress knownConditionTrueFalse -- cppcheck no infiere que REST puede estar vacío cuando args.size() == 2.
if (REST.empty()) {
cheat = (cheat == State::ENABLED) ? State::DISABLED : State::ENABLED;
} else if (REST[0] == "ON") {
@@ -1113,7 +1116,7 @@ void CommandRegistry::registerHandlers() { // NOLINT(readability-function-cogni
if (path.find("tilesets") == std::string::npos) { continue; }
std::string name = getFileName(path);
auto dot = name.rfind('.');
if (dot != std::string::npos) { name = name.substr(0, dot); }
if (dot != std::string::npos) { name.resize(dot); }
result.push_back(toUpper(name));
}
return result;
@@ -1362,7 +1365,7 @@ auto CommandRegistry::getCompletions(const std::string& path) const -> std::vect
if (!active_scope_.empty()) {
std::string root = path;
auto space = root.find(' ');
if (space != std::string::npos) { root = root.substr(0, space); }
if (space != std::string::npos) { root.resize(space); }
const auto* cmd = findCommand(root);
if (cmd != nullptr && !isCommandVisible(*cmd)) { return {}; }
}

View File

@@ -116,8 +116,6 @@ void Notifier::update(float delta_time) {
}
case Status::FINISHED:
break;
default:
break;
}

View File

@@ -2,6 +2,7 @@
#include <SDL3/SDL.h>
#include <cstdint>
#include <memory> // Para shared_ptr
#include <string> // Para string, basic_string
#include <vector> // Para vector
@@ -13,13 +14,13 @@ class DeltaTimer; // lines 11-11
class Notifier {
public:
// Justificado para las notificaciones
enum class TextAlign {
enum class TextAlign : std::uint8_t {
LEFT,
CENTER,
};
// Forma de las notificaciones
enum class Shape {
enum class Shape : std::uint8_t {
ROUNDED,
SQUARED,
};
@@ -65,7 +66,7 @@ class Notifier {
private:
// Tipos anidados
enum class Status {
enum class Status : std::uint8_t {
RISING,
STAY,
VANISHING,