Galv’s Message Background V.1.3

Demo – Version 1.3 >

#------------------------------------------------------------------------------#
#  Galv's Message Background
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 1.3
#------------------------------------------------------------------------------#
#  2013-04-01 - version 1.2 - added option to disable script in battle
#  2013-02-10 - version 1.1 - dim and transparent settings work with image now
#  2012-12-02 - version 1.0 - release
#------------------------------------------------------------------------------#
#  This script displays an image file for a message background instead of using
#  the windowskin. If you are using Galv's Message Busts put this script ABOVE.
#
#  This image background will not stretch to fit, that's not it's purpose.
#  I encourage you to make your own message background images, the ones in the
#  demo are just quick examples!
#------------------------------------------------------------------------------#
#  INSTRUCTIONS:
#  Put in script list below Materials and above Main.
#
#  Read the instructions
#------------------------------------------------------------------------------#
#  SCRIPT CALL
#------------------------------------------------------------------------------#
#
#  msgbg("ImageName", y_offset)     # To change message background during game
#                                   # "ImageName" is the new file name to use
#                                   # y_offset is the new IMAGE_Y for that bg
#  EXAMPLE
#  msgbg("MsgImage", -98)
#
#------------------------------------------------------------------------------#

($imported ||= {})["Galvs_Message_Background"] = true
module Galv_Msgbg

#------------------------------------------------------------------------------#
#  SCRIPT SETTINGS
#------------------------------------------------------------------------------#

  # DEFAULT MESSAGE #

  MESSAGE_IMAGE = "MsgImage"   # Name of image in /Graphics/System to use for
                               # the message background.

  IMAGE_Y = -98                # Y offset of image

  DISABLE_SWITCH = 1   # Turn swith ON to disable image background

  DISABLE_IN_BATTLE = true  # Disable this script when in battle.

#------------------------------------------------------------------------------#
#  END SCRIPT SETTINGS
#------------------------------------------------------------------------------#

end

class Window_Message < Window_Base
  alias galv_msgbg_window_create_back_bitmap create_back_bitmap
  def create_back_bitmap
    @bg ||= Sprite.new
    if !$game_message.message_bg.nil?
      @bg.bitmap = Cache.system($game_message.message_bg)
      @current_bg = $game_message.message_bg
    end
    @bg.z = z - 1
    @bg.opacity = 0
    galv_msgbg_window_create_back_bitmap
  end

  alias galv_msgbg_window_dispose dispose
  def dispose
    galv_msgbg_window_dispose
    dispose_msgbg if !@bg.nil?
  end

  def dispose_msgbg
    @bg.dispose
    @bg.bitmap.dispose
  end

  alias galv_msgbg_window_update_back_sprite update_back_sprite
  def update_back_sprite
    if !$game_switches[Galv_Msgbg::DISABLE_SWITCH] && !$game_temp.msg_off
      update_msgbg if openness > 0
      @bg.opacity = 0 if openness == 0
    else
      galv_msgbg_window_update_back_sprite
      @bg.opacity = 0
    end
    @bg.update
    @back_sprite.update
  end

  def update_msgbg
    if $game_message.message_bg != @current_bg
      if !$game_message.message_bg.nil?
        @bg.bitmap = Cache.system($game_message.message_bg)
        @current_bg = $game_message.message_bg
      end
    end
    @bg.y = self.y + $game_message.message_bg_y
    case @background
    when 0; @bg.opacity = openness
    when 1; @bg.opacity = openness * 0.5
    when 2; @bg.opacity = 0
    end
    @back_sprite.visible = false
    self.opacity = 0
  end

end # Window_Message < Window_Base

class Game_Message
  attr_accessor :message_bg
  attr_accessor :message_bg_y

  alias galv_msgbg_message_initialize initialize
  def initialize
    galv_msgbg_message_initialize
    @message_bg = Galv_Msgbg::MESSAGE_IMAGE
    @message_bg_y = Galv_Msgbg::IMAGE_Y
  end
end # Game_Message

class Game_Temp
  attr_accessor :msg_off
end # Game_Temp

class Scene_Battle < Scene_Base
  alias galv_msgbg_sb_start start
  def start
    $game_temp.msg_off = true if Galv_Msgbg::DISABLE_IN_BATTLE
    galv_msgbg_sb_start
  end

  alias galv_msgbg_sb_terminate terminate
  def terminate
    $game_temp.msg_off = nil
    galv_msgbg_sb_terminate
  end
end # Scene_Battle < Scene_Base

class Game_Interpreter
  def msgbg(image,y_offset)
    $game_message.message_bg = image
    $game_message.message_bg_y = y_offset
  end
end # Game_Interpreter

59 thoughts on “Galv’s Message Background V.1.3