· 8 years ago · Jul 18, 2018, 12:38 AM
1# ===================================================================
2#
3# Script: Component_CommandInterpreter
4#
5# $$COPYRIGHT$$
6#
7# ===================================================================
8
9class LivePreviewInfo
10 ###*
11 * Stores internal preview-info if the game runs currently in Live-Preview.
12 *
13 * @module gs
14 * @class LivePreviewInfo
15 * @memberof gs
16 ###
17 constructor: ->
18 ###*
19 * Timer ID if a timeout for live-preview was configured to exit the game loop after a certain amount of time.
20 * @property timeout
21 * @type number
22 ###
23 @timeout = null
24
25 ###*
26 * Indicates if Live-Preview is currently waiting for the next user-action. (Selecting another command, etc.)
27 * @property waiting
28 * @type boolean
29 ###
30 @waiting = no
31
32 ###*
33 * Counts the amount of executed commands since the last
34 * interpreter-pause(waiting, etc.). If its more than 500, the interpreter will automatically pause for 1 frame to
35 * avoid that Live-Preview freezes the Editor in case of endless loops.
36 * @property executedCommands
37 * @type number
38 ###
39 @executedCommands = 0
40
41 ###*
42 * Indicates that the command to skip to has not been found.
43 * @property commandNotFound
44 * @type boolean
45 ###
46 @commandNotFound = no
47
48gs.LivePreviewInfo = LivePreviewInfo
49
50class InterpreterContext
51 @objectCodecBlackList = ["owner"]
52
53 ###*
54 * Describes an interpreter-context which holds information about
55 * the interpreter's owner and also unique ID used for accessing correct
56 * local variables.
57 *
58 * @module gs
59 * @class InterpreterContext
60 * @memberof gs
61 * @param {number|string} id - A unique ID
62 * @param {Object} owner - The owner of the interpreter
63 ###
64 constructor: (id, owner) ->
65 ###*
66 * A unique numeric or textual ID used for accessing correct local variables.
67 * @property id
68 * @type number|string
69 ###
70 @id = id
71
72 ###*
73 * The owner of the interpreter (e.g. current scene, etc.).
74 * @property owner
75 * @type Object
76 ###
77 @owner = owner
78
79 ###*
80 * Sets the context's data.
81 * @param {number|string} id - A unique ID
82 * @param {Object} owner - The owner of the interpreter
83 * @method set
84 ###
85 set: (id, owner) ->
86 @id = id
87 @owner = owner
88
89gs.InterpreterContext = InterpreterContext
90
91class Component_CommandInterpreter extends gs.Component
92 @objectCodecBlackList = ["object", "command", "onMessageADVWaiting", "onMessageADVDisappear", "onMessageADVFinish"]
93
94 ###*
95 * Called if this object instance is restored from a data-bundle. It can be used
96 * re-assign event-handler, anonymous functions, etc.
97 *
98 * @method onDataBundleRestore.
99 * @param Object data - The data-bundle
100 * @param gs.ObjectCodecContext context - The codec-context.
101 ###
102 onDataBundleRestore: (data, context) ->
103
104
105 ###*
106 * A component which allows a game object to process commands like for
107 * scene-objects. For each command a command-function exists. To add
108 * own custom commands to the interpreter just create a sub-class and
109 * override the gs.Component_CommandInterpreter.assignCommand method
110 * and assign the command-function for your custom-command.
111 *
112 * @module gs
113 * @class Component_CommandInterpreter
114 * @extends gs.Component
115 * @memberof gs
116 ###
117 constructor: () ->
118 super()
119
120 ###*
121 * Wait-Counter in frames. If greater than 0, the interpreter will for that amount of frames before continue.
122 * @property waitCounter
123 * @type number
124 ###
125 @waitCounter = 0
126
127 ###*
128 * Index to the next command to execute.
129 * @property pointer
130 * @type number
131 ###
132 @pointer = 0
133
134 ###*
135 * Stores states of conditions.
136 * @property conditions
137 * @type number
138 * @protected
139 ###
140 @conditions = []
141
142 ###*
143 * Stores states of loops.
144 * @property loops
145 * @type number
146 * @protected
147 ###
148 @loops = []
149
150 # FIXME: Should not be stored in the interpreter.
151 @timers = []
152
153 ###*
154 * Indicates if the interpreter is currently running.
155 * @property isRunning
156 * @type boolean
157 * @readOnly
158 ###
159 @isRunning = no
160
161 ###*
162 * Indicates if the interpreter is currently waiting.
163 * @property isWaiting
164 * @type boolean
165 ###
166 @isWaiting = no
167
168 ###*
169 * Indicates if the interpreter is currently waiting until a message processed by another context like a Common Event
170 * is finished.
171 * FIXME: Conflict handling can be removed maybe.
172 * @property isWaitingForMessage
173 * @type boolean
174 ###
175 @isWaitingForMessage = no
176
177 ###*
178 * Stores internal preview-info if the game runs currently in Live-Preview.
179 * <ul>
180 * <li>previewInfo.timeout - Timer ID if a timeout for live-preview was configured to exit the game loop after a certain amount of time.</li>
181 * <li>previewInfo.waiting - Indicates if Live-Preview is currently waiting for the next user-action. (Selecting another command, etc.)</li>
182 * <li>previewInfo.executedCommands - Counts the amount of executed commands since the last
183 * interpreter-pause(waiting, etc.). If its more than 500, the interpreter will automatically pause for 1 frame to
184 * avoid that Live-Preview freezes the Editor in case of endless loops.</li>
185 * </ul>
186 * @property previewInfo
187 * @type boolean
188 * @protected
189 ###
190 @previewInfo = new gs.LivePreviewInfo()
191
192 ###*
193 * Stores Live-Preview related info passed from the VN Maker editor like the command-index the player clicked on, etc.
194 * @property previewData
195 * @type Object
196 * @protected
197 ###
198 @previewData = null
199
200 ###*
201 * Indicates if the interpreter automatically repeats execution after the last command was executed.
202 * @property repeat
203 * @type boolean
204 ###
205 @repeat = no
206
207 ###*
208 * The execution context of the interpreter.
209 * @property context
210 * @type gs.InterpreterContext
211 * @protected
212 ###
213 @context = new gs.InterpreterContext(0, null)
214
215 ###*
216 * Sub-Interpreter from a Common Event Call. The interpreter will wait until the sub-interpreter is done and set back to
217 * <b>null</b>.
218 * @property subInterpreter
219 * @type gs.Component_CommandInterpreter
220 * @protected
221 ###
222 @subInterpreter = null
223
224 ###*
225 * Current indent-level of execution
226 * @property indent
227 * @type number
228 * @protected
229 ###
230 @indent = 0
231
232 ###*
233 * Stores information about for what the interpreter is currently waiting for like for a ADV message, etc. to
234 * restore probably when loaded from a save-game.
235 * @property waitingFor
236 * @type Object
237 * @protected
238 ###
239 @waitingFor = {}
240
241 ###*
242 * Stores interpreter related settings like how to handle messages, etc.
243 * @property settings
244 * @type Object
245 * @protected
246 ###
247 @settings = { message: { byId: {}, autoErase: yes, waitAtEnd: yes, backlog: yes }, screen: { pan: new gs.Point(0, 0) } }
248
249 ###*
250 * Mapping table to quickly get the anchor point for the an inserted anchor-point constant such as
251 * Top-Left(0), Top(1), Top-Right(2) and so on.
252 * @property graphicAnchorPointsByConstant
253 * @type gs.Point[]
254 * @protected
255 ###
256 @graphicAnchorPointsByConstant = [
257 new gs.Point(0.0, 0.0),
258 new gs.Point(0.5, 0.0),
259 new gs.Point(1.0, 0.0),
260 new gs.Point(1.0, 0.5),
261 new gs.Point(1.0, 1.0),
262 new gs.Point(0.5, 1.0),
263 new gs.Point(0.0, 1.0),
264 new gs.Point(0.0, 0.5),
265 new gs.Point(0.5, 0.5)
266 ]
267
268 onHotspotClick: (e, data) ->
269 @executeAction(data.params.actions.onClick, no, data.bindValue)
270 onHotspotEnter: (e, data) ->
271 @executeAction(data.params.actions.onEnter, yes, data.bindValue)
272 onHotspotLeave: (e, data) ->
273 @executeAction(data.params.actions.onLeave, no, data.bindValue)
274 onHotspotDragStart: (e, data) ->
275 @executeAction(data.params.actions.onDrag, yes, data.bindValue)
276 onHotspotDrag: (e, data) ->
277 @executeAction(data.params.actions.onDrag, yes, data.bindValue)
278 onHotspotDragEnd: (e, data) ->
279 @executeAction(data.params.actions.onDrag, no, data.bindValue)
280 onHotspotDrop: (e, data) ->
281 @executeAction(data.params.actions.onDrop, no, data.bindValue)
282 gs.GlobalEventManager.emit("hotspotDrop", e.sender)
283 onHotspotDropReceived: (e, data) ->
284 @executeAction(data.params.actions.onDropReceive, yes, data.bindValue)
285 onHotspotStateChanged: (e, params) ->
286 if e.sender.behavior.selected
287 @executeAction(params.actions.onSelect, yes)
288 else
289 @executeAction(params.actions.onDeselect, no)
290
291 ###*
292 * Called when a ADV message finished rendering and is now waiting
293 * for the user/autom-message timer to proceed.
294 *
295 * @method onMessageADVWaiting
296 * @return {Object} Event Object containing additional data.
297 * @protected
298 ###
299 onMessageADVWaiting: (e) ->
300 messageObject = e.sender.object
301 if !@messageSettings().waitAtEnd
302 if e.data.params.waitForCompletion
303 @isWaiting = no
304 messageObject.textRenderer.isWaiting = no
305 messageObject.textRenderer.isRunning = no
306 messageObject.events.off "waiting", e.handler
307
308 if @messageSettings().backlog and (messageObject.settings.autoErase or messageObject.settings.paragraphSpacing > 0)
309 GameManager.backlog.push({ character: messageObject.character, message: messageObject.behavior.message, choices: [] })
310
311 ###*
312 * Called when an ADV message finished fade-out.
313 *
314 * @method onMessageADVDisappear
315 * @return {Object} Event Object containing additional data.
316 * @protected
317 ###
318 onMessageADVDisappear: (messageObject, waitForCompletion) ->
319 SceneManager.scene.currentCharacter = { name: "" }
320 messageObject.behavior.clear()
321 messageObject.visible = no
322
323 if messageObject.waitForCompletion
324 @isWaiting = no
325 @waitingFor.messageADV = null
326
327 ###*
328 * Called when an ADV message finished clear.
329 *
330 * @method onMessageADVClear
331 * @return {Object} Event Object containing additional data.
332 * @protected
333 ###
334 onMessageADVClear: (messageObject, waitForCompletion) ->
335 messageObject = @targetMessage()
336 if @messageSettings().backlog
337 GameManager.backlog.push({ character: messageObject.character, message: messageObject.behavior.message, choices: [] })
338 @onMessageADVDisappear(messageObject, waitForCompletion)
339
340
341
342 ###*
343 * Called when a hotspot/image-map sends a "jumpTo" event to let the
344 * interpreter jump to the position defined in the event object.
345 *
346 * @method onJumpTo
347 * @return {Object} Event Object containing additional data.
348 * @protected
349 ###
350 onJumpTo: (e) ->
351 @jumpToLabel(e.label)
352 @isWaiting = no
353
354 ###*
355 * Called when a hotspot/image-map sends a "callCommonEvent" event to let the
356 * interpreter call the common event defined in the event object.
357 *
358 * @method onJumpTo
359 * @return {Object} Event Object containing additional data.
360 * @protected
361 ###
362 onCallCommonEvent: (e) ->
363 eventId = e.commonEventId
364 event = RecordManager.commonEvents[eventId]
365 if !event
366 event = RecordManager.commonEvents.first (x) => x.name == eventId
367 eventId = event.index if event
368 @callCommonEvent(eventId, e.params || [], !e.finish)
369 @isWaiting = e.waiting ? no
370
371 ###*
372 * Called when a ADV message finishes.
373 *
374 * @method onMessageADVFinish
375 * @return {Object} Event Object containing additional data.
376 * @protected
377 ###
378 onMessageADVFinish: (e) ->
379 messageObject = e.sender.object
380
381 if not @messageSettings().waitAtEnd then return
382
383 GameManager.globalData.messages[lcsm(e.data.params.message)] = { read: yes }
384 GameManager.saveGlobalData()
385 if e.data.params.waitForCompletion
386 @isWaiting = no
387 @waitingFor.messageADV = null
388 pointer = @pointer
389 commands = @object.commands
390
391 messageObject.events.off "finish", e.handler
392 #messageObject.character = null
393
394 if messageObject.voice? and GameManager.settings.skipVoiceOnAction
395 AudioManager.stopSound(messageObject.voice.name)
396
397 if not @isMessageCommand(pointer, commands) and @messageSettings().autoErase
398 @isWaiting = yes
399 @waitingFor.messageADV = e.data.params
400
401 fading = GameManager.tempSettings.messageFading
402 duration = if GameManager.tempSettings.skip then 0 else fading.duration
403
404 messageObject.waitForCompletion = e.data.params.waitForCompletion
405 messageObject.animator.disappear(fading.animation, fading.easing, duration, gs.CallBack("onMessageADVDisappear", this, e.data.params.waitForCompletion))
406
407 ###*
408 * Called when a common event finished execution. In most cases, the interpreter
409 * will stop waiting and continue processing after this. But h
410 *
411 * @method onCommonEventFinish
412 * @return {Object} Event Object containing additional data.
413 * @protected
414 ###
415 onCommonEventFinish: (e) ->
416 SceneManager.scene.commonEventContainer.removeObject(e.sender.object)
417 e.sender.object.events.off "finish"
418 @subInterpreter = null
419 @isWaiting = e.data.waiting ? no
420
421 ###*
422 * Called when a scene call finished execution.
423 *
424 * @method onCallSceneFinish
425 * @param {Object} sender - The sender of this event.
426 * @protected
427 ###
428 onCallSceneFinish: (sender) ->
429 @isWaiting = no
430 @subInterpreter = null
431
432 ###*
433 * Serializes the interpreter into a data-bundle.
434 *
435 * @method toDataBundle
436 * @return {Object} The data-bundle.
437 ###
438 toDataBundle: ->
439 if @isInputDataCommand(Math.max(@pointer - 1, 0), @object.commands)
440 pointer: Math.max(@pointer - 1 , 0),
441 choice: @choice,
442 conditions: @conditions,
443 loops: @loops,
444 labels: @labels,
445 isWaiting: no,
446 isRunning: @isRunning,
447 waitCounter: @waitCounter,
448 waitingFor: @waitingFor,
449 indent: @indent,
450 settings: @settings
451 else
452 pointer: @pointer,
453 choice: @choice,
454 conditions: @conditions,
455 loops: @loops,
456 labels: @labels,
457 isWaiting: @isWaiting,
458 isRunning: @isRunning,
459 waitCounter: @waitCounter,
460 waitingFor: @waitingFor,
461 indent: @indent,
462 settings: @settings
463
464 ###*
465 # Previews the current scene at the specified pointer. This method is called from the
466 # VN Maker Scene-Editor if live-preview is enabled and the user clicked on a command.
467 #
468 # @method preview
469 ###
470 preview: ->
471 try
472 return if !$PARAMS.preview or !$PARAMS.preview.scene
473 AudioManager.stopAllSounds()
474 AudioManager.stopAllMusic()
475 AudioManager.stopAllVoices()
476 SceneManager.scene.choices = []
477 GameManager.setupCursor()
478 @previewData = $PARAMS.preview
479 gs.GlobalEventManager.emit("previewRestart")
480 if @previewInfo.timeout
481 clearTimeout(@previewInfo.timeout)
482
483 if Graphics.stopped
484 Graphics.stopped = no
485 Graphics.onEachFrame(gs.Main.frameCallback)
486
487 scene = new vn.Object_Scene()
488
489 scene.sceneData.uid = @previewData.scene.uid
490 SceneManager.switchTo(scene)
491 catch ex
492 console.warn(ex)
493
494 ###*
495 # Sets up the interpreter.
496 #
497 # @method setup
498 ###
499 setup: ->
500 super
501
502 @previewData = $PARAMS.preview
503 if @previewData
504 gs.GlobalEventManager.on "mouseDown", (=>
505 if @previewInfo.waiting
506 if @previewInfo.timeout
507 clearTimeout(@previewInfo.timeout)
508 @previewInfo.waiting = no
509 #@isWaiting = no
510 GameManager.tempSettings.skip = no
511 @previewData = null
512 gs.GlobalEventManager.emit("previewRestart")
513 ), null, @object
514
515 ###*
516 # Disposes the interpreter.
517 #
518 # @method dispose
519 ###
520 dispose: ->
521 if @previewData
522 gs.GlobalEventManager.offByOwner("mouseDown", @object)
523
524
525 super
526
527
528 isInstantSkip: -> GameManager.tempSettings.skip and GameManager.tempSettings.skipTime == 0
529
530 ###*
531 * Restores the interpreter from a data-bundle
532 *
533 * @method restore
534 * @param {Object} bundle- The data-bundle.
535 ###
536 restore: ->
537
538 ###*
539 * Gets the default game message for novel-mode.
540 *
541 * @method messageObjectNVL
542 * @return {ui.Object_Message} The NVL game message object.
543 ###
544 messageObjectNVL: -> gs.ObjectManager.current.objectById("nvlGameMessage_message")
545
546 ###*
547 * Gets the default game message for adventure-mode.
548 *
549 * @method messageObjectADV
550 * @return {ui.Object_Message} The ADV game message object.
551 ###
552 messageObjectADV: ->
553 gs.ObjectManager.current.objectById("gameMessage_message")
554
555 ###*
556 * Starts the interpreter
557 *
558 * @method start
559 ###
560 start: ->
561 @conditions = []
562 @loops = []
563 @indent = 0
564 @pointer = 0
565 @isRunning = yes
566 @isWaiting = no
567 @subInterpreter = null
568 @waitCounter = 0
569
570 ###*
571 * Stops the interpreter
572 *
573 * @method stop
574 ###
575 stop: ->
576 @isRunning = no
577
578 ###*
579 * Resumes the interpreter
580 *
581 * @method resume
582 ###
583 resume: ->
584 @isRunning = yes
585
586 ###*
587 * Updates the interpreter and executes all commands until the next wait is
588 * triggered by a command. So in the case of an endless-loop the method will
589 * never return.
590 *
591 * @method update
592 ###
593 update: ->
594 if @subInterpreter?
595 @subInterpreter.update()
596 return
597
598 GameManager.variableStore.setupTempVariables(@context)
599
600 if (not @object.commands? or @pointer >= @object.commands.length) and not @isWaiting
601 if @repeat
602 @start()
603 else if @isRunning
604 @isRunning = no
605 if @onFinish? then @onFinish(this)
606 return
607
608 if not @isRunning then return
609
610 if not @object.commands.optimized
611 DataOptimizer.optimizeEventCommands(@object.commands)
612
613 if @waitCounter > 0
614 @waitCounter--
615 @isWaiting = @waitCounter > 0
616 return
617
618 if @isWaitingForMessage
619 @isWaiting = yes
620 if not @isProcessingMessageInOtherContext()
621 @isWaiting = no
622 @isWaitingForMessage = no
623 else
624 return
625
626 if GameManager.inLivePreview
627 while not (@isWaiting or @previewInfo.waiting) and @pointer < @object.commands.length and @isRunning
628 @executeCommand(@pointer)
629
630 @previewInfo.executedCommands++
631
632 if @previewInfo.executedCommands > 500
633 @previewInfo.executedCommands = 0
634 @isWaiting = yes
635 @waitCounter = 1
636 else
637 while not (@isWaiting or @previewInfo.waiting) and @pointer < @object.commands.length and @isRunning
638 @executeCommand(@pointer)
639
640
641 if @pointer >= @object.commands.length and not @isWaiting
642 if @repeat
643 @start()
644 else if @isRunning
645 @isRunning = no
646 if @onFinish? then @onFinish(this)
647
648
649
650
651 ###*
652 * Assigns the correct command-function to the specified command-object if
653 * necessary.
654 *
655 * @method assignCommand
656 ###
657 assignCommand: (command) ->
658 switch command.id
659 when "gs.Idle" then command.execute = @commandIdle
660 when "gs.StartTimer" then command.execute = @commandStartTimer
661 when "gs.PauseTimer" then command.execute = @commandPauseTimer
662 when "gs.ResumeTimer" then command.execute = @commandResumeTimer
663 when "gs.StopTimer" then command.execute = @commandStopTimer
664 when "gs.WaitCommand" then command.execute = @commandWait
665 when "gs.LoopCommand" then command.execute = @commandLoop
666 when "gs.BreakLoopCommand" then command.execute = @commandBreakLoop
667 when "gs.Comment" then command.execute = -> 0
668 when "gs.EmptyCommand" then command.execute = -> 0
669 when "gs.ListAdd" then command.execute = @commandListAdd
670 when "gs.ListPop" then command.execute = @commandListPop
671 when "gs.ListShift" then command.execute = @commandListShift
672 when "gs.ListRemoveAt" then command.execute = @commandListRemoveAt
673 when "gs.ListInsertAt" then command.execute = @commandListInsertAt
674 when "gs.ListValueAt" then command.execute = @commandListValueAt
675 when "gs.ListClear" then command.execute = @commandListClear
676 when "gs.ListShuffle" then command.execute = @commandListShuffle
677 when "gs.ListSort" then command.execute = @commandListSort
678 when "gs.ListIndexOf" then command.execute = @commandListIndexOf
679 when "gs.ListSet" then command.execute = @commandListSet
680 when "gs.ListCopy" then command.execute = @commandListCopy
681 when "gs.ListLength" then command.execute = @commandListLength
682 when "gs.ListJoin" then command.execute = @commandListJoin
683 when "gs.ListFromText" then command.execute = @commandListFromText
684 when "gs.ResetVariables" then command.execute = @commandResetVariables
685 when "gs.ChangeVariableDomain" then command.execute = @commandChangeVariableDomain
686 when "gs.ChangeNumberVariables" then command.execute = @commandChangeNumberVariables
687 when "gs.ChangeDecimalVariables" then command.execute = @commandChangeDecimalVariables
688 when "gs.ChangeBooleanVariables" then command.execute = @commandChangeBooleanVariables
689 when "gs.ChangeStringVariables" then command.execute = @commandChangeStringVariables
690 when "gs.CheckSwitch" then command.execute = @commandCheckSwitch
691 when "gs.CheckNumberVariable" then command.execute = @commandCheckNumberVariable
692 when "gs.CheckTextVariable" then command.execute = @commandCheckTextVariable
693 when "gs.Condition" then command.execute = @commandCondition
694 when "gs.ConditionElse" then command.execute = @commandConditionElse
695 when "gs.ConditionElseIf" then command.execute = @commandConditionElseIf
696 when "gs.Label" then command.execute = @commandLabel
697 when "gs.JumpToLabel" then command.execute = @commandJumpToLabel
698 when "gs.SetMessageArea" then command.execute = @commandSetMessageArea
699 when "gs.ShowMessage" then command.execute = @commandShowMessage
700 when "gs.ShowPartialMessage" then command.execute = @commandShowPartialMessage
701 when "gs.MessageFading" then command.execute = @commandMessageFading
702 when "gs.MessageSettings" then command.execute = @commandMessageSettings
703 when "gs.CreateMessageArea" then command.execute = @commandCreateMessageArea
704 when "gs.EraseMessageArea" then command.execute = @commandEraseMessageArea
705 when "gs.SetTargetMessage" then command.execute = @commandSetTargetMessage
706 when "vn.MessageBoxDefaults" then command.execute = @commandMessageBoxDefaults
707 when "vn.MessageBoxVisibility" then command.execute = @commandMessageBoxVisibility
708 when "vn.MessageVisibility" then command.execute = @commandMessageVisibility
709 when "vn.BacklogVisibility" then command.execute = @commandBacklogVisibility
710 when "gs.ClearMessage" then command.execute = @commandClearMessage
711 when "gs.ChangeWeather" then command.execute = @commandChangeWeather
712 when "gs.FreezeScreen" then command.execute = @commandFreezeScreen
713 when "gs.ScreenTransition" then command.execute = @commandScreenTransition
714 when "gs.ShakeScreen" then command.execute = @commandShakeScreen
715 when "gs.TintScreen" then command.execute = @commandTintScreen
716 when "gs.FlashScreen" then command.execute = @commandFlashScreen
717 when "gs.ZoomScreen" then command.execute = @commandZoomScreen
718 when "gs.RotateScreen" then command.execute = @commandRotateScreen
719 when "gs.PanScreen" then command.execute = @commandPanScreen
720 when "gs.ScreenEffect" then command.execute = @commandScreenEffect
721 when "gs.ShowVideo" then command.execute = @commandShowVideo
722 when "gs.MoveVideo" then command.execute = @commandMoveVideo
723 when "gs.MoveVideoPath" then command.execute = @commandMoveVideoPath
724 when "gs.TintVideo" then command.execute = @commandTintVideo
725 when "gs.FlashVideo" then command.execute = @commandFlashVideo
726 when "gs.CropVideo" then command.execute = @commandCropVideo
727 when "gs.RotateVideo" then command.execute = @commandRotateVideo
728 when "gs.ZoomVideo" then command.execute = @commandZoomVideo
729 when "gs.BlendVideo" then command.execute = @commandBlendVideo
730 when "gs.MaskVideo" then command.execute = @commandMaskVideo
731 when "gs.VideoEffect" then command.execute = @commandVideoEffect
732 when "gs.VideoMotionBlur" then command.execute = @commandVideoMotionBlur
733 when "gs.VideoDefaults" then command.execute = @commandVideoDefaults
734 when "gs.EraseVideo" then command.execute = @commandEraseVideo
735 when "gs.ShowImageMap" then command.execute = @commandShowImageMap
736 when "gs.EraseImageMap" then command.execute = @commandEraseImageMap
737 when "gs.AddHotspot" then command.execute = @commandAddHotspot
738 when "gs.EraseHotspot" then command.execute = @commandEraseHotspot
739 when "gs.ChangeHotspotState" then command.execute = @commandChangeHotspotState
740 when "gs.ShowPicture" then command.execute = @commandShowPicture
741 when "gs.MovePicture" then command.execute = @commandMovePicture
742 when "gs.MovePicturePath" then command.execute = @commandMovePicturePath
743 when "gs.TintPicture" then command.execute = @commandTintPicture
744 when "gs.FlashPicture" then command.execute = @commandFlashPicture
745 when "gs.CropPicture" then command.execute = @commandCropPicture
746 when "gs.RotatePicture" then command.execute = @commandRotatePicture
747 when "gs.ZoomPicture" then command.execute = @commandZoomPicture
748 when "gs.BlendPicture" then command.execute = @commandBlendPicture
749 when "gs.ShakePicture" then command.execute = @commandShakePicture
750 when "gs.MaskPicture" then command.execute = @commandMaskPicture
751 when "gs.PictureEffect" then command.execute = @commandPictureEffect
752 when "gs.PictureMotionBlur" then command.execute = @commandPictureMotionBlur
753 when "gs.PictureDefaults" then command.execute = @commandPictureDefaults
754 when "gs.PlayPictureAnimation" then command.execute = @commandPlayPictureAnimation
755 when "gs.ErasePicture" then command.execute = @commandErasePicture
756 when "gs.InputNumber" then command.execute = @commandInputNumber
757 when "vn.Choice" then command.execute = @commandShowChoice
758 when "vn.ChoiceTimer" then command.execute = @commandChoiceTimer
759 when "vn.ShowChoices" then command.execute = @commandShowChoices
760 when "vn.UnlockCG" then command.execute = @commandUnlockCG
761 when "vn.L2DJoinScene" then command.execute = @commandL2DJoinScene
762 when "vn.L2DExitScene" then command.execute = @commandL2DExitScene
763 when "vn.L2DMotion" then command.execute = @commandL2DMotion
764 when "vn.L2DMotionGroup" then command.execute = @commandL2DMotionGroup
765 when "vn.L2DExpression" then command.execute = @commandL2DExpression
766 when "vn.L2DMove" then command.execute = @commandL2DMove
767 when "vn.L2DParameter" then command.execute = @commandL2DParameter
768 when "vn.L2DSettings" then command.execute = @commandL2DSettings
769 when "vn.L2DDefaults" then command.execute = @commandL2DDefaults
770 when "vn.CharacterJoinScene" then command.execute = @commandCharacterJoinScene
771 when "vn.CharacterExitScene" then command.execute = @commandCharacterExitScene
772 when "vn.CharacterChangeExpression" then command.execute = @commandCharacterChangeExpression
773 when "vn.CharacterSetParameter" then command.execute = @commandCharacterSetParameter
774 when "vn.CharacterGetParameter" then command.execute = @commandCharacterGetParameter
775 when "vn.CharacterDefaults" then command.execute = @commandCharacterDefaults
776 when "vn.CharacterEffect" then command.execute = @commandCharacterEffect
777 when "vn.ZoomCharacter" then command.execute = @commandZoomCharacter
778 when "vn.RotateCharacter" then command.execute = @commandRotateCharacter
779 when "vn.BlendCharacter" then command.execute = @commandBlendCharacter
780 when "vn.ShakeCharacter" then command.execute = @commandShakeCharacter
781 when "vn.MaskCharacter" then command.execute = @commandMaskCharacter
782 when "vn.MoveCharacter" then command.execute = @commandMoveCharacter
783 when "vn.MoveCharacterPath" then command.execute = @commandMoveCharacterPath
784 when "vn.FlashCharacter" then command.execute = @commandFlashCharacter
785 when "vn.TintCharacter" then command.execute = @commandTintCharacter
786 when "vn.CharacterMotionBlur" then command.execute = @commandCharacterMotionBlur
787 when "vn.ChangeBackground" then command.execute = @commandChangeBackground
788 when "vn.ShakeBackground" then command.execute = @commandShakeBackground
789 when "vn.ScrollBackground" then command.execute = @commandScrollBackground
790 when "vn.ScrollBackgroundTo" then command.execute = @commandScrollBackgroundTo
791 when "vn.ScrollBackgroundPath" then command.execute = @commandScrollBackgroundPath
792 when "vn.ZoomBackground" then command.execute = @commandZoomBackground
793 when "vn.RotateBackground" then command.execute = @commandRotateBackground
794 when "vn.TintBackground" then command.execute = @commandTintBackground
795 when "vn.BlendBackground" then command.execute = @commandBlendBackground
796 when "vn.MaskBackground" then command.execute = @commandMaskBackground
797 when "vn.BackgroundMotionBlur" then command.execute = @commandBackgroundMotionBlur
798 when "vn.BackgroundEffect" then command.execute = @commandBackgroundEffect
799 when "vn.BackgroundDefaults" then command.execute = @commandBackgroundDefaults
800 when "vn.ChangeScene" then command.execute = @commandChangeScene
801 when "vn.ReturnToPreviousScene" then command.execute = @commandReturnToPreviousScene
802 when "vn.CallScene" then command.execute = @commandCallScene
803 when "vn.SwitchToLayout" then command.execute = @commandSwitchToLayout
804 when "gs.ChangeTransition" then command.execute = @commandChangeTransition
805 when "gs.ChangeWindowSkin" then command.execute = @commandChangeWindowSkin
806 when "gs.ChangeScreenTransitions" then command.execute = @commandChangeScreenTransitions
807 when "vn.UIAccess" then command.execute = @commandUIAccess
808 when "gs.PlayVideo" then command.execute = @commandPlayVideo
809 when "gs.PlayMusic" then command.execute = @commandPlayMusic
810 when "gs.StopMusic" then command.execute = @commandStopMusic
811 when "gs.PlaySound" then command.execute = @commandPlaySound
812 when "gs.StopSound" then command.execute = @commandStopSound
813 when "gs.PauseMusic" then command.execute = @commandPauseMusic
814 when "gs.ResumeMusic" then command.execute = @commandResumeMusic
815 when "gs.AudioDefaults" then command.execute = @commandAudioDefaults
816 when "gs.EndCommonEvent" then command.execute = @commandEndCommonEvent
817 when "gs.ResumeCommonEvent" then command.execute = @commandResumeCommonEvent
818 when "gs.CallCommonEvent" then command.execute = @commandCallCommonEvent
819 when "gs.ChangeTimer" then command.execute = @commandChangeTimer
820 when "gs.ShowText" then command.execute = @commandShowText
821 when "gs.RefreshText" then command.execute = @commandRefreshText
822 when "gs.TextMotionBlur" then command.execute = @commandTextMotionBlur
823 when "gs.MoveText" then command.execute = @commandMoveText
824 when "gs.MoveTextPath" then command.execute = @commandMoveTextPath
825 when "gs.RotateText" then command.execute = @commandRotateText
826 when "gs.ZoomText" then command.execute = @commandZoomText
827 when "gs.BlendText" then command.execute = @commandBlendText
828 when "gs.ColorText" then command.execute = @commandColorText
829 when "gs.EraseText" then command.execute = @commandEraseText
830 when "gs.TextEffect" then command.execute = @commandTextEffect
831 when "gs.TextDefaults" then command.execute = @commandTextDefaults
832 when "gs.ChangeTextSettings" then command.execute = @commandChangeTextSettings
833 when "gs.InputText" then command.execute = @commandInputText
834 when "gs.InputName" then command.execute = @commandInputName
835 when "gs.SavePersistentData" then command.execute = @commandSavePersistentData
836 when "gs.SaveSettings" then command.execute = @commandSaveSettings
837 when "gs.PrepareSaveGame" then command.execute = @commandPrepareSaveGame
838 when "gs.SaveGame" then command.execute = @commandSaveGame
839 when "gs.LoadGame" then command.execute = @commandLoadGame
840 when "gs.GetInputData" then command.execute = @commandGetInputData
841 when "gs.WaitForInput" then command.execute = @commandWaitForInput
842 when "gs.ChangeObjectDomain" then command.execute = @commandChangeObjectDomain
843 when "vn.GetGameData" then command.execute = @commandGetGameData
844 when "vn.SetGameData" then command.execute = @commandSetGameData
845 when "vn.GetObjectData" then command.execute = @commandGetObjectData
846 when "vn.SetObjectData" then command.execute = @commandSetObjectData
847 when "vn.ChangeSounds" then command.execute = @commandChangeSounds
848 when "vn.ChangeColors" then command.execute = @commandChangeColors
849 when "gs.ChangeScreenCursor" then command.execute = @commandChangeScreenCursor
850 when "gs.ResetGlobalData" then command.execute = @commandResetGlobalData
851 when "gs.Script" then command.execute = @commandScript
852
853 ###*
854 * Executes the command at the specified index and increases the command-pointer.
855 *
856 * @method executeCommand
857 ###
858 executeCommand: (index) ->
859 @command = @object.commands[index]
860
861 if @previewData
862 if @previewData.uid and @previewData.uid != @command.uid
863 GameManager.tempSettings.skip = yes
864 GameManager.tempSettings.skipTime = 0
865 else if @pointer < @previewData.pointer
866 GameManager.tempSettings.skip = yes
867 GameManager.tempSettings.skipTime = 0
868 else
869 GameManager.tempSettings.skip = @previewData.settings.animationDisabled
870 GameManager.tempSettings.skipTime = 0
871 @previewInfo.waiting = yes
872
873 gs.GlobalEventManager.emit("previewWaiting")
874 if @previewData.settings.animationDisabled or @previewData.settings.animationTime > 0
875 @previewInfo.timeout = setTimeout (-> Graphics.stopped = yes), (@previewData.settings.animationTime)*1000
876
877 if @command.execute?
878 @command.interpreter = this
879 @command.execute() if @command.indent == @indent
880 @pointer++
881
882 @command = @object.commands[@pointer]
883 if @command?
884 indent = @command.indent
885 else
886 indent = @indent
887 while indent > 0 and (not @loops[indent]?)
888 indent--
889
890 if indent < @indent
891 @indent = indent
892 if @loops[@indent]?
893 @pointer = @loops[@indent]
894 @command = @object.commands[@pointer]
895 @command.interpreter = this
896 else
897 @assignCommand(@command)
898
899 if @command.execute?
900 @command.interpreter = this
901 @command.execute() if @command.indent == @indent
902 @pointer++
903 @command = @object.commands[@pointer]
904 if @command?
905 indent = @command.indent
906 else
907 indent = @indent
908 while indent > 0 and (not @loops[indent]?)
909 indent--
910
911 if indent < @indent
912 @indent = indent
913 if @loops[@indent]?
914 @pointer = @loops[@indent]
915 @command = @object.commands[@pointer]
916 @command.interpreter = this
917 else
918 @pointer++
919 ###*
920 * Skips all commands until a command with the specified indent-level is
921 * found. So for example: To jump from a Condition-Command to the next
922 * Else-Command just pass the indent-level of the Condition/Else command.
923 *
924 * @method skip
925 * @param {number} indent - The indent-level.
926 * @param {boolean} backward - If true the skip runs backward.
927 ###
928 skip: (indent, backward) ->
929 if backward
930 @pointer--
931 while @pointer > 0 and @object.commands[@pointer].indent != indent
932 @pointer--
933 else
934 @pointer++
935 while @pointer < @object.commands.length and @object.commands[@pointer].indent != indent
936 @pointer++
937
938 ###*
939 * Halts the interpreter for the specified amount of time. An optionally
940 * callback function can be passed which is called when the time is up.
941 *
942 * @method wait
943 * @param {number} time - The time to wait
944 * @param {gs.Callback} callback - Called if the wait time is up.
945 ###
946 wait: (time, callback) ->
947 @isWaiting = yes
948 @waitCounter = time
949 @waitCallback = callback
950
951 ###*
952 * Checks if the command at the specified pointer-index is a game message
953 * related command.
954 *
955 * @method isMessageCommand
956 * @param {number} pointer - The pointer/index.
957 * @param {Object[]} commands - The list of commands to check.
958 * @return {boolean} <b>true</b> if its a game message related command. Otherwise <b>false</b>.
959 ###
960 isMessageCommand: (pointer, commands) ->
961 result = yes
962 if pointer >= commands.length or (commands[pointer].id != "gs.InputNumber" and
963 commands[pointer].id != "vn.Choice" and
964 commands[pointer].id != "gs.InputText" and
965 commands[pointer].id != "gs.InputName")
966 result = no
967 return result
968
969 ###*
970 * Checks if the command at the specified pointer-index asks for user-input like
971 * the Input Number or Input Text command.
972 *
973 * @method isInputDataCommand
974 * @param {number} pointer - The pointer/index.
975 * @param {Object[]} commands - The list of commands to check.
976 * @return {boolean} <b>true</b> if its an input-data command. Otherwise <b>false</b>
977 ###
978 isInputDataCommand: (pointer, commands) ->
979 pointer < commands.length and (
980 commands[pointer].id == "gs.InputNumber" or
981 commands[pointer].id == "gs.InputText" or
982 commands[pointer].id == "vn.Choice" or
983 commands[pointer].id == "vn.ShowChoices"
984 )
985
986 ###*
987 * Checks if a game message is currently running by another interpreter like a
988 * common-event interpreter.
989 *
990 * @method isProcessingMessageInOtherContext
991 * @return {boolean} <b>true</b> a game message is running in another context. Otherwise <b>false</b>
992 ###
993 isProcessingMessageInOtherContext: ->
994 result = no
995 gm = GameManager
996 s = SceneManager.scene
997
998 result =
999 (s.inputNumberWindow? and s.inputNumberWindow.visible and s.inputNumberWindow.executionContext != @context) or
1000 (s.inputTextWindow? and s.inputTextWindow.active and s.inputTextWindow.executionContext != @context)
1001
1002 return result
1003
1004 ###*
1005 * If a game message is currently running by an other interpreter like a common-event
1006 * interpreter, this method trigger a wait until the other interpreter is finished
1007 * with the game message.
1008 *
1009 * @method waitForMessage
1010 * @return {boolean} <b>true</b> a game message is running in another context. Otherwise <b>false</b>
1011 ###
1012 waitForMessage: ->
1013 @isWaitingForMessage = yes
1014 @isWaiting = yes
1015 @pointer--
1016
1017
1018 ###*
1019 * Gets the value the number variable at the specified index.
1020 *
1021 * @method numberValueAtIndex
1022 * @param {number} scope - The variable's scope.
1023 * @param {number} index - The index of the variable to get the value from.
1024 * @return {Number} The value of the variable.
1025 ###
1026 numberValueAtIndex: (scope, index, domain) -> GameManager.variableStore.numberValueAtIndex(scope, index, domain)
1027
1028 ###*
1029 * Gets the value of a (possible) number variable. If a constant number value is specified, this method
1030 * does nothing an just returns that constant value. That's to make it more comfortable to just pass a value which
1031 * can be calculated by variable but also be just a constant value.
1032 *
1033 * @method numberValueOf
1034 * @param {number|Object} object - A number variable or constant number value.
1035 * @return {Number} The value of the variable.
1036 ###
1037 numberValueOf: (object) -> GameManager.variableStore.numberValueOf(object)
1038
1039 ###*
1040 * It does the same like <b>numberValueOf</b> with one difference: If the specified object
1041 * is a variable, it's value is considered as a duration-value in milliseconds and automatically converted
1042 * into frames.
1043 *
1044 * @method durationValueOf
1045 * @param {number|Object} object - A number variable or constant number value.
1046 * @return {Number} The value of the variable.
1047 ###
1048 durationValueOf: (object) ->
1049 if object and object.index?
1050 Math.round(GameManager.variableStore.numberValueOf(object) / 1000 * Graphics.frameRate)
1051 else
1052 Math.round(GameManager.variableStore.numberValueOf(object))
1053
1054 ###*
1055 * Gets a position ({x, y}) for the specified predefined object position configured in
1056 * Database - System.
1057 *
1058 * @method predefinedObjectPosition
1059 * @param {number} position - The index/ID of the predefined object position to set.
1060 * @param {gs.Object_Base} object - The game object to set the position for.
1061 * @param {Object} params - The params object of the scene command.
1062 * @return {Object} The position {x, y}.
1063 ###
1064 predefinedObjectPosition: (position, object, params) ->
1065 objectPosition = RecordManager.system.objectPositions[position]
1066 if !objectPosition then return { x: 0, y: 0 }
1067
1068 return objectPosition.func.call(null, object, params) || { x: 0, y: 0 }
1069
1070 ###*
1071 * Sets the value of a number variable at the specified index.
1072 *
1073 * @method setNumberValueAtIndex
1074 * @param {number} scope - The variable's scope.
1075 * @param {number} index - The index of the variable to set.
1076 * @param {number} value - The number value to set the variable to.
1077 ###
1078 setNumberValueAtIndex: (scope, index, value, domain) -> GameManager.variableStore.setNumberValueAtIndex(scope, index, value, domain)
1079
1080 ###*
1081 * Sets the value of a number variable.
1082 *
1083 * @method setNumberValueTo
1084 * @param {number} variable - The variable to set.
1085 * @param {number} value - The number value to set the variable to.
1086 ###
1087 setNumberValueTo: (variable, value) -> GameManager.variableStore.setNumberValueTo(variable, value)
1088
1089 ###*
1090 * Sets the value of a list variable.
1091 *
1092 * @method setListObjectTo
1093 * @param {Object} variable - The variable to set.
1094 * @param {Object} value - The list object to set the variable to.
1095 ###
1096 setListObjectTo: (variable, value) -> GameManager.variableStore.setListObjectTo(variable, value)
1097
1098 ###*
1099 * Sets the value of a boolean/switch variable.
1100 *
1101 * @method setBooleanValueTo
1102 * @param {Object} variable - The variable to set.
1103 * @param {boolean} value - The boolean value to set the variable to.
1104 ###
1105 setBooleanValueTo: (variable, value) -> GameManager.variableStore.setBooleanValueTo(variable, value)
1106
1107 ###*
1108 * Sets the value of a number variable at the specified index.
1109 *
1110 * @method setBooleanValueAtIndex
1111 * @param {number} scope - The variable's scope.
1112 * @param {number} index - The index of the variable to set.
1113 * @param {boolean} value - The boolean value to set the variable to.
1114 ###
1115 setBooleanValueAtIndex: (scope, index, value, domain) -> GameManager.variableStore.setBooleanValueAtIndex(scope, index, value, domain)
1116
1117 ###*
1118 * Sets the value of a string/text variable.
1119 *
1120 * @method setStringValueTo
1121 * @param {Object} variable - The variable to set.
1122 * @param {string} value - The string/text value to set the variable to.
1123 ###
1124 setStringValueTo: (variable, value) -> GameManager.variableStore.setStringValueTo(variable, value)
1125
1126 ###*
1127 * Sets the value of the string variable at the specified index.
1128 *
1129 * @method setStringValueAtIndex
1130 * @param {number} scope - The variable scope.
1131 * @param {number} index - The variable's index.
1132 * @param {string} value - The value to set.
1133 ###
1134 setStringValueAtIndex: (scope, index, value, domain) -> GameManager.variableStore.setStringValueAtIndex(scope, index, value, domain)
1135
1136 ###*
1137 * Gets the value of a (possible) string variable. If a constant string value is specified, this method
1138 * does nothing an just returns that constant value. That's to make it more comfortable to just pass a value which
1139 * can be calculated by variable but also be just a constant value.
1140 *
1141 * @method stringValueOf
1142 * @param {string|Object} object - A string variable or constant string value.
1143 * @return {string} The value of the variable.
1144 ###
1145 stringValueOf: (object) -> GameManager.variableStore.stringValueOf(object)
1146
1147 ###*
1148 * Gets the value of the string variable at the specified index.
1149 *
1150 * @method stringValueAtIndex
1151 * @param {number} scope - The variable's scope.
1152 * @param {number} index - The index of the variable to get the value from.
1153 * @return {string} The value of the variable.
1154 ###
1155 stringValueAtIndex: (scope, index, domain) -> GameManager.variableStore.stringValueAtIndex(scope, index, domain)
1156
1157 ###*
1158 * Gets the value of a (possible) boolean variable. If a constant boolean value is specified, this method
1159 * does nothing an just returns that constant value. That's to make it more comfortable to just pass a value which
1160 * can be calculated by variable but also be just a constant value.
1161 *
1162 * @method booleanValueOf
1163 * @param {boolean|Object} object - A boolean variable or constant boolean value.
1164 * @return {boolean} The value of the variable.
1165 ###
1166 booleanValueOf: (object) -> GameManager.variableStore.booleanValueOf(object)
1167
1168 ###*
1169 * Gets the value of the boolean variable at the specified index.
1170 *
1171 * @method booleanValueAtIndex
1172 * @param {number} scope - The variable's scope.
1173 * @param {number} index - The index of the variable to get the value from.
1174 * @return {string} The value of the variable.
1175 ###
1176 booleanValueAtIndex: (scope, index, domain) -> GameManager.variableStore.booleanValueAtIndex(scope, index, domain)
1177
1178 ###*
1179 * Gets the value of a (possible) list variable.
1180 *
1181 * @method listObjectOf
1182 * @param {Object} object - A list variable.
1183 * @return {Object} The value of the list variable.
1184 ###
1185 listObjectOf: (object) -> GameManager.variableStore.listObjectOf(object)
1186
1187 ###*
1188 * Compares two object using the specified operation and returns the result.
1189 *
1190 * @method compare
1191 * @param {Object} a - Object A.
1192 * @param {Object} b - Object B.
1193 * @param {number} operation - The compare-operation to compare Object A with Object B.
1194 * <ul>
1195 * <li>0 = Equal To</li>
1196 * <li>1 = Not Equal To</li>
1197 * <li>2 = Greater Than</li>
1198 * <li>3 = Greater or Equal To</li>
1199 * <li>4 = Less Than</li>
1200 * <li>5 = Less or Equal To</li>
1201 * </ul>
1202 * @return {boolean} The comparison result.
1203 ###
1204 compare: (a, b, operation) ->
1205 switch operation
1206 when 0 then return `a == b`
1207 when 1 then return `a != b`
1208 when 2 then return a > b
1209 when 3 then return a >= b
1210 when 4 then return a < b
1211 when 5 then return a <= b
1212
1213 ###*
1214 * Changes number variables and allows decimal values such as 0.5 too.
1215 *
1216 * @method changeDecimalVariables
1217 * @param {Object} params - Input params from the command
1218 * @param {Object} roundMethod - The result of the operation will be rounded using the specified method.
1219 * <ul>
1220 * <li>0 = None. The result will not be rounded.</li>
1221 * <li>1 = Commercially</li>
1222 * <li>2 = Round Up</li>
1223 * <li>3 = Round Down</li>
1224 * </ul>
1225 ###
1226 changeDecimalVariables: (params, roundMethod) ->
1227 source = 0
1228 roundFunc = null
1229
1230 switch roundMethod
1231 when 0 then roundFunc = (value) -> value
1232 when 1 then roundFunc = (value) -> Math.round(value)
1233 when 2 then roundFunc = (value) -> Math.ceil(value)
1234 when 3 then roundFunc = (value) -> Math.floor(value)
1235
1236 switch params.source
1237 when 0 # Constant Value / Variable Value
1238 source = @numberValueOf(params.sourceValue)
1239 when 1 # Random
1240 start = @numberValueOf(params.sourceRandom.start)
1241 end = @numberValueOf(params.sourceRandom.end)
1242 diff = end - start
1243 source = Math.floor(start + Math.random() * (diff+1))
1244 when 2 # Pointer
1245 source = @numberValueAtIndex(params.sourceScope, @numberValueOf(params.sourceReference)-1, params.sourceReferenceDomain)
1246 when 3 # Game Data
1247 source = @numberValueOfGameData(params.sourceValue1)
1248 when 4 # Database Data
1249 source = @numberValueOfDatabaseData(params.sourceValue1)
1250
1251 switch params.target
1252 when 0 # Variable
1253 switch params.operation
1254 when 0 # Set
1255 @setNumberValueTo(params.targetVariable, roundFunc(source))
1256 when 1 # Add
1257 @setNumberValueTo(params.targetVariable, roundFunc(@numberValueOf(params.targetVariable) + source) )
1258 when 2 # Sub
1259 @setNumberValueTo(params.targetVariable, roundFunc(@numberValueOf(params.targetVariable) - source) )
1260 when 3 # Mul
1261 @setNumberValueTo(params.targetVariable, roundFunc(@numberValueOf(params.targetVariable) * source))
1262 when 4 # Div
1263 @setNumberValueTo(params.targetVariable, roundFunc(@numberValueOf(params.targetVariable) / source))
1264 when 5 # Mod
1265 @setNumberValueTo(params.targetVariable, @numberValueOf(params.targetVariable) % source)
1266 when 1 # Range
1267 scope = params.targetScope
1268 start = params.targetRange.start-1
1269 end = params.targetRange.end-1
1270 for i in [start..end]
1271 switch params.operation
1272 when 0 # Set
1273 @setNumberValueAtIndex(scope, i, roundFunc(source))
1274 when 1 # Add
1275 @setNumberValueAtIndex(scope, i, roundFunc(@numberValueAtIndex(scope, i) + source))
1276 when 2 # Sub
1277 @setNumberValueAtIndex(scope, i, roundFunc(@numberValueAtIndex(scope, i) - source))
1278 when 3 # Mul
1279 @setNumberValueAtIndex(scope, i, roundFunc(@numberValueAtIndex(scope, i) * source))
1280 when 4 # Div
1281 @setNumberValueAtIndex(scope, i, roundFunc(@numberValueAtIndex(scope, i) / source))
1282 when 5 # Mod
1283 @setNumberValueAtIndex(scope, i, @numberValueAtIndex(scope, i) % source)
1284 when 2 # Reference
1285 index = @numberValueOf(params.targetReference) - 1
1286 switch params.operation
1287 when 0 # Set
1288 @setNumberValueAtIndex(params.targetScope, index, roundFunc(source), params.targetReferenceDomain)
1289 when 1 # Add
1290 @setNumberValueAtIndex(params.targetScope, index, roundFunc(@numberValueAtIndex(params.targetScope, index, params.targetReferenceDomain) + source), params.targetReferenceDomain)
1291 when 2 # Sub
1292 @setNumberValueAtIndex(params.targetScope, index, roundFunc(@numberValueAtIndex(params.targetScope, index, params.targetReferenceDomain) - source), params.targetReferenceDomain)
1293 when 3 # Mul
1294 @setNumberValueAtIndex(params.targetScope, index, roundFunc(@numberValueAtIndex(params.targetScope, index, params.targetReferenceDomain) * source), params.targetReferenceDomain)
1295 when 4 # Div
1296 @setNumberValueAtIndex(params.targetScope, index, roundFunc(@numberValueAtIndex(params.targetScope, index, params.targetReferenceDomain) / source), params.targetReferenceDomain)
1297 when 5 # Mod
1298 @setNumberValueAtIndex(params.targetScope, index, @numberValueAtIndex(params.targetScope, index, params.targetReferenceDomain) % source, params.targetReferenceDomain)
1299
1300 return null
1301
1302 ###*
1303 * Shakes a game object.
1304 *
1305 * @method shakeObject
1306 * @param {gs.Object_Base} object - The game object to shake.
1307 * @return {Object} A params object containing additional info about the shake-animation.
1308 ###
1309 shakeObject: (object, params) ->
1310 duration = Math.max(Math.round(@durationValueOf(params.duration)), 2)
1311 easing = gs.Easings.fromObject(params.easing)
1312
1313 object.animator.shake({ x: @numberValueOf(params.range.x), y: @numberValueOf(params.range.y) }, @numberValueOf(params.speed) / 100, duration, easing)
1314
1315 if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
1316 @isWaiting = yes
1317 @waitCounter = duration
1318
1319 ###*
1320 * Lets the interpreter wait for the completion of a running operation like an animation, etc.
1321 *
1322 * @method waitForCompletion
1323 * @param {gs.Object_Base} object - The game object the operation is executed on. Can be <b>null</b>.
1324 * @return {Object} A params object containing additional info.
1325 ###
1326 waitForCompletion: (object, params) ->
1327 duration = @durationValueOf(params.duration)
1328 if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
1329 @isWaiting = yes
1330 @waitCounter = duration
1331
1332 ###*
1333 * Erases a game object.
1334 *
1335 * @method eraseObject
1336 * @param {gs.Object_Base} object - The game object to erase.
1337 * @return {Object} A params object containing additional info.
1338 ###
1339 eraseObject: (object, params, callback) ->
1340 easing = gs.Easings.fromObject(params.easing)
1341 duration = @durationValueOf(params.duration)
1342 object.animator.disappear(params.animation, easing, duration, (sender) =>
1343 sender.dispose()
1344 callback?(sender)
1345 )
1346
1347 if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
1348 @isWaiting = yes
1349 @waitCounter = duration
1350
1351 ###*
1352 * Shows a game object on screen.
1353 *
1354 * @method showObject
1355 * @param {gs.Object_Base} object - The game object to show.
1356 * @param {gs.Point} position - The position where the game object should be shown.
1357 * @param {Object} A params object containing additional info.
1358 ###
1359 showObject: (object, position, params) ->
1360 x = @numberValueOf(position.x)
1361 y = @numberValueOf(position.y)
1362 easing = gs.Easings.fromObject(params.easing)
1363 duration = @durationValueOf(params.duration)
1364
1365 object.animator.appear(x, y, params.animation, easing, duration)
1366
1367 if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
1368 @isWaiting = yes
1369 @waitCounter = duration
1370
1371
1372 ###*
1373 * Moves a game object.
1374 *
1375 * @method moveObject
1376 * @param {gs.Object_Base} object - The game object to move.
1377 * @param {gs.Point} position - The position to move the game object to.
1378 * @param {Object} A params object containing additional info.
1379 ###
1380 moveObject: (object, position, params) ->
1381 if params.positionType == 0
1382 p = @predefinedObjectPosition(params.predefinedPositionId, object, params)
1383 x = p.x
1384 y = p.y
1385 else
1386 x = @numberValueOf(position.x)
1387 y = @numberValueOf(position.y)
1388
1389 easing = gs.Easings.fromObject(params.easing)
1390 duration = @durationValueOf(params.duration)
1391
1392 object.animator.moveTo(x, y, duration, easing)
1393
1394 if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
1395 @isWaiting = yes
1396 @waitCounter = duration
1397
1398 ###*
1399 * Moves a game object along a path.
1400 *
1401 * @method moveObjectPath
1402 * @param {gs.Object_Base} object - The game object to move.
1403 * @param {Object} path - The path to move the game object along.
1404 * @param {Object} A params object containing additional info.
1405 ###
1406 moveObjectPath: (object, path, params) ->
1407 easing = gs.Easings.fromObject(params.easing)
1408 duration = @durationValueOf(params.duration)
1409 object.animator.movePath(path.data, params.loopType, duration, easing, path.effects?.data)
1410
1411 if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
1412 @isWaiting = yes
1413 @waitCounter = duration
1414
1415 ###*
1416 * Scrolls a scrollable game object along a path.
1417 *
1418 * @method scrollObjectPath
1419 * @param {gs.Object_Base} object - The game object to scroll.
1420 * @param {Object} path - The path to scroll the game object along.
1421 * @param {Object} A params object containing additional info.
1422 ###
1423 scrollObjectPath: (object, path, params) ->
1424 easing = gs.Easings.fromObject(params.easing)
1425 duration = @durationValueOf(params.duration)
1426 object.animator.scrollPath(path, params.loopType, duration, easing)
1427
1428 if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
1429 @isWaiting = yes
1430 @waitCounter = duration
1431
1432 ###*
1433 * Zooms/Scales a game object.
1434 *
1435 * @method zoomObject
1436 * @param {gs.Object_Base} object - The game object to zoom.
1437 * @param {Object} A params object containing additional info.
1438 ###
1439 zoomObject: (object, params) ->
1440 easing = gs.Easings.fromObject(params.easing)
1441 duration = @durationValueOf(params.duration)
1442 object.animator.zoomTo(@numberValueOf(params.zooming.x) / 100, @numberValueOf(params.zooming.y) / 100, duration, easing)
1443
1444 if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
1445 @isWaiting = yes
1446 @waitCounter = duration
1447
1448 ###*
1449 * Rotates a game object.
1450 *
1451 * @method rotateObject
1452 * @param {gs.Object_Base} object - The game object to rotate.
1453 * @param {Object} A params object containing additional info.
1454 ###
1455 rotateObject: (object, params) ->
1456 easing = gs.Easings.fromObject(params.easing)
1457 duration = @durationValueOf(params.duration)
1458
1459
1460 easing = gs.Easings.fromObject(params.easing)
1461
1462 #if GameManager.tempSettings.skip
1463 # actualDuration = @durationValueOf(@params.duration)
1464 # duration = @durationValueOf(@duration)
1465 # speed = @numberValueOf(@params.speed) / 100
1466 # speed = Math.round(duration / (actualDuration||1) * speed)
1467 # picture.animator.rotate(@params.direction, speed, actualDuration||1, easing)
1468 # duration = actualDuration
1469 #else
1470 # duration = @durationValueOf(params.duration)
1471 # object.animator.rotate(params.direction, @numberValueOf(@params.speed) / 100, duration, easing)
1472
1473 object.animator.rotate(params.direction, @numberValueOf(params.speed) / 100, duration, easing)
1474
1475 if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
1476 @isWaiting = yes
1477 @waitCounter = duration
1478
1479 ###*
1480 * Blends a game object.
1481 *
1482 * @method blendObject
1483 * @param {gs.Object_Base} object - The game object to blend.
1484 * @param {Object} A params object containing additional info.
1485 ###
1486 blendObject: (object, params) ->
1487 easing = gs.Easings.fromObject(params.easing)
1488 duration = @durationValueOf(params.duration)
1489 object.animator.blendTo(@numberValueOf(params.opacity), duration, easing)
1490
1491 if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
1492 @isWaiting = yes
1493 @waitCounter = duration
1494
1495 ###*
1496 * Executes a masking-effect on a game object..
1497 *
1498 * @method maskObject
1499 * @param {gs.Object_Base} object - The game object to execute a masking-effect on.
1500 * @param {Object} A params object containing additional info.
1501 ###
1502 maskObject: (object, params) ->
1503 easing = gs.Easings.fromObject(params.easing)
1504
1505 if params.mask.type == 0
1506 object.mask.type = 0
1507 object.mask.ox = @numberValueOf(params.mask.ox)
1508 object.mask.oy = @numberValueOf(params.mask.oy)
1509 if object.mask.source?.videoElement?
1510 object.mask.source.pause()
1511
1512 if params.mask.sourceType == 0
1513 object.mask.source = ResourceManager.getBitmap("Graphics/Masks/#{params.mask.graphic?.name}")
1514 else
1515 object.mask.source = ResourceManager.getVideo("Movies/#{params.mask.video?.name}")
1516 if object.mask.source
1517 object.mask.source.play()
1518 object.mask.source.loop = yes
1519 else
1520 duration = @durationValueOf(params.duration)
1521 mask = Object.flatCopy(params.mask)
1522 mask.value = @numberValueOf(mask.value)
1523 object.animator.maskTo(mask, duration, easing)
1524
1525 if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
1526 @isWaiting = yes
1527 @waitCounter = duration
1528
1529 ###*
1530 * Tints a game object.
1531 *
1532 * @method tintObject
1533 * @param {gs.Object_Base} object - The game object to tint.
1534 * @param {Object} A params object containing additional info.
1535 ###
1536 tintObject: (object, params) ->
1537 duration = @durationValueOf(params.duration)
1538 easing = gs.Easings.fromObject(params.easing)
1539 object.animator.tintTo(params.tone, duration, easing)
1540
1541 if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
1542 @isWaiting = yes
1543 @waitCounter = duration
1544
1545 ###*
1546 * Flashes a game object.
1547 *
1548 * @method flashObject
1549 * @param {gs.Object_Base} object - The game object to flash.
1550 * @param {Object} A params object containing additional info.
1551 ###
1552 flashObject: (object, params) ->
1553 duration = @durationValueOf(params.duration)
1554 object.animator.flash(new Color(params.color), duration)
1555
1556 if params.waitForCompletion and not (duration == 0 or @isInstantSkip())
1557 @isWaiting = yes
1558 @waitCounter = duration
1559
1560 ###*
1561 * Cropes a game object.
1562 *
1563 * @method cropObject
1564 * @param {gs.Object_Base} object - The game object to crop.
1565 * @param {Object} A params object containing additional info.
1566 ###
1567 cropObject: (object, params) ->
1568 object.srcRect.x = @numberValueOf(params.x)
1569 object.srcRect.y = @numberValueOf(params.y)
1570 object.srcRect.width = @numberValueOf(params.width)
1571 object.srcRect.height = @numberValueOf(params.height)
1572
1573 object.dstRect.width = @numberValueOf(params.width)
1574 object.dstRect.height = @numberValueOf(params.height)
1575
1576 ###*
1577 * Sets the motion blur settings of a game object.
1578 *
1579 * @method objectMotionBlur
1580 * @param {gs.Object_Base} object - The game object to set the motion blur settings for.
1581 * @param {Object} A params object containing additional info.
1582 ###
1583 objectMotionBlur: (object, params) ->
1584 object.motionBlur.set(params.motionBlur)
1585
1586 ###*
1587 * Enables an effect on a game object.
1588 *
1589 * @method objectEffect
1590 * @param {gs.Object_Base} object - The game object to execute a masking-effect on.
1591 * @param {Object} A params object containing additional info.
1592 ###
1593 objectEffect: (object, params) ->
1594 duration = @durationValueOf(params.duration)
1595 easing = gs.Easings.fromObject(params.easing)
1596
1597 switch params.type
1598 when 0 # Wobble
1599 object.animator.wobbleTo(params.wobble.power / 10000, params.wobble.speed / 100, duration, easing)
1600 wobble = object.effects.wobble
1601 wobble.enabled = params.wobble.power > 0
1602 wobble.vertical = params.wobble.orientation == 0 or params.wobble.orientation == 2
1603 wobble.horizontal = params.wobble.orientation == 1 or params.wobble.orientation == 2
1604 when 1 # Blur
1605 object.animator.blurTo(params.blur.power / 100, duration, easing)
1606 object.effects.blur.enabled = yes
1607 when 2 # Pixelate
1608 object.animator.pixelateTo(params.pixelate.size.width, params.pixelate.size.height, duration, easing)
1609 object.effects.pixelate.enabled = yes
1610
1611 if params.waitForCompletion and duration != 0
1612 @isWaiting = yes
1613 @waitCounter = duration
1614
1615 ###*
1616 * Executes an action like for a hotspot.
1617 *
1618 * @method executeAction
1619 * @param {Object} action - Action-Data.
1620 * @param {boolean} stateValue - In case of switch-binding, the switch is set to this value.
1621 * @param {number} bindValue - A number value which be put into the action's bind-value variable.
1622 ###
1623 executeAction: (action, stateValue, bindValue) ->
1624 switch action.type
1625 when 0 # Jump To Label
1626 if action.labelIndex
1627 @pointer = action.labelIndex
1628 else
1629 @jumpToLabel(action.label)
1630 when 1 # Call Common Event
1631 @callCommonEvent(action.commonEventId, null, @isWaiting)
1632 when 2 # Bind To Switch
1633 domain = GameManager.variableStore.domain
1634 @setBooleanValueTo(action.switch, stateValue)
1635 when 3 # Call Scene
1636 @callScene(action.scene?.uid)
1637 when 4 # Bind Value to Variable
1638 domain = GameManager.variableStore.domain
1639 @setNumberValueTo(action.bindValueVariable, bindValue)
1640 if action.labelIndex
1641 @pointer = action.labelIndex
1642 else
1643 @jumpToLabel(action.label)
1644
1645 ###*
1646 * Calls a common event and returns the sub-interpreter for it.
1647 *
1648 * @method callCommonEvent
1649 * @param {number} id - The ID of the common event to call.
1650 * @param {Object} parameters - Optional common event parameters.
1651 * @param {boolean} wait - Indicates if the interpreter should be stay in waiting-mode even if the sub-interpreter is finished.
1652 ###
1653 callCommonEvent: (id, parameters, wait) ->
1654 commonEvent = GameManager.commonEvents[id]
1655
1656 if commonEvent?
1657 if SceneManager.scene.commonEventContainer.subObjects.indexOf(commonEvent) == -1
1658 SceneManager.scene.commonEventContainer.addObject(commonEvent)
1659 commonEvent.events?.on "finish", gs.CallBack("onCommonEventFinish", this), { waiting: wait }
1660
1661 @subInterpreter = commonEvent.behavior.call(parameters || [], @settings, @context)
1662 #GameManager.variableStore.setupLocalVariables(@subInterpreter.context)
1663 #GameManager.variableStore.setupTempVariables(@subInterpreter.context)
1664 commonEvent.behavior.update()
1665
1666 if @subInterpreter?
1667 @isWaiting = yes
1668 @subInterpreter.settings = @settings
1669 @subInterpreter.start()
1670 @subInterpreter.update()
1671
1672 ###*
1673 * Calls a scene and returns the sub-interpreter for it.
1674 *
1675 * @method callScene
1676 * @param {String} uid - The UID of the scene to call.
1677 ###
1678 callScene: (uid) ->
1679 sceneDocument = DataManager.getDocument(uid)
1680
1681 if sceneDocument?
1682 @isWaiting = yes
1683 @subInterpreter = new vn.Component_CallSceneInterpreter()
1684 object = { commands: sceneDocument.items.commands }
1685 @subInterpreter.repeat = no
1686 @subInterpreter.context.set(sceneDocument.uid, sceneDocument)
1687 @subInterpreter.object = object
1688 @subInterpreter.onFinish = gs.CallBack("onCallSceneFinish", this)
1689 @subInterpreter.start()
1690 @subInterpreter.settings = @settings
1691 @subInterpreter.update()
1692
1693
1694
1695 ###*
1696 * Calls a common event and returns the sub-interpreter for it.
1697 *
1698 * @method storeListValue
1699 * @param {number} id - The ID of the common event to call.
1700 * @param {Object} parameters - Optional common event parameters.
1701 * @param {boolean} wait - Indicates if the interpreter should be stay in waiting-mode even if the sub-interpreter is finished.
1702 ###
1703 storeListValue: (variable, list, value, valueType) ->
1704 switch valueType
1705 when 0 # Number Value
1706 @setNumberValueTo(variable, (if !isNaN(value) then value else 0))
1707 when 1 # Switch Value
1708 @setBooleanValueTo(variable, (if value then 1 else 0))
1709 when 2 # Text Value
1710 @setStringValueTo(variable, value.toString())
1711 when 3 # List Value
1712 @setListObjectTo(variable, (if value.length? then value else []))
1713
1714 ###*
1715 * @method jumpToLabel
1716 ###
1717 jumpToLabel: (label) ->
1718 return if not label
1719 found = no
1720
1721 for i in [0...@object.commands.length]
1722 if @object.commands[i].id == "gs.Label" and @object.commands[i].params.name == label
1723 @pointer = i
1724 @indent = @object.commands[i].indent
1725 found = yes
1726 break
1727
1728 if found
1729 @waitCounter = 0
1730 @isWaiting = no
1731
1732 ###*
1733 * Gets the current message box object depending on game mode (ADV or NVL).
1734 *
1735 * @method messageBoxObject
1736 * @return {gs.Object_Base} The message box object.
1737 * @protected
1738 ###
1739 messageBoxObject: (id) ->
1740 if SceneManager.scene.layout.visible
1741 return gs.ObjectManager.current.objectById(id || "messageBox")
1742 else
1743 return gs.ObjectManager.current.objectById(id || "nvlMessageBox")
1744
1745 ###*
1746 * Gets the current message object depending on game mode (ADV or NVL).
1747 *
1748 * @method messageObject
1749 * @return {ui.Object_Message} The message object.
1750 * @protected
1751 ###
1752 messageObject: ->
1753 if SceneManager.scene.layout.visible
1754 return gs.ObjectManager.current.objectById("gameMessage_message")
1755 else
1756 return gs.ObjectManager.current.objectById("nvlGameMessage_message")
1757 ###*
1758 * Gets the current message ID depending on game mode (ADV or NVL).
1759 *
1760 * @method messageObjectId
1761 * @return {string} The message object ID.
1762 * @protected
1763 ###
1764 messageObjectId: ->
1765 if SceneManager.scene.layout.visible
1766 return "gameMessage_message"
1767 else
1768 return "nvlGameMessage_message"
1769
1770 ###*
1771 * Gets the current message settings.
1772 *
1773 * @method messageSettings
1774 * @return {Object} The message settings
1775 * @protected
1776 ###
1777 messageSettings: ->
1778 message = @targetMessage()
1779
1780 return message.settings
1781
1782 ###*
1783 * Gets the current target message object where all message commands are executed on.
1784 *
1785 * @method targetMessage
1786 * @return {ui.Object_Message} The target message object.
1787 * @protected
1788 ###
1789 targetMessage: ->
1790 message = @messageObject()
1791 target = @settings.message.target
1792 if target?
1793 switch target.type
1794 when 0 # Layout-Based
1795 message = gs.ObjectManager.current.objectById(target.id) ? @messageObject()
1796 when 1 # Custom
1797 message = SceneManager.scene.messageAreas[target.id]?.message ? @messageObject()
1798
1799 return message
1800
1801 ###*
1802 * Gets the current target message box containing the current target message.
1803 *
1804 * @method targetMessageBox
1805 * @return {ui.Object_UIElement} The target message box.
1806 * @protected
1807 ###
1808 targetMessageBox: ->
1809 messageBox = @messageObject()
1810 target = @settings.message.target
1811 if target?
1812 switch target.type
1813 when 0 # Layout-Based
1814 messageBox = gs.ObjectManager.current.objectById(target.id) ? @messageObject()
1815 when 1 # Custom
1816 messageBox = gs.ObjectManager.current.objectById("customGameMessage_"+target.id) ? @messageObject()
1817
1818 return messageBox
1819
1820 ###*
1821 * Called after an input number dialog was accepted by the user. It takes the user's input and puts
1822 * it in the configured number variable.
1823 *
1824 * @method onInputNumberFinish
1825 * @return {Object} Event Object containing additional data like the number, etc.
1826 * @protected
1827 ###
1828 onInputNumberFinish: (e) ->
1829 @messageObject().behavior.clear()
1830 @setNumberValueTo(@waitingFor.inputNumber.variable, parseInt(ui.Component_FormulaHandler.fieldValue(e.sender, e.number)))
1831 @isWaiting = no
1832 @waitingFor.inputNumber = null
1833 SceneManager.scene.inputNumberBox.dispose()
1834
1835 ###*
1836 * Called after an input text dialog was accepted by the user. It takes the user's text input and puts
1837 * it in the configured string variable.
1838 *
1839 * @method onInputTextFinish
1840 * @return {Object} Event Object containing additional data like the text, etc.
1841 * @protected
1842 ###
1843 onInputTextFinish: (e) ->
1844 @messageObject().behavior.clear()
1845 @setStringValueTo(@waitingFor.inputText.variable, ui.Component_FormulaHandler.fieldValue(e.sender, e.text).replace(/_/g, ""))
1846 @isWaiting = no
1847 @waitingFor.inputText = null
1848 SceneManager.scene.inputTextBox.dispose()
1849
1850 ###*
1851 * Called after a choice was selected by the user. It jumps to the corresponding label
1852 * and also puts the choice into backlog.
1853 *
1854 * @method onChoiceAccept
1855 * @return {Object} Event Object containing additional data like the label, etc.
1856 * @protected
1857 ###
1858 onChoiceAccept: (e) ->
1859 scene = SceneManager.scene
1860 scene.choiceTimer.behavior.stop()
1861
1862 e.isSelected = yes
1863 delete e.sender
1864
1865 GameManager.backlog.push({ character: { name: "" }, message: "", choice: e, choices: scene.choices, isChoice: yes })
1866 scene.choices = []
1867 messageObject = @messageObject()
1868 if messageObject?.visible
1869 @isWaiting = yes
1870 fading = GameManager.tempSettings.messageFading
1871 duration = if GameManager.tempSettings.skip then 0 else fading.duration
1872 messageObject.animator.disappear(fading.animation, fading.easing, duration, =>
1873 messageObject.behavior.clear()
1874 messageObject.visible = no
1875 @isWaiting = no
1876 @waitingFor.choice = null
1877 @executeAction(e.action, true)
1878 )
1879 else
1880 @isWaiting = no
1881 @executeAction(e.action, true)
1882 scene.choiceWindow.dispose()
1883
1884 ###*
1885 * Idle
1886 * @method commandIdle
1887 * @protected
1888 ###
1889 commandIdle: ->
1890 @interpreter.isWaiting = !@interpreter.isInstantSkip()
1891
1892
1893 ###*
1894 * Start Timer
1895 * @method commandStartTimer
1896 * @protected
1897 ###
1898 commandStartTimer: ->
1899 scene = SceneManager.scene
1900 timers = scene.timers
1901 number = @interpreter.numberValueOf(@params.number)
1902 timer = timers[number]
1903 if not timer?
1904 timer = new gs.Object_IntervalTimer()
1905 timers[number] = timer
1906
1907 timer.events.offByOwner("elapsed", @object)
1908 timer.events.on("elapsed", (e) =>
1909 params = e.data.params
1910 switch params.action.type
1911 when 0 # Jump To Label
1912 if params.labelIndex?
1913 SceneManager.scene.interpreter.pointer = params.labelIndex
1914 else
1915 SceneManager.scene.interpreter.jumpToLabel(params.action.data.label)
1916 when 1 # Call Common Event
1917 SceneManager.scene.interpreter.callCommonEvent(params.action.data.commonEventId, null, @interpreter.isWaiting)
1918 { params: @params }, @object)
1919
1920 timer.behavior.interval = @interpreter.durationValueOf(@params.interval)
1921 timer.behavior.start()
1922
1923
1924 ###*
1925 * Resume Timer
1926 * @method commandResumeTimer
1927 * @protected
1928 ###
1929 commandResumeTimer: ->
1930 timers = SceneManager.scene.timers
1931 number = @interpreter.numberValueOf(@params.number)
1932 timers[number]?.behavior.resume()
1933
1934 ###*
1935 * Pauses Timer
1936 * @method commandPauseTimer
1937 * @protected
1938 ###
1939 commandPauseTimer: ->
1940 timers = SceneManager.scene.timers
1941 number = @interpreter.numberValueOf(@params.number)
1942 timers[number]?.behavior.pause()
1943
1944 ###*
1945 * Stop Timer
1946 * @method commandStopTimer
1947 * @protected
1948 ###
1949 commandStopTimer: ->
1950 timers = SceneManager.scene.timers
1951 number = @interpreter.numberValueOf(@params.number)
1952 timers[number]?.behavior.stop()
1953
1954 ###*
1955 * Wait
1956 * @method commandWait
1957 * @protected
1958 ###
1959 commandWait: ->
1960 time = @interpreter.durationValueOf(@params.time)
1961
1962 if time? and time > 0 and !@interpreter.previewData
1963 @interpreter.waitCounter = time
1964 @interpreter.isWaiting = yes
1965
1966 ###*
1967 * Loop
1968 * @method commandLoop
1969 * @protected
1970 ###
1971 commandLoop: ->
1972 @interpreter.loops[@interpreter.indent] = @interpreter.pointer
1973 @interpreter.indent++
1974
1975 ###*
1976 * Break Loop
1977 * @method commandBreakLoop
1978 * @protected
1979 ###
1980 commandBreakLoop: ->
1981 indent = @indent
1982 while not @interpreter.loops[indent]? and indent > 0
1983 indent--
1984
1985 @interpreter.loops[indent] = null
1986 @interpreter.indent = indent
1987
1988 ###*
1989 * @method commandListAdd
1990 * @protected
1991 ###
1992 commandListAdd: ->
1993 list = @interpreter.listObjectOf(@params.listVariable)
1994
1995 switch @params.valueType
1996 when 0 # Number Value
1997 list.push(@interpreter.numberValueOf(@params.numberValue))
1998 when 1 # Switch Value
1999 list.push(@interpreter.booleanValueOf(@params.switchValue))
2000 when 2 # Text Value
2001 list.push(@interpreter.stringValueOf(@params.stringValue))
2002 when 3 # List Value
2003 list.push(@interpreter.listObjectOf(@params.listValue))
2004
2005 @interpreter.setListObjectTo(@params.listVariable, list)
2006
2007 ###*
2008 * @method commandListPop
2009 * @protected
2010 ###
2011 commandListPop: ->
2012 list = @interpreter.listObjectOf(@params.listVariable)
2013 value = list.pop() ? 0
2014
2015 @interpreter.storeListValue(@params.targetVariable, list, value, @params.valueType)
2016
2017 ###*
2018 * @method commandListShift
2019 * @protected
2020 ###
2021 commandListShift: ->
2022 list = @interpreter.listObjectOf(@params.listVariable)
2023 value = list.shift() ? 0
2024
2025 @interpreter.storeListValue(@params.targetVariable, list, value, @params.valueType)
2026
2027 ###*
2028 * @method commandListIndexOf
2029 * @protected
2030 ###
2031 commandListIndexOf: ->
2032 list = @interpreter.listObjectOf(@params.listVariable)
2033 value = -1
2034
2035 switch @params.valueType
2036 when 0 # Number Value
2037 value = list.indexOf(@interpreter.numberValueOf(@params.numberValue))
2038 when 1 # Switch Value
2039 value = list.indexOf(@interpreter.booleanValueOf(@params.switchValue))
2040 when 2 # Text Value
2041 value = list.indexOf(@interpreter.stringValueOf(@params.stringValue))
2042 when 3 # List Value
2043 value = list.indexOf(@interpreter.listObjectOf(@params.listValue))
2044
2045 @interpreter.setNumberValueTo(@params.targetVariable, value)
2046
2047 ###*
2048 * @method commandListClear
2049 * @protected
2050 ###
2051 commandListClear: ->
2052 list = @interpreter.listObjectOf(@params.listVariable)
2053 list.length = 0
2054
2055 ###*
2056 * @method commandListValueAt
2057 * @protected
2058 ###
2059 commandListValueAt: ->
2060 list = @interpreter.listObjectOf(@params.listVariable)
2061 index = @interpreter.numberValueOf(@params.index)
2062
2063 if index >= 0 and index < list.length
2064 value = list[index] ? 0
2065 @interpreter.storeListValue(@params.targetVariable, list, value, @params.valueType)
2066
2067 ###*
2068 * @method commandListRemoveAt
2069 * @protected
2070 ###
2071 commandListRemoveAt: ->
2072 list = @interpreter.listObjectOf(@params.listVariable)
2073 index = @interpreter.numberValueOf(@params.index)
2074
2075 if index >= 0 and index < list.length
2076 list.splice(index, 1)
2077
2078 ###*
2079 * @method commandListInsertAt
2080 * @protected
2081 ###
2082 commandListInsertAt: ->
2083 list = @interpreter.listObjectOf(@params.listVariable)
2084 index = @interpreter.numberValueOf(@params.index)
2085
2086 if index >= 0 and index < list.length
2087 switch @params.valueType
2088 when 0 # Number Value
2089 list.splice(index, 0, @interpreter.numberValueOf(@params.numberValue))
2090 when 1 # Switch Value
2091 list.splice(index, 0, @interpreter.booleanValueOf(@params.switchValue))
2092 when 2 # Text Value
2093 list.splice(index, 0, @interpreter.stringValueOf(@params.stringValue))
2094 when 3 # List Value
2095 list.splice(index, 0, @interpreter.listObjectOf(@params.listValue))
2096
2097 @interpreter.setListObjectTo(@params.listVariable, list)
2098
2099 ###*
2100 * @method commandListSet
2101 * @protected
2102 ###
2103 commandListSet: ->
2104 list = @interpreter.listObjectOf(@params.listVariable)
2105 index = @interpreter.numberValueOf(@params.index)
2106
2107 if index >= 0
2108 switch @params.valueType
2109 when 0 # Number Value
2110 list[index] = @interpreter.numberValueOf(@params.numberValue)
2111 when 1 # Switch Value
2112 list[index] = @interpreter.booleanValueOf(@params.switchValue)
2113 when 2 # Text Value
2114 list[index] = @interpreter.stringValueOf(@params.stringValue)
2115 when 3 # List Value
2116 list[index] = @interpreter.listObjectOf(@params.listValue)
2117
2118 @interpreter.setListObjectTo(@params.listVariable, list)
2119
2120 ###*
2121 * @method commandListCopy
2122 * @protected
2123 ###
2124 commandListCopy: ->
2125 list = @interpreter.listObjectOf(@params.listVariable)
2126 copy = Object.deepCopy(list)
2127
2128 @interpreter.setListObjectTo(@params.targetVariable, copy)
2129
2130 ###*
2131 * @method commandListLength
2132 * @protected
2133 ###
2134 commandListLength: ->
2135 list = @interpreter.listObjectOf(@params.listVariable)
2136
2137 @interpreter.setNumberValueTo(@params.targetVariable, list.length)
2138
2139 ###*
2140 * @method commandListJoin
2141 * @protected
2142 ###
2143 commandListJoin: ->
2144 list = @interpreter.listObjectOf(@params.listVariable)
2145 value = if @params.order == 0 then list.join(@params.separator||"") else list.reverse().join(@params.separator||"")
2146
2147 @interpreter.setStringValueTo(@params.targetVariable, value)
2148
2149 ###*
2150 * @method commandListFromText
2151 * @protected
2152 ###
2153 commandListFromText: ->
2154 text = @interpreter.stringValueOf(@params.textVariable)
2155 separator = @interpreter.stringValueOf(@params.separator)
2156 list = text.split(separator)
2157
2158 @interpreter.setListObjectTo(@params.targetVariable, list)
2159
2160 ###*
2161 * @method commandListShuffle
2162 * @protected
2163 ###
2164 commandListShuffle: ->
2165 list = @interpreter.listObjectOf(@params.listVariable)
2166 if list.length == 0 then return
2167
2168 for i in [list.length-1..1]
2169 j = Math.floor(Math.random() * (i+1))
2170 tempi = list[i]
2171 tempj = list[j]
2172 list[i] = tempj
2173 list[j] = tempi
2174
2175 ###*
2176 * @method commandListSort
2177 * @protected
2178 ###
2179 commandListSort: ->
2180 list = @interpreter.listObjectOf(@params.listVariable)
2181 if list.length == 0 then return
2182
2183 switch @params.sortOrder
2184 when 0 # Ascending
2185 list.sort (a, b) ->
2186 if a < b then return -1
2187 if a > b then return 1
2188 return 0
2189 when 1 # Descending
2190 list.sort (a, b) ->
2191 if a > b then return -1
2192 if a < b then return 1
2193 return 0
2194
2195
2196 ###*
2197 * @method commandResetVariables
2198 * @protected
2199 ###
2200 commandResetVariables: ->
2201 switch @params.target
2202 when 0 # All
2203 range = null
2204 when 1 # Range
2205 range = @params.range
2206
2207 switch @params.scope
2208 when 0 # Local
2209 if @params.scene
2210 GameManager.variableStore.clearLocalVariables({ id: @params.scene.uid }, @params.type, range)
2211 when 1 # All Locals
2212 GameManager.variableStore.clearLocalVariables(null, @params.type, range)
2213 when 2 # Global
2214 GameManager.variableStore.clearGlobalVariables(@params.type, range)
2215 when 3 # Persistent
2216 GameManager.variableStore.clearPersistentVariables(@params.type, range)
2217 GameManager.saveGlobalData()
2218
2219
2220 ###*
2221 * @method commandChangeVariableDomain
2222 * @protected
2223 ###
2224 commandChangeVariableDomain: ->
2225 GameManager.variableStore.changeDomain(@interpreter.stringValueOf(@params.domain))
2226
2227 ###*
2228 * @method commandChangeDecimalVariables
2229 * @protected
2230 ###
2231 commandChangeDecimalVariables: -> @interpreter.changeDecimalVariables(@params, @params.roundMethod)
2232
2233 ###*
2234 * @method commandChangeNumberVariables
2235 * @protected
2236 ###
2237 commandChangeNumberVariables: ->
2238 source = 0
2239
2240 switch @params.source
2241 when 0 # Constant Value / Variable Value
2242 source = @interpreter.numberValueOf(@params.sourceValue)
2243 when 1 # Random
2244 start = @interpreter.numberValueOf(@params.sourceRandom.start)
2245 end = @interpreter.numberValueOf(@params.sourceRandom.end)
2246 diff = end - start
2247 source = Math.floor(start + Math.random() * (diff+1))
2248 when 2 # Pointer
2249 source = @interpreter.numberValueAtIndex(@params.sourceScope, @interpreter.numberValueOf(@params.sourceReference)-1, @params.sourceReferenceDomain)
2250 when 3 # Game Data
2251 source = @interpreter.numberValueOfGameData(@params.sourceValue1)
2252 when 4 # Database Data
2253 source = @interpreter.numberValueOfDatabaseData(@params.sourceValue1)
2254
2255 switch @params.target
2256 when 0 # Variable
2257 switch @params.operation
2258 when 0 # Set
2259 @interpreter.setNumberValueTo(@params.targetVariable, source)
2260 when 1 # Add
2261 @interpreter.setNumberValueTo(@params.targetVariable, @interpreter.numberValueOf(@params.targetVariable) + source)
2262 when 2 # Sub
2263 @interpreter.setNumberValueTo(@params.targetVariable, @interpreter.numberValueOf(@params.targetVariable) - source)
2264 when 3 # Mul
2265 @interpreter.setNumberValueTo(@params.targetVariable, @interpreter.numberValueOf(@params.targetVariable) * source)
2266 when 4 # Div
2267 @interpreter.setNumberValueTo(@params.targetVariable, Math.floor(@interpreter.numberValueOf(@params.targetVariable) / source))
2268 when 5 # Mod
2269 @interpreter.setNumberValueTo(@params.targetVariable, @interpreter.numberValueOf(@params.targetVariable) % source)
2270 when 1 # Range
2271 scope = @params.targetScope
2272 start = @params.targetRange.start-1
2273 end = @params.targetRange.end-1
2274 for i in [start..end]
2275 switch @params.operation
2276 when 0 # Set
2277 @interpreter.setNumberValueAtIndex(scope, i, source)
2278 when 1 # Add
2279 @interpreter.setNumberValueAtIndex(scope, i, @interpreter.numberValueAtIndex(scope, i) + source)
2280 when 2 # Sub
2281 @interpreter.setNumberValueAtIndex(scope, i, @interpreter.numberValueAtIndex(scope, i) - source)
2282 when 3 # Mul
2283 @interpreter.setNumberValueAtIndex(scope, i, @interpreter.numberValueAtIndex(scope, i) * source)
2284 when 4 # Div
2285 @interpreter.setNumberValueAtIndex(scope, i, Math.floor(@interpreter.numberValueAtIndex(scope, i) / source))
2286 when 5 # Mod
2287 @interpreter.setNumberValueAtIndex(scope, i, @interpreter.numberValueAtIndex(scope, i) % source)
2288 when 2 # Reference
2289 index = @interpreter.numberValueOf(@params.targetReference) - 1
2290 switch @params.operation
2291 when 0 # Set
2292 @interpreter.setNumberValueAtIndex(@params.targetScope, index, source, @params.targetReferenceDomain)
2293 when 1 # Add
2294 @interpreter.setNumberValueAtIndex(@params.targetScope, index, @interpreter.numberValueAtIndex(@params.targetScope, index, @params.targetReferenceDomain) + source, @params.targetReferenceDomain)
2295 when 2 # Sub
2296 @interpreter.setNumberValueAtIndex(@params.targetScope, index, @interpreter.numberValueAtIndex(@params.targetScope, index, @params.targetReferenceDomain) - source, @params.targetReferenceDomain)
2297 when 3 # Mul
2298 @interpreter.setNumberValueAtIndex(@params.targetScope, index, @interpreter.numberValueAtIndex(@params.targetScope, index, @params.targetReferenceDomain) * source, @params.targetReferenceDomain)
2299 when 4 # Div
2300 @interpreter.setNumberValueAtIndex(@params.targetScope, index, Math.floor(@interpreter.numberValueAtIndex(@params.targetScope, index, @params.targetReferenceDomain) / source), @params.targetReferenceDomain)
2301 when 5 # Mod
2302 @interpreter.setNumberValueAtIndex(@params.targetScope, index, @interpreter.numberValueAtIndex(@params.targetScope, index, @params.targetReferenceDomain) % source, @params.targetReferenceDomain)
2303
2304 return null
2305
2306 ###*
2307 * @method commandChangeBooleanVariables
2308 * @protected
2309 ###
2310 commandChangeBooleanVariables: ->
2311 source = @interpreter.booleanValueOf(@params.value)
2312
2313 switch @params.target
2314 when 0 # Variable
2315 if @params.value == 2 # Trigger
2316 targetValue = @interpreter.booleanValueOf(@params.targetVariable)
2317 @interpreter.setBooleanValueTo(@params.targetVariable, if targetValue then false else true)
2318 else
2319 @interpreter.setBooleanValueTo(@params.targetVariable, source)
2320 when 1 # Range
2321 variable = { index: 0, scope: @params.targetRangeScope }
2322 for i in [(@params.rangeStart-1)..(@params.rangeEnd-1)]
2323 variable.index = i
2324 if @params.value == 2 # Trigger
2325 targetValue = @interpreter.booleanValueOf(variable)
2326 @interpreter.setBooleanValueTo(variable, if targetValue then false else true)
2327 else
2328 @interpreter.setBooleanValueTo(variable, source)
2329 when 2 # Reference
2330 index = @interpreter.numberValueOf(@params.targetReference) - 1
2331 @interpreter.setBooleanValueAtIndex(@params.targetRangeScope, index, source, @params.targetReferenceDomain)
2332
2333 return null
2334
2335 ###*
2336 * @method commandChangeStringVariables
2337 * @protected
2338 ###
2339 commandChangeStringVariables: ->
2340 source = ""
2341 switch @params.source
2342 when 0 # Constant Text
2343 source = lcs(@params.textValue)
2344 when 1 # Variable
2345 source = @interpreter.stringValueOf(@params.sourceVariable)
2346 when 2 # Database Data
2347 source = @interpreter.stringValueOfDatabaseData(@params.databaseData)
2348 when 2 # Script
2349 try
2350 source = eval(@params.script)
2351 catch ex
2352 source = "ERR: " + ex.message
2353 else
2354 source = lcs(@params.textValue)
2355
2356 switch @params.target
2357 when 0 # Variable
2358 switch @params.operation
2359 when 0 # Set
2360 @interpreter.setStringValueTo(@params.targetVariable, source)
2361 when 1 # Add
2362 @interpreter.setStringValueTo(@params.targetVariable, @interpreter.stringValueOf(@params.targetVariable) + source)
2363 when 2 # To Upper-Case
2364 @interpreter.setStringValueTo(@params.targetVariable, @interpreter.stringValueOf(@params.targetVariable).toUpperCase())
2365 when 3 # To Lower-Case
2366 @interpreter.setStringValueTo(@params.targetVariable, @interpreter.stringValueOf(@params.targetVariable).toLowerCase())
2367
2368 when 1 # Range
2369 variable = { index: 0, scope: @params.targetRangeScope }
2370 for i in [@params.rangeStart-1..@params.rangeEnd-1]
2371 variable.index = i
2372 switch @params.operation
2373 when 0 # Set
2374 @interpreter.setStringValueTo(variable, source)
2375 when 1 # Add
2376 @interpreter.setStringValueTo(variable, @interpreter.stringValueOf(variable) + source)
2377 when 2 # To Upper-Case
2378 @interpreter.setStringValueTo(variable, @interpreter.stringValueOf(variable).toUpperCase())
2379 when 3 # To Lower-Case
2380 @interpreter.setStringValueTo(variable, @interpreter.stringValueOf(variable).toLowerCase())
2381
2382 when 2 # Reference
2383 index = @interpreter.numberValueOf(@params.targetReference) - 1
2384 switch @params.operation
2385 when 0 # Set
2386 @interpreter.setStringValueAtIndex(@params.targetRangeScope, index, source, @params.targetReferenceDomain)
2387 when 1 # Add
2388 targetValue = @interpreter.stringValueAtIndex(@params.targetRangeScope, index, @params.targetReferenceDomain)
2389 @interpreter.setStringValueAtIndex(@params.targetRangeScope, index, targetValue + source, @params.targetReferenceDomain)
2390 when 2 # To Upper-Case
2391 targetValue = @interpreter.stringValueAtIndex(@params.targetRangeScope, index, @params.targetReferenceDomain)
2392 @interpreter.setStringValueAtIndex(@params.targetRangeScope, index, targetValue.toUpperCase(), @params.targetReferenceDomain)
2393 when 3 # To Lower-Case
2394 targetValue = @interpreter.stringValueAtIndex(@params.targetRangeScope, index, @params.targetReferenceDomain)
2395 @interpreter.setStringValueTo(@params.targetRangeScope, index, targetValue.toLowerCase(), @params.targetReferenceDomain)
2396 return null
2397
2398 ###*
2399 * @method commandCheckSwitch
2400 * @protected
2401 ###
2402 commandCheckSwitch: ->
2403 result = @interpreter.booleanValueOf(@params.targetVariable) && @params.value
2404 if result
2405 @interpreter.pointer = @params.labelIndex
2406
2407
2408 ###*
2409 * @method commandNumberCondition
2410 * @protected
2411 ###
2412 commandNumberCondition: ->
2413 result = @interpreter.compare(@interpreter.numberValueOf(@params.targetVariable), @interpreter.numberValueOf(@params.value), @params.operation)
2414 @interpreter.conditions[@interpreter.indent] = result
2415
2416 if result
2417 @interpreter.indent++
2418
2419 ###*
2420 * @method commandCondition
2421 * @protected
2422 ###
2423 commandCondition: ->
2424 switch @params.valueType
2425 when 0 # Number
2426 result = @interpreter.compare(@interpreter.numberValueOf(@params.variable), @interpreter.numberValueOf(@params.numberValue), @params.operation)
2427 when 1 # Switch
2428 result = @interpreter.compare(@interpreter.booleanValueOf(@params.variable), @interpreter.booleanValueOf(@params.switchValue), @params.operation)
2429 when 2 # Text
2430 result = @interpreter.compare(lcs(@interpreter.stringValueOf(@params.variable)), lcs(@interpreter.stringValueOf(@params.textValue)), @params.operation)
2431
2432 @interpreter.conditions[@interpreter.indent] = result
2433 if result
2434 @interpreter.indent++
2435
2436 ###*
2437 * @method commandConditionElse
2438 * @protected
2439 ###
2440 commandConditionElse: ->
2441 if not @interpreter.conditions[@interpreter.indent]
2442 @interpreter.indent++
2443
2444 ###*
2445 * @method commandConditionElseIf
2446 * @protected
2447 ###
2448 commandConditionElseIf: ->
2449 if not @interpreter.conditions[@interpreter.indent]
2450 @interpreter.commandCondition.call(this)
2451
2452 ###*
2453 * @method commandCheckNumberVariable
2454 * @protected
2455 ###
2456 commandCheckNumberVariable: ->
2457 result = @interpreter.compare(@interpreter.numberValueOf(@params.targetVariable), @interpreter.numberValueOf(@params.value), @params.operation)
2458 if result
2459 @interpreter.pointer = @params.labelIndex
2460
2461 ###*
2462 * @method commandCheckTextVariable
2463 * @protected
2464 ###
2465 commandCheckTextVariable: ->
2466 result = no
2467 text1 = @interpreter.stringValueOf(@params.targetVariable)
2468 text2 = @interpreter.stringValueOf(@params.value)
2469 switch @params.operation
2470 when 0 then result = text1 == text2
2471 when 1 then result = text1 != text2
2472 when 2 then result = text1.length > text2.length
2473 when 3 then result = text1.length >= text2.length
2474 when 4 then result = text1.length < text2.length
2475 when 5 then result = text1.length <= text2.length
2476
2477 if result
2478 @interpreter.pointer = @params.labelIndex
2479
2480 ###*
2481 * @method commandLabel
2482 * @protected
2483 ###
2484 commandLabel: -> # Does Nothing
2485
2486
2487 ###*
2488 * @method commandJumpToLabel
2489 * @protected
2490 ###
2491 commandJumpToLabel: ->
2492 label = @params.labelIndex #@interpreter.labels[@params.name]
2493 if label?
2494 @interpreter.pointer = label
2495 @interpreter.indent = @interpreter.object.commands[label].indent
2496 else
2497 switch @params.target
2498 when "activeContext"
2499 @interpreter.jumpToLabel(@interpreter.stringValueOf(@params.name))
2500 when "activeScene"
2501 SceneManager.scene.interpreter.jumpToLabel(@interpreter.stringValueOf(@params.name))
2502 else
2503 @interpreter.jumpToLabel(@interpreter.stringValueOf(@params.name))
2504
2505 ###*
2506 * @method commandClearMessage
2507 * @protected
2508 ###
2509 commandClearMessage: ->
2510 scene = SceneManager.scene
2511 messageObject = @interpreter.targetMessage()
2512 if not messageObject? then return
2513
2514 flags = @params.fieldFlags || {}
2515 isLocked = gs.CommandFieldFlags.isLocked
2516 duration = 0
2517 fading = GameManager.tempSettings.messageFading
2518 if not GameManager.tempSettings.skip
2519 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else fading.duration
2520 messageObject.animator.disappear(fading.animation, fading.easing, duration, gs.CallBack("onMessageADVClear", @interpreter))
2521
2522 @interpreter.waitForCompletion(messageObject, @params)
2523 gs.GameNotifier.postMinorChange()
2524
2525 ###*
2526 * @method commandMessageBoxDefaults
2527 * @protected
2528 ###
2529 commandMessageBoxDefaults: ->
2530 defaults = GameManager.defaults.messageBox
2531 flags = @params.fieldFlags || {}
2532 isLocked = gs.CommandFieldFlags.isLocked
2533
2534 if !isLocked(flags.appearDuration) then defaults.appearDuration = @interpreter.durationValueOf(@params.appearDuration)
2535 if !isLocked(flags.disappearDuration) then defaults.disappearDuration = @interpreter.durationValueOf(@params.disappearDuration)
2536 if !isLocked(flags.zOrder) then defaults.zOrder = @interpreter.numberValueOf(@params.zOrder)
2537 if !isLocked(flags["appearEasing.type"]) then defaults.appearEasing = @params.appearEasing
2538 if !isLocked(flags["appearAnimation.type"]) then defaults.appearAnimation = @params.appearAnimation
2539 if !isLocked(flags["disappearEasing.type"]) then defaults.disappearEasing = @params.disappearEasing
2540 if !isLocked(flags["disappearAnimation.type"]) then defaults.disappearAnimation = @params.disappearAnimation
2541
2542
2543 ###*
2544 * @method commandShowMessage
2545 * @protected
2546 ###
2547 commandShowMessage: ->
2548 scene = SceneManager.scene
2549 scene.messageMode = vn.MessageMode.ADV
2550 character = scene.characters.first (v) => !v.disposed and v.rid == @params.characterId
2551
2552 showMessage = =>
2553 character = RecordManager.characters[@params.characterId]
2554
2555 scene.layout.visible = yes
2556 messageObject = @interpreter.targetMessage()
2557
2558 if not messageObject? then return
2559
2560 scene.currentCharacter = character
2561 messageObject.character = character
2562
2563 messageObject.opacity = 255
2564 messageObject.events.offByOwner("callCommonEvent", @interpreter)
2565 messageObject.events.on("callCommonEvent", gs.CallBack("onCallCommonEvent", @interpreter), params: @params, @interpreter)
2566 messageObject.events.once("finish", gs.CallBack("onMessageADVFinish", @interpreter), params: @params, @interpreter)
2567 messageObject.events.once("waiting", gs.CallBack("onMessageADVWaiting", @interpreter), params: @params, @interpreter)
2568 if messageObject.settings.useCharacterColor
2569 messageObject.message.showMessage(@interpreter, @params, character)
2570 else
2571 messageObject.message.showMessage(@interpreter, @params)
2572
2573 settings = GameManager.settings
2574 voiceSettings = settings.voicesByCharacter[character.index]
2575
2576 if @params.voice? and GameManager.settings.voiceEnabled and (!voiceSettings or voiceSettings > 0)
2577 if (GameManager.settings.skipVoiceOnAction or !AudioManager.voice?.playing) and !GameManager.tempSettings.skip
2578 messageObject.voice = @params.voice
2579 messageObject.behavior.voice = AudioManager.playVoice(@params.voice)
2580 else
2581 messageObject.behavior.voice = null
2582
2583 if @params.expressionId? and character?
2584 expression = RecordManager.characterExpressions[@params.expressionId || 0]
2585 defaults = GameManager.defaults.character
2586 duration = if !gs.CommandFieldFlags.isLocked(@params.fieldFlags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.expressionDuration
2587 easing = gs.Easings.fromObject(defaults.changeEasing)
2588 animation = defaults.changeAnimation
2589
2590 character.behavior.changeExpression(expression, animation, easing, duration, =>
2591 showMessage()
2592 )
2593 else
2594 showMessage()
2595
2596 @interpreter.isWaiting = (@params.waitForCompletion ? yes) and !(GameManager.tempSettings.skip and GameManager.tempSettings.skipTime == 0)
2597 @interpreter.waitingFor.messageADV = @params
2598
2599 ###*
2600 * @method commandSetMessageArea
2601 * @protected
2602 ###
2603 commandSetMessageArea: ->
2604 scene = SceneManager.scene
2605 number = @interpreter.numberValueOf(@params.number)
2606
2607 if scene.messageAreas[number]
2608 messageLayout = scene.messageAreas[number].layout
2609 messageLayout.dstRect.x = @params.box.x
2610 messageLayout.dstRect.y = @params.box.y
2611 messageLayout.dstRect.width = @params.box.size.width
2612 messageLayout.dstRect.height = @params.box.size.height
2613 messageLayout.needsUpdate = yes
2614
2615 ###*
2616 * @method commandMessageFading
2617 * @protected
2618 ###
2619 commandMessageFading: ->
2620 GameManager.tempSettings.messageFading = duration: @interpreter.durationValueOf(@params.duration), animation: @params.animation, easing: gs.Easings.fromObject(@params.easing)
2621
2622 ###*
2623 * @method commandMessageSettings
2624 * @protected
2625 ###
2626 commandMessageSettings: ->
2627 messageObject = @interpreter.targetMessage()
2628 if !messageObject then return
2629
2630 flags = @params.fieldFlags || {}
2631 isLocked = gs.CommandFieldFlags.isLocked
2632 messageSettings = @interpreter.messageSettings()
2633
2634 if !isLocked(flags.autoErase)
2635 messageSettings.autoErase = @params.autoErase
2636
2637 if !isLocked(flags.waitAtEnd)
2638 messageSettings.waitAtEnd = @params.waitAtEnd
2639
2640 if !isLocked(flags.backlog)
2641 messageSettings.backlog = @params.backlog
2642
2643 if !isLocked(flags.lineHeight)
2644 messageSettings.lineHeight = @params.lineHeight
2645
2646 if !isLocked(flags.lineSpacing)
2647 messageSettings.lineSpacing = @params.lineSpacing
2648
2649 if !isLocked(flags.linePadding)
2650 messageSettings.linePadding = @params.linePadding
2651
2652 if !isLocked(flags.paragraphSpacing)
2653 messageSettings.paragraphSpacing = @params.paragraphSpacing
2654
2655 if !isLocked(flags.useCharacterColor)
2656 messageSettings.useCharacterColor = @params.useCharacterColor
2657
2658 messageObject.textRenderer.minLineHeight = messageSettings.lineHeight ? 0
2659 messageObject.textRenderer.lineSpacing = messageSettings.lineSpacing ? messageObject.textRenderer.lineSpacing
2660 messageObject.textRenderer.padding = messageSettings.linePadding ? messageObject.textRenderer.padding
2661
2662 fontName = if !isLocked(flags.font) then @params.font else messageObject.font.name
2663 fontSize = if !isLocked(flags.size) then @params.size else messageObject.font.size
2664 font = messageObject.font
2665
2666 if !isLocked(flags.font) or !isLocked(flags.size)
2667 messageObject.font = new Font(fontName, fontSize)
2668
2669 if !isLocked(flags.bold)
2670 messageObject.font.bold = @params.bold
2671 if !isLocked(flags.italic)
2672 messageObject.font.italic = @params.italic
2673 if !isLocked(flags.smallCaps)
2674 messageObject.font.smallCaps = @params.smallCaps
2675 if !isLocked(flags.underline)
2676 messageObject.font.underline = @params.underline
2677 if !isLocked(flags.strikeThrough)
2678 messageObject.font.strikeThrough = @params.strikeThrough
2679 if !isLocked(flags.color)
2680 messageObject.font.color = new Color(@params.color)
2681
2682 messageObject.font.color = if flags.color? and !isLocked(flags.color) then new Color(@params.color) else font.color
2683 messageObject.font.border = if flags.outline? and !isLocked(flags.outline) then @params.outline else font.border
2684 messageObject.font.borderColor = if flags.outlineColor? and !isLocked(flags.outlineColor) then new Color(@params.outlineColor) else new Color(font.borderColor)
2685 messageObject.font.borderSize = if flags.outlineSize? and !isLocked(flags.outlineSize) then (@params.outlineSize ? 4) else font.borderSize
2686 messageObject.font.shadow = if flags.shadow? and !isLocked(flags.shadow)then @params.shadow else font.shadow
2687 messageObject.font.shadowColor = if flags.shadowColor? and !isLocked(flags.shadowColor) then new Color(@params.shadowColor) else new Color(font.shadowColor)
2688 messageObject.font.shadowOffsetX = if flags.shadowOffsetX? and !isLocked(flags.shadowOffsetX) then (@params.shadowOffsetX ? 1) else font.shadowOffsetX
2689 messageObject.font.shadowOffsetY = if flags.shadowOffsetY? and !isLocked(flags.shadowOffsetY) then (@params.shadowOffsetY ? 1) else font.shadowOffsetY
2690
2691 if isLocked(flags.bold) then messageObject.font.bold = font.bold
2692 if isLocked(flags.italic) then messageObject.font.italic = font.italic
2693 if isLocked(flags.smallCaps) then messageObject.font.smallCaps = font.smallCaps
2694
2695 ###*
2696 * @method commandCreateMessageArea
2697 * @protected
2698 ###
2699 commandCreateMessageArea: ->
2700 number = @interpreter.numberValueOf(@params.number)
2701 scene = SceneManager.scene
2702 scene.behavior.changeMessageAreaDomain(@params.numberDomain)
2703 if !scene.messageAreas[number]
2704 messageArea = new gs.Object_MessageArea()
2705 messageArea.layout = ui.UIManager.createControlFromDescriptor(type: "ui.CustomGameMessage", id: "customGameMessage_"+number, params: { id: "customGameMessage_"+number }, messageArea)
2706 messageArea.message = gs.ObjectManager.current.objectById("customGameMessage_"+number+"_message")
2707 messageArea.message.domain = @params.numberDomain
2708 messageArea.addObject(messageArea.layout)
2709 messageArea.layout.dstRect.x = @params.box.x
2710 messageArea.layout.dstRect.y = @params.box.y
2711 messageArea.layout.dstRect.width = @params.box.size.width
2712 messageArea.layout.dstRect.height = @params.box.size.height
2713 messageArea.layout.needsUpdate = yes
2714 scene.messageAreas[number] = messageArea
2715
2716 ###*
2717 * @method commandEraseMessageArea
2718 * @protected
2719 ###
2720 commandEraseMessageArea: ->
2721 number = @interpreter.numberValueOf(@params.number)
2722 scene = SceneManager.scene
2723 scene.behavior.changeMessageAreaDomain(@params.numberDomain)
2724 area = scene.messageAreas[number]
2725 area?.layout.dispose()
2726 scene.messageAreas[number] = null
2727
2728 ###*
2729 * @method commandSetTargetMessage
2730 * @protected
2731 ###
2732 commandSetTargetMessage: ->
2733 message = @interpreter.targetMessage()
2734 message?.textRenderer.isWaiting = false
2735 message?.behavior.isWaiting = false
2736
2737 scene = SceneManager.scene
2738 scene.behavior.changeMessageAreaDomain(@params.numberDomain)
2739 target = { type: @params.type, id: null }
2740
2741 switch @params.type
2742 when 0 # Layout-based
2743 target.id = @params.id
2744 when 1 # Custom
2745 target.id = @interpreter.numberValueOf(@params.number)
2746
2747 @interpreter.settings.message.target = target
2748
2749 if @params.clear
2750 @interpreter.targetMessage()?.behavior.clear()
2751 @interpreter.targetMessage()?.visible = yes
2752
2753 ###*
2754 * @method commandBacklogVisibility
2755 * @protected
2756 ###
2757 commandBacklogVisibility: ->
2758 if @params.visible
2759 control = gs.ObjectManager.current.objectById("backlogBox")
2760 if not control? then control = gs.ObjectManager.current.objectById("backlog")
2761
2762 if control?
2763 control.dispose()
2764
2765 if @params.backgroundVisible
2766 control = SceneManager.scene.behavior.createControl(this, { descriptor: "ui.MessageBacklogBox" })
2767 else
2768 control = SceneManager.scene.behavior.createControl(this, { descriptor: "ui.MessageBacklog" })
2769 else
2770 control = gs.ObjectManager.current.objectById("backlogBox")
2771 if not control? then control = gs.ObjectManager.current.objectById("backlog")
2772
2773 control?.dispose()
2774
2775 ###*
2776 * @method commandMessageVisibility
2777 * @protected
2778 ###
2779 commandMessageVisibility: ->
2780 defaults = GameManager.defaults.messageBox
2781 flags = @params.fieldFlags || {}
2782 isLocked = gs.CommandFieldFlags.isLocked
2783
2784 message = @interpreter.targetMessage()
2785 if not message? or @params.visible == message.visible then return
2786
2787 if @params.visible
2788 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.appearDuration
2789 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromObject(@params.easing) else gs.Easings.fromObject(defaults.appearEasing)
2790 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.appearAnimation
2791 message.animator.appear(message.dstRect.x, message.dstRect.y, @params.animation, easing, duration)
2792 else
2793 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.disappearDuration
2794 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromObject(@params.easing) else gs.Easings.fromObject(defaults.disappearEasing)
2795 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.disappearAnimation
2796 message.animator.disappear(animation, easing, duration, -> message.visible = no)
2797 message.update()
2798
2799 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
2800 @interpreter.isWaiting = yes
2801 @interpreter.waitCounter = duration
2802 gs.GameNotifier.postMinorChange()
2803 ###*
2804 * @method commandMessageBoxVisibility
2805 * @protected
2806 ###
2807 commandMessageBoxVisibility: ->
2808 defaults = GameManager.defaults.messageBox
2809 flags = @params.fieldFlags || {}
2810 isLocked = gs.CommandFieldFlags.isLocked
2811 messageBox = @interpreter.messageBoxObject(@interpreter.stringValueOf(@params.id))
2812 visible = @params.visible == 1
2813 if not messageBox? or visible == messageBox.visible then return
2814
2815 if @params.visible
2816 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.appearDuration
2817 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromObject(@params.easing) else gs.Easings.fromObject(defaults.appearEasing)
2818 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.appearAnimation
2819 messageBox.animator.appear(messageBox.dstRect.x, messageBox.dstRect.y, animation, easing, duration)
2820 else
2821 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.disappearDuration
2822 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromObject(@params.easing) else gs.Easings.fromObject(defaults.disappearEasing)
2823 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.disappearAnimation
2824 messageBox.animator.disappear(animation, easing, duration, -> messageBox.visible = no)
2825 messageBox.update()
2826
2827 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
2828 @interpreter.isWaiting = yes
2829 @interpreter.waitCounter = duration
2830 gs.GameNotifier.postMinorChange()
2831
2832 ###*
2833 * @method commandUIAccess
2834 * @protected
2835 ###
2836 commandUIAccess: ->
2837 flags = @params.fieldFlags || {}
2838 isLocked = gs.CommandFieldFlags.isLocked
2839
2840 if !isLocked(flags.generalMenu)
2841 GameManager.tempSettings.menuAccess = @interpreter.booleanValueOf(@params.generalMenu)
2842 if !isLocked(flags.saveMenu)
2843 GameManager.tempSettings.saveMenuAccess = @interpreter.booleanValueOf(@params.saveMenu)
2844 if !isLocked(flags.loadMenu)
2845 GameManager.tempSettings.loadMenuAccess = @interpreter.booleanValueOf(@params.loadMenu)
2846 if !isLocked(flags.backlog)
2847 GameManager.tempSettings.backlogAccess = @interpreter.booleanValueOf(@params.backlog)
2848
2849 ###*
2850 * @method commandUnlockCG
2851 * @protected
2852 ###
2853 commandUnlockCG: ->
2854 cg = RecordManager.cgGallery[@interpreter.stringValueOf(@params.cgId)]
2855
2856 if cg?
2857 GameManager.globalData.cgGallery[cg.index] = { unlocked: yes }
2858 GameManager.saveGlobalData()
2859
2860 ###*
2861 * @method commandL2DMove
2862 * @protected
2863 ###
2864 commandL2DMove: ->
2865 scene = SceneManager.scene
2866 character = scene.characters.first (v) => !v.disposed and v.rid == @params.characterId
2867 if not character instanceof vn.Object_Live2DCharacter then return
2868
2869 @interpreter.moveObject(character, @params.position, @params)
2870 gs.GameNotifier.postMinorChange()
2871
2872 ###*
2873 * @method commandL2DMotionGroup
2874 * @protected
2875 ###
2876 commandL2DMotionGroup: ->
2877 scene = SceneManager.scene
2878 character = scene.characters.first (v) => !v.disposed and v.rid == @params.characterId
2879 if not character instanceof vn.Object_Live2DCharacter then return
2880
2881 character.motionGroup = { name: @params.data.motionGroup, loop: @params.loop, playType: @params.playType }
2882 if @params.waitForCompletion and not @params.loop
2883 motions = character.model.motionsByGroup[character.motionGroup.name]
2884 if motions?
2885 @interpreter.isWaiting = yes
2886 @interpreter.waitCounter = motions.sum (m) -> m.getDurationMSec() / 16.6
2887 gs.GameNotifier.postMinorChange()
2888
2889 ###*
2890 * @method commandL2DMotion
2891 * @protected
2892 ###
2893 commandL2DMotion: ->
2894 defaults = GameManager.defaults.live2d
2895 flags = @params.fieldFlags || {}
2896 isLocked = gs.CommandFieldFlags.isLocked
2897 scene = SceneManager.scene
2898 character = scene.characters.first (v) => !v.disposed and v.rid == @params.characterId
2899 if not character instanceof vn.Object_Live2DCharacter then return
2900 fadeInTime = if !isLocked(flags.fadeInTime) then @params.fadeInTime else defaults.motionFadeInTime
2901 character.motion = { name: @params.data.motion, fadeInTime: fadeInTime, loop: @params.loop }
2902 character.motionGroup = null
2903
2904 if @params.waitForCompletion and not @params.loop
2905 motion = character.model.motions[character.motion.name]
2906 if motion?
2907 @interpreter.isWaiting = yes
2908 @interpreter.waitCounter = motion.getDurationMSec() / 16.6
2909 gs.GameNotifier.postMinorChange()
2910
2911 ###*
2912 * @method commandL2DExpression
2913 * @protected
2914 ###
2915 commandL2DExpression: ->
2916 defaults = GameManager.defaults.live2d
2917 flags = @params.fieldFlags || {}
2918 isLocked = gs.CommandFieldFlags.isLocked
2919 scene = SceneManager.scene
2920 character = scene.characters.first (v) => !v.disposed and v.rid == @params.characterId
2921 if not character instanceof vn.Object_Live2DCharacter then return
2922 fadeInTime = if !isLocked(flags.fadeInTime) then @params.fadeInTime else defaults.expressionFadeInTime
2923
2924 character.expression = { name: @params.data.expression, fadeInTime: fadeInTime }
2925 gs.GameNotifier.postMinorChange()
2926
2927 ###*
2928 * @method commandL2DExitScene
2929 * @protected
2930 ###
2931 commandL2DExitScene: ->
2932 defaults = GameManager.defaults.live2d
2933 @interpreter.commandCharacterExitScene.call(this, defaults)
2934 gs.GameNotifier.postMinorChange()
2935
2936 ###*
2937 * @method commandL2DSettings
2938 * @protected
2939 ###
2940 commandL2DSettings: ->
2941 flags = @params.fieldFlags || {}
2942 isLocked = gs.CommandFieldFlags.isLocked
2943
2944 scene = SceneManager.scene
2945 character = scene.characters.first (v) => !v.disposed and v.rid == @params.characterId
2946 if not character?.visual.l2dObject then return
2947
2948
2949 if !isLocked(flags.lipSyncSensitivity)
2950 character.visual.l2dObject.lipSyncSensitivity = @interpreter.numberValueOf(@params.lipSyncSensitivity)
2951 if !isLocked(flags.idleIntensity)
2952 character.visual.l2dObject.idleIntensity = @interpreter.numberValueOf(@params.idleIntensity)
2953 if !isLocked(flags.breathIntensity)
2954 character.visual.l2dObject.breathIntensity = @interpreter.numberValueOf(@params.breathIntensity)
2955 if !isLocked(flags["eyeBlink.enabled"])
2956 character.visual.l2dObject.eyeBlink.enabled = @params.eyeBlink.enabled
2957 if !isLocked(flags["eyeBlink.interval"])
2958 character.visual.l2dObject.eyeBlink.blinkIntervalMsec = @interpreter.numberValueOf(@params.eyeBlink.interval)
2959 if !isLocked(flags["eyeBlink.closedMotionTime"])
2960 character.visual.l2dObject.eyeBlink.closedMotionMsec = @interpreter.numberValueOf(@params.eyeBlink.closedMotionTime)
2961 if !isLocked(flags["eyeBlink.closingMotionTime"])
2962 character.visual.l2dObject.eyeBlink.closingMotionMsec = @interpreter.numberValueOf(@params.eyeBlink.closingMotionTime)
2963 if !isLocked(flags["eyeBlink.openingMotionTime"])
2964 character.visual.l2dObject.eyeBlink.openingMotionMsec = @interpreter.numberValueOf(@params.eyeBlink.openingMotionTime)
2965
2966 gs.GameNotifier.postMinorChange()
2967 ###*
2968 * @method commandL2DParameter
2969 * @protected
2970 ###
2971 commandL2DParameter: ->
2972 scene = SceneManager.scene
2973 character = scene.characters.first (v) => !v.disposed and v.rid == @params.characterId
2974 if not character instanceof vn.Object_Live2DCharacter then return
2975
2976 easing = gs.Easings.fromObject(@params.easing)
2977 duration = @interpreter.durationValueOf(@params.duration)
2978 character.animator.l2dParameterTo(@params.param.name, @interpreter.numberValueOf(@params.param.value), duration, easing)
2979
2980 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
2981 @interpreter.isWaiting = yes
2982 @interpreter.waitCounter = duration
2983 gs.GameNotifier.postMinorChange()
2984 ###*
2985 * @method commandL2DDefaults
2986 * @protected
2987 ###
2988 commandL2DDefaults: ->
2989 defaults = GameManager.defaults.live2d
2990 flags = @params.fieldFlags || {}
2991 isLocked = gs.CommandFieldFlags.isLocked
2992
2993 if !isLocked(flags.appearDuration) then defaults.appearDuration = @interpreter.durationValueOf(@params.appearDuration)
2994 if !isLocked(flags.disappearDuration) then defaults.disappearDuration = @interpreter.durationValueOf(@params.disappearDuration)
2995 if !isLocked(flags.zOrder) then defaults.zOrder = @interpreter.numberValueOf(@params.zOrder)
2996 if !isLocked(flags.motionFadeInTime) then defaults.motionFadeInTime = @interpreter.numberValueOf(@params.motionFadeInTime)
2997 if !isLocked(flags["appearEasing.type"]) then defaults.appearEasing = @params.appearEasing
2998 if !isLocked(flags["appearAnimation.type"]) then defaults.appearAnimation = @params.appearAnimation
2999 if !isLocked(flags["disappearEasing.type"]) then defaults.disappearEasing = @params.disappearEasing
3000 if !isLocked(flags["disappearAnimation.type"]) then defaults.disappearAnimation = @params.disappearAnimation
3001
3002 gs.GameNotifier.postMinorChange()
3003 ###*
3004 * @method commandL2DJoinScene
3005 * @protected
3006 ###
3007 commandL2DJoinScene: ->
3008 defaults = GameManager.defaults.live2d
3009 flags = @params.fieldFlags || {}
3010 isLocked = gs.CommandFieldFlags.isLocked
3011 scene = SceneManager.scene
3012 record = RecordManager.characters[@interpreter.stringValueOf(@params.characterId)]
3013 return if !record or scene.characters.first (v) -> !v.disposed and v.rid == record.index
3014
3015 if @params.positionType == 1
3016 x = @params.position.x
3017 y = @params.position.y
3018 else if @params.positionType == 2
3019 x = @interpreter.numberValueOf(@params.position.x)
3020 y = @interpreter.numberValueOf(@params.position.y)
3021
3022 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut) else gs.Easings.fromObject(defaults.appearEasing)
3023 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.appearDuration
3024 zIndex = if !isLocked(flags.zOrder) then @interpreter.numberValueOf(@params.zOrder) else defaults.zOrder
3025 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.appearAnimation
3026 motionBlur = if !isLocked(flags["motionBlur.enabled"]) then @params.motionBlur else defaults.motionBlur
3027 origin = if !isLocked(flags.origin) then @params.origin else defaults.origin
3028 instant = duration == 0 or @interpreter.isInstantSkip()
3029 noAnim = duration == 0 or GameManager.tempSettings.skip
3030
3031 if @params.waitForCompletion and not instant
3032 @interpreter.isWaiting = yes
3033 @interpreter.waitCounter = duration
3034
3035
3036 character = new vn.Object_Live2DCharacter(record)
3037 character.modelName = @params.model?.name || ""
3038 character.model = ResourceManager.getLive2DModel("Live2D/#{character.modelName}")
3039 character.motion = { name: "", fadeInTime: 0, loop: true } if character.model.motions
3040 #character.expression = { name: Object.keys(character.model.expressions)[0], fadeInTime: 0 } if character.model.expressions
3041 character.dstRect.x = x
3042 character.dstRect.y = y
3043 character.anchor.x = if !origin then 0 else 0.5
3044 character.anchor.y = if !origin then 0 else 0.5
3045 character.blendMode = @interpreter.numberValueOf(@params.blendMode)
3046 character.zoom.x = @params.position.zoom.d
3047 character.zoom.y = @params.position.zoom.d
3048 character.zIndex = zIndex || 200
3049 character.model?.reset()
3050 character.setup()
3051 character.visual.l2dObject.idleIntensity = record.idleIntensity ? 1.0
3052 character.visual.l2dObject.breathIntensity = record.breathIntensity ? 1.0
3053 character.visual.l2dObject.lipSyncSensitivity = record.lipSyncSensitivity ? 1.0
3054
3055 character.update()
3056
3057 if @params.positionType == 0
3058 p = @interpreter.predefinedObjectPosition(@params.predefinedPositionId, character, @params)
3059 character.dstRect.x = p.x
3060 character.dstRect.y = p.y
3061
3062 scene.behavior.addCharacter(character, noAnim, { animation: animation, duration: duration, easing: easing, motionBlur: motionBlur})
3063
3064 if @params.viewport?.type == "ui"
3065 character.viewport = Graphics.viewport
3066
3067 gs.GameNotifier.postMinorChange()
3068 ###*
3069 * @method commandCharacterJoinScene
3070 * @protected
3071 ###
3072 commandCharacterJoinScene: ->
3073 defaults = GameManager.defaults.character
3074 flags = @params.fieldFlags || {}
3075 isLocked = gs.CommandFieldFlags.isLocked
3076 scene = SceneManager.scene
3077 characterId = @interpreter.stringValueOf(@params.characterId)
3078 expressionId = @interpreter.stringValueOf(@params.expressionId) || @params.expressionId
3079 record = RecordManager.characters[characterId]
3080
3081 return if !record or scene.characters.first (v) -> !v.disposed and v.rid == record.index and !v.disposed
3082
3083 character = new vn.Object_Character(record, null, scene)
3084 character.expression = RecordManager.characterExpressions[expressionId ? record.defaultExpressionId||0] #character.expression
3085 if character.expression?.idle[0]?.resource.name
3086 bitmap = ResourceManager.getBitmap("Graphics/Characters/#{character.expression.idle[0].resource.name}")
3087
3088 mirror = no
3089 angle = 0
3090 zoom = 1
3091
3092 if @params.positionType == 1
3093 x = @interpreter.numberValueOf(@params.position.x)
3094 y = @interpreter.numberValueOf(@params.position.y)
3095 mirror = @params.position.horizontalFlip
3096 angle = @params.position.angle||0
3097 zoom = @params.position.data?.zoom || 1
3098 else if @params.positionType == 2
3099 x = @interpreter.numberValueOf(@params.position.x)
3100 y = @interpreter.numberValueOf(@params.position.y)
3101 mirror = no
3102 angle = 0
3103 zoom = 1
3104
3105 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut) else gs.Easings.fromObject(defaults.appearEasing)
3106 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.appearDuration
3107 origin = if !isLocked(flags.origin) then @params.origin else defaults.origin
3108 zIndex = if !isLocked(flags.zOrder) then @interpreter.numberValueOf(@params.zOrder) else defaults.zOrder
3109 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.appearAnimation
3110 motionBlur = if !isLocked(flags["motionBlur.enabled"]) then @params.motionBlur else defaults.motionBlur
3111 instant = duration == 0 or @interpreter.isInstantSkip()
3112 noAnim = duration == 0 or GameManager.tempSettings.skip
3113
3114 if @params.waitForCompletion and not instant
3115 @interpreter.isWaiting = yes
3116 @interpreter.waitCounter = duration
3117
3118 if character.expression?.idle[0]?.resource.name
3119 bitmap = ResourceManager.getBitmap("Graphics/Characters/#{character.expression.idle[0].resource.name}")
3120 if @params.origin == 1 and bitmap?
3121 x += (bitmap.width*zoom-bitmap.width)/2
3122 y += (bitmap.height*zoom-bitmap.height)/2
3123
3124 character.mirror = mirror
3125 character.anchor.x = if !origin then 0 else 0.5
3126 character.anchor.y = if !origin then 0 else 0.5
3127 character.zoom.x = zoom
3128 character.zoom.y = zoom
3129 character.dstRect.x = x
3130 character.dstRect.y = y
3131 character.zIndex = zIndex || 200
3132 character.blendMode = @interpreter.numberValueOf(@params.blendMode)
3133 character.angle = angle
3134 character.setup()
3135 character.update()
3136
3137 if @params.positionType == 0
3138 p = @interpreter.predefinedObjectPosition(@params.predefinedPositionId, character, @params)
3139 character.dstRect.x = p.x
3140 character.dstRect.y = p.y
3141
3142 scene.behavior.addCharacter(character, noAnim, { animation: animation, duration: duration, easing: easing, motionBlur: motionBlur})
3143
3144 if @params.viewport?.type == "ui"
3145 character.viewport = Graphics.viewport
3146
3147 gs.GameNotifier.postMinorChange()
3148
3149 ###*
3150 * @method commandCharacterExitScene
3151 * @protected
3152 ###
3153 commandCharacterExitScene: (defaults) ->
3154 defaults = defaults || GameManager.defaults.character
3155 flags = @params.fieldFlags || {}
3156 isLocked = gs.CommandFieldFlags.isLocked
3157 characterId = @interpreter.stringValueOf(@params.characterId)
3158
3159 scene = SceneManager.scene
3160 character = scene.characters.first (v) => !v.disposed and v.rid == characterId
3161
3162 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut) else gs.Easings.fromObject(defaults.disappearEasing)
3163 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.disappearDuration
3164 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.disappearAnimation
3165 instant = duration == 0 or @interpreter.isInstantSkip()
3166 noAnim = duration == 0 or GameManager.tempSettings.skip
3167
3168 if @params.waitForCompletion and not instant
3169 @interpreter.isWaiting = yes
3170 @interpreter.waitCounter = duration
3171
3172 scene.behavior.removeCharacter(character, noAnim, { animation: animation, duration: duration, easing: easing})
3173 gs.GameNotifier.postMinorChange()
3174
3175 ###*
3176 * @method commandCharacterChangeExpression
3177 * @protected
3178 ###
3179 commandCharacterChangeExpression: ->
3180 scene = SceneManager.scene
3181 characterId = @interpreter.stringValueOf(@params.characterId)
3182 character = scene.characters.first (v) => !v.disposed and v.rid == characterId
3183 if not character? then return
3184 defaults = GameManager.defaults.character
3185 flags = @params.fieldFlags || {}
3186 isLocked = gs.CommandFieldFlags.isLocked
3187
3188 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.expressionDuration
3189 expression = RecordManager.characterExpressions[@params.expressionId || 0]
3190 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromObject(@params.easing) else gs.Easings.fromObject(defaults.changeEasing)
3191 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.changeAnimation
3192
3193 character.behavior.changeExpression(expression, @params.animation, easing, duration)
3194
3195 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
3196 @interpreter.isWaiting = yes
3197 @interpreter.waitCounter = duration
3198
3199 gs.GameNotifier.postMinorChange()
3200
3201 ###*
3202 * @method commandCharacterSetParameter
3203 * @protected
3204 ###
3205 commandCharacterSetParameter: ->
3206 params = GameManager.characterParams[@interpreter.stringValueOf(@params.characterId)]
3207 if not params? or not @params.param? then return
3208
3209 switch @params.valueType
3210 when 0 # Number Value
3211 switch @params.param.type
3212 when 0 # Number
3213 params[@params.param.name] = @interpreter.numberValueOf(@params.numberValue)
3214 when 1 # Switch
3215 params[@params.param.name] = @interpreter.numberValueOf(@params.numberValue) > 0
3216 when 2 # Text
3217 params[@params.param.name] = @interpreter.numberValueOf(@params.numberValue).toString()
3218 when 1 # Switch Value
3219 switch @params.param.type
3220 when 0 # Number
3221 value = @interpreter.booleanValueOf(@params.switchValue)
3222 params[@params.param.name] = if value then 1 else 0
3223 when 1 # Switch
3224 params[@params.param.name] = @interpreter.booleanValueOf(@params.switchValue)
3225 when 2 # Text
3226 value = @interpreter.booleanValueOf(@params.switchValue)
3227 params[@params.param.name] = if value then "ON" else "OFF"
3228 when 2 # Text Value
3229 switch @params.param.type
3230 when 0 # Number
3231 value = @interpreter.stringValueOf(@params.textValue)
3232 params[@params.param.name] = value.length
3233 when 1 # Switch
3234 params[@params.param.name] = @interpreter.stringValueOf(@params.textValue) == "ON"
3235 when 2 # Text
3236 params[@params.param.name] = @interpreter.stringValueOf(@params.textValue)
3237
3238
3239
3240
3241 ###*
3242 * @method commandCharacterGetParameter
3243 * @protected
3244 ###
3245 commandCharacterGetParameter: ->
3246 params = GameManager.characterParams[@interpreter.stringValueOf(@params.characterId)]
3247 if not params? or not @params.param? then return
3248
3249 value = params[@params.param.name]
3250
3251 switch @params.valueType
3252 when 0 # Number Value
3253 switch @params.param.type
3254 when 0 # Number
3255 @interpreter.setNumberValueTo(@params.targetVariable, value)
3256 when 1 # Switch
3257 @interpreter.setNumberValueTo(@params.targetVariable, if value then 1 else 0)
3258 when 2 # Text
3259 @interpreter.setNumberValueTo(@params.targetVariable, if value? then value.length else 0)
3260 when 1 # Switch Value
3261 switch @params.param.type
3262 when 0 # Number
3263 @interpreter.setBooleanValueTo(@params.targetVariable, value > 0)
3264 when 1 # Switch
3265 @interpreter.setBooleanValueTo(@params.targetVariable, value)
3266 when 2 # Text
3267 @interpreter.setBooleanValueTo(@params.targetVariable, value == "ON")
3268
3269 when 2 # Text Value
3270 switch @params.param.type
3271 when 0 # Number
3272 @interpreter.setStringValueTo(@params.targetVariable, if value? then value.toString() else "")
3273 when 1 # Switch
3274 @interpreter.setStringValueTo(@params.targetVariable, if value then "ON" else "OFF")
3275 when 2 # Text
3276 @interpreter.setStringValueTo(@params.targetVariable, value)
3277
3278
3279
3280 ###*
3281 * @method commandCharacterMotionBlur
3282 * @protected
3283 ###
3284 commandCharacterMotionBlur: ->
3285 scene = SceneManager.scene
3286 characterId = @interpreter.stringValueOf(@params.characterId)
3287 character = scene.characters.first (v) => !v.disposed and v.rid == characterId
3288 if not character? then return
3289
3290 character.motionBlur.set(@params.motionBlur)
3291
3292 ###*
3293 * @method commandCharacterDefaults
3294 * @protected
3295 ###
3296 commandCharacterDefaults: ->
3297 defaults = GameManager.defaults.character
3298 flags = @params.fieldFlags || {}
3299 isLocked = gs.CommandFieldFlags.isLocked
3300
3301 if !isLocked(flags.appearDuration) then defaults.appearDuration = @interpreter.durationValueOf(@params.appearDuration)
3302 if !isLocked(flags.disappearDuration) then defaults.disappearDuration = @interpreter.durationValueOf(@params.disappearDuration)
3303 if !isLocked(flags.expressionDuration) then defaults.expressionDuration = @interpreter.durationValueOf(@params.expressionDuration)
3304 if !isLocked(flags.zOrder) then defaults.zOrder = @interpreter.numberValueOf(@params.zOrder)
3305 if !isLocked(flags["appearEasing.type"]) then defaults.appearEasing = @params.appearEasing
3306 if !isLocked(flags["appearAnimation.type"]) then defaults.appearAnimation = @params.appearAnimation
3307 if !isLocked(flags["disappearEasing.type"]) then defaults.disappearEasing = @params.disappearEasing
3308 if !isLocked(flags["disappearAnimation.type"]) then defaults.disappearAnimation = @params.disappearAnimation
3309 if !isLocked(flags["motionBlur.enabled"]) then defaults.motionBlur = @params.motionBlur
3310 if !isLocked(flags.origin) then defaults.origin = @params.origin
3311
3312 ###*
3313 * @method commandCharacterEffect
3314 * @protected
3315 ###
3316 commandCharacterEffect: ->
3317 scene = SceneManager.scene
3318 characterId = @interpreter.stringValueOf(@params.characterId)
3319 character = scene.characters.first (c) -> !c.disposed and c.rid == characterId
3320 if not character? then return
3321
3322 @interpreter.objectEffect(character, @params)
3323
3324 gs.GameNotifier.postMinorChange()
3325
3326 ###*
3327 * @method commandFlashCharacter
3328 * @protected
3329 ###
3330 commandFlashCharacter: ->
3331 scene = SceneManager.scene
3332 characterId = @interpreter.stringValueOf(@params.characterId)
3333 character = scene.characters.first (v) => !v.disposed and v.rid == characterId
3334 return if not character
3335
3336 duration = @interpreter.durationValueOf(@params.duration)
3337 character.animator.flash(new Color(@params.color), duration)
3338 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
3339 @interpreter.isWaiting = yes
3340 @interpreter.waitCounter = duration
3341
3342 gs.GameNotifier.postMinorChange()
3343
3344 ###*
3345 * @method commandTintCharacter
3346 * @protected
3347 ###
3348 commandTintCharacter: ->
3349 scene = SceneManager.scene
3350 characterId = @interpreter.stringValueOf(@params.characterId)
3351 character = scene.characters.first (v) => !v.disposed and v.rid == characterId
3352 easing = gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut)
3353 return if not character
3354
3355 duration = @interpreter.durationValueOf(@params.duration)
3356 character.animator.tintTo(@params.tone, duration, easing)
3357 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
3358 @interpreter.isWaiting = yes
3359 @interpreter.waitCounter = duration
3360
3361 gs.GameNotifier.postMinorChange()
3362
3363 ###*
3364 * @method commandZoomCharacter
3365 * @protected
3366 ###
3367 commandZoomCharacter: ->
3368 scene = SceneManager.scene
3369 characterId = @interpreter.stringValueOf(@params.characterId)
3370 character = scene.characters.first (v) => !v.disposed and v.rid == characterId
3371 if not character? then return
3372
3373 @interpreter.zoomObject(character, @params)
3374
3375 gs.GameNotifier.postMinorChange()
3376
3377 ###*
3378 * @method commandRotateCharacter
3379 * @protected
3380 ###
3381 commandRotateCharacter: ->
3382 scene = SceneManager.scene
3383 characterId = @interpreter.stringValueOf(@params.characterId)
3384 character = scene.characters.first (v) => !v.disposed and v.rid == characterId
3385 if not character? then return
3386
3387 @interpreter.rotateObject(character, @params)
3388
3389 gs.GameNotifier.postMinorChange()
3390
3391 ###*
3392 * @method commandBlendCharacter
3393 * @protected
3394 ###
3395 commandBlendCharacter: ->
3396 characterId = @interpreter.stringValueOf(@params.characterId)
3397 character = SceneManager.scene.characters.first (v) => !v.disposed and v.rid == characterId
3398 if not character? then return
3399
3400 @interpreter.blendObject(character, @params)
3401
3402 gs.GameNotifier.postMinorChange()
3403
3404 ###*
3405 * @method commandShakeCharacter
3406 * @protected
3407 ###
3408 commandShakeCharacter: ->
3409 characterId = @interpreter.stringValueOf(@params.characterId)
3410 character = SceneManager.scene.characters.first (v) => !v.disposed and v.rid == characterId
3411 if not character? then return
3412 @interpreter.shakeObject(character, @params)
3413
3414 gs.GameNotifier.postMinorChange()
3415
3416 ###*
3417 * @method commandMaskCharacter
3418 * @protected
3419 ###
3420 commandMaskCharacter: ->
3421 scene = SceneManager.scene
3422 characterId = @interpreter.stringValueOf(@params.characterId)
3423 character = scene.characters.first (v) => !v.disposed and v.rid == characterId
3424 if not character? then return
3425
3426 @interpreter.maskObject(character, @params)
3427
3428 gs.GameNotifier.postMinorChange()
3429
3430 ###*
3431 * @method commandMoveCharacter
3432 * @protected
3433 ###
3434 commandMoveCharacter: ->
3435 scene = SceneManager.scene
3436 characterId = @interpreter.stringValueOf(@params.characterId)
3437 character = scene.characters.first (v) => !v.disposed and v.rid == characterId
3438 if not character? then return
3439
3440 @interpreter.moveObject(character, @params.position, @params)
3441
3442 gs.GameNotifier.postMinorChange()
3443
3444 ###*
3445 * @method commandMoveCharacterPath
3446 * @protected
3447 ###
3448 commandMoveCharacterPath: ->
3449 scene = SceneManager.scene
3450 characterId = @interpreter.stringValueOf(@params.characterId)
3451 character = scene.characters.first (v) => !v.disposed and v.rid == characterId
3452 if not character? then return
3453
3454 @interpreter.moveObjectPath(character, @params.path, @params)
3455
3456 gs.GameNotifier.postMinorChange()
3457
3458 ###*
3459 * @method commandShakeBackground
3460 * @protected
3461 ###
3462 commandShakeBackground: ->
3463 background = SceneManager.scene.backgrounds[@interpreter.numberValueOf(@params.layer)]
3464 if not background? then return
3465
3466 @interpreter.shakeObject(background, @params)
3467
3468 gs.GameNotifier.postMinorChange()
3469
3470 ###*
3471 * @method commandScrollBackground
3472 * @protected
3473 ###
3474 commandScrollBackground: ->
3475 scene = SceneManager.scene
3476 duration = @interpreter.durationValueOf(@params.duration)
3477 horizontalSpeed = @interpreter.numberValueOf(@params.horizontalSpeed)
3478 verticalSpeed = @interpreter.numberValueOf(@params.verticalSpeed)
3479 easing = gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut)
3480 layer = @interpreter.numberValueOf(@params.layer)
3481 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
3482 @interpreter.isWaiting = yes
3483 @interpreter.waitCounter = duration
3484
3485 scene.backgrounds[layer]?.animator.move(horizontalSpeed, verticalSpeed, duration, easing)
3486
3487 gs.GameNotifier.postMinorChange()
3488
3489 ###*
3490 * @method commandScrollBackgroundTo
3491 * @protected
3492 ###
3493 commandScrollBackgroundTo: ->
3494 scene = SceneManager.scene
3495 duration = @interpreter.durationValueOf(@params.duration)
3496 x = @interpreter.numberValueOf(@params.background.location.x)
3497 y = @interpreter.numberValueOf(@params.background.location.y)
3498 easing = gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut)
3499 layer = @interpreter.numberValueOf(@params.layer)
3500 background = scene.backgrounds[layer]
3501 if !background then return
3502
3503 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
3504 @interpreter.isWaiting = yes
3505 @interpreter.waitCounter = duration
3506
3507 if @params.positionType == 0
3508 p = @interpreter.predefinedObjectPosition(@params.predefinedPositionId, background, @params)
3509 x = p.x
3510 y = p.y
3511
3512 background.animator.moveTo(x, y, duration, easing)
3513
3514 gs.GameNotifier.postMinorChange()
3515
3516 ###*
3517 * @method commandScrollBackgroundPath
3518 * @protected
3519 ###
3520 commandScrollBackgroundPath: ->
3521 scene = SceneManager.scene
3522 background = scene.backgrounds[@interpreter.numberValueOf(@params.layer)]
3523 return unless background?
3524
3525 @interpreter.moveObjectPath(background, @params.path, @params)
3526
3527 gs.GameNotifier.postMinorChange()
3528
3529 ###*
3530 * @method commandMaskBackground
3531 * @protected
3532 ###
3533 commandMaskBackground: ->
3534 scene = SceneManager.scene
3535 background = scene.backgrounds[@interpreter.numberValueOf(@params.layer)]
3536 return unless background?
3537
3538 @interpreter.maskObject(background, @params)
3539
3540 gs.GameNotifier.postMinorChange()
3541
3542 ###*
3543 * @method commandZoomBackground
3544 * @protected
3545 ###
3546 commandZoomBackground: ->
3547 scene = SceneManager.scene
3548 duration = @interpreter.durationValueOf(@params.duration)
3549 x = @interpreter.numberValueOf(@params.zooming.x)
3550 y = @interpreter.numberValueOf(@params.zooming.y)
3551 easing = gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut)
3552 layer = @interpreter.numberValueOf(@params.layer)
3553 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
3554 @interpreter.isWaiting = yes
3555 @interpreter.waitCounter = duration
3556
3557 scene.backgrounds[layer]?.animator.zoomTo(x / 100, y / 100, duration, easing)
3558
3559 gs.GameNotifier.postMinorChange()
3560
3561 ###*
3562 * @method commandRotateBackground
3563 * @protected
3564 ###
3565 commandRotateBackground: ->
3566 scene = SceneManager.scene
3567 background = scene.backgrounds[@interpreter.numberValueOf(@params.layer)]
3568
3569 if background
3570 @interpreter.rotateObject(background, @params)
3571
3572 gs.GameNotifier.postMinorChange()
3573
3574 ###*
3575 * @method commandTintBackground
3576 * @protected
3577 ###
3578 commandTintBackground: ->
3579 scene = SceneManager.scene
3580 layer = @interpreter.numberValueOf(@params.layer)
3581 background = scene.backgrounds[layer]
3582 if not background? then return
3583
3584 duration = @interpreter.durationValueOf(@params.duration)
3585 easing = gs.Easings.fromObject(@params.easing)
3586 background.animator.tintTo(@params.tone, duration, easing)
3587
3588 @interpreter.waitForCompletion(background, @params)
3589
3590 gs.GameNotifier.postMinorChange()
3591
3592 ###*
3593 * @method commandBlendBackground
3594 * @protected
3595 ###
3596 commandBlendBackground: ->
3597 layer = @interpreter.numberValueOf(@params.layer)
3598 background = SceneManager.scene.backgrounds[layer]
3599 if not background? then return
3600
3601 @interpreter.blendObject(background, @params)
3602
3603 gs.GameNotifier.postMinorChange()
3604
3605 ###*
3606 * @method commandBackgroundEffect
3607 * @protected
3608 ###
3609 commandBackgroundEffect: ->
3610 layer = @interpreter.numberValueOf(@params.layer)
3611 background = SceneManager.scene.backgrounds[layer]
3612 if not background? then return
3613
3614 @interpreter.objectEffect(background, @params)
3615
3616 gs.GameNotifier.postMinorChange()
3617
3618 ###*
3619 * @method commandBackgroundDefaults
3620 * @protected
3621 ###
3622 commandBackgroundDefaults: ->
3623 defaults = GameManager.defaults.background
3624 flags = @params.fieldFlags || {}
3625 isLocked = gs.CommandFieldFlags.isLocked
3626
3627 if !isLocked(flags.duration) then defaults.duration = @interpreter.durationValueOf(@params.duration)
3628 if !isLocked(flags.zOrder) then defaults.zOrder = @interpreter.numberValueOf(@params.zOrder)
3629 if !isLocked(flags["easing.type"]) then defaults.easing = @params.easing
3630 if !isLocked(flags["animation.type"]) then defaults.animation = @params.animation
3631 if !isLocked(flags.origin) then defaults.origin = @params.origin
3632 if !isLocked(flags.loopHorizontal) then defaults.loopHorizontal = @params.loopHorizontal
3633 if !isLocked(flags.loopVertical) then defaults.loopVertical = @params.loopVertical
3634
3635 ###*
3636 * @method commandBackgroundMotionBlur
3637 * @protected
3638 ###
3639 commandBackgroundMotionBlur: ->
3640 layer = @interpreter.numberValueOf(@params.layer)
3641 background = SceneManager.scene.backgrounds[layer]
3642 if not background? then return
3643
3644 background.motionBlur.set(@params.motionBlur)
3645
3646 ###*
3647 * @method commandChangeBackground
3648 * @protected
3649 ###
3650 commandChangeBackground: ->
3651 defaults = GameManager.defaults.background
3652 scene = SceneManager.scene
3653 flags = @params.fieldFlags || {}
3654 isLocked = gs.CommandFieldFlags.isLocked
3655 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.duration
3656 loopH = if !isLocked(flags.loopHorizontal) then @params.loopHorizontal else defaults.loopHorizontal
3657 loopV = if !isLocked(flags.loopVertical) then @params.loopVertical else defaults.loopVertical
3658 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.animation
3659 origin = if !isLocked(flags.origin) then @params.origin else defaults.origin
3660 zIndex = if !isLocked(flags.zOrder) then @interpreter.numberValueOf(@params.zOrder) else defaults.zOrder
3661
3662 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
3663 @interpreter.isWaiting = yes
3664 @interpreter.waitCounter = duration
3665
3666 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromObject(@params.easing) else gs.Easings.fromObject(defaults.easing)
3667 layer = @interpreter.numberValueOf(@params.layer)
3668 scene.behavior.changeBackground(@params.graphic, no, animation, easing, duration, 0, 0, layer, loopH, loopV)
3669
3670 if scene.backgrounds[layer]
3671 if @params.viewport?.type == "ui"
3672 scene.backgrounds[layer].viewport = Graphics.viewport
3673 scene.backgrounds[layer].anchor.x = if origin == 0 then 0 else 0.5
3674 scene.backgrounds[layer].anchor.y = if origin == 0 then 0 else 0.5
3675 scene.backgrounds[layer].blendMode = @interpreter.numberValueOf(@params.blendMode)
3676 scene.backgrounds[layer].zIndex = zIndex + layer
3677
3678 if origin == 1
3679 scene.backgrounds[layer].dstRect.x = scene.backgrounds[layer].dstRect.x# + scene.backgrounds[layer].bitmap.width/2
3680 scene.backgrounds[layer].dstRect.y = scene.backgrounds[layer].dstRect.y# + scene.backgrounds[layer].bitmap.height/2
3681 scene.backgrounds[layer].setup()
3682 scene.backgrounds[layer].update()
3683
3684 gs.GameNotifier.postMinorChange()
3685
3686 ###*
3687 * @method commandCallScene
3688 * @protected
3689 ###
3690 commandCallScene: ->
3691 @interpreter.callScene(@interpreter.stringValueOf(@params.scene.uid || @params.scene))
3692
3693 ###*
3694 * @method commandChangeScene
3695 * @protected
3696 ###
3697 commandChangeScene: ->
3698 if GameManager.inLivePreview then return
3699 GameManager.tempSettings.skip = no
3700
3701 if !@params.savePrevious
3702 SceneManager.clear()
3703
3704 scene = SceneManager.scene
3705 if !@params.erasePictures and !@params.savePrevious
3706 scene.removeObject(scene.pictureContainer)
3707 for picture in scene.pictures
3708 ResourceManager.context.remove("Graphics/Pictures/#{picture.image}") if picture
3709 if !@params.eraseTexts and !@params.savePrevious
3710 scene.removeObject(scene.textContainer)
3711 # if !@params.eraseMessageAreas and !@params.savePrevious
3712 # scene.removeObject(scene.messageAreaContainer)
3713 # if !@params.eraseHotspots and !@params.savePrevious
3714 # scene.removeObject(scene.hotspotContainer)
3715 if !@params.eraseVideos and !@params.savePrevious
3716 scene.removeObject(scene.videoContainer)
3717 for video in scene.videos
3718 ResourceManager.context.remove("Movies/#{video.video}") if video
3719
3720 if @params.scene
3721 if @params.savePrevious
3722 GameManager.sceneData = uid: uid = @params.scene.uid, pictures: [], texts: [], videos: []
3723 else
3724 GameManager.sceneData = {
3725 uid: uid = @params.scene.uid,
3726 pictures: scene.pictureContainer.subObjectsByDomain,
3727 texts: scene.textContainer.subObjectsByDomain,
3728 videos: scene.videoContainer.subObjectsByDomain
3729 # messageAreas: scene.messageAreaContainer.subObjectsByDomain,
3730 # hotspots: scene.hotspotContainer.subObjectsByDomain
3731 }
3732 flags = @params.fieldFlags || {}
3733 isLocked = gs.CommandFieldFlags.isLocked
3734 newScene = new vn.Object_Scene()
3735 if @params.savePrevious
3736 newScene.sceneData = uid: uid = @params.scene.uid, pictures: [], texts: [], videos: [], backlog: GameManager.backlog
3737 else
3738 newScene.sceneData = uid: uid = @params.scene.uid, pictures: scene.pictureContainer.subObjectsByDomain, texts: scene.textContainer.subObjectsByDomain, videos: scene.videoContainer.subObjectsByDomain
3739
3740 SceneManager.switchTo(newScene, @params.savePrevious, => @interpreter.isWaiting = no)
3741 else
3742 SceneManager.switchTo(null)
3743
3744 @interpreter.isWaiting = yes
3745
3746 ###*
3747 * @method commandReturnToPreviousScene
3748 * @protected
3749 ###
3750 commandReturnToPreviousScene: ->
3751 if GameManager.inLivePreview then return
3752 SceneManager.returnToPrevious(=> @interpreter.isWaiting = no)
3753
3754 @interpreter.isWaiting = yes
3755
3756
3757 ###*
3758 * @method commandSwitchToLayout
3759 * @protected
3760 ###
3761 commandSwitchToLayout: ->
3762 if GameManager.inLivePreview then return
3763 if ui.UIManager.layouts[@params.layout.name]?
3764 scene = new gs.Object_Layout(@params.layout.name)
3765 SceneManager.switchTo(scene, @params.savePrevious, => @interpreter.isWaiting = no)
3766 @interpreter.isWaiting = yes
3767
3768 ###*
3769 * @method commandChangeTransition
3770 * @protected
3771 ###
3772 commandChangeTransition: ->
3773 flags = @params.fieldFlags || {}
3774 isLocked = gs.CommandFieldFlags.isLocked
3775
3776 if !isLocked(flags.duration)
3777 SceneManager.transitionData.duration = @interpreter.durationValueOf(@params.duration)
3778 if !isLocked(flags.graphic)
3779 SceneManager.transitionData.graphic = @params.graphic
3780 if !isLocked(flags.vague)
3781 SceneManager.transitionData.vague = @params.vague
3782
3783 ###*
3784 * @method commandFreezeScreen
3785 * @protected
3786 ###
3787 commandFreezeScreen: ->
3788 Graphics.freeze()
3789
3790 ###*
3791 * @method commandScreenTransition
3792 * @protected
3793 ###
3794 commandScreenTransition: ->
3795 defaults = GameManager.defaults.scene
3796 flags = @params.fieldFlags || {}
3797 isLocked = gs.CommandFieldFlags.isLocked
3798 graphicName = if !isLocked(flags.graphic) then @params.graphic?.name else SceneManager.transitionData.graphic?.name
3799
3800 if graphicName
3801 bitmap = if !isLocked(flags.graphic) then ResourceManager.getBitmap("Graphics/Masks/#{graphicName}") else ResourceManager.getBitmap("Graphics/Masks/#{graphicName}")
3802 vague = if !isLocked(flags.vague) then @interpreter.numberValueOf(@params.vague) else SceneManager.transitionData.vague
3803 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else SceneManager.transitionData.duration
3804
3805 @interpreter.isWaiting = !GameManager.inLivePreview
3806 @interpreter.waitCounter = duration
3807
3808
3809 Graphics.transition(duration, bitmap, vague)
3810
3811 ###*
3812 * @method commandShakeScreen
3813 * @protected
3814 ###
3815 commandShakeScreen: ->
3816 if not SceneManager.scene.viewport? then return
3817
3818 @interpreter.shakeObject(SceneManager.scene.viewport, @params)
3819 gs.GameNotifier.postMinorChange()
3820
3821
3822 ###*
3823 * @method commandTintScreen
3824 * @protected
3825 ###
3826 commandTintScreen: ->
3827 duration = @interpreter.durationValueOf(@params.duration)
3828 SceneManager.scene.viewport.animator.tintTo(new Tone(@params.tone), duration, gs.Easings.EASE_LINEAR[0])
3829
3830 if @params.waitForCompletion and duration > 0
3831 @interpreter.isWaiting = yes
3832 @interpreter.waitCounter = duration
3833 gs.GameNotifier.postMinorChange()
3834
3835 ###*
3836 * @method commandZoomScreen
3837 * @protected
3838 ###
3839 commandZoomScreen: ->
3840 easing = gs.Easings.fromObject(@params.easing)
3841 duration = @interpreter.durationValueOf(@params.duration)
3842 scene = SceneManager.scene
3843
3844 SceneManager.scene.viewport.anchor.x = 0.5
3845 SceneManager.scene.viewport.anchor.y = 0.5
3846 SceneManager.scene.viewport.animator.zoomTo(@interpreter.numberValueOf(@params.zooming.x) / 100, @interpreter.numberValueOf(@params.zooming.y) / 100, duration, easing)
3847
3848 @interpreter.waitForCompletion(null, @params)
3849 gs.GameNotifier.postMinorChange()
3850
3851 ###*
3852 * @method commandPanScreen
3853 * @protected
3854 ###
3855 commandPanScreen: ->
3856 scene = SceneManager.scene
3857 duration = @interpreter.durationValueOf(@params.duration)
3858 easing = gs.Easings.fromObject(@params.easing)
3859 @interpreter.settings.screen.pan.x -= @params.position.x
3860 @interpreter.settings.screen.pan.y -= @params.position.y
3861 viewport = SceneManager.scene.viewport
3862
3863 viewport.animator.scrollTo(-@params.position.x + viewport.dstRect.x, -@params.position.y + viewport.dstRect.y, duration, easing)
3864 @interpreter.waitForCompletion(null, @params)
3865 gs.GameNotifier.postMinorChange()
3866
3867 ###*
3868 * @method commandRotateScreen
3869 * @protected
3870 ###
3871 commandRotateScreen: ->
3872 scene = SceneManager.scene
3873
3874 easing = gs.Easings.fromObject(@params.easing)
3875 duration = @interpreter.durationValueOf(@params.duration)
3876 pan = @interpreter.settings.screen.pan
3877
3878 SceneManager.scene.viewport.anchor.x = 0.5
3879 SceneManager.scene.viewport.anchor.y = 0.5
3880 SceneManager.scene.viewport.animator.rotate(@params.direction, @interpreter.numberValueOf(@params.speed) / 100, duration, easing)
3881
3882 @interpreter.waitForCompletion(null, @params)
3883 gs.GameNotifier.postMinorChange()
3884
3885 ###*
3886 * @method commandFlashScreen
3887 * @protected
3888 ###
3889 commandFlashScreen: ->
3890 duration = @interpreter.durationValueOf(@params.duration)
3891 SceneManager.scene.viewport.animator.flash(new Color(@params.color), duration, gs.Easings.EASE_LINEAR[0])
3892
3893 if @params.waitForCompletion and duration != 0
3894 @interpreter.isWaiting = yes
3895 @interpreter.waitCounter = duration
3896 gs.GameNotifier.postMinorChange()
3897
3898
3899 ###*
3900 * @method commandScreenEffect
3901 * @protected
3902 ###
3903 commandScreenEffect: ->
3904 scene = SceneManager.scene
3905 flags = @params.fieldFlags || {}
3906 isLocked = gs.CommandFieldFlags.isLocked
3907 duration = @interpreter.durationValueOf(@params.duration)
3908 easing = gs.Easings.fromObject(@params.easing)
3909
3910 if !gs.CommandFieldFlags.isLocked(flags.zOrder)
3911 zOrder = @interpreter.numberValueOf(@params.zOrder)
3912 else
3913 zOrder = SceneManager.scene.viewport.zIndex
3914
3915 viewport = scene.viewportContainer.subObjects.first (v) -> v.zIndex == zOrder
3916
3917 if !viewport
3918 viewport = new gs.Object_Viewport()
3919 viewport.zIndex = zOrder
3920 scene.viewportContainer.addObject(viewport)
3921
3922 switch @params.type
3923 when 0 # Wobble
3924 viewport.animator.wobbleTo(@params.wobble.power / 10000, @params.wobble.speed / 100, duration, easing)
3925 wobble = viewport.effects.wobble
3926 wobble.enabled = @params.wobble.power > 0
3927 wobble.vertical = @params.wobble.orientation == 0 or @params.wobble.orientation == 2
3928 wobble.horizontal = @params.wobble.orientation == 1 or @params.wobble.orientation == 2
3929 when 1 # Blur
3930 viewport.animator.blurTo(@params.blur.power / 100, duration, easing)
3931 viewport.effects.blur.enabled = yes
3932 when 2 # Pixelate
3933 viewport.animator.pixelateTo(@params.pixelate.size.width, @params.pixelate.size.height, duration, easing)
3934 viewport.effects.pixelate.enabled = yes
3935
3936 if @params.waitForCompletion and duration != 0
3937 @interpreter.isWaiting = yes
3938 @interpreter.waitCounter = duration
3939 gs.GameNotifier.postMinorChange()
3940
3941 ###*
3942 * @method commandVideoDefaults
3943 * @protected
3944 ###
3945 commandVideoDefaults: ->
3946 defaults = GameManager.defaults.video
3947 flags = @params.fieldFlags || {}
3948 isLocked = gs.CommandFieldFlags.isLocked
3949
3950 if !isLocked(flags.appearDuration) then defaults.appearDuration = @interpreter.durationValueOf(@params.appearDuration)
3951 if !isLocked(flags.disappearDuration) then defaults.disappearDuration = @interpreter.durationValueOf(@params.disappearDuration)
3952 if !isLocked(flags.zOrder) then defaults.zOrder = @interpreter.numberValueOf(@params.zOrder)
3953 if !isLocked(flags["appearEasing.type"]) then defaults.appearEasing = @params.appearEasing
3954 if !isLocked(flags["appearAnimation.type"]) then defaults.appearAnimation = @params.appearAnimation
3955 if !isLocked(flags["disappearEasing.type"]) then defaults.disappearEasing = @params.disappearEasing
3956 if !isLocked(flags["disappearAnimation.type"]) then defaults.disappearAnimation = @params.disappearAnimation
3957 if !isLocked(flags["motionBlur.enabled"]) then defaults.motionBlur = @params.motionBlur
3958 if !isLocked(flags.origin) then defaults.origin = @params.origin
3959
3960
3961 ###*
3962 * @method commandShowVideo
3963 * @protected
3964 ###
3965 commandShowVideo: ->
3966 defaults = GameManager.defaults.video
3967 flags = @params.fieldFlags || {}
3968 isLocked = gs.CommandFieldFlags.isLocked
3969 scene = SceneManager.scene
3970 scene.behavior.changeVideoDomain(@params.numberDomain)
3971 number = @interpreter.numberValueOf(@params.number)
3972 videos = scene.videos
3973 if not videos[number]? then videos[number] = new gs.Object_Video()
3974
3975 x = @interpreter.numberValueOf(@params.position.x)
3976 y = @interpreter.numberValueOf(@params.position.y)
3977
3978 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut) else gs.Easings.fromObject(defaults.appearEasing)
3979 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.appearDuration
3980 origin = if !isLocked(flags.origin) then @params.origin else defaults.origin
3981 zIndex = if !isLocked(flags.zOrder) then @interpreter.numberValueOf(@params.zOrder) else defaults.zOrder
3982 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.appearAnimation
3983
3984 video = videos[number]
3985 video.domain = @params.numberDomain
3986 video.video = @params.video?.name
3987 video.loop = @params.loop ? yes
3988 video.dstRect.x = x
3989 video.dstRect.y = y
3990 video.blendMode = @interpreter.numberValueOf(@params.blendMode)
3991 video.anchor.x = if origin == 0 then 0 else 0.5
3992 video.anchor.y = if origin == 0 then 0 else 0.5
3993 video.zIndex = zIndex || (1000 + number)
3994 if @params.viewport?.type == "scene"
3995 video.viewport = SceneManager.scene.behavior.viewport
3996 video.update()
3997
3998 if @params.positionType == 0
3999 p = @interpreter.predefinedObjectPosition(@params.predefinedPositionId, video, @params)
4000 video.dstRect.x = p.x
4001 video.dstRect.y = p.y
4002
4003 video.animator.appear(x, y, animation, easing, duration)
4004
4005 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
4006 @interpreter.isWaiting = yes
4007 @interpreter.waitCounter = duration
4008 gs.GameNotifier.postMinorChange()
4009
4010 ###*
4011 * @method commandMoveVideo
4012 * @protected
4013 ###
4014 commandMoveVideo: ->
4015 scene = SceneManager.scene
4016 scene.behavior.changeVideoDomain(@params.numberDomain)
4017 number = @interpreter.numberValueOf(@params.number)
4018 video = scene.videos[number]
4019 if not video? then return
4020
4021 @interpreter.moveObject(video, @params.picture.position, @params)
4022
4023 gs.GameNotifier.postMinorChange()
4024
4025 ###*
4026 * @method commandMoveVideoPath
4027 * @protected
4028 ###
4029 commandMoveVideoPath: ->
4030 scene = SceneManager.scene
4031 scene.behavior.changeVideoDomain(@params.numberDomain)
4032 number = @interpreter.numberValueOf(@params.number)
4033 video = scene.videos[number]
4034 if not video? then return
4035
4036 @interpreter.moveObjectPath(video, @params)
4037
4038 gs.GameNotifier.postMinorChange()
4039
4040 ###*
4041 * @method commandRotateVideo
4042 * @protected
4043 ###
4044 commandRotateVideo: ->
4045 scene = SceneManager.scene
4046 scene.behavior.changeVideoDomain(@params.numberDomain)
4047 number = @interpreter.numberValueOf(@params.number)
4048 video = scene.videos[number]
4049 if not video? then return
4050
4051 @interpreter.rotateObject(video, @params)
4052
4053 gs.GameNotifier.postMinorChange()
4054
4055 ###*
4056 * @method commandZoomVideo
4057 * @protected
4058 ###
4059 commandZoomVideo: ->
4060 scene = SceneManager.scene
4061 scene.behavior.changeVideoDomain(@params.numberDomain)
4062 number = @interpreter.numberValueOf(@params.number)
4063 video = scene.videos[number]
4064 if not video? then return
4065
4066 @interpreter.zoomObject(video, @params)
4067
4068 gs.GameNotifier.postMinorChange()
4069
4070 ###*
4071 * @method commandBlendVideo
4072 * @protected
4073 ###
4074 commandBlendVideo: ->
4075 SceneManager.scene.behavior.changeVideoDomain(@params.numberDomain)
4076 video = SceneManager.scene.videos[@interpreter.numberValueOf(@params.number)]
4077 if not video? then return
4078
4079 @interpreter.blendObject(video, @params)
4080
4081 gs.GameNotifier.postMinorChange()
4082
4083 ###*
4084 * @method commandTintVideo
4085 * @protected
4086 ###
4087 commandTintVideo: ->
4088 scene = SceneManager.scene
4089 scene.behavior.changeVideoDomain(@params.numberDomain)
4090 number = @interpreter.numberValueOf(@params.number)
4091 video = scene.videos[number]
4092 if not video? then return
4093
4094 @interpreter.tintObject(video, @params)
4095
4096 gs.GameNotifier.postMinorChange()
4097
4098 ###*
4099 * @method commandFlashVideo
4100 * @protected
4101 ###
4102 commandFlashVideo: ->
4103 scene = SceneManager.scene
4104 scene.behavior.changeVideoDomain(@params.numberDomain)
4105 number = @interpreter.numberValueOf(@params.number)
4106 video = scene.videos[number]
4107 if not video? then return
4108
4109 @interpreter.flashObject(video, @params)
4110
4111 gs.GameNotifier.postMinorChange()
4112
4113 ###*
4114 * @method commandCropVideo
4115 * @protected
4116 ###
4117 commandCropVideo: ->
4118 scene = SceneManager.scene
4119 scene.behavior.changeVideoDomain(@params.numberDomain)
4120 number = @interpreter.numberValueOf(@params.number)
4121 video = scene.videos[number]
4122 if not video? then return
4123
4124 @interpreter.cropObject(video, @params)
4125
4126
4127 ###*
4128 * @method commandVideoMotionBlur
4129 * @protected
4130 ###
4131 commandVideoMotionBlur: ->
4132 scene = SceneManager.scene
4133 scene.behavior.changeVideoDomain(@params.numberDomain)
4134 number = @interpreter.numberValueOf(@params.number)
4135 video = scene.videos[number]
4136 if not video? then return
4137
4138 @interpreter.objectMotionBlur(video, @params)
4139
4140 ###*
4141 * @method commandMaskVideo
4142 * @protected
4143 ###
4144 commandMaskVideo: ->
4145 scene = SceneManager.scene
4146 scene.behavior.changeVideoDomain(@params.numberDomain)
4147 number = @interpreter.numberValueOf(@params.number)
4148 video = scene.videos[number]
4149 if not video? then return
4150
4151 @interpreter.maskObject(video, @params)
4152
4153 gs.GameNotifier.postMinorChange()
4154
4155 ###*
4156 * @method commandVideoEffect
4157 * @protected
4158 ###
4159 commandVideoEffect: ->
4160 scene = SceneManager.scene
4161 scene.behavior.changeVideoDomain(@params.numberDomain)
4162 number = @interpreter.numberValueOf(@params.number)
4163 video = scene.videos[number]
4164 if not video? then return
4165
4166 @interpreter.objectEffect(video, @params)
4167 gs.GameNotifier.postMinorChange()
4168
4169 ###*
4170 * @method commandEraseVideo
4171 * @protected
4172 ###
4173 commandEraseVideo: ->
4174 defaults = GameManager.defaults.video
4175 flags = @params.fieldFlags || {}
4176 isLocked = gs.CommandFieldFlags.isLocked
4177 scene = SceneManager.scene
4178 scene.behavior.changeVideoDomain(@params.numberDomain)
4179 number = @interpreter.numberValueOf(@params.number)
4180 video = scene.videos[number]
4181 if not video? then return
4182
4183 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut) else gs.Easings.fromObject(defaults.disappearEasing)
4184 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.disappearDuration
4185 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.disappearAnimation
4186
4187 video.animator.disappear(animation, easing, duration, (sender) =>
4188 sender.dispose()
4189 scene.behavior.changeTextDomain(sender.domain)
4190 scene.videos[number] = null
4191 # sender.video.pause()
4192 )
4193
4194 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
4195 @interpreter.isWaiting = yes
4196 @interpreter.waitCounter = duration
4197 gs.GameNotifier.postMinorChange()
4198
4199 ###*
4200 * @method commandShowImageMap
4201 * @protected
4202 ###
4203 commandShowImageMap: ->
4204 flags = @params.fieldFlags || {}
4205 isLocked = gs.CommandFieldFlags.isLocked
4206 SceneManager.scene.behavior.changePictureDomain(@params.numberDomain)
4207 number = @interpreter.numberValueOf(@params.number)
4208 imageMap = SceneManager.scene.pictures[number]
4209 if imageMap?
4210 imageMap.dispose()
4211 imageMap = new gs.Object_ImageMap()
4212 imageMap.visual.variableContext = @interpreter.context
4213 SceneManager.scene.pictures[number] = imageMap
4214 bitmap = ResourceManager.getBitmap("Graphics/Pictures/#{@params.ground?.name}")
4215
4216 imageMap.dstRect.width = bitmap.width
4217 imageMap.dstRect.height = bitmap.height
4218
4219 if @params.positionType == 0
4220 p = @interpreter.predefinedObjectPosition(@params.predefinedPositionId, imageMap, @params)
4221 imageMap.dstRect.x = p.x
4222 imageMap.dstRect.y = p.y
4223 else
4224 imageMap.dstRect.x = @interpreter.numberValueOf(@params.position.x)
4225 imageMap.dstRect.y = @interpreter.numberValueOf(@params.position.y)
4226
4227 imageMap.anchor.x = if @params.origin == 1 then 0.5 else 0
4228 imageMap.anchor.y = if @params.origin == 1 then 0.5 else 0
4229 imageMap.zIndex = if !isLocked(flags.zOrder) then @interpreter.numberValueOf(@params.zOrder) else (700 + number)
4230 imageMap.blendMode = if !isLocked(flags.blendMode) then @params.blendMode else 0
4231 imageMap.hotspots = @params.hotspots
4232 imageMap.images = [
4233 @params.ground?.name,
4234 @params.hover?.name,
4235 @params.unselected?.name,
4236 @params.selected?.name,
4237 @params.selectedHover?.name
4238 ]
4239
4240 imageMap.events.on "jumpTo", gs.CallBack("onJumpTo", @interpreter)
4241 imageMap.events.on "callCommonEvent", gs.CallBack("onCallCommonEvent", @interpreter)
4242
4243 imageMap.setup()
4244 imageMap.update()
4245
4246 @interpreter.showObject(imageMap, {x:0, y:0}, @params)
4247
4248 if @params.waitForCompletion
4249 @interpreter.waitCounter = 0
4250 @interpreter.isWaiting = yes
4251
4252 imageMap.events.on "finish", (sender) =>
4253 @interpreter.isWaiting = no
4254 # @interpreter.eraseObject(scene.imageMap, @params)
4255 gs.GameNotifier.postMinorChange()
4256
4257 ###*
4258 * @method commandEraseImageMap
4259 * @protected
4260 ###
4261 commandEraseImageMap: ->
4262 scene = SceneManager.scene
4263 scene.behavior.changePictureDomain(@params.numberDomain)
4264 number = @interpreter.numberValueOf(@params.number)
4265 imageMap = scene.pictures[number]
4266 if not imageMap? then return
4267
4268 imageMap.events.emit("finish", imageMap)
4269 imageMap.visual.active = no
4270 @interpreter.eraseObject(imageMap, @params, (sender) =>
4271 scene.behavior.changePictureDomain(sender.domain)
4272 scene.pictures[number] = null
4273 )
4274 gs.GameNotifier.postMinorChange()
4275
4276 ###*
4277 * @method commandAddHotspot
4278 * @protected
4279 ###
4280 commandAddHotspot: ->
4281 scene = SceneManager.scene
4282 scene.behavior.changeHotspotDomain(@params.numberDomain)
4283 number = @interpreter.numberValueOf(@params.number)
4284 hotspots = scene.hotspots
4285
4286 if not hotspots[number]?
4287 hotspots[number] = new gs.Object_Hotspot()
4288
4289 hotspot = hotspots[number]
4290 hotspot.domain = @params.numberDomain
4291 hotspot.data = { params: @params, bindValue: @interpreter.numberValueOf(@params.actions.onDrag.bindValue) }
4292
4293 switch @params.positionType
4294 when 0 # Direct
4295 hotspot.dstRect.x = @params.box.x
4296 hotspot.dstRect.y = @params.box.y
4297 hotspot.dstRect.width = @params.box.size.width
4298 hotspot.dstRect.height = @params.box.size.height
4299 when 1 # Calculated
4300 hotspot.dstRect.x = @interpreter.numberValueOf(@params.box.x)
4301 hotspot.dstRect.y = @interpreter.numberValueOf(@params.box.y)
4302 hotspot.dstRect.width = @interpreter.numberValueOf(@params.box.size.width)
4303 hotspot.dstRect.height = @interpreter.numberValueOf(@params.box.size.height)
4304 when 2 # Bind to Picture
4305 picture = scene.pictures[@interpreter.numberValueOf(@params.pictureNumber)]
4306 if picture?
4307 hotspot.target = picture
4308 when 3 # Bind to Text
4309 text = scene.texts[@interpreter.numberValueOf(@params.textNumber)]
4310 if text?
4311 hotspot.target = text
4312
4313 hotspot.behavior.shape = @params.shape ? gs.HotspotShape.RECTANGLE
4314
4315 if text?
4316 hotspot.images = null
4317 else
4318 hotspot.images = [
4319 @params.baseGraphic?.name || @interpreter.stringValueOf(@params.baseGraphic) || picture?.image,
4320 @params.hoverGraphic?.name || @interpreter.stringValueOf(@params.hoverGraphic),
4321 @params.selectedGraphic?.name || @interpreter.stringValueOf(@params.selectedGraphic),
4322 @params.selectedHoverGraphic?.name || @interpreter.stringValueOf(@params.selectedHoverGraphic),
4323 @params.unselectedGraphic?.name || @interpreter.stringValueOf(@params.unselectedGraphic)
4324 ]
4325
4326
4327 if @params.actions.onClick.type != 0 or @params.actions.onClick.label
4328 hotspot.events.on "click", gs.CallBack("onHotspotClick", @interpreter, { params: @params, bindValue: @interpreter.numberValueOf(@params.actions.onClick.bindValue) })
4329 if @params.actions.onEnter.type != 0 or @params.actions.onEnter.label
4330 hotspot.events.on "enter", gs.CallBack("onHotspotEnter", @interpreter, { params: @params, bindValue: @interpreter.numberValueOf(@params.actions.onEnter.bindValue) })
4331 if @params.actions.onLeave.type != 0 or @params.actions.onLeave.label
4332 hotspot.events.on "leave", gs.CallBack("onHotspotLeave", @interpreter, { params: @params, bindValue: @interpreter.numberValueOf(@params.actions.onLeave.bindValue) })
4333 if @params.actions.onDrag.type != 0 or @params.actions.onDrag.label
4334 hotspot.events.on "dragStart", gs.CallBack("onHotspotDragStart", @interpreter, { params: @params, bindValue: @interpreter.numberValueOf(@params.actions.onDrag.bindValue) })
4335 hotspot.events.on "drag", gs.CallBack("onHotspotDrag", @interpreter, { params: @params, bindValue: @interpreter.numberValueOf(@params.actions.onDrag.bindValue) })
4336 hotspot.events.on "dragEnd", gs.CallBack("onHotspotDragEnd", @interpreter, { params: @params, bindValue: @interpreter.numberValueOf(@params.actions.onDrag.bindValue) })
4337 if @params.actions.onSelect.type != 0 or @params.actions.onSelect.label or
4338 @params.actions.onDeselect.type != 0 or @params.actions.onDeselect.label
4339 hotspot.events.on "stateChanged", gs.CallBack("onHotspotStateChanged", @interpreter, @params)
4340 if @params.dragging.enabled
4341 hotspot.events.on "dragEnd", gs.CallBack("onHotspotDrop", @interpreter, { params: @params, bindValue: @interpreter.numberValueOf(@params.actions.onDrag.bindValue) })
4342 if @params.actions.onDropReceive.type != 0 or @params.actions.onDropReceive.label
4343 hotspot.events.on "dropReceived", gs.CallBack("onHotspotDropReceived", @interpreter, { params: @params, bindValue: @interpreter.numberValueOf(@params.actions.onDrag.bindValue) })
4344
4345 hotspot.selectable = yes
4346
4347
4348 if @params.dragging.enabled
4349 dragging = @params.dragging
4350 hotspot.draggable = {
4351 rect: new Rect(dragging.rect.x, dragging.rect.y, dragging.rect.size.width, dragging.rect.size.height),
4352 axisX: dragging.horizontal,
4353 axisY: dragging.vertical
4354 }
4355 hotspot.addComponent(new ui.Component_Draggable())
4356 hotspot.events.on "drag", (e) =>
4357 drag = e.sender.draggable
4358 GameManager.variableStore.setupTempVariables(@interpreter.context)
4359 if @params.dragging.horizontal
4360 @interpreter.setNumberValueTo(@params.dragging.variable, Math.round((e.sender.dstRect.x-drag.rect.x) / (drag.rect.width-e.sender.dstRect.width) * 100))
4361 else
4362 @interpreter.setNumberValueTo(@params.dragging.variable, Math.round((e.sender.dstRect.y-drag.rect.y) / (drag.rect.height-e.sender.dstRect.height) * 100))
4363
4364 hotspot.setup()
4365 ###*
4366 * @method commandChangeHotspotState
4367 * @protected
4368 ###
4369 commandChangeHotspotState: ->
4370 flags = @params.fieldFlags || {}
4371 isLocked = gs.CommandFieldFlags.isLocked
4372 scene = SceneManager.scene
4373 scene.behavior.changeHotspotDomain(@params.numberDomain)
4374 number = @interpreter.numberValueOf(@params.number)
4375 hotspot = scene.hotspots[number]
4376 return if !hotspot
4377
4378 if !isLocked(flags.selected) then hotspot.behavior.selected = @interpreter.booleanValueOf(@params.selected)
4379 if !isLocked(flags.enabled) then hotspot.behavior.enabled = @interpreter.booleanValueOf(@params.enabled)
4380
4381 hotspot.behavior.updateInput()
4382 hotspot.behavior.updateImage()
4383
4384 ###*
4385 * @method commandEraseHotspot
4386 * @protected
4387 ###
4388 commandEraseHotspot: ->
4389 scene = SceneManager.scene
4390 scene.behavior.changeHotspotDomain(@params.numberDomain)
4391 number = @interpreter.numberValueOf(@params.number)
4392
4393 if scene.hotspots[number]?
4394 scene.hotspots[number].dispose()
4395 scene.hotspotContainer.eraseObject(number)
4396
4397 ###*
4398 * @method commandChangeObjectDomain
4399 * @protected
4400 ###
4401 commandChangeObjectDomain: ->
4402 SceneManager.scene.behavior.changeObjectDomain(@interpreter.stringValueOf(@params.domain))
4403
4404 ###*
4405 * @method commandPictureDefaults
4406 * @protected
4407 ###
4408 commandPictureDefaults: ->
4409 defaults = GameManager.defaults.picture
4410 flags = @params.fieldFlags || {}
4411 isLocked = gs.CommandFieldFlags.isLocked
4412
4413 if !isLocked(flags.appearDuration) then defaults.appearDuration = @interpreter.durationValueOf(@params.appearDuration)
4414 if !isLocked(flags.disappearDuration) then defaults.disappearDuration = @interpreter.durationValueOf(@params.disappearDuration)
4415 if !isLocked(flags.zOrder) then defaults.zOrder = @interpreter.numberValueOf(@params.zOrder)
4416 if !isLocked(flags["appearEasing.type"]) then defaults.appearEasing = @params.appearEasing
4417 if !isLocked(flags["appearAnimation.type"]) then defaults.appearAnimation = @params.appearAnimation
4418 if !isLocked(flags["disappearEasing.type"]) then defaults.disappearEasing = @params.disappearEasing
4419 if !isLocked(flags["disappearAnimation.type"]) then defaults.disappearAnimation = @params.disappearAnimation
4420 if !isLocked(flags["motionBlur.enabled"]) then defaults.motionBlur = @params.motionBlur
4421 if !isLocked(flags.origin) then defaults.origin = @params.origin
4422
4423
4424 createPicture: (graphic, params) ->
4425 graphic = @stringValueOf(graphic)
4426 graphicName = if graphic?.name? then graphic.name else graphic
4427 bitmap = ResourceManager.getBitmap("Graphics/Pictures/#{graphicName}")
4428 return null if bitmap && !bitmap.loaded
4429
4430 defaults = GameManager.defaults.picture
4431 flags = params.fieldFlags || {}
4432 isLocked = gs.CommandFieldFlags.isLocked
4433 scene = SceneManager.scene
4434 number = @numberValueOf(params.number)
4435 pictures = scene.pictures
4436 picture = pictures[number]
4437 if not picture?
4438 picture = new gs.Object_Picture(null, null, params.visual?.type)
4439 picture.domain = params.numberDomain
4440 pictures[number] = picture
4441 switch params.visual?.type
4442 when 1
4443 picture.visual.looping.vertical = yes
4444 picture.visual.looping.horizontal = yes
4445 when 2
4446 picture.frameThickness = params.visual.frame.thickness
4447 picture.frameCornerSize = params.visual.frame.cornerSize
4448 when 3
4449 picture.visual.orientation = params.visual.threePartImage.orientation
4450 when 4
4451 picture.color = gs.Color.fromObject(params.visual.quad.color)
4452 when 5
4453 snapshot = Graphics.snapshot()
4454 #ResourceManager.addCustomBitmap(snapshot)
4455 picture.bitmap = snapshot
4456 picture.dstRect.width = snapshot.width
4457 picture.dstRect.height = snapshot.height
4458 picture.srcRect.set(0, 0, snapshot.width, snapshot.height)
4459 else
4460 picture.bitmap = null
4461
4462
4463 x = @numberValueOf(params.position.x)
4464 y = @numberValueOf(params.position.y)
4465 picture = pictures[number]
4466
4467 if !picture.bitmap
4468 picture.image = graphicName
4469 else
4470 picture.image = null
4471
4472 bitmap = picture.bitmap ? ResourceManager.getBitmap("Graphics/Pictures/#{graphicName}")
4473 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromValues(@numberValueOf(params.easing.type), params.easing.inOut) else gs.Easings.fromObject(defaults.appearEasing)
4474 duration = if !isLocked(flags.duration) then @durationValueOf(params.duration) else defaults.appearDuration
4475 origin = if !isLocked(flags.origin) then params.origin else defaults.origin
4476 zIndex = if !isLocked(flags.zOrder) then @numberValueOf(params.zOrder) else defaults.zOrder
4477 animation = if !isLocked(flags["animation.type"]) then params.animation else defaults.appearAnimation
4478
4479 picture.mirror = params.position.horizontalFlip
4480 picture.angle = params.position.angle || 0
4481 picture.zoom.x = (params.position.data?.zoom||1)
4482 picture.zoom.y = (params.position.data?.zoom||1)
4483 picture.blendMode = @numberValueOf(params.blendMode)
4484
4485 if params.origin == 1 and bitmap?
4486 x += (bitmap.width*picture.zoom.x-bitmap.width)/2
4487 y += (bitmap.height*picture.zoom.y-bitmap.height)/2
4488
4489 picture.dstRect.x = x
4490 picture.dstRect.y = y
4491 picture.anchor.x = if origin == 1 then 0.5 else 0
4492 picture.anchor.y = if origin == 1 then 0.5 else 0
4493 picture.zIndex = zIndex || (700 + number)
4494
4495 if params.viewport?.type == "scene"
4496 picture.viewport = SceneManager.scene.behavior.viewport
4497
4498 if params.size?.type == 1
4499 picture.dstRect.width = @numberValueOf(params.size.width)
4500 picture.dstRect.height = @numberValueOf(params.size.height)
4501
4502 picture.update()
4503
4504 return picture
4505 ###*
4506 * @method commandShowPicture
4507 * @protected
4508 ###
4509 commandShowPicture: ->
4510 SceneManager.scene.behavior.changePictureDomain(@params.numberDomain || "")
4511 defaults = GameManager.defaults.picture
4512 flags = @params.fieldFlags || {}
4513 isLocked = gs.CommandFieldFlags.isLocked
4514 picture = @interpreter.createPicture(@params.graphic, @params)
4515 if !picture
4516 @interpreter.pointer--
4517 @interpreter.isWaiting = yes
4518 @interpreter.waitCounter = 1
4519 return
4520
4521 if @params.positionType == 0
4522 p = @interpreter.predefinedObjectPosition(@params.predefinedPositionId, picture, @params)
4523 picture.dstRect.x = p.x
4524 picture.dstRect.y = p.y
4525
4526 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut) else gs.Easings.fromObject(defaults.appearEasing)
4527 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.appearDuration
4528 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.appearAnimation
4529
4530 picture.animator.appear(picture.dstRect.x, picture.dstRect.y, animation, easing, duration)
4531
4532 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
4533 @interpreter.isWaiting = yes
4534 @interpreter.waitCounter = duration
4535
4536 gs.GameNotifier.postMinorChange()
4537
4538 ###*
4539 * @method commandPlayPictureAnimation
4540 * @protected
4541 ###
4542 commandPlayPictureAnimation: ->
4543 SceneManager.scene.behavior.changePictureDomain(@params.numberDomain || "")
4544
4545 defaults = GameManager.defaults.picture
4546 flags = @params.fieldFlags || {}
4547 isLocked = gs.CommandFieldFlags.isLocked
4548 picture = null
4549
4550 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut) else gs.Easings.fromObject(defaults.appearEasing)
4551 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.appearDuration
4552 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.appearAnimation
4553
4554 if @params.animationId?
4555 record = RecordManager.animations[@params.animationId]
4556 if record?
4557 picture = @interpreter.createPicture(record.graphic, @params)
4558
4559 component = picture.findComponent("Component_FrameAnimation")
4560 if component?
4561 component.refresh(record)
4562 component.start()
4563 else
4564 component = new gs.Component_FrameAnimation(record)
4565 picture.addComponent(component)
4566
4567 component.update()
4568
4569 if @params.positionType == 0
4570 p = @interpreter.predefinedObjectPosition(@params.predefinedPositionId, picture, @params)
4571 picture.dstRect.x = p.x
4572 picture.dstRect.y = p.y
4573
4574 picture.animator.appear(picture.dstRect.x, picture.dstRect.y, animation, easing, duration)
4575
4576 else
4577 picture = SceneManager.scene.pictures[@interpreter.numberValueOf(@params.number)]
4578 animation = picture?.findComponent("Component_FrameAnimation")
4579
4580 if animation?
4581 picture.removeComponent(animation)
4582 bitmap = ResourceManager.getBitmap("Graphics/Animations/#{picture.image}")
4583 if bitmap?
4584 picture.srcRect.set(0, 0, bitmap.width, bitmap.height)
4585 picture.dstRect.width = picture.srcRect.width
4586 picture.dstRect.height = picture.srcRect.height
4587
4588 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
4589 @interpreter.isWaiting = yes
4590 @interpreter.waitCounter = duration
4591
4592 gs.GameNotifier.postMinorChange()
4593
4594 ###*
4595 * @method commandMovePicturePath
4596 * @protected
4597 ###
4598 commandMovePicturePath: ->
4599 scene = SceneManager.scene
4600 scene.behavior.changePictureDomain(@params.numberDomain)
4601 number = @interpreter.numberValueOf(@params.number)
4602 picture = scene.pictures[number]
4603 if not picture? then return
4604
4605 @interpreter.moveObjectPath(picture, @params.path, @params)
4606
4607 gs.GameNotifier.postMinorChange()
4608
4609 ###*
4610 * @method commandMovePicture
4611 * @protected
4612 ###
4613 commandMovePicture: ->
4614 scene = SceneManager.scene
4615 scene.behavior.changePictureDomain(@params.numberDomain)
4616 number = @interpreter.numberValueOf(@params.number)
4617 picture = scene.pictures[number]
4618 if not picture? then return
4619
4620 @interpreter.moveObject(picture, @params.picture.position, @params)
4621
4622 gs.GameNotifier.postMinorChange()
4623
4624
4625 ###*
4626 * @method commandTintPicture
4627 * @protected
4628 ###
4629 commandTintPicture: ->
4630 scene = SceneManager.scene
4631 scene.behavior.changePictureDomain(@params.numberDomain || "")
4632 number = @interpreter.numberValueOf(@params.number)
4633 picture = scene.pictures[number]
4634 if not picture? then return
4635
4636 @interpreter.tintObject(picture, @params)
4637
4638 gs.GameNotifier.postMinorChange()
4639
4640 ###*
4641 * @method commandFlashPicture
4642 * @protected
4643 ###
4644 commandFlashPicture: ->
4645 scene = SceneManager.scene
4646 scene.behavior.changePictureDomain(@params.numberDomain || "")
4647 number = @interpreter.numberValueOf(@params.number)
4648 picture = scene.pictures[number]
4649 if not picture? then return
4650
4651 @interpreter.flashObject(picture, @params)
4652
4653 gs.GameNotifier.postMinorChange()
4654
4655 ###*
4656 * @method commandCropPicture
4657 * @protected
4658 ###
4659 commandCropPicture: ->
4660 scene = SceneManager.scene
4661 scene.behavior.changePictureDomain(@params.numberDomain || "")
4662 number = @interpreter.numberValueOf(@params.number)
4663 picture = scene.pictures[number]
4664 if not picture? then return
4665
4666 @interpreter.cropObject(picture, @params)
4667
4668 ###*
4669 * @method commandRotatePicture
4670 * @protected
4671 ###
4672 commandRotatePicture: ->
4673 scene = SceneManager.scene
4674 scene.behavior.changePictureDomain(@params.numberDomain || "")
4675 number = @interpreter.numberValueOf(@params.number)
4676 picture = scene.pictures[number]
4677 if not picture? then return
4678
4679 @interpreter.rotateObject(picture, @params)
4680
4681 gs.GameNotifier.postMinorChange()
4682
4683 ###*
4684 * @method commandZoomPicture
4685 * @protected
4686 ###
4687 commandZoomPicture: ->
4688 scene = SceneManager.scene
4689 scene.behavior.changePictureDomain(@params.numberDomain || "")
4690 number = @interpreter.numberValueOf(@params.number)
4691 picture = scene.pictures[number]
4692 if not picture? then return
4693
4694 @interpreter.zoomObject(picture, @params)
4695
4696 gs.GameNotifier.postMinorChange()
4697
4698 ###*
4699 * @method commandBlendPicture
4700 * @protected
4701 ###
4702 commandBlendPicture: ->
4703 SceneManager.scene.behavior.changePictureDomain(@params.numberDomain || "")
4704 picture = SceneManager.scene.pictures[@interpreter.numberValueOf(@params.number)]
4705 if not picture? then return
4706
4707 @interpreter.blendObject(picture, @params)
4708 gs.GameNotifier.postMinorChange()
4709
4710 ###*
4711 * @method commandShakePicture
4712 * @protected
4713 ###
4714 commandShakePicture: ->
4715 picture = SceneManager.scene.pictures[@interpreter.numberValueOf(@params.number)]
4716 if not picture? then return
4717
4718 @interpreter.shakeObject(picture, @params)
4719 gs.GameNotifier.postMinorChange()
4720
4721 ###*
4722 * @method commandMaskPicture
4723 * @protected
4724 ###
4725 commandMaskPicture: ->
4726 scene = SceneManager.scene
4727 scene.behavior.changePictureDomain(@params.numberDomain || "")
4728 number = @interpreter.numberValueOf(@params.number)
4729 picture = scene.pictures[number]
4730 if not picture? then return
4731
4732 @interpreter.maskObject(picture, @params)
4733 gs.GameNotifier.postMinorChange()
4734
4735
4736 ###*
4737 * @method commandPictureMotionBlur
4738 * @protected
4739 ###
4740 commandPictureMotionBlur: ->
4741 scene = SceneManager.scene
4742 scene.behavior.changePictureDomain(@params.numberDomain || "")
4743 number = @interpreter.numberValueOf(@params.number)
4744 picture = scene.pictures[number]
4745 if not picture? then return
4746
4747 @interpreter.objectMotionBlur(picture, @params)
4748
4749 gs.GameNotifier.postMinorChange()
4750
4751 ###*
4752 * @method commandPictureEffect
4753 * @protected
4754 ###
4755 commandPictureEffect: ->
4756 scene = SceneManager.scene
4757 scene.behavior.changePictureDomain(@params.numberDomain || "")
4758 number = @interpreter.numberValueOf(@params.number)
4759 picture = scene.pictures[number]
4760 if not picture? then return
4761
4762 @interpreter.objectEffect(picture, @params)
4763 gs.GameNotifier.postMinorChange()
4764
4765 ###*
4766 * @method commandErasePicture
4767 * @protected
4768 ###
4769 commandErasePicture: ->
4770 defaults = GameManager.defaults.picture
4771 flags = @params.fieldFlags || {}
4772 isLocked = gs.CommandFieldFlags.isLocked
4773
4774 scene = SceneManager.scene
4775 scene.behavior.changePictureDomain(@params.numberDomain || "")
4776 number = @interpreter.numberValueOf(@params.number)
4777 picture = scene.pictures[number]
4778 if not picture? then return
4779
4780 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut) else gs.Easings.fromObject(defaults.disappearEasing)
4781 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.disappearDuration
4782 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.disappearAnimation
4783
4784 picture.animator.disappear(animation, easing, duration,
4785 (sender) =>
4786 sender.dispose()
4787 scene.behavior.changePictureDomain(sender.domain)
4788 scene.pictures[number] = null
4789 )
4790
4791 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
4792 @interpreter.isWaiting = yes
4793 @interpreter.waitCounter = duration
4794
4795 gs.GameNotifier.postMinorChange()
4796
4797
4798 ###*
4799 * @method commandInputNumber
4800 * @protected
4801 ###
4802 commandInputNumber: ->
4803 scene = SceneManager.scene
4804 @interpreter.isWaiting = yes
4805 if @interpreter.isProcessingMessageInOtherContext()
4806 @interpreter.waitForMessage()
4807 return
4808
4809 if (GameManager.settings.allowChoiceSkip||@interpreter.preview) and GameManager.tempSettings.skip
4810 @interpreter.isWaiting = no
4811 @interpreter.messageObject().behavior.clear()
4812 @interpreter.setNumberValueTo(@params.variable, 0)
4813 return
4814
4815 $tempFields.digits = @params.digits
4816 scene.behavior.showInputNumber(@params.digits, gs.CallBack("onInputNumberFinish", @interpreter, @params))
4817
4818 @interpreter.waitingFor.inputNumber = @params
4819 gs.GameNotifier.postMinorChange()
4820
4821 ###*
4822 * @method commandChoiceTimer
4823 * @protected
4824 ###
4825 commandChoiceTimer: ->
4826 scene = SceneManager.scene
4827
4828 GameManager.tempFields.choiceTimer = scene.choiceTimer
4829 GameManager.tempFields.choiceTimerVisible = @params.visible
4830
4831 if @params.enabled
4832 scene.choiceTimer.behavior.seconds = @interpreter.numberValueOf(@params.seconds)
4833 scene.choiceTimer.behavior.minutes = @interpreter.numberValueOf(@params.minutes)
4834 scene.choiceTimer.behavior.start()
4835 scene.choiceTimer.events.on "finish", (sender) =>
4836 if scene.choiceWindow and scene.choices?.length > 0
4837 defaultChoice = (scene.choices.first (c) -> c.isDefault) || scene.choices[0]
4838 #scene.choiceWindow.events.emit("selectionAccept", scene.choiceWindow, { labelIndex: defaultChoice.action.labelIndex })
4839 scene.choiceWindow.events.emit("selectionAccept", scene.choiceWindow, defaultChoice)
4840 else
4841 scene.choiceTimer.stop()
4842
4843 ###*
4844 * @method commandShowChoices
4845 * @protected
4846 ###
4847 commandShowChoices: ->
4848 scene = SceneManager.scene
4849 pointer = @interpreter.pointer
4850 choices = scene.choices || []
4851
4852 if (GameManager.settings.allowChoiceSkip||@interpreter.previewData) and GameManager.tempSettings.skip
4853 messageObject = @interpreter.messageObject()
4854 if messageObject?.visible
4855 messageObject.behavior.clear()
4856 defaultChoice = (choices.first((c) -> c.isDefault)) || choices[0]
4857 if defaultChoice.action.labelIndex?
4858 @interpreter.pointer = defaultChoice.action.labelIndex
4859 else
4860 @interpreter.jumpToLabel(defaultChoice.action.label)
4861 scene.choices = []
4862 else
4863 if choices.length > 0
4864 @interpreter.isWaiting = yes
4865 scene.behavior.showChoices(gs.CallBack("onChoiceAccept", @interpreter, { pointer: pointer, params: @params }))
4866
4867 gs.GameNotifier.postMinorChange()
4868
4869 ###*
4870 * @method commandShowChoice
4871 * @protected
4872 ###
4873 commandShowChoice: ->
4874 scene = SceneManager.scene
4875 commands = @interpreter.object.commands
4876 command = null
4877 index = 0
4878 pointer = @interpreter.pointer
4879 choices = null
4880 dstRect = null
4881
4882 switch @params.positionType
4883 when 0 # Auto
4884 dstRect = null
4885 when 1 # Direct
4886 dstRect = new Rect(@params.box.x, @params.box.y, @params.box.size.width, @params.box.size.height)
4887
4888 if !scene.choices
4889 scene.choices = []
4890 choices = scene.choices
4891 choices.push({
4892 dstRect: dstRect,
4893 #text: lcs(@params.text),
4894 text: @params.text,
4895 index: index,
4896 action: @params.action,
4897 isSelected: no,
4898 isDefault: @params.defaultChoice,
4899 isEnabled: @interpreter.booleanValueOf(@params.enabled) })
4900
4901 ###*
4902 * @method commandOpenMenu
4903 * @protected
4904 ###
4905 commandOpenMenu: ->
4906 SceneManager.switchTo(new gs.Object_Layout("menuLayout"), true)
4907 @interpreter.waitCounter = 1
4908 @interpreter.isWaiting = yes
4909
4910 ###*
4911 * @method commandOpenLoadMenu
4912 * @protected
4913 ###
4914 commandOpenLoadMenu: ->
4915 SceneManager.switchTo(new gs.Object_Layout("loadMenuLayout"), true)
4916 @interpreter.waitCounter = 1
4917 @interpreter.isWaiting = yes
4918
4919 ###*
4920 * @method commandOpenSaveMenu
4921 * @protected
4922 ###
4923 commandOpenSaveMenu: ->
4924 SceneManager.switchTo(new gs.Object_Layout("saveMenuLayout"), true)
4925 @interpreter.waitCounter = 1
4926 @interpreter.isWaiting = yes
4927
4928 ###*
4929 * @method commandReturnToTitle
4930 * @protected
4931 ###
4932 commandReturnToTitle: ->
4933 SceneManager.clear()
4934 SceneManager.switchTo(new gs.Object_Layout("titleLayout"))
4935 @interpreter.waitCounter = 1
4936 @interpreter.isWaiting = yes
4937
4938
4939 ###*
4940 * @method commandPlayVideo
4941 * @protected
4942 ###
4943 commandPlayVideo: ->
4944 if (GameManager.inLivePreview or GameManager.settings.allowVideoSkip) and GameManager.tempSettings.skip then return
4945
4946 GameManager.tempSettings.skip = no
4947 scene = SceneManager.scene
4948
4949 if @params.video?.name?
4950 scene.video = ResourceManager.getVideo("Movies/#{@params.video.name}")
4951
4952 @videoSprite = new Sprite(Graphics.viewport)
4953 @videoSprite.srcRect = new Rect(0, 0, scene.video.width, scene.video.height)
4954 @videoSprite.video = scene.video
4955 @videoSprite.zoomX = Graphics.width / scene.video.width
4956 @videoSprite.zoomY = Graphics.height / scene.video.height
4957 @videoSprite.z = 99999999
4958 scene.video.onEnded = =>
4959 @interpreter.isWaiting = no
4960 @videoSprite.dispose()
4961 scene.video = null
4962 scene.video.volume = @params.volume / 100
4963 scene.video.playbackRate = @params.playbackRate / 100
4964 @interpreter.isWaiting = yes
4965 scene.video.play()
4966 gs.GameNotifier.postMinorChange()
4967 ###*
4968 * @method commandAudioDefaults
4969 * @protected
4970 ###
4971 commandAudioDefaults: ->
4972 defaults = GameManager.defaults.audio
4973 flags = @params.fieldFlags || {}
4974 isLocked = gs.CommandFieldFlags.isLocked
4975
4976 if !isLocked(flags.musicFadeInDuration) then defaults.musicFadeInDuration = @params.musicFadeInDuration
4977 if !isLocked(flags.musicFadeOutDuration) then defaults.musicFadeOutDuration = @params.musicFadeOutDuration
4978 if !isLocked(flags.musicVolume) then defaults.musicVolume = @params.musicVolume
4979 if !isLocked(flags.musicPlaybackRate) then defaults.musicPlaybackRate = @params.musicPlaybackRate
4980 if !isLocked(flags.soundVolume) then defaults.soundVolume = @params.soundVolume
4981 if !isLocked(flags.soundPlaybackRate) then defaults.soundPlaybackRate = @params.soundPlaybackRate
4982 if !isLocked(flags.voiceVolume) then defaults.voiceVolume = @params.voiceVolume
4983 if !isLocked(flags.voicePlaybackRate) then defaults.voicePlaybackRate = @params.voicePlaybackRate
4984
4985 ###*
4986 * @method commandPlayMusic
4987 * @protected
4988 ###
4989 commandPlayMusic: ->
4990 if not @params.music? then return
4991 defaults = GameManager.defaults.audio
4992 flags = @params.fieldFlags || {}
4993 isLocked = gs.CommandFieldFlags.isLocked
4994 music = null
4995
4996 if GameManager.settings.bgmEnabled
4997 fadeDuration = if !isLocked(flags.fadeInDuration) then @params.fadeInDuration else defaults.musicFadeInDuration
4998 volume = if !isLocked(flags["music.volume"]) then @params.music.volume else defaults.musicVolume
4999 playbackRate = if !isLocked(flags["music.playbackRate"]) then @params.music.playbackRate else defaults.musicPlaybackRate
5000 music = { name: @params.music.name, volume: volume, playbackRate: playbackRate }
5001 if @params.playType == 1
5002 playTime = min: @params.playTime.min * 60, max: @params.playTime.max * 60
5003 playRange = start: @params.playRange.start * 60, end: @params.playRange.end * 60
5004 AudioManager.playMusicRandom(music, fadeDuration, @params.layer || 0, playTime, playRange)
5005 else
5006 music = AudioManager.playMusic(@params.music.name, volume, playbackRate, fadeDuration, @params.layer || 0, @params.loop)
5007
5008 if music and @params.waitForCompletion and !@params.loop
5009 @interpreter.isWaiting = yes
5010 @interpreter.waitCounter = Math.round(music.duration * Graphics.frameRate)
5011
5012 gs.GameNotifier.postMinorChange()
5013 ###*
5014 * @method commandStopMusic
5015 * @protected
5016 ###
5017 commandStopMusic: ->
5018 defaults = GameManager.defaults.audio
5019 flags = @params.fieldFlags || {}
5020 isLocked = gs.CommandFieldFlags.isLocked
5021 fadeDuration = if !isLocked(flags.fadeOutDuration) then @params.fadeOutDuration else defaults.musicFadeOutDuration
5022
5023 AudioManager.stopMusic(fadeDuration, @interpreter.numberValueOf(@params.layer))
5024
5025 gs.GameNotifier.postMinorChange()
5026 ###*
5027 * @method commandPauseMusic
5028 * @protected
5029 ###
5030 commandPauseMusic: ->
5031 defaults = GameManager.defaults.audio
5032 flags = @params.fieldFlags || {}
5033 isLocked = gs.CommandFieldFlags.isLocked
5034 fadeDuration = if !isLocked(flags.fadeOutDuration) then @params.fadeOutDuration else defaults.musicFadeOutDuration
5035
5036 AudioManager.stopMusic(fadeDuration, @interpreter.numberValueOf(@params.layer))
5037
5038 ###*
5039 * @method commandResumeMusic
5040 * @protected
5041 ###
5042 commandResumeMusic: ->
5043 defaults = GameManager.defaults.audio
5044 flags = @params.fieldFlags || {}
5045 isLocked = gs.CommandFieldFlags.isLocked
5046 fadeDuration = if !isLocked(flags.fadeInDuration) then @params.fadeInDuration else defaults.musicFadeInDuration
5047
5048 AudioManager.resumeMusic(fadeDuration, @interpreter.numberValueOf(@params.layer))
5049 gs.GameNotifier.postMinorChange()
5050 ###*
5051 * @method commandPlaySound
5052 * @protected
5053 ###
5054 commandPlaySound: ->
5055 defaults = GameManager.defaults.audio
5056 flags = @params.fieldFlags || {}
5057 isLocked = gs.CommandFieldFlags.isLocked
5058 sound = null
5059 if GameManager.settings.soundEnabled and !GameManager.tempSettings.skip
5060 volume = if !isLocked(flags["sound.volume"]) then @params.sound.volume else defaults.soundVolume
5061 playbackRate = if !isLocked(flags["sound.playbackRate"]) then @params.sound.playbackRate else defaults.soundPlaybackRate
5062
5063 sound = AudioManager.playSound(@params.sound.name, volume, playbackRate, @params.musicEffect, null, @params.loop)
5064 gs.GameNotifier.postMinorChange()
5065 if sound and @params.waitForCompletion and !@params.loop
5066 @interpreter.isWaiting = yes
5067 @interpreter.waitCounter = Math.round(sound.duration * Graphics.frameRate)
5068 ###*
5069 * @method commandStopSound
5070 * @protected
5071 ###
5072 commandStopSound: ->
5073 AudioManager.stopSound(@params.sound.name)
5074 gs.GameNotifier.postMinorChange()
5075 ###*
5076 * @method commandEndCommonEvent
5077 * @protected
5078 ###
5079 commandEndCommonEvent: ->
5080 eventId = @interpreter.stringValueOf(@params.commonEventId)
5081 event = GameManager.commonEvents[eventId]
5082 event?.behavior.stop()
5083
5084 ###*
5085 * @method commandResumeCommonEvent
5086 * @protected
5087 ###
5088 commandResumeCommonEvent: ->
5089 eventId = @interpreter.stringValueOf(@params.commonEventId)
5090 event = GameManager.commonEvents[eventId]
5091 event?.behavior.resume()
5092
5093 ###*
5094 * @method commandCallCommonEvent
5095 * @protected
5096 ###
5097 commandCallCommonEvent: ->
5098 scene = SceneManager.scene
5099 eventId = null
5100
5101 if @params.commonEventId.index?
5102 eventId = @interpreter.stringValueOf(@params.commonEventId)
5103 list = @interpreter.listObjectOf(@params.parameters.values[0])
5104 params = { values: list }
5105 else
5106 params = @params.parameters
5107 eventId = @params.commonEventId
5108
5109 @interpreter.callCommonEvent(eventId, params)
5110
5111
5112 ###*
5113 * @method commandChangeTextSettings
5114 * @protected
5115 ###
5116 commandChangeTextSettings: ->
5117 scene = SceneManager.scene
5118 scene.behavior.changeTextDomain(@params.numberDomain)
5119 number = @interpreter.numberValueOf(@params.number)
5120 texts = scene.texts
5121 if not texts[number]?
5122 texts[number] = new gs.Object_Text()
5123 texts[number].visible = no
5124
5125
5126 textSprite = texts[number]
5127 padding = textSprite.behavior.padding
5128 font = textSprite.font
5129 fontName = textSprite.font.name
5130 fontSize = textSprite.font.size
5131 flags = @params.fieldFlags || {}
5132 isLocked = gs.CommandFieldFlags.isLocked
5133 if !isLocked(flags.lineSpacing) then textSprite.textRenderer.lineSpacing = @params.lineSpacing ? textSprite.textRenderer.lineSpacing
5134 if !isLocked(flags.font) then fontName = @interpreter.stringValueOf(@params.font)
5135 if !isLocked(flags.size) then fontSize = @interpreter.numberValueOf(@params.size)
5136
5137 if !isLocked(flags.font) or !isLocked(flags.size)
5138 textSprite.font = new Font(fontName, fontSize)
5139
5140 padding.left = if !isLocked(flags["padding.0"]) then @params.padding?[0] else padding.left
5141 padding.top = if !isLocked(flags["padding.1"]) then @params.padding?[1] else padding.top
5142 padding.right = if !isLocked(flags["padding.2"]) then @params.padding?[2] else padding.right
5143 padding.bottom = if !isLocked(flags["padding.3"]) then @params.padding?[3] else padding.bottom
5144
5145 if !isLocked(flags.bold)
5146 textSprite.font.bold = @params.bold
5147 if !isLocked(flags.italic)
5148 textSprite.font.italic = @params.italic
5149 if !isLocked(flags.smallCaps)
5150 textSprite.font.smallCaps = @params.smallCaps
5151 if !isLocked(flags.underline)
5152 textSprite.font.underline = @params.underline
5153 if !isLocked(flags.strikeThrough)
5154 textSprite.font.strikeThrough = @params.strikeThrough
5155
5156 textSprite.font.color = if !isLocked(flags.color) then new Color(@params.color) else font.color
5157 textSprite.font.border = if !isLocked(flags.outline)then @params.outline else font.border
5158 textSprite.font.borderColor = if !isLocked(flags.outlineColor) then new Color(@params.outlineColor) else new Color(font.borderColor)
5159 textSprite.font.borderSize = if !isLocked(flags.outlineSize) then @params.outlineSize else font.borderSize
5160 textSprite.font.shadow = if !isLocked(flags.shadow)then @params.shadow else font.shadow
5161 textSprite.font.shadowColor = if !isLocked(flags.shadowColor) then new Color(@params.shadowColor) else new Color(font.shadowColor)
5162 textSprite.font.shadowOffsetX = if !isLocked(flags.shadowOffsetX) then @params.shadowOffsetX else font.shadowOffsetX
5163 textSprite.font.shadowOffsetY = if !isLocked(flags.shadowOffsetY) then @params.shadowOffsetY else font.shadowOffsetY
5164 textSprite.behavior.refresh()
5165 textSprite.update()
5166
5167 ###*
5168 * @method commandChangeTextSettings
5169 * @protected
5170 ###
5171 commandTextDefaults: ->
5172 defaults = GameManager.defaults.text
5173 flags = @params.fieldFlags || {}
5174 isLocked = gs.CommandFieldFlags.isLocked
5175
5176 if !isLocked(flags.appearDuration) then defaults.appearDuration = @interpreter.durationValueOf(@params.appearDuration)
5177 if !isLocked(flags.disappearDuration) then defaults.disappearDuration = @interpreter.durationValueOf(@params.disappearDuration)
5178 if !isLocked(flags.zOrder) then defaults.zOrder = @interpreter.numberValueOf(@params.zOrder)
5179 if !isLocked(flags["appearEasing.type"]) then defaults.appearEasing = @params.appearEasing
5180 if !isLocked(flags["appearAnimation.type"]) then defaults.appearAnimation = @params.appearAnimation
5181 if !isLocked(flags["disappearEasing.type"]) then defaults.disappearEasing = @params.disappearEasing
5182 if !isLocked(flags["disappearAnimation.type"]) then defaults.disappearAnimation = @params.disappearAnimation
5183 if !isLocked(flags["motionBlur.enabled"]) then defaults.motionBlur = @params.motionBlur
5184 if !isLocked(flags.origin) then defaults.origin = @params.origin
5185
5186 ###*
5187 * @method commandShowText
5188 * @protected
5189 ###
5190 commandShowText: ->
5191 defaults = GameManager.defaults.text
5192 flags = @params.fieldFlags || {}
5193 isLocked = gs.CommandFieldFlags.isLocked
5194 scene = SceneManager.scene
5195 scene.behavior.changeTextDomain(@params.numberDomain)
5196 number = @interpreter.numberValueOf(@params.number)
5197 text = @params.text
5198 texts = scene.texts
5199 if not texts[number]? then texts[number] = new gs.Object_Text()
5200
5201 x = @interpreter.numberValueOf(@params.position.x)
5202 y = @interpreter.numberValueOf(@params.position.y)
5203 textObject = texts[number]
5204 textObject.domain = @params.numberDomain
5205
5206 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut) else gs.Easings.fromObject(defaults.appearEasing)
5207 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.appearDuration
5208 origin = if !isLocked(flags.origin) then @params.origin else defaults.origin
5209 zIndex = if !isLocked(flags.zOrder) then @interpreter.numberValueOf(@params.zOrder) else defaults.zOrder
5210 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.appearAnimation
5211 positionAnchor = if !isLocked(flags.positionOrigin) then @interpreter.graphicAnchorPointsByConstant[@params.positionOrigin] || new gs.Point(0, 0) else @interpreter.graphicAnchorPointsByConstant[defaults.positionOrigin]
5212
5213 textObject.text = text
5214 textObject.dstRect.x = x
5215 textObject.dstRect.y = y
5216 textObject.blendMode = @interpreter.numberValueOf(@params.blendMode)
5217 textObject.anchor.x = if origin == 0 then 0 else 0.5
5218 textObject.anchor.y = if origin == 0 then 0 else 0.5
5219 textObject.positionAnchor.x = positionAnchor.x
5220 textObject.positionAnchor.y = positionAnchor.y
5221 textObject.zIndex = zIndex || (700 + number)
5222 textObject.sizeToFit = yes
5223 textObject.formatting = yes
5224 if @params.viewport?.type == "scene"
5225 textObject.viewport = SceneManager.scene.behavior.viewport
5226 textObject.update()
5227
5228 if @params.positionType == 0
5229 p = @interpreter.predefinedObjectPosition(@params.predefinedPositionId, textObject, @params)
5230 textObject.dstRect.x = p.x
5231 textObject.dstRect.y = p.y
5232
5233 textObject.animator.appear(x, y, animation, easing, duration)
5234
5235 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
5236 @interpreter.isWaiting = yes
5237 @interpreter.waitCounter = duration
5238
5239 gs.GameNotifier.postMinorChange()
5240 ###*
5241 * @method commandTextMotionBlur
5242 * @protected
5243 ###
5244 commandTextMotionBlur: ->
5245 scene = SceneManager.scene
5246 scene.behavior.changeTextDomain(@params.numberDomain)
5247 number = @interpreter.numberValueOf(@params.number)
5248 text = scene.texts[number]
5249 if not text? then return
5250
5251 text.motionBlur.set(@params.motionBlur)
5252
5253 ###*
5254 * @method commandRefreshText
5255 * @protected
5256 ###
5257 commandRefreshText: ->
5258 scene = SceneManager.scene
5259 scene.behavior.changeTextDomain(@params.numberDomain)
5260 number = @interpreter.numberValueOf(@params.number)
5261 texts = scene.texts
5262 if not texts[number]? then return
5263
5264 texts[number].behavior.refresh(yes)
5265
5266 ###*
5267 * @method commandMoveText
5268 * @protected
5269 ###
5270 commandMoveText: ->
5271 scene = SceneManager.scene
5272 scene.behavior.changeTextDomain(@params.numberDomain)
5273 number = @interpreter.numberValueOf(@params.number)
5274 text = scene.texts[number]
5275 if not text? then return
5276
5277 @interpreter.moveObject(text, @params.picture.position, @params)
5278
5279 gs.GameNotifier.postMinorChange()
5280 ###*
5281 * @method commandMoveTextPath
5282 * @protected
5283 ###
5284 commandMoveTextPath: ->
5285 scene = SceneManager.scene
5286 scene.behavior.changeTextDomain(@params.numberDomain)
5287 number = @interpreter.numberValueOf(@params.number)
5288 text = scene.texts[number]
5289 if not text? then return
5290
5291 @interpreter.moveObjectPath(text, @params.path, @params)
5292
5293 gs.GameNotifier.postMinorChange()
5294 ###*
5295 * @method commandRotateText
5296 * @protected
5297 ###
5298 commandRotateText: ->
5299 scene = SceneManager.scene
5300 scene.behavior.changeTextDomain(@params.numberDomain)
5301 number = @interpreter.numberValueOf(@params.number)
5302 text = scene.texts[number]
5303 if not text? then return
5304
5305 @interpreter.rotateObject(text, @params)
5306
5307 gs.GameNotifier.postMinorChange()
5308 ###*
5309 * @method commandZoomText
5310 * @protected
5311 ###
5312 commandZoomText: ->
5313 scene = SceneManager.scene
5314 scene.behavior.changeTextDomain(@params.numberDomain)
5315 number = @interpreter.numberValueOf(@params.number)
5316 text = scene.texts[number]
5317 if not text? then return
5318
5319 @interpreter.zoomObject(text, @params)
5320
5321 gs.GameNotifier.postMinorChange()
5322
5323 ###*
5324 * @method commandBlendText
5325 * @protected
5326 ###
5327 commandBlendText: ->
5328 SceneManager.scene.behavior.changeTextDomain(@params.numberDomain)
5329 text = SceneManager.scene.texts[@interpreter.numberValueOf(@params.number)]
5330 if not text? then return
5331
5332 @interpreter.blendObject(text, @params)
5333 gs.GameNotifier.postMinorChange()
5334 ###*
5335 * @method commandColorText
5336 * @protected
5337 ###
5338 commandColorText: ->
5339 scene = SceneManager.scene
5340 scene.behavior.changeTextDomain(@params.numberDomain)
5341 number = @interpreter.numberValueOf(@params.number)
5342 text = scene.texts[number]
5343 duration = @interpreter.durationValueOf(@params.duration)
5344 easing = gs.Easings.fromObject(@params.easing)
5345
5346 if text?
5347 text.animator.colorTo(new Color(@params.color), duration, easing)
5348 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
5349 @interpreter.isWaiting = yes
5350 @interpreter.waitCounter = duration
5351 gs.GameNotifier.postMinorChange()
5352 ###*
5353 * @method commandEraseText
5354 * @protected
5355 ###
5356 commandEraseText: ->
5357 defaults = GameManager.defaults.text
5358 flags = @params.fieldFlags || {}
5359 isLocked = gs.CommandFieldFlags.isLocked
5360 scene = SceneManager.scene
5361 scene.behavior.changeTextDomain(@params.numberDomain)
5362 number = @interpreter.numberValueOf(@params.number)
5363 text = scene.texts[number]
5364 if not text? then return
5365
5366 easing = if !isLocked(flags["easing.type"]) then gs.Easings.fromValues(@interpreter.numberValueOf(@params.easing.type), @params.easing.inOut) else gs.Easings.fromObject(defaults.disappearEasing)
5367 duration = if !isLocked(flags.duration) then @interpreter.durationValueOf(@params.duration) else defaults.disappearDuration
5368 animation = if !isLocked(flags["animation.type"]) then @params.animation else defaults.disappearAnimation
5369
5370
5371 text.animator.disappear(animation, easing, duration, (sender) =>
5372 sender.dispose()
5373 scene.behavior.changeTextDomain(sender.domain)
5374 scene.texts[number] = null
5375 )
5376
5377 if @params.waitForCompletion and not (duration == 0 or @interpreter.isInstantSkip())
5378 @interpreter.isWaiting = yes
5379 @interpreter.waitCounter = duration
5380 gs.GameNotifier.postMinorChange()
5381 ###*
5382 * @method commandTextEffect
5383 * @protected
5384 ###
5385 commandTextEffect: ->
5386 scene = SceneManager.scene
5387 scene.behavior.changeTextDomain(@params.numberDomain)
5388 number = @interpreter.numberValueOf(@params.number)
5389 text = scene.texts[number]
5390 if not text? then return
5391
5392 @interpreter.objectEffect(text, @params)
5393 gs.GameNotifier.postMinorChange()
5394 ###*
5395 * @method commandInputText
5396 * @protected
5397 ###
5398 commandInputText: ->
5399 scene = SceneManager.scene
5400 scene.behavior.changeTextDomain(@params.numberDomain)
5401 if (GameManager.settings.allowChoiceSkip||@interpreter.preview) and GameManager.tempSettings.skip
5402 @interpreter.messageObject().behavior.clear()
5403 @interpreter.setStringValueTo(@params.variable, "")
5404 return
5405
5406 @interpreter.isWaiting = yes
5407 if @interpreter.isProcessingMessageInOtherContext()
5408 @interpreter.waitForMessage()
5409 return
5410
5411 $tempFields.letters = @params.letters
5412 scene.behavior.showInputText(@params.letters, gs.CallBack("onInputTextFinish", @interpreter, @interpreter))
5413 @interpreter.waitingFor.inputText = @params
5414 gs.GameNotifier.postMinorChange()
5415 ###*
5416 * @method commandSavePersistentData
5417 * @protected
5418 ###
5419 commandSavePersistentData: -> GameManager.saveGlobalData()
5420
5421 ###*
5422 * @method commandSaveSettings
5423 * @protected
5424 ###
5425 commandSaveSettings: -> GameManager.saveSettings()
5426
5427 ###*
5428 * @method commandPrepareSaveGame
5429 * @protected
5430 ###
5431 commandPrepareSaveGame: ->
5432 if @interpreter.previewData? then return
5433
5434 @interpreter.pointer++
5435 GameManager.prepareSaveGame(@params.snapshot)
5436 @interpreter.pointer--
5437
5438 ###*
5439 * @method commandSaveGame
5440 * @protected
5441 ###
5442 commandSaveGame: ->
5443 if @interpreter.previewData? then return
5444
5445 thumbWidth = @interpreter.numberValueOf(@params.thumbWidth)
5446 thumbHeight = @interpreter.numberValueOf(@params.thumbHeight)
5447
5448 GameManager.save(@interpreter.numberValueOf(@params.slot) - 1, thumbWidth, thumbHeight)
5449
5450 ###*
5451 * @method commandLoadGame
5452 * @protected
5453 ###
5454 commandLoadGame: ->
5455 if @interpreter.previewData? then return
5456
5457 GameManager.load(@interpreter.numberValueOf(@params.slot) - 1)
5458
5459 ###*
5460 * @method commandWaitForInput
5461 * @protected
5462 ###
5463 commandWaitForInput: ->
5464 return if @interpreter.isInstantSkip()
5465
5466 gs.GlobalEventManager.offByOwner("mouseDown", @interpreter.object)
5467 gs.GlobalEventManager.offByOwner("mouseUp", @interpreter.object)
5468 gs.GlobalEventManager.offByOwner("keyDown", @interpreter.object)
5469 gs.GlobalEventManager.offByOwner("keyUp", @interpreter.object)
5470
5471 f = =>
5472 key = @interpreter.numberValueOf(@params.key)
5473 executeAction = no
5474 if Input.Mouse.isButton(@params.key)
5475 executeAction = Input.Mouse.buttons[@params.key] == @params.state
5476 else if @params.key == 100
5477 executeAction = yes if Input.keyDown and @params.state == 1
5478 executeAction = yes if Input.keyUp and @params.state == 2
5479 else if @params.key == 101
5480 executeAction = yes if Input.Mouse.buttonDown and @params.state == 1
5481 executeAction = yes if Input.Mouse.buttonUp and @params.state == 2
5482 else if @params.key == 102
5483 executeAction = yes if (Input.keyDown or Input.Mouse.buttonDown) and @params.state == 1
5484 executeAction = yes if (Input.keyUp or Input.Mouse.buttonUp) and @params.state == 2
5485 else
5486 key = if key > 100 then key - 100 else key
5487 executeAction = Input.keys[key] == @params.state
5488
5489
5490 if executeAction
5491 @interpreter.isWaiting = no
5492
5493 gs.GlobalEventManager.offByOwner("mouseDown", @interpreter.object)
5494 gs.GlobalEventManager.offByOwner("mouseUp", @interpreter.object)
5495 gs.GlobalEventManager.offByOwner("keyDown", @interpreter.object)
5496 gs.GlobalEventManager.offByOwner("keyUp", @interpreter.object)
5497
5498 gs.GlobalEventManager.on "mouseDown", f, null, @interpreter.object
5499 gs.GlobalEventManager.on "mouseUp", f, null, @interpreter.object
5500 gs.GlobalEventManager.on "keyDown", f, null, @interpreter.object
5501 gs.GlobalEventManager.on "keyUp", f, null, @interpreter.object
5502
5503 @interpreter.isWaiting = yes
5504
5505 ###*
5506 * @method commandGetInputData
5507 * @protected
5508 ###
5509 commandGetInputData: ->
5510 switch @params.field
5511 when 0 # Button A
5512 @interpreter.setNumberValueTo(@params.targetVariable, Input.keys[Input.A])
5513 when 1 # Button B
5514 @interpreter.setNumberValueTo(@params.targetVariable, Input.keys[Input.B])
5515 when 2 # Button X
5516 @interpreter.setNumberValueTo(@params.targetVariable, Input.keys[Input.X])
5517 when 3 # Button Y
5518 @interpreter.setNumberValueTo(@params.targetVariable, Input.keys[Input.Y])
5519 when 4 # Button L
5520 @interpreter.setNumberValueTo(@params.targetVariable, Input.keys[Input.L])
5521 when 5 # Button R
5522 @interpreter.setNumberValueTo(@params.targetVariable, Input.keys[Input.R])
5523 when 6 # Button START
5524 @interpreter.setNumberValueTo(@params.targetVariable, Input.keys[Input.START])
5525 when 7 # Button SELECT
5526 @interpreter.setNumberValueTo(@params.targetVariable, Input.keys[Input.SELECT])
5527 when 8 # Mouse X
5528 @interpreter.setNumberValueTo(@params.targetVariable, Input.Mouse.x)
5529 when 9 # Mouse Y
5530 @interpreter.setNumberValueTo(@params.targetVariable, Input.Mouse.y)
5531 when 10 # Mouse Wheel
5532 @interpreter.setNumberValueTo(@params.targetVariable, Input.Mouse.wheel)
5533 when 11 # Mouse Left
5534 @interpreter.setNumberValueTo(@params.targetVariable, Input.Mouse.buttons[Input.Mouse.LEFT])
5535 when 12 # Mouse Right
5536 @interpreter.setNumberValueTo(@params.targetVariable, Input.Mouse.buttons[Input.Mouse.RIGHT])
5537 when 13 # Mouse Middle
5538 @interpreter.setNumberValueTo(@params.targetVariable, Input.Mouse.buttons[Input.Mouse.MIDDLE])
5539 when 100 # Any Key
5540 anyKey = 0
5541 anyKey = 1 if Input.keyDown
5542 anyKey = 2 if Input.keyUp
5543 @interpreter.setNumberValueTo(@params.targetVariable, anyKey)
5544 when 101 # Any Button
5545 anyButton = 0
5546 anyButton = 1 if Input.Mouse.buttonDown
5547 anyButton = 2 if Input.Mouse.buttonUp
5548 @interpreter.setNumberValueTo(@params.targetVariable, anyButton)
5549 when 102 # Any Input
5550 anyInput = 0
5551 anyInput = 1 if Input.Mouse.buttonDown or Input.keyDown
5552 anyInput = 2 if Input.Mouse.buttonUp or Input.keyUp
5553 @interpreter.setNumberValueTo(@params.targetVariable, anyInput)
5554 else
5555 code = @params.field - 100
5556 @interpreter.setNumberValueTo(@params.targetVariable, Input.keys[code])
5557 ###*
5558 * @method commandGetGameData
5559 * @protected
5560 ###
5561 commandGetGameData: ->
5562 tempSettings = GameManager.tempSettings
5563 settings = GameManager.settings
5564
5565 switch @params.field
5566 when 0 # Scene ID
5567 @interpreter.setStringValueTo(@params.targetVariable, SceneManager.scene.sceneDocument.uid)
5568 when 1 # Game Time - Seconds
5569 @interpreter.setNumberValueTo(@params.targetVariable, Math.round(Graphics.frameCount / 60))
5570 when 2 # Game Time - Minutes
5571 @interpreter.setNumberValueTo(@params.targetVariable, Math.round(Graphics.frameCount / 60 / 60))
5572 when 3 # Game Time - Hours
5573 @interpreter.setNumberValueTo(@params.targetVariable, Math.round(Graphics.frameCount / 60 / 60 / 60))
5574 when 4 # Date - Day of Month
5575 @interpreter.setNumberValueTo(@params.targetVariable, new Date().getDate())
5576 when 5 # Date - Day of Week
5577 @interpreter.setNumberValueTo(@params.targetVariable, new Date().getDay())
5578 when 6 # Date - Month
5579 @interpreter.setNumberValueTo(@params.targetVariable, new Date().getMonth())
5580 when 7 # Date - Year
5581 @interpreter.setNumberValueTo(@params.targetVariable, new Date().getFullYear())
5582 when 8
5583 @interpreter.setBooleanValueTo(@params.targetVariable, settings.allowSkip)
5584 when 9
5585 @interpreter.setBooleanValueTo(@params.targetVariable, settings.allowSkipUnreadMessages)
5586 when 10
5587 @interpreter.setNumberValueTo(@params.targetVariable, settings.messageSpeed)
5588 when 11
5589 @interpreter.setBooleanValueTo(@params.targetVariable, settings.autoMessage.enabled)
5590 when 12
5591 @interpreter.setNumberValueTo(@params.targetVariable, settings.autoMessage.time)
5592 when 13
5593 @interpreter.setBooleanValueTo(@params.targetVariable, settings.autoMessage.waitForVoice)
5594 when 14
5595 @interpreter.setBooleanValueTo(@params.targetVariable, settings.autoMessage.stopOnAction)
5596 when 15
5597 @interpreter.setBooleanValueTo(@params.targetVariable, settings.timeMessageToVoice)
5598 when 16
5599 @interpreter.setBooleanValueTo(@params.targetVariable, settings.allowVideoSkip)
5600 when 17
5601 @interpreter.setBooleanValueTo(@params.targetVariable, settings.allowChoiceSkip)
5602 when 18
5603 @interpreter.setBooleanValueTo(@params.targetVariable, settings.skipVoiceOnAction)
5604 when 19
5605 @interpreter.setBooleanValueTo(@params.targetVariable, settings.fullScreen)
5606 when 20
5607 @interpreter.setBooleanValueTo(@params.targetVariable, settings.adjustAspectRatio)
5608 when 21
5609 @interpreter.setBooleanValueTo(@params.targetVariable, settings.confirmation)
5610 when 22
5611 @interpreter.setNumberValueTo(@params.targetVariable, settings.bgmVolume)
5612 when 23
5613 @interpreter.setNumberValueTo(@params.targetVariable, settings.voiceVolume)
5614 when 24
5615 @interpreter.setNumberValueTo(@params.targetVariable, settings.seVolume)
5616 when 25
5617 @interpreter.setBooleanValueTo(@params.targetVariable, settings.bgmEnabled)
5618 when 26
5619 @interpreter.setBooleanValueTo(@params.targetVariable, settings.voiceEnabled)
5620 when 27
5621 @interpreter.setBooleanValueTo(@params.targetVariable, settings.seEnabled)
5622 when 28 # Language - Code
5623 @interpreter.setStringValueTo(@params.targetVariable, LanguageManager.language?.code || "")
5624 when 29 # Language - Name
5625 @interpreter.setStringValueTo(@params.targetVariable, LanguageManager.language?.name || "")
5626 when 30
5627 @interpreter.setBooleanValueTo(@params.targetVariable, GameManager.tempSettings.skip)
5628
5629 ###*
5630 * @method commandSetGameData
5631 * @protected
5632 ###
5633 commandSetGameData: ->
5634 tempSettings = GameManager.tempSettings
5635 settings = GameManager.settings
5636
5637 switch @params.field
5638 when 0
5639 settings.allowSkip = @interpreter.booleanValueOf(@params.switchValue)
5640 when 1
5641 settings.allowSkipUnreadMessages = @interpreter.booleanValueOf(@params.switchValue)
5642 when 2
5643 settings.messageSpeed = @interpreter.numberValueOf(@params.decimalValue)
5644 when 3
5645 settings.autoMessage.enabled = @interpreter.booleanValueOf(@params.switchValue)
5646 when 4
5647 settings.autoMessage.time = @interpreter.numberValueOf(@params.numberValue)
5648 when 5
5649 settings.autoMessage.waitForVoice = @interpreter.booleanValueOf(@params.switchValue)
5650 when 6
5651 settings.autoMessage.stopOnAction = @interpreter.booleanValueOf(@params.switchValue)
5652 when 7
5653 settings.timeMessageToVoice = @interpreter.booleanValueOf(@params.switchValue)
5654 when 8
5655 settings.allowVideoSkip = @interpreter.booleanValueOf(@params.switchValue)
5656 when 9
5657 settings.allowChoiceSkip = @interpreter.booleanValueOf(@params.switchValue)
5658 when 10
5659 settings.skipVoiceOnAction = @interpreter.booleanValueOf(@params.switchValue)
5660 when 11
5661 settings.fullScreen = @interpreter.booleanValueOf(@params.switchValue)
5662 if settings.fullScreen
5663 SceneManager.scene.behavior.enterFullScreen()
5664 else
5665 SceneManager.scene.behavior.leaveFullScreen()
5666 when 12
5667 settings.adjustAspectRatio = @interpreter.booleanValueOf(@params.switchValue)
5668 Graphics.keepRatio = settings.adjustAspectRatio
5669 Graphics.onResize()
5670 when 13
5671 settings.confirmation = @interpreter.booleanValueOf(@params.switchValue)
5672 when 14
5673 settings.bgmVolume = @interpreter.numberValueOf(@params.numberValue)
5674 when 15
5675 settings.voiceVolume = @interpreter.numberValueOf(@params.numberValue)
5676 when 16
5677 settings.seVolume = @interpreter.numberValueOf(@params.numberValue)
5678 when 17
5679 settings.bgmEnabled = @interpreter.booleanValueOf(@params.switchValue)
5680 when 18
5681 settings.voiceEnabled = @interpreter.booleanValueOf(@params.switchValue)
5682 when 19
5683 settings.seEnabled = @interpreter.booleanValueOf(@params.switchValue)
5684 when 20
5685 code = @interpreter.stringValueOf(@params.textValue)
5686 language = LanguageManager.languages.first (l) => l.code == code
5687 LanguageManager.selectLanguage(language) if language
5688 when 21
5689 GameManager.tempSettings.skip = @interpreter.booleanValueOf(@params.switchValue)
5690
5691 ###*
5692 * @method commandGetObjectData
5693 * @protected
5694 ###
5695 commandGetObjectData: ->
5696 scene = SceneManager.scene
5697 switch @params.objectType
5698 when 0 # Picture
5699 scene.behavior.changePictureDomain(@params.numberDomain)
5700 object = SceneManager.scene.pictures[@interpreter.numberValueOf(@params.number)]
5701 when 1 # Background
5702 object = SceneManager.scene.backgrounds[@interpreter.numberValueOf(@params.layer)]
5703 when 2 # Text
5704 scene.behavior.changeTextDomain(@params.numberDomain)
5705 object = SceneManager.scene.texts[@interpreter.numberValueOf(@params.number)]
5706 when 3 # Movie
5707 scene.behavior.changeVideoDomain(@params.numberDomain)
5708 object = SceneManager.scene.videos[@interpreter.numberValueOf(@params.number)]
5709 when 4 # Character
5710 characterId = @interpreter.stringValueOf(@params.characterId)
5711 object = SceneManager.scene.characters.first (v) => !v.disposed and v.rid == characterId
5712 when 5 # Message Box
5713 object = gs.ObjectManager.current.objectById("messageBox")
5714 when 6 # Message Area
5715 scene.behavior.changeMessageAreaDomain(@params.numberDomain)
5716 area = SceneManager.scene.messageAreas[@interpreter.numberValueOf(@params.number)]
5717 object = area?.layout
5718 when 7 # Hotspot
5719 scene.behavior.changeHotspotDomain(@params.numberDomain)
5720 object = SceneManager.scene.hotspots[@interpreter.numberValueOf(@params.number)]
5721
5722
5723 field = @params.field
5724 if @params.objectType == 4 # Character
5725 switch @params.field
5726 when 0 # ID
5727 @interpreter.setStringValueTo(@params.targetVariable, RecordManager.characters[characterId]?.index || "")
5728 when 1 # Name
5729 @interpreter.setStringValueTo(@params.targetVariable, lcs(RecordManager.characters[characterId]?.name) || "")
5730 field -= 2
5731
5732 if @params.objectType == 6 # Message
5733 switch field
5734 when 0 # Position - X
5735 @interpreter.setNumberValueTo(@params.targetVariable, object.dstRect.x)
5736 when 1 # Position - Y
5737 @interpreter.setNumberValueTo(@params.targetVariable, object.dstRect.y)
5738 when 2 # Z-Index
5739 @interpreter.setNumberValueTo(@params.targetVariable, object.zIndex)
5740 when 3 # Opacity
5741 @interpreter.setNumberValueTo(@params.targetVariable, object.opacity)
5742 when 4 # Visible
5743 @interpreter.setBooleanValueTo(@params.targetVariable, object.visible)
5744
5745 else if object?
5746 if field >= 0
5747 switch field
5748 when 0 # Resource Name
5749 switch @params.objectType
5750 when 2
5751 @interpreter.setStringValueTo(@params.targetVariable, object.text || "")
5752 when 3
5753 @interpreter.setStringValueTo(@params.targetVariable, object.video || "")
5754 else
5755 @interpreter.setStringValueTo(@params.targetVariable, object.image || "")
5756 when 1 # Position - X
5757 @interpreter.setNumberValueTo(@params.targetVariable, object.dstRect.x)
5758 when 2 # Position - Y
5759 @interpreter.setNumberValueTo(@params.targetVariable, object.dstRect.y)
5760 when 3 # Anchor - X
5761 @interpreter.setNumberValueTo(@params.targetVariable, Math.round(object.anchor.x * 100))
5762 when 4 # Anchor - Y
5763 @interpreter.setNumberValueTo(@params.targetVariable, Math.round(object.anchor.y * 100))
5764 when 5 # Zoom - X
5765 @interpreter.setNumberValueTo(@params.targetVariable, Math.round(object.zoom.x * 100))
5766 when 6 # Zoom - Y
5767 @interpreter.setNumberValueTo(@params.targetVariable, Math.round(object.zoom.y * 100))
5768 when 7 # Size - Width
5769 @interpreter.setNumberValueTo(@params.targetVariable, object.dstRect.width)
5770 when 8 # Size - Height
5771 @interpreter.setNumberValueTo(@params.targetVariable, object.dstRect.height)
5772 when 9 # Z-Index
5773 @interpreter.setNumberValueTo(@params.targetVariable, object.zIndex)
5774 when 10 # Opacity
5775 @interpreter.setNumberValueTo(@params.targetVariable, object.opacity)
5776 when 11 # Angle
5777 @interpreter.setNumberValueTo(@params.targetVariable, object.angle)
5778 when 12 # Visible
5779 @interpreter.setBooleanValueTo(@params.targetVariable, object.visible)
5780 when 13 # Blend Mode
5781 @interpreter.setNumberValueTo(@params.targetVariable, object.blendMode)
5782 when 14 # Flipped
5783 @interpreter.setBooleanValueTo(@params.targetVariable, object.mirror)
5784
5785 ###*
5786 * @method commandSetObjectData
5787 * @protected
5788 ###
5789 commandSetObjectData: ->
5790 scene = SceneManager.scene
5791
5792 switch @params.objectType
5793 when 0 # Picture
5794 scene.behavior.changePictureDomain(@params.numberDomain)
5795 object = SceneManager.scene.pictures[@interpreter.numberValueOf(@params.number)]
5796 when 1 # Background
5797 object = SceneManager.scene.backgrounds[@interpreter.numberValueOf(@params.layer)]
5798 when 2 # Text
5799 scene.behavior.changeTextDomain(@params.numberDomain)
5800 object = SceneManager.scene.texts[@interpreter.numberValueOf(@params.number)]
5801 when 3 # Movie
5802 scene.behavior.changeVideoDomain(@params.numberDomain)
5803 object = SceneManager.scene.videos[@interpreter.numberValueOf(@params.number)]
5804 when 4 # Character
5805 characterId = @interpreter.stringValueOf(@params.characterId)
5806 object = SceneManager.scene.characters.first (v) => !v.disposed and v.rid == characterId
5807 when 5 # Message Box
5808 object = gs.ObjectManager.current.objectById("messageBox")
5809 when 6 # Message Area
5810 scene.behavior.changeMessageAreaDomain(@params.numberDomain)
5811 area = SceneManager.scene.messageAreas[@interpreter.numberValueOf(@params.number)]
5812 object = area?.layout
5813 when 7 # Hotspot
5814 scene.behavior.changeHotspotDomain(@params.numberDomain)
5815 object = SceneManager.scene.hotspots[@interpreter.numberValueOf(@params.number)]
5816
5817
5818 field = @params.field
5819 if @params.objectType == 4 # Character
5820 switch field
5821 when 0 # Name
5822 name = @interpreter.stringValueOf(@params.textValue)
5823 if object?
5824 object.name = name
5825 RecordManager.characters[characterId]?.name = name
5826 field--
5827
5828 if @params.objectType == 6 # Message
5829 switch field
5830 when 0 # Position - X
5831 object.dstRect.x = @interpreter.numberValueOf(@params.numberValue)
5832 when 1 # Position - Y
5833 object.dstRect.y = @interpreter.numberValueOf(@params.numberValue)
5834 when 2 # Z-Index
5835 object.zIndex = @interpreter.numberValueOf(@params.numberValue)
5836 when 3 # Opacity
5837 object.opacity= @interpreter.numberValueOf(@params.numberValue)
5838 when 4 # Visible
5839 object.visible = @interpreter.booleanValueOf(@params.switchValue)
5840
5841 else if object?
5842 if field >= 0
5843 switch field
5844 when 0 # Resource Name / Text
5845 switch @params.objectType
5846 when 2
5847 object.text = @interpreter.stringValueOf(@params.textValue)
5848 when 3
5849 object.video = @interpreter.stringValueOf(@params.textValue)
5850 else
5851 object.image = @interpreter.stringValueOf(@params.textValue)
5852 when 1 # Position - X
5853 object.dstRect.x = @interpreter.numberValueOf(@params.numberValue)
5854 when 2 # Position - Y
5855 object.dstRect.y = @interpreter.numberValueOf(@params.numberValue)
5856 when 3 # Anchor - X
5857 object.anchor.x = @interpreter.numberValueOf(@params.numberValue) / 100
5858 when 4 # Anchor - Y
5859 object.anchor.y = @interpreter.numberValueOf(@params.numberValue) / 100
5860 when 5 # Zoom - X
5861 object.zoom.x = @interpreter.numberValueOf(@params.numberValue) / 100
5862 when 6 # Zoom - Y
5863 object.zoom.y = @interpreter.numberValueOf(@params.numberValue) / 100
5864 when 7 # Z-Index
5865 object.zIndex = @interpreter.numberValueOf(@params.numberValue)
5866 when 8 # Opacity
5867 object.opacity= @interpreter.numberValueOf(@params.numberValue)
5868 when 9 # Angle
5869 object.angle = @interpreter.numberValueOf(@params.numberValue)
5870 when 10 # Visible
5871 object.visible = @interpreter.booleanValueOf(@params.switchValue)
5872 when 11 # Blend Mode
5873 object.blendMode = @interpreter.numberValueOf(@params.numberValue)
5874 when 12 # Flipped
5875 object.mirror = @interpreter.booleanValueOf(@params.switchValue)
5876
5877 ###*
5878 * @method commandChangeSounds
5879 * @protected
5880 ###
5881 commandChangeSounds: ->
5882 sounds = RecordManager.system.sounds
5883 fieldFlags = @params.fieldFlags || {}
5884
5885 for sound, i in @params.sounds
5886 if !gs.CommandFieldFlags.isLocked(fieldFlags["sounds."+i])
5887 sounds[i] = @params.sounds[i]
5888
5889 ###*
5890 * @method commandChangeColors
5891 * @protected
5892 ###
5893 commandChangeColors: ->
5894 colors = RecordManager.system.colors
5895 fieldFlags = @params.fieldFlags || {}
5896
5897 for color, i in @params.colors
5898 if !gs.CommandFieldFlags.isLocked(fieldFlags["colors."+i])
5899 colors[i] = new gs.Color(@params.colors[i])
5900
5901 ###*
5902 * @method commandChangeScreenCursor
5903 * @protected
5904 ###
5905 commandChangeScreenCursor: ->
5906 if @params.graphic?.name?
5907 bitmap = ResourceManager.getBitmap("Graphics/Pictures/#{@params.graphic.name}")
5908 Graphics.setCursorBitmap(bitmap, @params.hx, @params.hy)
5909 else
5910 Graphics.setCursorBitmap(null, 0, 0)
5911
5912 ###*
5913 * @method commandResetGlobalData
5914 * @protected
5915 ###
5916 commandResetGlobalData: ->
5917 GameManager.resetGlobalData()
5918
5919 ###*
5920 * @method commandScript
5921 * @protected
5922 ###
5923 commandScript: ->
5924 try
5925 if !@params.scriptFunc
5926 @params.scriptFunc = eval("(function(){" + @params.script + "})")
5927
5928 @params.scriptFunc()
5929 catch ex
5930 console.log(ex)
5931
5932window.CommandInterpreter = Component_CommandInterpreter
5933gs.Component_CommandInterpreter = Component_CommandInterpreter