Changeset View
Changeset View
Standalone View
Standalone View
source/ps/TemplateLoader.cpp
/* Copyright (C) 2022 Wildfire Games. | /* Copyright (C) 2023 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | if (templatesType == SIMULATION_TEMPLATES || templatesType == ALL_TEMPLATES) | ||||
WARN_IF_ERR(vfs::ForEachFile(g_VFS, VfsPath(TEMPLATE_ROOT) / path, AddToTemplates, (uintptr_t)&templates, L"*.xml", flags)); | WARN_IF_ERR(vfs::ForEachFile(g_VFS, VfsPath(TEMPLATE_ROOT) / path, AddToTemplates, (uintptr_t)&templates, L"*.xml", flags)); | ||||
if (templatesType == ACTOR_TEMPLATES || templatesType == ALL_TEMPLATES) | if (templatesType == ACTOR_TEMPLATES || templatesType == ALL_TEMPLATES) | ||||
WARN_IF_ERR(vfs::ForEachFile(g_VFS, VfsPath(ACTOR_ROOT) / path, AddActorToTemplates, (uintptr_t)&templates, L"*.xml", flags)); | WARN_IF_ERR(vfs::ForEachFile(g_VFS, VfsPath(ACTOR_ROOT) / path, AddActorToTemplates, (uintptr_t)&templates, L"*.xml", flags)); | ||||
return templates; | return templates; | ||||
} | } | ||||
std::vector<std::string> CTemplateLoader::FindTemplatesUnrestricted(const std::string& path, bool includeSubdirectories) const | |||||
{ | |||||
std::vector<std::string> templates; | |||||
size_t flags = includeSubdirectories ? vfs::DIR_RECURSIVE : 0; | |||||
WARN_IF_ERR(vfs::ForEachFile(g_VFS, VfsPath(TEMPLATE_ROOT) / path, AddToTemplatesUnrestricted, (uintptr_t)&templates, L"*.xml", flags)); | |||||
return templates; | |||||
} | |||||
const CParamNode& CTemplateLoader::GetTemplateFileData(const std::string& templateName) | const CParamNode& CTemplateLoader::GetTemplateFileData(const std::string& templateName) | ||||
{ | { | ||||
if (std::unordered_map<std::string, CParamNode>::const_iterator it = m_TemplateFileData.find(templateName); it != m_TemplateFileData.end()) | if (std::unordered_map<std::string, CParamNode>::const_iterator it = m_TemplateFileData.find(templateName); it != m_TemplateFileData.end()) | ||||
return it->second; | return it->second; | ||||
CParamNode ret; | CParamNode ret; | ||||
if (!LoadTemplateFile(ret, templateName, false, 0)) | if (!LoadTemplateFile(ret, templateName, false, 0)) | ||||
{ | { | ||||
Show All 26 Lines |
Wildfire Games · Phabricator