Skip to content

Commit

Permalink
Merge pull request #347 from Zezombye/346-decompiling-workshop-script…
Browse files Browse the repository at this point in the history
…-with-take-a-breather-disabled-causes-error

Allow disabling Take a Breather
  • Loading branch information
CactusPuppy authored Nov 15, 2023
2 parents 57d4c0c + 2322ede commit 517f665
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/tests/results/*.txt text eol=lf
15 changes: 15 additions & 0 deletions VS Code Extension/customGameSettingsSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16473,6 +16473,9 @@
"enableUlt": {
"type": "boolean"
},
"enableSecondaryFire": {
"type": "boolean"
},
"secondaryFireMaximumTime%": {
"type": "number",
"minimum": 20,
Expand Down Expand Up @@ -21302,6 +21305,9 @@
"enableUlt": {
"type": "boolean"
},
"enableSecondaryFire": {
"type": "boolean"
},
"secondaryFireMaximumTime%": {
"type": "number",
"minimum": 20,
Expand Down Expand Up @@ -26131,6 +26137,9 @@
"enableUlt": {
"type": "boolean"
},
"enableSecondaryFire": {
"type": "boolean"
},
"secondaryFireMaximumTime%": {
"type": "number",
"minimum": 20,
Expand Down Expand Up @@ -30960,6 +30969,9 @@
"enableUlt": {
"type": "boolean"
},
"enableSecondaryFire": {
"type": "boolean"
},
"secondaryFireMaximumTime%": {
"type": "number",
"minimum": 20,
Expand Down Expand Up @@ -35930,6 +35942,9 @@
"enableUlt": {
"type": "boolean"
},
"enableSecondaryFire": {
"type": "boolean"
},
"secondaryFireMaximumTime%": {
"type": "number",
"minimum": 20,
Expand Down
105 changes: 83 additions & 22 deletions VS Code Extension/overpy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,17 @@ const opyInternalFuncs = {
const opyFuncs = {
//Functions

"_&toArray": {
"description": "Get an array of the values of an enum.",
"args": [
{
"name": "__enumType__",
"description": "The enum to take the values from.",
"type": "Type"
}
],
"return": {Array: "Object"}
},
"all": {
"description": "Whether every value in the specified array evaluates to true. Can use mapped arrays.\n\nExample: `all([player.A == 2 for player in getAllPlayers()])`",
"args": [
Expand Down Expand Up @@ -63380,6 +63391,7 @@ const customGameSettingsSchema =
"orisa",
"pharah",
"reinhardt",
"roadhog",
"sigma",
"sojourn",
"soldier",
Expand Down Expand Up @@ -74678,6 +74690,32 @@ astParsingFunctions["_&setUltCharge"] = function(content) {

return content;
}
/*
* This file is part of OverPy (https://github.com/Zezombye/overpy).
* Copyright (c) 2023 Zezombye.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

"use strict";

astParsingFunctions["_&toArray"] = function(content) {
if (content.args[0].name === "__enumType__") {
return new Ast("__array__", content.args[0].args)
}

return content;
}
/*
* This file is part of OverPy (https://github.com/Zezombye/overpy).
* Copyright (c) 2019 Zezombye.
Expand Down Expand Up @@ -75791,7 +75829,9 @@ astParsingFunctions.healee = function(content) {

astParsingFunctions.len = function(content) {

if (enableOptimization) {
if (content.args[0].name === "__enumType__") {
return new getAstForNumber(content.args[0].args.length);
} else if (enableOptimization) {
if (content.args[0].name === "__array__") {
return getAstForNumber(content.args[0].args.length);
}
Expand Down Expand Up @@ -78109,6 +78149,33 @@ class WorkshopVar {
}
}

const builtInEnumNameToAstInfo = {
"Hero": {
name: "__hero__",
type: "HeroLiteral"
},
"Map": {
name: "__map__",
type: "MapLiteral"
},
"Gamemode": {
name: "__gamemode__",
type: "GamemodeLiteral"
},
"Team": {
name: "__team__",
type: "TeamLiteral"
},
"Button": {
name: "__button__",
type: "ButtonLiteral"
},
"Color": {
name: "__color__",
type: "ColorLiteral"
}
}

function parseLines(lines) {

//console.log("Lines to ast: "+JSON.stringify(lines, null, 4));
Expand Down Expand Up @@ -78758,6 +78825,17 @@ function parse(content, kwargs={}) {
result.originalName = name;
return result;
}

//Check for enums
if (enumMembers[name]) {
return new Ast("__enumType__", Object.values(enumMembers[name]), [], "Type");
} else if (builtInEnumNameToAstInfo[name]) {
const astInfo = builtInEnumNameToAstInfo[name];
const values = Object.keys(constantValues[astInfo.type])
.filter((key) => key !== "description")
.map((key) => new Ast(astInfo.name, [new Ast(key, [], [], astInfo.type)]))
return new Ast("__enumType__", values, [], "Type");
}

//Check for global variable
if (isVarName(name, true)) {
Expand Down Expand Up @@ -78959,29 +79037,12 @@ function parseMember(object, member) {
return enumMembers[object[0].text][name];
}

//Check enums
//Check for enums
if (Object.keys(constantValues).includes(object[0].text)) {
return new Ast(name, [], [], object[0].text);

} else if (object[0].text === "Hero") {
return new Ast("__hero__", [new Ast(name, [], [], "HeroLiteral")])

} else if (object[0].text === "Map") {
return new Ast("__map__", [new Ast(name, [], [], "MapLiteral")])

} else if (object[0].text === "Gamemode") {
return new Ast("__gamemode__", [new Ast(name, [], [], "GamemodeLiteral")])

} else if (object[0].text === "Team") {
return new Ast("__team__", [new Ast(name, [], [], "TeamLiteral")])

} else if (object[0].text === "Button") {
return new Ast("__button__", [new Ast(name, [], [], "ButtonLiteral")])

} else if (object[0].text === "Color") {
return new Ast("__color__", [new Ast(name, [], [], "ColorLiteral")])


} else if (builtInEnumNameToAstInfo[object[0].text]) {
const astInfo = builtInEnumNameToAstInfo[object[0].text];
return new Ast(astInfo.name, [new Ast(name, [], [], astInfo.type)]);
//Check the pseudo-enum "math"
} else if (object[0].text === "Math") {
if (name === "PI") {
Expand Down
6 changes: 3 additions & 3 deletions VS Code Extension/overpy.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/data/customGameSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3850,6 +3850,7 @@ const customGameSettingsSchema =
"orisa",
"pharah",
"reinhardt",
"roadhog",
"sigma",
"sojourn",
"soldier",
Expand Down

0 comments on commit 517f665

Please sign in to comment.