Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for UnrealScript #2305

Merged
merged 2 commits into from Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions components.json
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
@@ -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
@@ -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
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
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