Skip to content

Commit

Permalink
Implement wait
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwarren committed Nov 22, 2015
1 parent 66da07f commit bdac532
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 26 deletions.
14 changes: 10 additions & 4 deletions Prototypes/jsrunner/asl4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Player {

}
DoWait() {

quest.ui.beginWait();
}
DoPause(ms: number) {

Expand Down Expand Up @@ -497,6 +497,7 @@ class LegacyGame {
_commandOverrideModeOn: boolean = false;
_commandOverrideResolve: Callback;
_commandOverrideVariable: string;
_waitResolve: Callback;
_afterTurnScript: string;
_beforeTurnScript: string;
_outPutOn: boolean = false;
Expand Down Expand Up @@ -4683,7 +4684,7 @@ class LegacyGame {
await this.Print("|nPress a key to continue...", ctx);
}
}
this.DoWait();
await this.DoWait();
}
InitFileData(fileData: string): void {
this._fileData = fileData;
Expand Down Expand Up @@ -10790,8 +10791,13 @@ class LegacyGame {
quest.print(output.text, !output.nobr);
}

DoWait() {
// TODO
async DoWait(): Promise<void> {
this._player.DoWait();
return new Promise<void>(resolve => this._waitResolve = resolve);
}

EndWait() {
this._waitResolve();
}

Pause(duration: number) {
Expand Down
5 changes: 2 additions & 3 deletions Prototypes/jsrunner/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@
var onFailure = function () {
console.log("fail");
};
quest.sendCommand = function (command, elapsedTime) {
game.SendCommand(command, elapsedTime);
}
quest.sendCommand = game.SendCommand.bind(game);
quest.endWait = game.EndWait.bind(game);
game.Initialise(onSuccess, onFailure);
}
else {
Expand Down
6 changes: 6 additions & 0 deletions Prototypes/jsrunner/test.asl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ define game <>
enter <input2>
msg <First #input#, now #input2#.>
}
command <test2> {
wait <Press a key please...>
msg <Done!>
wait <Now press a key again...>
msg <Finished!>
}
verb <read> msg <You can't read that.>
end define

Expand Down
1 change: 1 addition & 0 deletions Prototypes/jsrunner/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@
quest.ui.locationUpdated = updateLocation;
quest.ui.updateList = updateList;
quest.ui.updateCompass = updateCompassDirections;
quest.ui.beginWait = beginWait;
})();
30 changes: 16 additions & 14 deletions Prototypes/jsrunner/ui/playercore.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,16 @@ $(function () {
ui_init();
updateStatusVisibility();

var overrideContextMenuClick = function(e) {
if (!e) e = window.event;
if ((e.type && e.type == "contextmenu") || (e.button && e.button == 2) || (e.which && e.which == 3)) {
return false;
}
return true;
};
if (document.layers) document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = overrideContextMenuClick;
document.oncontextmenu = overrideContextMenuClick;
// var overrideContextMenuClick = function(e) {
// if (!e) e = window.event;
// if ((e.type && e.type == "contextmenu") || (e.button && e.button == 2) || (e.which && e.which == 3)) {
// return false;
// }
// return true;
// };
// if (document.layers) document.captureEvents(Event.MOUSEDOWN);
// document.onmousedown = overrideContextMenuClick;
// document.oncontextmenu = overrideContextMenuClick;

$("#txtCommand").focus();
});
Expand Down Expand Up @@ -558,10 +558,12 @@ function updateVerbButtons(selectedItem, verbsArray, idprefix) {
}

function beginWait() {
_waitMode = true;
$("#txtCommand").hide();
$("#endWaitLink").show();
markScrollPosition();
setTimeout(function () {
_waitMode = true;
$("#txtCommand").hide();
$("#endWaitLink").show();
markScrollPosition();
}, 1);
}

function endWait() {
Expand Down
9 changes: 4 additions & 5 deletions Prototypes/jsrunner/ui/playerweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ function ui_init() {
}

function sendEndWait() {
window.setTimeout(function () {
$("#fldUIMsg").val("endwait");
$("#cmdSubmit").click();
}, 100);
waitEnded();
setTimeout(function () {
quest.endWait();
waitEnded();
}, 1);
}

function sessionTimeout() {
Expand Down

0 comments on commit bdac532

Please sign in to comment.