Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ===================================================================
- #
- # Script: Component_GameSceneBehavior
- #
- # $$COPYRIGHT$$
- #
- # ===================================================================
- class Component_GameSceneBehavior extends gs.Component_LayoutSceneBehavior
- # @objectCodecBlackList = ["objectManager"]
- ###*
- * Defines the behavior of visual novel game scene.
- *
- * @module vn
- * @class Component_GameSceneBehavior
- * @extends gs.Component_LayoutSceneBehavior
- * @memberof vn
- ###
- constructor: ->
- super()
- @onAutoCommonEventStart = =>
- @object.removeComponent(@object.interpreter)
- @object.interpreter.stop()
- @onAutoCommonEventFinish = =>
- if !@object.components.contains(@object.interpreter)
- @object.addComponent(@object.interpreter)
- @object.interpreter.resume()
- @resourceContext = null
- @objectDomain = ""
- ###*
- * Initializes the scene.
- *
- * @method initialize
- ###
- initialize: ->
- if SceneManager.previousScenes.length == 0
- gs.GlobalEventManager.clearExcept(@object.commonEventContainer.subObjects)
- @resourceContext = ResourceManager.createContext()
- ResourceManager.context = @resourceContext
- Graphics.freeze()
- saveGame = GameManager.loadedSaveGame
- sceneUid = null
- if saveGame
- sceneUid = saveGame.sceneUid
- @object.sceneData = saveGame.data
- else
- sceneUid = $PARAMS.preview?.scene.uid || @object.sceneData.uid || RecordManager.system.startInfo.scene.uid
- @object.sceneDocument = DataManager.getDocument(sceneUid)
- if @object.sceneDocument and @object.sceneDocument.items.type == "vn.scene"
- @object.chapter = DataManager.getDocument(@object.sceneDocument.items.chapterUid)
- @object.currentCharacter = { "name": "" } #RecordManager.characters[0]
- if not GameManager.initialized
- GameManager.initialize()
- LanguageManager.loadBundles()
- else
- sprite = new gs.Sprite()
- sprite.bitmap = new gs.Bitmap(Graphics.width, 50)
- sprite.bitmap.drawText(0, 0, Graphics.width, 50, "No Start Scene selected", 1, 0)
- sprite.srcRect = new gs.Rect(0, 0, Graphics.width, 50)
- sprite.y = (Graphics.height - 50) / 2
- sprite.z = 10000
- @setupScreen()
- ###*
- * Disposes the scene.
- *
- * @method dispose
- ###
- dispose: ->
- ResourceManager.context = @resourceContext
- @object.removeObject(@object.commonEventContainer)
- @show(no)
- for event in GameManager.commonEvents
- if event
- event.events.offByOwner("start", @object)
- event.events.offByOwner("finish", @object)
- if @object.video
- @object.video.dispose()
- @object.video.onEnded()
- super()
- changePictureDomain: (domain) ->
- @object.pictureContainer.behavior.changeDomain(domain)
- @object.pictures = @object.pictureContainer.subObjects
- changeTextDomain: (domain) ->
- @object.textContainer.behavior.changeDomain(domain)
- @object.texts = @object.textContainer.subObjects
- changeVideoDomain: (domain) ->
- @object.videoContainer.behavior.changeDomain(domain)
- @object.videos = @object.videoContainer.subObjects
- changeHotspotDomain: (domain) ->
- @object.hotspotContainer.behavior.changeDomain(domain)
- @object.hotspots = @object.hotspotContainer.subObjects
- changeMessageAreaDomain: (domain) ->
- @object.messageAreaContainer.behavior.changeDomain(domain)
- @object.messageAreas = @object.messageAreaContainer.subObjects
- ###*
- * Shows/Hides the current scene. A hidden scene is no longer shown and executed
- * but all objects and data is still there and be shown again anytime.
- *
- * @method show
- * @param {boolean} visible - Indicates if the scene should be shown or hidden.
- ###
- show: (visible) ->
- if visible
- @object.viewport = GameManager.sceneViewport
- window.$dataFields = @dataFields
- @object.visible = visible
- @object.layout?.update()
- @object.pictureContainer.behavior.setVisible(visible)
- @object.hotspotContainer.behavior.setVisible(visible)
- @object.textContainer.behavior.setVisible(visible)
- @object.videoContainer.behavior.setVisible(visible)
- @object.messageAreaContainer.behavior.setVisible(visible)
- @object.viewportContainer.behavior.setVisible(visible)
- @object.characterContainer.behavior.setVisible(visible)
- @object.backgroundContainer.behavior.setVisible(visible)
- @viewport?.visible = visible
- @object.choiceWindow?.visible = visible
- @object.inputNumberBox?.visible = visible
- @object.inputTextBox?.visible = visible
- @object.inputTextBox?.update()
- @object.inputNumberBox?.update()
- @object.choiceWindow?.update()
- #if visible and @object.commonEventContainer.subObjects.length == 0
- @setupCommonEvents()
- ###*
- * Sets up common event handling.
- *
- * @method setupCommonEvents
- ###
- setupCommonEvents: ->
- commonEvents = @object.sceneData?.commonEvents
- if commonEvents
- for event, i in commonEvents
- if event and @object.commonEventContainer.subObjects.indexOf(event) == -1
- @object.commonEventContainer.setObject(event, i)
- event.behavior.setupEventHandlers()
- if event.interpreter?.isRunning
- event.events.emit("start", event)
- else
- for event, i in GameManager.commonEvents
- if event and (event.record.startCondition == 1 or event.record.parallel) and @object.commonEventContainer.subObjects.indexOf(event) == -1
- @object.commonEventContainer.setObject(event, i)
- event.events.offByOwner("start", @object)
- event.events.offByOwner("finish", @object)
- if not event.record.parallel
- event.events.on "start", gs.CallBack("onAutoCommonEventStart", this), null, @object
- event.events.on "finish", gs.CallBack("onAutoCommonEventFinish", this), null, @object
- if event.interpreter?.isRunning
- event.events.emit("start", event)
- return null
- ###*
- * Sets up main interpreter.
- *
- * @method setupInterpreter
- * @protected
- ###
- setupInterpreter: ->
- @object.commands = @object.sceneDocument.items.commands
- if @object.sceneData.interpreter
- @object.removeComponent(@object.interpreter)
- @object.interpreter = @object.sceneData.interpreter
- @object.addComponent(@object.interpreter)
- #Object.mixin(@object.interpreter, @object.sceneData.interpreter, gs.Component_CommandInterpreter.objectCodecBlackList)
- @object.interpreter.context.set(@object.sceneDocument.uid, @object)
- @object.interpreter.object = @object
- else
- @object.interpreter.setup()
- @object.interpreter.context.set(@object.sceneDocument.uid, @object)
- @object.interpreter.start()
- ###*
- * Sets up characters and restores them from loaded save game if necessary.
- *
- * @method setupCharacters
- * @protected
- ###
- setupCharacters: ->
- if @object.sceneData.characters?
- for c, i in @object.sceneData.characters
- @object.characterContainer.setObject(c, i)
- @object.currentCharacter = @object.sceneData.currentCharacter || { name: "" }#RecordManager.characters[0]
- ###*
- * Sets up viewports and restores them from loaded save game if necessary.
- *
- * @method setupViewports
- * @protected
- ###
- setupViewports: ->
- viewports = @object.sceneData?.viewports ? []
- for viewport, i in viewports
- if viewport
- @object.viewportContainer.setObject(viewport, i)
- ###*
- * Sets up backgrounds and restores them from loaded save game if necessary.
- *
- * @method setupBackgrounds
- * @protected
- ###
- setupBackgrounds: ->
- backgrounds = @object.sceneData?.backgrounds ? []
- for b, i in backgrounds
- @object.backgroundContainer.setObject(b, i)
- ###*
- * Sets up pictures and restores them from loaded save game if necessary.
- *
- * @method setupPictures
- * @protected
- ###
- setupPictures: ->
- pictures = @object.sceneData?.pictures ? {}
- for domain of pictures
- @object.pictureContainer.behavior.changeDomain(domain)
- if pictures[domain] then for picture, i in pictures[domain]
- @object.pictureContainer.setObject(picture, i)
- if picture?.image
- path = "Graphics/Pictures/#{picture.image}"
- @resourceContext.add(path, ResourceManager.resourcesByPath[path])
- ###*
- * Sets up texts and restores them from loaded save game if necessary.
- *
- * @method setupTexts
- * @protected
- ###
- setupTexts: ->
- texts = @object.sceneData?.texts ? {}
- for domain of texts
- @object.textContainer.behavior.changeDomain(domain)
- if texts[domain] then for text, i in texts[domain]
- @object.textContainer.setObject(text, i)
- ###*
- * Sets up videos and restores them from loaded save game if necessary.
- *
- * @method setupVideos
- * @protected
- ###
- setupVideos: ->
- videos = @object.sceneData?.videos ? {}
- for domain of videos
- @object.videoContainer.behavior.changeDomain(domain)
- if videos[domain] then for video, i in videos[domain]
- if video
- path = "Movies/#{video.video}"
- @resourceContext.add(path, ResourceManager.resourcesByPath[path])
- video.visible = yes
- video.update()
- @object.videoContainer.setObject(video, i)
- ###*
- * Sets up hotspots and restores them from loaded save game if necessary.
- *
- * @method setupHotspots
- * @protected
- ###
- setupHotspots: ->
- hotspots = @object.sceneData?.hotspots ? {}
- for domain of hotspots
- @object.hotspotContainer.behavior.changeDomain(domain)
- if hotspots[domain] then for hotspot, i in hotspots[domain]
- @object.hotspotContainer.setObject(hotspot, i)
- ###*
- * Sets up layout.
- *
- * @method setupLayout
- * @protected
- ###
- setupLayout: ->
- @dataFields = ui.UIManager.dataSources[ui.UiFactory.layouts.gameLayout.dataSource || "default"]()
- @dataFields.scene = @object
- window.$dataFields = @dataFields
- advVisible = @object.messageMode == vn.MessageMode.ADV
- @object.layout = ui.UiFactory.createFromDescriptor(ui.UiFactory.layouts.gameLayout, @object)
- @object.layout.visible = advVisible
- $gameMessage_message.visible = advVisible
- @object.layout.ui.prepare()
- @object.choices = @object.sceneData?.choices || @object.choices
- if @object.choices?.length > 0
- @showChoices(gs.CallBack("onChoiceAccept", @object.interpreter, { pointer: @object.interpreter.pointer, params: @params }))
- if @object.interpreter.waitingFor.inputNumber
- @showInputNumber(GameManager.tempFields.digits, gs.CallBack("onInputNumberFinish", @object.interpreter, @object.interpreter))
- if @object.interpreter.waitingFor.inputText
- @showInputText(GameManager.tempFields.letters, gs.CallBack("onInputTextFinish", @object.interpreter, @object.interpreter))
- ###*
- * Sets up the main viewport / screen viewport.
- *
- * @method setupMainViewport
- * @protected
- ###
- setupMainViewport: ->
- if !@object.sceneData.viewport
- GameManager.sceneViewport.removeComponent(GameManager.sceneViewport.visual)
- GameManager.sceneViewport.dispose()
- GameManager.sceneViewport = new gs.Object_Viewport(GameManager.sceneViewport.visual.viewport)
- @viewport = GameManager.sceneViewport.visual.viewport
- @object.viewport = GameManager.sceneViewport
- else
- GameManager.sceneViewport.dispose()
- GameManager.sceneViewport = @object.sceneData.viewport
- @object.viewport = @object.sceneData.viewport
- @viewport = @object.viewport.visual.viewport
- @viewport.viewport = Graphics.viewport
- ###*
- * Sets up screen.
- *
- * @method setupScreen
- * @protected
- ###
- setupScreen: ->
- if @object.sceneData.screen
- @object.viewport.restore(@object.sceneData.screen)
- ###*
- * Restores main interpreter from loaded save game.
- *
- * @method restoreInterpreter
- * @protected
- ###
- restoreInterpreter: ->
- if @object.sceneData.interpreter
- @object.interpreter.restore()
- ###*
- * Restores message from loaded save game.
- *
- * @method restoreMessages
- * @protected
- ###
- restoreMessages: ->
- if @object.sceneData?.messageAreas
- for domain of @object.sceneData.messageAreas
- @object.messageAreaContainer.behavior.changeDomain(domain)
- messageAreas = @object.sceneData.messageAreas
- if messageAreas[domain] then for area, i in messageAreas[domain]
- if area
- messageArea = new gs.Object_MessageArea()
- messageLayout = ui.UIManager.createControlFromDescriptor(type: "ui.CustomGameMessage", id: "customGameMessage_"+i, params: { id: "customGameMessage_"+i }, messageArea)
- message = gs.ObjectManager.current.objectById("customGameMessage_"+i+"_message")
- area.message.textRenderer.disposeEventHandlers();
- message.textRenderer.dispose()
- Object.mixin(message, area.message)
- for c in message.components
- c.object = message
- #message.restore(f.message)
- messageLayout.dstRect.x = area.layout.dstRect.x
- messageLayout.dstRect.y = area.layout.dstRect.y
- messageLayout.dstRect.width = area.layout.dstRect.width
- messageLayout.dstRect.height = area.layout.dstRect.height
- messageLayout.needsUpdate = yes
- message.textRenderer.setupEventHandlers()
- messageLayout.update()
- #message.message.restoreMessages(f.messages)
- #message.textRenderer.restore(f.textRenderer)
- #message.visible = yes
- messageArea.message = message
- messageArea.layout = messageLayout
- messageArea.addObject(messageLayout)
- @object.messageAreaContainer.setObject(messageArea, i)
- ###*
- * Restores audio-playback from loaded save game.
- *
- * @method restoreAudioPlayback
- * @protected
- ###
- restoreAudioPlayback: ->
- if @object.sceneData.audio
- AudioManager.audioBuffers.push(b) for b in @object.sceneData.audio.audioBuffers
- AudioManager.audioBuffersByLayer = @object.sceneData.audio.audioBuffersByLayer
- AudioManager.audioLayers = @object.sceneData.audio.audioLayers
- AudioManager.soundReferences = @object.sceneData.audio.soundReferences
- ###*
- * Restores the scene objects from the current loaded save-game. If no save-game is
- * present in GameManager.loadedSaveGame, nothing will happen.
- *
- * @method restoreScene
- * @protected
- ###
- restoreScene: ->
- saveGame = GameManager.loadedSaveGame
- if saveGame
- context = new gs.ObjectCodecContext([Graphics.viewport, @object, this], saveGame.encodedObjectStore, null)
- saveGame.data = gs.ObjectCodec.decode(saveGame.data, context)
- for c in saveGame.data.characterNames
- if c then RecordManager.characters[c.index]?.name = c.name
- GameManager.restore(saveGame)
- gs.ObjectCodec.onRestore(saveGame.data, context)
- @resourceContext.fromDataBundle(saveGame.data.resourceContext, ResourceManager.resourcesByPath)
- @object.sceneData = saveGame.data
- Graphics.frameCount = saveGame.data.frameCount
- ###*
- * Prepares all data for the scene and loads the necessary graphic and audio resources.
- *
- * @method prepareData
- * @abstract
- ###
- prepareData: ->
- #RecordManager.translate()
- GameManager.scene = @object
- gs.ObjectManager.current = @objectManager
- @object.sceneData.uid = @object.sceneDocument.uid
- if !ResourceLoader.loadEventCommandsData(@object.sceneDocument.items.commands)
- ResourceLoader.loadEventCommandsGraphics(@object.sceneDocument.items.commands)
- GameManager.backlog = @object.sceneData.backlog || GameManager.sceneData.backlog || []
- ResourceLoader.loadSystemSounds()
- ResourceLoader.loadSystemGraphics()
- ResourceLoader.loadUiTypesGraphics(ui.UiFactory.customTypes)
- ResourceLoader.loadUiLayoutGraphics(ui.UiFactory.layouts.gameLayout)
- if @dataFields?
- ResourceLoader.loadUiDataFieldsGraphics(@dataFields)
- $tempFields.choiceTimer = @object.choiceTimer
- GameManager.variableStore.setup({ id: @object.sceneDocument.uid})
- ###*
- * Prepares all visual game object for the scene.
- *
- * @method prepareVisual
- ###
- prepareVisual: ->
- if @object.layout then return
- if GameManager.tempFields.isExitingGame
- GameManager.tempFields.isExitingGame = no
- gs.GameNotifier.postResetSceneChange(@object.sceneDocument.items.name)
- else
- gs.GameNotifier.postSceneChange(@object.sceneDocument.items.name)
- @restoreScene()
- @object.messageMode = @object.sceneData.messageMode ? vn.MessageMode.ADV
- @setupMainViewport()
- @setupViewports()
- @setupCharacters()
- @setupBackgrounds()
- @setupPictures()
- @setupTexts()
- @setupVideos()
- @setupHotspots()
- @setupInterpreter()
- @setupLayout()
- @setupCommonEvents()
- @restoreMessageBox()
- @restoreInterpreter()
- @restoreMessages()
- @restoreAudioPlayback()
- @show(true)
- @object.sceneData = {}
- GameManager.sceneData = {}
- Graphics.update()
- @transition({ duration: 0 })
- ###*
- * Adds a new character to the scene.
- *
- * @method addCharacter
- * @param {vn.Object_Character} character - The character to add.
- * @param {boolean} noAnimation - Indicates if the character should be added immediately witout any appear-animation.
- * @param {Object} animationData - Contains the appear-animation data -> { animation, easing, duration }.
- ###
- addCharacter: (character, noAnimation, animationData) ->
- unless noAnimation
- character.motionBlur.set(animationData.motionBlur)
- if animationData.duration > 0
- character.animator.appear(character.dstRect.x, character.dstRect.y, animationData.animation, animationData.easing, animationData.duration) unless noAnimation
- character.viewport = @viewport
- character.visible = yes
- @object.characterContainer.addObject(character)
- ###*
- * Removes a character from the scene.
- *
- * @method removeCharacter
- * @param {vn.Object_Character} character - The character to remove.
- * @param {Object} animationData - Contains the disappear-animation data -> { animation, easing, duration }.
- ###
- removeCharacter: (character, animationData) ->
- character?.animator.disappear(animationData.animation, animationData.easing, animationData.duration, (sender) -> sender.dispose())
- ###*
- * Resumes the current scene if it has been paused.
- *
- * @method resumeScene
- ###
- resumeScene: ->
- @object.pictureContainer.active = yes
- @object.characterContainer.active = yes
- @object.backgroundContainer.active = yes
- @object.textContainer.active = yes
- @object.hotspotContainer.active = yes
- @object.videoContainer.active = yes
- message = gs.ObjectManager.current.objectById("gameMessage_message")
- message.active = yes
- ###*
- * Pauses the current scene. A paused scene will not continue, messages, pictures, etc. will
- * stop until the scene resumes.
- *
- * @method pauseScene
- ###
- pauseScene: ->
- @object.pictureContainer.active = no
- @object.characterContainer.active = no
- @object.backgroundContainer.active = no
- @object.textContainer.active = no
- @object.hotspotContainer.active = no
- @object.videoContainer.active = no
- message = gs.ObjectManager.current.objectById("gameMessage_message")
- message.active = no
- ###*
- * Changes the visibility of the entire game UI like the message boxes, etc. to allows
- * the player to see the entire scene. Useful for CGs, etc.
- *
- * @param {boolean} visible - If <b>true</b>, the game UI will be visible. Otherwise it will be hidden.
- * @method changeUIVisibility
- ###
- changeUIVisibility: (visible) ->
- @uiVisible = visible
- @object.layout.visible = visible
- ###*
- * Shows input-text box to let the user enter a text.
- *
- * @param {number} letters - The max. number of letters the user can enter.
- * @param {gs.Callback} callback - A callback function called if the input-text box has been accepted by the user.
- * @method showInputText
- ###
- showInputText: (letters, callback) ->
- @object.inputTextBox?.dispose()
- @object.inputTextBox = ui.UiFactory.createControlFromDescriptor(ui.UiFactory.customTypes["ui.InputTextBox"], @object.layout)
- @object.inputTextBox.ui.prepare()
- @object.inputTextBox.events.on("accept", callback)
- ###*
- * Shows input-number box to let the user enter a number.
- *
- * @param {number} digits - The max. number of digits the user can enter.
- * @param {gs.Callback} callback - A callback function called if the input-number box has been accepted by the user.
- * @method showInputNumber
- ###
- showInputNumber: (digits, callback) ->
- @object.inputNumberBox?.dispose()
- @object.inputNumberBox = ui.UiFactory.createControlFromDescriptor(ui.UiFactory.customTypes["ui.InputNumberBox"], @object.layout)
- @object.inputNumberBox.ui.prepare()
- @object.inputNumberBox.events.on("accept", callback)
- ###*
- * Shows choices to let the user pick a choice.
- *
- * @param {Object[]} choices - An array of choices
- * @param {gs.Callback} callback - A callback function called if a choice has been picked by the user.
- * @method showChoices
- ###
- showChoices: (callback) ->
- useFreeLayout = @object.choices.where((x) -> x.dstRect?).length > 0
- @object.choiceWindow?.dispose()
- if useFreeLayout
- @object.choiceWindow = ui.UiFactory.createControlFromDescriptor(ui.UiFactory.customTypes["ui.FreeChoiceBox"], @object.layout)
- else
- @object.choiceWindow = ui.UiFactory.createControlFromDescriptor(ui.UiFactory.customTypes["ui.ChoiceBox"], @object.layout)
- @object.choiceWindow.events.on("selectionAccept", callback)
- @object.choiceWindow.ui.prepare()
- ###*
- * Changes the background of the scene.
- *
- * @method changeBackground
- * @param {Object} background - The background graphic object -> { name }
- * @param {boolean} noAnimation - Indicates if the background should be changed immediately witout any change-animation.
- * @param {Object} animation - The appear/disappear animation to use.
- * @param {Object} easing - The easing of the change animation.
- * @param {number} duration - The duration of the change in frames.
- * @param {number} ox - The x-origin of the background.
- * @param {number} oy - The y-origin of the background.
- * @param {number} layer - The background-layer to change.
- * @param {boolean} loopHorizontal - Indicates if the background should be looped horizontally.
- * @param {boolean} loopVertical - Indicates if the background should be looped vertically.
- ###
- changeBackground: (background, noAnimation, animation, easing, duration, ox, oy, layer, loopHorizontal, loopVertical) ->
- if background?
- otherObject = @object.backgrounds[layer]
- object = new vn.Object_Background()
- object.image = background.name
- object.origin.x = ox
- object.origin.y = oy
- object.viewport = @viewport
- object.visual.looping.vertical = no
- object.visual.looping.horizontal = no
- object.update()
- @object.backgroundContainer.setObject(object, layer)
- duration = duration ? 30
- otherObject?.zIndex = layer
- otherObject?.animator.otherObject?.dispose()
- if duration == 0
- otherObject?.dispose()
- object.visual.looping.vertical = loopVertical
- object.visual.looping.horizontal = loopHorizontal
- else
- if noAnimation
- object.visual.looping.vertical = loopVertical
- object.visual.looping.horizontal = loopHorizontal
- else
- object.animator.otherObject = otherObject
- object.animator.appear(0, 0, animation, easing, duration, (sender) =>
- sender.update()
- sender.animator.otherObject?.dispose()
- sender.animator.otherObject = null
- sender.visual.looping.vertical = loopVertical
- sender.visual.looping.horizontal = loopHorizontal
- )
- else
- @object.backgrounds[layer]?.animator.hide duration, easing, =>
- @object.backgrounds[layer].dispose()
- @object.backgrounds[layer] = null
- ###*
- * Skips all viewport animations except the main viewport animation.
- *
- * @method skipViewports
- * @protected
- ###
- skipViewports: ->
- viewports = @object.viewportContainer.subObjects
- for viewport in viewports
- if viewport
- for component in viewport.components
- component.skip?()
- return null
- ###*
- * Skips all picture animations.
- *
- * @method skipPictures
- * @protected
- ###
- skipPictures: ->
- for picture in @object.pictures
- if picture
- for component in picture.components
- component.skip?()
- return null
- ###*
- * Skips all text animations.
- *
- * @method skipTexts
- * @protected
- ###
- skipTexts: ->
- for text in @object.texts
- if text
- for component in text.components
- component.skip?()
- return null
- ###*
- * Skips all video animations but not the video-playback itself.
- *
- * @method skipVideos
- * @protected
- ###
- skipVideos: ->
- for video in @object.videos
- if video
- for component in video.components
- component.skip?()
- return null
- ###*
- * Skips all background animations.
- *
- * @method skipBackgrounds
- * @protected
- ###
- skipBackgrounds: ->
- for background in @object.backgrounds
- if background
- for component in background.components
- component.skip?()
- return null
- ###*
- * Skips all character animations
- *
- * @method skipCharacters
- * @protected
- ###
- skipCharacters: ->
- for character in @object.characters
- if character
- for component in character.components
- component.skip?()
- return null
- ###*
- * Skips the main viewport animation.
- *
- * @method skipMainViewport
- * @protected
- ###
- skipMainViewport: ->
- for component in @object.viewport.components
- component.skip?()
- return null
- ###*
- * Skips all animations of all message boxes defined in MESSAGE_BOX_IDS ui constant.
- *
- * @method skipMessageBoxes
- * @protected
- ###
- skipMessageBoxes: ->
- for messageBoxId in gs.UIConstants.MESSAGE_BOX_IDS || ["messageBox", "nvlMessageBox"]
- messageBox = gs.ObjectManager.current.objectById(messageBoxId)
- if messageBox.components
- for component in messageBox.components
- component.skip?()
- return null
- ###*
- * Skips all animations of all message areas.
- *
- * @method skipMessageAreas
- * @protected
- ###
- skipMessageAreas: ->
- for messageArea in @object.messageAreas
- if messageArea?.message
- for component in messageArea.message.components
- component.skip?()
- msg = gs.ObjectManager.current.objectById("gameMessage_message")
- if msg
- for component in msg.components
- component.skip?()
- msg = gs.ObjectManager.current.objectById("nvlGameMessage_message")
- if msg
- for component in msg.components
- component.skip?()
- return null
- ###*
- * Skips the scene interpreter timer.
- *
- * @method skipInterpreter
- * @protected
- ###
- skipInterpreter: ->
- if @object.interpreter.waitCounter > GameManager.tempSettings.skipTime
- @object.interpreter.waitCounter = GameManager.tempSettings.skipTime
- if @object.interpreter.waitCounter == 0
- @object.interpreter.isWaiting = no
- ###*
- * Skips the interpreter timer of all common events.
- *
- * @method skipCommonEvents
- * @protected
- ###
- skipCommonEvents: ->
- events = @object.commonEventContainer.subObjects
- for event in events
- if event?.interpreter and event.interpreter.waitCounter > GameManager.tempSettings.skipTime
- event.interpreter.waitCounter = GameManager.tempSettings.skipTime
- if event.interpreter.waitCounter == 0
- event.interpreter.isWaiting = no
- ###*
- * Skips the scene's content.
- *
- * @method skipContent
- * @protected
- ###
- skipContent: ->
- @skipPictures()
- @skipTexts()
- @skipVideos()
- @skipBackgrounds()
- @skipCharacters()
- @skipMainViewport()
- @skipViewports()
- @skipMessageBoxes()
- @skipMessageAreas()
- @skipInterpreter()
- @skipCommonEvents()
- ###*
- * Checks for the shortcut to hide/show the game UI. By default, this is the space-key. You
- * can override this method to change the shortcut.
- *
- * @method updateUIVisibilityShortcut
- * @protected
- ###
- updateUIVisibilityShortcut: ->
- if !@uiVisible and (Input.trigger(Input.C) or Input.Mouse.buttonDown)
- @changeUIVisibility(!@uiVisible)
- if Input.trigger(Input.KEY_SPACE)
- @changeUIVisibility(!@uiVisible)
- ###*
- * Checks for the shortcut to exit the game. By default, this is the escape-key. You
- * can override this method to change the shortcut.
- *
- * @method updateQuitShortcut
- * @protected
- ###
- updateQuitShortcut: ->
- if Input.trigger(Input.KEY_ESCAPE)
- gs.Application.exit()
- ###*
- * Checks for the shortcut to open the settings menu. By default, this is the s-key. You
- * can override this method to change the shortcut.
- *
- * @method updateSettingsShortcut
- * @protected
- ###
- updateSettingsShortcut: ->
- if GameManager.tempSettings.menuAccess and Input.trigger(Input.X)
- SceneManager.switchTo(new gs.Object_Layout("settingsMenuLayout"), true)
- ###*
- * Checks for the shortcut to open the settings menu. By default, this is the control-key. You
- * can override this method to change the shortcut.
- *
- * @method updateSkipShortcut
- * @protected
- ###
- updateSkipShortcut: ->
- if @object.settings.allowSkip
- if Input.keys[Input.KEY_CONTROL] == 1
- GameManager.tempSettings.skip = yes
- else if Input.keys[Input.KEY_CONTROL] == 2
- GameManager.tempSettings.skip = no
- ###*
- * Checks for default keyboard shortcuts e.g space-key to hide the UI, etc.
- *
- * @method updateShortcuts
- * @protected
- ###
- updateShortcuts: ->
- @updateSettingsShortcut()
- @updateQuitShortcut()
- @updateUIVisibilityShortcut()
- @updateSkipShortcut()
- ###*
- * Updates the full screen video played via Play Movie command.
- *
- * @method updateVideo
- ###
- updateVideo: ->
- if @object.video?
- @object.video.update()
- if @object.settings.allowVideoSkip and (Input.trigger(Input.C) or Input.Mouse.buttons[Input.Mouse.LEFT] == 2)
- @object.video.stop()
- Input.clear()
- ###*
- * Updates skipping if enabled.
- *
- * @method updateSkipping
- ###
- updateSkipping: ->
- if !@object.settings.allowSkip
- @object.tempSettings.skip = no
- if GameManager.tempSettings.skip
- @skipContent()
- ###*
- * Updates the scene's content.
- *
- * @method updateContent
- ###
- updateContent: ->
- #if !@object.interpreter.isRunning and !Graphics.frozen
- # @setupInterpreter()
- GameManager.scene = @object
- Graphics.viewport.update()
- @object.viewport.update()
- @updateSkipping()
- @updateVideo()
- @updateShortcuts()
- super()
- vn.Component_GameSceneBehavior = Component_GameSceneBehavior
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement