Skip to content

Commit

Permalink
Added support for UnrealScript (#2305)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Apr 27, 2020
1 parent bd4d816 commit 1093ceb
Show file tree
Hide file tree
Showing 18 changed files with 584 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,11 @@
"title": "T4 templating",
"owner": "RunDevelopment"
},
"unrealscript": {
"title": "UnrealScript",
"alias": ["uscript", "uc"],
"owner": "RunDevelopment"
},
"vala": {
"title": "Vala",
"require": "clike",
Expand Down
42 changes: 42 additions & 0 deletions components/prism-unrealscript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Prism.languages.unrealscript = {
'comment': /\/\/.*|\/\*[\s\S]*?\*\//,
'string': {
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
greedy: true
},
'category': {
pattern: /(\b(?:(?:autoexpand|hide|show)categories|var)\s*\()[^()]+(?=\))/,
lookbehind: true,
greedy: true,
alias: 'property'
},
'metadata': {
pattern: /(\w\s*)<\s*\w+\s*=[^<>|=\r\n]+(?:\|\s*\w+\s*=[^<>|=\r\n]+)*>/,
lookbehind: true,
greedy: true,
inside: {
'property': /\w+(?=\s*=)/,
'operator': /=/,
'punctuation': /[<>|]/
}
},
'macro': {
pattern: /`\w+/,
alias: 'property'
},
'class-name': {
pattern: /(\b(?:class|enum|extends|interface|state(?:\(\))?|struct|within)\s+)\w+/,
lookbehind: true
},

'keyword': /\b(?:abstract|actor|array|auto|autoexpandcategories|bool|break|byte|case|class|classgroup|client|coerce|collapsecategories|config|const|continue|default|defaultproperties|delegate|dependson|deprecated|do|dontcollapsecategories|editconst|editinlinenew|else|enum|event|exec|export|extends|final|float|for|forcescriptorder|foreach|function|goto|guid|hidecategories|hidedropdown|if|ignores|implements|inherits|input|int|interface|iterator|latent|local|material|name|native|nativereplication|noexport|nontransient|noteditinlinenew|notplaceable|operator|optional|out|pawn|perobjectconfig|perobjectlocalized|placeable|postoperator|preoperator|private|protected|reliable|replication|return|server|showcategories|simulated|singular|state|static|string|struct|structdefault|structdefaultproperties|switch|texture|transient|travel|unreliable|until|var|vector|while|within)\b/,
'function': /[a-z_]\w*(?=\s*\()/i,

'boolean': /\b(?:false|true)\b/,
'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
// https://docs.unrealengine.com/udk/Three/UnrealScriptExpressions.html
'operator': />>|<<|--|\+\+|\*\*|[-+*/~!=<>$@]=?|&&?|\|\|?|\^\^?|[?:%]|\b(?:Cross|Dot|ClockwiseFrom)\b/,
'punctuation': /[()[\]{};,.]/
};

Prism.languages.uc = Prism.languages.uscript = Prism.languages.unrealscript;
1 change: 1 addition & 0 deletions components/prism-unrealscript.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions examples/prism-unrealscript.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<h2>Full example</h2>
<pre><code>// Source: https://github.com/Jusas/XCOM2_ReconSoldierClass/blob/master/ReconOperatorSoldierClass/Src/ReconSoldierClass/Classes/ReconOperator_AcademyUnlocks.uc

class ReconOperator_AcademyUnlocks extends X2StrategyElement;

static function array&lt;X2DataTemplate> CreateTemplates()
{
local array&lt;X2DataTemplate> Templates;

Templates.AddItem(AdrenalineUnlock());

return Templates;
}

static function X2SoldierAbilityUnlockTemplate AdrenalineUnlock()
{
local X2SoldierAbilityUnlockTemplate Template;
local ArtifactCost Resources;

`CREATE_X2TEMPLATE(class'X2SoldierAbilityUnlockTemplate', Template, 'ReconAdrenalineUnlock');

Template.AllowedClasses.AddItem('ReconSoldierClass');
Template.AbilityName = 'ReconAdrenalineSpike';
Template.strImage = "img:///UILibrary_ReconOperator.GTS.GTS_adrenaline";

// Requirements
Template.Requirements.RequiredHighestSoldierRank = 5;
Template.Requirements.RequiredSoldierClass = 'ReconSoldierClass';
Template.Requirements.RequiredSoldierRankClassCombo = true;
Template.Requirements.bVisibleIfSoldierRankGatesNotMet = true;

// Cost
Resources.ItemTemplateName = 'Supplies';
Resources.Quantity = 75;
Template.Cost.ResourceCosts.AddItem(Resources);

return Template;
}</code></pre>
2 changes: 2 additions & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@
"trig": "turtle",
"ts": "typescript",
"t4": "t4-cs",
"uscript": "unrealscript",
"uc": "unrealscript",
"vb": "visual-basic",
"xeoracube": "xeora",
"yml": "yaml"
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@
"t4": "T4 Text Templates (C#)",
"t4-vb": "T4 Text Templates (VB)",
"t4-templating": "T4 templating",
"uscript": "UnrealScript",
"uc": "UnrealScript",
"vbnet": "VB.Net",
"vhdl": "VHDL",
"vim": "vim",
Expand Down
Loading

0 comments on commit 1093ceb

Please sign in to comment.