diff --git a/modern/src/debugger/index.js b/modern/src/debugger/index.js index 62f2f551..2280da75 100644 --- a/modern/src/debugger/index.js +++ b/modern/src/debugger/index.js @@ -130,7 +130,7 @@ function Debugger({ maki }) { React.useEffect(() => { run({ runtime, data: maki, system, debugHandler: setGen }); - }, []); + }, [maki, system]); const nextValue = React.useCallback( value => { @@ -160,12 +160,12 @@ function Debugger({ maki }) { // When we unpause, we should resume React.useEffect(() => { if (!paused) next(); - }, [paused]); + }, [next, paused]); // When we get a new generator, immediatly take the first step. React.useEffect(() => { next(); - }, [gen]); + }, [gen, next]); React.useEffect(() => { function handler(e) { diff --git a/modern/src/initialize.js b/modern/src/initialize.js index d1a66a5f..fb1bf08e 100644 --- a/modern/src/initialize.js +++ b/modern/src/initialize.js @@ -20,7 +20,7 @@ import Status from "./runtime/Status"; async function loadImage(imgUrl) { return await new Promise(resolve => { const img = new Image(); - img.addEventListener("load", function() { + img.addEventListener("load", () => { resolve(img); }); img.src = imgUrl; diff --git a/modern/src/maki-interpreter/parser.js b/modern/src/maki-interpreter/parser.js index ce4b8f8a..522c3590 100644 --- a/modern/src/maki-interpreter/parser.js +++ b/modern/src/maki-interpreter/parser.js @@ -80,7 +80,7 @@ class MakiFile { let ret = ""; const end = Math.min(this._arr.length, this._i + length); - for (var i = this._i; i < end; ++i) { + for (let i = this._i; i < end; ++i) { ret += String.fromCharCode(this._arr[i]); } this._i += length; diff --git a/modern/src/runtime/Container.js b/modern/src/runtime/Container.js index 5d35f08a..dc8918d9 100644 --- a/modern/src/runtime/Container.js +++ b/modern/src/runtime/Container.js @@ -11,6 +11,7 @@ class Container extends GuiObject { getclassname() { return "Container"; } + getlayout(id) { return findDescendantByTypeAndId(this, "layout", id); } diff --git a/modern/src/runtime/Group.js b/modern/src/runtime/Group.js index fcfc3b2f..c1c29cdb 100644 --- a/modern/src/runtime/Group.js +++ b/modern/src/runtime/Group.js @@ -10,6 +10,7 @@ class Group extends GuiObject { getclassname() { return "Group"; } + getobject(id) { // Not sure this is correct, but it is my understanding this is just an alias return this.findobject(id); diff --git a/modern/src/runtime/GuiObject.js b/modern/src/runtime/GuiObject.js index 123518f0..c0fdef5e 100644 --- a/modern/src/runtime/GuiObject.js +++ b/modern/src/runtime/GuiObject.js @@ -7,6 +7,7 @@ class GuiObject extends MakiObject { this.visible = true; } + /** * getclassname() * @@ -16,22 +17,27 @@ class GuiObject extends MakiObject { getclassname() { return "GuiObject"; } + findobject(id) { return findDescendantByTypeAndId(this, null, id); } + getobject(id) { // Not sure this is correct, but it is my understanding this is just an alias return this.findobject(id); } + init(newRoot) { this.parent = newRoot; newRoot.js_addChild(this); return this; } + setxmlparam(param, value) { this.xmlNode.attributes[param] = value; return value; } + getxmlparam(param) { const attributes = this.xmlNode.attributes; if (attributes !== undefined && attributes.hasOwnProperty(param)) { @@ -39,6 +45,7 @@ class GuiObject extends MakiObject { } return null; } + getparent() { return this.parent; } diff --git a/modern/src/runtime/Layout.js b/modern/src/runtime/Layout.js index 85b16908..adbb8028 100644 --- a/modern/src/runtime/Layout.js +++ b/modern/src/runtime/Layout.js @@ -11,6 +11,7 @@ class Layout extends GuiObject { getclassname() { return "Layout"; } + getcontainer() { return findParentNodeOfType(this, ["container"]); } diff --git a/modern/src/runtime/PopupMenu.js b/modern/src/runtime/PopupMenu.js index a3f4770d..1844618d 100644 --- a/modern/src/runtime/PopupMenu.js +++ b/modern/src/runtime/PopupMenu.js @@ -11,15 +11,19 @@ class PopupMenu extends GuiObject { getclassname() { return "PopupMenu"; } + addcommand(txt, id, checked, disabled) { unimplementedWarning("addcommand"); } + addseparator() { unimplementedWarning("addseparator"); } + checkcommand(id, check) { unimplementedWarning("checkcommand"); } + popatmouse() { unimplementedWarning("popatmouse"); } diff --git a/modern/src/runtime/System.js b/modern/src/runtime/System.js index 0a3188be..aaad5862 100644 --- a/modern/src/runtime/System.js +++ b/modern/src/runtime/System.js @@ -30,49 +30,62 @@ class System extends MakiObject { getscriptgroup() { return this.scriptGroup; } + getcontainer(id) { return findDescendantByTypeAndId(this.root, "container", id); } + getruntimeversion() { return "5.666"; } + gettoken(str, separator, tokennum) { unimplementedWarning("gettoken"); return "Some Token String"; } + getparam() { unimplementedWarning("getparam"); return "Some String"; } + messagebox(message, msgtitle, flag, notanymoreId) { console.log({ message, msgtitle, flag, notanymoreId }); } + integertostring(value) { return value.toString(); } + getprivateint(section, item, defvalue) { unimplementedWarning("getprivateint"); return defvalue; } + setprivateint(section, item, defvalue) { unimplementedWarning("setprivateint"); } + getleftvumeter() { unimplementedWarning("getleftvumeter"); return 0.5; } + getrightvumeter() { unimplementedWarning("getrightvumeter"); return 0.5; } + getvolume() { unimplementedWarning("getvolume"); return 1; } + getplayitemlength() { unimplementedWarning("getplayitemlength"); return 100000; } + seekto(pos) { unimplementedWarning("seekto"); } diff --git a/modern/src/utils.js b/modern/src/utils.js index ae81fd60..3a641357 100644 --- a/modern/src/utils.js +++ b/modern/src/utils.js @@ -45,9 +45,8 @@ export async function asyncFlatMap(arr, mapper) { const childPromises = mapped.map(async item => { if (Array.isArray(item)) { return await asyncFlatMap(item, mapper); - } else { - return item; } + return item; }); return flatten(await Promise.all(childPromises)); } @@ -152,7 +151,7 @@ function findDirectDescendantById(node, id) { function findInLexicalScope(node, pred) { let currentNode = node; while (currentNode.parent) { - let parent = currentNode.parent; + const parent = currentNode.parent; const children = parent.children; for (let i = 0; i < children.length; i++) { const child = children[i];