Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Simple Menu
- # Author: Nicke
- # Created: 29/12/2011
- # Edited: 02/01/2012
- # Version: 1.0a
- #==============================================================================
- # Instructions
- # -----------------------------------------------------------------------------
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
- #
- # A simple menu script featuring a few functions.
- #==============================================================================
- ($imported ||= {})["NICKE-SIMPLE-MENU"] = true
- module NICKE
- module MENU
- #--------------------------------------------------------------------------#
- # * Settings
- #--------------------------------------------------------------------------#
- # Menu font settings.
- # MENU_FONT = [ font, size, bold, shadow ]
- MENU_FONT = [["Rockwell", "Tahoma"], 14, true, true]
- # When adding a new item make sure you edit in menu_command method as well.
- # Right now it supports 8 items with the appropriated methods to it.
- # CMDS [ ID ] = [ title ]
- CMDS = [] # Don't remove!
- CMDS[0] = ["Quests"]
- CMDS[1] = ["Items"]
- CMDS[2] = ["Skills"]
- CMDS[3] = ["Status"]
- CMDS[4] = ["Equip"]
- CMDS[5] = ["Save"]
- CMDS[6] = ["Load"]
- CMDS[7] = ["Quit"]
- # In here you might want to change the index so that it match up with
- # CMDS items. i.e skills should be 2 if CMDS skills is 2.
- # These are important because of status window related things and
- # save/load disabling option.
- # INDEX_SAVE and INDEX_LOAD can be nil if not in used.
- # Index = index_id
- INDEX_SKILLS = 2
- INDEX_STATUS = 3
- INDEX_EQUIP = 4
- INDEX_SAVE = 5
- INDEX_LOAD = 6
- # If you use CMDS.size the items will be pushed horizontal.
- # Bare in mind that if you add too many they will eventually go off screen.
- # WINDOW [ Columns, x, y, z, opacity, center window]
- WINDOW = [CMDS.size, 0, 0, 200, 255, false]
- # Transition, nil to use default.
- # TRANSITION [ SPEED, TRANSITION, OPACITY ]
- # TRANSITION = [40, "Graphics/Transitions/1", 50]
- TRANSITION = nil
- # Menu background image (System folder)
- # Note: You might want to decrease the opacity as well as arrange
- # the windows so that you can properly see the background.
- # Set to nil to use default.
- BACK = nil
- # Note: Not active if menu background is in use.
- # Background type:
- # 0 = radial blur
- # 1 = normal blur
- # 2 = hue change
- # 3 = gradient
- # 4 = default
- # BACK_TYPE = [ type, enabled }
- BACK_TYPE = [0, true]
- BACK_RADIAL_BLUR = [15, 50] # 0-360, 2-100
- BACK_CUSTOM_HUE = 10 # 0-360
- BACK_CUSTOM_GRADIENT = [Color.new(255,200,200,128),
- Color.new(255,200,25,128),
- true]
- # Gold window.
- # GOLD = [ x, y, z, opacity, enabled ]
- GOLD = [485, 420, 201, 0, false]
- # Status window.
- # STATUS = [ x, y, z, opacity, enabled ]
- STATUS = [0, 56, 200, 255, false]
- end
- end
- # *** Don't edit below unless you know what you are doing. ***
- #==============================================================================#
- # ** Window_MenuStatus
- #------------------------------------------------------------------------------
- # New Class :: Window_MenuStatus
- #==============================================================================#
- class Window_MenuStatus < Window_Selectable
- # // Override MenuStatus initialize so that we can specify width and height.
- def initialize(x, y, width = 384, height = 416) # Default values
- super(x, y, width, height)
- refresh
- self.active = false
- self.index = -1
- end
- end
- #==============================================================================#
- # ** Window_Command
- #------------------------------------------------------------------------------
- # New Class :: Window_Command
- #
- # Method to draw a item in the menu window.
- #==============================================================================#
- class Window_Command < Window_Selectable
- # // draw_item for Window_Command.
- alias nicke_menu_draw_item_win_menu draw_item unless $@
- def draw_item(*args, &block)
- old_size = self.contents.font.size
- self.contents.font.name = NICKE::MENU::MENU_FONT[0]
- self.contents.font.size = NICKE::MENU::MENU_FONT[1]
- self.contents.font.bold = NICKE::MENU::MENU_FONT[2]
- self.contents.font.shadow = NICKE::MENU::MENU_FONT[3]
- self.contents.font.size = old_size
- nicke_menu_draw_item_win_menu(*args, &block)
- end
- end
- #==============================================================================#
- # ** Scene_Menu
- #------------------------------------------------------------------------------
- # New Class :: Scene_Menu
- #==============================================================================#
- class Scene_Menu < Scene_Base
- # // Method initialize override.
- def initialize(index = 0)
- @command_index = index
- end
- # // Method start override.
- def start
- super
- create_menu_background
- create_command_window
- if NICKE::MENU::GOLD[4]
- @gold_window = Window_Gold.new(NICKE::MENU::GOLD[0], NICKE::MENU::GOLD[1])
- @gold_window.z = NICKE::MENU::GOLD[2]
- @gold_window.opacity = NICKE::MENU::GOLD[3]
- end
- if NICKE::MENU::STATUS[4]
- @status_window = Window_MenuStatus.new(NICKE::MENU::STATUS[0], NICKE::MENU::STATUS[1], Graphics.width, 424)
- @status_window.z = NICKE::MENU::STATUS[2]
- @status_window.opacity = NICKE::MENU::STATUS[3]
- end
- end
- # // Method terminate override.
- def terminate
- super
- dispose_menu_background
- dispose_command_window
- dispose_gold_window if NICKE::MENU::GOLD[4]
- dispose_status_window if NICKE::MENU::STATUS[4]
- end
- def create_menu_background
- @menuback_sprite = Sprite.new
- if NICKE::MENU::BACK.nil?
- @menuback_sprite.bitmap = $game_temp.background_bitmap
- if NICKE::MENU::BACK_TYPE[1]
- source = $game_temp.background_bitmap
- bitmap = Bitmap.new(Graphics.width, Graphics.height)
- bitmap.stretch_blt(bitmap.rect, source, source.rect)
- case NICKE::MENU::BACK_TYPE[0]
- when 0 ; bitmap.radial_blur(NICKE::MENU::BACK_RADIAL_BLUR[0], NICKE::MENU::BACK_RADIAL_BLUR[0])
- when 1 ; bitmap.blur
- when 2 ; bitmap.hue_change(NICKE::MENU::BACK_CUSTOM_HUE)
- when 3 ; bitmap.gradient_fill_rect(bitmap.rect, NICKE::MENU::BACK_CUSTOM_GRADIENT[0],
- NICKE::MENU::BACK_CUSTOM_GRADIENT[1], NICKE::MENU::BACK_CUSTOM_GRADIENT[2])
- when 4
- @menuback_sprite.color.set(16, 16, 16, 128)
- return
- end
- @menuback_sprite.dispose
- @menuback_sprite = Sprite.new(@viewport1)
- @menuback_sprite.bitmap = bitmap
- end
- else
- @menuback_sprite.bitmap = Cache.system(NICKE::MENU::BACK)
- end
- update_menu_background
- end
- def create_command_window
- @menu = []
- for i in NICKE::MENU::CMDS
- @menu << i[0]
- end
- @command_window = Window_Command.new(Graphics.width, @menu, NICKE::MENU::WINDOW[0])
- @command_window.index = @command_index
- if NICKE::MENU::WINDOW[5]
- @command_window.x = (Graphics.width - @command_window.width) / 2
- else
- @command_window.x = NICKE::MENU::WINDOW[1]
- end
- @command_window.y = NICKE::MENU::WINDOW[2]
- @command_window.z = NICKE::MENU::WINDOW[3]
- @command_window.opacity = NICKE::MENU::WINDOW[4]
- # // Turn off save if save disabled.
- if !NICKE::MENU::INDEX_SAVE.nil?
- if $game_system.save_disabled
- @command_window.draw_item(NICKE::MENU::INDEX_SAVE, false)
- end
- end
- # // Turn off load if no save files found.
- if !NICKE::MENU::INDEX_LOAD.nil?
- if !check_continue
- @command_window.draw_item(NICKE::MENU::INDEX_LOAD, false)
- end
- end
- @command_window.open
- end
- def dispose_command_window
- @command_window.dispose unless @command_window.nil?
- @command_window = nil
- end
- def dispose_gold_window
- @gold_window.dispose unless @gold_window.nil?
- @gold_window = nil
- end
- def dispose_status_window
- @status_window.dispose unless @status_window.nil?
- @status_window = nil
- end
- def dispose_menu_background
- @menuback_sprite.dispose unless @menuback_sprite.nil?
- @menuback_sprite = nil
- end
- def return_scene
- $scene = Scene_Map.new
- end
- def update
- super
- @command_window.update
- @gold_window.update if NICKE::MENU::GOLD[4]
- @status_window.update if NICKE::MENU::STATUS[4]
- if NICKE::MENU::STATUS[4]
- if @command_window.active
- update_command_selection
- elsif @status_window.active
- update_actor_selection
- end
- else
- update_command_selection
- end
- end
- def update_command_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- return_scene
- end
- if Input.trigger?(Input::C)
- # // Skills, Status, Equip.
- if NICKE::MENU::STATUS[4]
- # // Index should be changed if you switch positioning.
- if @command_window.index == NICKE::MENU::INDEX_SKILLS # // Skills.
- start_actor_selection
- return
- end
- if @command_window.index == NICKE::MENU::INDEX_STATUS # // Status.
- start_actor_selection
- return
- end
- if @command_window.index == NICKE::MENU::INDEX_EQUIP # // Equip.
- start_actor_selection
- return
- end
- end
- if !NICKE::MENU::INDEX_SAVE.nil?
- if @command_window.index == NICKE::MENU::INDEX_SAVE # // Save.
- if $game_system.save_disabled
- Sound.play_buzzer
- return
- end
- end
- end
- if !NICKE::MENU::INDEX_LOAD.nil?
- if @command_window.index == NICKE::MENU::INDEX_LOAD # // Load.
- if !check_continue
- Sound.play_buzzer
- return
- end
- end
- end
- case @command_window.index
- when 0...NICKE::MENU::CMDS.size
- menu_command(@command_window.index)
- end
- end
- end
- def update_actor_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- end_actor_selection
- end
- if Input.trigger?(Input::C)
- $game_party.last_actor_index = @status_window.index
- Sound.play_decision
- case @command_window.index
- when NICKE::MENU::INDEX_SKILLS # Skill.
- $scene = Scene_Skill.new(@status_window.index)
- when NICKE::MENU::INDEX_STATUS # Status.
- $scene = Scene_Status.new(@status_window.index)
- when NICKE::MENU::INDEX_EQUIP # Equip.
- $scene = Scene_Equip.new(@status_window.index)
- end
- end
- end
- def menu_command(index)
- # // Note: Changes should be made here if you wish to add more items to CMDS.
- # // i.e the index numbers should be changed if you switch order of the items.
- case index
- when 0 ; command_journal # // Imported. Can be removed or commented.
- when 1 ; command_items
- when 2 ; command_skills
- when 3 ; command_status
- when 4 ; command_equipment
- when 5 ; command_save
- when 6 ; command_load
- when 7 ; command_system
- end
- end
- def check_continue
- # // Check if any save data is available.
- @continue_enabled = (Dir.glob('Save*.rvdata').size > 0)
- end
- # // Imported from my game. You can remove it if you want.
- # // Make sure you change in menu_command as well if so.
- def command_journal
- Sound.play_decision
- $scene = Scene_Simple_Journal.new
- end
- def command_items
- Sound.play_decision
- $scene = Scene_Item.new
- end
- def command_skills
- Sound.play_decision
- $scene = Scene_Skill.new
- end
- def command_status
- Sound.play_decision
- $scene = Scene_Status.new
- end
- def command_equipment
- Sound.play_decision
- $scene = Scene_Equip.new
- end
- def command_save
- Sound.play_decision
- $scene = Scene_File.new(true, false, false)
- end
- def command_load
- Sound.play_decision
- $scene = Scene_File.new(false, false, false)
- end
- def command_system
- Sound.play_decision
- $scene = Scene_End.new
- end
- def perform_transition
- if NICKE::MENU::TRANSITION.nil?
- Graphics.transition(30)
- else
- Graphics.transition(NICKE::MENU::TRANSITION[0],NICKE::MENU::TRANSITION[1],NICKE::MENU::TRANSITION[2])
- end
- end
- end # END OF FILE
- #=*==========================================================================*=#
- # ** END OF FILE
- #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement