CoffeeScript VNM Patches

Status
Not open for further replies.

Archeia

Level 99 Demi-fiend
Developer
Joined
Mar 1, 2012
Messages
14,869
Reaction score
14,965
First Language
Filipino
Primarily Uses
VNM
This topic serves as semi-official patches until the next VNM update rolls around or if by any reason you don't want to update.

Allow Shadow Property on JSON Patch
VNM Version 1.0.1093
Code:
# ===================================================================
#
#   Enable Shadow Property on JSON
#   Allows you to use shadow properties with JSON.
#
# ===================================================================

class StyleExt extends ui.Style
###
* Initializes font-data from a style-descriptor.
*
* @method setupFont
* @param {Object} descriptor - The style-descriptor.
* @protected
###
setupFont: (descriptor) ->
    if descriptor.font
        if !@font
            @font = new Font(descriptor.font.name, descriptor.font.size ? 0)
        else
            @font.name = descriptor.font.name
            @font.size = descriptor.font.size ? 0
      
        @font.bold = descriptor.font.bold ? @font.bold
        @font.italic = descriptor.font.italic ? @font.italic
        @font.smallCaps = descriptor.font.smallCaps ? @font.smallCaps
        @font.underline = descriptor.font.underline ? @font.underline
        @font.strikeThrough = descriptor.font.strikeThrough ? @font.strikeThrough
  
        if descriptor.font.color?
            @font.color.setFromArray(descriptor.font.color)
  
        if descriptor.font.border?
            @font.border = descriptor.font.border ? no
            @font.borderSize = descriptor.font.borderSize ? 4
            @font.borderColor.set(0, 0, 0, 255)
        if descriptor.font.shadow?
            @font.shadow = descriptor.font.shadow ? no
            @font.shadowOffsetX = descriptor.font.shadowOffsetX ? 2
            @font.shadowOffsetY = descriptor.font.shadowOffsetY ? 2
            @font.shadowColor.setFromArray(descriptor.font.shadowColor)
      
        if descriptor.font.outline?
            @font.border = descriptor.font.outline ? no
            @font.borderSize = descriptor.font.outline.size ? 4
      
            if descriptor.font.outline.color?
                @font.borderColor.setFromArray(descriptor.font.outline.color)
            else
                @font.borderColor.set(0, 0, 0, 255)
ui.Style = StyleExt

...
 

Archeia

Level 99 Demi-fiend
Developer
Joined
Mar 1, 2012
Messages
14,869
Reaction score
14,965
First Language
Filipino
Primarily Uses
VNM
Fix Imagemap Z-Index
VNM Version 1.0.1093
You need this to also use the fix below.
Code:
# ===================================================================
#
#   Fix ImageMap Clicking Issue
#   This fixes the instance where you can click on imagemaps behind
#   instances like the message log.
#
# ===================================================================
class Patch_ImageMap extends gs.Component_ImageMap
    ###*
    * Updates the image-map's ground and all hotspots.
    *
    * @method update
    ###
    update: ->
        super()
        @object.rIndex = @ground.rIndex
        @updateGround()

        for hotspot in @hotspots
            @updateHotspot(hotspot)

        return null

gs.Component_ImageMap = Patch_ImageMap

Fix ImageMap Clicking Issue

