| 421 |
} |
} |
| 422 |
delete this.active_queue; |
delete this.active_queue; |
| 423 |
} |
} |
| 424 |
|
if(this.entities) { |
| 425 |
|
for(var i = 0; i < this.entities.length; i++) { |
| 426 |
|
if(!this.entities[i].scene) { |
| 427 |
|
this.entities[i].scene = this.scene; |
| 428 |
|
this.entities[i].activate(); |
| 429 |
|
} |
| 430 |
|
} |
| 431 |
|
} |
| 432 |
}; |
}; |
| 433 |
E.prototype.addActiveQueue = function (f) { |
E.prototype.addActiveQueue = function (f) { |
| 434 |
if(this.scene) { |
if(this.scene) { |
| 474 |
entity.scene = this.scene; |
entity.scene = this.scene; |
| 475 |
entity.parent = this; |
entity.parent = this; |
| 476 |
this.entities.push(entity); |
this.entities.push(entity); |
| 477 |
entity.activate(); |
if(this.scene) { |
| 478 |
|
entity.activate(); |
| 479 |
|
} |
| 480 |
}; |
}; |
| 481 |
E.prototype.removeChild = function (entity) { |
E.prototype.removeChild = function (entity) { |
| 482 |
if(!this.entities) { |
if(!this.entities) { |
| 1220 |
Scene.prototype.refresh = function () { |
Scene.prototype.refresh = function () { |
| 1221 |
for(var i in this.layers) { |
for(var i in this.layers) { |
| 1222 |
this.layers[i].refresh(); |
this.layers[i].refresh(); |
| 1223 |
|
this.layers[i].updated(); |
| 1224 |
} |
} |
| 1225 |
}; |
}; |
| 1226 |
Scene.prototype.scrollTo = function (x, y, layerName) { |
Scene.prototype.scrollTo = function (x, y, layerName) { |
| 1579 |
this.moveTo(0, 0); |
this.moveTo(0, 0); |
| 1580 |
} |
} |
| 1581 |
this.defaultStyle = "#000"; |
this.defaultStyle = "#000"; |
| 1582 |
this.defaultFont = "14px sans-serif"; |
this.defaultFont = "18px/2 sans-serif"; |
| 1583 |
this.defaultBlur = 0.8; |
this.defaultBlur = 0.6; |
| 1584 |
this.defaultShadowColor = "#000"; |
this.defaultShadowColor = "#000"; |
| 1585 |
|
this.defaultShadowOffsetX = 0.3; |
| 1586 |
|
this.defaultShadowOffsetY = 0.3; |
| 1587 |
this.clip = new Line({ |
this.clip = new Line({ |
| 1588 |
x: 0, |
x: 0, |
| 1589 |
y: 0 |
y: 0 |
| 1597 |
this.clip.setClip(true); |
this.clip.setClip(true); |
| 1598 |
this.entities = new Array(); |
this.entities = new Array(); |
| 1599 |
this.entities.push(this.clip); |
this.entities.push(this.clip); |
| 1600 |
this.animeSpeed = 200; |
this.animeSpeed = 400; |
| 1601 |
this.animated = new Trigger(); |
this.animated = new Trigger(); |
| 1602 |
} |
} |
| 1603 |
MultilineText.prototype.setText = function (text, offset) { |
MultilineText.prototype.setText = function (text, offset) { |
| 1620 |
return 16; |
return 16; |
| 1621 |
} |
} |
| 1622 |
var fontSize = parseInt(font.substring(lastPos, firstPos)); |
var fontSize = parseInt(font.substring(lastPos, firstPos)); |
| 1623 |
return fontSize + 2; |
var line_height = Math.round(fontSize * 1.2); |
| 1624 |
|
return line_height; |
| 1625 |
}; |
}; |
| 1626 |
MultilineText.prototype.createBuffer = function (offset) { |
MultilineText.prototype.createBuffer = function (offset) { |
| 1627 |
var _this = this; |
var _this = this; |
| 1643 |
c.textBaseline = "top"; |
c.textBaseline = "top"; |
| 1644 |
c.shadowBlur = this.defaultBlur; |
c.shadowBlur = this.defaultBlur; |
| 1645 |
c.shadowColor = this.defaultShadowColor; |
c.shadowColor = this.defaultShadowColor; |
| 1646 |
|
c.shadowOffsetX = this.defaultShadowOffsetX; |
| 1647 |
|
c.shadowOffsetY = this.defaultShadowOffsetY; |
| 1648 |
var lineHeight = this.getLineHeight(c); |
var lineHeight = this.getLineHeight(c); |
| 1649 |
var lineInfo = new TextLineInfo(0); |
var lineInfo = new TextLineInfo(0); |
| 1650 |
lineInfo.height = lineHeight; |
lineInfo.height = lineHeight; |
| 1652 |
var _newLine = function () { |
var _newLine = function () { |
| 1653 |
pos.x = 0; |
pos.x = 0; |
| 1654 |
pos.y += lineInfo.height; |
pos.y += lineInfo.height; |
| 1655 |
|
if((pos.y + lineInfo.height) > _this.height) { |
| 1656 |
|
return false; |
| 1657 |
|
} |
| 1658 |
lineInfo = new TextLineInfo(pos.y); |
lineInfo = new TextLineInfo(pos.y); |
| 1659 |
lineInfo.height = lineHeight; |
lineInfo.height = lineHeight; |
| 1660 |
_this.lines.push(lineInfo); |
_this.lines.push(lineInfo); |
| 1661 |
|
return true; |
| 1662 |
}; |
}; |
| 1663 |
while(offset < len) { |
while(offset < len) { |
| 1664 |
s = script.substr(offset, 1); |
s = script.substr(offset, 1); |
| 1665 |
switch(s) { |
if(s == "\n") { |
| 1666 |
case "\n": |
if(!_newLine()) { |
|
_newLine(); |
|
| 1667 |
break; |
break; |
| 1668 |
default: |
} |
| 1669 |
var metric = c.measureText(s); |
offset++; |
| 1670 |
if((pos.x + metric.width) > this.width) { |
continue; |
| 1671 |
_newLine(); |
} |
| 1672 |
} |
var metric = c.measureText(s); |
| 1673 |
c.fillText(s, pos.x, pos.y); |
if((pos.x + metric.width) > this.width) { |
| 1674 |
pos.x += metric.width; |
if(!_newLine()) { |
| 1675 |
lineInfo.width += metric.width; |
break; |
| 1676 |
|
} |
| 1677 |
} |
} |
| 1678 |
|
c.fillText(s, pos.x, pos.y); |
| 1679 |
|
pos.x += metric.width; |
| 1680 |
|
lineInfo.width += metric.width; |
| 1681 |
offset++; |
offset++; |
| 1682 |
} |
} |
| 1683 |
this.sprite = new Sprite(this.width, this.height, this.buffer); |
this.sprite = new Sprite(this.width, this.height, this.buffer); |
| 1720 |
} |
} |
| 1721 |
} |
} |
| 1722 |
if(this.animeLine >= this.lines.length) { |
if(this.animeLine >= this.lines.length) { |
|
this.stop(); |
|
| 1723 |
this.showAll(); |
this.showAll(); |
|
this.animated.fire(); |
|
| 1724 |
} else { |
} else { |
| 1725 |
this.clip.p[3].x = this.animePos.x; |
this.clip.p[3].x = this.animePos.x; |
| 1726 |
this.clip.p[4].x = this.clip.p[3].x; |
this.clip.p[4].x = this.clip.p[3].x; |
| 1778 |
x: 0, |
x: 0, |
| 1779 |
y: this.height |
y: this.height |
| 1780 |
}; |
}; |
| 1781 |
|
this.stop(); |
| 1782 |
|
this.animated.fire(); |
| 1783 |
}; |
}; |
| 1784 |
return MultilineText; |
return MultilineText; |
| 1785 |
})(E); |
})(E); |
| 2064 |
} |
} |
| 2065 |
c.save(); |
c.save(); |
| 2066 |
if(parent.options) { |
if(parent.options) { |
| 2067 |
this.useDrawOption(parent, c); |
if(this.useDrawOption(parent, c)) { |
| 2068 |
|
c.restore(); |
| 2069 |
|
return; |
| 2070 |
|
} |
| 2071 |
} |
} |
| 2072 |
if(parent.scroll) { |
if(parent.scroll) { |
| 2073 |
c.translate(parent.scroll.x, parent.scroll.y); |
c.translate(parent.scroll.x, parent.scroll.y); |
| 2084 |
c.save(); |
c.save(); |
| 2085 |
c.translate(entity.x, entity.y); |
c.translate(entity.x, entity.y); |
| 2086 |
if(entity.options) { |
if(entity.options) { |
| 2087 |
this.useDrawOption(entity, c); |
if(this.useDrawOption(entity, c)) { |
| 2088 |
|
c.restore(); |
| 2089 |
|
return; |
| 2090 |
|
} |
| 2091 |
} |
} |
| 2092 |
if(entity.filter) { |
if(entity.filter) { |
| 2093 |
this.filterDraw(entity, c); |
this.filterDraw(entity, c); |
| 2120 |
if(this.drawOptionFunctions[p]) { |
if(this.drawOptionFunctions[p]) { |
| 2121 |
this.drawOptionFunctions[p].call(this, c, entity, entity.options[p]); |
this.drawOptionFunctions[p].call(this, c, entity, entity.options[p]); |
| 2122 |
} else { |
} else { |
| 2123 |
|
if(entity.options[p] === 0 && p == "globalAlpha") { |
| 2124 |
|
return true; |
| 2125 |
|
} |
| 2126 |
c[p] = entity.options[p]; |
c[p] = entity.options[p]; |
| 2127 |
} |
} |
| 2128 |
} |
} |
| 5045 |
}; |
}; |
| 5046 |
return EffectScene; |
return EffectScene; |
| 5047 |
})(Scene); |
})(Scene); |
| 5048 |
|
var MessageWindow = (function (_super) { |
| 5049 |
|
__extends(MessageWindow, _super); |
| 5050 |
|
function MessageWindow(size, noDefault) { |
| 5051 |
|
_super.call(this); |
| 5052 |
|
this.width = size.width; |
| 5053 |
|
this.height = size.height; |
| 5054 |
|
this.textClip = new Shape(this.width, this.height); |
| 5055 |
|
this.textClip.setClip(true); |
| 5056 |
|
this.padding = new Rectangle(8, 8, 8, 8); |
| 5057 |
|
this.entities = [ |
| 5058 |
|
null, |
| 5059 |
|
null, |
| 5060 |
|
this.textClip, |
| 5061 |
|
null |
| 5062 |
|
]; |
| 5063 |
|
if(!noDefault) { |
| 5064 |
|
this.defaultSkin(); |
| 5065 |
|
} |
| 5066 |
|
this.normalSpeed = 400; |
| 5067 |
|
this.fastSpeed = 800; |
| 5068 |
|
this.readed = new Trigger(); |
| 5069 |
|
this.isReaded = true; |
| 5070 |
|
this.hasNextCursor = false; |
| 5071 |
|
} |
| 5072 |
|
MessageWindow.prototype._activate = function (e) { |
| 5073 |
|
e.scene = this.scene; |
| 5074 |
|
e.parent = this; |
| 5075 |
|
e.activate(); |
| 5076 |
|
}; |
| 5077 |
|
MessageWindow.prototype.getBg = function () { |
| 5078 |
|
return this.entities[0]; |
| 5079 |
|
}; |
| 5080 |
|
MessageWindow.prototype.setBg = function (bg) { |
| 5081 |
|
if(this.entities[0]) { |
| 5082 |
|
this.entities[0].destroy(); |
| 5083 |
|
} |
| 5084 |
|
this.entities[0] = bg; |
| 5085 |
|
this._activate(bg); |
| 5086 |
|
}; |
| 5087 |
|
MessageWindow.prototype.getTextBg = function () { |
| 5088 |
|
return this.entities[1]; |
| 5089 |
|
}; |
| 5090 |
|
MessageWindow.prototype.setTextBg = function (textWindow) { |
| 5091 |
|
if(this.entities[1]) { |
| 5092 |
|
this.entities[1].destroy(); |
| 5093 |
|
} |
| 5094 |
|
this.entities[1] = textWindow; |
| 5095 |
|
this._activate(textWindow); |
| 5096 |
|
}; |
| 5097 |
|
MessageWindow.prototype.getTextArea = function () { |
| 5098 |
|
return this.entities[3]; |
| 5099 |
|
}; |
| 5100 |
|
MessageWindow.prototype.setTextArea = function (textArea) { |
| 5101 |
|
if(this.entities[3]) { |
| 5102 |
|
this.entities[3].destroy(); |
| 5103 |
|
} |
| 5104 |
|
this.entities[3] = textArea; |
| 5105 |
|
this.textClip.moveTo(textArea.x, textArea.y); |
| 5106 |
|
this.textClip.width = textArea.width; |
| 5107 |
|
this.textClip.height = textArea.height; |
| 5108 |
|
this._activate(textArea); |
| 5109 |
|
}; |
| 5110 |
|
MessageWindow.prototype.getNextCursor = function () { |
| 5111 |
|
return this.nextCursor; |
| 5112 |
|
}; |
| 5113 |
|
MessageWindow.prototype.setNextCursor = function (cursor) { |
| 5114 |
|
this.nextCursor = cursor; |
| 5115 |
|
}; |
| 5116 |
|
MessageWindow.prototype.setText = function (text, offset) { |
| 5117 |
|
var textArea = this.getTextArea(); |
| 5118 |
|
this.scriptOffset = textArea.setText(text, offset); |
| 5119 |
|
this.script = textArea.script; |
| 5120 |
|
textArea.hideAll(); |
| 5121 |
|
this.deleteNextCursor(); |
| 5122 |
|
this.isReaded = false; |
| 5123 |
|
return this.scriptOffset; |
| 5124 |
|
}; |
| 5125 |
|
MessageWindow.prototype.setScript = function (script, offset) { |
| 5126 |
|
var textArea = this.getTextArea(); |
| 5127 |
|
this.script = script; |
| 5128 |
|
this.scriptOffset = textArea.setScript(script, offset); |
| 5129 |
|
textArea.hideAll(); |
| 5130 |
|
this.deleteNextCursor(); |
| 5131 |
|
this.isReaded = false; |
| 5132 |
|
return this.scriptOffset; |
| 5133 |
|
}; |
| 5134 |
|
MessageWindow.prototype.defaultSkin = function () { |
| 5135 |
|
if(this.entities) { |
| 5136 |
|
var childEntity; |
| 5137 |
|
while(childEntity = this.entities.pop()) { |
| 5138 |
|
childEntity.destroy(); |
| 5139 |
|
} |
| 5140 |
|
} |
| 5141 |
|
var bgColor = JGUtil.createLinearGradient(new Rectangle(0, 0, this.width, this.height), [ |
| 5142 |
|
"rgba(138,193,255,0.5)", |
| 5143 |
|
"rgba(222, 235, 250, 0.5)" |
| 5144 |
|
]); |
| 5145 |
|
var bg = new Shape(this.width, this.height, ShapeStyle.fill, bgColor); |
| 5146 |
|
this.setBg(bg); |
| 5147 |
|
var textBg = new Shape(this.width - (this.padding.left + this.padding.right), this.height - (this.padding.top + this.padding.bottom), ShapeStyle.fill, "rgba(45,73,136,0.2)"); |
| 5148 |
|
textBg.moveTo(this.padding.left, this.padding.top); |
| 5149 |
|
this.setTextBg(textBg); |
| 5150 |
|
var textArea = new MultilineText({ |
| 5151 |
|
width: textBg.width - 8, |
| 5152 |
|
height: textBg.height - 4 |
| 5153 |
|
}, { |
| 5154 |
|
x: textBg.x + 4, |
| 5155 |
|
y: textBg.y + 2 |
| 5156 |
|
}); |
| 5157 |
|
textArea.animated.handle(this, this.onAnimated); |
| 5158 |
|
this.setTextArea(textArea); |
| 5159 |
|
var cursor = new Line({ |
| 5160 |
|
x: 0, |
| 5161 |
|
y: 0 |
| 5162 |
|
}, { |
| 5163 |
|
x: 6, |
| 5164 |
|
y: 8 |
| 5165 |
|
}); |
| 5166 |
|
cursor.addLine(12, 0); |
| 5167 |
|
cursor.closePath = true; |
| 5168 |
|
cursor.fill = true; |
| 5169 |
|
cursor.setFillColor("rgba(255, 255, 255, 0.8)"); |
| 5170 |
|
cursor.width = 12; |
| 5171 |
|
cursor.height = 8; |
| 5172 |
|
this.nextCursor = cursor; |
| 5173 |
|
}; |
| 5174 |
|
MessageWindow.prototype.showNextCursor = function () { |
| 5175 |
|
if(this.hasNextCursor) { |
| 5176 |
|
return; |
| 5177 |
|
} |
| 5178 |
|
var nextCursor = this.nextCursor.createSprite(); |
| 5179 |
|
var textArea = this.getTextArea(); |
| 5180 |
|
var lastLine = textArea.lines[textArea.lines.length - 1]; |
| 5181 |
|
nextCursor.moveTo(this.width / 2 - nextCursor.width / 2, this.height - nextCursor.height - this.padding.bottom - 4); |
| 5182 |
|
nextCursor.tl().moveBy(0, 4, 500).moveBy(0, -4, 500).delay(500).loop(); |
| 5183 |
|
this.append(nextCursor); |
| 5184 |
|
this.hasNextCursor = true; |
| 5185 |
|
}; |
| 5186 |
|
MessageWindow.prototype.deleteNextCursor = function () { |
| 5187 |
|
if(this.hasNextCursor) { |
| 5188 |
|
this.entities[4].remove(); |
| 5189 |
|
this.hasNextCursor = false; |
| 5190 |
|
} |
| 5191 |
|
}; |
| 5192 |
|
MessageWindow.prototype.hide = function (fade) { |
| 5193 |
|
if(fade) { |
| 5194 |
|
this.tl().fadeOut(200); |
| 5195 |
|
} else { |
| 5196 |
|
this.setDrawOption("globalAlpha", 0); |
| 5197 |
|
} |
| 5198 |
|
}; |
| 5199 |
|
MessageWindow.prototype.show = function (fade) { |
| 5200 |
|
if(fade) { |
| 5201 |
|
this.tl().fadeIn(200); |
| 5202 |
|
} else { |
| 5203 |
|
this.removeDrawOption("globalAlpha"); |
| 5204 |
|
} |
| 5205 |
|
}; |
| 5206 |
|
MessageWindow.prototype.showText = function () { |
| 5207 |
|
var textArea = this.getTextArea(); |
| 5208 |
|
textArea.startAnimation(this.normalSpeed); |
| 5209 |
|
}; |
| 5210 |
|
MessageWindow.prototype.fastMode = function () { |
| 5211 |
|
var textArea = this.getTextArea(); |
| 5212 |
|
textArea.animeSpeed = this.fastSpeed; |
| 5213 |
|
}; |
| 5214 |
|
MessageWindow.prototype.normalMode = function () { |
| 5215 |
|
var textArea = this.getTextArea(); |
| 5216 |
|
textArea.animeSpeed = this.normalSpeed; |
| 5217 |
|
}; |
| 5218 |
|
MessageWindow.prototype.showAll = function () { |
| 5219 |
|
var textArea = this.getTextArea(); |
| 5220 |
|
textArea.showAll(); |
| 5221 |
|
}; |
| 5222 |
|
MessageWindow.prototype.next = function () { |
| 5223 |
|
if(this.scriptOffset < 0) { |
| 5224 |
|
return false; |
| 5225 |
|
} |
| 5226 |
|
}; |
| 5227 |
|
MessageWindow.prototype.oldWipeOut = function (time) { |
| 5228 |
|
if(time === undefined) { |
| 5229 |
|
time = 500; |
| 5230 |
|
} |
| 5231 |
|
var textArea = this.getTextArea(); |
| 5232 |
|
var old = textArea.createSprite(); |
| 5233 |
|
old.moveTo(textArea.x, textArea.y); |
| 5234 |
|
this.append(old); |
| 5235 |
|
var lastLine = textArea.lines[textArea.lines.length - 1]; |
| 5236 |
|
var movePoint = lastLine.offsetY + lastLine.height; |
| 5237 |
|
textArea.moveTo(textArea.x, textArea.y + movePoint); |
| 5238 |
|
old.tl().moveBy(0, -textArea.height, time).removeFromScene(); |
| 5239 |
|
textArea.tl().moveBy(0, -movePoint, time); |
| 5240 |
|
}; |
| 5241 |
|
MessageWindow.prototype.oldFadeOut = function (time) { |
| 5242 |
|
if(time === undefined) { |
| 5243 |
|
time = 500; |
| 5244 |
|
} |
| 5245 |
|
var textArea = this.getTextArea(); |
| 5246 |
|
var old = textArea.createSprite(); |
| 5247 |
|
old.moveTo(textArea.x, textArea.y); |
| 5248 |
|
this.append(old); |
| 5249 |
|
old.tl().fadeOut(time).removeFromScene(); |
| 5250 |
|
}; |
| 5251 |
|
MessageWindow.prototype.onAnimated = function () { |
| 5252 |
|
var hasNext = this.scriptOffset >= 0; |
| 5253 |
|
if(hasNext) { |
| 5254 |
|
this.showNextCursor(); |
| 5255 |
|
} |
| 5256 |
|
this.isReaded = true; |
| 5257 |
|
this.readed.fire(hasNext); |
| 5258 |
|
}; |
| 5259 |
|
return MessageWindow; |
| 5260 |
|
})(E); |