diff --git a/experiments/modern/src/runtime/Button.js b/experiments/modern/src/runtime/Button.js index a7a180f5..54841fa5 100644 --- a/experiments/modern/src/runtime/Button.js +++ b/experiments/modern/src/runtime/Button.js @@ -7,7 +7,7 @@ class Button extends GuiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassname() { return "Button"; } } diff --git a/experiments/modern/src/runtime/Container.js b/experiments/modern/src/runtime/Container.js index 6acef794..b6a6c250 100644 --- a/experiments/modern/src/runtime/Container.js +++ b/experiments/modern/src/runtime/Container.js @@ -8,7 +8,7 @@ class Container extends GuiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "Container"; } getlayout(id) { diff --git a/experiments/modern/src/runtime/Group.js b/experiments/modern/src/runtime/Group.js index 8249a0bd..081c4070 100644 --- a/experiments/modern/src/runtime/Group.js +++ b/experiments/modern/src/runtime/Group.js @@ -7,7 +7,7 @@ class Group extends GuiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "Group"; } getobject(id) { diff --git a/experiments/modern/src/runtime/GuiObject.js b/experiments/modern/src/runtime/GuiObject.js index f66fb228..d73d613b 100644 --- a/experiments/modern/src/runtime/GuiObject.js +++ b/experiments/modern/src/runtime/GuiObject.js @@ -13,7 +13,7 @@ class GuiObject extends MakiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "GuiObject"; } findobject(id) { @@ -52,17 +52,17 @@ class GuiObject extends MakiObject { } gettop() { - unimplementedWarning('gettop'); + unimplementedWarning("gettop"); return 5; } getheight() { - unimplementedWarning('getheight'); + unimplementedWarning("getheight"); return 100; } getwidth() { - unimplementedWarning('getwidth'); + unimplementedWarning("getwidth"); return 100; } diff --git a/experiments/modern/src/runtime/JsElements.js b/experiments/modern/src/runtime/JsElements.js index d771eaa0..516858c4 100644 --- a/experiments/modern/src/runtime/JsElements.js +++ b/experiments/modern/src/runtime/JsElements.js @@ -7,7 +7,7 @@ class JsElements extends MakiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassname() { return "Elements"; } } diff --git a/experiments/modern/src/runtime/JsGammaSet.js b/experiments/modern/src/runtime/JsGammaSet.js index 411c8302..e32948d6 100644 --- a/experiments/modern/src/runtime/JsGammaSet.js +++ b/experiments/modern/src/runtime/JsGammaSet.js @@ -7,7 +7,7 @@ class JsGammaSet extends MakiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "GammaSet"; } } diff --git a/experiments/modern/src/runtime/JsGroupDef.js b/experiments/modern/src/runtime/JsGroupDef.js index 397483c9..db0c9a4f 100644 --- a/experiments/modern/src/runtime/JsGroupDef.js +++ b/experiments/modern/src/runtime/JsGroupDef.js @@ -7,7 +7,7 @@ class JsGroupDef extends MakiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassname() { return "GroupDef"; } } diff --git a/experiments/modern/src/runtime/Layer.js b/experiments/modern/src/runtime/Layer.js index 3e941a59..77e563d8 100644 --- a/experiments/modern/src/runtime/Layer.js +++ b/experiments/modern/src/runtime/Layer.js @@ -7,7 +7,7 @@ class Layer extends GuiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "Layer"; } } diff --git a/experiments/modern/src/runtime/Layout.js b/experiments/modern/src/runtime/Layout.js index af29b29a..b9986d3f 100644 --- a/experiments/modern/src/runtime/Layout.js +++ b/experiments/modern/src/runtime/Layout.js @@ -8,11 +8,11 @@ class Layout extends GuiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "Layout"; } getcontainer() { - return findParentNodeOfType(this, ["container"]);; + return findParentNodeOfType(this, ["container"]); } resize(x, y, w, h) { diff --git a/experiments/modern/src/runtime/List.js b/experiments/modern/src/runtime/List.js index 3b39b64e..b8d380b9 100644 --- a/experiments/modern/src/runtime/List.js +++ b/experiments/modern/src/runtime/List.js @@ -7,7 +7,7 @@ class List extends GuiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "List"; } } diff --git a/experiments/modern/src/runtime/MakiObject.js b/experiments/modern/src/runtime/MakiObject.js index 66eb4b75..7a3f09ea 100644 --- a/experiments/modern/src/runtime/MakiObject.js +++ b/experiments/modern/src/runtime/MakiObject.js @@ -19,8 +19,8 @@ class MakiObject { }, // ugly but works for now name: this.constructor.name.toLowerCase(), - type: 'element' - } + type: "element", + }; } } @@ -68,7 +68,7 @@ class MakiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "Object"; } diff --git a/experiments/modern/src/runtime/PopupMenu.js b/experiments/modern/src/runtime/PopupMenu.js index c6696f32..ebd80f82 100644 --- a/experiments/modern/src/runtime/PopupMenu.js +++ b/experiments/modern/src/runtime/PopupMenu.js @@ -8,20 +8,20 @@ class PopupMenu extends GuiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "PopupMenu"; } addcommand(txt, id, checked, disabled) { - unimplementedWarning('addcommand'); + unimplementedWarning("addcommand"); } addseparator() { - unimplementedWarning('addseparator'); + unimplementedWarning("addseparator"); } checkcommand(id, check) { - unimplementedWarning('checkcommand'); + unimplementedWarning("checkcommand"); } popatmouse() { - unimplementedWarning('popatmouse'); + unimplementedWarning("popatmouse"); } } diff --git a/experiments/modern/src/runtime/Slider.js b/experiments/modern/src/runtime/Slider.js index 44bba6ef..24ae01f7 100644 --- a/experiments/modern/src/runtime/Slider.js +++ b/experiments/modern/src/runtime/Slider.js @@ -7,7 +7,7 @@ class Slider extends GuiObject { * Returns the class name for the object. * @ret The class name. */ - static getClassName() { + getclassaname() { return "Slider"; } } diff --git a/experiments/modern/src/runtime/Status.js b/experiments/modern/src/runtime/Status.js index 4aa2b9e1..110b9721 100644 --- a/experiments/modern/src/runtime/Status.js +++ b/experiments/modern/src/runtime/Status.js @@ -7,7 +7,7 @@ class Status extends GuiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "Status"; } } diff --git a/experiments/modern/src/runtime/System.js b/experiments/modern/src/runtime/System.js index c4532d74..4b4c8c3f 100644 --- a/experiments/modern/src/runtime/System.js +++ b/experiments/modern/src/runtime/System.js @@ -8,7 +8,7 @@ class System extends MakiObject { this.scriptGroup = scriptGroup; this.root = scriptGroup; - while(this.root.parent) { + while (this.root.parent) { this.root = this.root.parent; } } @@ -19,7 +19,7 @@ class System extends MakiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "System"; } @@ -37,11 +37,11 @@ class System extends MakiObject { return "5.666"; } gettoken(str, separator, tokennum) { - unimplementedWarning('gettoken'); + unimplementedWarning("gettoken"); return "Some Token String"; } getparam() { - unimplementedWarning('getparam'); + unimplementedWarning("getparam"); return "Some String"; } messagebox(message, msgtitle, flag, notanymoreId) { @@ -51,22 +51,22 @@ class System extends MakiObject { return value.toString(); } getprivateint(section, item, defvalue) { - unimplementedWarning('getprivateint'); + unimplementedWarning("getprivateint"); return defvalue; } setprivateint(section, item, defvalue) { - unimplementedWarning('setprivateint'); + unimplementedWarning("setprivateint"); } getleftvumeter() { - unimplementedWarning('getleftvumeter'); + unimplementedWarning("getleftvumeter"); return 0.5; } getrightvumeter() { - unimplementedWarning('getrightvumeter'); + unimplementedWarning("getrightvumeter"); return 0.5; } getvolume() { - unimplementedWarning('getvolume'); + unimplementedWarning("getvolume"); return 1; } } diff --git a/experiments/modern/src/runtime/Text.js b/experiments/modern/src/runtime/Text.js index 826381b2..8c87a58e 100644 --- a/experiments/modern/src/runtime/Text.js +++ b/experiments/modern/src/runtime/Text.js @@ -7,7 +7,7 @@ class Text extends GuiObject { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "Text"; } } diff --git a/experiments/modern/src/runtime/ToggleButton.js b/experiments/modern/src/runtime/ToggleButton.js index c4e3ade6..3bb62faa 100644 --- a/experiments/modern/src/runtime/ToggleButton.js +++ b/experiments/modern/src/runtime/ToggleButton.js @@ -7,7 +7,7 @@ class ToggleButton extends Button { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "ToggleButton"; } } diff --git a/experiments/modern/src/runtime/WinampAbstractionLayer.js b/experiments/modern/src/runtime/WinampAbstractionLayer.js index 8ac71c6e..3494ce57 100644 --- a/experiments/modern/src/runtime/WinampAbstractionLayer.js +++ b/experiments/modern/src/runtime/WinampAbstractionLayer.js @@ -8,7 +8,7 @@ class WinampAbstractionLayer extends Group { * Returns the class name for the object. * @ret The class name. */ - static getclassname() { + getclassaname() { return "WinampAbstractionLayer"; } } diff --git a/experiments/modern/src/utils.js b/experiments/modern/src/utils.js index 668f12a3..ae81fd60 100644 --- a/experiments/modern/src/utils.js +++ b/experiments/modern/src/utils.js @@ -1,6 +1,4 @@ import { xml2js } from "xml-js"; -const JsElements = require("./runtime/JsElements"); -const JsGroupDef = require("./runtime/JsGroupDef"); export function getCaseInsensitveFile(zip, filename) { // TODO: Escape `file` for rejex characters @@ -108,8 +106,10 @@ export function findParentNodeOfType(node, type) { let n = node; while (n.parent) { n = n.parent; - if ((!Array.isArray(type) && n.xmlNode.name === type) || - (Array.isArray(type) && type.includes(n.xmlNode.name))) { + if ( + (!Array.isArray(type) && n.xmlNode.name === type) || + (Array.isArray(type) && type.includes(n.xmlNode.name)) + ) { return n; } } @@ -121,12 +121,14 @@ export function findDescendantByTypeAndId(node, type, id) { } const idLC = id.toLowerCase(); - for(let i = 0; i < node.children.length; i++) { + for (let i = 0; i < node.children.length; i++) { const child = node.children[i]; - if ((!type || child.xmlNode.name === type) && - (child.xmlNode.attributes !== undefined && - child.xmlNode.attributes.id !== undefined && - child.xmlNode.attributes.id.toLowerCase() === idLC)) { + if ( + (!type || child.xmlNode.name === type) && + (child.xmlNode.attributes !== undefined && + child.xmlNode.attributes.id !== undefined && + child.xmlNode.attributes.id.toLowerCase() === idLC) + ) { return child; } } @@ -173,7 +175,7 @@ function findInLexicalScope(node, pred) { // return the first child of an that matches id export function findElementById(node, id) { return findInLexicalScope(node, child => { - if (child instanceof JsElements) { + if (child.getclassname && child.getclassname() === "Elements") { const element = findDirectDescendantById(child, id); if (element) { return element; @@ -185,7 +187,11 @@ export function findElementById(node, id) { // Search up the tree for a node that is in node's lexical scope and matches id. export function findGroupDefById(node, id) { return findInLexicalScope(node, child => { - if (child instanceof JsGroupDef && child.xmlNode.attributes.id === id) { + if ( + child.getclassname && + child.getclassname() === "GroupDef" && + child.xmlNode.attributes.id === id + ) { return child; } });