forked from jaildesigner-jailgames/jaildoctors_dilemma
linter
This commit is contained in:
@@ -21,7 +21,7 @@ void Asset::destroy() {
|
||||
}
|
||||
|
||||
// [SINGLETON] Con este método obtenemos el objeto asset y podemos trabajar con él
|
||||
Asset* Asset::get() {
|
||||
auto Asset::get() -> Asset* {
|
||||
return Asset::asset;
|
||||
}
|
||||
|
||||
@@ -32,23 +32,23 @@ void Asset::add(const std::string& file, AssetType type, bool required, bool abs
|
||||
}
|
||||
|
||||
// Devuelve la ruta completa a un fichero a partir de una cadena
|
||||
std::string Asset::get(const std::string& text) const {
|
||||
auto it = std::find_if(file_list_.begin(), file_list_.end(), [&text](const auto& f) {
|
||||
auto Asset::get(const std::string& text) const -> std::string {
|
||||
auto it = std::ranges::find_if(file_list_, [&text](const auto& f) {
|
||||
return getFileName(f.file) == text;
|
||||
});
|
||||
|
||||
if (it != file_list_.end()) {
|
||||
return it->file;
|
||||
}
|
||||
std::cout << "Warning: file " << text << " not found" << std::endl;
|
||||
std::cout << "Warning: file " << text << " not found" << '\n';
|
||||
return "";
|
||||
}
|
||||
|
||||
// Comprueba que existen todos los elementos
|
||||
bool Asset::check() const {
|
||||
auto Asset::check() const -> bool {
|
||||
bool success = true;
|
||||
|
||||
std::cout << "\n** CHECKING FILES" << std::endl;
|
||||
std::cout << "\n** CHECKING FILES" << '\n';
|
||||
|
||||
// std::cout << "Executable path is: " << executable_path_ << std::endl;
|
||||
// std::cout << "Sample filepath: " << file_list_.back().file << std::endl;
|
||||
@@ -66,7 +66,7 @@ bool Asset::check() const {
|
||||
|
||||
// Si hay ficheros de ese tipo, comprueba si existen
|
||||
if (any) {
|
||||
std::cout << "\n>> " << getTypeName(static_cast<AssetType>(type)).c_str() << " FILES" << std::endl;
|
||||
std::cout << "\n>> " << getTypeName(static_cast<AssetType>(type)).c_str() << " FILES" << '\n';
|
||||
|
||||
for (const auto& f : file_list_) {
|
||||
if (f.required && f.type == static_cast<AssetType>(type)) {
|
||||
@@ -74,19 +74,19 @@ bool Asset::check() const {
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
std::cout << " All files are OK." << std::endl;
|
||||
std::cout << " All files are OK." << '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Resultado
|
||||
std::cout << (success ? "\n** CHECKING FILES COMPLETED.\n" : "\n** CHECKING FILES FAILED.\n") << std::endl;
|
||||
std::cout << (success ? "\n** CHECKING FILES COMPLETED.\n" : "\n** CHECKING FILES FAILED.\n") << '\n';
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
// Comprueba que existe un fichero
|
||||
bool Asset::checkFile(const std::string& path) {
|
||||
auto Asset::checkFile(const std::string& path) -> bool {
|
||||
std::ifstream file(path);
|
||||
bool success = file.good();
|
||||
file.close();
|
||||
@@ -99,7 +99,7 @@ bool Asset::checkFile(const std::string& path) {
|
||||
}
|
||||
|
||||
// Devuelve el nombre del tipo de recurso
|
||||
std::string Asset::getTypeName(AssetType type) {
|
||||
auto Asset::getTypeName(AssetType type) -> std::string {
|
||||
switch (type) {
|
||||
case AssetType::DATA:
|
||||
return "DATA";
|
||||
@@ -144,10 +144,10 @@ std::string Asset::getTypeName(AssetType type) {
|
||||
}
|
||||
|
||||
// Devuelve la lista de recursos de un tipo
|
||||
std::vector<std::string> Asset::getListByType(AssetType type) const {
|
||||
auto Asset::getListByType(AssetType type) const -> std::vector<std::string> {
|
||||
std::vector<std::string> list;
|
||||
|
||||
for (auto f : file_list_) {
|
||||
for (const auto& f : file_list_) {
|
||||
if (f.type == type) {
|
||||
list.push_back(f.file);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string> // para string, basic_string
|
||||
#include <utility>
|
||||
#include <vector> // para vector
|
||||
|
||||
#include "utils/utils.hpp"
|
||||
@@ -31,8 +32,8 @@ class Asset {
|
||||
bool required; // Indica si es un fichero que debe de existir
|
||||
|
||||
// Constructor
|
||||
AssetItem(const std::string& file_path, AssetType asset_type, bool is_required)
|
||||
: file(file_path),
|
||||
AssetItem(std::string file_path, AssetType asset_type, bool is_required)
|
||||
: file(std::move(file_path)),
|
||||
type(asset_type),
|
||||
required(is_required) {}
|
||||
};
|
||||
@@ -43,10 +44,10 @@ class Asset {
|
||||
std::string executable_path_; // Ruta al ejecutable
|
||||
|
||||
// Comprueba que existe un fichero
|
||||
static bool checkFile(const std::string& path);
|
||||
static auto checkFile(const std::string& path) -> bool;
|
||||
|
||||
// Devuelve el nombre del tipo de recurso
|
||||
static std::string getTypeName(AssetType type);
|
||||
static auto getTypeName(AssetType type) -> std::string;
|
||||
|
||||
// Constructor
|
||||
explicit Asset(const std::string& executable_path)
|
||||
@@ -63,17 +64,17 @@ class Asset {
|
||||
static void destroy();
|
||||
|
||||
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
|
||||
static Asset* get();
|
||||
static auto get() -> Asset*;
|
||||
|
||||
// Añade un elemento a la lista
|
||||
void add(const std::string& file, AssetType type, bool required = true, bool absolute = false);
|
||||
|
||||
// Devuelve la ruta completa a un fichero a partir de una cadena
|
||||
std::string get(const std::string& text) const;
|
||||
[[nodiscard]] auto get(const std::string& text) const -> std::string;
|
||||
|
||||
// Comprueba que existen todos los elementos
|
||||
bool check() const;
|
||||
[[nodiscard]] auto check() const -> bool;
|
||||
|
||||
// Devuelve la lista de recursos de un tipo
|
||||
std::vector<std::string> getListByType(AssetType type) const;
|
||||
[[nodiscard]] auto getListByType(AssetType type) const -> std::vector<std::string>;
|
||||
};
|
||||
Reference in New Issue
Block a user