#===============================================================================
# HEIRUKICHI CUSTOM MENU BACKGROUND
#===============================================================================
# Version 1.0.0
# - Author: Heirukichi
# - Last update 06-02-2019 [MM-DD-YYYY]
#===============================================================================
# TERMS OF USE
#-------------------------------------------------------------------------------
# You are free to use this script in both commercial and non commercial games as
# long as proper credit is given to me (Heirukichi).
# Feen free to edit this script as much as you like as long as you do not
# pretend you wrote the whole script and you distribute it under the same
# license.
#
# Attribution-ShareAlike 4.0 International: https://creativecommons.org/licenses/by-sa/4.0/
#
# In addition to this I would like to be notified when this script is used in a
# commercial game. As the license says the usage of this script is free. The
# notification is only used to keep track of games where it is being used.
# You can send me a private message on RPG Maker Forums @Heirukichi.
# While doing this is not mandatory please do not forget about it.
# It helps a lot. Of course feel free to notify me when you use it for
# non-commercial games as well (if you feel like doing it).
#===============================================================================
# DESCRIPTION
#-------------------------------------------------------------------------------
# This script allows you to show a custom background image for menus. The same
# image is going to be used for each menu. It also allows you to remove that
# image (and the default one as well) and show nothing at all behind your menu.
#===============================================================================
# INSTRUCTIONS
#-------------------------------------------------------------------------------
# Instructions on how to configure this script can be found in the CONFIG module
# below.
#===============================================================================
# COMPATIBILITY
#-------------------------------------------------------------------------------
# The script should not have any compatibility issue with other scripts. However
# be sure to place it BELOW any other script that OVERWRITES one of the aliased
# methods.
# If any script you are using aliases one of the new methods in this script, be
# sure to place this one ABOVE that script.
#-------------------------------------------------------------------------------
# Classes and methods (* = aliased, + = new, ! = overwritten)
#-------------------------------------------------------------------------------
# Scene_MenuBase
# * create_background (Aliased method)
# * dispose_background (Aliased nethod)
# + hrk_create_custom_bg (New method)
#===============================================================================
module HRK_MBG
module CONFIG
#===========================================================================
# Set SWITCH_ID to be the real switch id of the switch you want to use to
# tell the engine if the background image has to be shown or not.
# Default is 50
#===========================================================================
SWITCH_ID = 50 # Change this to be your switch id
DEFAULT_VALUE = true # Set this to false if you want a background by default
#===========================================================================
# Set CUSTOM_IMAGE to true if you want to use a custom background image for
# menus. If it is set to true, you have to set a file name for the image you
# want to use. Images should be saved in "Graphics/System/".
#===========================================================================
CUSTOM_IMAGE = false
IMAGE_NAME = "menu_bg"
#===========================================================================
# Set CUSTOM_TINT to true if you want to have a different tint for the background sprite.
# When set to true, change BACKGROUND_TINT accordingly
#===========================================================================
BACKGROUND_TINT = [0, 0, 0, 255] # Red, Green, Blue, Opacity
CUSTOM_TINT = true
end # end of CONFIG module
#=============================================================================
# - - WARNING! - - Any modification after this point might prevent the script
# from working properly. Do it at your own risk.
#=============================================================================
# * True when using the background image for menus.
#-----------------------------------------------------------------------------
def self.using_bg?
$game_switches[CONFIG::SWITCH_ID] == CONFIG::DEFAULT_VALUE
end
#-----------------------------------------------------------------------------
# * True when using a custom background
#-----------------------------------------------------------------------------
def self.custom_bg?
CONFIG::CUSTOM_IMAGE
end
#-----------------------------------------------------------------------------
# * Returns the file path of custom background images
#-----------------------------------------------------------------------------
def self.menu_bg
sprintf("Graphics/System/%s", CONFIG::IMAGE_NAME)
end
#-----------------------------------------------------------------------------
# * Returns true if a custom background tint is being used
#-----------------------------------------------------------------------------
def self.bg_custom_tint?
CONFIG::CUSTOM_TINT
end
#-----------------------------------------------------------------------------
# * Custom background tint value
#-----------------------------------------------------------------------------
def self.bg_tint
CONFIG::BACKGROUND_TINT
end
#-----------------------------------------------------------------------------
# * Cached bitmap
#-----------------------------------------------------------------------------
def self.img
if @bg_img.nil?
@bg_img = Bitmap.new(menu_bg)
else
@bg_img = Bitmap.new(menu_bg) if @bg_img.disposed?
end
@bg_img
end
end # end of HRK_MBG module
#===============================================================================
# * Scene_MenuBase class
#===============================================================================
class Scene_MenuBase < Scene_Base
#-----------------------------------------------------------------------------
# * Aliased method: create_background
#-----------------------------------------------------------------------------
alias hrk_create_bg_old create_background
def create_background
if HRK_MBG.using_bg?
HRK_MBG.custom_bg? ? hrk_create_custom_bg : hrk_create_bg_old
if HRK_MBG.bg_custom_tint?
t = HRK_MBG.bg_tint
@background_sprite.color.set(t[0], t[1], t[2], t[3])
end
end
end
#-----------------------------------------------------------------------------
# + New method: hrk_create_custom_bg
#-----------------------------------------------------------------------------
def hrk_create_custom_bg
@background_sprite = Sprite.new
@background_sprite.bitmap = HRK_MBG.img
end
#-----------------------------------------------------------------------------
# * Aliased method: dispose_background
#-----------------------------------------------------------------------------
alias hrk_dispose_bg_old dispose_background
def dispose_background
hrk_dispose_bg_old if HRK_MBG.using_bg?
end
end