forked from jaildesigner-jailgames/jaildoctors_dilemma
linter
This commit is contained in:
@@ -18,16 +18,16 @@ struct JA_Music_t; // lines 17-17
|
||||
struct JA_Sound_t; // lines 18-18
|
||||
|
||||
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
||||
Resource* Resource::resource_ = nullptr;
|
||||
Resource* Resource::resource = nullptr;
|
||||
|
||||
// [SINGLETON] Crearemos el objeto screen con esta función estática
|
||||
void Resource::init() { Resource::resource_ = new Resource(); }
|
||||
void Resource::init() { Resource::resource = new Resource(); }
|
||||
|
||||
// [SINGLETON] Destruiremos el objeto screen con esta función estática
|
||||
void Resource::destroy() { delete Resource::resource_; }
|
||||
void Resource::destroy() { delete Resource::resource; }
|
||||
|
||||
// [SINGLETON] Con este método obtenemos el objeto screen y podemos trabajar con él
|
||||
Resource* Resource::get() { return Resource::resource_; }
|
||||
Resource* Resource::get() { return Resource::resource; }
|
||||
|
||||
// Constructor
|
||||
Resource::Resource() { load(); }
|
||||
@@ -155,7 +155,7 @@ std::vector<int>& Resource::getTileMap(const std::string& name) {
|
||||
auto it = std::find_if(tile_maps_.begin(), tile_maps_.end(), [&name](const auto& t) { return t.name == name; });
|
||||
|
||||
if (it != tile_maps_.end()) {
|
||||
return it->tileMap;
|
||||
return it->tile_map;
|
||||
}
|
||||
|
||||
std::cerr << "Error: Mapa de tiles no encontrado " << name << std::endl;
|
||||
@@ -300,14 +300,14 @@ void Resource::loadRooms() {
|
||||
void Resource::createText() {
|
||||
struct ResourceInfo {
|
||||
std::string key; // Identificador del recurso
|
||||
std::string textureFile; // Nombre del archivo de textura
|
||||
std::string textFile; // Nombre del archivo de texto
|
||||
std::string texture_file; // Nombre del archivo de textura
|
||||
std::string text_file; // Nombre del archivo de texto
|
||||
|
||||
// Constructor para facilitar la creación de objetos ResourceInfo
|
||||
ResourceInfo(const std::string& k, const std::string& tFile, const std::string& txtFile)
|
||||
ResourceInfo(const std::string& k, const std::string& t_file, const std::string& txt_file)
|
||||
: key(k),
|
||||
textureFile(tFile),
|
||||
textFile(txtFile) {}
|
||||
texture_file(t_file),
|
||||
text_file(txt_file) {}
|
||||
};
|
||||
|
||||
std::cout << "\n>> CREATING TEXT_OBJECTS" << std::endl;
|
||||
@@ -320,7 +320,7 @@ void Resource::createText() {
|
||||
{"8bithud", "8bithud.gif", "8bithud.txt"}};
|
||||
|
||||
for (const auto& resource : resources) {
|
||||
texts_.emplace_back(ResourceText(resource.key, std::make_shared<Text>(getSurface(resource.textureFile), getTextFile(resource.textFile))));
|
||||
texts_.emplace_back(ResourceText(resource.key, std::make_shared<Text>(getSurface(resource.texture_file), getTextFile(resource.text_file))));
|
||||
printWithDots("Text : ", resource.key, "[ DONE ]");
|
||||
}
|
||||
}
|
||||
@@ -329,7 +329,7 @@ void Resource::createText() {
|
||||
void Resource::clearSounds() {
|
||||
// Itera sobre el vector y libera los recursos asociados a cada JA_Sound_t
|
||||
for (auto& sound : sounds_) {
|
||||
if (sound.sound) {
|
||||
if (sound.sound != nullptr) {
|
||||
JA_DeleteSound(sound.sound);
|
||||
sound.sound = nullptr;
|
||||
}
|
||||
@@ -341,7 +341,7 @@ void Resource::clearSounds() {
|
||||
void Resource::clearMusics() {
|
||||
// Itera sobre el vector y libera los recursos asociados a cada JA_Music_t
|
||||
for (auto& music : musics_) {
|
||||
if (music.music) {
|
||||
if (music.music != nullptr) {
|
||||
JA_DeleteMusic(music.music);
|
||||
music.music = nullptr;
|
||||
}
|
||||
@@ -351,7 +351,7 @@ void Resource::clearMusics() {
|
||||
|
||||
// Calcula el numero de recursos para cargar
|
||||
void Resource::calculateTotal() {
|
||||
std::vector<AssetType> assetTypes = {
|
||||
std::vector<AssetType> asset_types = {
|
||||
AssetType::SOUND,
|
||||
AssetType::MUSIC,
|
||||
AssetType::BITMAP,
|
||||
@@ -362,8 +362,8 @@ void Resource::calculateTotal() {
|
||||
AssetType::ROOM};
|
||||
|
||||
size_t total = 0;
|
||||
for (const auto& assetType : assetTypes) {
|
||||
auto list = Asset::get()->getListByType(assetType);
|
||||
for (const auto& asset_type : asset_types) {
|
||||
auto list = Asset::get()->getListByType(asset_type);
|
||||
total += list.size();
|
||||
}
|
||||
|
||||
@@ -375,17 +375,17 @@ void Resource::renderProgress() {
|
||||
constexpr float X_PADDING = 10;
|
||||
constexpr float Y_PADDING = 10;
|
||||
constexpr float BAR_HEIGHT = 10;
|
||||
const float bar_position = Options::game.height - BAR_HEIGHT - Y_PADDING;
|
||||
const float BAR_POSITION = Options::game.height - BAR_HEIGHT - Y_PADDING;
|
||||
Screen::get()->start();
|
||||
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||
|
||||
auto surface = Screen::get()->getRendererSurface();
|
||||
const float WIRED_BAR_WIDTH = Options::game.width - (X_PADDING * 2);
|
||||
SDL_FRect rect_wired = {X_PADDING, bar_position, WIRED_BAR_WIDTH, X_PADDING};
|
||||
SDL_FRect rect_wired = {X_PADDING, BAR_POSITION, WIRED_BAR_WIDTH, X_PADDING};
|
||||
surface->drawRectBorder(&rect_wired, static_cast<Uint8>(PaletteColor::WHITE));
|
||||
|
||||
const float FULL_BAR_WIDTH = WIRED_BAR_WIDTH * count_.getPercentage();
|
||||
SDL_FRect rect_full = {X_PADDING, bar_position, FULL_BAR_WIDTH, X_PADDING};
|
||||
SDL_FRect rect_full = {X_PADDING, BAR_POSITION, FULL_BAR_WIDTH, X_PADDING};
|
||||
surface->fillRect(&rect_full, static_cast<Uint8>(PaletteColor::WHITE));
|
||||
|
||||
Screen::get()->render();
|
||||
|
||||
@@ -91,12 +91,12 @@ struct ResourceAnimation {
|
||||
// Estructura para almacenar ficheros con el mapa de tiles de una habitación y su nombre
|
||||
struct ResourceTileMap {
|
||||
std::string name; // Nombre del mapa de tiles
|
||||
std::vector<int> tileMap; // Vector con los indices del mapa de tiles
|
||||
std::vector<int> tile_map; // Vector con los indices del mapa de tiles
|
||||
|
||||
// Constructor
|
||||
ResourceTileMap(const std::string& name, const std::vector<int>& tileMap)
|
||||
ResourceTileMap(const std::string& name, const std::vector<int>& tile_map)
|
||||
: name(name),
|
||||
tileMap(tileMap) {}
|
||||
tile_map(tile_map) {}
|
||||
};
|
||||
|
||||
// Estructura para almacenar habitaciones y su nombre
|
||||
@@ -131,7 +131,7 @@ struct ResourceCount {
|
||||
}
|
||||
|
||||
// Obtiene el porcentaje de recursos cargados
|
||||
float getPercentage() {
|
||||
float getPercentage() const {
|
||||
return static_cast<float>(loaded) / static_cast<float>(total);
|
||||
}
|
||||
};
|
||||
@@ -139,7 +139,7 @@ struct ResourceCount {
|
||||
class Resource {
|
||||
private:
|
||||
// [SINGLETON] Objeto resource privado para Don Melitón
|
||||
static Resource* resource_;
|
||||
static Resource* resource;
|
||||
|
||||
std::vector<ResourceSound> sounds_; // Vector con los sonidos
|
||||
std::vector<ResourceMusic> musics_; // Vector con las musicas
|
||||
@@ -198,8 +198,8 @@ class Resource {
|
||||
// Muestra el progreso de carga
|
||||
void renderProgress();
|
||||
|
||||
// Comprueba los eventos
|
||||
void checkEvents();
|
||||
// Comprueba los eventosstatic
|
||||
static void checkEvents();
|
||||
|
||||
// Actualiza el progreso de carga
|
||||
void updateLoadingProgress(int steps = 5);
|
||||
|
||||
Reference in New Issue
Block a user