diff --git a/dist/entry.css b/dist/entry.css index be69a356a0..92d38edcae 100644 --- a/dist/entry.css +++ b/dist/entry.css @@ -1883,7 +1883,7 @@ svg .svgBlockGroup text { } .entryPopupWindow > .entryEngineWorkspace_w > .entryEngineButtonWorkspace_w { position: absolute; - bottom: 1px; + bottom: 3px; } .entryPopupWindow > .entryEngineWorkspace_w > .entryAddButtonWorkspace_w { display: none; @@ -2069,7 +2069,9 @@ svg .svgBlockGroup text { .entryPopupWindow .entryMouseViewWorkspace_w { font-size: 9pt; margin: 0 auto; - width: 100%; + width: 40%; + margin-left: -20%; + left: 50%; color: #4b37a0; line-height: 24px; bottom: 1px; @@ -5109,6 +5111,7 @@ input.entryObjectNameWorkspace:-moz-read-only { flex: 1; } .propertyPanel { + z-index: 10; position: absolute; top: 326px; bottom: 0px; @@ -5344,15 +5347,11 @@ input.entryObjectNameWorkspace:-moz-read-only { } .entryCanvasWorkspace { width: 480px; - height: 270px; background-color: white; display: block; position: absolute; top: 24px; } -.entryPopupWindow .entryCanvasWorkspace { - top: -11px !important; -} .entryCanvasPhone { width: 100%; background-color: white; @@ -5360,7 +5359,6 @@ input.entryObjectNameWorkspace:-moz-read-only { } .entryPopupWindow > .entryCanvasWorkspace { width: 100% !important; - height: 100% !important; position: relative; border-bottom: 1px solid #ccc; border-top: 0px; @@ -5376,8 +5374,7 @@ input.entryObjectNameWorkspace:-moz-read-only { bottom: 24px; border-bottom: 1px solid #ccc; width: 100% !important; - height: 100% !important; - top: -25px !important; + top: 0; } .entryStateManagerWorkspace { float: right; diff --git a/dist/entry.js b/dist/entry.js index 907f1563d9..64c5c4453e 100644 --- a/dist/entry.js +++ b/dist/entry.js @@ -71,7 +71,6 @@ var Entry = {block:{}, TEXT_ALIGN_CENTER:0, TEXT_ALIGN_LEFT:1, TEXT_ALIGN_RIGHT: Entry.engine.view_.style.width = a + "px"; Entry.engine.view_.style.height = c + "px"; Entry.engine.view_.style.top = "40px"; - Entry.stage.canvas.canvas.style.height = c + "px"; Entry.stage.canvas.canvas.style.width = a + "px"; 400 <= a ? Entry.engine.view_.removeClass("collapsed") : Entry.engine.view_.addClass("collapsed"); Entry.playground.view_.style.left = a + .5 + "px"; @@ -860,8 +859,8 @@ Blockly.Blocks.arduino_toggle_led = {init:function() { this.setNextStatement(!0); }}; Entry.block.arduino_toggle_led = function(b, a) { - var c = a.getNumberValue("VALUE"), d = a.getField("OPERATOR"); - Entry.hw.setDigitalPortValue(c, "on" == d ? 255 : 0); + var c = a.getNumberValue("VALUE"), d = "on" == a.getField("OPERATOR") ? 255 : 0; + Entry.hw.setDigitalPortValue(c, d); return a.callReturn(); }; Blockly.Blocks.arduino_toggle_pwm = {init:function() { @@ -1061,8 +1060,8 @@ Blockly.Blocks.dplay_select_led = {init:function() { Entry.block.dplay_select_led = function(b, a) { var c = a.getField("PORT"), d = 7; "7" == c ? d = 7 : "8" == c ? d = 8 : "9" == c ? d = 9 : "10" == c && (d = 10); - c = a.getField("OPERATOR"); - Entry.hw.setDigitalPortValue(d, "on" == c ? 255 : 0); + c = "on" == a.getField("OPERATOR") ? 255 : 0; + Entry.hw.setDigitalPortValue(d, c); return a.callReturn(); }; Blockly.Blocks.dplay_get_switch_status = {init:function() { @@ -2072,10 +2071,10 @@ Entry.block.wait_second = function(b, a) { } a.isStart = !0; a.timeFlag = 1; - var c = a.getNumberValue("SECOND", a); + var c = a.getNumberValue("SECOND", a), c = 60 / (Entry.FPS || 60) * c * 1E3; setTimeout(function() { a.timeFlag = 0; - }, 60 / (Entry.FPS || 60) * c * 1E3); + }, c); return a; }; Blockly.Blocks.repeat_basic = {init:function() { @@ -6436,6 +6435,7 @@ Entry.Container.prototype.moveElement = function(b, a, c) { this.objects_.splice(a, 0, this.objects_.splice(b, 1)[0]); this.setCurrentObjects(); Entry.container.updateListView(); + Entry.requestUpdate = !0; return new Entry.State(Entry.container, Entry.container.moveElement, a, b, !0); }; Entry.Container.prototype.moveElementByBlock = function(b, a) { @@ -6860,12 +6860,14 @@ Entry.Dialog.prototype.generateSpeak = function() { this.update(); this.object.addChild(this.notch); this.object.addChild(b); + Entry.requestUpdate = !0; }; Entry.Dialog.prototype.update = function() { var b = this.parent.object.getTransformedBounds(), a = ""; -135 < b.y - this.height - 20 - this.border ? (this.object.y = b.y - this.height / 2 - 20 - this.padding, a += "n") : (this.object.y = b.y + b.height + this.height / 2 + 20 + this.padding, a += "s"); 240 > b.x + b.width + this.width ? (this.object.x = b.x + b.width + this.width / 2, a += "e") : (this.object.x = b.x - this.width / 2, a += "w"); this.notch.type != a && (this.object.removeChild(this.notch), this.notch = this.createSpeakNotch(a), this.object.addChild(this.notch)); + Entry.requestUpdate = !0; }; Entry.Dialog.prototype.createSpeakNotch = function(b) { var a = new createjs.Shape; @@ -6915,6 +6917,7 @@ Entry.Engine = function() { this.popup = null; this.isUpdating = !0; this.speeds = [1, 15, 30, 45, 60]; + this._mouseMoved = !1; Entry.keyPressed && Entry.keyPressed.attach(this, this.captureKeyEvent); Entry.addEventListener("canvasClick", function(a) { Entry.engine.fireEvent("mouse_clicked"); @@ -6929,8 +6932,8 @@ Entry.Engine = function() { Entry.engine.fireEventOnEntity("when_object_click_canceled", a); }); "phone" != Entry.type && (Entry.addEventListener("stageMouseMove", function(a) { - Entry.engine.updateMouseView(); - }), Entry.addEventListener("stageMouseOut", function(a) { + this._mouseMoved = !0; + }.bind(this)), Entry.addEventListener("stageMouseOut", function(a) { Entry.engine.hideMouseView(); })); Entry.addEventListener("run", function() { @@ -6939,6 +6942,9 @@ Entry.Engine = function() { Entry.addEventListener("stop", function() { $(window).unbind("keydown", b); }); + setInterval(function() { + this._mouseMoved && (this.updateMouseView(), this._mouseMoved = !1); + }.bind(this), 100); }; Entry.Engine.prototype.generateView = function(b, a) { if (a && "workspace" != a) { @@ -7129,26 +7135,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 +7181,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); @@ -7211,7 +7207,7 @@ Entry.Engine.prototype.raiseKeyEvent = function(b, a) { }; Entry.Engine.prototype.updateMouseView = function() { var b = Entry.stage.mouseCoordinate; - this.mouseView.innerHTML = "X : " + b.x + ", Y : " + b.y; + this.mouseView.textContent = "X : " + b.x + ", Y : " + b.y; this.mouseView.removeClass("entryRemove"); }; Entry.Engine.prototype.hideMouseView = function() { @@ -7227,12 +7223,15 @@ Entry.Engine.prototype.toggleFullscreen = function() { $(this.popup.body_).css("top", b.scrollTop()); $("body").css("overflow", "hidden"); popup.window_.appendChild(Entry.stage.canvas.canvas); + popup.window_.appendChild(Entry.engine.runButton[0]); } popup.window_.appendChild(Entry.engine.view_); } + Entry.windowResized.notify(); }; Entry.Engine.prototype.exitFullScreen = function() { document.webkitIsFullScreen || document.mozIsFullScreen || document.isFullScreen || (Entry.engine.footerView_.removeClass("entryRemove"), Entry.engine.headerView_.removeClass("entryRemove")); + Entry.windowResized.notify(); }; Entry.Engine.prototype.showProjectTimer = function() { Entry.engine.projectTimer && this.projectTimer.setVisible(!0); @@ -7265,8 +7264,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; @@ -7343,13 +7345,13 @@ Entry.EntityObject.prototype.restoreEntity = function(b) { Entry.stateManager && Entry.stateManager.addCommand("restore object", this, this.restoreEntity, a); }; Entry.EntityObject.prototype.setX = function(b) { - "number" == typeof b && (this.x = b, this.object.x = this.x, this.isClone || this.parent.updateCoordinateView(), this.updateDialog()); + "number" == typeof b && (this.x = b, this.object.x = this.x, this.isClone || this.parent.updateCoordinateView(), this.updateDialog(), Entry.requestUpdate = !0); }; Entry.EntityObject.prototype.getX = function() { return this.x; }; Entry.EntityObject.prototype.setY = function(b) { - "number" == typeof b && (this.y = b, this.object.y = -this.y, this.isClone || this.parent.updateCoordinateView(), this.updateDialog()); + "number" == typeof b && (this.y = b, this.object.y = -this.y, this.isClone || this.parent.updateCoordinateView(), this.updateDialog(), Entry.requestUpdate = !0); }; Entry.EntityObject.prototype.getY = function() { return this.y; @@ -7364,6 +7366,7 @@ Entry.EntityObject.prototype.setDirection = function(b, a) { this.object.direction = this.direction; this.isClone || this.parent.updateRotationView(); Entry.dispatchEvent("updateObject"); + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.setRotation = function(b) { "free" != this.parent.getRotateMethod() && (b = 0); @@ -7372,6 +7375,7 @@ Entry.EntityObject.prototype.setRotation = function(b) { this.updateDialog(); this.isClone || this.parent.updateRotationView(); Entry.dispatchEvent("updateObject"); + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getRotation = function() { return this.rotation; @@ -7380,6 +7384,7 @@ Entry.EntityObject.prototype.setRegX = function(b) { "textBox" == this.type && (b = 0); this.regX = b; this.object.regX = this.regX; + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getRegX = function() { return this.regX; @@ -7388,6 +7393,7 @@ Entry.EntityObject.prototype.setRegY = function(b) { "textBox" == this.type && (b = 0); this.regY = b; this.object.regY = this.regY; + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getRegY = function() { return this.regY; @@ -7397,6 +7403,7 @@ Entry.EntityObject.prototype.setScaleX = function(b) { this.object.scaleX = this.scaleX; this.parent.updateCoordinateView(); this.updateDialog(); + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getScaleX = function() { return this.scaleX; @@ -7406,6 +7413,7 @@ Entry.EntityObject.prototype.setScaleY = function(b) { this.object.scaleY = this.scaleY; this.parent.updateCoordinateView(); this.updateDialog(); + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getScaleY = function() { return this.scaleY; @@ -7416,6 +7424,7 @@ Entry.EntityObject.prototype.setSize = function(b) { this.setScaleX(this.getScaleX() * b); this.setScaleY(this.getScaleY() * b); this.isClone || this.parent.updateCoordinateView(); + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getSize = function() { return (this.getWidth() * Math.abs(this.getScaleX()) + this.getHeight() * Math.abs(this.getScaleY())) / 2; @@ -7426,6 +7435,7 @@ Entry.EntityObject.prototype.setWidth = function(b) { this.textObject && this.getLineBreak() && (this.textObject.lineWidth = this.width); this.updateDialog(); this.updateBG(); + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getWidth = function() { return this.width; @@ -7435,6 +7445,7 @@ Entry.EntityObject.prototype.setHeight = function(b) { this.textObject && (this.object.height = this.height, this.alignTextBox()); this.updateDialog(); this.updateBG(); + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getHeight = function() { return this.height; @@ -7443,6 +7454,7 @@ Entry.EntityObject.prototype.setColour = function(b) { b || (b = "#000000"); this.colour = b; this.textObject && (this.textObject.color = this.colour); + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getColour = function() { return this.colour; @@ -7451,6 +7463,7 @@ Entry.EntityObject.prototype.setBGColour = function(b) { b || (b = "transparent"); this.bgColor = b; this.updateBG(); + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getBGColour = function() { return this.bgColor; @@ -7459,6 +7472,7 @@ Entry.EntityObject.prototype.setUnderLine = function(b) { void 0 === b && (b = !1); this.underLine = b; this.textObject.underLine = b; + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getUnderLine = function() { return this.underLine; @@ -7467,6 +7481,7 @@ Entry.EntityObject.prototype.setStrike = function(b) { void 0 === b && (b = !1); this.strike = b; this.textObject.strike = b; + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getStrike = function() { return this.strike; @@ -7505,6 +7520,7 @@ Entry.EntityObject.prototype.syncFont = function() { Entry.stage.update(); this.getLineBreak() || this.setWidth(this.textObject.getMeasuredWidth()); Entry.stage.updateObject(); + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getFontType = function() { return this.fontType; @@ -7520,6 +7536,7 @@ Entry.EntityObject.prototype.setFontSize = function(b) { }; Entry.EntityObject.prototype.setFontBold = function(b) { this.fontBold = b; + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.toggleFontBold = function() { this.fontBold = !this.fontBold; @@ -7528,6 +7545,7 @@ Entry.EntityObject.prototype.toggleFontBold = function() { }; Entry.EntityObject.prototype.setFontItalic = function(b) { this.fontItalic = b; + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.toggleFontItalic = function() { this.fontItalic = !this.fontItalic; @@ -7580,6 +7598,7 @@ Entry.EntityObject.prototype.setVisible = function(b) { this.visible = b; this.object.visible = this.visible; this.dialog && this.syncDialogVisible(); + Entry.requestUpdate = !0; return this.visible; }; Entry.EntityObject.prototype.getVisible = function() { @@ -7611,6 +7630,7 @@ Entry.EntityObject.prototype.setImage = function(b) { f.object.image = e; f.object.cache(0, 0, f.getWidth(), f.getHeight()); f = null; + Entry.requestUpdate = !0; }; } Entry.dispatchEvent("updateObject"); @@ -7644,13 +7664,14 @@ Entry.EntityObject.prototype.applyFilter = function() { e.push(g); b.alpha = a.alpha = f(a.alpha, 0, 1); b.filters = e; - }(b, a), a.cache(0, 0, this.getWidth(), this.getHeight())); + }(b, a), a.cache(0, 0, this.getWidth(), this.getHeight()), Entry.requestUpdate = !0); }; Entry.EntityObject.prototype.resetFilter = function() { - "sprite" == this.parent.objectType && (this.object.filters = [], this.setInitialEffectValue(), this.object.alpha = this.effect.alpha, this.object.cache(0, 0, this.getWidth(), this.getHeight())); + "sprite" == this.parent.objectType && (this.object.filters = [], this.setInitialEffectValue(), this.object.alpha = this.effect.alpha, this.object.cache(0, 0, this.getWidth(), this.getHeight()), Entry.requestUpdate = !0); }; Entry.EntityObject.prototype.updateDialog = function() { this.dialog && this.dialog.update(); + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.takeSnapshot = function() { this.snapshot_ = this.toJSON(); @@ -7659,6 +7680,7 @@ Entry.EntityObject.prototype.takeSnapshot = function() { Entry.EntityObject.prototype.loadSnapshot = function() { this.snapshot_ && this.syncModel_(this.snapshot_); "sprite" == this.parent.objectType && this.setImage(this.parent.getPicture()); + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.removeClone = function() { if (this.isClone) { @@ -7692,6 +7714,7 @@ Entry.EntityObject.prototype.toJSON = function() { }; Entry.EntityObject.prototype.setInitialEffectValue = function() { this.effect = this.getInitialEffectValue(); + Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getInitialEffectValue = function() { return {blur:0, hue:0, hsv:0, brightness:0, contrast:0, saturation:0, alpha:1}; @@ -7994,6 +8017,7 @@ Entry.EntryObject = function(b) { d.onload = function(a) { Entry.container.cachePicture(c.id, d); Entry.Loader.removeQueue(); + Entry.requestUpdate = !0; }; } } @@ -10865,6 +10889,7 @@ Entry.Scene.prototype.selectScene = function(b) { Entry.container.listView_ || Entry.stage.sortZorder(); Entry.container.updateListView(); this.updateView(); + Entry.requestUpdate = !0; } }; Entry.Scene.prototype.toJSON = function() { @@ -11036,517 +11061,141 @@ p.callReturn = function() { p.run = function() { return Entry.block[this.type](this.entity, this); }; -Entry.Stage = function() { - this.variables = {}; - this.background = new createjs.Shape; - this.background.graphics.beginFill("#ffffff").drawRect(-480, -240, 960, 480); - this.objectContainers = []; - this.selectedObjectContainer = null; - this.variableContainer = new createjs.Container; - this.dialogContainer = new createjs.Container; - this.selectedObject = null; - this.isObjectClick = !1; -}; -Entry.Stage.prototype.initStage = function(b) { - this.canvas = new createjs.Stage(b.id); - this.canvas.x = 320; - this.canvas.y = 180; - this.canvas.scaleX = this.canvas.scaleY = 2 / 1.5; - createjs.Touch.enable(this.canvas); - this.canvas.enableMouseOver(10); - this.canvas.mouseMoveOutside = !0; - this.canvas.addChild(this.background); - this.canvas.addChild(this.variableContainer); - this.canvas.addChild(this.dialogContainer); - this.inputField = null; - this.initCoordinator(); - this.initHandle(); - this.mouseCoordinate = {x:0, y:0}; - if (Entry.isPhone()) { - b.ontouchstart = function(a) { - Entry.dispatchEvent("canvasClick", a); - Entry.stage.isClick = !0; - }, b.ontouchend = function(a) { - Entry.stage.isClick = !1; - Entry.dispatchEvent("canvasClickCanceled", a); - }; - } else { - var a = function(a) { - Entry.dispatchEvent("canvasClick", a); - Entry.stage.isClick = !0; - }; - b.onmousedown = a; - b.ontouchstart = a; - a = function(a) { - Entry.stage.isClick = !1; - Entry.dispatchEvent("canvasClickCanceled", a); - }; - b.onmouseup = a; - b.ontouchend = a; - $(document).click(function(a) { - Entry.stage.focused = "entryCanvas" === a.target.id ? !0 : !1; - }); +Entry.StampEntity = function(b, a) { + this.parent = b; + this.type = b.objectType; + this.isStamp = this.isClone = !0; + this.width = a.getWidth(); + this.height = a.getHeight(); + "sprite" == this.type && (this.object = a.object.clone(!0), this.object.filters = null, a.effect && (this.effect = Entry.cloneSimpleObject(a.effect), this.applyFilter())); + this.object.entity = this; + if (a.dialog) { + var c = a.dialog; + new Entry.Dialog(this, c.message_, c.mode_, !0); + this.dialog.object = a.dialog.object.clone(!0); + Entry.stage.loadDialog(this.dialog); } - Entry.addEventListener("canvasClick", function(a) { - Entry.stage.isObjectClick = !1; - }); - a = function(a) { - a.preventDefault(); - var b = this.getBoundingClientRect(), e; - -1 < Entry.getBrowserType().indexOf("IE") ? (e = 480 * ((a.pageX - b.left - document.documentElement.scrollLeft) / b.width - .5), a = -270 * ((a.pageY - b.top - document.documentElement.scrollTop) / b.height - .5)) : a.changedTouches ? (e = 480 * ((a.changedTouches[0].pageX - b.left - document.body.scrollLeft) / b.width - .5), a = -270 * ((a.changedTouches[0].pageY - b.top - document.body.scrollTop) / b.height - .5)) : (e = 480 * ((a.pageX - b.left - document.body.scrollLeft) / b.width - .5), - a = -270 * ((a.pageY - b.top - document.body.scrollTop) / b.height - .5)); - Entry.stage.mouseCoordinate = {x:e.toFixed(1), y:a.toFixed(1)}; - Entry.dispatchEvent("stageMouseMove"); - }; - b.onmousemove = a; - b.ontouchmove = a; - b.onmouseout = function(a) { - Entry.dispatchEvent("stageMouseOut"); - }; - Entry.addEventListener("updateObject", function(a) { - Entry.engine.isState("stop") && Entry.stage.updateObject(); - }); - Entry.addEventListener("canvasInputComplete", function(a) { - try { - var b = Entry.stage.inputField.value(); - Entry.stage.hideInputField(); - if (b) { - var e = Entry.container; - e.setInputValue(b); - e.inputValue.complete = !0; - } - } catch (f) { - } - }); - this.initWall(); - this.render(); }; -Entry.Stage.prototype.render = function() { - Entry.stage.timer && clearTimeout(Entry.stage.timer); - var b = (new Date).getTime(); - Entry.stage.update(); - b = (new Date).getTime() - b; - Entry.stage.timer = setTimeout(Entry.stage.render, 16 - b % 16 + 16 * Math.floor(b / 16)); +var EntityPrototype = Entry.EntityObject.prototype; +Entry.StampEntity.prototype.applyFilter = EntityPrototype.applyFilter; +Entry.StampEntity.prototype.removeClone = EntityPrototype.removeClone; +Entry.StampEntity.prototype.getWidth = EntityPrototype.getWidth; +Entry.StampEntity.prototype.getHeight = EntityPrototype.getHeight; +Entry.StampEntity.prototype.getInitialEffectValue = EntityPrototype.getInitialEffectValue; +Entry.Toast = function() { + this.toasts_ = []; + var b = document.getElementById("entryToastContainer"); + b && document.body.removeChild(b); + this.body_ = Entry.createElement("div", "entryToastContainer"); + this.body_.addClass("entryToastContainer"); + document.body.appendChild(this.body_); }; -Entry.Stage.prototype.update = function() { - Entry.engine.isState("stop") && this.objectUpdated ? (this.canvas.update(), this.objectUpdated = !1) : this.canvas.update(); - this.inputField && !this.inputField._isHidden && this.inputField.render(); +Entry.Toast.prototype.warning = function(b, a, c) { + var d = Entry.createElement("div", "entryToast"); + d.addClass("entryToast"); + d.addClass("entryToastWarning"); + d.bindOnClick(function() { + Entry.toast.body_.removeChild(this); + }); + var e = Entry.createElement("div", "entryToast"); + e.addClass("entryToastTitle"); + e.innerHTML = b; + d.appendChild(e); + b = Entry.createElement("p", "entryToast"); + b.addClass("entryToastMessage"); + b.innerHTML = a; + d.appendChild(b); + this.toasts_.push(d); + this.body_.appendChild(d); + c || window.setTimeout(function() { + d.style.opacity = 1; + var a = setInterval(function() { + .05 > d.style.opacity && (clearInterval(a), d.style.display = "none", Entry.removeElement(d)); + d.style.opacity *= .9; + }, 20); + }, 1E3); }; -Entry.Stage.prototype.loadObject = function(b) { - var a = b.entity.object; - this.getObjectContainerByScene(b.scene).addChild(a); - this.canvas.update(); +Entry.Toast.prototype.success = function(b, a, c) { + var d = Entry.createElement("div", "entryToast"); + d.addClass("entryToast"); + d.addClass("entryToastSuccess"); + d.bindOnClick(function() { + Entry.toast.body_.removeChild(this); + }); + var e = Entry.createElement("div", "entryToast"); + e.addClass("entryToastTitle"); + e.innerHTML = b; + d.appendChild(e); + b = Entry.createElement("p", "entryToast"); + b.addClass("entryToastMessage"); + b.innerHTML = a; + d.appendChild(b); + this.toasts_.push(d); + this.body_.appendChild(d); + c || window.setTimeout(function() { + d.style.opacity = 1; + var a = setInterval(function() { + .05 > d.style.opacity && (clearInterval(a), d.style.display = "none", Entry.removeElement(d)); + d.style.opacity *= .9; + }, 20); + }, 1E3); }; -Entry.Stage.prototype.loadEntity = function(b) { - Entry.stage.getObjectContainerByScene(b.parent.scene).addChild(b.object); - this.sortZorder(); +Entry.Toast.prototype.alert = function(b, a, c) { + var d = Entry.createElement("div", "entryToast"); + d.addClass("entryToast"); + d.addClass("entryToastAlert"); + d.bindOnClick(function() { + Entry.toast.body_.removeChild(this); + }); + var e = Entry.createElement("div", "entryToast"); + e.addClass("entryToastTitle"); + e.innerHTML = b; + d.appendChild(e); + b = Entry.createElement("p", "entryToast"); + b.addClass("entryToastMessage"); + b.innerHTML = a; + d.appendChild(b); + this.toasts_.push(d); + this.body_.appendChild(d); + c || window.setTimeout(function() { + d.style.opacity = 1; + var a = setInterval(function() { + .05 > d.style.opacity && (clearInterval(a), d.style.display = "none", Entry.toast.body_.removeChild(d)); + d.style.opacity *= .9; + }, 20); + }, 5E3); }; -Entry.Stage.prototype.unloadEntity = function(b) { - Entry.stage.getObjectContainerByScene(b.parent.scene).removeChild(b.object); +Entry.TvCast = function(b) { + this.generateView(b); }; -Entry.Stage.prototype.loadVariable = function(b) { - var a = b.view_; - this.variables[b.id] = a; - this.variableContainer.addChild(a); - this.canvas.update(); +p = Entry.TvCast.prototype; +p.init = function(b) { + this.tvCastHash = b; }; -Entry.Stage.prototype.removeVariable = function(b) { - this.variableContainer.removeChild(b.view_); - this.canvas.update(); +p.generateView = function(b) { + var a = Entry.createElement("div"); + a.addClass("entryContainerMovieWorkspace"); + a.addClass("entryRemove"); + this.movieContainer = a; + a = Entry.createElement("iframe"); + a.setAttribute("id", "tvCastIframe"); + a.setAttribute("allowfullscreen", ""); + a.setAttribute("frameborder", 0); + a.setAttribute("src", b); + this.movieFrame = a; + this.movieContainer.appendChild(this.movieFrame); }; -Entry.Stage.prototype.loadDialog = function(b) { - this.dialogContainer.addChild(b.object); +p.getView = function() { + return this.movieContainer; }; -Entry.Stage.prototype.unloadDialog = function(b) { - this.dialogContainer.removeChild(b.object); +p.resize = function() { + document.getElementById("entryContainerWorkspaceId"); + var b = document.getElementById("tvCastIframe"); + w = this.movieContainer.offsetWidth; + b.width = w + "px"; + b.height = 9 * w / 16 + "px"; }; -Entry.Stage.prototype.sortZorder = function() { - for (var b = Entry.container.getCurrentObjects(), a = this.selectedObjectContainer, c = 0, d = b.length - 1;0 <= d;d--) { - for (var e = b[d], f = e.entity, e = e.clonedEntities, g = 0, h = e.length;g < h;g++) { - e[g].shape && a.setChildIndex(e[g].shape, c++), a.setChildIndex(e[g].object, c++); - } - f.shape && a.setChildIndex(f.shape, c++); - a.setChildIndex(f.object, c++); - } -}; -Entry.Stage.prototype.initCoordinator = function() { - var b = new createjs.Container, a = new createjs.Bitmap(Entry.mediaFilePath + "workspace_coordinate.png"); - a.scaleX = .5; - a.scaleY = .5; - a.x = -240; - a.y = -135; - b.addChild(a); - this.canvas.addChild(b); - b.visible = !1; - this.coordinator = b; -}; -Entry.Stage.prototype.toggleCoordinator = function() { - this.coordinator.visible = !this.coordinator.visible; -}; -Entry.Stage.prototype.selectObject = function(b) { - this.selectedObject = b ? b : null; - this.updateObject(); -}; -Entry.Stage.prototype.initHandle = function() { - this.handle = new EaselHandle(this.canvas); - this.handle.setChangeListener(this, this.updateHandle); - this.handle.setEditStartListener(this, this.startEdit); - this.handle.setEditEndListener(this, this.endEdit); -}; -Entry.Stage.prototype.updateObject = function() { - this.handle.setDraggable(!0); - if (!this.editEntity) { - var b = this.selectedObject; - if (b) { - "textBox" == b.objectType ? this.handle.toggleCenter(!1) : this.handle.toggleCenter(!0); - "free" == b.getRotateMethod() ? this.handle.toggleRotation(!0) : this.handle.toggleRotation(!1); - this.handle.toggleDirection(!0); - b.getLock() ? (this.handle.toggleRotation(!1), this.handle.toggleDirection(!1), this.handle.toggleResize(!1), this.handle.toggleCenter(!1), this.handle.setDraggable(!1)) : this.handle.toggleResize(!0); - this.handle.setVisible(!0); - var a = b.entity; - this.handle.setWidth(a.getScaleX() * a.getWidth()); - this.handle.setHeight(a.getScaleY() * a.getHeight()); - var c, d; - if ("textBox" == a.type) { - if (a.getLineBreak()) { - c = a.regX * a.scaleX, d = -a.regY * a.scaleY; - } else { - var e = a.getTextAlign(); - d = -a.regY * a.scaleY; - switch(e) { - case Entry.TEXT_ALIGN_LEFT: - c = -a.getWidth() / 2 * a.scaleX; - break; - case Entry.TEXT_ALIGN_CENTER: - c = a.regX * a.scaleX; - break; - case Entry.TEXT_ALIGN_RIGHT: - c = a.getWidth() / 2 * a.scaleX; - } - } - } else { - c = (a.regX - a.width / 2) * a.scaleX, d = (a.height / 2 - a.regY) * a.scaleY; - } - e = a.getRotation() / 180 * Math.PI; - this.handle.setX(a.getX() - c * Math.cos(e) - d * Math.sin(e)); - this.handle.setY(-a.getY() - c * Math.sin(e) + d * Math.cos(e)); - this.handle.setRegX((a.regX - a.width / 2) * a.scaleX); - this.handle.setRegY((a.regY - a.height / 2) * a.scaleY); - this.handle.setRotation(a.getRotation()); - this.handle.setDirection(a.getDirection()); - this.objectUpdated = !0; - this.handle.setVisible(b.entity.getVisible()); - b.entity.getVisible() && this.handle.render(); - } else { - this.handle.setVisible(!1); - } - } -}; -Entry.Stage.prototype.updateHandle = function() { - this.editEntity = !0; - var b = this.handle, a = this.selectedObject.entity; - if (a.lineBreak) { - a.setHeight(b.height / a.getScaleY()), a.setWidth(b.width / a.getScaleX()); - } else { - if (0 !== a.width) { - var c = Math.abs(b.width / a.width); - a.flip && (c *= -1); - a.setScaleX(c); - } - 0 !== a.height && a.setScaleY(b.height / a.height); - } - c = b.rotation / 180 * Math.PI; - if ("textBox" == a.type) { - var d = b.regX / a.scaleX, d = b.regY / a.scaleY; - if (a.getLineBreak()) { - a.setX(b.x), a.setY(-b.y); - } else { - switch(a.getTextAlign()) { - case Entry.TEXT_ALIGN_LEFT: - a.setX(b.x - b.width / 2 * Math.cos(c)); - a.setY(-b.y + b.width / 2 * Math.sin(c)); - break; - case Entry.TEXT_ALIGN_CENTER: - a.setX(b.x); - a.setY(-b.y); - break; - case Entry.TEXT_ALIGN_RIGHT: - a.setX(b.x + b.width / 2 * Math.cos(c)), a.setY(-b.y - b.width / 2 * Math.sin(c)); - } - } - } else { - d = a.width / 2 + b.regX / a.scaleX, a.setX(b.x + b.regX * Math.cos(c) - b.regY * Math.sin(c)), a.setRegX(d), d = a.height / 2 + b.regY / a.scaleY, a.setY(-b.y - b.regX * Math.sin(c) - b.regY * Math.cos(c)), a.setRegY(d); - } - a.setDirection(b.direction); - a.setRotation(b.rotation); - this.selectedObject.entity.doCommand(); - this.editEntity = !1; -}; -Entry.Stage.prototype.startEdit = function() { - this.selectedObject.entity.initCommand(); -}; -Entry.Stage.prototype.endEdit = function() { - this.selectedObject.entity.checkCommand(); -}; -Entry.Stage.prototype.initWall = function() { - var b = new createjs.Container, a = new Image; - a.src = Entry.mediaFilePath + "media/bound.png"; - b.up = new createjs.Bitmap; - b.up.scaleX = 16; - b.up.y = -165; - b.up.x = -240; - b.up.image = a; - b.addChild(b.up); - b.down = new createjs.Bitmap; - b.down.scaleX = 16; - b.down.y = 135; - b.down.x = -240; - b.down.image = a; - b.addChild(b.down); - b.right = new createjs.Bitmap; - b.right.scaleY = 9; - b.right.y = -135; - b.right.x = 240; - b.right.image = a; - b.addChild(b.right); - b.left = new createjs.Bitmap; - b.left.scaleY = 9; - b.left.y = -135; - b.left.x = -270; - b.left.image = a; - b.addChild(b.left); - this.canvas.addChild(b); - this.wall = b; -}; -Entry.Stage.prototype.showInputField = function(b) { - b = 1 / 1.5; - this.inputField || (this.inputField = new CanvasInput({canvas:document.getElementById("entryCanvas"), fontSize:30 * b, fontFamily:"NanumGothic", fontColor:"#212121", width:556 * b, height:26 * b, padding:8 * b, borderWidth:1 * b, borderColor:"#000", borderRadius:3 * b, boxShadow:"none", innerShadow:"0px 0px 5px rgba(0, 0, 0, 0.5)", x:202 * b, y:450 * b, topPosition:!0, onsubmit:function() { - Entry.dispatchEvent("canvasInputComplete"); - }})); - b = new createjs.Container; - var a = new Image; - a.src = Entry.mediaFilePath + "confirm_button.png"; - var c = new createjs.Bitmap; - c.scaleX = .23; - c.scaleY = .23; - c.x = 160; - c.y = 89; - c.cursor = "pointer"; - c.image = a; - b.addChild(c); - b.on("mousedown", function(a) { - Entry.dispatchEvent("canvasInputComplete"); - }); - this.inputSubmitButton || (this.inputField.value(""), this.canvas.addChild(b), this.inputSubmitButton = b); - this.inputField.show(); -}; -Entry.Stage.prototype.hideInputField = function() { - this.inputField && this.inputField.value() && this.inputField.value(""); - this.inputSubmitButton && (this.canvas.removeChild(this.inputSubmitButton), this.inputSubmitButton = null); - this.inputField && this.inputField.hide(); -}; -Entry.Stage.prototype.initObjectContainers = function() { - var b = Entry.scene.scenes_; - if (b && 0 !== b.length) { - for (var a = 0;a < b.length;a++) { - this.objectContainers[a] = this.createObjectContainer(b[a]); - } - this.selectedObjectContainer = this.objectContainers[0]; - } else { - b = this.createObjectContainer(Entry.scene.selectedScene), this.objectContainers.push(b), this.selectedObjectContainer = b; - } - this.canvas.addChild(this.selectedObjectContainer); - this.selectObjectContainer(Entry.scene.selectedScene); -}; -Entry.Stage.prototype.selectObjectContainer = function(b) { - if (this.canvas) { - for (var a = this.objectContainers, c = 0;c < a.length;c++) { - this.canvas.removeChild(a[c]); - } - this.selectedObjectContainer = this.getObjectContainerByScene(b); - this.canvas.addChildAt(this.selectedObjectContainer, 2); - } -}; -Entry.Stage.prototype.reAttachToCanvas = function() { - for (var b = [this.selectedObjectContainer, this.variableContainer, this.coordinator, this.handle, this.dialogContainer], a = 0;a < b.length;a++) { - this.canvas.removeChild(b[a]), this.canvas.addChild(b[a]); - } - console.log(this.canvas.getChildIndex(this.selectedObjectContainer)); -}; -Entry.Stage.prototype.createObjectContainer = function(b) { - var a = new createjs.Container; - a.scene = b; - return a; -}; -Entry.Stage.prototype.removeObjectContainer = function(b) { - var a = this.objectContainers; - b = this.getObjectContainerByScene(b); - this.canvas.removeChild(b); - a.splice(this.objectContainers.indexOf(b), 1); -}; -Entry.Stage.prototype.getObjectContainerByScene = function(b) { - for (var a = this.objectContainers, c = 0;c < a.length;c++) { - if (a[c].scene.id == b.id) { - return a[c]; - } - } -}; -Entry.Stage.prototype.moveSprite = function(b) { - if (this.selectedObject && Entry.stage.focused && !this.selectedObject.getLock()) { - var a = 5; - b.shiftKey && (a = 1); - var c = this.selectedObject.entity; - switch(b.keyCode) { - case 38: - c.setY(c.getY() + a); - break; - case 40: - c.setY(c.getY() - a); - break; - case 37: - c.setX(c.getX() - a); - break; - case 39: - c.setX(c.getX() + a); - } - this.updateObject(); - } -}; -Entry.StampEntity = function(b, a) { - this.parent = b; - this.type = b.objectType; - this.isStamp = this.isClone = !0; - this.width = a.getWidth(); - this.height = a.getHeight(); - "sprite" == this.type && (this.object = a.object.clone(!0), this.object.filters = null, a.effect && (this.effect = Entry.cloneSimpleObject(a.effect), this.applyFilter())); - this.object.entity = this; - if (a.dialog) { - var c = a.dialog; - new Entry.Dialog(this, c.message_, c.mode_, !0); - this.dialog.object = a.dialog.object.clone(!0); - Entry.stage.loadDialog(this.dialog); - } -}; -var EntityPrototype = Entry.EntityObject.prototype; -Entry.StampEntity.prototype.applyFilter = EntityPrototype.applyFilter; -Entry.StampEntity.prototype.removeClone = EntityPrototype.removeClone; -Entry.StampEntity.prototype.getWidth = EntityPrototype.getWidth; -Entry.StampEntity.prototype.getHeight = EntityPrototype.getHeight; -Entry.StampEntity.prototype.getInitialEffectValue = EntityPrototype.getInitialEffectValue; -Entry.Toast = function() { - this.toasts_ = []; - var b = document.getElementById("entryToastContainer"); - b && document.body.removeChild(b); - this.body_ = Entry.createElement("div", "entryToastContainer"); - this.body_.addClass("entryToastContainer"); - document.body.appendChild(this.body_); -}; -Entry.Toast.prototype.warning = function(b, a, c) { - var d = Entry.createElement("div", "entryToast"); - d.addClass("entryToast"); - d.addClass("entryToastWarning"); - d.bindOnClick(function() { - Entry.toast.body_.removeChild(this); - }); - var e = Entry.createElement("div", "entryToast"); - e.addClass("entryToastTitle"); - e.innerHTML = b; - d.appendChild(e); - b = Entry.createElement("p", "entryToast"); - b.addClass("entryToastMessage"); - b.innerHTML = a; - d.appendChild(b); - this.toasts_.push(d); - this.body_.appendChild(d); - c || window.setTimeout(function() { - d.style.opacity = 1; - var a = setInterval(function() { - .05 > d.style.opacity && (clearInterval(a), d.style.display = "none", Entry.removeElement(d)); - d.style.opacity *= .9; - }, 20); - }, 1E3); -}; -Entry.Toast.prototype.success = function(b, a, c) { - var d = Entry.createElement("div", "entryToast"); - d.addClass("entryToast"); - d.addClass("entryToastSuccess"); - d.bindOnClick(function() { - Entry.toast.body_.removeChild(this); - }); - var e = Entry.createElement("div", "entryToast"); - e.addClass("entryToastTitle"); - e.innerHTML = b; - d.appendChild(e); - b = Entry.createElement("p", "entryToast"); - b.addClass("entryToastMessage"); - b.innerHTML = a; - d.appendChild(b); - this.toasts_.push(d); - this.body_.appendChild(d); - c || window.setTimeout(function() { - d.style.opacity = 1; - var a = setInterval(function() { - .05 > d.style.opacity && (clearInterval(a), d.style.display = "none", Entry.removeElement(d)); - d.style.opacity *= .9; - }, 20); - }, 1E3); -}; -Entry.Toast.prototype.alert = function(b, a, c) { - var d = Entry.createElement("div", "entryToast"); - d.addClass("entryToast"); - d.addClass("entryToastAlert"); - d.bindOnClick(function() { - Entry.toast.body_.removeChild(this); - }); - var e = Entry.createElement("div", "entryToast"); - e.addClass("entryToastTitle"); - e.innerHTML = b; - d.appendChild(e); - b = Entry.createElement("p", "entryToast"); - b.addClass("entryToastMessage"); - b.innerHTML = a; - d.appendChild(b); - this.toasts_.push(d); - this.body_.appendChild(d); - c || window.setTimeout(function() { - d.style.opacity = 1; - var a = setInterval(function() { - .05 > d.style.opacity && (clearInterval(a), d.style.display = "none", Entry.toast.body_.removeChild(d)); - d.style.opacity *= .9; - }, 20); - }, 5E3); -}; -Entry.TvCast = function(b) { - this.generateView(b); -}; -p = Entry.TvCast.prototype; -p.init = function(b) { - this.tvCastHash = b; -}; -p.generateView = function(b) { - var a = Entry.createElement("div"); - a.addClass("entryContainerMovieWorkspace"); - a.addClass("entryRemove"); - this.movieContainer = a; - a = Entry.createElement("iframe"); - a.setAttribute("id", "tvCastIframe"); - a.setAttribute("allowfullscreen", ""); - a.setAttribute("frameborder", 0); - a.setAttribute("src", b); - this.movieFrame = a; - this.movieContainer.appendChild(this.movieFrame); -}; -p.getView = function() { - return this.movieContainer; -}; -p.resize = function() { - document.getElementById("entryContainerWorkspaceId"); - var b = document.getElementById("tvCastIframe"); - w = this.movieContainer.offsetWidth; - b.width = w + "px"; - b.height = 9 * w / 16 + "px"; -}; -Entry.BlockDriver = function() { +Entry.BlockDriver = function() { }; (function(b) { b.convert = function() { @@ -12299,10 +11948,10 @@ Entry.Utils.addFilters = function(b, a) { c.elem("feColorMatrix", {result:"matrixOut", in:"offOut", type:"matrix", values:"1.3 0 0 0 0 0 1.3 0 0 0 0 0 1.3 0 0 0 0 0 1 0"}); }; Entry.Utils.addBlockPattern = function(b, a) { - for (var c = b.elem("pattern", {id:"blockHoverPattern_" + a, class:"blockHoverPattern", patternUnits:"userSpaceOnUse", patternTransform:"translate(12, 0)", x:0, y:0, width:125, height:33}).elem("g"), d = c.elem("rect", {x:0, y:0, width:125, height:33}), e = Entry.mediaFilePath + "block_pattern_(order).png", f = 1;5 > f;f++) { - c.elem("image", {class:"pattern" + f, href:e.replace("(order)", f), x:0, y:0, width:125, height:33}); + for (var c = b.elem("pattern", {id:"blockHoverPattern_" + a, class:"blockHoverPattern", patternUnits:"userSpaceOnUse", patternTransform:"translate(12, 0)", x:0, y:0, width:125, height:33, style:"display: none"}), d = c.elem("g"), e = d.elem("rect", {x:0, y:0, width:125, height:33}), f = Entry.mediaFilePath + "block_pattern_(order).png", g = 1;5 > g;g++) { + d.elem("image", {class:"pattern" + g, href:f.replace("(order)", g), x:0, y:0, width:125, height:33}); } - return d; + return {pattern:c, rect:e}; }; Entry.Utils.COLLISION = {NONE:0, UP:1, RIGHT:2, LEFT:3, DOWN:4}; Entry.Utils.createMouseEvent = function(b, a) { @@ -12365,6 +12014,11 @@ Entry.Utils.waitForWebfonts = function(b, a) { })(b[d]); } }; +window.requestAnimFrame = function() { + return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(b) { + window.setTimeout(b, 1E3 / 60); + }; +}(); Entry.Model = function(b, a) { var c = Entry.Model; c.generateSchema(b); @@ -12883,199 +12537,587 @@ Entry.HWMonitor = function(b) { a.length && a[0].group.attr({transform:"translate(" + b + ",60)"}); g && rPort && (this._movePort(g, b, tP, h), this._movePort(rPort, b, bP, k)); }; - b._alignNS = function(a, b, d) { - for (var e = -this._rect.width / 2, f = this._rect.width / 2, g = this._rect.width, h = 0, k = 0;k < a.length;k++) { - h += a[k].width + 5; - } - h < f - e && (f = h / 2 + 3, e = -h / 2 - 3); - for (;1 < a.length;) { - var k = a.shift(), l = a.pop(), q = e, n = f, m = d; - h <= f - e ? (e += k.width + 5, f -= l.width + 5, m = 0) : 0 === a.length ? (e = (e + f) / 2 - 3, f = e + 6) : (e = Math.max(e, -g / 2 + k.width) + 15, f = Math.min(f, g / 2 - l.width) - 15); - this._movePort(k, e, b, q); - this._movePort(l, f, b, n); - h -= k.width + l.width + 10; - b += m; - } - a.length && this._movePort(a[0], (f + e - a[0].width) / 2, b, 100); + b._alignNS = function(a, b, d) { + for (var e = -this._rect.width / 2, f = this._rect.width / 2, g = this._rect.width, h = 0, k = 0;k < a.length;k++) { + h += a[k].width + 5; + } + h < f - e && (f = h / 2 + 3, e = -h / 2 - 3); + for (;1 < a.length;) { + var k = a.shift(), l = a.pop(), q = e, n = f, m = d; + h <= f - e ? (e += k.width + 5, f -= l.width + 5, m = 0) : 0 === a.length ? (e = (e + f) / 2 - 3, f = e + 6) : (e = Math.max(e, -g / 2 + k.width) + 15, f = Math.min(f, g / 2 - l.width) - 15); + this._movePort(k, e, b, q); + this._movePort(l, f, b, n); + h -= k.width + l.width + 10; + b += m; + } + a.length && this._movePort(a[0], (f + e - a[0].width) / 2, b, 100); + }; + b._alignNSList = function(a, b) { + var d = this._rect.width; + initX = -this._rect.width / 2 + 10; + initY = -this._rect.height / 2 + 10; + for (var e = listLine = wholeWidth = 0;e < a.length;e++) { + wholeWidth += a[e].width; + } + for (var f = 0, g = 0, h = initX, k = 0, l = 0, q = 0, e = 0;e < a.length;e++) { + l = a[e], e != a.length - 1 && (q = a[e + 1]), g += l.width, lP = initX, k = initY + 30 * f, l.group.attr({transform:"translate(" + lP + "," + k + ")"}), initX += l.width + 10, g > d - (l.width + q.width / 2.2) && (f += 1, initX = h, g = 0); + } + }; + b._movePort = function(a, b, d, e) { + var f = b, g = a.box.x * this.scale, h = a.box.y * this.scale; + b > e ? (f = b - a.width, b = b > g && g > e ? "M" + g + "," + d + "L" + g + "," + h : "M" + (b + e) / 2 + "," + d + "l0," + (h > d ? 28 : -3) + "H" + g + "L" + g + "," + h) : b = b < g && g < e ? "m" + g + "," + d + "L" + g + "," + h : "m" + (e + b) / 2 + "," + d + "l0," + (h > d ? 28 : -3) + "H" + g + "L" + g + "," + h; + a.group.attr({transform:"translate(" + f + "," + d + ")"}); + a.path.attr({d:b}); + }; +})(Entry.HWMonitor.prototype); +Entry.HW = function() { + this.connectTrial = 0; + this.isFirstConnect = !0; + this.initSocket(); + this.connected = !1; + this.portData = {}; + this.sendQueue = {}; + this.outputQueue = {}; + this.settingQueue = {}; + this.socketType = this.hwModule = this.selectedDevice = null; + Entry.addEventListener("stop", this.setZero); + this.hwInfo = {11:Entry.Arduino, 12:Entry.SensorBoard, 13:Entry.CODEino, 14:Entry.joystick, 15:Entry.dplay, 16:Entry.nemoino, 17:Entry.Xbot, 18:Entry.ardublock, 24:Entry.Hamster, 25:Entry.Albert, 31:Entry.Bitbrick, 42:Entry.Arduino, 51:Entry.Neobot, 71:Entry.Robotis_carCont, 72:Entry.Robotis_openCM70, 81:Entry.Arduino}; +}; +Entry.HW.TRIAL_LIMIT = 1; +p = Entry.HW.prototype; +p.initSocket = function() { + try { + if (this.connectTrial >= Entry.HW.TRIAL_LIMIT) { + this.isFirstConnect || Entry.toast.alert(Lang.Menus.connect_hw, Lang.Menus.connect_fail, !1), this.isFirstConnect = !1; + } else { + var b = this, a, c; + this.connected = !1; + this.connectTrial++; + if (-1 < location.protocol.indexOf("https")) { + c = new WebSocket("wss://hardware.play-entry.org:23518"); + } else { + try { + a = new WebSocket("ws://127.0.0.1:23518"), a.binaryType = "arraybuffer", a.onopen = function() { + b.socketType = "WebSocket"; + b.initHardware(a); + }.bind(this), a.onmessage = function(a) { + a = JSON.parse(a.data); + b.checkDevice(a); + b.updatePortData(a); + }.bind(this), a.onclose = function() { + "WebSocket" === b.socketType && (this.socket = null, b.initSocket()); + }; + } catch (d) { + } + try { + c = new WebSocket("wss://hardware.play-entry.org:23518"); + } catch (d) { + } + } + c.binaryType = "arraybuffer"; + c.onopen = function() { + b.socketType = "WebSocketSecurity"; + b.initHardware(c); + }; + c.onmessage = function(a) { + a = JSON.parse(a.data); + b.checkDevice(a); + b.updatePortData(a); + }; + c.onclose = function() { + "WebSocketSecurity" === b.socketType && (this.socket = null, b.initSocket()); + }; + Entry.dispatchEvent("hwChanged"); + } + } catch (d) { + } +}; +p.retryConnect = function() { + this.connectTrial = 0; + this.initSocket(); +}; +p.initHardware = function(b) { + this.socket = b; + this.connectTrial = 0; + this.connected = !0; + Entry.dispatchEvent("hwChanged"); + Entry.playground && Entry.playground.object && Entry.playground.setMenu(Entry.playground.object.objectType); +}; +p.setDigitalPortValue = function(b, a) { + this.sendQueue[b] = a; + this.removePortReadable(b); +}; +p.getAnalogPortValue = function(b) { + return this.connected ? this.portData["a" + b] : 0; +}; +p.getDigitalPortValue = function(b) { + if (!this.connected) { + return 0; + } + this.setPortReadable(b); + return void 0 !== this.portData[b] ? this.portData[b] : 0; +}; +p.setPortReadable = function(b) { + this.sendQueue.readablePorts || (this.sendQueue.readablePorts = []); + var a = !1, c; + for (c in this.sendQueue.readablePorts) { + if (this.sendQueue.readablePorts[c] == b) { + a = !0; + break; + } + } + a || this.sendQueue.readablePorts.push(b); +}; +p.removePortReadable = function(b) { + if (this.sendQueue.readablePorts || Array.isArray(this.sendQueue.readablePorts)) { + var a, c; + for (c in this.sendQueue.readablePorts) { + if (this.sendQueue.readablePorts[c] == b) { + a = Number(c); + break; + } + } + this.sendQueue.readablePorts = void 0 != a ? this.sendQueue.readablePorts.slice(0, a).concat(this.sendQueue.readablePorts.slice(a + 1, this.sendQueue.readablePorts.length)) : []; + } +}; +p.update = function() { + this.socket && 1 == this.socket.readyState && this.socket.send(JSON.stringify(this.sendQueue)); +}; +p.updatePortData = function(b) { + this.portData = b; + this.hwMonitor && this.hwMonitor.update(); +}; +p.closeConnection = function() { + this.socket && this.socket.close(); +}; +p.downloadConnector = function() { + window.open("http://download.play-entry.org/apps/Entry_HW_1.5.6_Setup.exe", "_blank").focus(); +}; +p.downloadSource = function() { + window.open("http://play-entry.com/down/board.ino", "_blank").focus(); +}; +p.setZero = function() { + Entry.hw.hwModule && Entry.hw.hwModule.setZero(); +}; +p.checkDevice = function(b) { + void 0 !== b.company && (b = "" + b.company + b.model, b != this.selectedDevice && (this.selectedDevice = b, this.hwModule = this.hwInfo[b], Entry.dispatchEvent("hwChanged"), Entry.toast.success("\ud558\ub4dc\uc6e8\uc5b4 \uc5f0\uacb0 \uc131\uacf5", "\ud558\ub4dc\uc6e8\uc5b4 \uc544\uc774\ucf58\uc744 \ub354\ube14\ud074\ub9ad\ud558\uba74, \uc13c\uc11c\uac12\ub9cc \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.", !0), this.hwModule.monitorTemplate && (this.hwMonitor ? (this.hwMonitor._hwModule = + this.hwModule, this.hwMonitor.initView()) : this.hwMonitor = new Entry.HWMonitor(this.hwModule), Entry.propertyPanel.addMode("hw", this.hwMonitor), b = this.hwModule.monitorTemplate, "both" == b.mode ? (b.mode = "list", this.hwMonitor.generateListView(), b.mode = "general", this.hwMonitor.generateView(), b.mode = "both") : "list" == b.mode ? this.hwMonitor.generateListView() : this.hwMonitor.generateView()))); +}; +p.banHW = function() { + var b = this.hwInfo, a; + for (a in b) { + Entry.playground.mainWorkspace.blockMenu.banClass(b[a].name, !0); + } +}; +Entry.BlockModel = function() { + Entry.Model(this); +}; +Entry.BlockModel.prototype.schema = {id:null, x:0, y:0, type:null, params:{}, statements:{}, prev:null, next:null, view:null}; +Entry.BlockRenderModel = function() { + Entry.Model(this); +}; +Entry.BlockRenderModel.prototype.schema = {id:0, type:Entry.STATIC.BLOCK_RENDER_MODEL, x:0, y:0, width:0, height:0, magneting:!1}; +Entry.BoxModel = function() { + Entry.Model(this); +}; +Entry.BoxModel.prototype.schema = {id:0, type:Entry.STATIC.BOX_MODEL, x:0, y:0, width:0, height:0}; +Entry.DragInstance = function(b) { + Entry.Model(this); + this.set(b); +}; +Entry.DragInstance.prototype.schema = {type:Entry.STATIC.DRAG_INSTANCE, startX:0, startY:0, offsetX:0, offsetY:0, absX:0, absY:0, prev:null, height:0, mode:0, isNew:!1}; +Entry.ThreadModel = function() { + Entry.Model(this); +}; +Entry.ThreadModel.prototype.schema = {id:0, type:Entry.STATIC.THREAD_MODEL, x:0, y:0, width:0, minWidth:0, height:0}; +Entry.Stage = function() { + this.variables = {}; + this.background = new createjs.Shape; + this.background.graphics.beginFill("#ffffff").drawRect(-480, -240, 960, 480); + this.objectContainers = []; + this.selectedObjectContainer = null; + this.variableContainer = new createjs.Container; + this.dialogContainer = new createjs.Container; + this.selectedObject = null; + this.isObjectClick = !1; +}; +Entry.Stage.prototype.initStage = function(b) { + this.canvas = new createjs.Stage(b.id); + this.canvas.x = 320; + this.canvas.y = 180; + this.canvas.scaleX = this.canvas.scaleY = 2 / 1.5; + createjs.Touch.enable(this.canvas); + this.canvas.enableMouseOver(10); + this.canvas.mouseMoveOutside = !0; + this.canvas.addChild(this.background); + this.canvas.addChild(this.variableContainer); + this.canvas.addChild(this.dialogContainer); + this.inputField = null; + this.initCoordinator(); + this.initHandle(); + this.mouseCoordinate = {x:0, y:0}; + if (Entry.isPhone()) { + b.ontouchstart = function(a) { + Entry.dispatchEvent("canvasClick", a); + Entry.stage.isClick = !0; + }, b.ontouchend = function(a) { + Entry.stage.isClick = !1; + Entry.dispatchEvent("canvasClickCanceled", a); + }; + } else { + var a = function(a) { + Entry.dispatchEvent("canvasClick", a); + Entry.stage.isClick = !0; + }; + b.onmousedown = a; + b.ontouchstart = a; + a = function(a) { + Entry.stage.isClick = !1; + Entry.dispatchEvent("canvasClickCanceled", a); + }; + b.onmouseup = a; + b.ontouchend = a; + $(document).click(function(a) { + Entry.stage.focused = "entryCanvas" === a.target.id ? !0 : !1; + }); + } + Entry.addEventListener("canvasClick", function(a) { + Entry.stage.isObjectClick = !1; + }); + Entry.windowResized.attach(this, function() { + Entry.stage.updateBoundRect(); + }); + a = function(a) { + a.preventDefault(); + var b = Entry.stage.getBoundRect(), e; + -1 < Entry.getBrowserType().indexOf("IE") ? (e = 480 * ((a.pageX - b.left - document.documentElement.scrollLeft) / b.width - .5), a = -270 * ((a.pageY - b.top - document.documentElement.scrollTop) / b.height - .5)) : a.changedTouches ? (e = 480 * ((a.changedTouches[0].pageX - b.left - document.body.scrollLeft) / b.width - .5), a = -270 * ((a.changedTouches[0].pageY - b.top - document.body.scrollTop) / b.height - .5)) : (e = 480 * ((a.pageX - b.left - document.body.scrollLeft) / b.width - .5), + a = -270 * ((a.pageY - b.top - document.body.scrollTop) / b.height - .5)); + Entry.stage.mouseCoordinate = {x:e.toFixed(1), y:a.toFixed(1)}; + Entry.dispatchEvent("stageMouseMove"); + }; + b.onmousemove = a; + b.ontouchmove = a; + b.onmouseout = function(a) { + Entry.dispatchEvent("stageMouseOut"); }; - b._alignNSList = function(a, b) { - var d = this._rect.width; - initX = -this._rect.width / 2 + 10; - initY = -this._rect.height / 2 + 10; - for (var e = listLine = wholeWidth = 0;e < a.length;e++) { - wholeWidth += a[e].width; + Entry.addEventListener("updateObject", function(a) { + Entry.engine.isState("stop") && Entry.stage.updateObject(); + }); + Entry.addEventListener("canvasInputComplete", function(a) { + try { + var b = Entry.stage.inputField.value(); + Entry.stage.hideInputField(); + if (b) { + var e = Entry.container; + e.setInputValue(b); + e.inputValue.complete = !0; + } + } catch (f) { } - for (var f = 0, g = 0, h = initX, k = 0, l = 0, q = 0, e = 0;e < a.length;e++) { - l = a[e], e != a.length - 1 && (q = a[e + 1]), g += l.width, lP = initX, k = initY + 30 * f, l.group.attr({transform:"translate(" + lP + "," + k + ")"}), initX += l.width + 10, g > d - (l.width + q.width / 2.2) && (f += 1, initX = h, g = 0); + }); + this.initWall(); + this.render(); +}; +Entry.Stage.prototype.render = function() { + Entry.stage.timer && clearTimeout(Entry.stage.timer); + var b = (new Date).getTime(); + Entry.stage.update(); + b = (new Date).getTime() - b; + Entry.stage.timer = setTimeout(Entry.stage.render, 16 - b % 16 + 16 * Math.floor(b / 16)); +}; +Entry.Stage.prototype.update = function() { + Entry.requestUpdate ? (Entry.engine.isState("stop") && this.objectUpdated ? (this.canvas.update(), this.objectUpdated = !1) : this.canvas.update(), this.inputField && !this.inputField._isHidden && this.inputField.render(), Entry.requestUpdateTwice ? Entry.requestUpdateTwice = !1 : Entry.requestUpdate = !1) : Entry.requestUpdate = !1; +}; +Entry.Stage.prototype.loadObject = function(b) { + var a = b.entity.object; + this.getObjectContainerByScene(b.scene).addChild(a); + this.canvas.update(); +}; +Entry.Stage.prototype.loadEntity = function(b) { + Entry.stage.getObjectContainerByScene(b.parent.scene).addChild(b.object); + this.sortZorder(); +}; +Entry.Stage.prototype.unloadEntity = function(b) { + Entry.stage.getObjectContainerByScene(b.parent.scene).removeChild(b.object); +}; +Entry.Stage.prototype.loadVariable = function(b) { + var a = b.view_; + this.variables[b.id] = a; + this.variableContainer.addChild(a); + Entry.requestUpdate = !0; +}; +Entry.Stage.prototype.removeVariable = function(b) { + this.variableContainer.removeChild(b.view_); + Entry.requestUpdate = !0; +}; +Entry.Stage.prototype.loadDialog = function(b) { + this.dialogContainer.addChild(b.object); +}; +Entry.Stage.prototype.unloadDialog = function(b) { + this.dialogContainer.removeChild(b.object); +}; +Entry.Stage.prototype.sortZorder = function() { + for (var b = Entry.container.getCurrentObjects(), a = this.selectedObjectContainer, c = 0, d = b.length - 1;0 <= d;d--) { + for (var e = b[d], f = e.entity, e = e.clonedEntities, g = 0, h = e.length;g < h;g++) { + e[g].shape && a.setChildIndex(e[g].shape, c++), a.setChildIndex(e[g].object, c++); } - }; - b._movePort = function(a, b, d, e) { - var f = b, g = a.box.x * this.scale, h = a.box.y * this.scale; - b > e ? (f = b - a.width, b = b > g && g > e ? "M" + g + "," + d + "L" + g + "," + h : "M" + (b + e) / 2 + "," + d + "l0," + (h > d ? 28 : -3) + "H" + g + "L" + g + "," + h) : b = b < g && g < e ? "m" + g + "," + d + "L" + g + "," + h : "m" + (e + b) / 2 + "," + d + "l0," + (h > d ? 28 : -3) + "H" + g + "L" + g + "," + h; - a.group.attr({transform:"translate(" + f + "," + d + ")"}); - a.path.attr({d:b}); - }; -})(Entry.HWMonitor.prototype); -Entry.HW = function() { - this.connectTrial = 0; - this.isFirstConnect = !0; - this.initSocket(); - this.connected = !1; - this.portData = {}; - this.sendQueue = {}; - this.outputQueue = {}; - this.settingQueue = {}; - this.socketType = this.hwModule = this.selectedDevice = null; - Entry.addEventListener("stop", this.setZero); - this.hwInfo = {11:Entry.Arduino, 12:Entry.SensorBoard, 13:Entry.CODEino, 14:Entry.joystick, 15:Entry.dplay, 16:Entry.nemoino, 17:Entry.Xbot, 18:Entry.ardublock, 24:Entry.Hamster, 25:Entry.Albert, 31:Entry.Bitbrick, 42:Entry.Arduino, 51:Entry.Neobot, 71:Entry.Robotis_carCont, 72:Entry.Robotis_openCM70, 81:Entry.Arduino}; + f.shape && a.setChildIndex(f.shape, c++); + a.setChildIndex(f.object, c++); + } }; -Entry.HW.TRIAL_LIMIT = 1; -p = Entry.HW.prototype; -p.initSocket = function() { - try { - if (this.connectTrial >= Entry.HW.TRIAL_LIMIT) { - this.isFirstConnect || Entry.toast.alert(Lang.Menus.connect_hw, Lang.Menus.connect_fail, !1), this.isFirstConnect = !1; - } else { - var b = this, a, c; - this.connected = !1; - this.connectTrial++; - if (-1 < location.protocol.indexOf("https")) { - c = new WebSocket("wss://hardware.play-entry.org:23518"); - } else { - try { - a = new WebSocket("ws://127.0.0.1:23518"), a.binaryType = "arraybuffer", a.onopen = function() { - b.socketType = "WebSocket"; - b.initHardware(a); - }.bind(this), a.onmessage = function(a) { - a = JSON.parse(a.data); - b.checkDevice(a); - b.updatePortData(a); - }.bind(this), a.onclose = function() { - "WebSocket" === b.socketType && (this.socket = null, b.initSocket()); - }; - } catch (d) { - } - try { - c = new WebSocket("wss://hardware.play-entry.org:23518"); - } catch (d) { +Entry.Stage.prototype.initCoordinator = function() { + var b = new createjs.Container, a = new createjs.Bitmap(Entry.mediaFilePath + "workspace_coordinate.png"); + a.scaleX = .5; + a.scaleY = .5; + a.x = -240; + a.y = -135; + b.addChild(a); + this.canvas.addChild(b); + b.visible = !1; + this.coordinator = b; +}; +Entry.Stage.prototype.toggleCoordinator = function() { + this.coordinator.visible = !this.coordinator.visible; +}; +Entry.Stage.prototype.selectObject = function(b) { + this.selectedObject = b ? b : null; + this.updateObject(); +}; +Entry.Stage.prototype.initHandle = function() { + this.handle = new EaselHandle(this.canvas); + this.handle.setChangeListener(this, this.updateHandle); + this.handle.setEditStartListener(this, this.startEdit); + this.handle.setEditEndListener(this, this.endEdit); +}; +Entry.Stage.prototype.updateObject = function() { + Entry.requestUpdate = !0; + this.handle.setDraggable(!0); + if (!this.editEntity) { + var b = this.selectedObject; + if (b) { + "textBox" == b.objectType ? this.handle.toggleCenter(!1) : this.handle.toggleCenter(!0); + "free" == b.getRotateMethod() ? this.handle.toggleRotation(!0) : this.handle.toggleRotation(!1); + this.handle.toggleDirection(!0); + b.getLock() ? (this.handle.toggleRotation(!1), this.handle.toggleDirection(!1), this.handle.toggleResize(!1), this.handle.toggleCenter(!1), this.handle.setDraggable(!1)) : this.handle.toggleResize(!0); + this.handle.setVisible(!0); + var a = b.entity; + this.handle.setWidth(a.getScaleX() * a.getWidth()); + this.handle.setHeight(a.getScaleY() * a.getHeight()); + var c, d; + if ("textBox" == a.type) { + if (a.getLineBreak()) { + c = a.regX * a.scaleX, d = -a.regY * a.scaleY; + } else { + var e = a.getTextAlign(); + d = -a.regY * a.scaleY; + switch(e) { + case Entry.TEXT_ALIGN_LEFT: + c = -a.getWidth() / 2 * a.scaleX; + break; + case Entry.TEXT_ALIGN_CENTER: + c = a.regX * a.scaleX; + break; + case Entry.TEXT_ALIGN_RIGHT: + c = a.getWidth() / 2 * a.scaleX; + } } + } else { + c = (a.regX - a.width / 2) * a.scaleX, d = (a.height / 2 - a.regY) * a.scaleY; } - c.binaryType = "arraybuffer"; - c.onopen = function() { - b.socketType = "WebSocketSecurity"; - b.initHardware(c); - }; - c.onmessage = function(a) { - a = JSON.parse(a.data); - b.checkDevice(a); - b.updatePortData(a); - }; - c.onclose = function() { - "WebSocketSecurity" === b.socketType && (this.socket = null, b.initSocket()); - }; - Entry.dispatchEvent("hwChanged"); + e = a.getRotation() / 180 * Math.PI; + this.handle.setX(a.getX() - c * Math.cos(e) - d * Math.sin(e)); + this.handle.setY(-a.getY() - c * Math.sin(e) + d * Math.cos(e)); + this.handle.setRegX((a.regX - a.width / 2) * a.scaleX); + this.handle.setRegY((a.regY - a.height / 2) * a.scaleY); + this.handle.setRotation(a.getRotation()); + this.handle.setDirection(a.getDirection()); + this.objectUpdated = !0; + this.handle.setVisible(b.entity.getVisible()); + b.entity.getVisible() && this.handle.render(); + } else { + this.handle.setVisible(!1); } - } catch (d) { - } -}; -p.retryConnect = function() { - this.connectTrial = 0; - this.initSocket(); -}; -p.initHardware = function(b) { - this.socket = b; - this.connectTrial = 0; - this.connected = !0; - Entry.dispatchEvent("hwChanged"); - Entry.playground && Entry.playground.object && Entry.playground.setMenu(Entry.playground.object.objectType); -}; -p.setDigitalPortValue = function(b, a) { - this.sendQueue[b] = a; - this.removePortReadable(b); -}; -p.getAnalogPortValue = function(b) { - return this.connected ? this.portData["a" + b] : 0; -}; -p.getDigitalPortValue = function(b) { - if (!this.connected) { - return 0; } - this.setPortReadable(b); - return void 0 !== this.portData[b] ? this.portData[b] : 0; }; -p.setPortReadable = function(b) { - this.sendQueue.readablePorts || (this.sendQueue.readablePorts = []); - var a = !1, c; - for (c in this.sendQueue.readablePorts) { - if (this.sendQueue.readablePorts[c] == b) { - a = !0; - break; +Entry.Stage.prototype.updateHandle = function() { + this.editEntity = !0; + var b = this.handle, a = this.selectedObject.entity; + if (a.lineBreak) { + a.setHeight(b.height / a.getScaleY()), a.setWidth(b.width / a.getScaleX()); + } else { + if (0 !== a.width) { + var c = Math.abs(b.width / a.width); + a.flip && (c *= -1); + a.setScaleX(c); } + 0 !== a.height && a.setScaleY(b.height / a.height); } - a || this.sendQueue.readablePorts.push(b); -}; -p.removePortReadable = function(b) { - if (this.sendQueue.readablePorts || Array.isArray(this.sendQueue.readablePorts)) { - var a, c; - for (c in this.sendQueue.readablePorts) { - if (this.sendQueue.readablePorts[c] == b) { - a = Number(c); - break; + c = b.rotation / 180 * Math.PI; + if ("textBox" == a.type) { + var d = b.regX / a.scaleX, d = b.regY / a.scaleY; + if (a.getLineBreak()) { + a.setX(b.x), a.setY(-b.y); + } else { + switch(a.getTextAlign()) { + case Entry.TEXT_ALIGN_LEFT: + a.setX(b.x - b.width / 2 * Math.cos(c)); + a.setY(-b.y + b.width / 2 * Math.sin(c)); + break; + case Entry.TEXT_ALIGN_CENTER: + a.setX(b.x); + a.setY(-b.y); + break; + case Entry.TEXT_ALIGN_RIGHT: + a.setX(b.x + b.width / 2 * Math.cos(c)), a.setY(-b.y - b.width / 2 * Math.sin(c)); } } - this.sendQueue.readablePorts = void 0 != a ? this.sendQueue.readablePorts.slice(0, a).concat(this.sendQueue.readablePorts.slice(a + 1, this.sendQueue.readablePorts.length)) : []; + } else { + d = a.width / 2 + b.regX / a.scaleX, a.setX(b.x + b.regX * Math.cos(c) - b.regY * Math.sin(c)), a.setRegX(d), d = a.height / 2 + b.regY / a.scaleY, a.setY(-b.y - b.regX * Math.sin(c) - b.regY * Math.cos(c)), a.setRegY(d); } + a.setDirection(b.direction); + a.setRotation(b.rotation); + this.selectedObject.entity.doCommand(); + this.editEntity = !1; }; -p.update = function() { - this.socket && 1 == this.socket.readyState && this.socket.send(JSON.stringify(this.sendQueue)); +Entry.Stage.prototype.startEdit = function() { + this.selectedObject.entity.initCommand(); }; -p.updatePortData = function(b) { - this.portData = b; - this.hwMonitor && this.hwMonitor.update(); +Entry.Stage.prototype.endEdit = function() { + this.selectedObject.entity.checkCommand(); }; -p.closeConnection = function() { - this.socket && this.socket.close(); +Entry.Stage.prototype.initWall = function() { + var b = new createjs.Container, a = new Image; + a.src = Entry.mediaFilePath + "media/bound.png"; + b.up = new createjs.Bitmap; + b.up.scaleX = 16; + b.up.y = -165; + b.up.x = -240; + b.up.image = a; + b.addChild(b.up); + b.down = new createjs.Bitmap; + b.down.scaleX = 16; + b.down.y = 135; + b.down.x = -240; + b.down.image = a; + b.addChild(b.down); + b.right = new createjs.Bitmap; + b.right.scaleY = 9; + b.right.y = -135; + b.right.x = 240; + b.right.image = a; + b.addChild(b.right); + b.left = new createjs.Bitmap; + b.left.scaleY = 9; + b.left.y = -135; + b.left.x = -270; + b.left.image = a; + b.addChild(b.left); + this.canvas.addChild(b); + this.wall = b; }; -p.downloadConnector = function() { - window.open("http://download.play-entry.org/apps/Entry_HW_1.5.6_Setup.exe", "_blank").focus(); +Entry.Stage.prototype.showInputField = function(b) { + b = 1 / 1.5; + this.inputField || (this.inputField = new CanvasInput({canvas:document.getElementById("entryCanvas"), fontSize:30 * b, fontFamily:"NanumGothic", fontColor:"#212121", width:556 * b, height:26 * b, padding:8 * b, borderWidth:1 * b, borderColor:"#000", borderRadius:3 * b, boxShadow:"none", innerShadow:"0px 0px 5px rgba(0, 0, 0, 0.5)", x:202 * b, y:450 * b, topPosition:!0, onsubmit:function() { + Entry.dispatchEvent("canvasInputComplete"); + }})); + b = new createjs.Container; + var a = new Image; + a.src = Entry.mediaFilePath + "confirm_button.png"; + var c = new createjs.Bitmap; + c.scaleX = .23; + c.scaleY = .23; + c.x = 160; + c.y = 89; + c.cursor = "pointer"; + c.image = a; + b.addChild(c); + b.on("mousedown", function(a) { + Entry.dispatchEvent("canvasInputComplete"); + }); + this.inputSubmitButton || (this.inputField.value(""), this.canvas.addChild(b), this.inputSubmitButton = b); + this.inputField.show(); + Entry.requestUpdateTwice = !0; }; -p.downloadSource = function() { - window.open("http://play-entry.com/down/board.ino", "_blank").focus(); +Entry.Stage.prototype.hideInputField = function() { + this.inputField && this.inputField.value() && this.inputField.value(""); + this.inputSubmitButton && (this.canvas.removeChild(this.inputSubmitButton), this.inputSubmitButton = null); + this.inputField && this.inputField.hide(); + Entry.requestUpdate = !0; }; -p.setZero = function() { - Entry.hw.hwModule && Entry.hw.hwModule.setZero(); +Entry.Stage.prototype.initObjectContainers = function() { + var b = Entry.scene.scenes_; + if (b && 0 !== b.length) { + for (var a = 0;a < b.length;a++) { + this.objectContainers[a] = this.createObjectContainer(b[a]); + } + this.selectedObjectContainer = this.objectContainers[0]; + } else { + b = this.createObjectContainer(Entry.scene.selectedScene), this.objectContainers.push(b), this.selectedObjectContainer = b; + } + this.canvas.addChild(this.selectedObjectContainer); + this.selectObjectContainer(Entry.scene.selectedScene); }; -p.checkDevice = function(b) { - void 0 !== b.company && (b = "" + b.company + b.model, b != this.selectedDevice && (this.selectedDevice = b, this.hwModule = this.hwInfo[b], Entry.dispatchEvent("hwChanged"), Entry.toast.success("\ud558\ub4dc\uc6e8\uc5b4 \uc5f0\uacb0 \uc131\uacf5", "\ud558\ub4dc\uc6e8\uc5b4 \uc544\uc774\ucf58\uc744 \ub354\ube14\ud074\ub9ad\ud558\uba74, \uc13c\uc11c\uac12\ub9cc \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.", !0), this.hwModule.monitorTemplate && (this.hwMonitor ? (this.hwMonitor._hwModule = - this.hwModule, this.hwMonitor.initView()) : this.hwMonitor = new Entry.HWMonitor(this.hwModule), Entry.propertyPanel.addMode("hw", this.hwMonitor), b = this.hwModule.monitorTemplate, "both" == b.mode ? (b.mode = "list", this.hwMonitor.generateListView(), b.mode = "general", this.hwMonitor.generateView(), b.mode = "both") : "list" == b.mode ? this.hwMonitor.generateListView() : this.hwMonitor.generateView()))); +Entry.Stage.prototype.selectObjectContainer = function(b) { + if (this.canvas) { + for (var a = this.objectContainers, c = 0;c < a.length;c++) { + this.canvas.removeChild(a[c]); + } + this.selectedObjectContainer = this.getObjectContainerByScene(b); + this.canvas.addChildAt(this.selectedObjectContainer, 2); + } }; -p.banHW = function() { - var b = this.hwInfo, a; - for (a in b) { - Entry.playground.mainWorkspace.blockMenu.banClass(b[a].name, !0); +Entry.Stage.prototype.reAttachToCanvas = function() { + for (var b = [this.selectedObjectContainer, this.variableContainer, this.coordinator, this.handle, this.dialogContainer], a = 0;a < b.length;a++) { + this.canvas.removeChild(b[a]), this.canvas.addChild(b[a]); } + console.log(this.canvas.getChildIndex(this.selectedObjectContainer)); }; -Entry.BlockModel = function() { - Entry.Model(this); +Entry.Stage.prototype.createObjectContainer = function(b) { + var a = new createjs.Container; + a.scene = b; + return a; }; -Entry.BlockModel.prototype.schema = {id:null, x:0, y:0, type:null, params:{}, statements:{}, prev:null, next:null, view:null}; -Entry.BlockRenderModel = function() { - Entry.Model(this); +Entry.Stage.prototype.removeObjectContainer = function(b) { + var a = this.objectContainers; + b = this.getObjectContainerByScene(b); + this.canvas.removeChild(b); + a.splice(this.objectContainers.indexOf(b), 1); }; -Entry.BlockRenderModel.prototype.schema = {id:0, type:Entry.STATIC.BLOCK_RENDER_MODEL, x:0, y:0, width:0, height:0, magneting:!1}; -Entry.BoxModel = function() { - Entry.Model(this); +Entry.Stage.prototype.getObjectContainerByScene = function(b) { + for (var a = this.objectContainers, c = 0;c < a.length;c++) { + if (a[c].scene.id == b.id) { + return a[c]; + } + } }; -Entry.BoxModel.prototype.schema = {id:0, type:Entry.STATIC.BOX_MODEL, x:0, y:0, width:0, height:0}; -Entry.DragInstance = function(b) { - Entry.Model(this); - this.set(b); +Entry.Stage.prototype.moveSprite = function(b) { + if (this.selectedObject && Entry.stage.focused && !this.selectedObject.getLock()) { + var a = 5; + b.shiftKey && (a = 1); + var c = this.selectedObject.entity; + switch(b.keyCode) { + case 38: + c.setY(c.getY() + a); + break; + case 40: + c.setY(c.getY() - a); + break; + case 37: + c.setX(c.getX() - a); + break; + case 39: + c.setX(c.getX() + a); + } + this.updateObject(); + } }; -Entry.DragInstance.prototype.schema = {type:Entry.STATIC.DRAG_INSTANCE, startX:0, startY:0, offsetX:0, offsetY:0, absX:0, absY:0, prev:null, height:0, mode:0, isNew:!1}; -Entry.ThreadModel = function() { - Entry.Model(this); +Entry.Stage.prototype.getBoundRect = function(b) { + this._boundRect || this.updateBoundRect(); + return this._boundRect; +}; +Entry.Stage.prototype.updateBoundRect = function(b) { + this._boundRect = this.canvas.canvas.getBoundingClientRect(); }; -Entry.ThreadModel.prototype.schema = {id:0, type:Entry.STATIC.THREAD_MODEL, x:0, y:0, width:0, minWidth:0, height:0}; Entry.Variable = function(b) { Entry.assert("string" == typeof b.name, "Variable name must be given"); this.name_ = b.name; @@ -13083,6 +13125,7 @@ Entry.Variable = function(b) { this.type = b.variableType ? b.variableType : "variable"; this.object_ = b.object || null; this.isCloud_ = b.isCloud || !1; + this._valueWidth = this._nameWidth = null; var a = Entry.parseNumber(b.value); this.value_ = "number" == typeof a ? a : b.value ? b.value : 0; "slide" == this.type ? (this.minValue_ = Number(b.minValue ? b.minValue : 0), this.maxValue_ = Number(b.maxValue ? b.maxValue : 100)) : "list" == this.type && (this.array_ = b.array ? b.array : []); @@ -13188,58 +13231,64 @@ Entry.Variable.prototype.generateView = function(b) { Entry.stage.loadVariable(this); }; Entry.Variable.prototype.updateView = function() { - if (this.view_ && this.isVisible()) { - if ("variable" == this.type) { - this.view_.x = this.getX(); - this.view_.y = this.getY(); - if (this.object_) { - var b = Entry.container.getObject(this.object_); - this.textView_.text = b ? b.name + ":" + this.getName() : this.getName(); - } else { - this.textView_.text = this.getName(); - } - this.valueView_.x = this.textView_.getMeasuredWidth() + 14; - this.valueView_.y = 1; - this.isNumber() ? this.valueView_.text = this.getValue().toFixed(2).replace(".00", "") : this.valueView_.text = this.getValue(); - this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1").rc(0, -14, this.textView_.getMeasuredWidth() + this.valueView_.getMeasuredWidth() + 26, 20, 4, 4, 4, 4); - this.wrapper_.graphics.clear().f("#1bafea").ss(1, 2, 0).s("#1bafea").rc(this.textView_.getMeasuredWidth() + 7, -11, this.valueView_.getMeasuredWidth() + 15, 14, 7, 7, 7, 7); - } else { - if ("slide" == this.type) { - this.view_.x = this.getX(), this.view_.y = this.getY(), this.object_ ? (b = Entry.container.getObject(this.object_), this.textView_.text = b ? b.name + ":" + this.getName() : this.getName()) : this.textView_.text = this.getName(), this.valueView_.x = this.textView_.getMeasuredWidth() + 14, this.valueView_.y = 1, this.isNumber() ? this.valueView_.text = this.getValue().toFixed(2).replace(".00", "") : this.valueView_.text = this.getValue(), b = this.textView_.getMeasuredWidth() + this.valueView_.getMeasuredWidth() + - 26, b = Math.max(b, 90), this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1").rc(0, -14, b, 33, 4, 4, 4, 4), this.wrapper_.graphics.clear().f("#1bafea").ss(1, 2, 0).s("#1bafea").rc(this.textView_.getMeasuredWidth() + 7, -11, this.valueView_.getMeasuredWidth() + 15, 14, 7, 7, 7, 7), b = this.textView_.getMeasuredWidth() + this.valueView_.getMeasuredWidth() + 26, b = Math.max(b, 90), this.maxWidth = b - 20, this.slideBar_.graphics.clear().beginFill("#A0A1A1").s("#A0A1A1").ss(1).dr(10, - 10, this.maxWidth, 1.5), b = this.getSlidePosition(this.maxWidth), this.valueSetter_.graphics.clear().beginFill("#1bafea").s("#A0A1A1").ss(1).dc(b, 10.5, 3); + if (this.view_) { + if (this.isVisible()) { + if ("variable" == this.type) { + this.view_.x = this.getX(); + this.view_.y = this.getY(); + if (this.object_) { + var b = Entry.container.getObject(this.object_); + this.textView_.text = b ? b.name + ":" + this.getName() : this.getName(); + } else { + this.textView_.text = this.getName(); + } + null === this._nameWidth && (this._nameWidth = this.textView_.getMeasuredWidth()); + this.valueView_.x = this._nameWidth + 14; + this.valueView_.y = 1; + this.isNumber() ? this.valueView_.text = this.getValue().toFixed(2).replace(".00", "") : this.valueView_.text = this.getValue(); + null === this._valueWidth && (this._valueWidth = this.valueView_.getMeasuredWidth()); + this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1").rc(0, -14, this._nameWidth + this._valueWidth + 26, 20, 4, 4, 4, 4); + this.wrapper_.graphics.clear().f("#1bafea").ss(1, 2, 0).s("#1bafea").rc(this._nameWidth + 7, -11, this._valueWidth + 15, 14, 7, 7, 7, 7); } else { - if ("list" == this.type) { - this.view_.x = this.getX(); - this.view_.y = this.getY(); - this.resizeHandle_.x = this.width_ - 2; - this.resizeHandle_.y = this.height_ - 2; - var a = this.getName(); - this.object_ && (b = Entry.container.getObject(this.object_)) && (a = b.name + ":" + a); - a = 7 < a.length ? a.substr(0, 6) + ".." : a; - this.titleView_.text = a; - this.titleView_.x = this.width_ / 2; - for (this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1").rect(0, 0, this.width_, this.height_);this.view_.children[4];) { - this.view_.removeChild(this.view_.children[4]); - } - b = Math.floor((this.getHeight() - 20) / 20); - b < this.array_.length ? (this.scrollButton_.y > this.getHeight() - 40 && (this.scrollButton_.y = this.getHeight() - 40), this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20, -2, this.getWidth() - 20 - 10 - 2 * this.BORDER, 17, 2), this.scrollButton_.visible = !0, this.scrollButton_.x = this.getWidth() - 12, this.scrollPosition = Math.floor((this.scrollButton_.y - 23) / (this.getHeight() - 23 - 40) * (this.array_.length - b))) : (this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20, - -2, this.getWidth() - 20 - 2 * this.BORDER, 17, 2), this.scrollButton_.visible = !1, this.scrollPosition = 0); - for (a = this.scrollPosition;a < this.scrollPosition + b && a < this.array_.length;a++) { - this.elementView.indexView.text = a + 1; - var c = String(this.array_[a].data), d = Math.floor((this.getWidth() - 50) / 7), c = Entry.cutStringByLength(c, d), c = String(this.array_[a].data).length > c.length ? c + ".." : c; - this.elementView.valueView.text = c; - c = this.elementView.clone(!0); - c.y = 20 * (a - this.scrollPosition) + 23; - this.view_.addChild(c); - } + if ("slide" == this.type) { + this.view_.x = this.getX(), this.view_.y = this.getY(), this.object_ ? (b = Entry.container.getObject(this.object_), this.textView_.text = b ? b.name + ":" + this.getName() : this.getName()) : this.textView_.text = this.getName(), null === this._nameWidth && (this._nameWidth = this.textView_.getMeasuredWidth()), this.valueView_.x = this._nameWidth + 14, this.valueView_.y = 1, this.isNumber() ? this.valueView_.text = this.getValue().toFixed(2).replace(".00", "") : this.valueView_.text = + this.getValue(), null === this._valueWidth && (this._valueWidth = this.valueView_.getMeasuredWidth()), b = this._nameWidth + this._valueWidth + 26, b = Math.max(b, 90), this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1").rc(0, -14, b, 33, 4, 4, 4, 4), this.wrapper_.graphics.clear().f("#1bafea").ss(1, 2, 0).s("#1bafea").rc(this._nameWidth + 7, -11, this._valueWidth + 15, 14, 7, 7, 7, 7), b = this._nameWidth + this._valueWidth + 26, b = Math.max(b, 90), this.maxWidth = b - 20, + this.slideBar_.graphics.clear().beginFill("#A0A1A1").s("#A0A1A1").ss(1).dr(10, 10, this.maxWidth, 1.5), b = this.getSlidePosition(this.maxWidth), this.valueSetter_.graphics.clear().beginFill("#1bafea").s("#A0A1A1").ss(1).dc(b, 10.5, 3); } else { - "answer" == this.type ? (this.view_.x = this.getX(), this.view_.y = this.getY(), this.textView_.text = this.getName(), this.valueView_.x = this.textView_.getMeasuredWidth() + 14, this.valueView_.y = 1, this.isNumber() ? parseInt(this.getValue(), 10) == this.getValue() ? this.valueView_.text = this.getValue() : this.valueView_.text = this.getValue().toFixed(1).replace(".00", "") : this.valueView_.text = this.getValue(), this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1").rc(0, - -14, this.textView_.getMeasuredWidth() + this.valueView_.getMeasuredWidth() + 26, 20, 4, 4, 4, 4), this.wrapper_.graphics.clear().f("#E457DC").ss(1, 2, 0).s("#E457DC").rc(this.textView_.getMeasuredWidth() + 7, -11, this.valueView_.getMeasuredWidth() + 15, 14, 7, 7, 7, 7)) : (this.view_.x = this.getX(), this.view_.y = this.getY(), this.textView_.text = this.getName(), this.valueView_.x = this.textView_.getMeasuredWidth() + 14, this.valueView_.y = 1, this.isNumber() ? this.valueView_.text = - this.getValue().toFixed(1).replace(".00", "") : this.valueView_.text = this.getValue(), this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1").rc(0, -14, this.textView_.getMeasuredWidth() + this.valueView_.getMeasuredWidth() + 26, 20, 4, 4, 4, 4), this.wrapper_.graphics.clear().f("#ffbb14").ss(1, 2, 0).s("orange").rc(this.textView_.getMeasuredWidth() + 7, -11, this.valueView_.getMeasuredWidth() + 15, 14, 7, 7, 7, 7)); + if ("list" == this.type) { + this.view_.x = this.getX(); + this.view_.y = this.getY(); + this.resizeHandle_.x = this.width_ - 2; + this.resizeHandle_.y = this.height_ - 2; + var a = this.getName(); + this.object_ && (b = Entry.container.getObject(this.object_)) && (a = b.name + ":" + a); + a = 7 < a.length ? a.substr(0, 6) + ".." : a; + this.titleView_.text = a; + this.titleView_.x = this.width_ / 2; + for (this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1").rect(0, 0, this.width_, this.height_);this.view_.children[4];) { + this.view_.removeChild(this.view_.children[4]); + } + b = Math.floor((this.getHeight() - 20) / 20); + b < this.array_.length ? (this.scrollButton_.y > this.getHeight() - 40 && (this.scrollButton_.y = this.getHeight() - 40), this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20, -2, this.getWidth() - 20 - 10 - 2 * this.BORDER, 17, 2), this.scrollButton_.visible = !0, this.scrollButton_.x = this.getWidth() - 12, this.scrollPosition = Math.floor((this.scrollButton_.y - 23) / (this.getHeight() - 23 - 40) * (this.array_.length - b))) : (this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20, + -2, this.getWidth() - 20 - 2 * this.BORDER, 17, 2), this.scrollButton_.visible = !1, this.scrollPosition = 0); + for (a = this.scrollPosition;a < this.scrollPosition + b && a < this.array_.length;a++) { + this.elementView.indexView.text = a + 1; + var c = String(this.array_[a].data), d = Math.floor((this.getWidth() - 50) / 7), c = Entry.cutStringByLength(c, d), c = String(this.array_[a].data).length > c.length ? c + ".." : c; + this.elementView.valueView.text = c; + c = this.elementView.clone(!0); + c.y = 20 * (a - this.scrollPosition) + 23; + this.view_.addChild(c); + } + } else { + "answer" == this.type ? (this.view_.x = this.getX(), this.view_.y = this.getY(), this.textView_.text = this.getName(), this.valueView_.y = 1, this.isNumber() ? parseInt(this.getValue(), 10) == this.getValue() ? this.valueView_.text = this.getValue() : this.valueView_.text = this.getValue().toFixed(1).replace(".00", "") : this.valueView_.text = this.getValue(), null === this._nameWidth && (this._nameWidth = this.textView_.getMeasuredWidth()), null === this._valueWidth && (this._valueWidth = + this.valueView_.getMeasuredWidth()), this.valueView_.x = this._nameWidth + 14, this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1").rc(0, -14, this._nameWidth + this._valueWidth + 26, 20, 4, 4, 4, 4), this.wrapper_.graphics.clear().f("#E457DC").ss(1, 2, 0).s("#E457DC").rc(this._nameWidth + 7, -11, this._valueWidth + 15, 14, 7, 7, 7, 7)) : (this.view_.x = this.getX(), this.view_.y = this.getY(), this.textView_.text = this.getName(), null === this._nameWidth && (this._nameWidth = + this.textView_.getMeasuredWidth()), this.valueView_.x = this._nameWidth + 14, this.valueView_.y = 1, this.isNumber() ? this.valueView_.text = this.getValue().toFixed(1).replace(".00", "") : this.valueView_.text = this.getValue(), null === this._valueWidth && (this._valueWidth = this.valueView_.getMeasuredWidth()), this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1").rc(0, -14, this._nameWidth + this._valueWidth + 26, 20, 4, 4, 4, 4), this.wrapper_.graphics.clear().f("#ffbb14").ss(1, + 2, 0).s("orange").rc(this._nameWidth + 7, -11, this._valueWidth + 15, 14, 7, 7, 7, 7)); + } } } } + Entry.requestUpdate = !0; } }; Entry.Variable.prototype.getName = function() { @@ -13248,7 +13297,9 @@ Entry.Variable.prototype.getName = function() { Entry.Variable.prototype.setName = function(b) { Entry.assert("string" == typeof b, "Variable name must be string"); this.name_ = b; + this._nameWidth = null; this.updateView(); + Entry.requestUpdateTwice = !0; }; Entry.Variable.prototype.getId = function() { return this.id_; @@ -13262,14 +13313,16 @@ Entry.Variable.prototype.isNumber = function() { Entry.Variable.prototype.setValue = function(b) { "slide" != this.type ? this.value_ = b : (b = Number(b), this.value_ = b < this.minValue_ ? this.minValue_ : b > this.maxValue_ ? this.maxValue_ : b); this.isCloud_ && Entry.variableContainer.updateCloudVariables(); + this._valueWidth = null; this.updateView(); + Entry.requestUpdateTwice = !0; }; Entry.Variable.prototype.isVisible = function() { return this.visible_; }; Entry.Variable.prototype.setVisible = function(b) { Entry.assert("boolean" == typeof b, "Variable visible state must be boolean"); - (this.visible_ = this.view_.visible = b) && this.updateView(); + this.visible !== b && (this.visible_ = this.view_.visible = b, this.updateView()); }; Entry.Variable.prototype.setX = function(b) { this.x_ = b; @@ -13821,7 +13874,7 @@ Entry.VariableContainer.prototype.removeVariable = function(b) { return new Entry.State(this, this.addVariable, c); }; Entry.VariableContainer.prototype.changeVariableName = function(b, a) { - b.name_ != a && (Entry.isExist(a, "name_", this.variables_) ? (b.listElement.nameField.value = b.name_, Entry.toast.alert(Lang.Workspace.variable_rename_failed, Lang.Workspace.variable_dup)) : 10 < a.length ? (b.listElement.nameField.value = b.name_, Entry.toast.alert(Lang.Workspace.variable_rename_failed, Lang.Workspace.variable_too_long)) : (b.name_ = a, b.updateView(), Entry.playground.reloadPlayground(), Entry.toast.success(Lang.Workspace.variable_rename, Lang.Workspace.variable_rename_ok))); + b.name_ != a && (Entry.isExist(a, "name_", this.variables_) ? (b.listElement.nameField.value = b.name_, Entry.toast.alert(Lang.Workspace.variable_rename_failed, Lang.Workspace.variable_dup)) : 10 < a.length ? (b.listElement.nameField.value = b.name_, Entry.toast.alert(Lang.Workspace.variable_rename_failed, Lang.Workspace.variable_too_long)) : (b.setName(a), Entry.playground.reloadPlayground(), Entry.toast.success(Lang.Workspace.variable_rename, Lang.Workspace.variable_rename_ok))); }; Entry.VariableContainer.prototype.changeListName = function(b, a) { b.name_ != a && (Entry.isExist(a, "name_", this.lists_) ? (b.listElement.nameField.value = b.name_, Entry.toast.alert(Lang.Workspace.list_rename_failed, Lang.Workspace.list_dup)) : 10 < a.length ? (b.listElement.nameField.value = b.name_, Entry.toast.alert(Lang.Workspace.list_rename_failed, Lang.Workspace.list_too_long)) : (b.name_ = a, b.updateView(), Entry.playground.reloadPlayground(), Entry.toast.success(Lang.Workspace.list_rename, Lang.Workspace.list_rename_ok))); @@ -15177,7 +15230,9 @@ Entry.BlockMenu = function(b, a, c, d) { this.setWidth(); this.svg = Entry.SVG(this._svgId); Entry.Utils.addFilters(this.svg, this.suffix); - this.patternRect = Entry.Utils.addBlockPattern(this.svg, this.suffix); + a = Entry.Utils.addBlockPattern(this.svg, this.suffix); + this.patternRect = a.rect; + this.pattern = a.pattern; this.svgGroup = this.svg.elem("g"); this.svgThreadGroup = this.svgGroup.elem("g"); this.svgThreadGroup.board = this; @@ -15441,6 +15496,10 @@ Entry.BlockMenu = function(b, a, c, d) { }; b.setPatternRectFill = function(a) { this.patternRect.attr({fill:a}); + this.pattern.attr({style:""}); + }; + b.disablePattern = function() { + this.pattern.attr({style:"display: none"}); }; b._clearCategory = function() { this._selectedCategoryView = null; @@ -16091,9 +16150,9 @@ Entry.BlockView.pngMap = {}; b._changeFill = function(a) { var b = this.getBoard(); if (b.patternRect && !b.dragBlock) { - var d = this._path, e = this._fillColor; - a && (b = this.getBoard(), b.setPatternRectFill(e), e = "url(#blockHoverPattern_" + this.getBoard().suffix + ")"); - d.attr({fill:e}); + var d = this._fillColor, e = this._path, b = this.getBoard(); + a ? (b.setPatternRectFill(d), d = "url(#blockHoverPattern_" + this.getBoard().suffix + ")") : b.disablePattern(); + e.attr({fill:d}); } }; b.addActivated = function() { @@ -16571,10 +16630,12 @@ Entry.Scope = function(b, a) { return this.executor.stepInto(this.block.statements[this._getStatementIndex(a, b)]); }; b._getParamIndex = function(a) { - return Entry.block[this.type].paramsKeyMap[a]; + this._schema || (this._schema = Entry.block[this.type]); + return this._schema.paramsKeyMap[a]; }; b._getStatementIndex = function(a) { - return Entry.block[this.type].statementsKeyMap[a]; + this._schema || (this._schema = Entry.block[this.type]); + return this._schema.statementsKeyMap[a]; }; b.die = function() { this.block = null; @@ -17928,7 +17989,9 @@ Entry.Board.OPTION_DOWNLOAD = 3; this.svgBlockGroup.board = this; a.isOverlay ? (this.wrapper.addClass("entryOverlayBoard"), this.generateButtons(), this.suffix = "overlayBoard") : this.suffix = "board"; Entry.Utils.addFilters(this.svg, this.suffix); - this.patternRect = Entry.Utils.addBlockPattern(this.svg, this.suffix); + a = Entry.Utils.addBlockPattern(this.svg, this.suffix); + this.patternRect = a.rect; + this.pattern = a.pattern; }; b.changeCode = function(a) { this.code && this.codeListener && this.code.changeEvent.detach(this.codeListener); @@ -18298,6 +18361,10 @@ Entry.Board.OPTION_DOWNLOAD = 3; }; b.setPatternRectFill = function(a) { this.patternRect.attr({fill:a}); + this.pattern.attr({style:""}); + }; + b.disablePattern = function() { + this.pattern.attr({style:"display: none"}); }; b._removeActivated = function() { this._activatedBlockView && (this._activatedBlockView.removeActivated(), this._activatedBlockView = null); @@ -20001,7 +20068,7 @@ Entry.Playground.prototype.flushPlayground = function() { } }; Entry.Playground.prototype.refreshPlayground = function() { - Entry.playground && Entry.playground.view_ && (this.injectPicture(), this.injectSound()); + Entry.playground && Entry.playground.view_ && ("picture" === this.getViewMode() && this.injectPicture(), "sound" === this.getViewMode() && this.injectSound()); }; Entry.Playground.prototype.updateListViewOrder = function(b) { b = "picture" == b ? this.pictureListView_.childNodes : this.soundListView_.childNodes; diff --git a/dist/entry.min.js b/dist/entry.min.js index 3216dc248d..73f9113735 100644 --- a/dist/entry.min.js +++ b/dist/entry.min.js @@ -3,11 +3,11 @@ Entry.FPS=b.speed?b.speed:60;createjs.Ticker.setFPS(Entry.FPS);"workspace"==this b.objects=Entry.container.toJSON();b.scenes=Entry.scene.toJSON();b.variables=Entry.variableContainer.getVariableJSON();b.messages=Entry.variableContainer.getMessageJSON();b.functions=Entry.variableContainer.getFunctionJSON();b.scenes=Entry.scene.toJSON();b.speed=Entry.FPS;return b},setBlockByText:function(b,a){for(var c=[],d=jQuery.parseXML(a).getElementsByTagName("category"),e=0;ea?a=325:720a?a=244:400svg").css({width:a- -64+"px"});Entry.playground.mainWorkspace.blockMenu.setWidth();$(".entryWorkspaceBoard").css({left:a+"px"});Entry.playground.resizeHandle_.style.left=a+"px";Entry.playground.variableViewWrapper_.style.width=a+"px";this.interfaceState=b}Entry.windowResized.notify()},getUpTime:function(){return(new Date).getTime()-this.startTime},addActivity:function(b){Entry.stateManager&&Entry.stateManager.addActivity(b)},startActivityLogging:function(){Entry.reporter&&Entry.reporter.start(Entry.projectId,window.user? -window.user._id:null,Entry.startTime)},getActivityLog:function(){var b={};Entry.stateManager&&(b.activityLog=Entry.stateManager.activityLog_);return b},DRAG_MODE_NONE:0,DRAG_MODE_MOUSEDOWN:1,DRAG_MODE_DRAG:2,cancelObjectEdit:function(b){var a=Entry.playground.object;if(a){var c=b.target;b=0!==$(a.view_).find(c).length;c=c.tagName.toUpperCase();!a.isEditing||"INPUT"===c&&b||a.editObjectValues(!1)}}};window.Entry=Entry;Entry.Albert={PORT_MAP:{leftWheel:0,rightWheel:0,buzzer:0,leftEye:0,rightEye:0,note:0,bodyLed:0,frontLed:0,padWidth:0,padHeight:0},setZero:function(){var b=Entry.Albert.PORT_MAP,a=Entry.hw.sendQueue,c;for(c in b)a[c]=b[c];Entry.hw.update();b=Entry.Albert;b.tempo=60;b.removeAllTimeouts()},monitorTemplate:{imgPath:"hw/albert.png",width:387,height:503,listPorts:{oid:{name:"OID",type:"input",pos:{x:0,y:0}},buzzer:{name:Lang.Hw.buzzer,type:"output",pos:{x:0,y:0}},note:{name:Lang.Hw.note,type:"output", +canvasWidth:480})},resizeElement:function(b){if("workspace"==Entry.type){var a=this.interfaceState;!b.canvasWidth&&a.canvasWidth&&(b.canvasWidth=a.canvasWidth);!b.menuWidth&&this.interfaceState.menuWidth&&(b.menuWidth=a.menuWidth);Entry.engine.speedPanelOn&&Entry.engine.toggleSpeedPanel();(a=b.canvasWidth)?325>a?a=325:720a?a=244:400svg").css({width:a-64+"px"});Entry.playground.mainWorkspace.blockMenu.setWidth(); +$(".entryWorkspaceBoard").css({left:a+"px"});Entry.playground.resizeHandle_.style.left=a+"px";Entry.playground.variableViewWrapper_.style.width=a+"px";this.interfaceState=b}Entry.windowResized.notify()},getUpTime:function(){return(new Date).getTime()-this.startTime},addActivity:function(b){Entry.stateManager&&Entry.stateManager.addActivity(b)},startActivityLogging:function(){Entry.reporter&&Entry.reporter.start(Entry.projectId,window.user?window.user._id:null,Entry.startTime)},getActivityLog:function(){var b= +{};Entry.stateManager&&(b.activityLog=Entry.stateManager.activityLog_);return b},DRAG_MODE_NONE:0,DRAG_MODE_MOUSEDOWN:1,DRAG_MODE_DRAG:2,cancelObjectEdit:function(b){var a=Entry.playground.object;if(a){var c=b.target;b=0!==$(a.view_).find(c).length;c=c.tagName.toUpperCase();!a.isEditing||"INPUT"===c&&b||a.editObjectValues(!1)}}};window.Entry=Entry;Entry.Albert={PORT_MAP:{leftWheel:0,rightWheel:0,buzzer:0,leftEye:0,rightEye:0,note:0,bodyLed:0,frontLed:0,padWidth:0,padHeight:0},setZero:function(){var b=Entry.Albert.PORT_MAP,a=Entry.hw.sendQueue,c;for(c in b)a[c]=b[c];Entry.hw.update();b=Entry.Albert;b.tempo=60;b.removeAllTimeouts()},monitorTemplate:{imgPath:"hw/albert.png",width:387,height:503,listPorts:{oid:{name:"OID",type:"input",pos:{x:0,y:0}},buzzer:{name:Lang.Hw.buzzer,type:"output",pos:{x:0,y:0}},note:{name:Lang.Hw.note,type:"output", pos:{x:0,y:0}}},ports:{leftProximity:{name:Lang.Blocks.ALBERT_sensor_leftProximity,type:"input",pos:{x:178,y:401}},rightProximity:{name:Lang.Blocks.ALBERT_sensor_rightProximity,type:"input",pos:{x:66,y:359}},battery:{name:Lang.Blocks.ALBERT_sensor_battery,type:"input",pos:{x:88,y:368}},light:{name:Lang.Blocks.ALBERT_sensor_light,type:"input",pos:{x:127,y:391}},leftWheel:{name:Lang.Hw.leftWheel,type:"output",pos:{x:299,y:406}},rightWheel:{name:Lang.Hw.rightWheel,type:"output",pos:{x:22,y:325}},leftEye:{name:Lang.Hw.leftEye, type:"output",pos:{x:260,y:26}},rightEye:{name:Lang.Hw.rightEye,type:"output",pos:{x:164,y:13}},bodyLed:{name:Lang.Hw.body+" "+Lang.Hw.led,type:"output",pos:{x:367,y:308}},frontLed:{name:Lang.Hw.front+" "+Lang.Hw.led,pos:{x:117,y:410}}},mode:"both"},tempo:60,timeouts:[],removeTimeout:function(b){clearTimeout(b);var a=this.timeouts;b=a.indexOf(b);0<=b&&a.splice(b,1)},removeAllTimeouts:function(){var b=this.timeouts,a;for(a in b)clearTimeout(b[a]);this.timeouts=[]},name:"albert"}; Blockly.Blocks.albert_hand_found={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_hand_found);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}};Entry.block.albert_hand_found=function(b,a){var c=Entry.hw.portData;return 40d)var h=c,c=d,d=h;e>f&&(h=e,e=f,f=h);g=(f-e)/(d-c)*(g-c);g+=e;g=Math.min(f,g);g=Math.max(e,g);return Math.round(g)}; Blockly.Blocks.dplay_select_led={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_num_pin_1);this.appendDummyInput().appendField(new Blockly.FieldDropdown([["7","7"],["8","8"],["9","9"],["10","10"]]),"PORT");this.appendDummyInput().appendField(Lang.Blocks.dplay_num_pin_1);this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.ARDUINO_on,"on"],[Lang.Blocks.ARDUINO_off,"off"]]),"OPERATOR").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.dplay_select_led=function(b,a){var c=a.getField("PORT"),d=7;"7"==c?d=7:"8"==c?d=8:"9"==c?d=9:"10"==c&&(d=10);c=a.getField("OPERATOR");Entry.hw.setDigitalPortValue(d,"on"==c?255:0);return a.callReturn()}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.dplay_select_led=function(b,a){var c=a.getField("PORT"),d=7;"7"==c?d=7:"8"==c?d=8:"9"==c?d=9:"10"==c&&(d=10);c="on"==a.getField("OPERATOR")?255:0;Entry.hw.setDigitalPortValue(d,c);return a.callReturn()}; Blockly.Blocks.dplay_get_switch_status={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\ub514\uc9c0\ud138 ");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["2","2"],["4","4"]]),"PORT");this.appendDummyInput().appendField(Lang.Blocks.dplay_num_pin_2).appendField(new Blockly.FieldDropdown([[Lang.Blocks.dplay_string_5,"ON"],[Lang.Blocks.dplay_string_6,"OFF"]]),"STATUS").appendField(" ");this.setInputsInline(!0);this.setOutput(!0,"Boolean")}}; Entry.block.dplay_get_switch_status=function(b,a){var c=a.getField("PORT"),d=2;"2"==c?d=2:"4"==c&&(d=4);return"OFF"==a.getField("STATUS")?1==Entry.hw.getDigitalPortValue(d)?1:0:0==Entry.hw.getDigitalPortValue(d)?1:0}; Blockly.Blocks.dplay_get_light_status={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.dplay_light).appendField(new Blockly.FieldDropdown([[Lang.Blocks.dplay_string_3,"BRIGHT"],[Lang.Blocks.dplay_string_4,"DARK"]]),"STATUS").appendField(" ");this.setInputsInline(!0);this.setOutput(!0,"Boolean")}}; @@ -232,7 +232,7 @@ Entry.block.quotient_and_mod=function(b,a){var c=a.getNumberValue("LEFTHAND",a), Blockly.Blocks.choose_project_timer_action={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_choose_project_timer_action_1,calcFontColor).appendField(new Blockly.FieldDropdown([[Lang.Blocks.CALC_choose_project_timer_action_sub_1,"START"],[Lang.Blocks.CALC_choose_project_timer_action_sub_2,"STOP"],[Lang.Blocks.CALC_choose_project_timer_action_sub_3,"RESET"]],null,!0,calcArrowColor),"ACTION").appendField(Lang.Blocks.CALC_choose_project_timer_action_2, calcFontColor).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/calc_01.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)},whenAdd:function(){Entry.engine&&Entry.engine.showProjectTimer()},whenRemove:function(b){Entry.engine&&Entry.engine.hideProjectTimer(b)}}; Entry.block.choose_project_timer_action=function(b,a){var c=a.getField("ACTION"),d=Entry.engine,e=d.projectTimer;"START"==c?e.isInit?e.isInit&&e.isPaused&&(e.pauseStart&&(e.pausedTime+=(new Date).getTime()-e.pauseStart),delete e.pauseStart,e.isPaused=!1):d.startProjectTimer():"STOP"==c?e.isInit&&!e.isPaused&&(e.isPaused=!0,e.pauseStart=(new Date).getTime()):"RESET"==c&&e.isInit&&(e.setValue(0),e.start=(new Date).getTime(),e.pausedTime=0,delete e.pauseStart);return a.callReturn()};Blockly.Blocks.wait_second={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_wait_second_1);this.appendValueInput("SECOND").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.FLOW_wait_second_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.wait_second=function(b,a){if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;return a.callReturn()}a.isStart=!0;a.timeFlag=1;var c=a.getNumberValue("SECOND",a);setTimeout(function(){a.timeFlag=0},60/(Entry.FPS||60)*c*1E3);return a}; +Entry.block.wait_second=function(b,a){if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;return a.callReturn()}a.isStart=!0;a.timeFlag=1;var c=a.getNumberValue("SECOND",a),c=60/(Entry.FPS||60)*c*1E3;setTimeout(function(){a.timeFlag=0},c);return a}; Blockly.Blocks.repeat_basic={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_repeat_basic_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.FLOW_repeat_basic_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.appendStatementInput("DO");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; Entry.block.repeat_basic=function(b,a){var c;if(!a.isLooped){a.isLooped=!0;c=a.getNumberValue("VALUE",a);if(0>c)throw Error(Lang.Blocks.FLOW_repeat_basic_errorMsg);a.iterCount=Math.floor(c)}if(0==a.iterCount||0>a.iterCount)return delete a.isLooped,delete a.iterCount,a.callReturn();a.iterCount--;return a.getStatement("DO",a)}; Blockly.Blocks.repeat_inf={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_repeat_inf).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.appendStatementInput("DO");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.repeat_inf=function(b,a){a.isLooped=!0;return a.getStatement("DO")}; @@ -699,7 +699,7 @@ Entry.Container.prototype.removeObject=function(b){var a=this.objects_.indexOf(b Entry.Container.prototype.selectObject=function(b,a){var c=this.getObject(b);a&&c&&Entry.scene.selectScene(c.scene);this.mapObjectOnScene(function(a){a.view_&&a.view_.removeClass("selectedObject");a.isSelected_=!1});c&&(c.view_&&c.view_.addClass("selectedObject"),c.isSelected_=!0);Entry.playground&&Entry.playground.injectObject(c);"minimize"!=Entry.type&&Entry.engine.isState("stop")&&Entry.stage.selectObject(c)};Entry.Container.prototype.getAllObjects=function(){return this.objects_}; Entry.Container.prototype.getObject=function(b){!b&&Entry.playground&&Entry.playground.object&&(b=Entry.playground.object.id);for(var a=this.objects_.length,c=0;cb.x+b.width+this.width?(this.object.x=b.x+b.width+this.width/2,a+="e"):(this.object.x=b.x-this.width/2,a+="w");this.notch.type!=a&&(this.object.removeChild(this.notch),this.notch=this.createSpeakNotch(a),this.object.addChild(this.notch))}; -Entry.Dialog.prototype.createSpeakNotch=function(b){var a=new createjs.Shape;a.type=b;"ne"==b?a.graphics.f("#f5f5f5").ss(2,"round").s("#6FC0DD").mt(0,this.height+this.padding-1.5).lt(-10,this.height+this.padding+20).lt(20,this.height+this.padding-1.5):"nw"==b?a.graphics.f("#f5f5f5").ss(2,"round").s("#6FC0DD").mt(this.width,this.height+this.padding-1.5).lt(this.width+10,this.height+this.padding+20).lt(this.width-20,this.height+this.padding-1.5):"se"==b?a.graphics.f("#f5f5f5").ss(2,"round").s("#6FC0DD").mt(0, --this.padding+1.5).lt(-10,-this.padding-20).lt(20,-this.padding+1.5):"sw"==b&&a.graphics.f("#f5f5f5").ss(2,"round").s("#6FC0DD").mt(this.width,-this.padding+1.5).lt(this.width+10,-this.padding-20).lt(this.width-20,-this.padding+1.5);return a};Entry.Dialog.prototype.remove=function(){Entry.stage.unloadDialog(this);this.parent.dialog=null};Entry.DoneProject=function(b){this.generateView(b)};var p=Entry.DoneProject.prototype;p.init=function(b){this.projectId=b};p.generateView=function(b){var a=Entry.createElement("div");a.addClass("entryContainerDoneWorkspace");this.doneContainer=a;var c=Entry.createElement("iframe");c.setAttribute("id","doneProjectframe");c.setAttribute("frameborder",0);c.setAttribute("src","/api/iframe/project/"+b);this.doneProjectFrame=c;this.doneContainer.appendChild(c);a.addClass("entryRemove")};p.getView=function(){return this.doneContainer}; -p.resize=function(){document.getElementById("entryContainerWorkspaceId");var b=document.getElementById("doneProjectframe"),a=this.doneContainer.offsetWidth;b.width=a+"px";b.height=9*a/16+"px"};Entry.Engine=function(){function b(a){var b=[37,38,39,40,32],d=a.keyCode||a.which,e=Entry.stage.inputField;32==d&&e&&e.hasFocus()||-1b.x+b.width+this.width?(this.object.x=b.x+b.width+this.width/2,a+="e"):(this.object.x=b.x-this.width/2,a+="w");this.notch.type!=a&&(this.object.removeChild(this.notch),this.notch=this.createSpeakNotch(a),this.object.addChild(this.notch));Entry.requestUpdate= +!0}; +Entry.Dialog.prototype.createSpeakNotch=function(b){var a=new createjs.Shape;a.type=b;"ne"==b?a.graphics.f("#f5f5f5").ss(2,"round").s("#6FC0DD").mt(0,this.height+this.padding-1.5).lt(-10,this.height+this.padding+20).lt(20,this.height+this.padding-1.5):"nw"==b?a.graphics.f("#f5f5f5").ss(2,"round").s("#6FC0DD").mt(this.width,this.height+this.padding-1.5).lt(this.width+10,this.height+this.padding+20).lt(this.width-20,this.height+this.padding-1.5):"se"==b?a.graphics.f("#f5f5f5").ss(2,"round").s("#6FC0DD").mt(0,-this.padding+ +1.5).lt(-10,-this.padding-20).lt(20,-this.padding+1.5):"sw"==b&&a.graphics.f("#f5f5f5").ss(2,"round").s("#6FC0DD").mt(this.width,-this.padding+1.5).lt(this.width+10,-this.padding-20).lt(this.width-20,-this.padding+1.5);return a};Entry.Dialog.prototype.remove=function(){Entry.stage.unloadDialog(this);this.parent.dialog=null};Entry.DoneProject=function(b){this.generateView(b)};var p=Entry.DoneProject.prototype;p.init=function(b){this.projectId=b};p.generateView=function(b){var a=Entry.createElement("div");a.addClass("entryContainerDoneWorkspace");this.doneContainer=a;var c=Entry.createElement("iframe");c.setAttribute("id","doneProjectframe");c.setAttribute("frameborder",0);c.setAttribute("src","/api/iframe/project/"+b);this.doneProjectFrame=c;this.doneContainer.appendChild(c);a.addClass("entryRemove")};p.getView=function(){return this.doneContainer}; +p.resize=function(){document.getElementById("entryContainerWorkspaceId");var b=document.getElementById("doneProjectframe"),a=this.doneContainer.offsetWidth;b.width=a+"px";b.height=9*a/16+"px"};Entry.Engine=function(){function b(a){var b=[37,38,39,40,32],d=a.keyCode||a.which,e=Entry.stage.inputField;32==d&&e&&e.hasFocus()||-1a||(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")}; -Entry.Engine.prototype.toggleFullscreen=function(){if(this.popup)this.popup.remove(),this.popup=null;else{this.popup=new Entry.Popup;if("workspace"!=Entry.type){var b=$(document);$(this.popup.body_).css("top",b.scrollTop());$("body").css("overflow","hidden");popup.window_.appendChild(Entry.stage.canvas.canvas)}popup.window_.appendChild(Entry.engine.view_)}}; -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.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.textContent="X : "+b.x+", Y : "+b.y;this.mouseView.removeClass("entryRemove")};Entry.Engine.prototype.hideMouseView=function(){this.mouseView.addClass("entryRemove")}; +Entry.Engine.prototype.toggleFullscreen=function(){if(this.popup)this.popup.remove(),this.popup=null;else{this.popup=new Entry.Popup;if("workspace"!=Entry.type){var b=$(document);$(this.popup.body_).css("top",b.scrollTop());$("body").css("overflow","hidden");popup.window_.appendChild(Entry.stage.canvas.canvas);popup.window_.appendChild(Entry.engine.runButton[0])}popup.window_.appendChild(Entry.engine.view_)}Entry.windowResized.notify()}; +Entry.Engine.prototype.exitFullScreen=function(){document.webkitIsFullScreen||document.mozIsFullScreen||document.isFullScreen||(Entry.engine.footerView_.removeClass("entryRemove"),Entry.engine.headerView_.removeClass("entryRemove"));Entry.windowResized.notify()};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;dthis.direction)==(0<=b&&180>b)||(this.setScaleX(-this.getScaleX()),Entry.stage.updateObject(),this.flip=!this.flip);this.direction=b.mod(360);this.object.direction=this.direction;this.isClone||this.parent.updateRotationView();Entry.dispatchEvent("updateObject")}; -Entry.EntityObject.prototype.setRotation=function(b){"free"!=this.parent.getRotateMethod()&&(b=0);this.rotation=b.mod(360);this.object.rotation=this.rotation;this.updateDialog();this.isClone||this.parent.updateRotationView();Entry.dispatchEvent("updateObject")};Entry.EntityObject.prototype.getRotation=function(){return this.rotation};Entry.EntityObject.prototype.setRegX=function(b){"textBox"==this.type&&(b=0);this.regX=b;this.object.regX=this.regX};Entry.EntityObject.prototype.getRegX=function(){return this.regX}; -Entry.EntityObject.prototype.setRegY=function(b){"textBox"==this.type&&(b=0);this.regY=b;this.object.regY=this.regY};Entry.EntityObject.prototype.getRegY=function(){return this.regY};Entry.EntityObject.prototype.setScaleX=function(b){this.scaleX=b;this.object.scaleX=this.scaleX;this.parent.updateCoordinateView();this.updateDialog()};Entry.EntityObject.prototype.getScaleX=function(){return this.scaleX}; -Entry.EntityObject.prototype.setScaleY=function(b){this.scaleY=b;this.object.scaleY=this.scaleY;this.parent.updateCoordinateView();this.updateDialog()};Entry.EntityObject.prototype.getScaleY=function(){return this.scaleY};Entry.EntityObject.prototype.setSize=function(b){1>b&&(b=1);b/=this.getSize();this.setScaleX(this.getScaleX()*b);this.setScaleY(this.getScaleY()*b);this.isClone||this.parent.updateCoordinateView()}; -Entry.EntityObject.prototype.getSize=function(){return(this.getWidth()*Math.abs(this.getScaleX())+this.getHeight()*Math.abs(this.getScaleY()))/2};Entry.EntityObject.prototype.setWidth=function(b){this.width=b;this.object.width=this.width;this.textObject&&this.getLineBreak()&&(this.textObject.lineWidth=this.width);this.updateDialog();this.updateBG()};Entry.EntityObject.prototype.getWidth=function(){return this.width}; -Entry.EntityObject.prototype.setHeight=function(b){this.height=b;this.textObject&&(this.object.height=this.height,this.alignTextBox());this.updateDialog();this.updateBG()};Entry.EntityObject.prototype.getHeight=function(){return this.height};Entry.EntityObject.prototype.setColour=function(b){b||(b="#000000");this.colour=b;this.textObject&&(this.textObject.color=this.colour)};Entry.EntityObject.prototype.getColour=function(){return this.colour}; -Entry.EntityObject.prototype.setBGColour=function(b){b||(b="transparent");this.bgColor=b;this.updateBG()};Entry.EntityObject.prototype.getBGColour=function(){return this.bgColor};Entry.EntityObject.prototype.setUnderLine=function(b){void 0===b&&(b=!1);this.underLine=b;this.textObject.underLine=b};Entry.EntityObject.prototype.getUnderLine=function(){return this.underLine};Entry.EntityObject.prototype.setStrike=function(b){void 0===b&&(b=!1);this.strike=b;this.textObject.strike=b}; -Entry.EntityObject.prototype.getStrike=function(){return this.strike};Entry.EntityObject.prototype.getFont=function(){var b=[];this.fontBold&&b.push("bold");this.fontItalic&&b.push("italic");b.push(this.getFontSize()+"px");b.push(this.fontType);return b.join(" ")}; +Entry.EntityObject.prototype.restoreEntity=function(b){var a=this.toJSON();this.syncModel_(b);Entry.dispatchEvent("updateObject");Entry.stateManager&&Entry.stateManager.addCommand("restore object",this,this.restoreEntity,a)};Entry.EntityObject.prototype.setX=function(b){"number"==typeof b&&(this.x=b,this.object.x=this.x,this.isClone||this.parent.updateCoordinateView(),this.updateDialog(),Entry.requestUpdate=!0)};Entry.EntityObject.prototype.getX=function(){return this.x}; +Entry.EntityObject.prototype.setY=function(b){"number"==typeof b&&(this.y=b,this.object.y=-this.y,this.isClone||this.parent.updateCoordinateView(),this.updateDialog(),Entry.requestUpdate=!0)};Entry.EntityObject.prototype.getY=function(){return this.y};Entry.EntityObject.prototype.getDirection=function(){return this.direction}; +Entry.EntityObject.prototype.setDirection=function(b,a){b||(b=0);"vertical"!=this.parent.getRotateMethod()||a||(0<=this.direction&&180>this.direction)==(0<=b&&180>b)||(this.setScaleX(-this.getScaleX()),Entry.stage.updateObject(),this.flip=!this.flip);this.direction=b.mod(360);this.object.direction=this.direction;this.isClone||this.parent.updateRotationView();Entry.dispatchEvent("updateObject");Entry.requestUpdate=!0}; +Entry.EntityObject.prototype.setRotation=function(b){"free"!=this.parent.getRotateMethod()&&(b=0);this.rotation=b.mod(360);this.object.rotation=this.rotation;this.updateDialog();this.isClone||this.parent.updateRotationView();Entry.dispatchEvent("updateObject");Entry.requestUpdate=!0};Entry.EntityObject.prototype.getRotation=function(){return this.rotation};Entry.EntityObject.prototype.setRegX=function(b){"textBox"==this.type&&(b=0);this.regX=b;this.object.regX=this.regX;Entry.requestUpdate=!0}; +Entry.EntityObject.prototype.getRegX=function(){return this.regX};Entry.EntityObject.prototype.setRegY=function(b){"textBox"==this.type&&(b=0);this.regY=b;this.object.regY=this.regY;Entry.requestUpdate=!0};Entry.EntityObject.prototype.getRegY=function(){return this.regY};Entry.EntityObject.prototype.setScaleX=function(b){this.scaleX=b;this.object.scaleX=this.scaleX;this.parent.updateCoordinateView();this.updateDialog();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getScaleX=function(){return this.scaleX}; +Entry.EntityObject.prototype.setScaleY=function(b){this.scaleY=b;this.object.scaleY=this.scaleY;this.parent.updateCoordinateView();this.updateDialog();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getScaleY=function(){return this.scaleY};Entry.EntityObject.prototype.setSize=function(b){1>b&&(b=1);b/=this.getSize();this.setScaleX(this.getScaleX()*b);this.setScaleY(this.getScaleY()*b);this.isClone||this.parent.updateCoordinateView();Entry.requestUpdate=!0}; +Entry.EntityObject.prototype.getSize=function(){return(this.getWidth()*Math.abs(this.getScaleX())+this.getHeight()*Math.abs(this.getScaleY()))/2};Entry.EntityObject.prototype.setWidth=function(b){this.width=b;this.object.width=this.width;this.textObject&&this.getLineBreak()&&(this.textObject.lineWidth=this.width);this.updateDialog();this.updateBG();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getWidth=function(){return this.width}; +Entry.EntityObject.prototype.setHeight=function(b){this.height=b;this.textObject&&(this.object.height=this.height,this.alignTextBox());this.updateDialog();this.updateBG();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getHeight=function(){return this.height};Entry.EntityObject.prototype.setColour=function(b){b||(b="#000000");this.colour=b;this.textObject&&(this.textObject.color=this.colour);Entry.requestUpdate=!0};Entry.EntityObject.prototype.getColour=function(){return this.colour}; +Entry.EntityObject.prototype.setBGColour=function(b){b||(b="transparent");this.bgColor=b;this.updateBG();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getBGColour=function(){return this.bgColor};Entry.EntityObject.prototype.setUnderLine=function(b){void 0===b&&(b=!1);this.underLine=b;this.textObject.underLine=b;Entry.requestUpdate=!0};Entry.EntityObject.prototype.getUnderLine=function(){return this.underLine}; +Entry.EntityObject.prototype.setStrike=function(b){void 0===b&&(b=!1);this.strike=b;this.textObject.strike=b;Entry.requestUpdate=!0};Entry.EntityObject.prototype.getStrike=function(){return this.strike};Entry.EntityObject.prototype.getFont=function(){var b=[];this.fontBold&&b.push("bold");this.fontItalic&&b.push("italic");b.push(this.getFontSize()+"px");b.push(this.fontType);return b.join(" ")}; Entry.EntityObject.prototype.setFont=function(b){if("textBox"==this.parent.objectType&&this.font!==b){b||(b="20px Nanum Gothic");var a=b.split(" "),c=0;if(c=-1=l?g=[1,0,0,0,0,0,k,h,0,0,0,-1*h,k,0,0,0,0,0,1,0,0,0,0,0,1]:.66>=l?g=[k,0,h,0,0,0,1,0,0,0,h,0,k,0,0,0,0,0,1,0,0,0,0,0,1]:.99>=l&&(g=[k,h,0,0,0,-1*h,k,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1]);g=(new createjs.ColorMatrix).concat(g);g=new createjs.ColorMatrixFilter(g);e.push(g);b.alpha=a.alpha=f(a.alpha,0,1);b.filters=e}(b,a),a.cache(0,0,this.getWidth(), -this.getHeight()))};Entry.EntityObject.prototype.resetFilter=function(){"sprite"==this.parent.objectType&&(this.object.filters=[],this.setInitialEffectValue(),this.object.alpha=this.effect.alpha,this.object.cache(0,0,this.getWidth(),this.getHeight()))};Entry.EntityObject.prototype.updateDialog=function(){this.dialog&&this.dialog.update()};Entry.EntityObject.prototype.takeSnapshot=function(){this.snapshot_=this.toJSON();this.collision=Entry.Utils.COLLISION.NONE}; -Entry.EntityObject.prototype.loadSnapshot=function(){this.snapshot_&&this.syncModel_(this.snapshot_);"sprite"==this.parent.objectType&&this.setImage(this.parent.getPicture())};Entry.EntityObject.prototype.removeClone=function(){if(this.isClone){this.dialog&&this.dialog.remove();this.brush&&this.removeBrush();Entry.stage.unloadEntity(this);var b=this.parent.clonedEntities.indexOf(this);this.parent.clonedEntities.splice(b,1);Entry.Utils.isFunction(this.clearExecutor)&&this.clearExecutor()}}; -Entry.EntityObject.prototype.clearExecutor=function(){this.parent.script.clearExecutorsByEntity(this)}; +this.getHeight()),Entry.requestUpdate=!0)};Entry.EntityObject.prototype.resetFilter=function(){"sprite"==this.parent.objectType&&(this.object.filters=[],this.setInitialEffectValue(),this.object.alpha=this.effect.alpha,this.object.cache(0,0,this.getWidth(),this.getHeight()),Entry.requestUpdate=!0)};Entry.EntityObject.prototype.updateDialog=function(){this.dialog&&this.dialog.update();Entry.requestUpdate=!0}; +Entry.EntityObject.prototype.takeSnapshot=function(){this.snapshot_=this.toJSON();this.collision=Entry.Utils.COLLISION.NONE};Entry.EntityObject.prototype.loadSnapshot=function(){this.snapshot_&&this.syncModel_(this.snapshot_);"sprite"==this.parent.objectType&&this.setImage(this.parent.getPicture());Entry.requestUpdate=!0}; +Entry.EntityObject.prototype.removeClone=function(){if(this.isClone){this.dialog&&this.dialog.remove();this.brush&&this.removeBrush();Entry.stage.unloadEntity(this);var b=this.parent.clonedEntities.indexOf(this);this.parent.clonedEntities.splice(b,1);Entry.Utils.isFunction(this.clearExecutor)&&this.clearExecutor()}};Entry.EntityObject.prototype.clearExecutor=function(){this.parent.script.clearExecutorsByEntity(this)}; Entry.EntityObject.prototype.toJSON=function(){var b={};b.x=Entry.cutDecimal(this.getX());b.y=Entry.cutDecimal(this.getY());b.regX=Entry.cutDecimal(this.getRegX());b.regY=Entry.cutDecimal(this.getRegY());b.scaleX=this.getScaleX();b.scaleY=this.getScaleY();b.rotation=Entry.cutDecimal(this.getRotation());b.direction=Entry.cutDecimal(this.getDirection());b.width=Entry.cutDecimal(this.getWidth());b.height=Entry.cutDecimal(this.getHeight());b.font=this.getFont();b.visible=this.getVisible();"textBox"== -this.parent.objectType&&(b.colour=this.getColour(),b.text=this.getText(),b.textAlign=this.getTextAlign(),b.lineBreak=this.getLineBreak(),b.bgColor=this.getBGColour(),b.underLine=this.getUnderLine(),b.strike=this.getStrike(),b.fontSize=this.getFontSize());return b};Entry.EntityObject.prototype.setInitialEffectValue=function(){this.effect=this.getInitialEffectValue()};Entry.EntityObject.prototype.getInitialEffectValue=function(){return{blur:0,hue:0,hsv:0,brightness:0,contrast:0,saturation:0,alpha:1}}; -Entry.EntityObject.prototype.removeBrush=function(){Entry.stage.selectedObjectContainer.removeChild(this.shape);this.shape=this.brush=null}; +this.parent.objectType&&(b.colour=this.getColour(),b.text=this.getText(),b.textAlign=this.getTextAlign(),b.lineBreak=this.getLineBreak(),b.bgColor=this.getBGColour(),b.underLine=this.getUnderLine(),b.strike=this.getStrike(),b.fontSize=this.getFontSize());return b};Entry.EntityObject.prototype.setInitialEffectValue=function(){this.effect=this.getInitialEffectValue();Entry.requestUpdate=!0}; +Entry.EntityObject.prototype.getInitialEffectValue=function(){return{blur:0,hue:0,hsv:0,brightness:0,contrast:0,saturation:0,alpha:1}};Entry.EntityObject.prototype.removeBrush=function(){Entry.stage.selectedObjectContainer.removeChild(this.shape);this.shape=this.brush=null}; Entry.EntityObject.prototype.updateBG=function(){if(this.bgObject){this.bgObject.graphics.clear();var b=this.getWidth(),a=this.getHeight();this.bgObject.graphics.setStrokeStyle(1).beginStroke().beginFill(this.getBGColour()).drawRect(-b/2,-a/2,b,a);if(this.getLineBreak())this.bgObject.x=0;else switch(this.getTextAlign()){case Entry.TEXT_ALIGN_LEFT:this.bgObject.x=b/2;break;case Entry.TEXT_ALIGN_CENTER:this.bgObject.x=0;break;case Entry.TEXT_ALIGN_RIGHT:this.bgObject.x=-b/2}}}; Entry.EntityObject.prototype.alignTextBox=function(){if("textBox"==this.type){var b=this.textObject;if(this.lineBreak){var a=b.getMeasuredLineHeight();b.y=a/2-this.getHeight()/2;switch(this.textAlign){case Entry.TEXT_ALIGN_CENTER:b.x=0;break;case Entry.TEXT_ALIGN_LEFT:b.x=-this.getWidth()/2;break;case Entry.TEXT_ALIGN_RIGHT:b.x=this.getWidth()/2}b.maxHeight=this.getHeight()}else b.x=0,b.y=0}};Entry.EntityObject.prototype.syncDialogVisible=function(){this.dialog&&(this.dialog.object.visible=this.visible)};Entry.Helper=function(){this.visible=!1};p=Entry.Helper.prototype; p.generateView=function(b,a){if(!this.parentView_){this.parentView_=b;this.blockHelpData=EntryStatic.blockInfo;var c=Entry.createElement("div","entryBlockHelperWorkspace");this.view=c;Entry.isForLecture&&c.addClass("lecture");this.parentView_.appendChild(c);var d=Entry.createElement("div","entryBlockHelperContentWorkspace");d.addClass("entryBlockHelperIntro");Entry.isForLecture&&d.addClass("lecture");c.appendChild(d);this.blockHelperContent_=d;this.blockHelperView_=c;c=Entry.createElement("div","entryBlockHelperBlockWorkspace"); @@ -811,7 +814,7 @@ Entry.StateManager.prototype.startRestore=function(){this.isRestore=!0};Entry.St Entry.StateManager.prototype.canUndo=function(){return 0=this.getScenes().length)Entry.toast.alert(Lang.Msgs.runtime_error,Lang.Workspace.Scene_delete_error,!1);else{var a=this.getScenes().indexOf(this.getSceneById(b.id));this.getScenes().splice(a,1);for(var a=Entry.container.getSceneObjects(b),c=0;cd.style.opacity&&(clearInterval(a),d.style.display="none",Entry.removeElement(d));d.style.opacity*=.9},20)},1E3)}; @@ -1145,11 +1122,11 @@ Entry.isEmpty=function(b){if(!b)return!0;for(var a in b)if(b.hasOwnProperty(a))r Entry.bindAnimationCallbackOnce=function(b,a){b.one("webkitAnimationEnd animationendo animationend",a)};Entry.Utils.isInInput=function(b){return"textarea"==b.target.type||"text"==b.target.type};Entry.Utils.isFunction=function(b){return"function"===typeof b}; Entry.Utils.addFilters=function(b,a){var c=b.elem("defs"),d=c.elem("filter",{id:"entryTrashcanFilter_"+a});d.elem("feGaussianBlur",{"in":"SourceAlpha",stdDeviation:2,result:"blur"});d.elem("feOffset",{"in":"blur",dx:1,dy:1,result:"offsetBlur"});d=d.elem("feMerge");d.elem("feMergeNode",{"in":"offsetBlur"});d.elem("feMergeNode",{"in":"SourceGraphic"},d);d=c.elem("filter",{id:"entryBlockShadowFilter_"+a,height:"200%"});d.elem("feOffset",{result:"offOut",in:"SourceGraphic",dx:0,dy:1});d.elem("feColorMatrix", {result:"matrixOut",in:"offOut",type:"matrix",values:"0.7 0 0 0 0 0 0.7 0 0 0 0 0 0.7 0 0 0 0 0 1 0"});d.elem("feBlend",{in:"SourceGraphic",in1:"offOut",mode:"normal"});c=c.elem("filter",{id:"entryBlockHighlightFilter_"+a});c.elem("feOffset",{result:"offOut",in:"SourceGraphic",dx:0,dy:0});c.elem("feColorMatrix",{result:"matrixOut",in:"offOut",type:"matrix",values:"1.3 0 0 0 0 0 1.3 0 0 0 0 0 1.3 0 0 0 0 0 1 0"})}; -Entry.Utils.addBlockPattern=function(b,a){for(var c=b.elem("pattern",{id:"blockHoverPattern_"+a,class:"blockHoverPattern",patternUnits:"userSpaceOnUse",patternTransform:"translate(12, 0)",x:0,y:0,width:125,height:33}).elem("g"),d=c.elem("rect",{x:0,y:0,width:125,height:33}),e=Entry.mediaFilePath+"block_pattern_(order).png",f=1;5>f;f++)c.elem("image",{class:"pattern"+f,href:e.replace("(order)",f),x:0,y:0,width:125,height:33});return d};Entry.Utils.COLLISION={NONE:0,UP:1,RIGHT:2,LEFT:3,DOWN:4}; -Entry.Utils.createMouseEvent=function(b,a){var c=document.createEvent("MouseEvent");c.initMouseEvent(b,!0,!0,window,0,0,0,a.clientX,a.clientY,!1,!1,!1,!1,0,null);return c};Entry.Utils.xmlToJsonData=function(b){b=$.parseXML(b);var a=[];b=b.childNodes[0].childNodes;for(var c in b){var d=b[c];if(d.tagName){var e={category:d.getAttribute("id"),blocks:[]},d=d.childNodes;for(c in d){var f=d[c];f.tagName&&(f=f.getAttribute("type"))&&e.blocks.push(f)}a.push(e)}}return a}; +Entry.Utils.addBlockPattern=function(b,a){for(var c=b.elem("pattern",{id:"blockHoverPattern_"+a,class:"blockHoverPattern",patternUnits:"userSpaceOnUse",patternTransform:"translate(12, 0)",x:0,y:0,width:125,height:33,style:"display: none"}),d=c.elem("g"),e=d.elem("rect",{x:0,y:0,width:125,height:33}),f=Entry.mediaFilePath+"block_pattern_(order).png",g=1;5>g;g++)d.elem("image",{class:"pattern"+g,href:f.replace("(order)",g),x:0,y:0,width:125,height:33});return{pattern:c,rect:e}}; +Entry.Utils.COLLISION={NONE:0,UP:1,RIGHT:2,LEFT:3,DOWN:4};Entry.Utils.createMouseEvent=function(b,a){var c=document.createEvent("MouseEvent");c.initMouseEvent(b,!0,!0,window,0,0,0,a.clientX,a.clientY,!1,!1,!1,!1,0,null);return c};Entry.Utils.xmlToJsonData=function(b){b=$.parseXML(b);var a=[];b=b.childNodes[0].childNodes;for(var c in b){var d=b[c];if(d.tagName){var e={category:d.getAttribute("id"),blocks:[]},d=d.childNodes;for(c in d){var f=d[c];f.tagName&&(f=f.getAttribute("type"))&&e.blocks.push(f)}a.push(e)}}return a}; Entry.Utils.stopProjectWithToast=function(b,a){a=a||"\ub7f0\ud0c0\uc784 \uc5d0\ub7ec \ubc1c\uc0dd";Entry.toast&&Entry.toast.alert(Lang.Msgs.warn,Lang.Workspace.check_runtime_error,!0);Entry.engine&&Entry.engine.toggleStop();"workspace"===Entry.type&&(Entry.container.selectObject(b.getCode().object.id,!0),b.view.getBoard().activateBlock(b));throw Error(a);};Entry.Utils.isChrome=function(){return/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())}; Entry.Utils.waitForWebfonts=function(b,a){for(var c=0,d=0,e=b.length;d=b.length&&(l&&clearInterval(l),c==b.length))return a(),!0}var h=document.createElement("span");h.innerHTML="giItT1WQy@!-/#";h.style.position="absolute";h.style.left="-10000px";h.style.top="-10000px";h.style.fontSize="300px";h.style.fontFamily="sans-serif";h.style.fontVariant="normal";h.style.fontStyle="normal";h.style.fontWeight= -"normal";h.style.letterSpacing="0";document.body.appendChild(h);var k=h.offsetWidth;h.style.fontFamily=d;var l;e()||(l=setInterval(e,50))})(b[d])};Entry.Model=function(b,a){var c=Entry.Model;c.generateSchema(b);c.generateSetter(b);c.generateObserve(b);(void 0===a||a)&&Object.seal(b);return b}; +"normal";h.style.letterSpacing="0";document.body.appendChild(h);var k=h.offsetWidth;h.style.fontFamily=d;var l;e()||(l=setInterval(e,50))})(b[d])};window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(b){window.setTimeout(b,1E3/60)}}();Entry.Model=function(b,a){var c=Entry.Model;c.generateSchema(b);c.generateSetter(b);c.generateObserve(b);(void 0===a||a)&&Object.seal(b);return b}; (function(b){b.generateSchema=function(a){var b=a.schema;if(void 0!==b){b=JSON.parse(JSON.stringify(b));a.data={};for(var d in b)(function(d){a.data[d]=b[d];Object.defineProperty(a,d,{get:function(){return a.data[d]}})})(d);a._toJSON=this._toJSON}};b.generateSetter=function(a){a.set=this.set};b.set=function(a,b){var d={},e;for(e in this.data)void 0!==a[e]&&(a[e]===this.data[e]?delete a[e]:(d[e]=this.data[e],this.data[e]=a[e]instanceof Array?a[e].concat():a[e]));b||this.notify(Object.keys(a),d)};b.generateObserve= function(a){a.observers=[];a.observe=this.observe;a.unobserve=this.unobserve;a.notify=this.notify};b.observe=function(a,b,d,e){d=new Entry.Observer(this.observers,a,b,d);if(!1!==e)a[b]([]);return d};b.unobserve=function(a){a.destroy()};b.notify=function(a,b){"string"===typeof a&&(a=[a]);var d=this;d.observers.map(function(e){var f=a;void 0!==e.attrs&&(f=Entry.Utils.intersectArray(e.attrs,a));if(f.length)e.object[e.funcName](f.map(function(a){return{name:a,object:d,oldValue:b[a]}}))})};b._toJSON=function(){var a= {},b;for(b in this.data)a[b]=this.data[b];return a}})(Entry.Model);Entry.Func=function(b){this.id=b?b.id:Entry.generateHash();this.content=b?new Entry.Code(b.content):new Entry.Code([[{type:"function_create",copyable:!1,deletable:!1,x:40,y:40}]]);this.blockMenuBlock=this.block=null;this.hashMap={};this.paramMap={};var a=function(){};a.prototype=Entry.block.function_general;a=new a;a.changeEvent=new Entry.Event;a.template=Lang.template.function_general;Entry.block["func_"+this.id]=a;if(b){b=this.content._blockMap;for(var c in b)Entry.Func.registerParamBlock(b[c].type); @@ -1195,8 +1172,36 @@ p.getDigitalPortValue=function(b){if(!this.connected)return 0;this.setPortReadab p.removePortReadable=function(b){if(this.sendQueue.readablePorts||Array.isArray(this.sendQueue.readablePorts)){var a,c;for(c in this.sendQueue.readablePorts)if(this.sendQueue.readablePorts[c]==b){a=Number(c);break}this.sendQueue.readablePorts=void 0!=a?this.sendQueue.readablePorts.slice(0,a).concat(this.sendQueue.readablePorts.slice(a+1,this.sendQueue.readablePorts.length)):[]}};p.update=function(){this.socket&&1==this.socket.readyState&&this.socket.send(JSON.stringify(this.sendQueue))}; p.updatePortData=function(b){this.portData=b;this.hwMonitor&&this.hwMonitor.update()};p.closeConnection=function(){this.socket&&this.socket.close()};p.downloadConnector=function(){window.open("http://download.play-entry.org/apps/Entry_HW_1.5.6_Setup.exe","_blank").focus()};p.downloadSource=function(){window.open("http://play-entry.com/down/board.ino","_blank").focus()};p.setZero=function(){Entry.hw.hwModule&&Entry.hw.hwModule.setZero()}; p.checkDevice=function(b){void 0!==b.company&&(b=""+b.company+b.model,b!=this.selectedDevice&&(this.selectedDevice=b,this.hwModule=this.hwInfo[b],Entry.dispatchEvent("hwChanged"),Entry.toast.success("\ud558\ub4dc\uc6e8\uc5b4 \uc5f0\uacb0 \uc131\uacf5","\ud558\ub4dc\uc6e8\uc5b4 \uc544\uc774\ucf58\uc744 \ub354\ube14\ud074\ub9ad\ud558\uba74, \uc13c\uc11c\uac12\ub9cc \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.",!0),this.hwModule.monitorTemplate&&(this.hwMonitor?(this.hwMonitor._hwModule=this.hwModule, -this.hwMonitor.initView()):this.hwMonitor=new Entry.HWMonitor(this.hwModule),Entry.propertyPanel.addMode("hw",this.hwMonitor),b=this.hwModule.monitorTemplate,"both"==b.mode?(b.mode="list",this.hwMonitor.generateListView(),b.mode="general",this.hwMonitor.generateView(),b.mode="both"):"list"==b.mode?this.hwMonitor.generateListView():this.hwMonitor.generateView())))};p.banHW=function(){var b=this.hwInfo,a;for(a in b)Entry.playground.mainWorkspace.blockMenu.banClass(b[a].name,!0)};Entry.BlockModel=function(){Entry.Model(this)};Entry.BlockModel.prototype.schema={id:null,x:0,y:0,type:null,params:{},statements:{},prev:null,next:null,view:null};Entry.BlockRenderModel=function(){Entry.Model(this)};Entry.BlockRenderModel.prototype.schema={id:0,type:Entry.STATIC.BLOCK_RENDER_MODEL,x:0,y:0,width:0,height:0,magneting:!1};Entry.BoxModel=function(){Entry.Model(this)};Entry.BoxModel.prototype.schema={id:0,type:Entry.STATIC.BOX_MODEL,x:0,y:0,width:0,height:0};Entry.DragInstance=function(b){Entry.Model(this);this.set(b)};Entry.DragInstance.prototype.schema={type:Entry.STATIC.DRAG_INSTANCE,startX:0,startY:0,offsetX:0,offsetY:0,absX:0,absY:0,prev:null,height:0,mode:0,isNew:!1};Entry.ThreadModel=function(){Entry.Model(this)};Entry.ThreadModel.prototype.schema={id:0,type:Entry.STATIC.THREAD_MODEL,x:0,y:0,width:0,minWidth:0,height:0};Entry.Variable=function(b){Entry.assert("string"==typeof b.name,"Variable name must be given");this.name_=b.name;this.id_=b.id?b.id:Entry.generateHash();this.type=b.variableType?b.variableType:"variable";this.object_=b.object||null;this.isCloud_=b.isCloud||!1;var a=Entry.parseNumber(b.value);this.value_="number"==typeof a?a:b.value?b.value:0;"slide"==this.type?(this.minValue_=Number(b.minValue?b.minValue:0),this.maxValue_=Number(b.maxValue?b.maxValue:100)):"list"==this.type&&(this.array_=b.array? -b.array:[]);b.isClone||(this.visible_=b.visible||"boolean"==typeof b.visible?b.visible:!0,this.x_=b.x?b.x:null,this.y_=b.y?b.y:null,"list"==this.type&&(this.width_=b.width?b.width:100,this.height_=b.height?b.height:120,this.scrollPosition=0),this.BORDER=6,this.FONT="10pt NanumGothic")}; +this.hwMonitor.initView()):this.hwMonitor=new Entry.HWMonitor(this.hwModule),Entry.propertyPanel.addMode("hw",this.hwMonitor),b=this.hwModule.monitorTemplate,"both"==b.mode?(b.mode="list",this.hwMonitor.generateListView(),b.mode="general",this.hwMonitor.generateView(),b.mode="both"):"list"==b.mode?this.hwMonitor.generateListView():this.hwMonitor.generateView())))};p.banHW=function(){var b=this.hwInfo,a;for(a in b)Entry.playground.mainWorkspace.blockMenu.banClass(b[a].name,!0)};Entry.BlockModel=function(){Entry.Model(this)};Entry.BlockModel.prototype.schema={id:null,x:0,y:0,type:null,params:{},statements:{},prev:null,next:null,view:null};Entry.BlockRenderModel=function(){Entry.Model(this)};Entry.BlockRenderModel.prototype.schema={id:0,type:Entry.STATIC.BLOCK_RENDER_MODEL,x:0,y:0,width:0,height:0,magneting:!1};Entry.BoxModel=function(){Entry.Model(this)};Entry.BoxModel.prototype.schema={id:0,type:Entry.STATIC.BOX_MODEL,x:0,y:0,width:0,height:0};Entry.DragInstance=function(b){Entry.Model(this);this.set(b)};Entry.DragInstance.prototype.schema={type:Entry.STATIC.DRAG_INSTANCE,startX:0,startY:0,offsetX:0,offsetY:0,absX:0,absY:0,prev:null,height:0,mode:0,isNew:!1};Entry.ThreadModel=function(){Entry.Model(this)};Entry.ThreadModel.prototype.schema={id:0,type:Entry.STATIC.THREAD_MODEL,x:0,y:0,width:0,minWidth:0,height:0};Entry.Stage=function(){this.variables={};this.background=new createjs.Shape;this.background.graphics.beginFill("#ffffff").drawRect(-480,-240,960,480);this.objectContainers=[];this.selectedObjectContainer=null;this.variableContainer=new createjs.Container;this.dialogContainer=new createjs.Container;this.selectedObject=null;this.isObjectClick=!1}; +Entry.Stage.prototype.initStage=function(b){this.canvas=new createjs.Stage(b.id);this.canvas.x=320;this.canvas.y=180;this.canvas.scaleX=this.canvas.scaleY=2/1.5;createjs.Touch.enable(this.canvas);this.canvas.enableMouseOver(10);this.canvas.mouseMoveOutside=!0;this.canvas.addChild(this.background);this.canvas.addChild(this.variableContainer);this.canvas.addChild(this.dialogContainer);this.inputField=null;this.initCoordinator();this.initHandle();this.mouseCoordinate={x:0,y:0};if(Entry.isPhone())b.ontouchstart= +function(a){Entry.dispatchEvent("canvasClick",a);Entry.stage.isClick=!0},b.ontouchend=function(a){Entry.stage.isClick=!1;Entry.dispatchEvent("canvasClickCanceled",a)};else{var a=function(a){Entry.dispatchEvent("canvasClick",a);Entry.stage.isClick=!0};b.onmousedown=a;b.ontouchstart=a;a=function(a){Entry.stage.isClick=!1;Entry.dispatchEvent("canvasClickCanceled",a)};b.onmouseup=a;b.ontouchend=a;$(document).click(function(a){Entry.stage.focused="entryCanvas"===a.target.id?!0:!1})}Entry.addEventListener("canvasClick", +function(a){Entry.stage.isObjectClick=!1});Entry.windowResized.attach(this,function(){Entry.stage.updateBoundRect()});a=function(a){a.preventDefault();var b=Entry.stage.getBoundRect(),e;-1this.offsetY?a.rawY/ 2:this.offsetY}),this.scrollButton_.on("pressmove",function(a){void 0===this.moveAmount?(this.y=a.target.y,this.moveAmount=!0):this.y=a.rawY/2-this.offsetY+this.list.height_/100*23;23>this.y&&(this.y=23);this.y>this.list.getHeight()-40&&(this.y=this.list.getHeight()-40);this.list.updateView()}),this.scrollButton_.on("pressup",function(a){this.moveAmount=void 0}),this.getX()&&this.getY()?(this.setX(this.getX()),this.setY(this.getY())):(a=Entry.variableContainer.lists_.length,this.setX(110*-Math.floor(a/ 6)+120),this.setY(24*b+20-135-145*Math.floor(a/6)));this.setVisible(this.isVisible());this.updateView();Entry.stage.loadVariable(this)}; -Entry.Variable.prototype.updateView=function(){if(this.view_&&this.isVisible())if("variable"==this.type){this.view_.x=this.getX();this.view_.y=this.getY();if(this.object_){var b=Entry.container.getObject(this.object_);this.textView_.text=b?b.name+":"+this.getName():this.getName()}else this.textView_.text=this.getName();this.valueView_.x=this.textView_.getMeasuredWidth()+14;this.valueView_.y=1;this.isNumber()?this.valueView_.text=this.getValue().toFixed(2).replace(".00",""):this.valueView_.text=this.getValue(); -this.rect_.graphics.clear().f("#ffffff").ss(1,2,0).s("#A0A1A1").rc(0,-14,this.textView_.getMeasuredWidth()+this.valueView_.getMeasuredWidth()+26,20,4,4,4,4);this.wrapper_.graphics.clear().f("#1bafea").ss(1,2,0).s("#1bafea").rc(this.textView_.getMeasuredWidth()+7,-11,this.valueView_.getMeasuredWidth()+15,14,7,7,7,7)}else if("slide"==this.type)this.view_.x=this.getX(),this.view_.y=this.getY(),this.object_?(b=Entry.container.getObject(this.object_),this.textView_.text=b?b.name+":"+this.getName():this.getName()): -this.textView_.text=this.getName(),this.valueView_.x=this.textView_.getMeasuredWidth()+14,this.valueView_.y=1,this.isNumber()?this.valueView_.text=this.getValue().toFixed(2).replace(".00",""):this.valueView_.text=this.getValue(),b=this.textView_.getMeasuredWidth()+this.valueView_.getMeasuredWidth()+26,b=Math.max(b,90),this.rect_.graphics.clear().f("#ffffff").ss(1,2,0).s("#A0A1A1").rc(0,-14,b,33,4,4,4,4),this.wrapper_.graphics.clear().f("#1bafea").ss(1,2,0).s("#1bafea").rc(this.textView_.getMeasuredWidth()+ -7,-11,this.valueView_.getMeasuredWidth()+15,14,7,7,7,7),b=this.textView_.getMeasuredWidth()+this.valueView_.getMeasuredWidth()+26,b=Math.max(b,90),this.maxWidth=b-20,this.slideBar_.graphics.clear().beginFill("#A0A1A1").s("#A0A1A1").ss(1).dr(10,10,this.maxWidth,1.5),b=this.getSlidePosition(this.maxWidth),this.valueSetter_.graphics.clear().beginFill("#1bafea").s("#A0A1A1").ss(1).dc(b,10.5,3);else if("list"==this.type){this.view_.x=this.getX();this.view_.y=this.getY();this.resizeHandle_.x=this.width_- -2;this.resizeHandle_.y=this.height_-2;var a=this.getName();this.object_&&(b=Entry.container.getObject(this.object_))&&(a=b.name+":"+a);a=7this.getHeight()-40&& -(this.scrollButton_.y=this.getHeight()-40),this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20,-2,this.getWidth()-20-10-2*this.BORDER,17,2),this.scrollButton_.visible=!0,this.scrollButton_.x=this.getWidth()-12,this.scrollPosition=Math.floor((this.scrollButton_.y-23)/(this.getHeight()-23-40)*(this.array_.length-b))):(this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20,-2,this.getWidth()-20-2*this.BORDER,17,2),this.scrollButton_.visible=!1,this.scrollPosition=0);for(a=this.scrollPosition;a< -this.scrollPosition+b&&ac.length?c+"..":c;this.elementView.valueView.text=c;c=this.elementView.clone(!0);c.y=20*(a-this.scrollPosition)+23;this.view_.addChild(c)}}else"answer"==this.type?(this.view_.x=this.getX(),this.view_.y=this.getY(),this.textView_.text=this.getName(),this.valueView_.x=this.textView_.getMeasuredWidth()+ -14,this.valueView_.y=1,this.isNumber()?parseInt(this.getValue(),10)==this.getValue()?this.valueView_.text=this.getValue():this.valueView_.text=this.getValue().toFixed(1).replace(".00",""):this.valueView_.text=this.getValue(),this.rect_.graphics.clear().f("#ffffff").ss(1,2,0).s("#A0A1A1").rc(0,-14,this.textView_.getMeasuredWidth()+this.valueView_.getMeasuredWidth()+26,20,4,4,4,4),this.wrapper_.graphics.clear().f("#E457DC").ss(1,2,0).s("#E457DC").rc(this.textView_.getMeasuredWidth()+7,-11,this.valueView_.getMeasuredWidth()+ -15,14,7,7,7,7)):(this.view_.x=this.getX(),this.view_.y=this.getY(),this.textView_.text=this.getName(),this.valueView_.x=this.textView_.getMeasuredWidth()+14,this.valueView_.y=1,this.isNumber()?this.valueView_.text=this.getValue().toFixed(1).replace(".00",""):this.valueView_.text=this.getValue(),this.rect_.graphics.clear().f("#ffffff").ss(1,2,0).s("#A0A1A1").rc(0,-14,this.textView_.getMeasuredWidth()+this.valueView_.getMeasuredWidth()+26,20,4,4,4,4),this.wrapper_.graphics.clear().f("#ffbb14").ss(1, -2,0).s("orange").rc(this.textView_.getMeasuredWidth()+7,-11,this.valueView_.getMeasuredWidth()+15,14,7,7,7,7))};Entry.Variable.prototype.getName=function(){return this.name_};Entry.Variable.prototype.setName=function(b){Entry.assert("string"==typeof b,"Variable name must be string");this.name_=b;this.updateView()};Entry.Variable.prototype.getId=function(){return this.id_};Entry.Variable.prototype.getValue=function(){return this.isNumber()?Number(this.value_):this.value_}; -Entry.Variable.prototype.isNumber=function(){return isNaN(this.value_)?!1:!0};Entry.Variable.prototype.setValue=function(b){"slide"!=this.type?this.value_=b:(b=Number(b),this.value_=bthis.maxValue_?this.maxValue_:b);this.isCloud_&&Entry.variableContainer.updateCloudVariables();this.updateView()};Entry.Variable.prototype.isVisible=function(){return this.visible_}; -Entry.Variable.prototype.setVisible=function(b){Entry.assert("boolean"==typeof b,"Variable visible state must be boolean");(this.visible_=this.view_.visible=b)&&this.updateView()};Entry.Variable.prototype.setX=function(b){this.x_=b;this.updateView()};Entry.Variable.prototype.getX=function(){return this.x_};Entry.Variable.prototype.setY=function(b){this.y_=b;this.updateView()};Entry.Variable.prototype.getY=function(){return this.y_}; +Entry.Variable.prototype.updateView=function(){if(this.view_){if(this.isVisible())if("variable"==this.type){this.view_.x=this.getX();this.view_.y=this.getY();if(this.object_){var b=Entry.container.getObject(this.object_);this.textView_.text=b?b.name+":"+this.getName():this.getName()}else this.textView_.text=this.getName();null===this._nameWidth&&(this._nameWidth=this.textView_.getMeasuredWidth());this.valueView_.x=this._nameWidth+14;this.valueView_.y=1;this.isNumber()?this.valueView_.text=this.getValue().toFixed(2).replace(".00", +""):this.valueView_.text=this.getValue();null===this._valueWidth&&(this._valueWidth=this.valueView_.getMeasuredWidth());this.rect_.graphics.clear().f("#ffffff").ss(1,2,0).s("#A0A1A1").rc(0,-14,this._nameWidth+this._valueWidth+26,20,4,4,4,4);this.wrapper_.graphics.clear().f("#1bafea").ss(1,2,0).s("#1bafea").rc(this._nameWidth+7,-11,this._valueWidth+15,14,7,7,7,7)}else if("slide"==this.type)this.view_.x=this.getX(),this.view_.y=this.getY(),this.object_?(b=Entry.container.getObject(this.object_),this.textView_.text= +b?b.name+":"+this.getName():this.getName()):this.textView_.text=this.getName(),null===this._nameWidth&&(this._nameWidth=this.textView_.getMeasuredWidth()),this.valueView_.x=this._nameWidth+14,this.valueView_.y=1,this.isNumber()?this.valueView_.text=this.getValue().toFixed(2).replace(".00",""):this.valueView_.text=this.getValue(),null===this._valueWidth&&(this._valueWidth=this.valueView_.getMeasuredWidth()),b=this._nameWidth+this._valueWidth+26,b=Math.max(b,90),this.rect_.graphics.clear().f("#ffffff").ss(1, +2,0).s("#A0A1A1").rc(0,-14,b,33,4,4,4,4),this.wrapper_.graphics.clear().f("#1bafea").ss(1,2,0).s("#1bafea").rc(this._nameWidth+7,-11,this._valueWidth+15,14,7,7,7,7),b=this._nameWidth+this._valueWidth+26,b=Math.max(b,90),this.maxWidth=b-20,this.slideBar_.graphics.clear().beginFill("#A0A1A1").s("#A0A1A1").ss(1).dr(10,10,this.maxWidth,1.5),b=this.getSlidePosition(this.maxWidth),this.valueSetter_.graphics.clear().beginFill("#1bafea").s("#A0A1A1").ss(1).dc(b,10.5,3);else if("list"==this.type){this.view_.x= +this.getX();this.view_.y=this.getY();this.resizeHandle_.x=this.width_-2;this.resizeHandle_.y=this.height_-2;var a=this.getName();this.object_&&(b=Entry.container.getObject(this.object_))&&(a=b.name+":"+a);a=7this.getHeight()-40&&(this.scrollButton_.y=this.getHeight()-40),this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20,-2,this.getWidth()-20-10-2*this.BORDER,17,2),this.scrollButton_.visible=!0,this.scrollButton_.x=this.getWidth()-12,this.scrollPosition=Math.floor((this.scrollButton_.y-23)/(this.getHeight()-23-40)*(this.array_.length-b))):(this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20,-2,this.getWidth()-20-2*this.BORDER, +17,2),this.scrollButton_.visible=!1,this.scrollPosition=0);for(a=this.scrollPosition;ac.length?c+"..":c;this.elementView.valueView.text=c;c=this.elementView.clone(!0);c.y=20*(a-this.scrollPosition)+23;this.view_.addChild(c)}}else"answer"==this.type?(this.view_.x=this.getX(),this.view_.y= +this.getY(),this.textView_.text=this.getName(),this.valueView_.y=1,this.isNumber()?parseInt(this.getValue(),10)==this.getValue()?this.valueView_.text=this.getValue():this.valueView_.text=this.getValue().toFixed(1).replace(".00",""):this.valueView_.text=this.getValue(),null===this._nameWidth&&(this._nameWidth=this.textView_.getMeasuredWidth()),null===this._valueWidth&&(this._valueWidth=this.valueView_.getMeasuredWidth()),this.valueView_.x=this._nameWidth+14,this.rect_.graphics.clear().f("#ffffff").ss(1, +2,0).s("#A0A1A1").rc(0,-14,this._nameWidth+this._valueWidth+26,20,4,4,4,4),this.wrapper_.graphics.clear().f("#E457DC").ss(1,2,0).s("#E457DC").rc(this._nameWidth+7,-11,this._valueWidth+15,14,7,7,7,7)):(this.view_.x=this.getX(),this.view_.y=this.getY(),this.textView_.text=this.getName(),null===this._nameWidth&&(this._nameWidth=this.textView_.getMeasuredWidth()),this.valueView_.x=this._nameWidth+14,this.valueView_.y=1,this.isNumber()?this.valueView_.text=this.getValue().toFixed(1).replace(".00",""): +this.valueView_.text=this.getValue(),null===this._valueWidth&&(this._valueWidth=this.valueView_.getMeasuredWidth()),this.rect_.graphics.clear().f("#ffffff").ss(1,2,0).s("#A0A1A1").rc(0,-14,this._nameWidth+this._valueWidth+26,20,4,4,4,4),this.wrapper_.graphics.clear().f("#ffbb14").ss(1,2,0).s("orange").rc(this._nameWidth+7,-11,this._valueWidth+15,14,7,7,7,7));Entry.requestUpdate=!0}};Entry.Variable.prototype.getName=function(){return this.name_}; +Entry.Variable.prototype.setName=function(b){Entry.assert("string"==typeof b,"Variable name must be string");this.name_=b;this._nameWidth=null;this.updateView();Entry.requestUpdateTwice=!0};Entry.Variable.prototype.getId=function(){return this.id_};Entry.Variable.prototype.getValue=function(){return this.isNumber()?Number(this.value_):this.value_};Entry.Variable.prototype.isNumber=function(){return isNaN(this.value_)?!1:!0}; +Entry.Variable.prototype.setValue=function(b){"slide"!=this.type?this.value_=b:(b=Number(b),this.value_=bthis.maxValue_?this.maxValue_:b);this.isCloud_&&Entry.variableContainer.updateCloudVariables();this._valueWidth=null;this.updateView();Entry.requestUpdateTwice=!0};Entry.Variable.prototype.isVisible=function(){return this.visible_}; +Entry.Variable.prototype.setVisible=function(b){Entry.assert("boolean"==typeof b,"Variable visible state must be boolean");this.visible!==b&&(this.visible_=this.view_.visible=b,this.updateView())};Entry.Variable.prototype.setX=function(b){this.x_=b;this.updateView()};Entry.Variable.prototype.getX=function(){return this.x_};Entry.Variable.prototype.setY=function(b){this.y_=b;this.updateView()};Entry.Variable.prototype.getY=function(){return this.y_}; Entry.Variable.prototype.setWidth=function(b){this.width_=100>b?100:b;this.updateView()};Entry.Variable.prototype.getWidth=function(){return this.width_};Entry.Variable.prototype.isInList=function(b,a){this.getX();this.getY()};Entry.Variable.prototype.setHeight=function(b){this.height_=100>b?100:b;this.updateView()};Entry.Variable.prototype.getHeight=function(){return this.height_};Entry.Variable.prototype.takeSnapshot=function(){this.snapshot_=this.toJSON()}; Entry.Variable.prototype.loadSnapshot=function(){this.snapshot_&&!this.isCloud_&&this.syncModel_(this.snapshot_)};Entry.Variable.prototype.syncModel_=function(b){this.setX(b.x);this.setY(b.y);this.id_=b.id;this.setVisible(b.visible);this.setValue(b.value);this.setName(b.name);this.isCloud_=b.isCloud;"list"==this.type&&(this.setWidth(b.width),this.setHeight(b.height),this.array_=b.array)}; Entry.Variable.prototype.toJSON=function(){var b={};b.name=this.name_;b.id=this.id_;b.visible=this.visible_;b.value=this.value_;b.variableType=this.type;"list"==this.type?(b.width=this.getWidth(),b.height=this.getHeight(),b.array=JSON.parse(JSON.stringify(this.array_))):"slide"==this.type&&(b.minValue=this.minValue_,b.maxValue=this.maxValue_);b.isCloud=this.isCloud_;b.object=this.object_;b.x=this.x_;b.y=this.y_;return b};Entry.Variable.prototype.remove=function(){Entry.stage.removeVariable(this)}; @@ -1267,8 +1273,7 @@ Entry.VariableContainer.prototype.checkAllVariableName=function(b,a){a=this[a];f Entry.VariableContainer.prototype.addVariable=function(b){if(!b){var a=this.variableAddPanel;b=a.view.name.value.trim();b&&0!==b.length||(b=Lang.Workspace.variable);b.length>this._maxNameLength&&(b=this._truncName(b,"variable"));b=this.checkAllVariableName(b,"variables_")?Entry.getOrderedName(b,this.variables_,"name_"):b;var c=a.info;b={name:b,isCloud:c.isCloud,object:c.object,variableType:"variable"};a.view.addClass("entryRemove");this.resetVariableAddPanel("variable")}b=new Entry.Variable(b);Entry.stateManager&& Entry.stateManager.addCommand("add variable",this,this.removeVariable,b);b.generateView(this.variables_.length);this.createVariableView(b);this.variables_.unshift(b);Entry.playground.reloadPlayground();this.updateList();return new Entry.State(this,this.removeVariable,b)}; Entry.VariableContainer.prototype.removeVariable=function(b){var a=this.variables_.indexOf(b),c=b.toJSON();this.selected==b&&this.select(null);b.remove();this.variables_.splice(a,1);Entry.stateManager&&Entry.stateManager.addCommand("remove variable",this,this.addVariable,c);Entry.playground.reloadPlayground();this.updateList();return new Entry.State(this,this.addVariable,c)}; -Entry.VariableContainer.prototype.changeVariableName=function(b,a){b.name_!=a&&(Entry.isExist(a,"name_",this.variables_)?(b.listElement.nameField.value=b.name_,Entry.toast.alert(Lang.Workspace.variable_rename_failed,Lang.Workspace.variable_dup)):10e)var h=d,d=e,e=h;f>g&&(h=f,f=g,g=h);c-=d;c*=(g-f)/(e-d);c+=f;c=Math.min(g,c);c=Math.max(f, c);return Math.round(c)}},sensorBoard_get_named_sensor_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["\uc18c\ub9ac","0"],["\ube5b \uac10\uc9c0","1"],["\uc2ac\ub77c\uc774\ub354","2"],["\uc628\ub3c4","3"]],value:"0",fontSize:11}],events:{},def:{params:[null],type:"sensorBoard_get_named_sensor_value"},paramsKeyMap:{PORT:0},"class":"sensorBoard",isNotFor:["sensorBoard"],func:function(b,a){return Entry.hw.getAnalogPortValue(a.getField("PORT", @@ -1515,7 +1520,7 @@ null,null],type:"quotient_and_mod"},paramsKeyMap:{LEFTHAND:1,RIGHTHAND:3,OPERATO "START"],[Lang.Blocks.CALC_choose_project_timer_action_sub_2,"STOP"],[Lang.Blocks.CALC_choose_project_timer_action_sub_3,"RESET"]],value:"START",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC},{type:"Text",text:Lang.Blocks.CALC_choose_project_timer_action_2,color:"#3D3D3D"},{type:"Indicator",img:"block_icon/calc_01.png",size:12}],events:{viewAdd:[function(){Entry.engine&&Entry.engine.showProjectTimer()}],dataDestroy:[function(b){Entry.engine&&Entry.engine.hideProjectTimer(b)}]},def:{params:[null, "START",null,null],type:"choose_project_timer_action"},paramsKeyMap:{ACTION:1},"class":"calc_timer",isNotFor:[],func:function(b,a){var c=a.getField("ACTION"),d=Entry.engine,e=d.projectTimer;"START"==c?e.isInit?e.isInit&&e.isPaused&&(e.pauseStart&&(e.pausedTime+=(new Date).getTime()-e.pauseStart),delete e.pauseStart,e.isPaused=!1):d.startProjectTimer():"STOP"==c?e.isInit&&!e.isPaused&&(e.isPaused=!0,e.pauseStart=(new Date).getTime()):"RESET"==c&&e.isInit&&(e.setValue(0),e.start=(new Date).getTime(), e.pausedTime=0,delete e.pauseStart);return a.callReturn()}},wait_second:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[{type:"number",params:["2"]},null],type:"wait_second"},paramsKeyMap:{SECOND:0},"class":"delay",isNotFor:[],func:function(b,a){if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;return a.callReturn()}a.isStart=!0; -a.timeFlag=1;var c=a.getNumberValue("SECOND",a);setTimeout(function(){a.timeFlag=0},60/(Entry.FPS||60)*c*1E3);return a}},repeat_basic:{color:"#498deb",skeleton:"basic_loop",statements:[{accept:"basic"}],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"repeat_basic"},paramsKeyMap:{VALUE:0},statementsKeyMap:{DO:0},"class":"repeat",isNotFor:[],func:function(b,a){var c;if(!a.isLooped){a.isLooped= +a.timeFlag=1;var c=a.getNumberValue("SECOND",a),c=60/(Entry.FPS||60)*c*1E3;setTimeout(function(){a.timeFlag=0},c);return a}},repeat_basic:{color:"#498deb",skeleton:"basic_loop",statements:[{accept:"basic"}],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"repeat_basic"},paramsKeyMap:{VALUE:0},statementsKeyMap:{DO:0},"class":"repeat",isNotFor:[],func:function(b,a){var c;if(!a.isLooped){a.isLooped= !0;c=a.getNumberValue("VALUE",a);if(0>c)throw Error(Lang.Blocks.FLOW_repeat_basic_errorMsg);a.iterCount=Math.floor(c)}if(0==a.iterCount||0>a.iterCount)return delete a.isLooped,delete a.iterCount,a.callReturn();a.iterCount--;return a.getStatement("DO",a)}},repeat_inf:{color:"#498deb",skeleton:"basic_loop",statements:[{accept:"basic"}],params:[{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null],type:"repeat_inf"},statementsKeyMap:{DO:0},"class":"repeat",isNotFor:[], func:function(b,a){a.isLooped=!0;return a.getStatement("DO")}},stop_repeat:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null],type:"stop_repeat"},"class":"repeat",isNotFor:[],func:function(b,a){return this.executor.breakLoop()}},wait_until_true:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"Block",accept:"boolean"},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[{type:"True"}, null],type:"wait_until_true"},paramsKeyMap:{BOOL:0},"class":"wait",isNotFor:[],func:function(b,a){return a.getBooleanValue("BOOL",a)?a.callReturn():a}},_if:{color:"#498deb",skeleton:"basic_loop",statements:[{accept:"basic"}],params:[{type:"Block",accept:"boolean"},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[{type:"True"},null],type:"_if"},paramsKeyMap:{BOOL:0},statementsKeyMap:{STACK:0},"class":"condition",isNotFor:[],func:function(b,a){return a.isCondition?(delete a.isCondition, @@ -1525,11 +1530,11 @@ a),d=a.callReturn();"self"==c?b.parent.addCloneEntity(b.parent,b,null):Entry.con statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_clone.png",size:17,position:{x:0,y:-2}}],events:{},def:{params:[null],type:"when_clone_start"},"class":"clone",isNotFor:[],func:function(b,a){return a.callReturn()},event:"when_clone_start"},stop_run:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null]},func:function(b,a){return Entry.engine.toggleStop()}},repeat_while_true:{color:"#498deb",skeleton:"basic_loop", statements:[{accept:"basic"}],params:[{type:"Block",accept:"boolean"},{type:"Dropdown",options:[[Lang.Blocks.FLOW_repeat_while_true_until,"until"],[Lang.Blocks.FLOW_repeat_while_true_while,"while"]],value:"until",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_FLOW},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[{type:"True"},null,null],type:"repeat_while_true"},paramsKeyMap:{BOOL:0,OPTION:1},statementsKeyMap:{DO:0},"class":"repeat",isNotFor:[],func:function(b,a){var c= a.getBooleanValue("BOOL",a);"until"==a.getField("OPTION",a)&&(c=!c);return(a.isLooped=c)?a.getStatement("DO",a):a.callReturn()}},stop_object:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.FLOW_stop_object_all,"all"],[Lang.Blocks.FLOW_stop_object_this_object,"thisOnly"],[Lang.Blocks.FLOW_stop_object_this_thread,"thisThread"],[Lang.Blocks.FLOW_stop_object_other_thread,"otherThread"]],value:"all",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_FLOW},{type:"Indicator", -img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null,null],type:"stop_object"},paramsKeyMap:{TARGET:0},"class":"terminate",isNotFor:[],func:function(b,a){var c=a.getField("TARGET",a),d=Entry.container;switch(c){case "all":return d.clearRunningState(),this.die();case "thisOnly":return b.parent.script.clearExecutorsByEntity(b),this.die();case "thisObject":return b.parent.script.clearExecutors(),this.die();case "thisThread":return this.die();case "otherThread":return b.parent.script.clearExecutors(), -b.parent.script.addExecutor(this.executor),a.callReturn()}}},restart_project:{color:"#498deb",skeleton:"basic_without_next",statements:[],params:[{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null],type:"restart_project"},"class":"terminate",isNotFor:[],func:function(b,a){Entry.engine.toggleStop();Entry.engine.toggleRun()}},remove_all_clones:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{}, -def:{params:[null],type:"remove_all_clones"},"class":"clone",isNotFor:[],func:function(b,a){var c=b.parent.getClonedEntities();c.map(function(a){a.removeClone()});c=null;return a.callReturn()}},functionAddButton:{skeleton:"basic_button",color:"#eee",isNotFor:["functionInit"],params:[{type:"Text",text:Lang.Workspace.function_create,color:"#333",align:"center"}],events:{mousedown:[function(){Entry.variableContainer.createFunction()}]}},function_field_label:{skeleton:"basic_param",isNotFor:["functionEdit"], -color:"#f9c535",params:[{type:"TextInput",value:Lang.Blocks.FUNCTION_explanation_1},{type:"Output",accept:"param"}],paramsKeyMap:{NAME:0,NEXT:1},def:{params:["\uc774\ub984"],type:"function_field_label"}},function_field_string:{skeleton:"basic_param",isNotFor:["functionEdit"],color:"#ffd974",params:[{type:"Block",accept:"string",restore:!0},{type:"Output",accept:"param"}],paramsKeyMap:{PARAM:0,NEXT:1},def:{params:[{type:"text",params:["\ubb38\uc790/\uc22b\uc790\uac12"]}],type:"function_field_string"}}, -function_field_boolean:{skeleton:"basic_param",isNotFor:["functionEdit"],color:"#aeb8ff",params:[{type:"Block",accept:"boolean",restore:!0},{type:"Output",accept:"param"}],paramsKeyMap:{PARAM:0,NEXT:1},def:{params:[{type:"True",params:["\ud310\ub2e8\uac12"]}],type:"function_field_boolean"}},function_param_string:{skeleton:"basic_string_field",color:"#ffd974",template:"%1 %2",events:{viewAdd:[function(){Entry.Func.refreshMenuCode()}]},func:function(){return this.executor.register.params[this.executor.register.paramMap[this.block.type]]}}, +img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null,null],type:"stop_object"},paramsKeyMap:{TARGET:0},"class":"terminate",isNotFor:[],func:function(b,a){var c=a.getField("TARGET",a),d=Entry.container;switch(c){case "all":return d.clearRunningState(),this.die();case "thisOnly":return b.parent.script.clearExecutorsByEntity(b),this.die();case "thisObject":return b.parent.script.clearExecutors(),this.die();case "thisThread":return this.die();case "otherThread":for(var c=this.executor,d= +b.parent.script,e=d.executors,f=0;f'),{parent:this.blockMenuContainer});this.svgDom.mouseenter(function(a){d._scroller&& d._scroller.setOpacity(1);a=d.workspace.selectedBlockView;!Entry.playground||Entry.playground.resizing||a&&a.dragMode===Entry.DRAG_MODE_DRAG||(Entry.playground.focusBlockMenu=!0,a=d.svgGroup.getBBox(),a=a.width+a.x+64,a>Entry.interfaceState.menuWidth&&(this.widthBackup=Entry.interfaceState.menuWidth-64,$(this).stop().animate({width:a-62},200)))});this.svgDom.mouseleave(function(a){Entry.playground&&!Entry.playground.resizing&&(d._scroller&&d._scroller.setOpacity(0),(a=this.widthBackup)&&$(this).stop().animate({width:a}, 200),delete this.widthBackup,delete Entry.playground.focusBlockMenu)});$(window).scroll(function(){d.updateOffset()})};b.changeCode=function(a){if(!(a instanceof Entry.Code))return console.error("You must inject code instance");this.codeListener&&this.code.changeEvent.detach(this.codeListener);var b=this;this.set({code:a});this.codeListener=this.code.changeEvent.attach(this,function(){b.changeEvent.notify()});a.createView(this);this.align()};b.bindCodeView=function(a){this.svgBlockGroup.remove(); @@ -1893,10 +1898,10 @@ d&&Entry.playground.checkVariables();"arduino"==d&&this._generateHwCode();var e= function(){h.scroller.resizeScrollBar.call(h.scroller);k.removeClass("foldOut");Entry.windowResized.notify()});this.visible&&(f=this._categoryCodes[d],this._selectedCategoryView=e,e.addClass("entrySelectedCategory"),f.constructor!==Entry.Code&&(f=this._categoryCodes[d]=new Entry.Code(f)),this.changeCode(f));this.lastSelector=d}};b._generateCategoryCodes=function(a){this._categoryCodes={};for(var b=0;bthis._bannedClass.indexOf(a)&&this._bannedClass.push(a);this.align(b)};b.unbanClass=function(a,b){var d=this._bannedClass.indexOf(a);-1b&&(a.preventDefault(),this.selectMenu(b-49))};b.setPatternRectFill=function(a){this.patternRect.attr({fill:a})};b._clearCategory=function(){this._selectedCategoryView=null;this._categories=[];var a=this._categoryElems,b;for(b in a)a[b].remove();this._categoryElems={};a=this._categoryCodes;for(b in a){var d=a[b];d.constructor==Entry.Code&&d.clear()}this._categoryCodes=null};b.setCategoryData=function(a){this._clearCategory(); -this._categoryData=a;this._generateCategoryView(a);this._generateCategoryCodes(a)};b._generateCategoryView=function(a){if(a)for(var b=0;bb&&(a.preventDefault(),this.selectMenu(b-49))};b.setPatternRectFill=function(a){this.patternRect.attr({fill:a});this.pattern.attr({style:""})};b.disablePattern=function(){this.pattern.attr({style:"display: none"})};b._clearCategory=function(){this._selectedCategoryView=null;this._categories=[];var a=this._categoryElems,b;for(b in a)a[b].remove();this._categoryElems={};a=this._categoryCodes;for(b in a){var d=a[b];d.constructor== +Entry.Code&&d.clear()}this._categoryCodes=null};b.setCategoryData=function(a){this._clearCategory();this._categoryData=a;this._generateCategoryView(a);this._generateCategoryCodes(a)};b._generateCategoryView=function(a){if(a)for(var b=0;b=b?this.setVisible(!1):this.setVisible(!0)};b._reset=function(){this.vY=0;this.vScrollbar.attr({y:this.vY});this.resizeScrollBar()};b.onMouseDown=function(a){function b(a){a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault();a=a.originalEvent&&a.originalEvent.touches?a.originalEvent.touches[0]:a;var c=e.dragInstance; @@ -1933,11 +1938,11 @@ this.visible?0:1});this.visible&&this._setPosition()};b._updateShadow=function() this.block.isCopyable():void 0!==this._skeleton.copyable?this._skeleton.copyable:!0};b.bumpAway=function(a,b){var d=this;a=a||15;b?window.setTimeout(function(){d._moveBy(a,a,!1)},b):d._moveBy(a,a,!1)};b.bindPrev=function(a){if(a){if(this._toLocalCoordinate(a.view._nextGroup),(a=a.getNextBlock())&&a!==this.block){var b=this.block.getLastBlock();b.view.magnet.next?a.view._toLocalCoordinate(b.view._nextGroup):(a.view._toGlobalCoordinate(),a.separate(),a.view.bumpAway(null,100))}}else if(a=this.block.getPrevBlock())this._toLocalCoordinate(a.view._nextGroup), (a=this.block.getNextBlock())&&a.view&&a.view._toLocalCoordinate(this._nextGroup)};b.getAbsoluteCoordinate=function(a){a=void 0!==a?a:this.dragMode;if(a===Entry.DRAG_MODE_DRAG)return{x:this.x,y:this.y};a=this.block.getThread().view.requestAbsoluteCoordinate(this);a.x+=this.x;a.y+=this.y;return a};b.getBelowHeight=function(){return this.block.getThread().view.requestPartHeight(this)};b._updateDisplay=function(){this.svgGroup.attr({display:!1===this.display?"none":"block"});this.display&&this._setPosition()}; b._updateColor=function(){var a=this._schema.color;this.block.deletable===Entry.Block.DELETABLE_FALSE_LIGHTEN&&(a=Entry.Utils.colorLighten(a));this._fillColor=a;this._path.attr({fill:a});this._updateContents()};b._updateContents=function(){for(var a=0;a\s+/g,">").replace(/\s+(svgGroup)(defs)',h=this.svgGroup.getBoundingClientRect(),k=a?this.svgGroup:this.svgGroup.cloneNode(!0),l=this._skeleton.box(this),q=b?1:1.5,n=function(){var a=window.platform;return a&&"windows"===a.name.toLowerCase()&&"7"===a.version[0]?!0:!1}()?.9:.95;-1<=+-x/".split(""),t=0;t\s+/g,">").replace(/\s+(svgGroup)(defs)',h=this.svgGroup.getBoundingClientRect(),k=a?this.svgGroup:this.svgGroup.cloneNode(!0),l=this._skeleton.box(this),q=b?1:1.5,n=function(){var a=window.platform;return a&&"windows"===a.name.toLowerCase()&&"7"===a.version[0]? +!0:!1}()?.9:.95;-1<=+-x/".split(""),t=0;t'), -{parent:this.wrapper});this.visible=!0;var d=this;this.svg=Entry.SVG(this._svgId);$(window).scroll(function(){d.updateOffset()});this.svgGroup=this.svg.elem("g");this.svgThreadGroup=this.svgGroup.elem("g");this.svgThreadGroup.board=this;this.svgBlockGroup=this.svgGroup.elem("g");this.svgBlockGroup.board=this;a.isOverlay?(this.wrapper.addClass("entryOverlayBoard"),this.generateButtons(),this.suffix="overlayBoard"):this.suffix="board";Entry.Utils.addFilters(this.svg,this.suffix);this.patternRect=Entry.Utils.addBlockPattern(this.svg, -this.suffix)};b.changeCode=function(a){this.code&&this.codeListener&&this.code.changeEvent.detach(this.codeListener);this.set({code:a});var b=this;a&&(this.codeListener=this.code.changeEvent.attach(this,function(){b.changeEvent.notify()}),a.createView(this));this.scroller.resizeScrollBar()};b.bindCodeView=function(a){this.svgBlockGroup.remove();this.svgThreadGroup.remove();this.svgBlockGroup=a.svgBlockGroup;this.svgThreadGroup=a.svgThreadGroup;this.svgGroup.appendChild(this.svgThreadGroup);this.svgGroup.appendChild(this.svgBlockGroup)}; -b.setMagnetedBlock=function(a,b){if(this.magnetedBlockView){if(this.magnetedBlockView===a)return;this.magnetedBlockView.set({magneting:!1})}this.set({magnetedBlockView:a});a&&(a.set({magneting:b}),a.dominate())};b.getCode=function(){return this.code};b.findById=function(a){return this.code.findById(a)};b._addControl=function(){var a=this.svgDom,b=this;a.mousedown(function(){b.onMouseDown.apply(b,arguments)});a.bind("touchstart",function(){b.onMouseDown.apply(b,arguments)});a.on("wheel",function(){b.mouseWheel.apply(b, -arguments)});var d=b.scroller;d&&(a.mouseenter(function(a){d.setOpacity(1)}),a.mouseleave(function(a){d.setOpacity(0)}))};b.onMouseDown=function(a){function b(a){a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault();a=a.originalEvent&&a.originalEvent.touches?a.originalEvent.touches[0]:a;var c=f.dragInstance;f.scroller.scroll(a.pageX-c.offsetX,a.pageY-c.offsetY);c.set({offsetX:a.pageX,offsetY:a.pageY})}function d(a){$(document).unbind(".entryBoard");delete f.dragInstance}if(this.workspace.getMode()!= -Entry.Workspace.MODE_VIMBOARD){a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault();if(0===a.button||a.originalEvent&&a.originalEvent.touches){a=a.originalEvent&&a.originalEvent.touches?a.originalEvent.touches[0]:a;Entry.documentMousedown&&Entry.documentMousedown.notify(a);var e=$(document);e.bind("mousemove.entryBoard",b);e.bind("mouseup.entryBoard",d);e.bind("touchmove.entryBoard",b);e.bind("touchend.entryBoard",d);this.dragInstance=new Entry.DragInstance({startX:a.pageX, -startY:a.pageY,offsetX:a.pageX,offsetY:a.pageY})}else if(Entry.Utils.isRightButton(a)){if(!this.visible)return;a=[];this._contextOptions[Entry.Board.OPTION_PASTE].option.enable=!!Entry.clipboard;this._contextOptions[Entry.Board.OPTION_DOWNLOAD].option.enable=0!==this.code.getThreads().length;for(e=0;ea&&(f=f+e+10,e=0,d=15);e=Math.max(e,k.width);l=d+15;h._moveTo(f,l,!1);d=d+k.height+15}}this.scroller.resizeScrollBar()};b.clear=function(){this.svgBlockGroup.remove();this.svgThreadGroup.remove()};b.updateOffset=function(){this._offset= -this.svg.getBoundingClientRect();var a=$(window),b=a.scrollTop(),a=a.scrollLeft(),d=this._offset;this.relativeOffset={top:d.top-b,left:d.left-a};this.btnWrapper&&this.btnWrapper.attr({transform:"translate("+(d.width/2-65)+","+(d.height-200)+")"})};b.generateButtons=function(){var a=this,b=this.svgGroup.elem("g");this.btnWrapper=b;var d=b.elem("text",{x:27,y:33,class:"entryFunctionButtonText"});d.textContent=Lang.Buttons.save;var e=b.elem("text",{x:102.5,y:33,class:"entryFunctionButtonText"});e.textContent= -Lang.Buttons.cancel;var f=b.elem("circle",{cx:27.5,cy:27.5,r:27.5,class:"entryFunctionButton"}),b=b.elem("circle",{cx:102.5,cy:27.5,r:27.5,class:"entryFunctionButton"});$(f).bind("mousedown touchstart",function(){a.save()});$(d).bind("mousedown touchstart",function(){a.save()});$(b).bind("mousedown touchstart",function(){a.cancelEdit()});$(e).bind("mousedown touchstart",function(){a.cancelEdit()})};b.cancelEdit=function(){this.workspace.setMode(Entry.Workspace.MODE_BOARD,"cancelEdit")};b.save=function(){this.workspace.setMode(Entry.Workspace.MODE_BOARD, -"save")};b.generateCodeMagnetMap=function(){var a=this.code;if(a&&this.dragBlock)for(var b in this.dragBlock.magnet){var d=this._getCodeBlocks(a,b);d.sort(function(a,b){return a.point-b.point});d.unshift({point:-Number.MAX_VALUE,blocks:[]});for(var e=1;eg.point&&(g.blocks.push(h),l++,g=d[l],g););delete f.startBlock}f.endPoint=Number.MAX_VALUE;d[e-1].endPoint=f.point}this._magnetMap[b]=d}};b._getCodeBlocks=function(a,b){var d= -a.getThreads(),e=[],f;switch(b){case "previous":f=this._getNextMagnets;break;case "next":f=this._getPreviousMagnets;break;case "string":f=this._getFieldMagnets;break;case "boolean":f=this._getFieldMagnets;break;case "param":f=this._getOutputMagnets;break;default:return[]}for(var g=0;gd.endPoint)f=h+1;else{e=d.blocks;for(f=0;fa&&(f=f+e+10,e=0,d=15);e=Math.max(e,k.width);l=d+15;h._moveTo(f,l,!1);d=d+k.height+15}}this.scroller.resizeScrollBar()};b.clear=function(){this.svgBlockGroup.remove();this.svgThreadGroup.remove()};b.updateOffset= +function(){this._offset=this.svg.getBoundingClientRect();var a=$(window),b=a.scrollTop(),a=a.scrollLeft(),d=this._offset;this.relativeOffset={top:d.top-b,left:d.left-a};this.btnWrapper&&this.btnWrapper.attr({transform:"translate("+(d.width/2-65)+","+(d.height-200)+")"})};b.generateButtons=function(){var a=this,b=this.svgGroup.elem("g");this.btnWrapper=b;var d=b.elem("text",{x:27,y:33,class:"entryFunctionButtonText"});d.textContent=Lang.Buttons.save;var e=b.elem("text",{x:102.5,y:33,class:"entryFunctionButtonText"}); +e.textContent=Lang.Buttons.cancel;var f=b.elem("circle",{cx:27.5,cy:27.5,r:27.5,class:"entryFunctionButton"}),b=b.elem("circle",{cx:102.5,cy:27.5,r:27.5,class:"entryFunctionButton"});$(f).bind("mousedown touchstart",function(){a.save()});$(d).bind("mousedown touchstart",function(){a.save()});$(b).bind("mousedown touchstart",function(){a.cancelEdit()});$(e).bind("mousedown touchstart",function(){a.cancelEdit()})};b.cancelEdit=function(){this.workspace.setMode(Entry.Workspace.MODE_BOARD,"cancelEdit")}; +b.save=function(){this.workspace.setMode(Entry.Workspace.MODE_BOARD,"save")};b.generateCodeMagnetMap=function(){var a=this.code;if(a&&this.dragBlock)for(var b in this.dragBlock.magnet){var d=this._getCodeBlocks(a,b);d.sort(function(a,b){return a.point-b.point});d.unshift({point:-Number.MAX_VALUE,blocks:[]});for(var e=1;eg.point&&(g.blocks.push(h),l++,g=d[l],g););delete f.startBlock}f.endPoint=Number.MAX_VALUE;d[e-1].endPoint= +f.point}this._magnetMap[b]=d}};b._getCodeBlocks=function(a,b){var d=a.getThreads(),e=[],f;switch(b){case "previous":f=this._getNextMagnets;break;case "next":f=this._getPreviousMagnets;break;case "string":f=this._getFieldMagnets;break;case "boolean":f=this._getFieldMagnets;break;case "param":f=this._getOutputMagnets;break;default:return[]}for(var g=0;gd.endPoint)f=h+1;else{e=d.blocks;for(f=0;f alphaThreshold at one coordinate - pixelIntersection = _compareAlphaValues(imageData1,imageData2,intersection.width,intersection.height,alphaThreshold, getRect); + pixelIntersection = _compareAlphaValues(imageData1,imageData2,intersection.width / threshold,intersection.height,alphaThreshold / threshold, getRect); if ( pixelIntersection ) { pixelIntersection.x += intersection.x; @@ -147,18 +151,15 @@ this.ndgmr = this.ndgmr || {}; ctx.restore(); ctx.save(); //ctx.clearRect(0,0,intersetion.width,intersetion.height); - ctx.rotate(_getParentalCumulatedProperty(bitmap,'rotation')*(Math.PI/180)); - ctx.scale(_getParentalCumulatedProperty(bitmap,'scaleX','*'),_getParentalCumulatedProperty(bitmap,'scaleY','*')); - ctx.translate(-bl.x-intersetion['rect'+i].regX,-bl.y-intersetion['rect'+i].regY); + ctx.rotate(_getParentalCumulatedProperty(bitmap,'rotation')*(Math.PI/181)); + ctx.scale(_getParentalCumulatedProperty(bitmap,'scaleX','*') / threshold,_getParentalCumulatedProperty(bitmap,'scaleY','*') / threshold); + ctx.translate((-bl.x-intersetion['rect'+i].regX) / threshold,( -bl.y-intersetion['rect'+i].regY) / threshold); if ( (sr = bitmap.sourceRect) != undefined ) { ctx.drawImage(image,sr.x,sr.y,sr.width,sr.height,0,0,sr.width,sr.height); } else { - ctx.drawImage(image,0,0,image.width,image.height); + ctx.drawImage(image,0,0,image.width / threshold,image.height / threshold); } - if (intersection.width === 0 || intersection.height == 0) - return false; - else - return ctx.getImageData(0, 0, intersetion.width, intersetion.height).data; + return ctx.getImageData(0, 0, intersetion.width / threshold, intersetion.height / threshold).data; } var _compareAlphaValues = function(imageData1,imageData2,width,height,alphaThreshold,getRect) { diff --git a/src/container.js b/src/container.js index 6c0d0b4cac..95431b7460 100644 --- a/src/container.js +++ b/src/container.js @@ -471,6 +471,7 @@ Entry.Container.prototype.moveElement = function(start, end, isCallFromState) { this.objects_.splice(endIndex, 0, this.objects_.splice(startIndex, 1)[0]); this.setCurrentObjects(); Entry.container.updateListView(); + Entry.requestUpdate = true; return new Entry.State(Entry.container, Entry.container.moveElement, endIndex, startIndex, true); diff --git a/src/css/components/engine.less b/src/css/components/engine.less index da11c8d616..f47c4967cc 100644 --- a/src/css/components/engine.less +++ b/src/css/components/engine.less @@ -85,7 +85,7 @@ .entryPopupWindow > .entryEngineWorkspace_w > .entryEngineButtonWorkspace_w { position: absolute; - bottom: 1px; + bottom: 3px; } .entryPopupWindow > .entryEngineWorkspace_w > .entryAddButtonWorkspace_w { @@ -298,7 +298,9 @@ .entryPopupWindow .entryMouseViewWorkspace_w { font-size: 9pt; margin: 0 auto; - width: 100%; + width: 40%; + margin-left: -20%; + left: 50%; color: @bora; line-height: 24px; text-align: center; diff --git a/src/css/components/property_panel.less b/src/css/components/property_panel.less index 29633cb33f..55ff0b6634 100644 --- a/src/css/components/property_panel.less +++ b/src/css/components/property_panel.less @@ -1,4 +1,5 @@ .propertyPanel { + z-index: 10; position: absolute; top: 326px; bottom: 0px; diff --git a/src/css/components/stage.less b/src/css/components/stage.less index 28a36e241a..4b7fa61c3e 100644 --- a/src/css/components/stage.less +++ b/src/css/components/stage.less @@ -4,18 +4,12 @@ .entryCanvasWorkspace { width: 480px; - height: 270px; background-color: white; display: block; position: absolute; top: 24px; } -.entryPopupWindow .entryCanvasWorkspace { - top: -11px !important; -} - - .entryCanvasPhone { width: 100%; background-color: white; @@ -24,7 +18,6 @@ .entryPopupWindow > .entryCanvasWorkspace { width: 100% !important; - height: 100% !important; position: relative; border-bottom: 1px solid #ccc; border-top: 0px; @@ -43,6 +36,5 @@ bottom: 24px; border-bottom: 1px solid #ccc; width: 100% !important; - height: 100% !important; - top: -25px !important; + top: 0; } diff --git a/src/dialog.js b/src/dialog.js index 5c5f2d71ce..e670c8350b 100644 --- a/src/dialog.js +++ b/src/dialog.js @@ -57,6 +57,7 @@ Entry.Dialog.prototype.generateSpeak = function() { this.update(); this.object.addChild(this.notch); this.object.addChild(text); + Entry.requestUpdate = true; }; /** @@ -85,6 +86,7 @@ Entry.Dialog.prototype.update = function() { this.notch = this.createSpeakNotch(notchType); this.object.addChild(this.notch); } + Entry.requestUpdate = true; }; /** diff --git a/src/engine.js b/src/engine.js index f152341c61..9f67a93be1 100644 --- a/src/engine.js +++ b/src/engine.js @@ -14,26 +14,28 @@ Entry.Engine = function() { this.isUpdating = true; this.speeds = [1, 15, 30, 45, 60]; + this._mouseMoved = false;; if (Entry.keyPressed) Entry.keyPressed.attach(this, this.captureKeyEvent); - Entry.addEventListener('canvasClick', function(e){ + Entry.addEventListener('canvasClick', function(e) { Entry.engine.fireEvent('mouse_clicked'); }); - Entry.addEventListener('canvasClickCanceled', function(e){ + Entry.addEventListener('canvasClickCanceled', function(e) { Entry.engine.fireEvent('mouse_click_cancled'); }); - Entry.addEventListener('entityClick', function(entity){ + Entry.addEventListener('entityClick', function(entity) { Entry.engine.fireEventOnEntity('when_object_click', entity); }); - Entry.addEventListener('entityClickCanceled', function(entity){ + Entry.addEventListener('entityClickCanceled', function(entity) { Entry.engine.fireEventOnEntity('when_object_click_canceled', entity); }); + if (Entry.type != 'phone') { Entry.addEventListener('stageMouseMove', function(e){ - Entry.engine.updateMouseView(); - }); + this._mouseMoved = true; + }.bind(this)); Entry.addEventListener('stageMouseOut', function(e){ Entry.engine.hideMouseView(); }); @@ -51,12 +53,18 @@ Entry.Engine = function() { var arrows = [37,38,39,40,32]; var code = (e.keyCode || e.which); var input = Entry.stage.inputField; - if (code == 32 && input && - input.hasFocus()) + if (code == 32 && input && input.hasFocus()) return; if(arrows.indexOf(code) > -1) e.preventDefault(); } + + setInterval(function() { + if (this._mouseMoved) { + this.updateMouseView(); + this._mouseMoved = false; + } + }.bind(this), 100) }; /** @@ -446,6 +454,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 +556,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'); } }; @@ -645,7 +673,7 @@ Entry.Engine.prototype.raiseKeyEvent = function(entity, param) { */ Entry.Engine.prototype.updateMouseView = function() { var coordinate = Entry.stage.mouseCoordinate; - this.mouseView.innerHTML = 'X : ' + coordinate.x + ', Y : ' + coordinate.y; + this.mouseView.textContent = 'X : ' + coordinate.x + ', Y : ' + coordinate.y; this.mouseView.removeClass('entryRemove'); }; @@ -669,12 +697,14 @@ Entry.Engine.prototype.toggleFullscreen = function() { $('body').css('overflow', 'hidden'); popup.window_.appendChild(Entry.stage.canvas.canvas); + popup.window_.appendChild(Entry.engine.runButton[0]); } popup.window_.appendChild(Entry.engine.view_); } else { this.popup.remove(); this.popup = null; } + Entry.windowResized.notify(); }; Entry.Engine.prototype.exitFullScreen = function() { @@ -685,6 +715,7 @@ Entry.Engine.prototype.exitFullScreen = function() { Entry.engine.footerView_.removeClass('entryRemove'); Entry.engine.headerView_.removeClass('entryRemove'); } + Entry.windowResized.notify(); }; @@ -746,12 +777,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); diff --git a/src/entity.js b/src/entity.js index 886394f165..36410a2545 100644 --- a/src/entity.js +++ b/src/entity.js @@ -181,6 +181,7 @@ Entry.EntityObject.prototype.setX = function(x) { if (!this.isClone) this.parent.updateCoordinateView(); this.updateDialog(); + Entry.requestUpdate = true; }; /** @@ -204,6 +205,7 @@ Entry.EntityObject.prototype.setY = function(y) { if (!this.isClone) this.parent.updateCoordinateView(); this.updateDialog(); + Entry.requestUpdate = true; }; /** @@ -246,6 +248,7 @@ Entry.EntityObject.prototype.setDirection = function(direction, flippable) { if (!this.isClone) this.parent.updateRotationView(); Entry.dispatchEvent('updateObject'); + Entry.requestUpdate = true; }; /** @@ -263,6 +266,7 @@ Entry.EntityObject.prototype.setRotation = function(rotation) { if (!this.isClone) this.parent.updateRotationView(); Entry.dispatchEvent('updateObject'); + Entry.requestUpdate = true; }; /** @@ -283,7 +287,7 @@ Entry.EntityObject.prototype.setRegX = function(regX) { /** @type {number} */ this.regX = regX; this.object.regX = this.regX; - + Entry.requestUpdate = true; }; /** @@ -304,6 +308,7 @@ Entry.EntityObject.prototype.setRegY = function(regY) { /** @type {number} */ this.regY = regY; this.object.regY = this.regY; + Entry.requestUpdate = true; }; /** @@ -324,6 +329,7 @@ Entry.EntityObject.prototype.setScaleX = function(scaleX) { this.object.scaleX = this.scaleX; this.parent.updateCoordinateView(); this.updateDialog(); + Entry.requestUpdate = true; }; /** @@ -344,6 +350,7 @@ Entry.EntityObject.prototype.setScaleY = function(scaleY) { this.object.scaleY = this.scaleY; this.parent.updateCoordinateView(); this.updateDialog(); + Entry.requestUpdate = true; }; /** @@ -366,6 +373,7 @@ Entry.EntityObject.prototype.setSize = function(size) { this.setScaleY(this.getScaleY() * scale); if (!this.isClone) this.parent.updateCoordinateView(); + Entry.requestUpdate = true; }; /** @@ -388,6 +396,7 @@ Entry.EntityObject.prototype.setWidth = function(width) { this.textObject.lineWidth = this.width; this.updateDialog(); this.updateBG(); + Entry.requestUpdate = true; }; /** @@ -411,6 +420,7 @@ Entry.EntityObject.prototype.setHeight = function(height) { } this.updateDialog(); this.updateBG(); + Entry.requestUpdate = true; }; /** @@ -432,6 +442,7 @@ Entry.EntityObject.prototype.setColour = function(colour) { this.colour = colour; if (this.textObject) this.textObject.color = this.colour; + Entry.requestUpdate = true; }; /** @@ -453,6 +464,7 @@ Entry.EntityObject.prototype.setBGColour = function(colour) { this.bgColor = colour; this.updateBG(); //this.object.color = this.colour; + Entry.requestUpdate = true; }; /** @@ -468,6 +480,7 @@ Entry.EntityObject.prototype.setUnderLine = function(underLine) { underLine = false; this.underLine = underLine; this.textObject.underLine = underLine; + Entry.requestUpdate = true; }; Entry.EntityObject.prototype.getUnderLine = function() { @@ -479,6 +492,7 @@ Entry.EntityObject.prototype.setStrike = function(strike) { strike = false; this.strike = strike; this.textObject.strike = strike; + Entry.requestUpdate = true; }; Entry.EntityObject.prototype.getStrike = function() { @@ -543,6 +557,7 @@ Entry.EntityObject.prototype.syncFont = function() { this.setWidth(this.textObject.getMeasuredWidth()); } Entry.stage.updateObject(); + Entry.requestUpdate = true; }; /** @@ -588,6 +603,7 @@ Entry.EntityObject.prototype.setFontSize = function(fontSize) { */ Entry.EntityObject.prototype.setFontBold = function(isFontBold) { this.fontBold = isFontBold; + Entry.requestUpdate = true; }; /** @@ -604,6 +620,7 @@ Entry.EntityObject.prototype.toggleFontBold = function() { */ Entry.EntityObject.prototype.setFontItalic = function(isFontItalic) { this.fontItalic = isFontItalic; + Entry.requestUpdate = true; }; /** @@ -750,6 +767,7 @@ Entry.EntityObject.prototype.setVisible = function(visible) { this.object.visible = this.visible; if (this.dialog) this.syncDialogVisible(); + Entry.requestUpdate = true; return this.visible; }; @@ -806,6 +824,7 @@ Entry.EntityObject.prototype.setImage = function(pictureModel) { thisPointer.object.cache(0,0,thisPointer.getWidth(),thisPointer.getHeight()); //Entry.dispatchEvent('updateObject'); thisPointer = null; + Entry.requestUpdate = true; }; } else { Entry.image = image; @@ -905,6 +924,7 @@ Entry.EntityObject.prototype.applyFilter = function() { } return true; } + Entry.requestUpdate = true; }; @@ -919,6 +939,7 @@ Entry.EntityObject.prototype.resetFilter = function() { this.object.alpha = this.effect.alpha; this.object.cache(0,0,this.getWidth(),this.getHeight()); + Entry.requestUpdate = true; }; /** @@ -927,6 +948,7 @@ Entry.EntityObject.prototype.resetFilter = function() { Entry.EntityObject.prototype.updateDialog = function() { if (this.dialog) this.dialog.update(); + Entry.requestUpdate = true; }; /** @@ -945,6 +967,7 @@ Entry.EntityObject.prototype.loadSnapshot = function() { this.syncModel_(this.snapshot_); if (this.parent.objectType == 'sprite') this.setImage(this.parent.getPicture()); + Entry.requestUpdate = true; }; /** @@ -1005,6 +1028,7 @@ Entry.EntityObject.prototype.toJSON = function() { */ Entry.EntityObject.prototype.setInitialEffectValue = function () { this.effect = this.getInitialEffectValue(); + Entry.requestUpdate = true; }; /* diff --git a/src/entry.js b/src/entry.js index 12b14d1cea..a9e7cd055d 100644 --- a/src/entry.js +++ b/src/entry.js @@ -217,7 +217,6 @@ Entry.resizeElement = function(interfaceModel) { Entry.engine.view_.style.width = canvasSize + 'px'; Entry.engine.view_.style.height = canvasHeight + 'px'; Entry.engine.view_.style.top = '40px'; - Entry.stage.canvas.canvas.style.height = canvasHeight + 'px'; Entry.stage.canvas.canvas.style.width = canvasSize + 'px'; if (canvasSize >= 400) { Entry.engine.view_.removeClass("collapsed"); diff --git a/src/object.js b/src/object.js index b1992db5c4..5266e7b3fd 100644 --- a/src/object.js +++ b/src/object.js @@ -87,6 +87,7 @@ Entry.EntryObject = function(model) { image.onload = function(e) { Entry.container.cachePicture(picture.id, image); Entry.Loader.removeQueue(); + Entry.requestUpdate = true; }; } } diff --git a/src/playground.js b/src/playground.js index dbfc61bce4..f777d70bb2 100644 --- a/src/playground.js +++ b/src/playground.js @@ -1260,8 +1260,10 @@ Entry.Playground.prototype.flushPlayground = function () { Entry.Playground.prototype.refreshPlayground = function () { if (Entry.playground && Entry.playground.view_) { - this.injectPicture(); - this.injectSound(); + if (this.getViewMode() === "picture") + this.injectPicture(); + if (this.getViewMode() === "sound") + this.injectSound(); } }; diff --git a/src/scene.js b/src/scene.js index 8b3ef1bbc9..7db99d4a35 100644 --- a/src/scene.js +++ b/src/scene.js @@ -314,6 +314,7 @@ Entry.Scene.prototype.selectScene = function(scene) { Entry.stage.sortZorder(); Entry.container.updateListView(); this.updateView(); + Entry.requestUpdate = true; }; /** diff --git a/src/stage.js b/src/stage.js index d4387bf07e..aa0c0cc4f4 100644 --- a/src/stage.js +++ b/src/stage.js @@ -5,6 +5,8 @@ */ 'use strict'; +goog.require('Entry.Utils'); + /** * class for a canvas * @constructor @@ -85,9 +87,14 @@ Entry.Stage.prototype.initStage = function(canvas) { // Entry.container.selectObject(); Entry.stage.isObjectClick = false; }); + + Entry.windowResized.attach(this, function() { + Entry.stage.updateBoundRect(); + }); + var moveFunc = function(e){ e.preventDefault(); - var roundRect = this.getBoundingClientRect(); + var roundRect = Entry.stage.getBoundRect(); var x, y; if (Entry.getBrowserType().indexOf("IE") > -1) { x = ((e.pageX - roundRect.left - document.documentElement.scrollLeft) / roundRect.width - 0.5) * 480; @@ -109,6 +116,7 @@ Entry.Stage.prototype.initStage = function(canvas) { canvas.onmouseout = function(e) { Entry.dispatchEvent('stageMouseOut'); }; + Entry.addEventListener('updateObject', function(e){ if (Entry.engine.isState('stop')) Entry.stage.updateObject(); @@ -130,8 +138,10 @@ Entry.Stage.prototype.initStage = function(canvas) { this.initWall(); + this.render(); }; + Entry.Stage.prototype.render = function() { if (Entry.stage.timer) clearTimeout(Entry.stage.timer); @@ -145,6 +155,10 @@ Entry.Stage.prototype.render = function() { * redraw canvas */ Entry.Stage.prototype.update = function() { + if (!Entry.requestUpdate) { + Entry.requestUpdate = false; + return; + } if (Entry.engine.isState('stop') && this.objectUpdated) { this.canvas.update(); this.objectUpdated = false; @@ -153,6 +167,10 @@ Entry.Stage.prototype.update = function() { } if ( this.inputField && !this.inputField._isHidden ) this.inputField.render(); + if (Entry.requestUpdateTwice) + Entry.requestUpdateTwice = false; + else + Entry.requestUpdate = false; }; /** @@ -199,7 +217,7 @@ Entry.Stage.prototype.loadVariable = function(variable) { var variableView = variable.view_; this.variables[variable.id] = variableView; this.variableContainer.addChild(variableView); - this.canvas.update(); + Entry.requestUpdate = true; }; /** @@ -209,7 +227,7 @@ Entry.Stage.prototype.loadVariable = function(variable) { Entry.Stage.prototype.removeVariable = function(variable) { var variableView = variable.view_; this.variableContainer.removeChild(variableView); - this.canvas.update(); + Entry.requestUpdate = true; }; /** @@ -310,6 +328,7 @@ Entry.Stage.prototype.initHandle = function() { * object -> handle */ Entry.Stage.prototype.updateObject = function() { + Entry.requestUpdate = true; this.handle.setDraggable(true); if (this.editEntity) return; @@ -551,6 +570,7 @@ Entry.Stage.prototype.showInputField = function (sprite) { } this.inputField.show(); + Entry.requestUpdateTwice = true; }; @@ -568,6 +588,7 @@ Entry.Stage.prototype.hideInputField = function () { if (this.inputField) this.inputField.hide(); + Entry.requestUpdate = true; }; @@ -682,3 +703,13 @@ Entry.Stage.prototype.moveSprite = function (e) { this.updateObject(); }; +Entry.Stage.prototype.getBoundRect = function (e) { + if (!this._boundRect) + this.updateBoundRect(); + return this._boundRect; +}; + +Entry.Stage.prototype.updateBoundRect = function (e) { + this._boundRect = this.canvas.canvas.getBoundingClientRect(); +}; + diff --git a/src/util/utils.js b/src/util/utils.js index 6d92e0425a..b92f965b81 100644 --- a/src/util/utils.js +++ b/src/util/utils.js @@ -1064,7 +1064,8 @@ Entry.Utils.addBlockPattern = function (boardSvgDom, suffix) { patternTransform: "translate(12, 0)", x: 0, y: 0, width: 125, - height: 33 + height: 33, + style: "display: none" }); var group = pattern.elem('g'); @@ -1088,7 +1089,10 @@ Entry.Utils.addBlockPattern = function (boardSvgDom, suffix) { }); } - return elem; + return { + pattern: pattern, + rect: elem + } }; Entry.Utils.COLLISION = { @@ -1211,3 +1215,12 @@ Entry.Utils.waitForWebfonts = function(fonts, callback) { })(fonts[i]); } }; +window.requestAnimFrame = (function(){ + return window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + function( callback ){ + window.setTimeout(callback, 1000 / 60); + }; +})(); + diff --git a/src/variable.js b/src/variable.js index 700628d59e..8b11bf5a1f 100644 --- a/src/variable.js +++ b/src/variable.js @@ -19,6 +19,10 @@ Entry.Variable = function(variable) { this.object_ = variable.object || null; /** @type {boolean} */ this.isCloud_ = variable.isCloud || false; + + this._nameWidth = null; + this._valueWidth = null; + /** @type {number||string} */ var parsedValue = Entry.parseNumber(variable.value); if (typeof parsedValue == 'number') @@ -328,22 +332,24 @@ Entry.Variable.prototype.updateView = function() { this.textView_.text = this.getName(); } else this.textView_.text = this.getName(); - this.valueView_.x = this.textView_.getMeasuredWidth() + 14; + if (this._nameWidth === null) + this._nameWidth = this.textView_.getMeasuredWidth(); + this.valueView_.x = this._nameWidth + 14; this.valueView_.y = 1; - if (this.isNumber()) { + if (this.isNumber()) this.valueView_.text = this.getValue().toFixed(2).replace('.00', ''); - } - else { + else this.valueView_.text = this.getValue(); - } + if (this._valueWidth === null) + this._valueWidth = this.valueView_.getMeasuredWidth(); this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1") .rc(0, -14, - this.textView_.getMeasuredWidth() + this.valueView_.getMeasuredWidth() + 26, 20, + this._nameWidth + this._valueWidth + 26, 20, 4, 4, 4, 4); this.wrapper_.graphics.clear().f("#1bafea").ss(1, 2, 0).s("#1bafea") - .rc(this.textView_.getMeasuredWidth() + 7, -11, - this.valueView_.getMeasuredWidth() + 15, 14, + .rc(this._nameWidth + 7, -11, + this._valueWidth + 15, 14, 7, 7, 7, 7); } else if (this.type == 'slide') { this.view_.x = this.getX(); @@ -356,7 +362,9 @@ Entry.Variable.prototype.updateView = function() { this.textView_.text = this.getName(); } else this.textView_.text = this.getName(); - this.valueView_.x = this.textView_.getMeasuredWidth() + 14; + if (this._nameWidth === null) + this._nameWidth = this.textView_.getMeasuredWidth(); + this.valueView_.x = this._nameWidth + 14; this.valueView_.y = 1; if (this.isNumber()) { this.valueView_.text = this.getValue().toFixed(2).replace('.00', ''); @@ -364,18 +372,20 @@ Entry.Variable.prototype.updateView = function() { this.valueView_.text = this.getValue(); } - var width = this.textView_.getMeasuredWidth() + this.valueView_.getMeasuredWidth() + 26; + if (this._valueWidth === null) + this._valueWidth = this.valueView_.getMeasuredWidth(); + var width = this._nameWidth + this._valueWidth + 26; width = Math.max(width, 90); this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1") .rc(0, -14, width, 33, 4, 4, 4, 4); this.wrapper_.graphics.clear().f("#1bafea").ss(1, 2, 0).s("#1bafea") - .rc(this.textView_.getMeasuredWidth() + 7, -11, - this.valueView_.getMeasuredWidth() + 15, 14, + .rc(this._nameWidth + 7, -11, + this._valueWidth + 15, 14, 7, 7, 7, 7); - var width = this.textView_.getMeasuredWidth() + this.valueView_.getMeasuredWidth() + 26; + var width = this._nameWidth + this._valueWidth + 26; width = Math.max(width, 90); this.maxWidth = width -20; @@ -447,7 +457,6 @@ Entry.Variable.prototype.updateView = function() { this.view_.x = this.getX(); this.view_.y = this.getY(); this.textView_.text = this.getName(); - this.valueView_.x = this.textView_.getMeasuredWidth() + 14; this.valueView_.y = 1; if (this.isNumber()) { if (parseInt(this.getValue(),10) == this.getValue()) @@ -457,39 +466,50 @@ Entry.Variable.prototype.updateView = function() { } else { this.valueView_.text = this.getValue(); - } + if (this._nameWidth === null) + this._nameWidth = this.textView_.getMeasuredWidth(); + if (this._valueWidth === null) + this._valueWidth = this.valueView_.getMeasuredWidth(); + + this.valueView_.x = this._nameWidth + 14; this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1") .rc(0, -14, - this.textView_.getMeasuredWidth() + this.valueView_.getMeasuredWidth() + 26, 20, + this._nameWidth + this._valueWidth + 26, 20, 4, 4, 4, 4); this.wrapper_.graphics.clear().f("#E457DC").ss(1, 2, 0).s("#E457DC") - .rc(this.textView_.getMeasuredWidth() + 7, -11, - this.valueView_.getMeasuredWidth() + 15, 14, + .rc(this._nameWidth + 7, -11, + this._valueWidth + 15, 14, 7, 7, 7, 7); } else { this.view_.x = this.getX(); this.view_.y = this.getY(); this.textView_.text = this.getName(); - this.valueView_.x = this.textView_.getMeasuredWidth() + 14; + + if (this._nameWidth === null) + this._nameWidth = this.textView_.getMeasuredWidth(); + + this.valueView_.x = this._nameWidth + 14; this.valueView_.y = 1; - if (this.isNumber()) { + if (this.isNumber()) this.valueView_.text = this.getValue().toFixed(1).replace('.00', ''); - } - else { + else this.valueView_.text = this.getValue(); - } + if (this._valueWidth === null) + this._valueWidth = this.valueView_.getMeasuredWidth(); + this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1") .rc(0, -14, - this.textView_.getMeasuredWidth() + this.valueView_.getMeasuredWidth() + 26, 20, + this._nameWidth + this._valueWidth + 26, 20, 4, 4, 4, 4); this.wrapper_.graphics.clear().f("#ffbb14").ss(1, 2, 0).s("orange") - .rc(this.textView_.getMeasuredWidth() + 7, -11, - this.valueView_.getMeasuredWidth() + 15, 14, + .rc(this._nameWidth + 7, -11, + this._valueWidth + 15, 14, 7, 7, 7, 7); } } + Entry.requestUpdate = true; }; /** @@ -508,7 +528,9 @@ Entry.Variable.prototype.setName = function(variableName) { Entry.assert(typeof variableName == 'string', 'Variable name must be string'); this.name_ = variableName; + this._nameWidth = null; this.updateView(); + Entry.requestUpdateTwice = true; }; /** @@ -555,7 +577,9 @@ Entry.Variable.prototype.setValue = function(value) { } if (this.isCloud_) Entry.variableContainer.updateCloudVariables(); + this._valueWidth = null; this.updateView(); + Entry.requestUpdateTwice = true; }; /** @@ -573,10 +597,11 @@ Entry.Variable.prototype.isVisible = function() { Entry.Variable.prototype.setVisible = function(visibleState) { Entry.assert(typeof visibleState == 'boolean', 'Variable visible state must be boolean'); + if (this.visible === visibleState) + return; this.view_.visible = visibleState; this.visible_ = visibleState; - if (visibleState) - this.updateView(); + this.updateView(); }; /** diff --git a/src/variable_container.js b/src/variable_container.js index 12c2f2b413..53152ac650 100644 --- a/src/variable_container.js +++ b/src/variable_container.js @@ -863,8 +863,7 @@ Entry.VariableContainer.prototype.changeVariableName = function(variable, name) Lang.Workspace.variable_too_long); return; } - variable.name_ = name; - variable.updateView(); + variable.setName(name); Entry.playground.reloadPlayground(); Entry.toast.success(Lang.Workspace.variable_rename, Lang.Workspace.variable_rename_ok); diff --git a/src/workspace/block_entry.js b/src/workspace/block_entry.js index 48468d5e11..5d5b537c35 100644 --- a/src/workspace/block_entry.js +++ b/src/workspace/block_entry.js @@ -5890,8 +5890,17 @@ Entry.block = { case 'thisThread': return this.die(); case 'otherThread': - sprite.parent.script.clearExecutors(); - sprite.parent.script.addExecutor(this.executor); + var executor = this.executor; + var code = sprite.parent.script; + var executors = code.executors; + + for (var i = 0 ; i < executors.length; i++) { + var currentExecutor = executors[i]; + if (currentExecutor !== executor) { + code.removeExecutor(currentExecutor); + --i; + } + } return script.callReturn(); } } @@ -9881,8 +9890,8 @@ Entry.block = { "isNotFor": [], "func": function (sprite, script) { var value1 = script.getNumberValue("VALUE1", script); - sprite.setX(value1); var value2 = script.getNumberValue("VALUE2", script); + sprite.setX(value1); sprite.setY(value2); if (sprite.brush && !sprite.brush.stop) { sprite.brush.lineTo(sprite.getX(), sprite.getY()*-1); diff --git a/src/workspace/block_menu.js b/src/workspace/block_menu.js index e31d80c570..853f65905e 100644 --- a/src/workspace/block_menu.js +++ b/src/workspace/block_menu.js @@ -37,7 +37,9 @@ Entry.BlockMenu = function(dom, align, categoryData, scroll) { this.svg = Entry.SVG(this._svgId); Entry.Utils.addFilters(this.svg, this.suffix); - this.patternRect = Entry.Utils.addBlockPattern(this.svg, this.suffix); + var returnVal = Entry.Utils.addBlockPattern(this.svg, this.suffix); + this.patternRect = returnVal.rect; + this.pattern = returnVal.pattern; this.svgGroup = this.svg.elem("g"); @@ -560,7 +562,18 @@ Entry.BlockMenu = function(dom, align, categoryData, scroll) { }; p.setPatternRectFill = function(color) { - this.patternRect.attr({fill:color}); + this.patternRect.attr({ + fill:color + }); + this.pattern.attr({ + style: "" + }); + }; + + p.disablePattern = function() { + this.pattern.attr({ + style: "display: none" + }); }; p._clearCategory = function() { diff --git a/src/workspace/block_view.js b/src/workspace/block_view.js index 9fd1a81b54..6fd86b56d7 100644 --- a/src/workspace/block_view.js +++ b/src/workspace/block_view.js @@ -968,13 +968,15 @@ Entry.BlockView.pngMap = {}; p._changeFill = function(isPattern) { var board = this.getBoard(); if (!board.patternRect || board.dragBlock) return; - var path = this._path; var fillColor = this._fillColor; + var path = this._path; + var board = this.getBoard(); if (isPattern) { - var board = this.getBoard(); board.setPatternRectFill(fillColor); fillColor = "url(#blockHoverPattern_" + this.getBoard().suffix +")"; + } else { + board.disablePattern(); } path.attr({fill:fillColor}); }; diff --git a/src/workspace/board.js b/src/workspace/board.js index e6a21e2e0a..35ce366b5d 100644 --- a/src/workspace/board.js +++ b/src/workspace/board.js @@ -100,7 +100,9 @@ Entry.Board.OPTION_DOWNLOAD = 3; } else this.suffix = 'board'; Entry.Utils.addFilters(this.svg, this.suffix); - this.patternRect = Entry.Utils.addBlockPattern(this.svg, this.suffix); + var returnVal = Entry.Utils.addBlockPattern(this.svg, this.suffix); + this.patternRect = returnVal.rect; + this.pattern = returnVal.pattern; }; p.changeCode = function(code) { @@ -788,7 +790,18 @@ Entry.Board.OPTION_DOWNLOAD = 3; }; p.setPatternRectFill = function(color) { - this.patternRect.attr({fill:color}); + this.patternRect.attr({ + fill:color + }); + this.pattern.attr({ + style: "" + }); + }; + + p.disablePattern = function() { + this.pattern.attr({ + style: "display: none" + }); }; p._removeActivated = function() { diff --git a/src/workspace/executors.js b/src/workspace/executors.js index c118e48aee..b767d1f694 100644 --- a/src/workspace/executors.js +++ b/src/workspace/executors.js @@ -154,11 +154,15 @@ Entry.Scope = function(block, executor) { }; p._getParamIndex = function(key) { - return Entry.block[this.type].paramsKeyMap[key]; + if (!this._schema) + this._schema = Entry.block[this.type]; + return this._schema.paramsKeyMap[key]; }; p._getStatementIndex = function(key) { - return Entry.block[this.type].statementsKeyMap[key]; + if (!this._schema) + this._schema = Entry.block[this.type]; + return this._schema.statementsKeyMap[key]; }; p.die = function() {