From cd0ed8c62a7f055ada29a0590dde8b9e543bb705 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Wed, 12 Nov 2014 16:50:26 -0800 Subject: [PATCH] Update "Lock Pointer" button status --- README.md | 3 ++- modules/pcjs/lib/cpu.js | 9 ++++++--- modules/pcjs/lib/video.js | 5 +++-- modules/pcjs/lib/x86cpu.js | 5 ++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3dafc5533..38d1c935c 100644 --- a/README.md +++ b/README.md @@ -290,7 +290,8 @@ where PCjs could run amok and destroy the planet. Other parameters that can be passed via the URL: -- *autostart*: set it to "false" to prevent all machines on the current page from automatically starting +- *autostart*: set it to "true" to allow all machines to start normally, "false" to prevent all machines from starting, +or "no" to prevent all machines from starting *unless* they have no "Run" button. For example: diff --git a/modules/pcjs/lib/cpu.js b/modules/pcjs/lib/cpu.js index 0b1f8ae61..1b512afec 100644 --- a/modules/pcjs/lib/cpu.js +++ b/modules/pcjs/lib/cpu.js @@ -764,7 +764,8 @@ CPU.prototype.setSpeed = function(nMultiplier, fOnClick) if (this.aCounts.mhzTarget != mhz) { this.aCounts.mhzTarget = mhz; var sSpeed = this.getSpeedTarget(); - if (this.bindings["setSpeed"]) this.bindings["setSpeed"].innerHTML = sSpeed; + var controlSpeed = this.bindings["setSpeed"]; + if (controlSpeed) controlSpeed.innerHTML = sSpeed; this.println("target speed: " + sSpeed); } if (fOnClick) this.setFocus(); @@ -947,7 +948,8 @@ CPU.prototype.runCPU = function(fOnClick) if (this.cmp) this.cmp.start(this.aCounts.msStartRun, this.getCycles()); this.aFlags.fRunning = true; if (this.chipset) this.chipset.setSpeaker(); - if (this.bindings["run"]) this.bindings["run"].innerHTML = "Halt"; + var controlRun = this.bindings["run"]; + if (controlRun) controlRun.innerHTML = "Halt"; if (fOnClick) this.setFocus(); } /* @@ -1065,7 +1067,8 @@ CPU.prototype.haltCPU = function(fComplete) if (this.aFlags.fRunning) { this.aFlags.fRunning = false; if (this.chipset) this.chipset.setSpeaker(); - if (this.bindings["run"]) this.bindings["run"].innerHTML = "Run"; + var controlRun = this.bindings["run"]; + if (controlRun) controlRun.innerHTML = "Run"; } this.aFlags.fComplete = fComplete; }; diff --git a/modules/pcjs/lib/video.js b/modules/pcjs/lib/video.js index 4f34c30f0..0c388ce34 100644 --- a/modules/pcjs/lib/video.js +++ b/modules/pcjs/lib/video.js @@ -2012,6 +2012,7 @@ Video.prototype.setBinding = function(sHTMLClass, sHTMLType, sBinding, control) case "lockPointer": this.bindings[sBinding] = control; + this.sLockMessage = control.innerHTML; if (this.canvasScreen && this.canvasScreen.lockPointer) { control.onclick = function onClickLockPointer() { if (DEBUG) video.messageDebugger("lockPointer()"); @@ -2065,8 +2066,6 @@ Video.prototype.getCanvas = function(mouse) /** * lockPointer() * - * TODO: Consider relabeling the "Lock Pointer" button for the duration of the lock. - * * @this {Video} * @param {boolean} fLock * @return {boolean} true if request successful, false if not (eg, failed OR not supported) @@ -2118,6 +2117,8 @@ Video.prototype.notifyPointerLocked = function(fLocked) this.mouse.notifyPointerLocked(fLocked); if (this.kbd) this.kbd.notifyEscape(fLocked); } + var control = this.bindings["lockPointer"]; + if (control) control.innerHTML = (fLocked? "Press Esc to Unlock Pointer" : this.sLockMessage); }; /** diff --git a/modules/pcjs/lib/x86cpu.js b/modules/pcjs/lib/x86cpu.js index 60a83f823..0fd5f6eb5 100644 --- a/modules/pcjs/lib/x86cpu.js +++ b/modules/pcjs/lib/x86cpu.js @@ -2399,9 +2399,8 @@ X86CPU.prototype.displayStatus = function() this.displayReg("I", (regPS & X86.PS.IF)? 1 : 0, 1); this.displayReg("D", (regPS & X86.PS.DF)? 1 : 0, 1); this.displayReg("O", (regPS & X86.PS.OF)? 1 : 0, 1); - if (this.bindings["speed"]) { - this.bindings["speed"].innerHTML = this.getSpeedCurrent(); - } + var controlSpeed = this.bindings["speed"]; + if (controlSpeed) controlSpeed.innerHTML = this.getSpeedCurrent(); }; /**