VNM Version 1.0.1093
Code:
# ===================================================================
#
#   Helps Fix Clicking Delays
#
# ===================================================================
class Patch_CompEventEmitter extends gs.Component_EventEmitter
    ###*
    * Emits the specified event. All observers/listeners registered for the
    * specified event are informed.
    *
    * @method emit
    * @param {string} eventName - The name of the event to fire.
    * @param {Object} [sender=null] - The sender of the event.
    * @param {Object} [data={}] - An optional object passed to each handler-function.
    ###
    emit: (eventName, sender, data) ->
        handlerLists = @handlers[eventName]
        data = data ? {} #@defaultData

        if handlerLists and @needsSort[eventName]
            @needsSort[eventName] = no
            for handlerList in handlerLists
                handlerList.sort (a, b) ->
                    if a.owner and b.owner
                        if a.owner.rIndex > b.owner.rIndex
                          return -1
                        else if a.owner.rIndex < b.owner.rIndex
                          return 1
                        else
                          return 0
                    else
                        return -1

        if handlerLists?
            breakOwner = null
            for handlerList in handlerLists by -1
                if !handlerList then continue
                i = 0
                count = handlerList.length
                @isEmitting++
                while i < count
                    handler = handlerList[i]

                    data.handler = handler
                    data.sender = sender
                    data.data = handler.data

                    if (!breakOwner and (!handler.owner or !handler.owner.visible? or handler.owner.visible)) or breakOwner == handler.owner
                        handler.handler(data)

                    if handler.once
                        @markedForRemove.push(handler)

                    if data.breakChain
                        breakOwner = handler.owner
                        break

                    i++
                @isEmitting--
                if data.breakChain
                    data.breakChain = no
            if !@isEmitting and @markedForRemove.length > 0
                for handler in @markedForRemove
                    @handlers[handler.eventName][handler.priority].remove(handler)
                @markedForRemove = []


        return null

gs.Component_EventEmitter = Patch_CompEventEmitter

More Actions for Imagemap (using JSON)
VNM Version 1.0.1093
Code:
# ===================================================================
#
#   More Actions for Imagemap
#
#   This script fixes the issue with ImageMap JSON only allowing
#   a single action property and also allows it to support conditions.
#
# ===================================================================
class Patch_ImageMapAction extends ui.Component_ActionHandler
    ###*
    * Adds event-handler for mouse/touch events to update the component only if
    * a user-action happened.
    *
    * @method setupEventHandlers
    ###
    setupEventHandlers: ->
        gs.GlobalEventManager.offByOwner("keyUp", @object)
        gs.GlobalEventManager.offByOwner("mouseUp", @object)
        gs.GlobalEventManager.offByOwner("mouseMoved", @object)
     
     
        if @object.focusable
            gs.GlobalEventManager.on "keyUp", ((e) =>
                if Input.release(Input.KEY_RETURN) and @object.ui.focused
                    @object.needsUpdate = yes
                    @executeActions()
            ), null, @object
     
        gs.GlobalEventManager.on "mouseUp", ((e) =>
            contains = Rect.contains(@object.dstRect.x, @object.dstRect.y,
                         @object.dstRect.width, @object.dstRect.height,
                         Input.Mouse.x - @object.origin.x, Input.Mouse.y - @object.origin.y)
         
            if contains
                exec = no
                actions = actions || @object.actions
                if actions?
                    for action in actions
                        exec = @checkAction(action) and !@checkActionWait(action)
                        break if exec
                     
                if exec
                    e.breakChain = yes
                    @executeActions()
                @object.needsUpdate = yes
             
        ), null, @object
     
         
        if @object.actions?.first((a) -> a and (a.event == "onMouseEnter" or a.event == "onMouseLeave" or a.event == "onMouseHover"))
            gs.GlobalEventManager.on "mouseMoved", ((e) =>
                contains = Rect.contains(@object.dstRect.x, @object.dstRect.y,
                         @object.dstRect.width, @object.dstRect.height,
                         Input.Mouse.x - @object.origin.x, Input.Mouse.y - @object.origin.y)
         
                if @containsPointer != contains
                    @containsPointer = contains
                    @object.needsUpdate = yes
            ),
            null, @object
         
        # @object.events.on "action", (e) =>
        #     actions = if e.actions then e.actions else [e.action]
        #     for action in actions
        #         @executeAction(action)
        @object.events.on "action", (e) =>
            actions = if e.actions then e.actions else [e.action]
            @executeActions(actions)


ui.Component_ActionHandler = Patch_ImageMapAction
 
Last edited:

Kentou

Admin
Admin
Joined
Jan 20, 2014
Messages
236
Reaction score
56
Change Scene Command with Variables
VNM Version 1.0.1093
Code:
class Component_ChangeSceneFixInterpreter extends gs.Component_CommandInterpreter
   ###*
   * @method commandChangeScene
   * @protected
   ###
   commandChangeScene: ->
       if GameManager.inLivePreview then return
       GameManager.tempSettings.skip = no

       if !@params.savePrevious
           SceneManager.clear()

       scene = SceneManager.scene
       if !@params.erasePictures and !@params.savePrevious
           scene.removeObject(scene.pictureContainer)
           for picture in scene.pictures
               ResourceManager.context.remove("#{picture.imageFolder}/#{picture.image}") if picture
       if !@params.eraseTexts and !@params.savePrevious
           scene.removeObject(scene.textContainer)
       if !@params.eraseVideos and !@params.savePrevious
           scene.removeObject(scene.videoContainer)
           for video in scene.videos
               ResourceManager.context.remove("#{video.videoFolder}/#{video.video}") if video

       if @params.scene
           paramScene = uid: @interpreter.stringValueOf(@params.scene.uid || @params.scene)
           if @params.savePrevious
               GameManager.sceneData = uid: uid = paramScene.uid, pictures: [], texts: [], videos: []
           else
               GameManager.sceneData = {
                   uid: uid = paramScene.uid,
                   pictures: scene.pictureContainer.subObjectsByDomain,
                   texts: scene.textContainer.subObjectsByDomain,
                   videos: scene.videoContainer.subObjectsByDomain
               }

           flags = @params.fieldFlags || {}
           isLocked = gs.CommandFieldFlags.isLocked
           newScene = new vn.Object_Scene()
           if @params.savePrevious
               newScene.sceneData = uid: uid = paramScene.uid, pictures: [], texts: [], videos: [], backlog: GameManager.backlog
           else
               newScene.sceneData = uid: uid = paramScene.uid, pictures: scene.pictureContainer.subObjectsByDomain, texts: scene.textContainer.subObjectsByDomain, videos: scene.videoContainer.subObjectsByDomain

           SceneManager.switchTo(newScene, @params.savePrevious, => @interpreter.isWaiting = no)
       else
           SceneManager.switchTo(null)

       @interpreter.isWaiting = yes
     
window.CommandInterpreter = Component_ChangeSceneFixInterpreter
gs.Component_CommandInterpreter = Component_ChangeSceneFixInterpreter
 

Kentou

Admin
Admin
Joined
Jan 20, 2014
Messages
236
Reaction score
56
Fix NVL Backlog Message Issue (Each entry contains content of previous message)
WARNING:
The rarely used Partial Message feature, if used, is not working anymore after this.
VNM Version 1.0.1093/1.0.1101
Code:
class Patch_NVLBacklog extends vn.Component_MessageBehavior
    ###*
    * Action to show a game message. PATCH: Treats each messages as a single one
    * which fixes NVL issues but not longer allows partial messages.
    *
    * @method showMessage
    * @param {Object} sender - The sender of this action.
    * @param {Object} params - An object containing the necessary parameters.
    ###
    showMessage: (sender, params) ->
        gs.GameNotifier.postContextChange(lcsm(params.message))
   
        @partial = params.partial
        @message = lcsm(params.message)
        @addMessage(params.message, RecordManager.characters[params.characterId], @object.messages.length > 0 and @object.settings.paragraphSpacing > 0, !@partial)
   
        if @object.textRenderer.isBatched()
            @object.textRenderer.waitAtEnd = yes
        else
            @object.textRenderer.waitAtEnd = !@partial

vn.Component_MessageBehavior = Patch_NVLBacklog
 

Kentou

Admin
Admin
Joined
Jan 20, 2014
Messages
236
Reaction score
56
Fixes the issue that Screen Tining, Rotating, Zooming and Panning is not restored correctly after loading a game save or coming back from another scene. (like a scene-based menu).
VNM Version 1.0.1093/1.0.1101

Installation

