Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpTemplateManager.cpp
Show All 22 Lines | |||||||||||
#include "simulation2/MessageTypes.h" | #include "simulation2/MessageTypes.h" | ||||||||||
#include "simulation2/serialization/SerializedTypes.h" | #include "simulation2/serialization/SerializedTypes.h" | ||||||||||
#include "lib/utf8.h" | #include "lib/utf8.h" | ||||||||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||||||||
#include "ps/TemplateLoader.h" | #include "ps/TemplateLoader.h" | ||||||||||
#include "ps/XML/RelaxNG.h" | #include "ps/XML/RelaxNG.h" | ||||||||||
class CCmpTemplateManager final : public ICmpTemplateManager | class CCmpTemplateManager final : public ICmpTemplateManager | ||||||||||
phositUnsubmitted Done Inline Actions
phosit: | |||||||||||
{ | { | ||||||||||
public: | public: | ||||||||||
static void ClassInit(CComponentManager& componentManager) | static void ClassInit(CComponentManager& componentManager) | ||||||||||
{ | { | ||||||||||
componentManager.SubscribeGloballyToMessageType(MT_Destroy); | componentManager.SubscribeGloballyToMessageType(MT_Destroy); | ||||||||||
} | } | ||||||||||
DEFAULT_COMPONENT_ALLOCATOR(TemplateManager) | DEFAULT_COMPONENT_ALLOCATOR(TemplateManager) | ||||||||||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | std::string CCmpTemplateManager::GetCurrentTemplateName(entity_id_t ent) const | ||||||||||
if (it == m_LatestTemplates.end()) | if (it == m_LatestTemplates.end()) | ||||||||||
return ""; | return ""; | ||||||||||
return it->second; | return it->second; | ||||||||||
} | } | ||||||||||
std::vector<std::string> CCmpTemplateManager::FindAllTemplates(bool includeActors) const | std::vector<std::string> CCmpTemplateManager::FindAllTemplates(bool includeActors) const | ||||||||||
{ | { | ||||||||||
ETemplatesType templatesType = includeActors ? ALL_TEMPLATES : SIMULATION_TEMPLATES; | ETemplatesType templatesType = includeActors ? ALL_TEMPLATES : SIMULATION_TEMPLATES; | ||||||||||
return m_templateLoader.FindTemplates("", true, templatesType); | std::vector<std::string> templates_to_ignore { | ||||||||||
// We want to ignore template_*.xml templates, since they may be incomplete. | |||||||||||
"template_", | |||||||||||
// Also ignore some subfolders. | |||||||||||
"mixins/", | |||||||||||
"special/" | |||||||||||
}; | |||||||||||
return m_templateLoader.FindTemplates("", true, templatesType, templates_to_ignore); | |||||||||||
} | } | ||||||||||
std::vector<std::vector<std::wstring>> CCmpTemplateManager::GetCivData() | std::vector<std::vector<std::wstring>> CCmpTemplateManager::GetCivData() | ||||||||||
{ | { | ||||||||||
std::vector<std::vector<std::wstring>> data; | std::vector<std::vector<std::wstring>> data; | ||||||||||
std::vector<std::string> templates_to_ignore { | |||||||||||
std::vector<std::string> names = m_templateLoader.FindTemplatesUnrestricted("special/players/", false); | // We want to ignore template_*.xml templates, since they may be incomplete. | ||||||||||
"template_", | |||||||||||
}; | |||||||||||
std::vector<std::string> names = m_templateLoader.FindTemplates("special/players/", false, SIMULATION_TEMPLATES, templates_to_ignore); | |||||||||||
data.reserve(names.size()); | data.reserve(names.size()); | ||||||||||
for (const std::string& name : names) | for (const std::string& name : names) | ||||||||||
{ | { | ||||||||||
const CParamNode& identity = GetTemplate(name)->GetChild("Identity"); | const CParamNode& identity = GetTemplate(name)->GetChild("Identity"); | ||||||||||
data.push_back(std::vector<std::wstring> { | data.push_back(std::vector<std::wstring> { | ||||||||||
identity.GetChild("Civ").ToWString(), | identity.GetChild("Civ").ToWString(), | ||||||||||
identity.GetChild("GenericName").ToWString() | identity.GetChild("GenericName").ToWString() | ||||||||||
}); | }); | ||||||||||
Show All 25 Lines |
Wildfire Games · Phabricator