-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up class parsing + add visible classes to be displayed in the G…
…UI without adding them separatedly to our tooltips git-svn-id: http://svn.wildfiregames.com/public/ps/trunk@15195 3db68df2-c116-0410-a063-a993310a9797
- Loading branch information
sanderd17
committed
May 22, 2014
1 parent
f280288
commit 9d74acc
Showing
8 changed files
with
65 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 20 additions & 13 deletions
33
binaries/data/mods/public/simulation/helpers/Templates.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,31 @@ | ||
/** | ||
* Return template.Identity.Classes._string if exists | ||
* Gets an array of all classes for this identity template | ||
*/ | ||
function GetTemplateIdentityClassesString(template) | ||
function GetIdentityClasses(template) | ||
{ | ||
var identityClassesString = undefined; | ||
if (template.Identity && template.Identity.Classes && "_string" in template.Identity.Classes) | ||
identityClassesString = template.Identity.Classes._string; | ||
return identityClassesString; | ||
var classList = []; | ||
if (template.Classes && template.Classes._string) | ||
classList = classList.concat(template.Classes._string.split(/\s+/)); | ||
|
||
if (template.VisibleClasses && template.VisibleClasses._string) | ||
classList.concat(template.VisibleClasses._string.split(/\s+/)); | ||
|
||
if (template.Rank) | ||
classList = classList.concat(template.Rank); | ||
return classList; | ||
} | ||
|
||
/** | ||
* Check whether template.Identity.Classes contains specified class | ||
* Gets an array with all classes for this identity template | ||
* that should be shown in the GUI | ||
*/ | ||
function TemplateHasIdentityClass(template, className) | ||
function GetVisibleIdentityClasses(template) | ||
{ | ||
var identityClassesString = GetTemplateIdentityClassesString(template); | ||
var hasClass = identityClassesString && identityClassesString.indexOf(className) != -1; | ||
return hasClass; | ||
if (template.VisibleClasses && template.VisibleClasses._string) | ||
return template.VisibleClasses._string.split(/\s+/); | ||
return []; | ||
} | ||
|
||
Engine.RegisterGlobal("GetTemplateIdentityClassesString", GetTemplateIdentityClassesString); | ||
Engine.RegisterGlobal("TemplateHasIdentityClass", TemplateHasIdentityClass); | ||
Engine.RegisterGlobal("GetIdentityClasses", GetIdentityClasses); | ||
Engine.RegisterGlobal("GetVisibleIdentityClasses", GetVisibleIdentityClasses); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters