From 88ead9755a44c04b1bfff2da198863bb4a03a4bf Mon Sep 17 00:00:00 2001 From: thatscar Date: Fri, 28 Sep 2018 17:35:45 +0300 Subject: [PATCH] Prelude and `textMode` Now respects prelude content and doesn't work without respective entries. Can click stuff on main menu and messages. --- js/compiler.js | 78 +++++++++++++++------------- js/inputoutput.js | 127 ++++++++++++++++++++++++++++------------------ js/parser.js | 2 +- 3 files changed, 121 insertions(+), 86 deletions(-) diff --git a/js/compiler.js b/js/compiler.js index 874a34597..f54a05639 100644 --- a/js/compiler.js +++ b/js/compiler.js @@ -383,53 +383,59 @@ function generateExtraMembers(state) { state.backgroundlayer=backgroundlayer; var lmbID; - if (state.objects.lmb===undefined) { - if ('lmb' in state.synonymsDict) { - var n = state.synonymsDict['lmb']; - var o = state.objects[n]; - lmbID = o.id; + if (state.metadata.includes("mouse_left")) { + if (state.objects.lmb===undefined) { + if ('lmb' in state.synonymsDict) { + var n = state.synonymsDict['lmb']; + var o = state.objects[n]; + lmbID = o.id; + } else { + var o=state.objects[state.idDict[1]]; + lmbID=o.id; + logError("lmb object/alias has to be defined"); + } } else { - var o=state.objects[state.idDict[1]]; - lmbID=o.id; - logError("lmb object/alias has to be defined"); + lmbID = state.objects.lmb.id; } - } else { - lmbID = state.objects.lmb.id; + state.lmbID=lmbID; } - state.lmbID=lmbID; var rmbID; - if (state.objects.rmb===undefined) { - if ('rmb' in state.synonymsDict) { - var n = state.synonymsDict['rmb']; - var o = state.objects[n]; - rmbID = o.id; - } else { - var o=state.objects[state.idDict[1]]; - rmbID=o.id; - //logError("rmb object/alias has to be defined"); // NOT IMPLEMENTED + if (state.metadata.includes("mouse_right")) { + if (state.objects.rmb===undefined) { + if ('rmb' in state.synonymsDict) { + var n = state.synonymsDict['rmb']; + var o = state.objects[n]; + rmbID = o.id; + } else { + var o=state.objects[state.idDict[1]]; + rmbID=o.id; + logError("rmb object/alias has to be defined"); + } + } else { + rmbID = state.objects.rmb.id; } - } else { - rmbID = state.objects.rmb.id; + state.rmbID=rmbID; } - state.rmbID=rmbID; var dragID; - if (state.objects.drag===undefined) { - if ('drag' in state.synonymsDict) { - var n = state.synonymsDict['drag']; - var o = state.objects[n]; - dragID = o.id; + if (state.metadata.includes("mouse_drag")) { + if (state.objects.drag===undefined) { + if ('drag' in state.synonymsDict) { + var n = state.synonymsDict['drag']; + var o = state.objects[n]; + dragID = o.id; + } else { + var o=state.objects[state.idDict[1]]; + dragID=o.id; + logError("drag object/alias has to be defined"); + } } else { - var o=state.objects[state.idDict[1]]; - dragID=o.id; - logError("drag object/alias has to be defined"); + dragID = state.objects.drag.id; } - } else { - dragID = state.objects.drag.id; + state.dragID=dragID; } - state.dragID=dragID; } Level.prototype.calcBackgroundMask = function(state) { @@ -1893,7 +1899,9 @@ function getMaskFromName(state,name) { objectMask.ibitset(o.id); } - if (objectMask.iszero()) { + if (!state.metadata.includes("nokeyboard") && objectMask.iszero()) { + consolePrint("yes " + (state.metadata.includes("nokeyboard")), true); + consolePrint(state.metadata, true); logErrorNoLine("error, didn't find any object called player, either in the objects section, or the legends section. there must be a player!"); } return objectMask; diff --git a/js/inputoutput.js b/js/inputoutput.js index 13f10e431..03f95fc8e 100644 --- a/js/inputoutput.js +++ b/js/inputoutput.js @@ -325,36 +325,62 @@ function levelEditorRightClick(event,click) { var lastCoord; function mouseLeft(event,click,id) { - /*if (false) { - consolePrint("no mouse, textmode",true); - console.log("no mouse, textmode"); - } else */{ - if (mouseCoordX>-1&&mouseCoordY>-1&&mouseCoordX-1&&mouseCoordY>-1&&mouseCoordX=0) { + 'mouse_left','mouse_drag','mouse_right','mouse_up','nokeyboard'].indexOf(token)>=0) { state.metadata.push(token); state.metadata.push("true"); state.tokenIndex=-1;