From e6de381ec2c317ed94e3f7d0e4d2f876a71c7dd5 Mon Sep 17 00:00:00 2001 From: vivid Date: Tue, 12 Jul 2016 10:55:35 +0900 Subject: [PATCH] timer & button bug project timer pause when project paused. run button show & hide bug --- dist/entry.js | 29 +++++++++++------------------ dist/entry.min.js | 10 ++++++---- src/engine.js | 42 +++++++++++++++++++++++++++++++----------- 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/dist/entry.js b/dist/entry.js index 600137447f..d4391c85d9 100644 --- a/dist/entry.js +++ b/dist/entry.js @@ -7129,26 +7129,14 @@ Entry.Engine.prototype.run = function() { this.isState("run") ? this.toggleStop() : (this.isState("stop") || this.isState("pause")) && this.toggleRun(); }; Entry.Engine.prototype.toggleRun = function() { - Entry.addActivity("run"); - "stop" == this.state && (Entry.container.mapEntity(function(b) { + "pause" === this.state ? this.togglePause() : (Entry.addActivity("run"), "stop" == this.state && (Entry.container.mapEntity(function(b) { b.takeSnapshot(); }), Entry.variableContainer.mapVariable(function(b) { b.takeSnapshot(); }), Entry.variableContainer.mapList(function(b) { b.takeSnapshot(); - }), this.projectTimer.takeSnapshot(), Entry.container.inputValue.takeSnapshot(), Entry.container.takeSequenceSnapshot(), Entry.scene.takeStartSceneSnapshot(), this.state = "run", this.fireEvent("start")); - this.state = "run"; - "mobile" == Entry.type && this.view_.addClass("entryEngineBlueWorkspace"); - this.pauseButton.innerHTML = Lang.Workspace.pause; - this.runButton.addClass("run"); - this.runButton.addClass("entryRemove"); - this.stopButton.removeClass("entryRemove"); - this.pauseButton && this.pauseButton.removeClass("entryRemove"); - this.runButton2 && this.runButton2.addClass("entryRemove"); - this.stopButton2 && this.stopButton2.removeClass("entryRemove"); - this.isUpdating || (Entry.engine.update(), Entry.engine.isUpdating = !0); - Entry.stage.selectObject(); - Entry.dispatchEvent("run"); + }), this.projectTimer.takeSnapshot(), Entry.container.inputValue.takeSnapshot(), Entry.container.takeSequenceSnapshot(), Entry.scene.takeStartSceneSnapshot(), this.state = "run", this.fireEvent("start")), this.state = "run", "mobile" == Entry.type && this.view_.addClass("entryEngineBlueWorkspace"), this.pauseButton.innerHTML = Lang.Workspace.pause, this.runButton.addClass("run"), this.runButton.addClass("entryRemove"), this.stopButton.removeClass("entryRemove"), this.pauseButton && this.pauseButton.removeClass("entryRemove"), + this.runButton2 && this.runButton2.addClass("entryRemove"), this.stopButton2 && this.stopButton2.removeClass("entryRemove"), this.isUpdating || (Entry.engine.update(), Entry.engine.isUpdating = !0), Entry.stage.selectObject(), Entry.dispatchEvent("run")); }; Entry.Engine.prototype.toggleStop = function() { Entry.addActivity("stop"); @@ -7187,7 +7175,9 @@ Entry.Engine.prototype.toggleStop = function() { Entry.stage.hideInputField(); }; Entry.Engine.prototype.togglePause = function() { - "pause" == this.state ? (this.state = "run", this.pauseButton.innerHTML = Lang.Workspace.pause) : (this.state = "pause", this.pauseButton.innerHTML = Lang.Workspace.restart, this.runButton.removeClass("entryRemove"), this.stopButton.removeClass("entryRemove")); + var b = Entry.engine.projectTimer; + "pause" == this.state ? (b.pausedTime += (new Date).getTime() - b.pauseStart, b.isPaused ? b.pauseStart = (new Date).getTime() : delete b.pauseStart, this.state = "run", this.pauseButton.innerHTML = Lang.Workspace.pause, this.runButton.addClass("entryRemove"), this.runButton2 && this.runButton2.addClass("entryRemove")) : (this.state = "pause", b.isPaused && (b.pausedTime += (new Date).getTime() - b.pauseStart), b.pauseStart = (new Date).getTime(), this.pauseButton.innerHTML = Lang.Workspace.restart, + this.runButton.removeClass("entryRemove"), this.stopButton.removeClass("entryRemove"), this.runButton2 && this.runButton2.removeClass("entryRemove")); }; Entry.Engine.prototype.fireEvent = function(b) { "run" == this.state && Entry.container.mapEntityIncludeCloneOnScene(this.raiseEvent, b); @@ -7265,8 +7255,11 @@ Entry.Engine.prototype.stopProjectTimer = function() { b && (this.updateProjectTimer(0), b.isPaused = !1, b.isInit = !1, b.pausedTime = 0, clearInterval(b.tick)); }; Entry.Engine.prototype.updateProjectTimer = function(b) { - var a = Entry.engine.projectTimer, c = (new Date).getTime(); - a && ("undefined" == typeof b ? a.isPaused || a.setValue((c - a.start - a.pausedTime) / 1E3) : (a.setValue(b), a.pausedTime = 0, a.start = c)); + var a = Entry.engine, c = a.projectTimer; + if (c) { + var d = (new Date).getTime(); + "undefined" == typeof b ? c.isPaused || a.isState("pause") || c.setValue((d - c.start - c.pausedTime) / 1E3) : (c.setValue(b), c.pausedTime = 0, c.start = d); + } }; Entry.EntityObject = function(b) { this.parent = b; diff --git a/dist/entry.min.js b/dist/entry.min.js index 11fdc33dc6..8cb2b6f103 100644 --- a/dist/entry.min.js +++ b/dist/entry.min.js @@ -748,11 +748,13 @@ Entry.Engine.prototype.toggleSpeedPanel=function(){if(this.speedPanelOn)this.spe Entry.Engine.prototype.setSpeedMeter=function(b){var a=this.speeds.indexOf(b);0>a||(a=Math.min(4,a),a=Math.max(0,a),this.speedPanelOn&&(this.speedHandle_.style.left=(Entry.interfaceState.canvasWidth-80)/10*(2*a+1)+80-9+"px"),Entry.FPS!=b&&(clearInterval(this.ticker),this.ticker=setInterval(this.update,Math.floor(1E3/b)),Entry.FPS=b))};Entry.Engine.prototype.start=function(b){createjs.Ticker.setFPS(Entry.FPS);this.ticker=setInterval(this.update,Math.floor(1E3/Entry.FPS))}; Entry.Engine.prototype.stop=function(){clearInterval(this.ticker);this.ticker=null};Entry.Engine.prototype.update=function(){Entry.engine.isState("run")&&(Entry.engine.computeObjects(),Entry.hw.update())};Entry.Engine.prototype.computeObjects=function(){Entry.container.mapObjectOnScene(this.computeFunction)};Entry.Engine.prototype.computeFunction=function(b){b.script.tick()}; Entry.Engine.computeThread=function(b,a){Entry.engine.isContinue=!0;for(var c=!1;a&&Entry.engine.isContinue&&!c;){Entry.engine.isContinue=!a.isRepeat;var d=a.run(),c=d&&d===a;a=d}return a};Entry.Engine.prototype.isState=function(b){return-1=a&&Entry.stage.moveSprite(b)}; Entry.Engine.prototype.raiseKeyEvent=function(b,a){return b.parent.script.raiseEvent(a[0],b,String(a[1]))};Entry.Engine.prototype.updateMouseView=function(){var b=Entry.stage.mouseCoordinate;this.mouseView.innerHTML="X : "+b.x+", Y : "+b.y;this.mouseView.removeClass("entryRemove")};Entry.Engine.prototype.hideMouseView=function(){this.mouseView.addClass("entryRemove")}; @@ -760,7 +762,7 @@ Entry.Engine.prototype.toggleFullscreen=function(){if(this.popup)this.popup.remo Entry.Engine.prototype.exitFullScreen=function(){document.webkitIsFullScreen||document.mozIsFullScreen||document.isFullScreen||(Entry.engine.footerView_.removeClass("entryRemove"),Entry.engine.headerView_.removeClass("entryRemove"))};Entry.Engine.prototype.showProjectTimer=function(){Entry.engine.projectTimer&&this.projectTimer.setVisible(!0)}; Entry.Engine.prototype.hideProjectTimer=function(){var b=this.projectTimer;if(b&&b.isVisible()&&!this.isState("run")){for(var a=Entry.container.getAllObjects(),c=["get_project_timer_value","reset_project_timer","set_visible_project_timer","choose_project_timer_action"],d=0,e=a.length;d -1) e.preventDefault(); @@ -446,6 +446,11 @@ Entry.Engine.prototype.run = function() { * toggle this engine state run */ Entry.Engine.prototype.toggleRun = function() { + if (this.state === 'pause') { + this.togglePause(); + return; + } + Entry.addActivity("run"); if (this.state == 'stop') { Entry.container.mapEntity(function(entity){ @@ -543,15 +548,30 @@ Entry.Engine.prototype.toggleStop = function() { * toggle this engine state pause */ Entry.Engine.prototype.togglePause = function() { + var timer = Entry.engine.projectTimer; if (this.state == 'pause') { + timer.pausedTime += (new Date()).getTime() - timer.pauseStart; + if (timer.isPaused) + timer.pauseStart = (new Date()).getTime() + else delete timer.pauseStart; this.state = 'run'; this.pauseButton.innerHTML = Lang.Workspace.pause; + this.runButton.addClass('entryRemove'); + if (this.runButton2) + this.runButton2.addClass('entryRemove'); } else { this.state = 'pause'; + if (!timer.isPaused) + timer.pauseStart = (new Date()).getTime(); + else { + timer.pausedTime += (new Date()).getTime() - timer.pauseStart; + timer.pauseStart = (new Date()).getTime(); + } this.pauseButton.innerHTML = Lang.Workspace.restart; this.runButton.removeClass('entryRemove'); this.stopButton.removeClass('entryRemove'); - //this.pauseButton.addClass('entryRemove'); + if (this.runButton2) + this.runButton2.removeClass('entryRemove'); } }; @@ -746,12 +766,12 @@ Entry.Engine.prototype.stopProjectTimer = function() { }; Entry.Engine.prototype.updateProjectTimer = function(value) { - var timer = Entry.engine.projectTimer; + var engine = Entry.engine; + var timer = engine.projectTimer; + if (!timer) return; var current = (new Date()).getTime(); - if (!timer) - return; if (typeof value == 'undefined') { - if (!timer.isPaused) + if (!timer.isPaused && !engine.isState('pause')) timer.setValue(((current - timer.start - timer.pausedTime)/1000)); } else { timer.setValue(value);