forked from 0ad/0ad
Avoid hardcoding the actor entity template details.
This was SVN commit r9183.
This commit is contained in:
parent
df4b74ccf6
commit
a122f55bde
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity>
|
||||
<VisualActor>
|
||||
<SilhouetteDisplay>false</SilhouetteDisplay>
|
||||
<SilhouetteOccluder>false</SilhouetteOccluder>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity>
|
||||
<Position>
|
||||
<Altitude>0</Altitude>
|
||||
<Anchor>upright</Anchor>
|
||||
<Floating>false</Floating>
|
||||
</Position>
|
||||
<VisualActor>
|
||||
<SilhouetteDisplay>false</SilhouetteDisplay>
|
||||
<SilhouetteOccluder>false</SilhouetteOccluder>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -358,22 +358,21 @@ bool CCmpTemplateManager::LoadTemplateFile(const std::string& templateName, int
|
||||
|
||||
void CCmpTemplateManager::ConstructTemplateActor(const std::string& actorName, CParamNode& out)
|
||||
{
|
||||
std::string name = utf8_from_wstring(CParamNode::EscapeXMLString(wstring_from_utf8(actorName)));
|
||||
std::string xml = "<?xml version='1.0' encoding='utf-8'?>"
|
||||
"<Entity>"
|
||||
"<Position>"
|
||||
"<Anchor>upright</Anchor>"
|
||||
"<Altitude>0</Altitude>"
|
||||
"<Floating>false</Floating>"
|
||||
"</Position>"
|
||||
"<VisualActor>"
|
||||
"<Actor>" + name + "</Actor>"
|
||||
"<SilhouetteDisplay>false</SilhouetteDisplay>"
|
||||
"<SilhouetteOccluder>false</SilhouetteOccluder>"
|
||||
"</VisualActor>"
|
||||
"</Entity>";
|
||||
// Load the base actor template if necessary
|
||||
const char* templateName = "special/actor";
|
||||
if (!LoadTemplateFile(templateName, 0))
|
||||
{
|
||||
LOGERROR(L"Failed to load entity template '%hs'", templateName);
|
||||
return;
|
||||
}
|
||||
|
||||
out.LoadXMLString(out, xml.c_str());
|
||||
// Copy the actor template
|
||||
out = m_TemplateFileData[templateName];
|
||||
|
||||
// Initialise the actor's name
|
||||
std::string name = utf8_from_wstring(CParamNode::EscapeXMLString(wstring_from_utf8(actorName)));
|
||||
std::string xml = "<Entity><VisualActor><Actor>" + name + "</Actor></VisualActor></Entity>";
|
||||
CParamNode::LoadXMLString(out, xml.c_str());
|
||||
}
|
||||
|
||||
static LibError AddToTemplates(const VfsPath& pathname, const FileInfo& UNUSED(fileInfo), const uintptr_t cbData)
|
||||
|
@ -78,7 +78,6 @@ public:
|
||||
const CParamNode* actor = tempMan->LoadTemplate(ent2, "actor|example1", -1);
|
||||
TS_ASSERT(actor != NULL);
|
||||
TS_ASSERT_WSTR_EQUALS(actor->ToXML(),
|
||||
L"<Position><Altitude>0</Altitude><Anchor>upright</Anchor><Floating>false</Floating></Position>"
|
||||
L"<VisualActor><Actor>example1</Actor><SilhouetteDisplay>false</SilhouetteDisplay><SilhouetteOccluder>false</SilhouetteOccluder></VisualActor>");
|
||||
|
||||
const CParamNode* preview = tempMan->LoadTemplate(ent2, "preview|unit", -1);
|
||||
@ -105,7 +104,6 @@ public:
|
||||
const CParamNode* previewactor = tempMan->LoadTemplate(ent2, "preview|actor|example2", -1);
|
||||
TS_ASSERT(previewactor != NULL);
|
||||
TS_ASSERT_WSTR_EQUALS(previewactor->ToXML(),
|
||||
L"<Position><Altitude>0</Altitude><Anchor>upright</Anchor><Floating>false</Floating></Position>"
|
||||
L"<Vision><AlwaysVisible>true</AlwaysVisible><Range>0</Range><RetainInFog>false</RetainInFog></Vision>"
|
||||
L"<VisualActor><Actor>example2</Actor><SilhouetteDisplay>false</SilhouetteDisplay><SilhouetteOccluder>false</SilhouetteOccluder></VisualActor>");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user