elimina NOLINT obsolets (241 marques que ja no disparaven warning)
This commit is contained in:
@@ -259,7 +259,7 @@ namespace Ja {
|
|||||||
sdl_audio_device = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &audio_spec);
|
sdl_audio_device = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &audio_spec);
|
||||||
if (sdl_audio_device == 0) { std::cout << "Failed to initialize SDL audio!" << '\n'; }
|
if (sdl_audio_device == 0) { std::cout << "Failed to initialize SDL audio!" << '\n'; }
|
||||||
for (auto& ch : channels) { ch.state = ChannelState::FREE; }
|
for (auto& ch : channels) { ch.state = ChannelState::FREE; }
|
||||||
std::fill(std::begin(sound_volume), std::end(sound_volume), 0.5F);
|
std::ranges::fill(sound_volume, 0.5F);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void quit() {
|
inline void quit() {
|
||||||
@@ -663,7 +663,7 @@ namespace Ja {
|
|||||||
const float V = SDL_clamp(volume, 0.0F, 1.0F);
|
const float V = SDL_clamp(volume, 0.0F, 1.0F);
|
||||||
|
|
||||||
if (group == -1) {
|
if (group == -1) {
|
||||||
std::fill(std::begin(sound_volume), std::end(sound_volume), V);
|
std::ranges::fill(sound_volume, V);
|
||||||
} else if (group >= 0 && group < MAX_GROUPS) {
|
} else if (group >= 0 && group < MAX_GROUPS) {
|
||||||
sound_volume[group] = V;
|
sound_volume[group] = V;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace GlobalInputs {
|
|||||||
if (stringInVector(Notifier::get()->getCodes(), CODE)) {
|
if (stringInVector(Notifier::get()->getCodes(), CODE)) {
|
||||||
SceneManager::current = SceneManager::Scene::TITLE;
|
SceneManager::current = SceneManager::Scene::TITLE;
|
||||||
} else {
|
} else {
|
||||||
Notifier::get()->show({Locale::get()->get("ui.press_again_menu")}, Notifier::Style::DEFAULT, -1, true, CODE); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("ui.press_again_menu")}, Notifier::Style::DEFAULT, -1, true, CODE);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ namespace GlobalInputs {
|
|||||||
if (stringInVector(Notifier::get()->getCodes(), CODE)) {
|
if (stringInVector(Notifier::get()->getCodes(), CODE)) {
|
||||||
SceneManager::current = SceneManager::Scene::QUIT;
|
SceneManager::current = SceneManager::Scene::QUIT;
|
||||||
} else {
|
} else {
|
||||||
Notifier::get()->show({Locale::get()->get("ui.press_again_exit")}, Notifier::Style::DEFAULT, -1, true, CODE); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("ui.press_again_exit")}, Notifier::Style::DEFAULT, -1, true, CODE);
|
||||||
}
|
}
|
||||||
#endif // __EMSCRIPTEN__
|
#endif // __EMSCRIPTEN__
|
||||||
}
|
}
|
||||||
@@ -78,29 +78,29 @@ namespace GlobalInputs {
|
|||||||
|
|
||||||
void handleToggleBorder() {
|
void handleToggleBorder() {
|
||||||
Screen::get()->toggleBorder();
|
Screen::get()->toggleBorder();
|
||||||
Notifier::get()->show({Locale::get()->get(Options::video.border.enabled ? "ui.border_enabled" : "ui.border_disabled")}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get(Options::video.border.enabled ? "ui.border_enabled" : "ui.border_disabled")});
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleToggleVideoMode() {
|
void handleToggleVideoMode() {
|
||||||
Screen::get()->toggleVideoMode();
|
Screen::get()->toggleVideoMode();
|
||||||
Notifier::get()->show({Locale::get()->get(static_cast<int>(Options::video.fullscreen) == 0 ? "ui.fullscreen_disabled" : "ui.fullscreen_enabled")}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get(static_cast<int>(Options::video.fullscreen) == 0 ? "ui.fullscreen_disabled" : "ui.fullscreen_enabled")});
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleDecWindowZoom() {
|
void handleDecWindowZoom() {
|
||||||
if (Screen::get()->decWindowZoom()) {
|
if (Screen::get()->decWindowZoom()) {
|
||||||
Notifier::get()->show({Locale::get()->get("ui.window_zoom") + std::to_string(Options::window.zoom)}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("ui.window_zoom") + std::to_string(Options::window.zoom)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleIncWindowZoom() {
|
void handleIncWindowZoom() {
|
||||||
if (Screen::get()->incWindowZoom()) {
|
if (Screen::get()->incWindowZoom()) {
|
||||||
Notifier::get()->show({Locale::get()->get("ui.window_zoom") + std::to_string(Options::window.zoom)}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("ui.window_zoom") + std::to_string(Options::window.zoom)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleToggleShaders() {
|
void handleToggleShaders() {
|
||||||
Screen::get()->toggleShaders();
|
Screen::get()->toggleShaders();
|
||||||
Notifier::get()->show({Locale::get()->get(Options::video.shader.enabled ? "ui.shaders_enabled" : "ui.shaders_disabled")}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get(Options::video.shader.enabled ? "ui.shaders_enabled" : "ui.shaders_disabled")});
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleNextShaderPreset() {
|
void handleNextShaderPreset() {
|
||||||
@@ -108,47 +108,47 @@ namespace GlobalInputs {
|
|||||||
if (!Options::crtpi_presets.empty()) {
|
if (!Options::crtpi_presets.empty()) {
|
||||||
Options::video.shader.current_crtpi_preset = (Options::video.shader.current_crtpi_preset + 1) % static_cast<int>(Options::crtpi_presets.size());
|
Options::video.shader.current_crtpi_preset = (Options::video.shader.current_crtpi_preset + 1) % static_cast<int>(Options::crtpi_presets.size());
|
||||||
Screen::get()->reloadCrtPi();
|
Screen::get()->reloadCrtPi();
|
||||||
Notifier::get()->show({Locale::get()->get("ui.crtpi") + " " + prettyName(Options::crtpi_presets[static_cast<size_t>(Options::video.shader.current_crtpi_preset)].name)}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("ui.crtpi") + " " + prettyName(Options::crtpi_presets[static_cast<size_t>(Options::video.shader.current_crtpi_preset)].name)});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!Options::postfx_presets.empty()) {
|
if (!Options::postfx_presets.empty()) {
|
||||||
Options::video.shader.current_postfx_preset = (Options::video.shader.current_postfx_preset + 1) % static_cast<int>(Options::postfx_presets.size());
|
Options::video.shader.current_postfx_preset = (Options::video.shader.current_postfx_preset + 1) % static_cast<int>(Options::postfx_presets.size());
|
||||||
Screen::get()->reloadPostFX();
|
Screen::get()->reloadPostFX();
|
||||||
Notifier::get()->show({Locale::get()->get("ui.postfx") + " " + prettyName(Options::postfx_presets[static_cast<size_t>(Options::video.shader.current_postfx_preset)].name)}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("ui.postfx") + " " + prettyName(Options::postfx_presets[static_cast<size_t>(Options::video.shader.current_postfx_preset)].name)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleNextShader() {
|
void handleNextShader() {
|
||||||
Screen::get()->nextShader();
|
Screen::get()->nextShader();
|
||||||
Notifier::get()->show({Locale::get()->get("ui.shader") + " " + // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("ui.shader") + " " +
|
||||||
(Options::video.shader.current_shader == Rendering::ShaderType::CRTPI ? "CRTPI" : "POSTFX")});
|
(Options::video.shader.current_shader == Rendering::ShaderType::CRTPI ? "CRTPI" : "POSTFX")});
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleNextPalette() {
|
void handleNextPalette() {
|
||||||
Screen::get()->nextPalette();
|
Screen::get()->nextPalette();
|
||||||
Notifier::get()->show({Locale::get()->get("ui.palette") + " " + toUpper(Screen::get()->getPalettePrettyName())}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("ui.palette") + " " + toUpper(Screen::get()->getPalettePrettyName())});
|
||||||
}
|
}
|
||||||
|
|
||||||
void handlePreviousPalette() {
|
void handlePreviousPalette() {
|
||||||
Screen::get()->previousPalette();
|
Screen::get()->previousPalette();
|
||||||
Notifier::get()->show({Locale::get()->get("ui.palette") + " " + toUpper(Screen::get()->getPalettePrettyName())}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("ui.palette") + " " + toUpper(Screen::get()->getPalettePrettyName())});
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleNextPaletteSortMode() {
|
void handleNextPaletteSortMode() {
|
||||||
Screen::get()->nextPaletteSortMode();
|
Screen::get()->nextPaletteSortMode();
|
||||||
Notifier::get()->show({Locale::get()->get("ui.palette_sort") + " " + toUpper(Screen::get()->getPaletteSortModeName())}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("ui.palette_sort") + " " + toUpper(Screen::get()->getPaletteSortModeName())});
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleToggleIntegerScale() {
|
void handleToggleIntegerScale() {
|
||||||
Screen::get()->toggleIntegerScale();
|
Screen::get()->toggleIntegerScale();
|
||||||
Screen::get()->setVideoMode(Options::video.fullscreen);
|
Screen::get()->setVideoMode(Options::video.fullscreen);
|
||||||
Notifier::get()->show({Locale::get()->get(Options::video.integer_scale ? "ui.integer_scale_enabled" : "ui.integer_scale_disabled")}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get(Options::video.integer_scale ? "ui.integer_scale_enabled" : "ui.integer_scale_disabled")});
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleToggleVSync() {
|
void handleToggleVSync() {
|
||||||
Screen::get()->toggleVSync();
|
Screen::get()->toggleVSync();
|
||||||
Notifier::get()->show({Locale::get()->get(Options::video.vertical_sync ? "ui.vsync_enabled" : "ui.vsync_disabled")}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get(Options::video.vertical_sync ? "ui.vsync_enabled" : "ui.vsync_disabled")});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detecta qué acción global ha sido presionada (si alguna)
|
// Detecta qué acción global ha sido presionada (si alguna)
|
||||||
|
|||||||
+20
-20
@@ -50,7 +50,7 @@ static void installWebStandardMapping(SDL_JoystickID jid) {
|
|||||||
Input* Input::instance = nullptr;
|
Input* Input::instance = nullptr;
|
||||||
|
|
||||||
// Inicializa la instancia única del singleton
|
// Inicializa la instancia única del singleton
|
||||||
void Input::init(const std::string& game_controller_db_path) { // NOLINT(readability-convert-member-functions-to-static)
|
void Input::init(const std::string& game_controller_db_path) {
|
||||||
Input::instance = new Input(game_controller_db_path);
|
Input::instance = new Input(game_controller_db_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ void Input::applyKeyboardBindingsFromOptions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Aplica configuración de botones del gamepad desde Options al primer gamepad conectado
|
// Aplica configuración de botones del gamepad desde Options al primer gamepad conectado
|
||||||
void Input::applyGamepadBindingsFromOptions() { // NOLINT(readability-convert-member-functions-to-static)
|
void Input::applyGamepadBindingsFromOptions() {
|
||||||
// Si no hay gamepads conectados, no hay nada que hacer
|
// Si no hay gamepads conectados, no hay nada que hacer
|
||||||
if (gamepads_.empty()) {
|
if (gamepads_.empty()) {
|
||||||
return;
|
return;
|
||||||
@@ -127,21 +127,21 @@ void Input::applyGamepadBindingsFromOptions() { // NOLINT(readability-convert-m
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Asigna inputs a botones del mando
|
// Asigna inputs a botones del mando
|
||||||
void Input::bindGameControllerButton(const std::shared_ptr<Gamepad>& gamepad, Action action, SDL_GamepadButton button) { // NOLINT(readability-convert-member-functions-to-static)
|
void Input::bindGameControllerButton(const std::shared_ptr<Gamepad>& gamepad, Action action, SDL_GamepadButton button) {
|
||||||
if (gamepad != nullptr) {
|
if (gamepad != nullptr) {
|
||||||
gamepad->bindings[action].button = button;
|
gamepad->bindings[action].button = button;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asigna inputs a botones del mando
|
// Asigna inputs a botones del mando
|
||||||
void Input::bindGameControllerButton(const std::shared_ptr<Gamepad>& gamepad, Action action_target, Action action_source) { // NOLINT(readability-convert-member-functions-to-static)
|
void Input::bindGameControllerButton(const std::shared_ptr<Gamepad>& gamepad, Action action_target, Action action_source) {
|
||||||
if (gamepad != nullptr) {
|
if (gamepad != nullptr) {
|
||||||
gamepad->bindings[action_target].button = gamepad->bindings[action_source].button;
|
gamepad->bindings[action_target].button = gamepad->bindings[action_source].button;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si alguna acción está activa
|
// Comprueba si alguna acción está activa
|
||||||
auto Input::checkAction(Action action, bool repeat, bool check_keyboard, const std::shared_ptr<Gamepad>& gamepad) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto Input::checkAction(Action action, bool repeat, bool check_keyboard, const std::shared_ptr<Gamepad>& gamepad) -> bool {
|
||||||
bool success_keyboard = false;
|
bool success_keyboard = false;
|
||||||
bool success_controller = false;
|
bool success_controller = false;
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ auto Input::checkAction(Action action, bool repeat, bool check_keyboard, const s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si hay almenos una acción activa
|
// Comprueba si hay almenos una acción activa
|
||||||
auto Input::checkAnyInput(bool check_keyboard, const std::shared_ptr<Gamepad>& gamepad) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto Input::checkAnyInput(bool check_keyboard, const std::shared_ptr<Gamepad>& gamepad) -> bool {
|
||||||
// Obtenemos el número total de acciones posibles para iterar sobre ellas.
|
// Obtenemos el número total de acciones posibles para iterar sobre ellas.
|
||||||
|
|
||||||
// --- Comprobación del Teclado ---
|
// --- Comprobación del Teclado ---
|
||||||
@@ -205,7 +205,7 @@ auto Input::checkAnyInput(bool check_keyboard, const std::shared_ptr<Gamepad>& g
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si hay algún botón pulsado
|
// Comprueba si hay algún botón pulsado
|
||||||
auto Input::checkAnyButton(bool repeat) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto Input::checkAnyButton(bool repeat) -> bool {
|
||||||
return std::ranges::any_of(BUTTON_INPUTS, [&](auto bi) {
|
return std::ranges::any_of(BUTTON_INPUTS, [&](auto bi) {
|
||||||
if (checkAction(bi, repeat, CHECK_KEYBOARD)) {
|
if (checkAction(bi, repeat, CHECK_KEYBOARD)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -236,25 +236,25 @@ auto Input::getControllerNames() const -> std::vector<std::string> {
|
|||||||
auto Input::getNumGamepads() const -> int { return gamepads_.size(); }
|
auto Input::getNumGamepads() const -> int { return gamepads_.size(); }
|
||||||
|
|
||||||
// Obtiene el gamepad a partir de un event.id
|
// Obtiene el gamepad a partir de un event.id
|
||||||
auto Input::getGamepad(SDL_JoystickID id) const -> std::shared_ptr<Input::Gamepad> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Input::getGamepad(SDL_JoystickID id) const -> std::shared_ptr<Input::Gamepad> {
|
||||||
auto it = std::ranges::find_if(gamepads_,
|
auto it = std::ranges::find_if(gamepads_,
|
||||||
[id](const auto& gamepad) { return gamepad->instance_id == id; });
|
[id](const auto& gamepad) { return gamepad->instance_id == id; });
|
||||||
return (it != gamepads_.end()) ? *it : nullptr;
|
return (it != gamepads_.end()) ? *it : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Input::getGamepadByName(const std::string& name) const -> std::shared_ptr<Input::Gamepad> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Input::getGamepadByName(const std::string& name) const -> std::shared_ptr<Input::Gamepad> {
|
||||||
auto it = std::ranges::find_if(gamepads_,
|
auto it = std::ranges::find_if(gamepads_,
|
||||||
[&name](const auto& gamepad) { return gamepad && gamepad->name == name; });
|
[&name](const auto& gamepad) { return gamepad && gamepad->name == name; });
|
||||||
return (it != gamepads_.end()) ? *it : nullptr;
|
return (it != gamepads_.end()) ? *it : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el SDL_GamepadButton asignado a un action
|
// Obtiene el SDL_GamepadButton asignado a un action
|
||||||
auto Input::getControllerBinding(const std::shared_ptr<Gamepad>& gamepad, Action action) -> SDL_GamepadButton { // NOLINT(readability-convert-member-functions-to-static)
|
auto Input::getControllerBinding(const std::shared_ptr<Gamepad>& gamepad, Action action) -> SDL_GamepadButton {
|
||||||
return static_cast<SDL_GamepadButton>(gamepad->bindings[action].button);
|
return static_cast<SDL_GamepadButton>(gamepad->bindings[action].button);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el eje del mando
|
// Comprueba el eje del mando
|
||||||
auto Input::checkAxisInput(Action action, const std::shared_ptr<Gamepad>& gamepad, bool repeat) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto Input::checkAxisInput(Action action, const std::shared_ptr<Gamepad>& gamepad, bool repeat) -> bool {
|
||||||
// Obtener el binding configurado para esta acción
|
// Obtener el binding configurado para esta acción
|
||||||
auto& binding = gamepad->bindings[action];
|
auto& binding = gamepad->bindings[action];
|
||||||
|
|
||||||
@@ -297,7 +297,7 @@ auto Input::checkAxisInput(Action action, const std::shared_ptr<Gamepad>& gamepa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los triggers del mando como botones digitales
|
// Comprueba los triggers del mando como botones digitales
|
||||||
auto Input::checkTriggerInput(Action action, const std::shared_ptr<Gamepad>& gamepad, bool repeat) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto Input::checkTriggerInput(Action action, const std::shared_ptr<Gamepad>& gamepad, bool repeat) -> bool {
|
||||||
// Solo manejamos botones específicos que pueden ser triggers
|
// Solo manejamos botones específicos que pueden ser triggers
|
||||||
if (gamepad->bindings[action].button != static_cast<int>(SDL_GAMEPAD_BUTTON_INVALID)) {
|
if (gamepad->bindings[action].button != static_cast<int>(SDL_GAMEPAD_BUTTON_INVALID)) {
|
||||||
// Solo procesamos L2 y R2 como triggers
|
// Solo procesamos L2 y R2 como triggers
|
||||||
@@ -344,13 +344,13 @@ auto Input::checkTriggerInput(Action action, const std::shared_ptr<Gamepad>& gam
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::addGamepadMappingsFromFile() { // NOLINT(readability-convert-member-functions-to-static)
|
void Input::addGamepadMappingsFromFile() {
|
||||||
if (SDL_AddGamepadMappingsFromFile(gamepad_mappings_file_.c_str()) < 0) {
|
if (SDL_AddGamepadMappingsFromFile(gamepad_mappings_file_.c_str()) < 0) {
|
||||||
std::cout << "Error, could not load " << gamepad_mappings_file_.c_str() << " file: " << SDL_GetError() << '\n';
|
std::cout << "Error, could not load " << gamepad_mappings_file_.c_str() << " file: " << SDL_GetError() << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::discoverGamepads() { // NOLINT(readability-convert-member-functions-to-static)
|
void Input::discoverGamepads() {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
handleEvent(event); // Comprueba mandos conectados
|
handleEvent(event); // Comprueba mandos conectados
|
||||||
@@ -386,7 +386,7 @@ void Input::resetInputStates() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::update() { // NOLINT(readability-convert-member-functions-to-static)
|
void Input::update() {
|
||||||
// --- TECLADO ---
|
// --- TECLADO ---
|
||||||
const bool* key_states = SDL_GetKeyboardState(nullptr);
|
const bool* key_states = SDL_GetKeyboardState(nullptr);
|
||||||
|
|
||||||
@@ -419,7 +419,7 @@ void Input::update() { // NOLINT(readability-convert-member-functions-to-static
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Input::handleEvent(const SDL_Event& event) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
auto Input::handleEvent(const SDL_Event& event) -> std::string {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_EVENT_GAMEPAD_ADDED:
|
case SDL_EVENT_GAMEPAD_ADDED:
|
||||||
return addGamepad(event.gdevice.which);
|
return addGamepad(event.gdevice.which);
|
||||||
@@ -430,7 +430,7 @@ auto Input::handleEvent(const SDL_Event& event) -> std::string { // NOLINT(read
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Input::addGamepad(int device_index) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
auto Input::addGamepad(int device_index) -> std::string {
|
||||||
installWebStandardMapping(device_index);
|
installWebStandardMapping(device_index);
|
||||||
SDL_Gamepad* pad = SDL_OpenGamepad(device_index);
|
SDL_Gamepad* pad = SDL_OpenGamepad(device_index);
|
||||||
if (pad == nullptr) {
|
if (pad == nullptr) {
|
||||||
@@ -451,7 +451,7 @@ auto Input::addGamepad(int device_index) -> std::string { // NOLINT(readability
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Input::removeGamepad(SDL_JoystickID id) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
auto Input::removeGamepad(SDL_JoystickID id) -> std::string {
|
||||||
auto it = std::ranges::find_if(gamepads_, [id](const std::shared_ptr<Gamepad>& gamepad) -> bool {
|
auto it = std::ranges::find_if(gamepads_, [id](const std::shared_ptr<Gamepad>& gamepad) -> bool {
|
||||||
return gamepad->instance_id == id;
|
return gamepad->instance_id == id;
|
||||||
});
|
});
|
||||||
@@ -466,7 +466,7 @@ auto Input::removeGamepad(SDL_JoystickID id) -> std::string { // NOLINT(readabi
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::printConnectedGamepads() const { // NOLINT(readability-convert-member-functions-to-static)
|
void Input::printConnectedGamepads() const {
|
||||||
if (gamepads_.empty()) {
|
if (gamepads_.empty()) {
|
||||||
std::cout << "No hay gamepads conectados." << '\n';
|
std::cout << "No hay gamepads conectados." << '\n';
|
||||||
return;
|
return;
|
||||||
@@ -480,7 +480,7 @@ void Input::printConnectedGamepads() const { // NOLINT(readability-convert-memb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Input::findAvailableGamepadByName(const std::string& gamepad_name) -> std::shared_ptr<Input::Gamepad> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Input::findAvailableGamepadByName(const std::string& gamepad_name) -> std::shared_ptr<Input::Gamepad> {
|
||||||
// Si no hay gamepads disponibles, devolver gamepad por defecto
|
// Si no hay gamepads disponibles, devolver gamepad por defecto
|
||||||
if (gamepads_.empty()) {
|
if (gamepads_.empty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -11,13 +11,13 @@
|
|||||||
Locale* Locale::instance = nullptr;
|
Locale* Locale::instance = nullptr;
|
||||||
|
|
||||||
// [SINGLETON] Crea el objeto con esta función estática
|
// [SINGLETON] Crea el objeto con esta función estática
|
||||||
void Locale::init(const std::string& file_path) { // NOLINT(readability-convert-member-functions-to-static)
|
void Locale::init(const std::string& file_path) {
|
||||||
Locale::instance = new Locale();
|
Locale::instance = new Locale();
|
||||||
Locale::instance->loadFromFile(file_path);
|
Locale::instance->loadFromFile(file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// [SINGLETON] Crea el objeto desde contenido en memoria (para release con pack)
|
// [SINGLETON] Crea el objeto desde contenido en memoria (para release con pack)
|
||||||
void Locale::initFromContent(const std::string& content) { // NOLINT(readability-convert-member-functions-to-static)
|
void Locale::initFromContent(const std::string& content) {
|
||||||
Locale::instance = new Locale();
|
Locale::instance = new Locale();
|
||||||
Locale::instance->loadFromContent(content);
|
Locale::instance->loadFromContent(content);
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ auto Locale::get() -> Locale* {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve la traducción de la clave o la clave como fallback
|
// Devuelve la traducción de la clave o la clave como fallback
|
||||||
auto Locale::get(const std::string& key) const -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
auto Locale::get(const std::string& key) const -> std::string {
|
||||||
auto it = strings_.find(key);
|
auto it = strings_.find(key);
|
||||||
if (it != strings_.end()) {
|
if (it != strings_.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
@@ -45,7 +45,7 @@ auto Locale::get(const std::string& key) const -> std::string { // NOLINT(reada
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Aplana un nodo YAML de forma recursiva: {a: {b: "val"}} -> {"a.b" -> "val"}
|
// Aplana un nodo YAML de forma recursiva: {a: {b: "val"}} -> {"a.b" -> "val"}
|
||||||
void Locale::flatten(const void* node_ptr, const std::string& prefix) { // NOLINT(readability-convert-member-functions-to-static)
|
void Locale::flatten(const void* node_ptr, const std::string& prefix) {
|
||||||
const auto& node = *static_cast<const fkyaml::node*>(node_ptr);
|
const auto& node = *static_cast<const fkyaml::node*>(node_ptr);
|
||||||
|
|
||||||
for (auto itr = node.begin(); itr != node.end(); ++itr) {
|
for (auto itr = node.begin(); itr != node.end(); ++itr) {
|
||||||
@@ -63,7 +63,7 @@ void Locale::flatten(const void* node_ptr, const std::string& prefix) { // NOLI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga las traducciones desde contenido YAML en memoria
|
// Carga las traducciones desde contenido YAML en memoria
|
||||||
void Locale::loadFromContent(const std::string& content) { // NOLINT(readability-convert-member-functions-to-static)
|
void Locale::loadFromContent(const std::string& content) {
|
||||||
if (content.empty()) {
|
if (content.empty()) {
|
||||||
std::cerr << "Locale: contenido vacío, sin traducciones cargadas\n";
|
std::cerr << "Locale: contenido vacío, sin traducciones cargadas\n";
|
||||||
return;
|
return;
|
||||||
@@ -81,7 +81,7 @@ void Locale::loadFromContent(const std::string& content) { // NOLINT(readabilit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga las traducciones desde el fichero YAML indicado
|
// Carga las traducciones desde el fichero YAML indicado
|
||||||
void Locale::loadFromFile(const std::string& file_path) { // NOLINT(readability-convert-member-functions-to-static)
|
void Locale::loadFromFile(const std::string& file_path) {
|
||||||
if (file_path.empty()) {
|
if (file_path.empty()) {
|
||||||
std::cerr << "Locale: ruta de fichero vacía, sin traducciones cargadas\n";
|
std::cerr << "Locale: ruta de fichero vacía, sin traducciones cargadas\n";
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace GIF {
|
|||||||
return match_len;
|
return match_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gif::decompress(int code_length, const uint8_t* input, int input_length, uint8_t* out) { // NOLINT(readability-convert-member-functions-to-static)
|
void Gif::decompress(int code_length, const uint8_t* input, int input_length, uint8_t* out) {
|
||||||
// Verifica que el code_length tenga un rango razonable.
|
// Verifica que el code_length tenga un rango razonable.
|
||||||
if (code_length < 2 || code_length > 12) {
|
if (code_length < 2 || code_length > 12) {
|
||||||
throw std::runtime_error("Invalid LZW code length");
|
throw std::runtime_error("Invalid LZW code length");
|
||||||
@@ -146,7 +146,7 @@ namespace GIF {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Gif::readSubBlocks(const uint8_t*& buffer) -> std::vector<uint8_t> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Gif::readSubBlocks(const uint8_t*& buffer) -> std::vector<uint8_t> {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
uint8_t block_size = *buffer;
|
uint8_t block_size = *buffer;
|
||||||
buffer++;
|
buffer++;
|
||||||
@@ -159,7 +159,7 @@ namespace GIF {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Gif::processImageDescriptor(const uint8_t*& buffer, const std::vector<RGB>& gct, int resolution_bits) -> std::vector<uint8_t> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Gif::processImageDescriptor(const uint8_t*& buffer, const std::vector<RGB>& gct, int resolution_bits) -> std::vector<uint8_t> {
|
||||||
ImageDescriptor image_descriptor;
|
ImageDescriptor image_descriptor;
|
||||||
// Lee 9 bytes para el image descriptor.
|
// Lee 9 bytes para el image descriptor.
|
||||||
readBytes(buffer, &image_descriptor, sizeof(ImageDescriptor));
|
readBytes(buffer, &image_descriptor, sizeof(ImageDescriptor));
|
||||||
@@ -175,7 +175,7 @@ namespace GIF {
|
|||||||
return uncompressed_data;
|
return uncompressed_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Gif::loadPalette(const uint8_t* buffer) -> std::vector<uint32_t> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Gif::loadPalette(const uint8_t* buffer) -> std::vector<uint32_t> {
|
||||||
uint8_t header[6];
|
uint8_t header[6];
|
||||||
std::memcpy(header, buffer, 6);
|
std::memcpy(header, buffer, 6);
|
||||||
buffer += 6;
|
buffer += 6;
|
||||||
@@ -199,7 +199,7 @@ namespace GIF {
|
|||||||
return global_color_table;
|
return global_color_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Gif::processGifStream(const uint8_t* buffer, uint16_t& w, uint16_t& h) -> std::vector<uint8_t> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Gif::processGifStream(const uint8_t* buffer, uint16_t& w, uint16_t& h) -> std::vector<uint8_t> {
|
||||||
// Leer la cabecera de 6 bytes ("GIF87a" o "GIF89a")
|
// Leer la cabecera de 6 bytes ("GIF87a" o "GIF89a")
|
||||||
uint8_t header[6];
|
uint8_t header[6];
|
||||||
std::memcpy(header, buffer, 6);
|
std::memcpy(header, buffer, 6);
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ PixelReveal::PixelReveal(int width, int height, float pixels_per_second, float s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el estado del revelado
|
// Actualiza el estado del revelado
|
||||||
void PixelReveal::update(float time_active) { // NOLINT(readability-make-member-function-const)
|
void PixelReveal::update(float time_active) {
|
||||||
// En modo normal revela (pone transparente); en modo inverso cubre (pone negro)
|
// En modo normal revela (pone transparente); en modo inverso cubre (pone negro)
|
||||||
const auto PIXEL_COLOR = reverse_ ? static_cast<Uint8>(PaletteColor::BLACK) : static_cast<Uint8>(PaletteColor::TRANSPARENT);
|
const auto PIXEL_COLOR = reverse_ ? static_cast<Uint8>(PaletteColor::BLACK) : static_cast<Uint8>(PaletteColor::TRANSPARENT);
|
||||||
|
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ void Screen::nextPalette() { palette_manager_->next(); }
|
|||||||
void Screen::previousPalette() { palette_manager_->previous(); }
|
void Screen::previousPalette() { palette_manager_->previous(); }
|
||||||
|
|
||||||
// Copia la surface a la textura
|
// Copia la surface a la textura
|
||||||
void Screen::surfaceToTexture() { // NOLINT(readability-convert-member-functions-to-static)
|
void Screen::surfaceToTexture() {
|
||||||
if (Options::video.border.enabled) {
|
if (Options::video.border.enabled) {
|
||||||
border_surface_->copyToTexture(renderer_, border_texture_);
|
border_surface_->copyToTexture(renderer_, border_texture_);
|
||||||
game_surface_->copyToTexture(renderer_, border_texture_, nullptr, &game_surface_dstrect_);
|
game_surface_->copyToTexture(renderer_, border_texture_, nullptr, &game_surface_dstrect_);
|
||||||
@@ -616,7 +616,7 @@ void Screen::toggleSupersampling() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Aplica los parámetros del preset actual al backend de shaders
|
// Aplica los parámetros del preset actual al backend de shaders
|
||||||
void Screen::applyCurrentPostFXPreset() { // NOLINT(readability-convert-member-functions-to-static)
|
void Screen::applyCurrentPostFXPreset() {
|
||||||
if (shader_backend_ && !Options::postfx_presets.empty()) {
|
if (shader_backend_ && !Options::postfx_presets.empty()) {
|
||||||
const auto& p = Options::postfx_presets[static_cast<size_t>(Options::video.shader.current_postfx_preset)];
|
const auto& p = Options::postfx_presets[static_cast<size_t>(Options::video.shader.current_postfx_preset)];
|
||||||
// Supersampling es un toggle global (Options::video.supersampling.enabled), no por preset.
|
// Supersampling es un toggle global (Options::video.supersampling.enabled), no por preset.
|
||||||
@@ -629,7 +629,7 @@ void Screen::applyCurrentPostFXPreset() { // NOLINT(readability-convert-member-
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Aplica los parámetros del preset CrtPi actual al backend de shaders
|
// Aplica los parámetros del preset CrtPi actual al backend de shaders
|
||||||
void Screen::applyCurrentCrtPiPreset() { // NOLINT(readability-convert-member-functions-to-static)
|
void Screen::applyCurrentCrtPiPreset() {
|
||||||
if (shader_backend_ && !Options::crtpi_presets.empty()) {
|
if (shader_backend_ && !Options::crtpi_presets.empty()) {
|
||||||
const auto& p = Options::crtpi_presets[static_cast<size_t>(Options::video.shader.current_crtpi_preset)];
|
const auto& p = Options::crtpi_presets[static_cast<size_t>(Options::video.shader.current_crtpi_preset)];
|
||||||
Rendering::CrtPiParams params{
|
Rendering::CrtPiParams params{
|
||||||
@@ -718,7 +718,7 @@ void Screen::initShaders() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene información sobre la pantalla
|
// Obtiene información sobre la pantalla
|
||||||
void Screen::getDisplayInfo() { // NOLINT(readability-convert-member-functions-to-static)
|
void Screen::getDisplayInfo() {
|
||||||
std::cout << "\n** VIDEO SYSTEM **\n";
|
std::cout << "\n** VIDEO SYSTEM **\n";
|
||||||
|
|
||||||
int num_displays = 0;
|
int num_displays = 0;
|
||||||
@@ -827,7 +827,7 @@ auto Screen::initSDLVideo() -> bool {
|
|||||||
// Registra els callbacks natius d'Emscripten que restauren el canvas quan
|
// Registra els callbacks natius d'Emscripten que restauren el canvas quan
|
||||||
// SDL3 no emet els events equivalents. Fora d'Emscripten és un no-op.
|
// SDL3 no emet els events equivalents. Fora d'Emscripten és un no-op.
|
||||||
// Vegeu el bloc de documentació a dalt del fitxer per al context complet.
|
// Vegeu el bloc de documentació a dalt del fitxer per al context complet.
|
||||||
void Screen::registerEmscriptenEventCallbacks() { // NOLINT(readability-convert-member-functions-to-static)
|
void Screen::registerEmscriptenEventCallbacks() {
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
// NO registrem resize callback. En mòbil, fer scroll fa que el navegador
|
// NO registrem resize callback. En mòbil, fer scroll fa que el navegador
|
||||||
// oculti/mostri la barra d'URL disparant un resize del DOM per cada scroll,
|
// oculti/mostri la barra d'URL disparant un resize del DOM per cada scroll,
|
||||||
@@ -838,7 +838,7 @@ void Screen::registerEmscriptenEventCallbacks() { // NOLINT(readability-convert
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea el objeto de texto
|
// Crea el objeto de texto
|
||||||
void Screen::createText() { // NOLINT(readability-convert-member-functions-to-static)
|
void Screen::createText() {
|
||||||
// Carga la surface de la fuente directamente del archivo
|
// Carga la surface de la fuente directamente del archivo
|
||||||
auto surface = std::make_shared<Surface>(Resource::List::get()->get("aseprite.gif"));
|
auto surface = std::make_shared<Surface>(Resource::List::get()->get("aseprite.gif"));
|
||||||
|
|
||||||
|
|||||||
@@ -1090,7 +1090,7 @@ namespace Rendering {
|
|||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto SDL3GPUShader::createShaderSPIRV(SDL_GPUDevice* device, // NOLINT(readability-convert-member-functions-to-static)
|
auto SDL3GPUShader::createShaderSPIRV(SDL_GPUDevice* device,
|
||||||
const uint8_t* spv_code,
|
const uint8_t* spv_code,
|
||||||
size_t spv_size,
|
size_t spv_size,
|
||||||
const char* entrypoint,
|
const char* entrypoint,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ auto convertYAMLFramesToRects(const fkyaml::node& frames_node, float frame_width
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga las animaciones desde un fichero YAML
|
// Carga las animaciones desde un fichero YAML
|
||||||
auto AnimatedSprite::loadAnimationsFromYAML(const std::string& file_path, std::shared_ptr<Surface>& surface, float& frame_width, float& frame_height) -> std::vector<AnimationData> { // NOLINT(readability-convert-member-functions-to-static)
|
auto AnimatedSprite::loadAnimationsFromYAML(const std::string& file_path, std::shared_ptr<Surface>& surface, float& frame_width, float& frame_height) -> std::vector<AnimationData> {
|
||||||
std::vector<AnimationData> animations;
|
std::vector<AnimationData> animations;
|
||||||
|
|
||||||
// Extract filename for logging
|
// Extract filename for logging
|
||||||
@@ -224,7 +224,7 @@ AnimatedSprite::AnimatedSprite(std::shared_ptr<Surface> surface, SDL_FRect pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el indice de la animación a partir del nombre
|
// Obtiene el indice de la animación a partir del nombre
|
||||||
auto AnimatedSprite::getIndex(const std::string& name) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto AnimatedSprite::getIndex(const std::string& name) -> int {
|
||||||
auto index = -1;
|
auto index = -1;
|
||||||
|
|
||||||
for (const auto& a : animations_) {
|
for (const auto& a : animations_) {
|
||||||
@@ -238,7 +238,7 @@ auto AnimatedSprite::getIndex(const std::string& name) -> int { // NOLINT(reada
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcula el frame correspondiente a la animación (time-based)
|
// Calcula el frame correspondiente a la animación (time-based)
|
||||||
void AnimatedSprite::animate(float delta_time) { // NOLINT(readability-convert-member-functions-to-static)
|
void AnimatedSprite::animate(float delta_time) {
|
||||||
if (animations_.empty()) { return; }
|
if (animations_.empty()) { return; }
|
||||||
if (animations_[current_animation_].speed <= 0.0F) {
|
if (animations_[current_animation_].speed <= 0.0F) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -148,14 +148,14 @@ void Surface::setColor(int index, Uint32 color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rellena la superficie con un color
|
// Rellena la superficie con un color
|
||||||
void Surface::clear(Uint8 color) { // NOLINT(readability-convert-member-functions-to-static)
|
void Surface::clear(Uint8 color) {
|
||||||
const size_t TOTAL_PIXELS = static_cast<size_t>(surface_data_->width) * static_cast<size_t>(surface_data_->height);
|
const size_t TOTAL_PIXELS = static_cast<size_t>(surface_data_->width) * static_cast<size_t>(surface_data_->height);
|
||||||
Uint8* data_ptr = surface_data_->data.get();
|
Uint8* data_ptr = surface_data_->data.get();
|
||||||
std::fill(data_ptr, data_ptr + TOTAL_PIXELS, color);
|
std::fill(data_ptr, data_ptr + TOTAL_PIXELS, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pone un pixel en la SurfaceData
|
// Pone un pixel en la SurfaceData
|
||||||
void Surface::putPixel(int x, int y, Uint8 color) { // NOLINT(readability-convert-member-functions-to-static)
|
void Surface::putPixel(int x, int y, Uint8 color) {
|
||||||
if (x < 0 || y < 0 || x >= surface_data_->width || y >= surface_data_->height) {
|
if (x < 0 || y < 0 || x >= surface_data_->width || y >= surface_data_->height) {
|
||||||
return; // Coordenadas fuera de rango
|
return; // Coordenadas fuera de rango
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ void Surface::putPixel(int x, int y, Uint8 color) { // NOLINT(readability-conve
|
|||||||
auto Surface::getPixel(int x, int y) -> Uint8 { return surface_data_->data.get()[x + (y * surface_data_->width)]; }
|
auto Surface::getPixel(int x, int y) -> Uint8 { return surface_data_->data.get()[x + (y * surface_data_->width)]; }
|
||||||
|
|
||||||
// Dibuja un rectangulo relleno
|
// Dibuja un rectangulo relleno
|
||||||
void Surface::fillRect(const SDL_FRect* rect, Uint8 color) { // NOLINT(readability-convert-member-functions-to-static)
|
void Surface::fillRect(const SDL_FRect* rect, Uint8 color) {
|
||||||
// Limitar los valores del rectángulo al tamaño de la superficie
|
// Limitar los valores del rectángulo al tamaño de la superficie
|
||||||
float x_start = std::max(0.0F, rect->x);
|
float x_start = std::max(0.0F, rect->x);
|
||||||
float y_start = std::max(0.0F, rect->y);
|
float y_start = std::max(0.0F, rect->y);
|
||||||
@@ -185,7 +185,7 @@ void Surface::fillRect(const SDL_FRect* rect, Uint8 color) { // NOLINT(readabil
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja el borde de un rectangulo
|
// Dibuja el borde de un rectangulo
|
||||||
void Surface::drawRectBorder(const SDL_FRect* rect, Uint8 color) { // NOLINT(readability-convert-member-functions-to-static)
|
void Surface::drawRectBorder(const SDL_FRect* rect, Uint8 color) {
|
||||||
// Limitar los valores del rectángulo al tamaño de la superficie
|
// Limitar los valores del rectángulo al tamaño de la superficie
|
||||||
float x_start = std::max(0.0F, rect->x);
|
float x_start = std::max(0.0F, rect->x);
|
||||||
float y_start = std::max(0.0F, rect->y);
|
float y_start = std::max(0.0F, rect->y);
|
||||||
@@ -212,7 +212,7 @@ void Surface::drawRectBorder(const SDL_FRect* rect, Uint8 color) { // NOLINT(re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja una linea (Bresenham en enteros)
|
// Dibuja una linea (Bresenham en enteros)
|
||||||
void Surface::drawLine(float x1, float y1, float x2, float y2, Uint8 color) { // NOLINT(readability-convert-member-functions-to-static)
|
void Surface::drawLine(float x1, float y1, float x2, float y2, Uint8 color) {
|
||||||
int ix1 = static_cast<int>(std::lround(x1));
|
int ix1 = static_cast<int>(std::lround(x1));
|
||||||
int iy1 = static_cast<int>(std::lround(y1));
|
int iy1 = static_cast<int>(std::lround(y1));
|
||||||
const int IX2 = static_cast<int>(std::lround(x2));
|
const int IX2 = static_cast<int>(std::lround(x2));
|
||||||
@@ -247,7 +247,7 @@ void Surface::drawLine(float x1, float y1, float x2, float y2, Uint8 color) { /
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Surface::render(int x, int y, SDL_FRect* src_rect, SDL_FlipMode flip) { // NOLINT(readability-make-member-function-const)
|
void Surface::render(int x, int y, SDL_FRect* src_rect, SDL_FlipMode flip) {
|
||||||
auto surface_data_dest = Screen::get()->getRendererSurface()->getSurfaceData();
|
auto surface_data_dest = Screen::get()->getRendererSurface()->getSurfaceData();
|
||||||
|
|
||||||
// Determina la región de origen (clip) a renderizar
|
// Determina la región de origen (clip) a renderizar
|
||||||
@@ -513,7 +513,7 @@ void Surface::toARGBBuffer(Uint32* buffer) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Vuelca la superficie a una textura
|
// Vuelca la superficie a una textura
|
||||||
void Surface::copyToTexture(SDL_Renderer* renderer, SDL_Texture* texture) { // NOLINT(readability-convert-member-functions-to-static)
|
void Surface::copyToTexture(SDL_Renderer* renderer, SDL_Texture* texture) {
|
||||||
if ((renderer == nullptr) || (texture == nullptr) || !surface_data_) {
|
if ((renderer == nullptr) || (texture == nullptr) || !surface_data_) {
|
||||||
throw std::runtime_error("Renderer or texture is null.");
|
throw std::runtime_error("Renderer or texture is null.");
|
||||||
}
|
}
|
||||||
@@ -555,7 +555,7 @@ void Surface::copyToTexture(SDL_Renderer* renderer, SDL_Texture* texture) { //
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Vuelca la superficie a una textura
|
// Vuelca la superficie a una textura
|
||||||
void Surface::copyToTexture(SDL_Renderer* renderer, SDL_Texture* texture, SDL_FRect* src_rect, SDL_FRect* dest_rect) { // NOLINT(readability-convert-member-functions-to-static)
|
void Surface::copyToTexture(SDL_Renderer* renderer, SDL_Texture* texture, SDL_FRect* src_rect, SDL_FRect* dest_rect) {
|
||||||
if ((renderer == nullptr) || (texture == nullptr) || !surface_data_) {
|
if ((renderer == nullptr) || (texture == nullptr) || !surface_data_) {
|
||||||
throw std::runtime_error("Renderer or texture is null.");
|
throw std::runtime_error("Renderer or texture is null.");
|
||||||
}
|
}
|
||||||
@@ -604,7 +604,7 @@ void Surface::copyToTexture(SDL_Renderer* renderer, SDL_Texture* texture, SDL_FR
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Realiza un efecto de fundido en la paleta principal
|
// Realiza un efecto de fundido en la paleta principal
|
||||||
auto Surface::fadePalette() -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto Surface::fadePalette() -> bool {
|
||||||
static constexpr int PALETTE_SIZE = 19;
|
static constexpr int PALETTE_SIZE = 19;
|
||||||
static_assert(std::tuple_size_v<Palette> >= PALETTE_SIZE, "Palette size is insufficient for fadePalette operation.");
|
static_assert(std::tuple_size_v<Palette> >= PALETTE_SIZE, "Palette size is insufficient for fadePalette operation.");
|
||||||
|
|
||||||
@@ -621,7 +621,7 @@ auto Surface::fadePalette() -> bool { // NOLINT(readability-convert-member-func
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Realiza un efecto de fundido en la paleta secundaria
|
// Realiza un efecto de fundido en la paleta secundaria
|
||||||
auto Surface::fadeSubPalette(Uint32 delay) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto Surface::fadeSubPalette(Uint32 delay) -> bool {
|
||||||
// Variable estática para almacenar el último tick
|
// Variable estática para almacenar el último tick
|
||||||
static Uint32 last_tick_ = 0;
|
static Uint32 last_tick_ = 0;
|
||||||
|
|
||||||
@@ -652,4 +652,4 @@ auto Surface::fadeSubPalette(Uint32 delay) -> bool { // NOLINT(readability-conv
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restaura la sub paleta a su estado original
|
// Restaura la sub paleta a su estado original
|
||||||
void Surface::resetSubPalette() { initializeSubPalette(sub_palette_); } // NOLINT(readability-convert-member-functions-to-static)
|
void Surface::resetSubPalette() { initializeSubPalette(sub_palette_); }
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include "utils/utils.hpp" // Para getFileName, stringToColor, printWithDots
|
#include "utils/utils.hpp" // Para getFileName, stringToColor, printWithDots
|
||||||
|
|
||||||
// Extrae el siguiente codepoint UTF-8 de la cadena, avanzando 'pos' al byte siguiente
|
// Extrae el siguiente codepoint UTF-8 de la cadena, avanzando 'pos' al byte siguiente
|
||||||
auto Text::nextCodepoint(const std::string& s, size_t& pos) -> uint32_t { // NOLINT(readability-convert-member-functions-to-static)
|
auto Text::nextCodepoint(const std::string& s, size_t& pos) -> uint32_t {
|
||||||
auto c = static_cast<unsigned char>(s[pos]);
|
auto c = static_cast<unsigned char>(s[pos]);
|
||||||
uint32_t cp = 0;
|
uint32_t cp = 0;
|
||||||
size_t extra = 0;
|
size_t extra = 0;
|
||||||
@@ -50,7 +50,7 @@ auto Text::nextCodepoint(const std::string& s, size_t& pos) -> uint32_t { // NO
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convierte un codepoint Unicode a una cadena UTF-8
|
// Convierte un codepoint Unicode a una cadena UTF-8
|
||||||
auto Text::codepointToUtf8(uint32_t cp) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
auto Text::codepointToUtf8(uint32_t cp) -> std::string {
|
||||||
std::string result;
|
std::string result;
|
||||||
if (cp < 0x80) {
|
if (cp < 0x80) {
|
||||||
result += static_cast<char>(cp);
|
result += static_cast<char>(cp);
|
||||||
@@ -72,7 +72,7 @@ auto Text::codepointToUtf8(uint32_t cp) -> std::string { // NOLINT(readability-
|
|||||||
|
|
||||||
// Carga un fichero de definición de fuente .fnt
|
// Carga un fichero de definición de fuente .fnt
|
||||||
// Formato: líneas "clave valor", comentarios con #, gliphos como "codepoint ancho"
|
// Formato: líneas "clave valor", comentarios con #, gliphos como "codepoint ancho"
|
||||||
auto Text::loadTextFile(const std::string& file_path) -> std::shared_ptr<File> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Text::loadTextFile(const std::string& file_path) -> std::shared_ptr<File> {
|
||||||
auto tf = std::make_shared<File>();
|
auto tf = std::make_shared<File>();
|
||||||
|
|
||||||
auto file_data = Resource::Helper::loadFile(file_path);
|
auto file_data = Resource::Helper::loadFile(file_path);
|
||||||
@@ -148,7 +148,7 @@ Text::Text(const std::shared_ptr<Surface>& surface, const std::shared_ptr<File>&
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe texto en pantalla
|
// Escribe texto en pantalla
|
||||||
void Text::write(int x, int y, const std::string& text, int kerning, int lenght) { // NOLINT(readability-convert-member-functions-to-static)
|
void Text::write(int x, int y, const std::string& text, int kerning, int lenght) {
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
int glyphs_done = 0;
|
int glyphs_done = 0;
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
@@ -170,7 +170,7 @@ void Text::write(int x, int y, const std::string& text, int kerning, int lenght)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto en una surface
|
// Escribe el texto en una surface
|
||||||
auto Text::writeToSurface(const std::string& text, int zoom, int kerning) -> std::shared_ptr<Surface> { // NOLINT(readability-make-member-function-const)
|
auto Text::writeToSurface(const std::string& text, int zoom, int kerning) -> std::shared_ptr<Surface> {
|
||||||
auto width = length(text, kerning) * zoom;
|
auto width = length(text, kerning) * zoom;
|
||||||
auto height = box_height_ * zoom;
|
auto height = box_height_ * zoom;
|
||||||
auto surface = std::make_shared<Surface>(width, height);
|
auto surface = std::make_shared<Surface>(width, height);
|
||||||
@@ -184,7 +184,7 @@ auto Text::writeToSurface(const std::string& text, int zoom, int kerning) -> std
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto con extras en una surface
|
// Escribe el texto con extras en una surface
|
||||||
auto Text::writeDXToSurface(Uint8 flags, const std::string& text, int kerning, Uint8 text_color, Uint8 shadow_distance, Uint8 shadow_color, int lenght) -> std::shared_ptr<Surface> { // NOLINT(readability-make-member-function-const)
|
auto Text::writeDXToSurface(Uint8 flags, const std::string& text, int kerning, Uint8 text_color, Uint8 shadow_distance, Uint8 shadow_color, int lenght) -> std::shared_ptr<Surface> {
|
||||||
auto width = Text::length(text, kerning) + shadow_distance;
|
auto width = Text::length(text, kerning) + shadow_distance;
|
||||||
auto height = box_height_ + shadow_distance;
|
auto height = box_height_ + shadow_distance;
|
||||||
auto surface = std::make_shared<Surface>(width, height);
|
auto surface = std::make_shared<Surface>(width, height);
|
||||||
@@ -198,7 +198,7 @@ auto Text::writeDXToSurface(Uint8 flags, const std::string& text, int kerning, U
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto con colores
|
// Escribe el texto con colores
|
||||||
void Text::writeColored(int x, int y, const std::string& text, Uint8 color, int kerning, int lenght) { // NOLINT(readability-convert-member-functions-to-static)
|
void Text::writeColored(int x, int y, const std::string& text, Uint8 color, int kerning, int lenght) {
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
int glyphs_done = 0;
|
int glyphs_done = 0;
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
@@ -232,7 +232,7 @@ void Text::writeCentered(int x, int y, const std::string& text, int kerning, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe texto con extras
|
// Escribe texto con extras
|
||||||
void Text::writeDX(Uint8 flags, int x, int y, const std::string& text, int kerning, Uint8 text_color, Uint8 shadow_distance, Uint8 shadow_color, int lenght) { // NOLINT(readability-convert-member-functions-to-static)
|
void Text::writeDX(Uint8 flags, int x, int y, const std::string& text, int kerning, Uint8 text_color, Uint8 shadow_distance, Uint8 shadow_color, int lenght) {
|
||||||
const auto CENTERED = ((flags & CENTER_FLAG) == CENTER_FLAG);
|
const auto CENTERED = ((flags & CENTER_FLAG) == CENTER_FLAG);
|
||||||
const auto SHADOWED = ((flags & SHADOW_FLAG) == SHADOW_FLAG);
|
const auto SHADOWED = ((flags & SHADOW_FLAG) == SHADOW_FLAG);
|
||||||
const auto COLORED = ((flags & COLOR_FLAG) == COLOR_FLAG);
|
const auto COLORED = ((flags & COLOR_FLAG) == COLOR_FLAG);
|
||||||
@@ -265,7 +265,7 @@ void Text::writeDX(Uint8 flags, int x, int y, const std::string& text, int kerni
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene la longitud en pixels de una cadena UTF-8
|
// Obtiene la longitud en pixels de una cadena UTF-8
|
||||||
auto Text::length(const std::string& text, int kerning) const -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto Text::length(const std::string& text, int kerning) const -> int {
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ auto Text::length(const std::string& text, int kerning) const -> int { // NOLIN
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el ancho en pixels de un glifo dado su codepoint Unicode
|
// Devuelve el ancho en pixels de un glifo dado su codepoint Unicode
|
||||||
auto Text::glyphWidth(uint32_t codepoint, int kerning) const -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto Text::glyphWidth(uint32_t codepoint, int kerning) const -> int {
|
||||||
auto it = offset_.find(codepoint);
|
auto it = offset_.find(codepoint);
|
||||||
if (it == offset_.end()) { it = offset_.find('?'); }
|
if (it == offset_.end()) { it = offset_.find('?'); }
|
||||||
if (it != offset_.end()) { return it->second.w + kerning; }
|
if (it != offset_.end()) { return it->second.w + kerning; }
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el sonido a partir de un nombre
|
// Obtiene el sonido a partir de un nombre
|
||||||
auto Cache::getSound(const std::string& name) -> Ja::Sound* { // NOLINT(readability-convert-member-functions-to-static)
|
auto Cache::getSound(const std::string& name) -> Ja::Sound* {
|
||||||
auto it = std::ranges::find_if(sounds_, [&name](const auto& s) -> bool { return s.name == name; });
|
auto it = std::ranges::find_if(sounds_, [&name](const auto& s) -> bool { return s.name == name; });
|
||||||
|
|
||||||
if (it != sounds_.end()) {
|
if (it != sounds_.end()) {
|
||||||
@@ -188,7 +188,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene la música a partir de un nombre
|
// Obtiene la música a partir de un nombre
|
||||||
auto Cache::getMusic(const std::string& name) -> Ja::Music* { // NOLINT(readability-convert-member-functions-to-static)
|
auto Cache::getMusic(const std::string& name) -> Ja::Music* {
|
||||||
auto it = std::ranges::find_if(musics_, [&name](const auto& m) -> bool { return m.name == name; });
|
auto it = std::ranges::find_if(musics_, [&name](const auto& m) -> bool { return m.name == name; });
|
||||||
|
|
||||||
if (it != musics_.end()) {
|
if (it != musics_.end()) {
|
||||||
@@ -200,7 +200,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene la surface a partir de un nombre
|
// Obtiene la surface a partir de un nombre
|
||||||
auto Cache::getSurface(const std::string& name) -> std::shared_ptr<Surface> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Cache::getSurface(const std::string& name) -> std::shared_ptr<Surface> {
|
||||||
auto it = std::ranges::find_if(surfaces_, [&name](const auto& t) -> bool { return t.name == name; });
|
auto it = std::ranges::find_if(surfaces_, [&name](const auto& t) -> bool { return t.name == name; });
|
||||||
|
|
||||||
if (it != surfaces_.end()) {
|
if (it != surfaces_.end()) {
|
||||||
@@ -212,7 +212,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene la paleta a partir de un nombre
|
// Obtiene la paleta a partir de un nombre
|
||||||
auto Cache::getPalette(const std::string& name) -> Palette { // NOLINT(readability-convert-member-functions-to-static)
|
auto Cache::getPalette(const std::string& name) -> Palette {
|
||||||
auto it = std::ranges::find_if(palettes_, [&name](const auto& t) -> bool { return t.name == name; });
|
auto it = std::ranges::find_if(palettes_, [&name](const auto& t) -> bool { return t.name == name; });
|
||||||
|
|
||||||
if (it != palettes_.end()) {
|
if (it != palettes_.end()) {
|
||||||
@@ -224,7 +224,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el fichero de texto a partir de un nombre
|
// Obtiene el fichero de texto a partir de un nombre
|
||||||
auto Cache::getTextFile(const std::string& name) -> std::shared_ptr<Text::File> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Cache::getTextFile(const std::string& name) -> std::shared_ptr<Text::File> {
|
||||||
auto it = std::ranges::find_if(text_files_, [&name](const auto& t) -> bool { return t.name == name; });
|
auto it = std::ranges::find_if(text_files_, [&name](const auto& t) -> bool { return t.name == name; });
|
||||||
|
|
||||||
if (it != text_files_.end()) {
|
if (it != text_files_.end()) {
|
||||||
@@ -236,7 +236,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el objeto de texto a partir de un nombre
|
// Obtiene el objeto de texto a partir de un nombre
|
||||||
auto Cache::getText(const std::string& name) -> std::shared_ptr<Text> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Cache::getText(const std::string& name) -> std::shared_ptr<Text> {
|
||||||
auto it = std::ranges::find_if(texts_, [&name](const auto& t) -> bool { return t.name == name; });
|
auto it = std::ranges::find_if(texts_, [&name](const auto& t) -> bool { return t.name == name; });
|
||||||
|
|
||||||
if (it != texts_.end()) {
|
if (it != texts_.end()) {
|
||||||
@@ -248,7 +248,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene los datos de animación parseados a partir de un nombre
|
// Obtiene los datos de animación parseados a partir de un nombre
|
||||||
auto Cache::getAnimationData(const std::string& name) -> const AnimationResource& { // NOLINT(readability-convert-member-functions-to-static)
|
auto Cache::getAnimationData(const std::string& name) -> const AnimationResource& {
|
||||||
auto it = std::ranges::find_if(animations_, [&name](const auto& a) -> bool { return a.name == name; });
|
auto it = std::ranges::find_if(animations_, [&name](const auto& a) -> bool { return a.name == name; });
|
||||||
|
|
||||||
if (it != animations_.end()) {
|
if (it != animations_.end()) {
|
||||||
@@ -260,7 +260,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene la habitación a partir de un nombre
|
// Obtiene la habitación a partir de un nombre
|
||||||
auto Cache::getRoom(const std::string& name) -> std::shared_ptr<Room::Data> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Cache::getRoom(const std::string& name) -> std::shared_ptr<Room::Data> {
|
||||||
auto it = std::ranges::find_if(rooms_, [&name](const auto& r) -> bool { return r.name == name; });
|
auto it = std::ranges::find_if(rooms_, [&name](const auto& r) -> bool { return r.name == name; });
|
||||||
|
|
||||||
if (it != rooms_.end()) {
|
if (it != rooms_.end()) {
|
||||||
@@ -306,7 +306,7 @@ namespace Resource {
|
|||||||
|
|
||||||
// Helper para registrar errores de carga con formato consistente.
|
// Helper para registrar errores de carga con formato consistente.
|
||||||
// El rethrow es responsabilitat del catch que crida la funció.
|
// El rethrow es responsabilitat del catch que crida la funció.
|
||||||
void Cache::logLoadError(const std::string& asset_type, const std::string& file_path, const std::exception& e) { // NOLINT(readability-convert-member-functions-to-static)
|
void Cache::logLoadError(const std::string& asset_type, const std::string& file_path, const std::exception& e) {
|
||||||
std::cerr << "\n[ ERROR ] Failed to load " << asset_type << ": " << getFileName(file_path) << '\n';
|
std::cerr << "\n[ ERROR ] Failed to load " << asset_type << ": " << getFileName(file_path) << '\n';
|
||||||
std::cerr << "[ ERROR ] Path: " << file_path << '\n';
|
std::cerr << "[ ERROR ] Path: " << file_path << '\n';
|
||||||
std::cerr << "[ ERROR ] Reason: " << e.what() << '\n';
|
std::cerr << "[ ERROR ] Reason: " << e.what() << '\n';
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ namespace Resource {
|
|||||||
// Singleton
|
// Singleton
|
||||||
List* List::instance = nullptr;
|
List* List::instance = nullptr;
|
||||||
|
|
||||||
void List::init(const std::string& executable_path) { // NOLINT(readability-convert-member-functions-to-static)
|
void List::init(const std::string& executable_path) {
|
||||||
List::instance = new List(executable_path);
|
List::instance = new List(executable_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void List::destroy() { // NOLINT(readability-convert-member-functions-to-static)
|
void List::destroy() {
|
||||||
delete List::instance;
|
delete List::instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade un elemento al mapa (función auxiliar)
|
// Añade un elemento al mapa (función auxiliar)
|
||||||
void List::addToMap(const std::string& file_path, Type type, bool required, bool absolute) { // NOLINT(readability-convert-member-functions-to-static)
|
void List::addToMap(const std::string& file_path, Type type, bool required, bool absolute) {
|
||||||
std::string full_path = absolute ? file_path : executable_path_ + file_path;
|
std::string full_path = absolute ? file_path : executable_path_ + file_path;
|
||||||
std::string filename = getFileName(full_path);
|
std::string filename = getFileName(full_path);
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga recursos desde un archivo de configuración con soporte para variables
|
// Carga recursos desde un archivo de configuración con soporte para variables
|
||||||
void List::loadFromFile(const std::string& config_file_path, const std::string& prefix, const std::string& system_folder) { // NOLINT(readability-convert-member-functions-to-static)
|
void List::loadFromFile(const std::string& config_file_path, const std::string& prefix, const std::string& system_folder) {
|
||||||
config_file_path_ = config_file_path;
|
config_file_path_ = config_file_path;
|
||||||
prefix_ = prefix;
|
prefix_ = prefix;
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga recursos desde un string de configuración (para release con pack)
|
// Carga recursos desde un string de configuración (para release con pack)
|
||||||
void List::loadFromString(const std::string& config_content, const std::string& prefix, const std::string& system_folder) { // NOLINT(readability-convert-member-functions-to-static,readability-function-cognitive-complexity)
|
void List::loadFromString(const std::string& config_content, const std::string& prefix, const std::string& system_folder) { // NOLINT(readability-function-cognitive-complexity)
|
||||||
try {
|
try {
|
||||||
// Parsear YAML
|
// Parsear YAML
|
||||||
auto yaml = fkyaml::node::deserialize(config_content);
|
auto yaml = fkyaml::node::deserialize(config_content);
|
||||||
@@ -282,7 +282,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve la ruta completa a un fichero (búsqueda O(1))
|
// Devuelve la ruta completa a un fichero (búsqueda O(1))
|
||||||
auto List::get(const std::string& filename) const -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
auto List::get(const std::string& filename) const -> std::string {
|
||||||
auto it = file_list_.find(filename);
|
auto it = file_list_.find(filename);
|
||||||
if (it != file_list_.end()) {
|
if (it != file_list_.end()) {
|
||||||
return it->second.file;
|
return it->second.file;
|
||||||
@@ -293,7 +293,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga datos del archivo
|
// Carga datos del archivo
|
||||||
auto List::loadData(const std::string& filename) const -> std::vector<uint8_t> { // NOLINT(readability-convert-member-functions-to-static)
|
auto List::loadData(const std::string& filename) const -> std::vector<uint8_t> {
|
||||||
auto it = file_list_.find(filename);
|
auto it = file_list_.find(filename);
|
||||||
if (it != file_list_.end()) {
|
if (it != file_list_.end()) {
|
||||||
std::ifstream file(it->second.file, std::ios::binary);
|
std::ifstream file(it->second.file, std::ios::binary);
|
||||||
@@ -327,7 +327,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parsea string a Type
|
// Parsea string a Type
|
||||||
auto List::parseAssetType(const std::string& type_str) -> Type { // NOLINT(readability-convert-member-functions-to-static)
|
auto List::parseAssetType(const std::string& type_str) -> Type {
|
||||||
if (type_str == "DATA") {
|
if (type_str == "DATA") {
|
||||||
return Type::DATA;
|
return Type::DATA;
|
||||||
}
|
}
|
||||||
@@ -361,7 +361,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el nombre del tipo de recurso
|
// Devuelve el nombre del tipo de recurso
|
||||||
auto List::getTypeName(Type type) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
auto List::getTypeName(Type type) -> std::string {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Type::DATA:
|
case Type::DATA:
|
||||||
return "DATA";
|
return "DATA";
|
||||||
@@ -385,7 +385,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve la lista de recursos de un tipo
|
// Devuelve la lista de recursos de un tipo
|
||||||
auto List::getListByType(Type type) const -> std::vector<std::string> { // NOLINT(readability-convert-member-functions-to-static)
|
auto List::getListByType(Type type) const -> std::vector<std::string> {
|
||||||
std::vector<std::string> list;
|
std::vector<std::string> list;
|
||||||
|
|
||||||
for (const auto& [filename, item] : file_list_) {
|
for (const auto& [filename, item] : file_list_) {
|
||||||
@@ -401,7 +401,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reemplaza variables en las rutas
|
// Reemplaza variables en las rutas
|
||||||
auto List::replaceVariables(const std::string& path, const std::string& prefix, const std::string& system_folder) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
auto List::replaceVariables(const std::string& path, const std::string& prefix, const std::string& system_folder) -> std::string {
|
||||||
std::string result = path;
|
std::string result = path;
|
||||||
|
|
||||||
// Reemplazar ${PREFIX}
|
// Reemplazar ${PREFIX}
|
||||||
@@ -422,7 +422,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parsea las opciones de una línea de configuración
|
// Parsea las opciones de una línea de configuración
|
||||||
auto List::parseOptions(const std::string& options, bool& required, bool& absolute) -> void { // NOLINT(readability-convert-member-functions-to-static)
|
auto List::parseOptions(const std::string& options, bool& required, bool& absolute) -> void {
|
||||||
if (options.empty()) {
|
if (options.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load a resource
|
// Load a resource
|
||||||
auto Loader::loadResource(const std::string& filename) -> std::vector<uint8_t> { // NOLINT(readability-make-member-function-const)
|
auto Loader::loadResource(const std::string& filename) -> std::vector<uint8_t> {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
std::cerr << "Loader: Not initialized\n";
|
std::cerr << "Loader: Not initialized\n";
|
||||||
return {};
|
return {};
|
||||||
@@ -81,7 +81,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if a resource exists
|
// Check if a resource exists
|
||||||
auto Loader::resourceExists(const std::string& filename) -> bool { // NOLINT(readability-make-member-function-const)
|
auto Loader::resourceExists(const std::string& filename) -> bool {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get pack statistics
|
// Get pack statistics
|
||||||
auto Loader::getPackResourceCount() const -> size_t { // NOLINT(readability-convert-member-functions-to-static)
|
auto Loader::getPackResourceCount() const -> size_t {
|
||||||
if (resource_pack_ && resource_pack_->isLoaded()) {
|
if (resource_pack_ && resource_pack_->isLoaded()) {
|
||||||
return resource_pack_->getResourceCount();
|
return resource_pack_->getResourceCount();
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load from filesystem
|
// Load from filesystem
|
||||||
auto Loader::loadFromFilesystem(const std::string& filepath) // NOLINT(readability-convert-member-functions-to-static)
|
auto Loader::loadFromFilesystem(const std::string& filepath)
|
||||||
-> std::vector<uint8_t> {
|
-> std::vector<uint8_t> {
|
||||||
std::ifstream file(filepath, std::ios::binary | std::ios::ate);
|
std::ifstream file(filepath, std::ios::binary | std::ios::ate);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@@ -147,7 +147,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate pack integrity
|
// Validate pack integrity
|
||||||
auto Loader::validatePack() const -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto Loader::validatePack() const -> bool {
|
||||||
if (!initialized_ || !resource_pack_ || !resource_pack_->isLoaded()) {
|
if (!initialized_ || !resource_pack_ || !resource_pack_->isLoaded()) {
|
||||||
std::cerr << "Loader: Cannot validate - pack not loaded\n";
|
std::cerr << "Loader: Cannot validate - pack not loaded\n";
|
||||||
return false;
|
return false;
|
||||||
@@ -158,7 +158,7 @@ namespace Resource {
|
|||||||
|
|
||||||
if (checksum == 0) {
|
if (checksum == 0) {
|
||||||
std::cerr << "Loader: Pack checksum is zero (invalid)\n";
|
std::cerr << "Loader: Pack checksum is zero (invalid)\n";
|
||||||
return false; // NOLINT(readability-simplify-boolean-expr)
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Loader: Pack checksum: 0x" << std::hex << checksum << std::dec
|
std::cout << "Loader: Pack checksum: 0x" << std::hex << checksum << std::dec
|
||||||
@@ -168,7 +168,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load assets.yaml from pack
|
// Load assets.yaml from pack
|
||||||
auto Loader::loadAssetsConfig() const -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
auto Loader::loadAssetsConfig() const -> std::string {
|
||||||
if (!initialized_ || !resource_pack_ || !resource_pack_->isLoaded()) {
|
if (!initialized_ || !resource_pack_ || !resource_pack_->isLoaded()) {
|
||||||
std::cerr << "Loader: Cannot load assets config - pack not loaded\n";
|
std::cerr << "Loader: Cannot load assets config - pack not loaded\n";
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
namespace Resource {
|
namespace Resource {
|
||||||
|
|
||||||
// Calculate CRC32 checksum for data verification
|
// Calculate CRC32 checksum for data verification
|
||||||
auto Pack::calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t { // NOLINT(readability-convert-member-functions-to-static)
|
auto Pack::calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t {
|
||||||
return std::accumulate(data.begin(), data.end(), uint32_t{0x12345678}, [](uint32_t acc, unsigned char byte) -> uint32_t {
|
return std::accumulate(data.begin(), data.end(), uint32_t{0x12345678}, [](uint32_t acc, unsigned char byte) -> uint32_t {
|
||||||
return ((acc << 5) + acc) + byte;
|
return ((acc << 5) + acc) + byte;
|
||||||
});
|
});
|
||||||
@@ -36,7 +36,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read entire file into memory
|
// Read entire file into memory
|
||||||
auto Pack::readFile(const std::string& filepath) -> std::vector<uint8_t> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Pack::readFile(const std::string& filepath) -> std::vector<uint8_t> {
|
||||||
std::ifstream file(filepath, std::ios::binary | std::ios::ate);
|
std::ifstream file(filepath, std::ios::binary | std::ios::ate);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
std::cerr << "ResourcePack: Failed to open file: " << filepath << '\n';
|
std::cerr << "ResourcePack: Failed to open file: " << filepath << '\n';
|
||||||
@@ -56,7 +56,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add a single file to the pack
|
// Add a single file to the pack
|
||||||
auto Pack::addFile(const std::string& filepath, const std::string& pack_name) // NOLINT(readability-convert-member-functions-to-static)
|
auto Pack::addFile(const std::string& filepath, const std::string& pack_name)
|
||||||
-> bool {
|
-> bool {
|
||||||
auto file_data = readFile(filepath);
|
auto file_data = readFile(filepath);
|
||||||
if (file_data.empty()) {
|
if (file_data.empty()) {
|
||||||
@@ -79,7 +79,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add all files from a directory recursively
|
// Add all files from a directory recursively
|
||||||
auto Pack::addDirectory(const std::string& dir_path, // NOLINT(readability-convert-member-functions-to-static)
|
auto Pack::addDirectory(const std::string& dir_path,
|
||||||
const std::string& base_path) -> bool {
|
const std::string& base_path) -> bool {
|
||||||
namespace fs = std::filesystem; // NOLINT(readability-identifier-naming)
|
namespace fs = std::filesystem; // NOLINT(readability-identifier-naming)
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save the pack to a file
|
// Save the pack to a file
|
||||||
auto Pack::savePack(const std::string& pack_file) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto Pack::savePack(const std::string& pack_file) -> bool {
|
||||||
std::ofstream file(pack_file, std::ios::binary);
|
std::ofstream file(pack_file, std::ios::binary);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
std::cerr << "ResourcePack: Failed to create pack file: " << pack_file << '\n';
|
std::cerr << "ResourcePack: Failed to create pack file: " << pack_file << '\n';
|
||||||
@@ -228,7 +228,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get a resource by name
|
// Get a resource by name
|
||||||
auto Pack::getResource(const std::string& filename) -> std::vector<uint8_t> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Pack::getResource(const std::string& filename) -> std::vector<uint8_t> {
|
||||||
auto it = resources_.find(filename);
|
auto it = resources_.find(filename);
|
||||||
if (it == resources_.end()) {
|
if (it == resources_.end()) {
|
||||||
return {};
|
return {};
|
||||||
@@ -262,7 +262,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get list of all resources
|
// Get list of all resources
|
||||||
auto Pack::getResourceList() const -> std::vector<std::string> { // NOLINT(readability-convert-member-functions-to-static)
|
auto Pack::getResourceList() const -> std::vector<std::string> {
|
||||||
std::vector<std::string> list;
|
std::vector<std::string> list;
|
||||||
list.reserve(resources_.size());
|
list.reserve(resources_.size());
|
||||||
for (const auto& [name, entry] : resources_) {
|
for (const auto& [name, entry] : resources_) {
|
||||||
@@ -273,7 +273,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate overall pack checksum for validation
|
// Calculate overall pack checksum for validation
|
||||||
auto Pack::calculatePackChecksum() const -> uint32_t { // NOLINT(readability-convert-member-functions-to-static)
|
auto Pack::calculatePackChecksum() const -> uint32_t {
|
||||||
if (!loaded_ || data_.empty()) {
|
if (!loaded_ || data_.empty()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ auto Debug::get() -> Debug* {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja en pantalla
|
// Dibuja en pantalla
|
||||||
void Debug::render() { // NOLINT(readability-make-member-function-const)
|
void Debug::render() {
|
||||||
auto text = Resource::Cache::get()->getText("aseprite");
|
auto text = Resource::Cache::get()->getText("aseprite");
|
||||||
int y = y_;
|
int y = y_;
|
||||||
int w = 0;
|
int w = 0;
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ Director::Director()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Configura la ruta y carga las opciones desde un fichero
|
// Configura la ruta y carga las opciones desde un fichero
|
||||||
Options::setConfigFile(Resource::List::get()->get("config.yaml")); // NOLINT(readability-static-accessed-through-instance)
|
Options::setConfigFile(Resource::List::get()->get("config.yaml"));
|
||||||
Options::loadFromFile();
|
Options::loadFromFile();
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
@@ -164,11 +164,11 @@ Director::Director()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Configura la ruta y carga los presets de PostFX
|
// Configura la ruta y carga los presets de PostFX
|
||||||
Options::setPostFXFile(Resource::List::get()->get("postfx.yaml")); // NOLINT(readability-static-accessed-through-instance)
|
Options::setPostFXFile(Resource::List::get()->get("postfx.yaml"));
|
||||||
Options::loadPostFXFromFile();
|
Options::loadPostFXFromFile();
|
||||||
|
|
||||||
// Configura la ruta y carga los presets del shader CrtPi
|
// Configura la ruta y carga los presets del shader CrtPi
|
||||||
Options::setCrtPiFile(Resource::List::get()->get("crtpi.yaml")); // NOLINT(readability-static-accessed-through-instance)
|
Options::setCrtPiFile(Resource::List::get()->get("crtpi.yaml"));
|
||||||
Options::loadCrtPiFromFile();
|
Options::loadCrtPiFromFile();
|
||||||
|
|
||||||
// En mode quiosc, forçar pantalla completa independentment de la configuració
|
// En mode quiosc, forçar pantalla completa independentment de la configuració
|
||||||
@@ -196,7 +196,7 @@ Director::Director()
|
|||||||
Input::init(gamecontroller_db);
|
Input::init(gamecontroller_db);
|
||||||
#else
|
#else
|
||||||
// In development, use Asset as normal
|
// In development, use Asset as normal
|
||||||
Input::init(Resource::List::get()->get("gamecontrollerdb.txt")); // NOLINT(readability-static-accessed-through-instance) Carga configuración de controles
|
Input::init(Resource::List::get()->get("gamecontrollerdb.txt")); // Carga configuración de controles
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Aplica las teclas y botones del gamepad configurados desde Options
|
// Aplica las teclas y botones del gamepad configurados desde Options
|
||||||
@@ -240,13 +240,13 @@ void Director::finishBoot() {
|
|||||||
#if defined(RELEASE_BUILD) && !defined(__EMSCRIPTEN__)
|
#if defined(RELEASE_BUILD) && !defined(__EMSCRIPTEN__)
|
||||||
{
|
{
|
||||||
// En release el locale está en el pack, no en el filesystem
|
// En release el locale está en el pack, no en el filesystem
|
||||||
std::string locale_key = Resource::List::get()->get(Options::language + ".yaml"); // NOLINT(readability-static-accessed-through-instance)
|
std::string locale_key = Resource::List::get()->get(Options::language + ".yaml");
|
||||||
auto locale_bytes = Resource::Helper::loadFile(locale_key);
|
auto locale_bytes = Resource::Helper::loadFile(locale_key);
|
||||||
std::string locale_content(locale_bytes.begin(), locale_bytes.end());
|
std::string locale_content(locale_bytes.begin(), locale_bytes.end());
|
||||||
Locale::initFromContent(locale_content);
|
Locale::initFromContent(locale_content);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Locale::init(Resource::List::get()->get(Options::language + ".yaml")); // NOLINT(readability-static-accessed-through-instance)
|
Locale::init(Resource::List::get()->get(Options::language + ".yaml"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Special handling for cheevos.bin - also needs filesystem path
|
// Special handling for cheevos.bin - also needs filesystem path
|
||||||
@@ -290,7 +290,7 @@ Director::~Director() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea la carpeta del sistema donde guardar datos
|
// Crea la carpeta del sistema donde guardar datos
|
||||||
void Director::createSystemFolder(const std::string& folder) { // NOLINT(readability-convert-member-functions-to-static)
|
void Director::createSystemFolder(const std::string& folder) {
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
// En Emscripten utilitzem MEMFS (no persistent entre sessions).
|
// En Emscripten utilitzem MEMFS (no persistent entre sessions).
|
||||||
// No cal crear directoris: MEMFS els crea automàticament en escriure-hi.
|
// No cal crear directoris: MEMFS els crea automàticament en escriure-hi.
|
||||||
@@ -352,7 +352,7 @@ void Director::createSystemFolder(const std::string& folder) { // NOLINT(readab
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga la configuración de assets desde assets.yaml
|
// Carga la configuración de assets desde assets.yaml
|
||||||
void Director::setFileList() { // NOLINT(readability-convert-member-functions-to-static)
|
void Director::setFileList() {
|
||||||
// Determinar el prefijo de ruta según la plataforma
|
// Determinar el prefijo de ruta según la plataforma
|
||||||
#ifdef MACOS_BUNDLE
|
#ifdef MACOS_BUNDLE
|
||||||
const std::string PREFIX = "/../Resources";
|
const std::string PREFIX = "/../Resources";
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ void Enemy::resetToInitialPosition(const Data& data) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Comprueba si ha llegado al limite del recorrido para darse media vuelta
|
// Comprueba si ha llegado al limite del recorrido para darse media vuelta
|
||||||
void Enemy::checkPath() { // NOLINT(readability-make-member-function-const)
|
void Enemy::checkPath() {
|
||||||
if (sprite_->getPosX() > x2_ || sprite_->getPosX() < x1_) {
|
if (sprite_->getPosX() > x2_ || sprite_->getPosX() < x1_) {
|
||||||
// Recoloca
|
// Recoloca
|
||||||
if (sprite_->getPosX() > x2_) {
|
if (sprite_->getPosX() > x2_) {
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ void Item::update(float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pinta el objeto en pantalla
|
// Pinta el objeto en pantalla
|
||||||
void Item::render() const { // NOLINT(readability-convert-member-functions-to-static)
|
void Item::render() const {
|
||||||
// Calcula el índice de color basado en el tiempo acumulado
|
// Calcula el índice de color basado en el tiempo acumulado
|
||||||
const int INDEX = static_cast<int>(time_accumulator_ / COLOR_CHANGE_INTERVAL) % static_cast<int>(color_.size());
|
const int INDEX = static_cast<int>(time_accumulator_ / COLOR_CHANGE_INTERVAL) % static_cast<int>(color_.size());
|
||||||
sprite_->render(1, color_.at(INDEX));
|
sprite_->render(1, color_.at(INDEX));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene su ubicación
|
// Obtiene su ubicación
|
||||||
auto Item::getPos() -> SDL_FPoint { // NOLINT(readability-convert-member-functions-to-static)
|
auto Item::getPos() -> SDL_FPoint {
|
||||||
const SDL_FPoint P = {.x = sprite_->getX(), .y = sprite_->getY()};
|
const SDL_FPoint P = {.x = sprite_->getX(), .y = sprite_->getY()};
|
||||||
return P;
|
return P;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ void Player::applyGravity(float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece la animación del jugador
|
// Establece la animación del jugador
|
||||||
void Player::animate(float delta_time) { // NOLINT(readability-make-member-function-const)
|
void Player::animate(float delta_time) {
|
||||||
if (vx_ != 0) {
|
if (vx_ != 0) {
|
||||||
sprite_->update(delta_time);
|
sprite_->update(delta_time);
|
||||||
}
|
}
|
||||||
@@ -479,7 +479,7 @@ void Player::handleJumpEnd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcula y reproduce el sonido de salto basado en tiempo transcurrido
|
// Calcula y reproduce el sonido de salto basado en tiempo transcurrido
|
||||||
void Player::playJumpSound(float delta_time) { // NOLINT(readability-convert-member-functions-to-static)
|
void Player::playJumpSound(float delta_time) {
|
||||||
size_t sound_index;
|
size_t sound_index;
|
||||||
if (jump_sound_ctrl_.shouldPlay(delta_time, sound_index)) {
|
if (jump_sound_ctrl_.shouldPlay(delta_time, sound_index)) {
|
||||||
if (sound_index < jumping_sound_.size()) {
|
if (sound_index < jumping_sound_.size()) {
|
||||||
@@ -489,7 +489,7 @@ void Player::playJumpSound(float delta_time) { // NOLINT(readability-convert-me
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcula y reproduce el sonido de caída basado en distancia vertical recorrida
|
// Calcula y reproduce el sonido de caída basado en distancia vertical recorrida
|
||||||
void Player::playFallSound(float delta_time) { // NOLINT(readability-convert-member-functions-to-static)
|
void Player::playFallSound(float delta_time) {
|
||||||
size_t sound_index;
|
size_t sound_index;
|
||||||
if (fall_sound_ctrl_.shouldPlay(delta_time, y_, sound_index)) {
|
if (fall_sound_ctrl_.shouldPlay(delta_time, y_, sound_index)) {
|
||||||
if (sound_index < falling_sound_.size()) {
|
if (sound_index < falling_sound_.size()) {
|
||||||
@@ -666,7 +666,7 @@ void Player::updateFeet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa los sonidos de salto y caida
|
// Inicializa los sonidos de salto y caida
|
||||||
void Player::initSounds() { // NOLINT(readability-convert-member-functions-to-static)
|
void Player::initSounds() {
|
||||||
for (int i = 0; i < 24; ++i) {
|
for (int i = 0; i < 24; ++i) {
|
||||||
std::string sound_file = "jump" + std::to_string(i + 1) + ".wav";
|
std::string sound_file = "jump" + std::to_string(i + 1) + ".wav";
|
||||||
jumping_sound_[i] = Resource::Cache::get()->getSound(sound_file);
|
jumping_sound_[i] = Resource::Cache::get()->getSound(sound_file);
|
||||||
@@ -708,7 +708,7 @@ auto Player::JumpSoundController::shouldPlay(float delta_time, size_t& out_index
|
|||||||
if (target_index > current_index) {
|
if (target_index > current_index) {
|
||||||
current_index = target_index;
|
current_index = target_index;
|
||||||
out_index = current_index;
|
out_index = current_index;
|
||||||
return true; // NOLINT(readability-simplify-boolean-expr)
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -787,7 +787,7 @@ void Player::setSkin(const std::string& skin_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa el sprite del jugador
|
// Inicializa el sprite del jugador
|
||||||
void Player::initSprite(const std::string& animations_path) { // NOLINT(readability-convert-member-functions-to-static)
|
void Player::initSprite(const std::string& animations_path) {
|
||||||
const auto& animation_data = Resource::Cache::get()->getAnimationData(animations_path);
|
const auto& animation_data = Resource::Cache::get()->getAnimationData(animations_path);
|
||||||
sprite_ = std::make_unique<AnimatedSprite>(animation_data);
|
sprite_ = std::make_unique<AnimatedSprite>(animation_data);
|
||||||
sprite_->setWidth(WIDTH);
|
sprite_->setWidth(WIDTH);
|
||||||
@@ -905,7 +905,7 @@ void Player::resetSoundControllersOnLanding() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el rectangulo de proyeccion
|
// Devuelve el rectangulo de proyeccion
|
||||||
auto Player::getProjection(Direction direction, float displacement) -> SDL_FRect { // NOLINT(readability-convert-member-functions-to-static)
|
auto Player::getProjection(Direction direction, float displacement) -> SDL_FRect {
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case Direction::LEFT:
|
case Direction::LEFT:
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
Cheevos* Cheevos::cheevos = nullptr;
|
Cheevos* Cheevos::cheevos = nullptr;
|
||||||
|
|
||||||
// [SINGLETON] Crearemos el objeto con esta función estática
|
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||||
void Cheevos::init(const std::string& file) { // NOLINT(readability-convert-member-functions-to-static)
|
void Cheevos::init(const std::string& file) {
|
||||||
Cheevos::cheevos = new Cheevos(file);
|
Cheevos::cheevos = new Cheevos(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ Cheevos::~Cheevos() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa los logros
|
// Inicializa los logros
|
||||||
void Cheevos::init() { // NOLINT(readability-convert-member-functions-to-static)
|
void Cheevos::init() {
|
||||||
cheevos_list_.clear();
|
cheevos_list_.clear();
|
||||||
const auto* loc = Locale::get();
|
const auto* loc = Locale::get();
|
||||||
cheevos_list_.emplace_back(Achievement{.id = 1, .caption = loc->get("achievements.c1"), .description = loc->get("achievements.d1"), .icon = 2});
|
cheevos_list_.emplace_back(Achievement{.id = 1, .caption = loc->get("achievements.c1"), .description = loc->get("achievements.d1"), .icon = 2});
|
||||||
@@ -61,7 +61,7 @@ void Cheevos::init() { // NOLINT(readability-convert-member-functions-to-static
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Busca un logro por id y devuelve el indice
|
// Busca un logro por id y devuelve el indice
|
||||||
auto Cheevos::find(int id) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto Cheevos::find(int id) -> int {
|
||||||
for (int i = 0; i < (int)cheevos_list_.size(); ++i) {
|
for (int i = 0; i < (int)cheevos_list_.size(); ++i) {
|
||||||
if (cheevos_list_[i].id == id) {
|
if (cheevos_list_[i].id == id) {
|
||||||
return i;
|
return i;
|
||||||
@@ -101,7 +101,7 @@ void Cheevos::setUnobtainable(int id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga el estado de los logros desde un fichero
|
// Carga el estado de los logros desde un fichero
|
||||||
void Cheevos::loadFromFile() { // NOLINT(readability-convert-member-functions-to-static)
|
void Cheevos::loadFromFile() {
|
||||||
std::ifstream file(file_, std::ios::binary);
|
std::ifstream file(file_, std::ios::binary);
|
||||||
|
|
||||||
// El fichero no existe
|
// El fichero no existe
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ auto CollisionMap::getTile(SDL_FPoint point) const -> Tile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el tipo de tile que hay en ese indice
|
// Devuelve el tipo de tile que hay en ese indice
|
||||||
auto CollisionMap::getTile(int index) const -> Tile { // NOLINT(readability-convert-member-functions-to-static)
|
auto CollisionMap::getTile(int index) const -> Tile {
|
||||||
const bool ON_RANGE = (index > -1) && (index < (int)tile_map_.size());
|
const bool ON_RANGE = (index > -1) && (index < (int)tile_map_.size());
|
||||||
|
|
||||||
if (ON_RANGE) {
|
if (ON_RANGE) {
|
||||||
@@ -107,21 +107,21 @@ auto CollisionMap::getSlopeHeight(SDL_FPoint p, Tile slope) -> int {
|
|||||||
// === Queries de colisión ===
|
// === Queries de colisión ===
|
||||||
|
|
||||||
// Comprueba las colisiones con paredes derechas
|
// Comprueba las colisiones con paredes derechas
|
||||||
auto CollisionMap::checkRightSurfaces(const SDL_FRect& rect) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto CollisionMap::checkRightSurfaces(const SDL_FRect& rect) -> int {
|
||||||
auto it = std::ranges::find_if(right_walls_,
|
auto it = std::ranges::find_if(right_walls_,
|
||||||
[&rect](const auto& s) { return checkCollision(s, rect); });
|
[&rect](const auto& s) { return checkCollision(s, rect); });
|
||||||
return (it != right_walls_.end()) ? it->x : Collision::NONE;
|
return (it != right_walls_.end()) ? it->x : Collision::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las colisiones con paredes izquierdas
|
// Comprueba las colisiones con paredes izquierdas
|
||||||
auto CollisionMap::checkLeftSurfaces(const SDL_FRect& rect) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto CollisionMap::checkLeftSurfaces(const SDL_FRect& rect) -> int {
|
||||||
auto it = std::ranges::find_if(left_walls_,
|
auto it = std::ranges::find_if(left_walls_,
|
||||||
[&rect](const auto& s) { return checkCollision(s, rect); });
|
[&rect](const auto& s) { return checkCollision(s, rect); });
|
||||||
return (it != left_walls_.end()) ? it->x : Collision::NONE;
|
return (it != left_walls_.end()) ? it->x : Collision::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las colisiones con techos
|
// Comprueba las colisiones con techos
|
||||||
auto CollisionMap::checkTopSurfaces(const SDL_FRect& rect) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto CollisionMap::checkTopSurfaces(const SDL_FRect& rect) -> int {
|
||||||
auto it = std::ranges::find_if(top_floors_,
|
auto it = std::ranges::find_if(top_floors_,
|
||||||
[&rect](const auto& s) { return checkCollision(s, rect); });
|
[&rect](const auto& s) { return checkCollision(s, rect); });
|
||||||
return (it != top_floors_.end()) ? it->y : Collision::NONE;
|
return (it != top_floors_.end()) ? it->y : Collision::NONE;
|
||||||
@@ -135,14 +135,14 @@ auto CollisionMap::checkTopSurfaces(const SDL_FPoint& p) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las colisiones con suelos
|
// Comprueba las colisiones con suelos
|
||||||
auto CollisionMap::checkBottomSurfaces(const SDL_FRect& rect) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto CollisionMap::checkBottomSurfaces(const SDL_FRect& rect) -> int {
|
||||||
auto it = std::ranges::find_if(bottom_floors_,
|
auto it = std::ranges::find_if(bottom_floors_,
|
||||||
[&rect](const auto& s) { return checkCollision(s, rect); });
|
[&rect](const auto& s) { return checkCollision(s, rect); });
|
||||||
return (it != bottom_floors_.end()) ? it->y : Collision::NONE;
|
return (it != bottom_floors_.end()) ? it->y : Collision::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las colisiones con conveyor belts
|
// Comprueba las colisiones con conveyor belts
|
||||||
auto CollisionMap::checkAutoSurfaces(const SDL_FRect& rect) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto CollisionMap::checkAutoSurfaces(const SDL_FRect& rect) -> int {
|
||||||
auto it = std::ranges::find_if(conveyor_belt_floors_,
|
auto it = std::ranges::find_if(conveyor_belt_floors_,
|
||||||
[&rect](const auto& s) { return checkCollision(s, rect); });
|
[&rect](const auto& s) { return checkCollision(s, rect); });
|
||||||
return (it != conveyor_belt_floors_.end()) ? it->y : Collision::NONE;
|
return (it != conveyor_belt_floors_.end()) ? it->y : Collision::NONE;
|
||||||
@@ -156,7 +156,7 @@ auto CollisionMap::checkConveyorBelts(const SDL_FPoint& p) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las colisiones línea con rampas izquierdas
|
// Comprueba las colisiones línea con rampas izquierdas
|
||||||
auto CollisionMap::checkLeftSlopes(const LineVertical& line) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto CollisionMap::checkLeftSlopes(const LineVertical& line) -> int {
|
||||||
for (const auto& slope : left_slopes_) {
|
for (const auto& slope : left_slopes_) {
|
||||||
const auto P = checkCollision(slope, line);
|
const auto P = checkCollision(slope, line);
|
||||||
if (P.x != -1) {
|
if (P.x != -1) {
|
||||||
@@ -174,7 +174,7 @@ auto CollisionMap::checkLeftSlopes(const SDL_FPoint& p) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las colisiones línea con rampas derechas
|
// Comprueba las colisiones línea con rampas derechas
|
||||||
auto CollisionMap::checkRightSlopes(const LineVertical& line) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto CollisionMap::checkRightSlopes(const LineVertical& line) -> int {
|
||||||
for (const auto& slope : right_slopes_) {
|
for (const auto& slope : right_slopes_) {
|
||||||
const auto P = checkCollision(slope, line);
|
const auto P = checkCollision(slope, line);
|
||||||
if (P.x != -1) {
|
if (P.x != -1) {
|
||||||
@@ -192,7 +192,7 @@ auto CollisionMap::checkRightSlopes(const SDL_FPoint& p) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene puntero a slope en un punto (prioriza left_slopes_ sobre right_slopes_)
|
// Obtiene puntero a slope en un punto (prioriza left_slopes_ sobre right_slopes_)
|
||||||
auto CollisionMap::getSlopeAtPoint(const SDL_FPoint& p) const -> const LineDiagonal* { // NOLINT(readability-convert-member-functions-to-static)
|
auto CollisionMap::getSlopeAtPoint(const SDL_FPoint& p) const -> const LineDiagonal* {
|
||||||
auto pred = [&p](const auto& slope) { return static_cast<bool>(checkCollision(p, slope)); };
|
auto pred = [&p](const auto& slope) { return static_cast<bool>(checkCollision(p, slope)); };
|
||||||
|
|
||||||
auto left_it = std::ranges::find_if(left_slopes_, pred);
|
auto left_it = std::ranges::find_if(left_slopes_, pred);
|
||||||
@@ -212,7 +212,7 @@ auto CollisionMap::getSlopeAtPoint(const SDL_FPoint& p) const -> const LineDiago
|
|||||||
// === Helpers para recopilar tiles ===
|
// === Helpers para recopilar tiles ===
|
||||||
|
|
||||||
// Helper: recopila tiles inferiores (muros sin muro debajo)
|
// Helper: recopila tiles inferiores (muros sin muro debajo)
|
||||||
auto CollisionMap::collectBottomTiles() -> std::vector<int> { // NOLINT(readability-make-member-function-const)
|
auto CollisionMap::collectBottomTiles() -> std::vector<int> {
|
||||||
std::vector<int> tile;
|
std::vector<int> tile;
|
||||||
|
|
||||||
// Busca todos los tiles de tipo muro que no tengan debajo otro muro
|
// Busca todos los tiles de tipo muro que no tengan debajo otro muro
|
||||||
@@ -234,7 +234,7 @@ auto CollisionMap::collectBottomTiles() -> std::vector<int> { // NOLINT(readabi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper: recopila tiles superiores (muros o pasables sin muro encima)
|
// Helper: recopila tiles superiores (muros o pasables sin muro encima)
|
||||||
auto CollisionMap::collectTopTiles() -> std::vector<int> { // NOLINT(readability-make-member-function-const)
|
auto CollisionMap::collectTopTiles() -> std::vector<int> {
|
||||||
std::vector<int> tile;
|
std::vector<int> tile;
|
||||||
|
|
||||||
// Busca todos los tiles de tipo muro o pasable que no tengan encima un muro
|
// Busca todos los tiles de tipo muro o pasable que no tengan encima un muro
|
||||||
@@ -256,7 +256,7 @@ auto CollisionMap::collectTopTiles() -> std::vector<int> { // NOLINT(readabilit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper: recopila tiles animados (para superficies automaticas/conveyor belts)
|
// Helper: recopila tiles animados (para superficies automaticas/conveyor belts)
|
||||||
auto CollisionMap::collectAnimatedTiles() -> std::vector<int> { // NOLINT(readability-make-member-function-const)
|
auto CollisionMap::collectAnimatedTiles() -> std::vector<int> {
|
||||||
std::vector<int> tile;
|
std::vector<int> tile;
|
||||||
|
|
||||||
// Busca todos los tiles de tipo animado
|
// Busca todos los tiles de tipo animado
|
||||||
@@ -281,7 +281,7 @@ auto CollisionMap::collectAnimatedTiles() -> std::vector<int> { // NOLINT(reada
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper: construye lineas horizontales a partir de tiles consecutivos
|
// Helper: construye lineas horizontales a partir de tiles consecutivos
|
||||||
void CollisionMap::buildHorizontalLines(const std::vector<int>& tiles, std::vector<LineHorizontal>& lines, bool is_bottom_surface) { // NOLINT(readability-convert-member-functions-to-static)
|
void CollisionMap::buildHorizontalLines(const std::vector<int>& tiles, std::vector<LineHorizontal>& lines, bool is_bottom_surface) {
|
||||||
if (tiles.size() <= 1) {
|
if (tiles.size() <= 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -337,7 +337,7 @@ void CollisionMap::setTopSurfaces() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcula las superficies laterales izquierdas
|
// Calcula las superficies laterales izquierdas
|
||||||
void CollisionMap::setLeftSurfaces() { // NOLINT(readability-make-member-function-const)
|
void CollisionMap::setLeftSurfaces() {
|
||||||
std::vector<int> tile;
|
std::vector<int> tile;
|
||||||
|
|
||||||
// Busca todos los tiles de tipo muro que no tienen a su izquierda un tile de tipo muro
|
// Busca todos los tiles de tipo muro que no tienen a su izquierda un tile de tipo muro
|
||||||
@@ -377,7 +377,7 @@ void CollisionMap::setLeftSurfaces() { // NOLINT(readability-make-member-functi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcula las superficies laterales derechas
|
// Calcula las superficies laterales derechas
|
||||||
void CollisionMap::setRightSurfaces() { // NOLINT(readability-make-member-function-const)
|
void CollisionMap::setRightSurfaces() {
|
||||||
std::vector<int> tile;
|
std::vector<int> tile;
|
||||||
|
|
||||||
// Busca todos los tiles de tipo muro que no tienen a su derecha un tile de tipo muro
|
// Busca todos los tiles de tipo muro que no tienen a su derecha un tile de tipo muro
|
||||||
@@ -417,7 +417,7 @@ void CollisionMap::setRightSurfaces() { // NOLINT(readability-make-member-funct
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Encuentra todas las rampas que suben hacia la izquierda
|
// Encuentra todas las rampas que suben hacia la izquierda
|
||||||
void CollisionMap::setLeftSlopes() { // NOLINT(readability-make-member-function-const)
|
void CollisionMap::setLeftSlopes() {
|
||||||
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_l
|
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_l
|
||||||
std::vector<int> found;
|
std::vector<int> found;
|
||||||
for (int i = 0; i < (int)tile_map_.size(); ++i) {
|
for (int i = 0; i < (int)tile_map_.size(); ++i) {
|
||||||
@@ -452,7 +452,7 @@ void CollisionMap::setLeftSlopes() { // NOLINT(readability-make-member-function
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Encuentra todas las rampas que suben hacia la derecha
|
// Encuentra todas las rampas que suben hacia la derecha
|
||||||
void CollisionMap::setRightSlopes() { // NOLINT(readability-make-member-function-const)
|
void CollisionMap::setRightSlopes() {
|
||||||
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_r
|
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_r
|
||||||
std::vector<int> found;
|
std::vector<int> found;
|
||||||
for (int i = 0; i < (int)tile_map_.size(); ++i) {
|
for (int i = 0; i < (int)tile_map_.size(); ++i) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ void EnemyManager::clear() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Elimina el último enemigo de la colección
|
// Elimina el último enemigo de la colección
|
||||||
void EnemyManager::removeLastEnemy() { // NOLINT(readability-convert-member-functions-to-static)
|
void EnemyManager::removeLastEnemy() {
|
||||||
if (!enemies_.empty()) {
|
if (!enemies_.empty()) {
|
||||||
enemies_.pop_back();
|
enemies_.pop_back();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ void ItemManager::setPaused(bool paused) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si hay colisión con algún item
|
// Comprueba si hay colisión con algún item
|
||||||
auto ItemManager::checkCollision(SDL_FRect& rect) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto ItemManager::checkCollision(SDL_FRect& rect) -> bool {
|
||||||
for (int i = 0; i < static_cast<int>(items_.size()); ++i) {
|
for (int i = 0; i < static_cast<int>(items_.size()); ++i) {
|
||||||
if (::checkCollision(rect, items_.at(i)->getCollider())) {
|
if (::checkCollision(rect, items_.at(i)->getCollider())) {
|
||||||
// Registra el item como recogido
|
// Registra el item como recogido
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ auto ItemTracker::hasBeenPicked(const std::string& name, SDL_FPoint pos) -> bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade el objeto a la lista de objetos cogidos
|
// Añade el objeto a la lista de objetos cogidos
|
||||||
void ItemTracker::addItem(const std::string& name, SDL_FPoint pos) { // NOLINT(readability-convert-member-functions-to-static)
|
void ItemTracker::addItem(const std::string& name, SDL_FPoint pos) {
|
||||||
// Comprueba si el objeto no ha sido recogido con anterioridad
|
// Comprueba si el objeto no ha sido recogido con anterioridad
|
||||||
if (!hasBeenPicked(name, pos)) {
|
if (!hasBeenPicked(name, pos)) {
|
||||||
// Primero busca si ya hay una entrada con ese nombre
|
// Primero busca si ya hay una entrada con ese nombre
|
||||||
@@ -47,7 +47,7 @@ void ItemTracker::addItem(const std::string& name, SDL_FPoint pos) { // NOLINT(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Busca una entrada en la lista por nombre
|
// Busca una entrada en la lista por nombre
|
||||||
auto ItemTracker::findByName(const std::string& name) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto ItemTracker::findByName(const std::string& name) -> int {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (const auto& item : items_) {
|
for (const auto& item : items_) {
|
||||||
@@ -61,7 +61,7 @@ auto ItemTracker::findByName(const std::string& name) -> int { // NOLINT(readab
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Busca una entrada en la lista por posición
|
// Busca una entrada en la lista por posición
|
||||||
auto ItemTracker::findByPos(int index, SDL_FPoint pos) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto ItemTracker::findByPos(int index, SDL_FPoint pos) -> int {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (const auto& item : items_[index].pos) {
|
for (const auto& item : items_[index].pos) {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ void Room::initializeRoom(const Data& room) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Abre la jail para poder entrar
|
// Abre la jail para poder entrar
|
||||||
void Room::openTheJail() { // NOLINT(readability-convert-member-functions-to-static)
|
void Room::openTheJail() {
|
||||||
if (data_->jail_is_open && number_ == Defaults::Game::Room::END_ROOM) {
|
if (data_->jail_is_open && number_ == Defaults::Game::Room::END_ROOM) {
|
||||||
// Elimina el último enemigo (Bry debe ser el último enemigo definido en el fichero)
|
// Elimina el último enemigo (Bry debe ser el último enemigo definido en el fichero)
|
||||||
if (!enemy_manager_->isEmpty()) {
|
if (!enemy_manager_->isEmpty()) {
|
||||||
@@ -163,7 +163,7 @@ void Room::setItemColors(const std::string& color1, const std::string& color2) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Actualiza las variables y objetos de la habitación
|
// Actualiza las variables y objetos de la habitación
|
||||||
void Room::update(float delta_time) { // NOLINT(readability-make-member-function-const)
|
void Room::update(float delta_time) {
|
||||||
if (is_paused_) {
|
if (is_paused_) {
|
||||||
// Si está en modo pausa no se actualiza nada
|
// Si está en modo pausa no se actualiza nada
|
||||||
return;
|
return;
|
||||||
@@ -187,7 +187,7 @@ void Room::setPaused(bool value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve la cadena del fichero de la habitación contigua segun el borde
|
// Devuelve la cadena del fichero de la habitación contigua segun el borde
|
||||||
auto Room::getRoom(Border border) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
auto Room::getRoom(Border border) -> std::string {
|
||||||
switch (border) {
|
switch (border) {
|
||||||
case Border::TOP:
|
case Border::TOP:
|
||||||
return upper_room_;
|
return upper_room_;
|
||||||
@@ -203,14 +203,14 @@ auto Room::getRoom(Border border) -> std::string { // NOLINT(readability-conver
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el tipo de tile que hay en ese pixel
|
// Devuelve el tipo de tile que hay en ese pixel
|
||||||
auto Room::getTile(SDL_FPoint point) -> Tile { // NOLINT(readability-convert-member-functions-to-static)
|
auto Room::getTile(SDL_FPoint point) -> Tile {
|
||||||
// Delega a CollisionMap y convierte el resultado
|
// Delega a CollisionMap y convierte el resultado
|
||||||
const auto COLLISION_TILE = collision_map_->getTile(point);
|
const auto COLLISION_TILE = collision_map_->getTile(point);
|
||||||
return static_cast<Tile>(COLLISION_TILE);
|
return static_cast<Tile>(COLLISION_TILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el tipo de tile en un índice del tilemap
|
// Devuelve el tipo de tile en un índice del tilemap
|
||||||
auto Room::getTile(int index) -> Tile { // NOLINT(readability-convert-member-functions-to-static)
|
auto Room::getTile(int index) -> Tile {
|
||||||
// Delega a CollisionMap y convierte el resultado
|
// Delega a CollisionMap y convierte el resultado
|
||||||
const auto COLLISION_TILE = collision_map_->getTile(index);
|
const auto COLLISION_TILE = collision_map_->getTile(index);
|
||||||
return static_cast<Tile>(COLLISION_TILE);
|
return static_cast<Tile>(COLLISION_TILE);
|
||||||
@@ -296,6 +296,6 @@ auto Room::getSlopeAtPoint(const SDL_FPoint& p) const -> const LineDiagonal* {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga una habitación desde un archivo YAML (delegado a RoomLoader)
|
// Carga una habitación desde un archivo YAML (delegado a RoomLoader)
|
||||||
auto Room::loadYAML(const std::string& file_path, bool verbose) -> Data { // NOLINT(readability-convert-member-functions-to-static)
|
auto Room::loadYAML(const std::string& file_path, bool verbose) -> Data {
|
||||||
return RoomLoader::loadYAML(file_path, verbose);
|
return RoomLoader::loadYAML(file_path, verbose);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "utils/utils.hpp" // Para stringToColor
|
#include "utils/utils.hpp" // Para stringToColor
|
||||||
|
|
||||||
// Convierte room connection de YAML a formato interno
|
// Convierte room connection de YAML a formato interno
|
||||||
auto RoomLoader::convertRoomConnection(const std::string& value) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
auto RoomLoader::convertRoomConnection(const std::string& value) -> std::string {
|
||||||
if (value == "null" || value.empty()) {
|
if (value == "null" || value.empty()) {
|
||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ auto RoomLoader::convertRoomConnection(const std::string& value) -> std::string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convierte string de autoSurface a int
|
// Convierte string de autoSurface a int
|
||||||
auto RoomLoader::convertAutoSurface(const fkyaml::node& node) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto RoomLoader::convertAutoSurface(const fkyaml::node& node) -> int {
|
||||||
if (node.is_integer()) {
|
if (node.is_integer()) {
|
||||||
return node.get_value<int>();
|
return node.get_value<int>();
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ auto RoomLoader::convertAutoSurface(const fkyaml::node& node) -> int { // NOLIN
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convierte un tilemap 2D a vector 1D flat
|
// Convierte un tilemap 2D a vector 1D flat
|
||||||
auto RoomLoader::flattenTilemap(const std::vector<std::vector<int>>& tilemap_2d) -> std::vector<int> { // NOLINT(readability-convert-member-functions-to-static, readability-named-parameter)
|
auto RoomLoader::flattenTilemap(const std::vector<std::vector<int>>& tilemap_2d) -> std::vector<int> { // NOLINT(readability-named-parameter)
|
||||||
std::vector<int> tilemap_flat;
|
std::vector<int> tilemap_flat;
|
||||||
tilemap_flat.reserve(512); // 16 rows × 32 cols
|
tilemap_flat.reserve(512); // 16 rows × 32 cols
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ auto RoomLoader::flattenTilemap(const std::vector<std::vector<int>>& tilemap_2d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parsea la configuración general de la habitación
|
// Parsea la configuración general de la habitación
|
||||||
void RoomLoader::parseRoomConfig(const fkyaml::node& yaml, Room::Data& room, const std::string& file_name) { // NOLINT(readability-convert-member-functions-to-static)
|
void RoomLoader::parseRoomConfig(const fkyaml::node& yaml, Room::Data& room, const std::string& file_name) {
|
||||||
if (!yaml.contains("room")) {
|
if (!yaml.contains("room")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ void RoomLoader::parseRoomConnections(const fkyaml::node& conn_node, Room::Data&
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parsea el tilemap de la habitación
|
// Parsea el tilemap de la habitación
|
||||||
void RoomLoader::parseTilemap(const fkyaml::node& yaml, Room::Data& room, const std::string& file_name, bool verbose) { // NOLINT(readability-convert-member-functions-to-static)
|
void RoomLoader::parseTilemap(const fkyaml::node& yaml, Room::Data& room, const std::string& file_name, bool verbose) {
|
||||||
if (!yaml.contains("tilemap")) {
|
if (!yaml.contains("tilemap")) {
|
||||||
std::cerr << "Warning: No tilemap found in " << file_name << '\n';
|
std::cerr << "Warning: No tilemap found in " << file_name << '\n';
|
||||||
return;
|
return;
|
||||||
@@ -146,7 +146,7 @@ void RoomLoader::parseTilemap(const fkyaml::node& yaml, Room::Data& room, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parsea los límites de movimiento de un enemigo
|
// Parsea los límites de movimiento de un enemigo
|
||||||
void RoomLoader::parseEnemyBoundaries(const fkyaml::node& bounds_node, Enemy::Data& enemy) { // NOLINT(readability-convert-member-functions-to-static)
|
void RoomLoader::parseEnemyBoundaries(const fkyaml::node& bounds_node, Enemy::Data& enemy) {
|
||||||
// Nuevo formato: position1 y position2
|
// Nuevo formato: position1 y position2
|
||||||
if (bounds_node.contains("position1")) {
|
if (bounds_node.contains("position1")) {
|
||||||
const auto& pos1 = bounds_node["position1"];
|
const auto& pos1 = bounds_node["position1"];
|
||||||
@@ -183,7 +183,7 @@ void RoomLoader::parseEnemyBoundaries(const fkyaml::node& bounds_node, Enemy::Da
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parsea los datos de un enemigo individual
|
// Parsea los datos de un enemigo individual
|
||||||
auto RoomLoader::parseEnemyData(const fkyaml::node& enemy_node) -> Enemy::Data { // NOLINT(readability-convert-member-functions-to-static)
|
auto RoomLoader::parseEnemyData(const fkyaml::node& enemy_node) -> Enemy::Data {
|
||||||
Enemy::Data enemy;
|
Enemy::Data enemy;
|
||||||
|
|
||||||
// Animation path
|
// Animation path
|
||||||
@@ -240,7 +240,7 @@ auto RoomLoader::parseEnemyData(const fkyaml::node& enemy_node) -> Enemy::Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parsea la lista de enemigos de la habitación
|
// Parsea la lista de enemigos de la habitación
|
||||||
void RoomLoader::parseEnemies(const fkyaml::node& yaml, Room::Data& room, bool verbose) { // NOLINT(readability-convert-member-functions-to-static)
|
void RoomLoader::parseEnemies(const fkyaml::node& yaml, Room::Data& room, bool verbose) {
|
||||||
if (!yaml.contains("enemies") || yaml["enemies"].is_null()) {
|
if (!yaml.contains("enemies") || yaml["enemies"].is_null()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -257,7 +257,7 @@ void RoomLoader::parseEnemies(const fkyaml::node& yaml, Room::Data& room, bool v
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parsea los datos de un item individual
|
// Parsea los datos de un item individual
|
||||||
auto RoomLoader::parseItemData(const fkyaml::node& item_node, const Room::Data& room) -> Item::Data { // NOLINT(readability-convert-member-functions-to-static)
|
auto RoomLoader::parseItemData(const fkyaml::node& item_node, const Room::Data& room) -> Item::Data {
|
||||||
Item::Data item;
|
Item::Data item;
|
||||||
|
|
||||||
// Tileset file
|
// Tileset file
|
||||||
@@ -294,7 +294,7 @@ auto RoomLoader::parseItemData(const fkyaml::node& item_node, const Room::Data&
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parsea la lista de items de la habitación
|
// Parsea la lista de items de la habitación
|
||||||
void RoomLoader::parseItems(const fkyaml::node& yaml, Room::Data& room, bool verbose) { // NOLINT(readability-convert-member-functions-to-static)
|
void RoomLoader::parseItems(const fkyaml::node& yaml, Room::Data& room, bool verbose) {
|
||||||
if (!yaml.contains("items") || yaml["items"].is_null()) {
|
if (!yaml.contains("items") || yaml["items"].is_null()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -330,7 +330,7 @@ auto RoomLoader::loadFromString(const std::string& yaml_content, const std::stri
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Carga un archivo de room en formato YAML
|
// Carga un archivo de room en formato YAML
|
||||||
auto RoomLoader::loadYAML(const std::string& file_path, bool verbose) -> Room::Data { // NOLINT(readability-convert-member-functions-to-static)
|
auto RoomLoader::loadYAML(const std::string& file_path, bool verbose) -> Room::Data {
|
||||||
Room::Data room;
|
Room::Data room;
|
||||||
|
|
||||||
// Extract filename for logging
|
// Extract filename for logging
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class RoomLoader {
|
|||||||
* @param tilemap_2d Array 2D de tiles (16 rows × 32 cols)
|
* @param tilemap_2d Array 2D de tiles (16 rows × 32 cols)
|
||||||
* @return Vector 1D flat con 512 elementos
|
* @return Vector 1D flat con 512 elementos
|
||||||
*/
|
*/
|
||||||
static auto flattenTilemap(const std::vector<std::vector<int>>& tilemap_2d) -> std::vector<int>; // NOLINT(readability-avoid-const-params-in-decls)
|
static auto flattenTilemap(const std::vector<std::vector<int>>& tilemap_2d) -> std::vector<int>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parsea la configuración general de la habitación
|
* @brief Parsea la configuración general de la habitación
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
#include <algorithm> // Para std::ranges::any_of
|
#include <algorithm> // Para std::ranges::any_of
|
||||||
|
|
||||||
// Comprueba si la habitación ya ha sido visitada
|
// Comprueba si la habitación ya ha sido visitada
|
||||||
auto RoomTracker::hasBeenVisited(const std::string& name) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto RoomTracker::hasBeenVisited(const std::string& name) -> bool {
|
||||||
return std::ranges::any_of(rooms_, [&name](const auto& l) -> bool { return l == name; });
|
return std::ranges::any_of(rooms_, [&name](const auto& l) -> bool { return l == name; });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Añade la habitación a la lista
|
// Añade la habitación a la lista
|
||||||
auto RoomTracker::addRoom(const std::string& name) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto RoomTracker::addRoom(const std::string& name) -> bool {
|
||||||
// Comprueba si la habitación ya ha sido visitada
|
// Comprueba si la habitación ya ha sido visitada
|
||||||
if (!hasBeenVisited(name)) {
|
if (!hasBeenVisited(name)) {
|
||||||
// En caso contrario añádela a la lista
|
// En caso contrario añádela a la lista
|
||||||
rooms_.push_back(name);
|
rooms_.push_back(name);
|
||||||
return true; // NOLINT(readability-simplify-boolean-expr)
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ void Scoreboard::update(float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el tiempo transcurrido de partida
|
// Obtiene el tiempo transcurrido de partida
|
||||||
auto Scoreboard::getTime() -> Scoreboard::ClockData { // NOLINT(readability-convert-member-functions-to-static)
|
auto Scoreboard::getTime() -> Scoreboard::ClockData {
|
||||||
const Uint32 TIME_ELAPSED = SDL_GetTicks() - data_->ini_clock - paused_time_elapsed_;
|
const Uint32 TIME_ELAPSED = SDL_GetTicks() - data_->ini_clock - paused_time_elapsed_;
|
||||||
|
|
||||||
ClockData time;
|
ClockData time;
|
||||||
@@ -159,22 +159,22 @@ void Scoreboard::fillTexture() {
|
|||||||
auto text = Resource::Cache::get()->getText("smb2");
|
auto text = Resource::Cache::get()->getText("smb2");
|
||||||
const std::string TIME_TEXT = std::to_string((clock_.minutes % 100) / 10) + std::to_string(clock_.minutes % 10) + clock_.separator + std::to_string((clock_.seconds % 60) / 10) + std::to_string(clock_.seconds % 10);
|
const std::string TIME_TEXT = std::to_string((clock_.minutes % 100) / 10) + std::to_string(clock_.minutes % 10) + clock_.separator + std::to_string((clock_.seconds % 60) / 10) + std::to_string(clock_.seconds % 10);
|
||||||
const std::string ITEMS_TEXT = std::to_string(data_->items / 100) + std::to_string((data_->items % 100) / 10) + std::to_string(data_->items % 10);
|
const std::string ITEMS_TEXT = std::to_string(data_->items / 100) + std::to_string((data_->items % 100) / 10) + std::to_string(data_->items % 10);
|
||||||
text->writeColored(ITEMS_LABEL_X, LINE1_Y, Locale::get()->get("scoreboard.items"), data_->color); // NOLINT(readability-static-accessed-through-instance)
|
text->writeColored(ITEMS_LABEL_X, LINE1_Y, Locale::get()->get("scoreboard.items"), data_->color);
|
||||||
text->writeColored(ITEMS_VALUE_X, LINE1_Y, ITEMS_TEXT, items_color_);
|
text->writeColored(ITEMS_VALUE_X, LINE1_Y, ITEMS_TEXT, items_color_);
|
||||||
text->writeColored(TIME_LABEL_X, LINE1_Y, Locale::get()->get("scoreboard.time"), data_->color); // NOLINT(readability-static-accessed-through-instance)
|
text->writeColored(TIME_LABEL_X, LINE1_Y, Locale::get()->get("scoreboard.time"), data_->color);
|
||||||
text->writeColored(TIME_VALUE_X, LINE1_Y, TIME_TEXT, stringToColor("white"));
|
text->writeColored(TIME_VALUE_X, LINE1_Y, TIME_TEXT, stringToColor("white"));
|
||||||
|
|
||||||
const std::string ROOMS_TEXT = std::to_string(data_->rooms / 100) + std::to_string((data_->rooms % 100) / 10) + std::to_string(data_->rooms % 10);
|
const std::string ROOMS_TEXT = std::to_string(data_->rooms / 100) + std::to_string((data_->rooms % 100) / 10) + std::to_string(data_->rooms % 10);
|
||||||
text->writeColored(ROOMS_LABEL_X, LINE2_Y, Locale::get()->get("scoreboard.rooms"), stringToColor("white")); // NOLINT(readability-static-accessed-through-instance)
|
text->writeColored(ROOMS_LABEL_X, LINE2_Y, Locale::get()->get("scoreboard.rooms"), stringToColor("white"));
|
||||||
text->writeColored(ROOMS_VALUE_X, LINE2_Y, ROOMS_TEXT, stringToColor("white"));
|
text->writeColored(ROOMS_VALUE_X, LINE2_Y, ROOMS_TEXT, stringToColor("white"));
|
||||||
|
|
||||||
// Indicadores de trucos activos (fuente 8bithud)
|
// Indicadores de trucos activos (fuente 8bithud)
|
||||||
auto cheat_text = Resource::Cache::get()->getText("8bithud");
|
auto cheat_text = Resource::Cache::get()->getText("8bithud");
|
||||||
if (Options::cheats.infinite_lives == Options::Cheat::State::ENABLED) {
|
if (Options::cheats.infinite_lives == Options::Cheat::State::ENABLED) {
|
||||||
cheat_text->writeColored(CHEAT_INF_LIVES_X, CHEAT_INF_LIVES_Y, Locale::get()->get("scoreboard.cheat_infinite_lives"), data_->color); // NOLINT(readability-static-accessed-through-instance)
|
cheat_text->writeColored(CHEAT_INF_LIVES_X, CHEAT_INF_LIVES_Y, Locale::get()->get("scoreboard.cheat_infinite_lives"), data_->color);
|
||||||
}
|
}
|
||||||
if (Options::cheats.invincible == Options::Cheat::State::ENABLED) {
|
if (Options::cheats.invincible == Options::Cheat::State::ENABLED) {
|
||||||
cheat_text->writeColored(CHEAT_INVINCIBLE_X, CHEAT_INVINCIBLE_Y, Locale::get()->get("scoreboard.cheat_invincibility"), data_->color); // NOLINT(readability-static-accessed-through-instance)
|
cheat_text->writeColored(CHEAT_INVINCIBLE_X, CHEAT_INVINCIBLE_Y, Locale::get()->get("scoreboard.cheat_invincibility"), data_->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deja el renderizador como estaba
|
// Deja el renderizador como estaba
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ void Stats::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade una muerte a las estadisticas
|
// Añade una muerte a las estadisticas
|
||||||
void Stats::addDeath(const std::string& name) { // NOLINT(readability-convert-member-functions-to-static)
|
void Stats::addDeath(const std::string& name) {
|
||||||
// Primero busca si ya hay una entrada con ese nombre
|
// Primero busca si ya hay una entrada con ese nombre
|
||||||
const int INDEX = findByName(name, buffer_list_);
|
const int INDEX = findByName(name, buffer_list_);
|
||||||
if (INDEX != -1) {
|
if (INDEX != -1) {
|
||||||
@@ -47,7 +47,7 @@ void Stats::addDeath(const std::string& name) { // NOLINT(readability-convert-m
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade una visita a las estadisticas
|
// Añade una visita a las estadisticas
|
||||||
void Stats::addVisit(const std::string& name) { // NOLINT(readability-convert-member-functions-to-static)
|
void Stats::addVisit(const std::string& name) {
|
||||||
// Primero busca si ya hay una entrada con ese nombre
|
// Primero busca si ya hay una entrada con ese nombre
|
||||||
const int INDEX = findByName(name, buffer_list_);
|
const int INDEX = findByName(name, buffer_list_);
|
||||||
if (INDEX != -1) {
|
if (INDEX != -1) {
|
||||||
@@ -65,7 +65,7 @@ void Stats::addVisit(const std::string& name) { // NOLINT(readability-convert-m
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Busca una entrada en la lista por nombre
|
// Busca una entrada en la lista por nombre
|
||||||
auto Stats::findByName(const std::string& name, const std::vector<RoomData>& list) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto Stats::findByName(const std::string& name, const std::vector<RoomData>& list) -> int {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (const auto& l : list) {
|
for (const auto& l : list) {
|
||||||
@@ -79,7 +79,7 @@ auto Stats::findByName(const std::string& name, const std::vector<RoomData>& lis
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga las estadisticas desde un fichero
|
// Carga las estadisticas desde un fichero
|
||||||
void Stats::loadFromFile(const std::string& file_path, std::vector<RoomData>& list) { // NOLINT(readability-convert-member-functions-to-static)
|
void Stats::loadFromFile(const std::string& file_path, std::vector<RoomData>& list) {
|
||||||
list.clear();
|
list.clear();
|
||||||
|
|
||||||
// Variables para manejar el fichero
|
// Variables para manejar el fichero
|
||||||
@@ -149,7 +149,7 @@ void Stats::saveToFile(const std::string& file_path, const std::vector<RoomData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcula cual es la habitación con más muertes
|
// Calcula cual es la habitación con más muertes
|
||||||
void Stats::checkWorstNightmare() { // NOLINT(readability-convert-member-functions-to-static)
|
void Stats::checkWorstNightmare() {
|
||||||
int deaths = 0;
|
int deaths = 0;
|
||||||
for (const auto& item : list_) {
|
for (const auto& item : list_) {
|
||||||
if (item.died > deaths) {
|
if (item.died > deaths) {
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ void TilemapRenderer::setTile(int index, int tile_value) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Pinta el mapa estático y debug lines
|
// Pinta el mapa estático y debug lines
|
||||||
void TilemapRenderer::fillMapTexture(const CollisionMap* collision_map) { // NOLINT(readability-convert-member-functions-to-static)
|
void TilemapRenderer::fillMapTexture(const CollisionMap* collision_map) {
|
||||||
const Uint8 COLOR = stringToColor(bg_color_);
|
const Uint8 COLOR = stringToColor(bg_color_);
|
||||||
auto previous_renderer = Screen::get()->getRendererSurface();
|
auto previous_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(map_surface_);
|
Screen::get()->setRendererSurface(map_surface_);
|
||||||
@@ -175,7 +175,7 @@ void TilemapRenderer::fillMapTexture(const CollisionMap* collision_map) { // NO
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Localiza todos los tiles animados
|
// Localiza todos los tiles animados
|
||||||
void TilemapRenderer::setAnimatedTiles(const CollisionMap* collision_map) { // NOLINT(readability-convert-member-functions-to-static)
|
void TilemapRenderer::setAnimatedTiles(const CollisionMap* collision_map) {
|
||||||
// Recorre la habitación entera por filas buscando tiles de tipo t_animated
|
// Recorre la habitación entera por filas buscando tiles de tipo t_animated
|
||||||
for (int i = 0; i < (int)tile_map_.size(); ++i) {
|
for (int i = 0; i < (int)tile_map_.size(); ++i) {
|
||||||
const auto TILE_TYPE = collision_map->getTile(i);
|
const auto TILE_TYPE = collision_map->getTile(i);
|
||||||
@@ -198,7 +198,7 @@ void TilemapRenderer::setAnimatedTiles(const CollisionMap* collision_map) { //
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza tiles animados
|
// Actualiza tiles animados
|
||||||
void TilemapRenderer::updateAnimatedTiles() { // NOLINT(readability-make-member-function-const)
|
void TilemapRenderer::updateAnimatedTiles() {
|
||||||
const int NUM_FRAMES = 4;
|
const int NUM_FRAMES = 4;
|
||||||
|
|
||||||
// Calcular frame actual basado en tiempo
|
// Calcular frame actual basado en tiempo
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ void Credits::handleInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa los textos
|
// Inicializa los textos
|
||||||
void Credits::iniTexts() { // NOLINT(readability-convert-member-functions-to-static)
|
void Credits::iniTexts() {
|
||||||
const auto* loc = Locale::get();
|
const auto* loc = Locale::get();
|
||||||
|
|
||||||
texts_.clear();
|
texts_.clear();
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ void Ending::updateState(float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa los textos
|
// Inicializa los textos
|
||||||
void Ending::iniTexts() { // NOLINT(readability-convert-member-functions-to-static)
|
void Ending::iniTexts() {
|
||||||
// Vector con los textos (traducidos según el idioma activo)
|
// Vector con los textos (traducidos según el idioma activo)
|
||||||
std::vector<TextAndPosition> texts;
|
std::vector<TextAndPosition> texts;
|
||||||
const auto* loc = Locale::get();
|
const auto* loc = Locale::get();
|
||||||
@@ -273,7 +273,7 @@ void Ending::iniPics() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa las escenas
|
// Inicializa las escenas
|
||||||
void Ending::iniScenes() { // NOLINT(readability-convert-member-functions-to-static)
|
void Ending::iniScenes() {
|
||||||
// Variable para los tiempos
|
// Variable para los tiempos
|
||||||
int trigger;
|
int trigger;
|
||||||
constexpr int LAPSE = 80;
|
constexpr int LAPSE = 80;
|
||||||
|
|||||||
@@ -391,7 +391,7 @@ void Ending2::placeSprites() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea los sprites con las texturas con los textos
|
// Crea los sprites con las texturas con los textos
|
||||||
void Ending2::createSpriteTexts() { // NOLINT(readability-convert-member-functions-to-static)
|
void Ending2::createSpriteTexts() {
|
||||||
// Crea los sprites de texto a partir de la lista
|
// Crea los sprites de texto a partir de la lista
|
||||||
for (size_t i = 0; i < sprite_list_.size(); ++i) {
|
for (size_t i = 0; i < sprite_list_.size(); ++i) {
|
||||||
auto text = Resource::Cache::get()->getText("smb2");
|
auto text = Resource::Cache::get()->getText("smb2");
|
||||||
@@ -400,7 +400,7 @@ void Ending2::createSpriteTexts() { // NOLINT(readability-convert-member-functi
|
|||||||
std::string txt = sprite_list_[i];
|
std::string txt = sprite_list_[i];
|
||||||
std::ranges::replace(txt, '_', ' '); // Reemplaza '_' por ' '
|
std::ranges::replace(txt, '_', ' '); // Reemplaza '_' por ' '
|
||||||
if (txt == "player") {
|
if (txt == "player") {
|
||||||
txt = Locale::get()->get("ending2.jaildoctor"); // NOLINT(readability-static-accessed-through-instance) Reemplaza "player" por nombre localizado
|
txt = Locale::get()->get("ending2.jaildoctor"); // Reemplaza "player" por nombre localizado
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula las dimensiones del texto
|
// Calcula las dimensiones del texto
|
||||||
@@ -432,7 +432,7 @@ void Ending2::createSpriteTexts() { // NOLINT(readability-convert-member-functi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea los sprites con las texturas con los textos del final
|
// Crea los sprites con las texturas con los textos del final
|
||||||
void Ending2::createTexts() { // NOLINT(readability-convert-member-functions-to-static)
|
void Ending2::createTexts() {
|
||||||
// Crea los primeros textos
|
// Crea los primeros textos
|
||||||
std::vector<std::string> list;
|
std::vector<std::string> list;
|
||||||
list.emplace_back(Locale::get()->get("ending2.starring"));
|
list.emplace_back(Locale::get()->get("ending2.starring"));
|
||||||
|
|||||||
+18
-18
@@ -214,10 +214,10 @@ void Game::handleEvent(const SDL_Event& event) {
|
|||||||
if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_9 && static_cast<int>(event.key.repeat) == 0) {
|
if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_9 && static_cast<int>(event.key.repeat) == 0) {
|
||||||
if (MapEditor::get()->isActive()) {
|
if (MapEditor::get()->isActive()) {
|
||||||
GameControl::exit_editor();
|
GameControl::exit_editor();
|
||||||
Notifier::get()->show({Locale::get()->get("game.editor_disabled")}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("game.editor_disabled")});
|
||||||
} else {
|
} else {
|
||||||
GameControl::enter_editor();
|
GameControl::enter_editor();
|
||||||
Notifier::get()->show({Locale::get()->get("game.editor_enabled")}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("game.editor_enabled")});
|
||||||
}
|
}
|
||||||
} else if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_8 && static_cast<int>(event.key.repeat) == 0 && MapEditor::get()->isActive()) {
|
} else if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_8 && static_cast<int>(event.key.repeat) == 0 && MapEditor::get()->isActive()) {
|
||||||
MapEditor::get()->showGrid(!MapEditor::get()->isGridEnabled());
|
MapEditor::get()->showGrid(!MapEditor::get()->isGridEnabled());
|
||||||
@@ -262,9 +262,9 @@ void Game::handleInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Input de pausa solo en estado PLAYING
|
// Input de pausa solo en estado PLAYING
|
||||||
if (Input::get()->checkAction(InputAction::PAUSE, Input::DO_NOT_ALLOW_REPEAT)) { // NOLINT(readability-static-accessed-through-instance)
|
if (Input::get()->checkAction(InputAction::PAUSE, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||||
togglePause();
|
togglePause();
|
||||||
Notifier::get()->show({paused_ ? Locale::get()->get("game.paused") : Locale::get()->get("game.running")}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({paused_ ? Locale::get()->get("game.paused") : Locale::get()->get("game.running")});
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalInputs::handle();
|
GlobalInputs::handle();
|
||||||
@@ -543,7 +543,7 @@ void Game::renderPostFadeEnding() {
|
|||||||
static void toggleCheat(Options::Cheat::State& cheat, const std::string& label) {
|
static void toggleCheat(Options::Cheat::State& cheat, const std::string& label) {
|
||||||
cheat = (cheat == Options::Cheat::State::ENABLED) ? Options::Cheat::State::DISABLED : Options::Cheat::State::ENABLED;
|
cheat = (cheat == Options::Cheat::State::ENABLED) ? Options::Cheat::State::DISABLED : Options::Cheat::State::ENABLED;
|
||||||
const bool ENABLED = (cheat == Options::Cheat::State::ENABLED);
|
const bool ENABLED = (cheat == Options::Cheat::State::ENABLED);
|
||||||
Notifier::get()->show({label + (ENABLED ? Locale::get()->get("game.enabled") : Locale::get()->get("game.disabled"))}, Notifier::Style::DEFAULT, -1, true); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({label + (ENABLED ? Locale::get()->get("game.enabled") : Locale::get()->get("game.disabled"))}, Notifier::Style::DEFAULT, -1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pone la información de debug en pantalla
|
// Pone la información de debug en pantalla
|
||||||
@@ -574,7 +574,7 @@ void Game::renderDebugInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los eventos
|
// Comprueba los eventos
|
||||||
void Game::handleDebugEvents(const SDL_Event& event) { // NOLINT(readability-convert-member-functions-to-static)
|
void Game::handleDebugEvents(const SDL_Event& event) {
|
||||||
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 0) {
|
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 0) {
|
||||||
switch (event.key.key) {
|
switch (event.key.key) {
|
||||||
case SDLK_R:
|
case SDLK_R:
|
||||||
@@ -598,21 +598,21 @@ void Game::handleDebugEvents(const SDL_Event& event) { // NOLINT(readability-co
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_1:
|
case SDLK_1:
|
||||||
toggleCheat(Options::cheats.infinite_lives, Locale::get()->get("game.cheat_infinite_lives")); // NOLINT(readability-static-accessed-through-instance)
|
toggleCheat(Options::cheats.infinite_lives, Locale::get()->get("game.cheat_infinite_lives"));
|
||||||
player_->setColor();
|
player_->setColor();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_2:
|
case SDLK_2:
|
||||||
toggleCheat(Options::cheats.invincible, Locale::get()->get("game.cheat_invincible")); // NOLINT(readability-static-accessed-through-instance)
|
toggleCheat(Options::cheats.invincible, Locale::get()->get("game.cheat_invincible"));
|
||||||
player_->setColor();
|
player_->setColor();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_3:
|
case SDLK_3:
|
||||||
toggleCheat(Options::cheats.jail_is_open, Locale::get()->get("game.cheat_jail_open")); // NOLINT(readability-static-accessed-through-instance)
|
toggleCheat(Options::cheats.jail_is_open, Locale::get()->get("game.cheat_jail_open"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_7:
|
case SDLK_7:
|
||||||
Notifier::get()->show({Locale::get()->get("achievements.header"), Locale::get()->get("achievements.c11")}, Notifier::Style::CHEEVO, -1, false, "F7"); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("achievements.header"), Locale::get()->get("achievements.c11")}, Notifier::Style::CHEEVO, -1, false, "F7");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_0: {
|
case SDLK_0: {
|
||||||
@@ -621,7 +621,7 @@ void Game::handleDebugEvents(const SDL_Event& event) { // NOLINT(readability-co
|
|||||||
invincible_before_debug_ = (Options::cheats.invincible == Options::Cheat::State::ENABLED);
|
invincible_before_debug_ = (Options::cheats.invincible == Options::Cheat::State::ENABLED);
|
||||||
}
|
}
|
||||||
Debug::get()->toggleEnabled();
|
Debug::get()->toggleEnabled();
|
||||||
Notifier::get()->show({Debug::get()->isEnabled() ? Locale::get()->get("game.debug_enabled") : Locale::get()->get("game.debug_disabled")}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Debug::get()->isEnabled() ? Locale::get()->get("game.debug_enabled") : Locale::get()->get("game.debug_disabled")});
|
||||||
room_->redrawMap();
|
room_->redrawMap();
|
||||||
if (Debug::get()->isEnabled()) {
|
if (Debug::get()->isEnabled()) {
|
||||||
Options::cheats.invincible = Options::Cheat::State::ENABLED;
|
Options::cheats.invincible = Options::Cheat::State::ENABLED;
|
||||||
@@ -728,7 +728,7 @@ auto Game::changeRoom(const std::string& room_path) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verifica que exista el fichero que se va a cargar
|
// Verifica que exista el fichero que se va a cargar
|
||||||
if (!Resource::List::get()->get(room_path).empty()) { // NOLINT(readability-static-accessed-through-instance)
|
if (!Resource::List::get()->get(room_path).empty()) {
|
||||||
// Crea un objeto habitación nuevo a partir del fichero
|
// Crea un objeto habitación nuevo a partir del fichero
|
||||||
room_ = std::make_shared<Room>(room_path, scoreboard_data_);
|
room_ = std::make_shared<Room>(room_path, scoreboard_data_);
|
||||||
|
|
||||||
@@ -830,7 +830,7 @@ void Game::killPlayer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pone el color del marcador en función del color del borde de la habitación
|
// Pone el color del marcador en función del color del borde de la habitación
|
||||||
void Game::setScoreBoardColor() { // NOLINT(readability-convert-member-functions-to-static)
|
void Game::setScoreBoardColor() {
|
||||||
// Obtiene el color del borde
|
// Obtiene el color del borde
|
||||||
const Uint8 BORDER_COLOR = room_->getBorderColor();
|
const Uint8 BORDER_COLOR = room_->getBorderColor();
|
||||||
|
|
||||||
@@ -905,12 +905,12 @@ void Game::checkRestoringJail(float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa las estadísticas
|
// Inicializa las estadísticas
|
||||||
void Game::initStats() { // NOLINT(readability-convert-member-functions-to-static)
|
void Game::initStats() {
|
||||||
stats_->init();
|
stats_->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea la textura con el nombre de la habitación
|
// Crea la textura con el nombre de la habitación
|
||||||
void Game::fillRoomNameTexture() { // NOLINT(readability-convert-member-functions-to-static)
|
void Game::fillRoomNameTexture() {
|
||||||
// Pone la textura como destino de renderizado
|
// Pone la textura como destino de renderizado
|
||||||
auto previuos_renderer = Screen::get()->getRendererSurface();
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(room_name_surface_);
|
Screen::get()->setRendererSurface(room_name_surface_);
|
||||||
@@ -927,7 +927,7 @@ void Game::fillRoomNameTexture() { // NOLINT(readability-convert-member-functio
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba algunos logros
|
// Comprueba algunos logros
|
||||||
void Game::checkSomeCheevos() { // NOLINT(readability-convert-member-functions-to-static)
|
void Game::checkSomeCheevos() {
|
||||||
auto* cheevos = Cheevos::get();
|
auto* cheevos = Cheevos::get();
|
||||||
|
|
||||||
// Logros sobre la cantidad de items
|
// Logros sobre la cantidad de items
|
||||||
@@ -961,7 +961,7 @@ void Game::checkSomeCheevos() { // NOLINT(readability-convert-member-functions-
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los logros de completar el juego
|
// Comprueba los logros de completar el juego
|
||||||
void Game::checkEndGameCheevos() { // NOLINT(readability-convert-member-functions-to-static)
|
void Game::checkEndGameCheevos() {
|
||||||
auto* cheevos = Cheevos::get();
|
auto* cheevos = Cheevos::get();
|
||||||
|
|
||||||
// "Complete the game"
|
// "Complete the game"
|
||||||
@@ -985,7 +985,7 @@ void Game::checkEndGameCheevos() { // NOLINT(readability-convert-member-functio
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa al jugador
|
// Inicializa al jugador
|
||||||
void Game::initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room) { // NOLINT(readability-convert-member-functions-to-static)
|
void Game::initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room) {
|
||||||
const bool IGNORE_INPUT = player_ != nullptr && player_->getIgnoreInput();
|
const bool IGNORE_INPUT = player_ != nullptr && player_->getIgnoreInput();
|
||||||
std::string player_animations = Player::skinToAnimationPath(Options::game.player_skin);
|
std::string player_animations = Player::skinToAnimationPath(Options::game.player_skin);
|
||||||
const Player::Data PLAYER{.spawn_data = spawn_point, .animations_path = player_animations, .room = std::move(room)};
|
const Player::Data PLAYER{.spawn_data = spawn_point, .animations_path = player_animations, .room = std::move(room)};
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ void GameOver::render() {
|
|||||||
|
|
||||||
// Escribe el texto de GAME OVER
|
// Escribe el texto de GAME OVER
|
||||||
const auto* loc = Locale::get();
|
const auto* loc = Locale::get();
|
||||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y, loc->get("game_over.title"), 1, color_); // NOLINT(readability-static-accessed-through-instance)
|
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y, loc->get("game_over.title"), 1, color_);
|
||||||
|
|
||||||
// Dibuja los sprites (ya posicionados en el constructor, solo ajustamos Y)
|
// Dibuja los sprites (ya posicionados en el constructor, solo ajustamos Y)
|
||||||
player_sprite_->setPosY(TEXT_Y + SPRITE_Y_OFFSET);
|
player_sprite_->setPosY(TEXT_Y + SPRITE_Y_OFFSET);
|
||||||
@@ -78,11 +78,11 @@ void GameOver::render() {
|
|||||||
// Escribe el texto con las habitaciones y los items
|
// Escribe el texto con las habitaciones y los items
|
||||||
const std::string ITEMS_TEXT = std::to_string(Options::stats.items / 100) + std::to_string((Options::stats.items % 100) / 10) + std::to_string(Options::stats.items % 10);
|
const std::string ITEMS_TEXT = std::to_string(Options::stats.items / 100) + std::to_string((Options::stats.items % 100) / 10) + std::to_string(Options::stats.items % 10);
|
||||||
const std::string ROOMS_TEXT = std::to_string(Options::stats.rooms / 100) + std::to_string((Options::stats.rooms % 100) / 10) + std::to_string(Options::stats.rooms % 10);
|
const std::string ROOMS_TEXT = std::to_string(Options::stats.rooms / 100) + std::to_string((Options::stats.rooms % 100) / 10) + std::to_string(Options::stats.rooms % 10);
|
||||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + ITEMS_Y_OFFSET, loc->get("game_over.items") + ITEMS_TEXT, 1, color_); // NOLINT(readability-static-accessed-through-instance)
|
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + ITEMS_Y_OFFSET, loc->get("game_over.items") + ITEMS_TEXT, 1, color_);
|
||||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + ROOMS_Y_OFFSET, loc->get("game_over.rooms") + ROOMS_TEXT, 1, color_); // NOLINT(readability-static-accessed-through-instance)
|
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + ROOMS_Y_OFFSET, loc->get("game_over.rooms") + ROOMS_TEXT, 1, color_);
|
||||||
|
|
||||||
// Escribe el texto con "Tu peor pesadilla"
|
// Escribe el texto con "Tu peor pesadilla"
|
||||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + NIGHTMARE_TITLE_Y_OFFSET, loc->get("game_over.worst_nightmare"), 1, color_); // NOLINT(readability-static-accessed-through-instance)
|
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + NIGHTMARE_TITLE_Y_OFFSET, loc->get("game_over.worst_nightmare"), 1, color_);
|
||||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + NIGHTMARE_TEXT_Y_OFFSET, Options::stats.worst_nightmare, 1, color_);
|
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + NIGHTMARE_TEXT_Y_OFFSET, Options::stats.worst_nightmare, 1, color_);
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ void LoadingScreen::handleInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa el array de índices de líneas (imita el direccionamiento de memoria del Spectrum)
|
// Inicializa el array de índices de líneas (imita el direccionamiento de memoria del Spectrum)
|
||||||
void LoadingScreen::initLineIndexArray() { // NOLINT(readability-convert-member-functions-to-static)
|
void LoadingScreen::initLineIndexArray() {
|
||||||
for (int i = 0; i < MONO_TOTAL_LINES; ++i) {
|
for (int i = 0; i < MONO_TOTAL_LINES; ++i) {
|
||||||
if (i < 64) { // Primer bloque de 2K
|
if (i < 64) { // Primer bloque de 2K
|
||||||
line_index_[i] = ((i % 8) * 8) + (i / 8);
|
line_index_[i] = ((i % 8) * 8) + (i / 8);
|
||||||
@@ -440,7 +440,7 @@ void LoadingScreen::renderBorder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el nombre del programa
|
// Escribe el nombre del programa
|
||||||
void LoadingScreen::printProgramName() { // NOLINT(readability-convert-member-functions-to-static)
|
void LoadingScreen::printProgramName() {
|
||||||
auto previous_renderer = Screen::get()->getRendererSurface();
|
auto previous_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(screen_surface_);
|
Screen::get()->setRendererSurface(screen_surface_);
|
||||||
program_sprite_->render();
|
program_sprite_->render();
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void Logo::updateJAILGAMES(float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcula el índice de color según el progreso (0.0-1.0)
|
// Calcula el índice de color según el progreso (0.0-1.0)
|
||||||
auto Logo::getColorIndex(float progress) const -> int { // NOLINT(readability-convert-member-functions-to-static)
|
auto Logo::getColorIndex(float progress) const -> int {
|
||||||
// Asegurar que progress esté en el rango [0.0, 1.0]
|
// Asegurar que progress esté en el rango [0.0, 1.0]
|
||||||
progress = std::clamp(progress, 0.0F, 1.0F);
|
progress = std::clamp(progress, 0.0F, 1.0F);
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ void Logo::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja en pantalla
|
// Dibuja en pantalla
|
||||||
void Logo::render() { // NOLINT(readability-convert-member-functions-to-static)
|
void Logo::render() {
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||||
@@ -245,7 +245,7 @@ void Logo::endSection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa el vector de colores
|
// Inicializa el vector de colores
|
||||||
void Logo::initColors() { // NOLINT(readability-convert-member-functions-to-static)
|
void Logo::initColors() {
|
||||||
// Inicializa el vector de colores
|
// Inicializa el vector de colores
|
||||||
const std::vector<Uint8> COLORS = {
|
const std::vector<Uint8> COLORS = {
|
||||||
static_cast<Uint8>(PaletteColor::BLACK),
|
static_cast<Uint8>(PaletteColor::BLACK),
|
||||||
@@ -261,7 +261,7 @@ void Logo::initColors() { // NOLINT(readability-convert-member-functions-to-sta
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea los sprites de cada linea
|
// Crea los sprites de cada linea
|
||||||
void Logo::initSprites() { // NOLINT(readability-convert-member-functions-to-static)
|
void Logo::initSprites() {
|
||||||
const float WIDTH = jailgames_surface_->getWidth();
|
const float WIDTH = jailgames_surface_->getWidth();
|
||||||
jailgames_initial_x_.reserve(jailgames_surface_->getHeight());
|
jailgames_initial_x_.reserve(jailgames_surface_->getHeight());
|
||||||
|
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ void Title::iterate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea y rellena la textura para mostrar los logros
|
// Crea y rellena la textura para mostrar los logros
|
||||||
void Title::createCheevosTexture() { // NOLINT(readability-convert-member-functions-to-static)
|
void Title::createCheevosTexture() {
|
||||||
// Define la zona central del menu (entre el logo y la marquesina)
|
// Define la zona central del menu (entre el logo y la marquesina)
|
||||||
constexpr int MENU_ZONE_Y = 73; // Top of menu zone
|
constexpr int MENU_ZONE_Y = 73; // Top of menu zone
|
||||||
constexpr int MENU_ZONE_HEIGHT = 102; // Height of menu zone
|
constexpr int MENU_ZONE_HEIGHT = 102; // Height of menu zone
|
||||||
@@ -476,7 +476,7 @@ void Title::createCheevosTexture() { // NOLINT(readability-convert-member-funct
|
|||||||
cheevos_surface_->clear(CHEEVOS_BG_COLOR);
|
cheevos_surface_->clear(CHEEVOS_BG_COLOR);
|
||||||
|
|
||||||
// Escribe la lista de logros en la textura
|
// Escribe la lista de logros en la textura
|
||||||
const std::string CHEEVOS_OWNER = Locale::get()->get("title.projects"); // NOLINT(readability-static-accessed-through-instance)
|
const std::string CHEEVOS_OWNER = Locale::get()->get("title.projects");
|
||||||
const std::string CHEEVOS_LIST_CAPTION = CHEEVOS_OWNER + " (" + std::to_string(Cheevos::get()->getTotalUnlockedAchievements()) + " / " + std::to_string(Cheevos::get()->size()) + ")";
|
const std::string CHEEVOS_LIST_CAPTION = CHEEVOS_OWNER + " (" + std::to_string(Cheevos::get()->getTotalUnlockedAchievements()) + " / " + std::to_string(Cheevos::get()->size()) + ")";
|
||||||
int pos = 2;
|
int pos = 2;
|
||||||
TEXT->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, cheevos_surface_->getWidth() / 2, pos, CHEEVOS_LIST_CAPTION, 1, stringToColor("bright_green"));
|
TEXT->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, cheevos_surface_->getWidth() / 2, pos, CHEEVOS_LIST_CAPTION, 1, stringToColor("bright_green"));
|
||||||
@@ -642,7 +642,7 @@ auto Title::isKeyValid(SDL_Scancode scancode) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verifica si una tecla ya fue usada en pasos anteriores
|
// Verifica si una tecla ya fue usada en pasos anteriores
|
||||||
auto Title::isKeyDuplicate(SDL_Scancode scancode, int current_step) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto Title::isKeyDuplicate(SDL_Scancode scancode, int current_step) -> bool {
|
||||||
for (int i = 0; i < current_step; i++) {
|
for (int i = 0; i < current_step; i++) {
|
||||||
if (temp_keys_[i] == scancode) {
|
if (temp_keys_[i] == scancode) {
|
||||||
return true;
|
return true;
|
||||||
@@ -653,7 +653,7 @@ auto Title::isKeyDuplicate(SDL_Scancode scancode, int current_step) -> bool { /
|
|||||||
|
|
||||||
// Retorna el nombre de la accion para el paso actual
|
// Retorna el nombre de la accion para el paso actual
|
||||||
// Aplica y guarda las teclas redefinidas
|
// Aplica y guarda las teclas redefinidas
|
||||||
void Title::applyKeyboardRemap() { // NOLINT(readability-convert-member-functions-to-static)
|
void Title::applyKeyboardRemap() {
|
||||||
// Guardar las nuevas teclas en Options::controls
|
// Guardar las nuevas teclas en Options::controls
|
||||||
Options::keyboard_controls.key_left = temp_keys_[0];
|
Options::keyboard_controls.key_left = temp_keys_[0];
|
||||||
Options::keyboard_controls.key_right = temp_keys_[1];
|
Options::keyboard_controls.key_right = temp_keys_[1];
|
||||||
@@ -694,17 +694,17 @@ void Title::renderKeyboardRemap() const {
|
|||||||
const int KEYS_START_Y = START_Y + (2 * LINE_SPACING);
|
const int KEYS_START_Y = START_Y + (2 * LINE_SPACING);
|
||||||
if (remap_step_ > 0) {
|
if (remap_step_ > 0) {
|
||||||
const std::string LEFT_KEY = SDL_GetScancodeName(temp_keys_[0]);
|
const std::string LEFT_KEY = SDL_GetScancodeName(temp_keys_[0]);
|
||||||
const std::string LEFT_MSG = loc->get("title.keys.label0") + LEFT_KEY; // NOLINT(readability-static-accessed-through-instance)
|
const std::string LEFT_MSG = loc->get("title.keys.label0") + LEFT_KEY;
|
||||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, KEYS_START_Y, LEFT_MSG, 1, COLOR);
|
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, KEYS_START_Y, LEFT_MSG, 1, COLOR);
|
||||||
}
|
}
|
||||||
if (remap_step_ > 1) {
|
if (remap_step_ > 1) {
|
||||||
const std::string RIGHT_KEY = SDL_GetScancodeName(temp_keys_[1]);
|
const std::string RIGHT_KEY = SDL_GetScancodeName(temp_keys_[1]);
|
||||||
const std::string RIGHT_MSG = loc->get("title.keys.label1") + RIGHT_KEY; // NOLINT(readability-static-accessed-through-instance)
|
const std::string RIGHT_MSG = loc->get("title.keys.label1") + RIGHT_KEY;
|
||||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, KEYS_START_Y + LINE_SPACING, RIGHT_MSG, 1, COLOR);
|
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, KEYS_START_Y + LINE_SPACING, RIGHT_MSG, 1, COLOR);
|
||||||
}
|
}
|
||||||
if (remap_step_ >= 3) {
|
if (remap_step_ >= 3) {
|
||||||
const std::string JUMP_KEY = SDL_GetScancodeName(temp_keys_[2]);
|
const std::string JUMP_KEY = SDL_GetScancodeName(temp_keys_[2]);
|
||||||
const std::string JUMP_MSG = loc->get("title.keys.label2") + JUMP_KEY; // NOLINT(readability-static-accessed-through-instance)
|
const std::string JUMP_MSG = loc->get("title.keys.label2") + JUMP_KEY;
|
||||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, KEYS_START_Y + (2 * LINE_SPACING), JUMP_MSG, 1, COLOR);
|
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, KEYS_START_Y + (2 * LINE_SPACING), JUMP_MSG, 1, COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -742,17 +742,17 @@ void Title::renderJoystickRemap() const {
|
|||||||
const int BUTTONS_START_Y = START_Y + (2 * LINE_SPACING);
|
const int BUTTONS_START_Y = START_Y + (2 * LINE_SPACING);
|
||||||
if (remap_step_ > 0) {
|
if (remap_step_ > 0) {
|
||||||
const std::string LEFT_BTN = getButtonName(temp_buttons_[0]);
|
const std::string LEFT_BTN = getButtonName(temp_buttons_[0]);
|
||||||
const std::string LEFT_MSG = loc->get("title.keys.label0") + LEFT_BTN; // NOLINT(readability-static-accessed-through-instance)
|
const std::string LEFT_MSG = loc->get("title.keys.label0") + LEFT_BTN;
|
||||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, BUTTONS_START_Y, LEFT_MSG, 1, COLOR);
|
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, BUTTONS_START_Y, LEFT_MSG, 1, COLOR);
|
||||||
}
|
}
|
||||||
if (remap_step_ > 1) {
|
if (remap_step_ > 1) {
|
||||||
const std::string RIGHT_BTN = getButtonName(temp_buttons_[1]);
|
const std::string RIGHT_BTN = getButtonName(temp_buttons_[1]);
|
||||||
const std::string RIGHT_MSG = loc->get("title.keys.label1") + RIGHT_BTN; // NOLINT(readability-static-accessed-through-instance)
|
const std::string RIGHT_MSG = loc->get("title.keys.label1") + RIGHT_BTN;
|
||||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, BUTTONS_START_Y + LINE_SPACING, RIGHT_MSG, 1, COLOR);
|
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, BUTTONS_START_Y + LINE_SPACING, RIGHT_MSG, 1, COLOR);
|
||||||
}
|
}
|
||||||
if (remap_step_ >= 3) {
|
if (remap_step_ >= 3) {
|
||||||
const std::string JUMP_BTN = getButtonName(temp_buttons_[2]);
|
const std::string JUMP_BTN = getButtonName(temp_buttons_[2]);
|
||||||
const std::string JUMP_MSG = loc->get("title.keys.label2") + JUMP_BTN; // NOLINT(readability-static-accessed-through-instance)
|
const std::string JUMP_MSG = loc->get("title.keys.label2") + JUMP_BTN;
|
||||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, BUTTONS_START_Y + (2 * LINE_SPACING), JUMP_MSG, 1, COLOR);
|
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, BUTTONS_START_Y + (2 * LINE_SPACING), JUMP_MSG, 1, COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -824,7 +824,7 @@ void Title::handleJoystickRemap(const SDL_Event& event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Valida si un botón está duplicado
|
// Valida si un botón está duplicado
|
||||||
auto Title::isButtonDuplicate(int button, int current_step) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
auto Title::isButtonDuplicate(int button, int current_step) -> bool {
|
||||||
for (int i = 0; i < current_step; ++i) {
|
for (int i = 0; i < current_step; ++i) {
|
||||||
if (temp_buttons_[i] == button) {
|
if (temp_buttons_[i] == button) {
|
||||||
return true;
|
return true;
|
||||||
@@ -834,7 +834,7 @@ auto Title::isButtonDuplicate(int button, int current_step) -> bool { // NOLINT
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Aplica y guarda los botones del gamepad redefinidos
|
// Aplica y guarda los botones del gamepad redefinidos
|
||||||
void Title::applyJoystickRemap() { // NOLINT(readability-convert-member-functions-to-static)
|
void Title::applyJoystickRemap() {
|
||||||
// Guardar los nuevos botones en Options::gamepad_controls
|
// Guardar los nuevos botones en Options::gamepad_controls
|
||||||
Options::gamepad_controls.button_left = temp_buttons_[0];
|
Options::gamepad_controls.button_left = temp_buttons_[0];
|
||||||
Options::gamepad_controls.button_right = temp_buttons_[1];
|
Options::gamepad_controls.button_right = temp_buttons_[1];
|
||||||
@@ -848,7 +848,7 @@ void Title::applyJoystickRemap() { // NOLINT(readability-convert-member-functio
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retorna el nombre amigable del botón del gamepad
|
// Retorna el nombre amigable del botón del gamepad
|
||||||
auto Title::getButtonName(int button) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
auto Title::getButtonName(int button) -> std::string {
|
||||||
// Triggers especiales
|
// Triggers especiales
|
||||||
if (button == Input::TRIGGER_L2_AS_BUTTON) {
|
if (button == Input::TRIGGER_L2_AS_BUTTON) {
|
||||||
return "L2";
|
return "L2";
|
||||||
|
|||||||
@@ -807,7 +807,7 @@ static auto cmdShow(const std::vector<std::string>& args) -> std::string {
|
|||||||
return "Notification shown";
|
return "Notification shown";
|
||||||
}
|
}
|
||||||
if (!args.empty() && args[0] == "CHEEVO") {
|
if (!args.empty() && args[0] == "CHEEVO") {
|
||||||
Notifier::get()->show({Locale::get()->get("achievements.header"), Locale::get()->get("achievements.c1")}, Notifier::Style::CHEEVO, -1, false); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("achievements.header"), Locale::get()->get("achievements.c1")}, Notifier::Style::CHEEVO, -1, false);
|
||||||
return "Cheevo notification shown";
|
return "Cheevo notification shown";
|
||||||
}
|
}
|
||||||
if (args.empty() || args[0] != "INFO") { return "usage: show [info|notification|cheevo]"; }
|
if (args.empty() || args[0] != "INFO") { return "usage: show [info|notification|cheevo]"; }
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ const Notifier::Style Notifier::Style::CHEEVO = {
|
|||||||
.play_sound = true};
|
.play_sound = true};
|
||||||
|
|
||||||
// [SINGLETON] Crearemos el objeto con esta función estática
|
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||||
void Notifier::init(const std::string& icon_file, const std::string& text) { // NOLINT(readability-convert-member-functions-to-static)
|
void Notifier::init(const std::string& icon_file, const std::string& text) {
|
||||||
Notifier::notifier = new Notifier(icon_file, text);
|
Notifier::notifier = new Notifier(icon_file, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ void Notifier::update(float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Elimina las notificaciones finalizadas
|
// Elimina las notificaciones finalizadas
|
||||||
void Notifier::clearFinishedNotifications() { // NOLINT(readability-convert-member-functions-to-static)
|
void Notifier::clearFinishedNotifications() {
|
||||||
auto result = std::ranges::remove_if(notifications_, [](const Notification& notification) -> bool {
|
auto result = std::ranges::remove_if(notifications_, [](const Notification& notification) -> bool {
|
||||||
return notification.state == Status::FINISHED;
|
return notification.state == Status::FINISHED;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user