diff --git a/binaries/data/mods/public/simulation/templates/special_filter/actor.xml b/binaries/data/mods/public/simulation/templates/special_filter/actor.xml
new file mode 100644
index 0000000..b63e632
-
|
+
|
|
| 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <Entity filtered=""> |
| 3 | <!-- Arbitrary-sized Footprint definition to make actors' selection outlines show up in Atlas --> |
| 4 | <Footprint> |
| 5 | <Circle radius='2.0'/> |
| 6 | <Height>1.0</Height> |
| 7 | </Footprint> |
| 8 | <Selectable> |
| 9 | <EditorOnly/> |
| 10 | <Overlay> |
| 11 | <Texture> |
| 12 | <MainTexture>actor.png</MainTexture> |
| 13 | <MainTextureMask>actor_mask.png</MainTextureMask> |
| 14 | </Texture> |
| 15 | </Overlay> |
| 16 | </Selectable> |
| 17 | <VisualActor> |
| 18 | <!-- Actor is added by the TemplateLoader --> |
| 19 | <ActorOnly/> |
| 20 | </VisualActor> |
| 21 | </Entity> |
| 22 | |
diff --git a/source/ps/TemplateLoader.cpp b/source/ps/TemplateLoader.cpp
index f26ddac..374a82b 100644
a
|
b
|
bool CTemplateLoader::LoadTemplateFile(const std::string& templateName, int dept
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 | |
45 | | // Handle special case "actor|foo" |
46 | | if (templateName.find("actor|") == 0) |
47 | | { |
48 | | ConstructTemplateActor(templateName.substr(6), m_TemplateFileData[templateName]); |
49 | | return true; |
50 | | } |
51 | | |
52 | 45 | // Handle special case "bar|foo" |
53 | 46 | size_t pos = templateName.find_first_of('|'); |
54 | 47 | if (pos != std::string::npos) |
… |
… |
bool CTemplateLoader::LoadTemplateFile(const std::string& templateName, int dept
|
56 | 49 | std::string prefix = templateName.substr(0, pos); |
57 | 50 | std::string baseName = templateName.substr(pos+1); |
58 | 51 | |
| 52 | // Handle special case "actor|foo" |
| 53 | std::string tName; |
| 54 | if (prefix == "actor") |
| 55 | { |
| 56 | tName = baseName; |
| 57 | baseName = "special/actor"; |
| 58 | } |
| 59 | |
59 | 60 | if (!LoadTemplateFile(baseName, depth+1)) |
60 | 61 | { |
61 | 62 | LOGERROR("Failed to load entity template '%s'", baseName.c_str()); |
… |
… |
bool CTemplateLoader::LoadTemplateFile(const std::string& templateName, int dept
|
76 | 77 | |
77 | 78 | m_TemplateFileData[templateName] = m_TemplateFileData[baseName]; |
78 | 79 | CParamNode::LoadXML(m_TemplateFileData[templateName], xero, path.string().c_str()); |
| 80 | |
| 81 | if (prefix == "actor") |
| 82 | CParamNode::LoadXMLString(m_TemplateFileData[templateName], |
| 83 | CStr("<Entity>" |
| 84 | "<VisualActor>" |
| 85 | "<Actor>" + |
| 86 | utf8_from_wstring(CParamNode::EscapeXMLString(wstring_from_utf8(tName))) + |
| 87 | "</Actor>" |
| 88 | "</VisualActor>" |
| 89 | "</Entity>").c_str()); |
| 90 | |
79 | 91 | return true; |
80 | 92 | } |
81 | 93 | |
… |
… |
const CParamNode& CTemplateLoader::GetTemplateFileData(const std::string& templa
|
270 | 282 | |
271 | 283 | return m_TemplateFileData[templateName]; |
272 | 284 | } |
273 | | |
274 | | void CTemplateLoader::ConstructTemplateActor(const std::string& actorName, CParamNode& out) |
275 | | { |
276 | | // Load the base actor template if necessary |
277 | | const char* templateName = "special/actor"; |
278 | | if (!LoadTemplateFile(templateName, 0)) |
279 | | { |
280 | | LOGERROR("Failed to load entity template '%s'", templateName); |
281 | | return; |
282 | | } |
283 | | |
284 | | // Copy the actor template |
285 | | out = m_TemplateFileData[templateName]; |
286 | | |
287 | | // Initialise the actor's name and make it an Atlas selectable entity. |
288 | | std::wstring actorNameW = wstring_from_utf8(actorName); |
289 | | std::string name = utf8_from_wstring(CParamNode::EscapeXMLString(actorNameW)); |
290 | | std::string xml = "<Entity>" |
291 | | "<VisualActor><Actor>" + name + "</Actor><ActorOnly/></VisualActor>" |
292 | | // arbitrary-sized Footprint definition to make actors' selection outlines show up in Atlas |
293 | | "<Footprint><Circle radius='2.0'/><Height>1.0</Height></Footprint>" |
294 | | "<Selectable>" |
295 | | "<EditorOnly/>" |
296 | | "<Overlay><Texture><MainTexture>actor.png</MainTexture><MainTextureMask>actor_mask.png</MainTextureMask></Texture></Overlay>" |
297 | | "</Selectable>" |
298 | | "</Entity>"; |
299 | | |
300 | | CParamNode::LoadXMLString(out, xml.c_str(), actorNameW.c_str()); |
301 | | } |