.
This commit is contained in:
@@ -28,34 +28,19 @@ Asset *Asset::get()
|
||||
return Asset::asset_;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Asset::Asset(const std::string &executable_path)
|
||||
: executable_path_(executable_path.substr(0, executable_path.find_last_of("\\/")))
|
||||
{
|
||||
longest_name_ = 0;
|
||||
}
|
||||
|
||||
// Añade un elemento a la lista
|
||||
void Asset::add(const std::string &file, AssetType type, bool required, bool absolute)
|
||||
{
|
||||
AssetItem ai;
|
||||
ai.file = absolute ? file : executable_path_ + file;
|
||||
ai.type = type;
|
||||
ai.required = required;
|
||||
file_list_.push_back(ai);
|
||||
|
||||
longest_name_ = SDL_max(longest_name_, getFileName(file).size());
|
||||
file_list_.emplace_back(absolute ? file : executable_path_ + file, type, required);
|
||||
longest_name_ = std::max(longest_name_, static_cast<int>(file_list_.back().file.size()));
|
||||
}
|
||||
|
||||
// Devuelve el fichero de un elemento de la lista a partir de una cadena
|
||||
// Devuelve la ruta completa a un fichero a partir de una cadena
|
||||
std::string Asset::get(const std::string &text) const
|
||||
{
|
||||
for (const auto &f : file_list_)
|
||||
{
|
||||
const size_t last_index = f.file.find_last_of("/") + 1;
|
||||
const std::string file = f.file.substr(last_index, std::string::npos);
|
||||
|
||||
if (file == text)
|
||||
if (getFileName(f.file) == text)
|
||||
{
|
||||
return f.file;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user