forked from jaildesigner-jailgames/jaildoctors_dilemma
linter
This commit is contained in:
@@ -106,7 +106,7 @@ void handleShowDebugInfo() {
|
||||
}
|
||||
|
||||
// Detecta qué acción global ha sido presionada (si alguna)
|
||||
InputAction getPressedAction() {
|
||||
auto getPressedAction() -> InputAction {
|
||||
if (Input::get()->checkAction(InputAction::EXIT, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
return InputAction::EXIT;
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ auto Screen::getBorderSurface() -> std::shared_ptr<Surface> { return border_surf
|
||||
|
||||
auto loadData(const std::string& filepath) -> std::vector<uint8_t> {
|
||||
// Load using ResourceHelper (supports both filesystem and pack)
|
||||
return jdd::ResourceHelper::loadFile(filepath);
|
||||
return Jdd::ResourceHelper::loadFile(filepath);
|
||||
}
|
||||
|
||||
// Carga el contenido de los archivos GLSL
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
// Carga una paleta desde un archivo .gif
|
||||
auto loadPalette(const std::string& file_path) -> Palette {
|
||||
// Load file using ResourceHelper (supports both filesystem and pack)
|
||||
auto buffer = jdd::ResourceHelper::loadFile(file_path);
|
||||
auto buffer = Jdd::ResourceHelper::loadFile(file_path);
|
||||
if (buffer.empty()) {
|
||||
throw std::runtime_error("Error opening file: " + file_path);
|
||||
}
|
||||
@@ -48,7 +48,7 @@ auto readPalFile(const std::string& file_path) -> Palette {
|
||||
palette.fill(0); // Inicializar todo con 0 (transparente por defecto)
|
||||
|
||||
// Load file using ResourceHelper (supports both filesystem and pack)
|
||||
auto file_data = jdd::ResourceHelper::loadFile(file_path);
|
||||
auto file_data = Jdd::ResourceHelper::loadFile(file_path);
|
||||
if (file_data.empty()) {
|
||||
throw std::runtime_error("No se pudo abrir el archivo .pal: " + file_path);
|
||||
}
|
||||
@@ -106,7 +106,7 @@ Surface::Surface(const std::string& file_path)
|
||||
// Carga una superficie desde un archivo
|
||||
auto Surface::loadSurface(const std::string& file_path) -> SurfaceData {
|
||||
// Load file using ResourceHelper (supports both filesystem and pack)
|
||||
std::vector<Uint8> buffer = jdd::ResourceHelper::loadFile(file_path);
|
||||
std::vector<Uint8> buffer = Jdd::ResourceHelper::loadFile(file_path);
|
||||
if (buffer.empty()) {
|
||||
std::cerr << "Error opening file: " << file_path << '\n';
|
||||
throw std::runtime_error("Error opening file");
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// Carga las animaciones en un vector(Animations) desde un fichero
|
||||
auto loadAnimationsFromFile(const std::string& file_path) -> Animations {
|
||||
// Load file using ResourceHelper (supports both filesystem and pack)
|
||||
auto file_data = jdd::ResourceHelper::loadFile(file_path);
|
||||
auto file_data = Jdd::ResourceHelper::loadFile(file_path);
|
||||
if (file_data.empty()) {
|
||||
std::cerr << "Error: Fichero no encontrado " << file_path << '\n';
|
||||
throw std::runtime_error("Fichero no encontrado: " + file_path);
|
||||
@@ -43,8 +43,7 @@ auto loadAnimationsFromFile(const std::string& file_path) -> Animations {
|
||||
}
|
||||
|
||||
// Constructor
|
||||
SurfaceAnimatedSprite::SurfaceAnimatedSprite(const std::string& file_path)
|
||||
: SurfaceMovingSprite() {
|
||||
SurfaceAnimatedSprite::SurfaceAnimatedSprite(const std::string& file_path) {
|
||||
// Carga las animaciones
|
||||
if (!file_path.empty()) {
|
||||
Animations v = loadAnimationsFromFile(file_path);
|
||||
@@ -53,8 +52,7 @@ SurfaceAnimatedSprite::SurfaceAnimatedSprite(const std::string& file_path)
|
||||
}
|
||||
|
||||
// Constructor
|
||||
SurfaceAnimatedSprite::SurfaceAnimatedSprite(const Animations& animations)
|
||||
: SurfaceMovingSprite() {
|
||||
SurfaceAnimatedSprite::SurfaceAnimatedSprite(const Animations& animations) {
|
||||
if (!animations.empty()) {
|
||||
setAnimations(animations);
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@ SurfaceMovingSprite::SurfaceMovingSprite(std::shared_ptr<Surface> surface, SDL_F
|
||||
flip_(SDL_FLIP_NONE) { SurfaceSprite::pos_ = pos; }
|
||||
|
||||
SurfaceMovingSprite::SurfaceMovingSprite()
|
||||
: SurfaceSprite(),
|
||||
x_(0.0F),
|
||||
: x_(0.0F),
|
||||
y_(0.0F),
|
||||
flip_(SDL_FLIP_NONE) { SurfaceSprite::clear(); }
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ auto loadTextFile(const std::string& file_path) -> std::shared_ptr<TextFile> {
|
||||
}
|
||||
|
||||
// Load file using ResourceHelper (supports both filesystem and pack)
|
||||
auto file_data = jdd::ResourceHelper::loadFile(file_path);
|
||||
auto file_data = Jdd::ResourceHelper::loadFile(file_path);
|
||||
if (file_data.empty()) {
|
||||
std::cerr << "Error: Fichero no encontrado " << getFileName(file_path) << '\n';
|
||||
throw std::runtime_error("Fichero no encontrado: " + getFileName(file_path));
|
||||
|
||||
@@ -223,7 +223,7 @@ auto Asset::check() const -> bool {
|
||||
}
|
||||
|
||||
// Comprueba que existe un fichero
|
||||
auto Asset::checkFile(const std::string& path) const -> bool {
|
||||
auto Asset::checkFile(const std::string& path) -> bool {
|
||||
std::ifstream file(path);
|
||||
bool success = file.good();
|
||||
file.close();
|
||||
|
||||
@@ -58,7 +58,7 @@ class Asset {
|
||||
std::string executable_path_; // Ruta del ejecutable
|
||||
|
||||
// --- Métodos internos ---
|
||||
[[nodiscard]] auto checkFile(const std::string& path) const -> bool; // Verifica si un archivo existe
|
||||
[[nodiscard]] static auto checkFile(const std::string& path) -> bool; // Verifica si un archivo existe
|
||||
[[nodiscard]] static auto getTypeName(Type type) -> std::string; // Obtiene el nombre del tipo
|
||||
[[nodiscard]] static auto parseAssetType(const std::string& type_str) -> Type; // Convierte string a tipo
|
||||
void addToMap(const std::string& file_path, Type type, bool required, bool absolute); // Añade archivo al mapa
|
||||
|
||||
@@ -198,7 +198,7 @@ void Resource::loadSounds() {
|
||||
JA_Sound_t* sound = nullptr;
|
||||
|
||||
// Try loading from resource pack first
|
||||
auto audio_data = jdd::ResourceHelper::loadFile(l);
|
||||
auto audio_data = Jdd::ResourceHelper::loadFile(l);
|
||||
if (!audio_data.empty()) {
|
||||
sound = JA_LoadSound(audio_data.data(), static_cast<Uint32>(audio_data.size()));
|
||||
}
|
||||
@@ -225,7 +225,7 @@ void Resource::loadMusics() {
|
||||
JA_Music_t* music = nullptr;
|
||||
|
||||
// Try loading from resource pack first
|
||||
auto audio_data = jdd::ResourceHelper::loadFile(l);
|
||||
auto audio_data = Jdd::ResourceHelper::loadFile(l);
|
||||
if (!audio_data.empty()) {
|
||||
music = JA_LoadMusic(audio_data.data(), static_cast<Uint32>(audio_data.size()));
|
||||
}
|
||||
@@ -415,8 +415,8 @@ void Resource::renderProgress() {
|
||||
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||
|
||||
auto surface = Screen::get()->getRendererSurface();
|
||||
const Uint8 TEXT_COLOR = static_cast<Uint8>(PaletteColor::BRIGHT_WHITE);
|
||||
const Uint8 BAR_COLOR = static_cast<Uint8>(PaletteColor::WHITE);
|
||||
const auto TEXT_COLOR = static_cast<Uint8>(PaletteColor::BRIGHT_WHITE);
|
||||
const auto BAR_COLOR = static_cast<Uint8>(PaletteColor::WHITE);
|
||||
const int TEXT_HEIGHT = loading_text_->getCharacterSize();
|
||||
const int CENTER_X = Options::game.width / 2;
|
||||
const int CENTER_Y = Options::game.height / 2;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "resource_loader.hpp"
|
||||
|
||||
namespace jdd {
|
||||
namespace Jdd {
|
||||
namespace ResourceHelper {
|
||||
|
||||
static bool resource_system_initialized = false;
|
||||
@@ -175,4 +175,4 @@ auto isPackLoaded() -> bool {
|
||||
}
|
||||
|
||||
} // namespace ResourceHelper
|
||||
} // namespace jdd
|
||||
} // namespace Jdd
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace jdd {
|
||||
namespace Jdd {
|
||||
namespace ResourceHelper {
|
||||
|
||||
// Initialize the resource system
|
||||
@@ -38,6 +38,6 @@ auto shouldUseResourcePack(const std::string& filepath) -> bool;
|
||||
auto isPackLoaded() -> bool;
|
||||
|
||||
} // namespace ResourceHelper
|
||||
} // namespace jdd
|
||||
} // namespace Jdd
|
||||
|
||||
#endif // RESOURCE_HELPER_HPP
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace jdd {
|
||||
namespace Jdd {
|
||||
|
||||
// Get singleton instance
|
||||
auto ResourceLoader::get() -> ResourceLoader& {
|
||||
@@ -196,4 +196,4 @@ auto ResourceLoader::loadAssetsConfig() const -> std::string {
|
||||
return config_content;
|
||||
}
|
||||
|
||||
} // namespace jdd
|
||||
} // namespace Jdd
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "resource_pack.hpp"
|
||||
|
||||
namespace jdd {
|
||||
namespace Jdd {
|
||||
|
||||
// Singleton class for loading resources from pack or filesystem
|
||||
class ResourceLoader {
|
||||
@@ -64,6 +64,6 @@ class ResourceLoader {
|
||||
bool initialized_{false};
|
||||
};
|
||||
|
||||
} // namespace jdd
|
||||
} // namespace Jdd
|
||||
|
||||
#endif // RESOURCE_LOADER_HPP
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace jdd {
|
||||
namespace Jdd {
|
||||
|
||||
// Calculate CRC32 checksum for data verification
|
||||
auto ResourcePack::calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t {
|
||||
@@ -100,7 +100,7 @@ auto ResourcePack::addDirectory(const std::string& dir_path,
|
||||
std::string relative_path = entry.path().lexically_relative(dir_path).string();
|
||||
|
||||
// Convert backslashes to forward slashes (Windows compatibility)
|
||||
std::replace(relative_path.begin(), relative_path.end(), '\\', '/');
|
||||
std::ranges::replace(relative_path, '\\', '/');
|
||||
|
||||
// Skip development files
|
||||
if (relative_path.find(".world") != std::string::npos ||
|
||||
@@ -129,13 +129,13 @@ auto ResourcePack::savePack(const std::string& pack_file) -> bool {
|
||||
file.write(reinterpret_cast<const char*>(&VERSION), sizeof(VERSION));
|
||||
|
||||
// Write resource count
|
||||
uint32_t resource_count = static_cast<uint32_t>(resources_.size());
|
||||
auto resource_count = static_cast<uint32_t>(resources_.size());
|
||||
file.write(reinterpret_cast<const char*>(&resource_count), sizeof(resource_count));
|
||||
|
||||
// Write resource entries
|
||||
for (const auto& [name, entry] : resources_) {
|
||||
// Write filename length and name
|
||||
uint32_t name_len = static_cast<uint32_t>(entry.filename.length());
|
||||
auto name_len = static_cast<uint32_t>(entry.filename.length());
|
||||
file.write(reinterpret_cast<const char*>(&name_len), sizeof(name_len));
|
||||
file.write(entry.filename.c_str(), name_len);
|
||||
|
||||
@@ -269,7 +269,7 @@ auto ResourcePack::getResourceList() const -> std::vector<std::string> {
|
||||
for (const auto& [name, entry] : resources_) {
|
||||
list.push_back(name);
|
||||
}
|
||||
std::sort(list.begin(), list.end());
|
||||
std::ranges::sort(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ auto ResourcePack::calculatePackChecksum() const -> uint32_t {
|
||||
for (const auto& [name, entry] : resources_) {
|
||||
sorted_names.push_back(name);
|
||||
}
|
||||
std::sort(sorted_names.begin(), sorted_names.end());
|
||||
std::ranges::sort(sorted_names);
|
||||
|
||||
// Combine individual checksums
|
||||
for (const auto& name : sorted_names) {
|
||||
@@ -300,4 +300,4 @@ auto ResourcePack::calculatePackChecksum() const -> uint32_t {
|
||||
return global_checksum;
|
||||
}
|
||||
|
||||
} // namespace jdd
|
||||
} // namespace Jdd
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace jdd {
|
||||
namespace Jdd {
|
||||
|
||||
// Entry metadata for each resource in the pack
|
||||
struct ResourceEntry {
|
||||
@@ -32,9 +32,9 @@ class ResourcePack {
|
||||
|
||||
// Disable copy/move
|
||||
ResourcePack(const ResourcePack&) = delete;
|
||||
ResourcePack& operator=(const ResourcePack&) = delete;
|
||||
auto operator=(const ResourcePack&) -> ResourcePack& = delete;
|
||||
ResourcePack(ResourcePack&&) = delete;
|
||||
ResourcePack& operator=(ResourcePack&&) = delete;
|
||||
auto operator=(ResourcePack&&) -> ResourcePack& = delete;
|
||||
|
||||
// Add a single file to the pack
|
||||
auto addFile(const std::string& filepath, const std::string& pack_name) -> bool;
|
||||
@@ -89,6 +89,6 @@ class ResourcePack {
|
||||
bool loaded_{false};
|
||||
};
|
||||
|
||||
} // namespace jdd
|
||||
} // namespace Jdd
|
||||
|
||||
#endif // RESOURCE_PACK_HPP
|
||||
|
||||
@@ -112,7 +112,7 @@ Director::Director(std::vector<std::string> const& args) {
|
||||
|
||||
// 3. Initialize resource pack system (optional, with fallback)
|
||||
std::cout << "Initializing resource pack (development mode): " << pack_path << '\n';
|
||||
jdd::ResourceHelper::initializeResourceSystem(pack_path, true);
|
||||
Jdd::ResourceHelper::initializeResourceSystem(pack_path, true);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -164,7 +164,7 @@ Director::~Director() {
|
||||
Input::destroy();
|
||||
Notifier::destroy();
|
||||
Resource::destroy();
|
||||
jdd::ResourceHelper::shutdownResourceSystem(); // Shutdown resource pack system
|
||||
Jdd::ResourceHelper::shutdownResourceSystem(); // Shutdown resource pack system
|
||||
Audio::destroy();
|
||||
Screen::destroy();
|
||||
Asset::destroy();
|
||||
|
||||
Reference in New Issue
Block a user