forked from jaildesigner-jailgames/jaildoctors_dilemma
linter
This commit is contained in:
@@ -8,21 +8,21 @@
|
||||
#include "utils/utils.hpp" // Para getFileName, printWithDots
|
||||
|
||||
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
||||
Asset* Asset::asset_ = nullptr;
|
||||
Asset* Asset::asset = nullptr;
|
||||
|
||||
// [SINGLETON] Crearemos el objeto asset con esta función estática
|
||||
void Asset::init(const std::string& executable_path) {
|
||||
Asset::asset_ = new Asset(executable_path);
|
||||
Asset::asset = new Asset(executable_path);
|
||||
}
|
||||
|
||||
// [SINGLETON] Destruiremos el objeto asset con esta función estática
|
||||
void Asset::destroy() {
|
||||
delete Asset::asset_;
|
||||
delete Asset::asset;
|
||||
}
|
||||
|
||||
// [SINGLETON] Con este método obtenemos el objeto asset y podemos trabajar con él
|
||||
Asset* Asset::get() {
|
||||
return Asset::asset_;
|
||||
return Asset::asset;
|
||||
}
|
||||
|
||||
// Añade un elemento a la lista
|
||||
@@ -39,10 +39,9 @@ std::string Asset::get(const std::string& text) const {
|
||||
|
||||
if (it != file_list_.end()) {
|
||||
return it->file;
|
||||
} else {
|
||||
std::cout << "Warning: file " << text << " not found" << std::endl;
|
||||
return "";
|
||||
}
|
||||
std::cout << "Warning: file " << text << " not found" << std::endl;
|
||||
return "";
|
||||
}
|
||||
|
||||
// Comprueba que existen todos los elementos
|
||||
@@ -74,8 +73,9 @@ bool Asset::check() const {
|
||||
success &= checkFile(f.file);
|
||||
}
|
||||
}
|
||||
if (success)
|
||||
if (success) {
|
||||
std::cout << " All files are OK." << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ bool Asset::check() const {
|
||||
}
|
||||
|
||||
// Comprueba que existe un fichero
|
||||
bool Asset::checkFile(const std::string& path) const {
|
||||
bool Asset::checkFile(const std::string& path) {
|
||||
std::ifstream file(path);
|
||||
bool success = file.good();
|
||||
file.close();
|
||||
@@ -99,7 +99,7 @@ bool Asset::checkFile(const std::string& path) const {
|
||||
}
|
||||
|
||||
// Devuelve el nombre del tipo de recurso
|
||||
std::string Asset::getTypeName(AssetType type) const {
|
||||
std::string Asset::getTypeName(AssetType type) {
|
||||
switch (type) {
|
||||
case AssetType::DATA:
|
||||
return "DATA";
|
||||
|
||||
@@ -22,7 +22,7 @@ enum class AssetType : int {
|
||||
class Asset {
|
||||
private:
|
||||
// [SINGLETON] Objeto asset privado para Don Melitón
|
||||
static Asset* asset_;
|
||||
static Asset* asset;
|
||||
|
||||
// Estructura para definir un item
|
||||
struct AssetItem {
|
||||
@@ -31,10 +31,10 @@ class Asset {
|
||||
bool required; // Indica si es un fichero que debe de existir
|
||||
|
||||
// Constructor
|
||||
AssetItem(const std::string& filePath, AssetType assetType, bool isRequired)
|
||||
: file(filePath),
|
||||
type(assetType),
|
||||
required(isRequired) {}
|
||||
AssetItem(const std::string& file_path, AssetType asset_type, bool is_required)
|
||||
: file(file_path),
|
||||
type(asset_type),
|
||||
required(is_required) {}
|
||||
};
|
||||
|
||||
// Variables
|
||||
@@ -43,10 +43,10 @@ class Asset {
|
||||
std::string executable_path_; // Ruta al ejecutable
|
||||
|
||||
// Comprueba que existe un fichero
|
||||
bool checkFile(const std::string& path) const;
|
||||
static bool checkFile(const std::string& path);
|
||||
|
||||
// Devuelve el nombre del tipo de recurso
|
||||
std::string getTypeName(AssetType type) const;
|
||||
static std::string getTypeName(AssetType type);
|
||||
|
||||
// Constructor
|
||||
explicit Asset(const std::string& executable_path)
|
||||
|
||||
Reference in New Issue
Block a user