Create a new CoffeeScript File in Script Editor under Components > Scene and make sure that the new script file is below all other scripts in that folder. The script name can be freely choosen. Put the following contents into the script.
Code:
# ===================================================================
#
#   Script: Component_GameSceneBehaviorSaveViewportPropsFix
#
# ===================================================================
class Component_GameSceneBehaviorSaveViewportPropsFix extends vn.Component_GameSceneBehavior
    ###*
    * A fix to save and restore viewport properties like tinting and zooming in case
    * of saving the scene for later return (Previous Scene command).
    *
    * @method show
    * @param {boolean} visible - Indicates if the scene should be shown or hidden.
    ###
    show: (visible) ->
        super(visible)

        if visible
            GameManager.sceneViewport.tone = @screenTone || GameManager.sceneViewport.tone
            GameManager.sceneViewport.zoom = @screenZoom || GameManager.sceneViewport.zoom
            GameManager.sceneViewport.anchor = @screenAnchor || GameManager.sceneViewport.anchor
            SceneManager.scene.viewport.visual.scroll = @screenScroll || SceneManager.scene.viewport.visual.scroll
        else
            @screenTone = Object.copy(GameManager.sceneViewport.tone)
            @screenZoom = Object.copy(GameManager.sceneViewport.zoom)
            @screenAnchor = Object.copy(GameManager.sceneViewport.anchor)
            @screenScroll = Object.copy(SceneManager.scene.viewport.visual.scroll)

vn.Component_GameSceneBehavior = Component_GameSceneBehaviorSaveViewportPropsFix
 

Kentou

Admin
Admin
Joined
Jan 20, 2014
Messages
236
Reaction score
56
Allows to use Variables for Pan Screen command.

Installation


Create a new CoffeeScript File in Script Editor under Components > Interpreter from VNM Version 1.0.1101 and into Components directly if you are on version 1.0.1093. Make sure that the new script file is below all other scripts in that folder. The script name can be freely choosen. Put the following contents into the script.
Code:
class Component_CommandInterpreterPanScreenVariable extends gs.Component_CommandInterpreter
    ###*
    * @method commandPanScreen
    * @protected
    ###
    commandPanScreen: ->
        scene = SceneManager.scene
        duration = @interpreter.durationValueOf(@params.duration)
        easing = gs.Easings.fromObject(@params.easing)
        px = @interpreter.numberValueOf(@params.position.x)
        py = @interpreter.numberValueOf(@params.position.y)
        @interpreter.settings.screen.pan.x -= px
        @interpreter.settings.screen.pan.y -= py
        viewport = SceneManager.scene.viewport

        viewport.animator.scrollTo(-px + viewport.dstRect.x, -py + viewport.dstRect.y, duration, easing)
        @interpreter.waitForCompletion(null, @params)
        gs.GameNotifier.postMinorChange()
       
window.CommandInterpreter = Component_CommandInterpreterPanScreenVariable
gs.Component_CommandInterpreter = Component_CommandInterpreterPanScreenVariable
 

Kentou

Admin
Admin
Joined
Jan 20, 2014
Messages
236
Reaction score
56
Fixes the issue that a random background get stuck in transition screen and becomes always visible if menu is entered, scene is changed, etc.

Installation


Go script editor and create a new JavaScript File (Not CoffeeScript), call it "Clean Up Sprites" and add the content of the following paste into it:

Next create a new CoffeeScript File (Not JavaScript this time!), call it "SceneManager_BGStuckFix" and add the content of the following paste into it:

Make sure the order of the scripts is like in the attached screenshot. It is important that SceneManager_BGStuckFix is BELOW SceneManager script.
 

Attachments

Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Okay someone really needs to fix that broken railing, its a health hazard...

Is it strange that dropping acid is improving my game development?
I'm starting to wonder if I should go the Half Minute Hero route with my game. The character's main weapon is logistically way too strong. So I can't really let the player continuously grow it.... But if they had to build it up each time like HMH, that could work. Also it lets me take advantage of my randomly generated maps so much more. Hmm... This could work! :LZSexcite:

Forum statistics

Threads
99,203
Messages
962,998
Members
130,790
Latest member
neshas
Top