Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # // Last Modified :11/05/2011
- #==============================================================================#
- # FRV::MENU_SYSTEM
- #==============================================================================#
- module FRV
- module MENU_SYSTEM
- #==============================================================================#
- # Start Primary Customization
- #------------------------------------------------------------------------------#
- #==============================================================================#
- #--------------------------------------------------------------------------#
- # * MENU_LAYOUT
- #--------------------------------------------------------------------------#
- # This controls the order in which commands appear in the menu
- # Default commands
- # :item, :skill, :equip, :status, :save, :system (AKA end)
- #--------------------------------------------------------------------------#
- MENU_LAYOUT = [
- :item, # // Default Item Scene
- :skill, # // Default Skill Scene
- :equip, # // Default Equip Scene
- :status, # // Default Status Scene
- :save, # // Default Save Scene
- :system # // Default End Scene
- ] # // DO NOT REMOVE
- #==============================================================================#
- # End Primary Customization
- #------------------------------------------------------------------------------#
- #==============================================================================#
- end
- end
- #==============================================================================#
- # Scene_Menu - IEO030-Lunatic
- #==============================================================================#
- class Scene_Menu < Scene_Base
- #--------------------------------------------------------------------------#
- # * new method :menu_command
- #--------------------------------------------------------------------------#
- def menu_command( command )
- menulay = $game_system.menu_layout
- case command
- when :item
- $scene = Scene_Item.new
- when :skill
- $scene = Scene_Skill.new(@status_window.index)
- when :equip
- $scene = Scene_Equip.new(@status_window.index)
- when :status
- if $imported["IEO-LotusStatus"]
- $scene = Scene_Status.new(@status_window.index, :menu, Scene_Menu.command_index(:status))
- else
- $scene = Scene_Status.new(@status_window.index)
- end
- when :save
- $scene = Scene_File.new(true, false, false)
- when :system
- $scene = Scene_End.new
- end
- end
- #--------------------------------------------------------------------------#
- # * new class method :hide_command?
- #--------------------------------------------------------------------------#
- def self.hide_command?( com )
- case com
- when :item ; return $game_party.members.size == 0
- when :skill ; return $game_party.members.size == 0
- when :equip ; return $game_party.members.size == 0
- when :status ; return $game_party.members.size == 0
- when :save ; return $game_system.save_disabled
- when :system ; return false
- end
- return false
- end
- #--------------------------------------------------------------------------#
- # * new class method :need_actor_selection?
- #--------------------------------------------------------------------------#
- def self.need_actor_selection?( com )
- case com
- when :item ; return false
- when :skill ; return true
- when :equip ; return true
- when :status ; return true
- when :save ; return false
- when :system ; return false
- # // Party swapping
- when :swap ; return true
- end
- return false
- end
- #--------------------------------------------------------------------------#
- # * new class method :command_index
- #--------------------------------------------------------------------------#
- def self.command_index( com )
- return $game_system.menu_layout.index( com )
- end
- #--------------------------------------------------------------------------#
- # * new method :before_actor_selection
- #--------------------------------------------------------------------------#
- def before_actor_selection( lastcommand = :nil )
- end
- end
- #==============================================================================#
- # FRV::Vocab
- #==============================================================================#
- module FRV
- module Vocab
- module_function
- def menu( command )
- case command
- when :item ; return ::Vocab.item
- when :skill ; return ::Vocab.skill
- when :equip ; return ::Vocab.equip
- when :status ; return ::Vocab.status
- when :save ; return ::Vocab.save
- when :system ; return ::Vocab.game_end
- else ; return ""
- end
- end
- def menu_help( command )
- case command
- when :item ; return "Shows the party's inventory"
- when :skill ; return "Shows party member's skills"
- when :equip ; return "Shows party member's equipment"
- when :status ; return "Shows party member's status"
- when :save ; return "Save file"
- when :system ; return "System Menu"
- else ; return ""
- end
- end
- end
- end
- #==============================================================================#
- # FRV::Icon
- #==============================================================================#
- module FRV
- module Icon
- module_function
- def menu( command ) ; return 0 end
- end
- end
- #==============================================================================#
- # Game_System
- #==============================================================================#
- class Game_System
- #--------------------------------------------------------------------------#
- # * Public Instance Variables
- #--------------------------------------------------------------------------#
- attr_accessor :menu_layout
- #--------------------------------------------------------------------------#
- # * alias method :initialize
- #--------------------------------------------------------------------------#
- alias :frv_ms_gs_initialize :initialize unless $@
- def initialize()
- frv_ms_gs_initialize()
- a = FRV::MENU_SYSTEM
- @menu_layout = a::MENU_LAYOUT.clone
- end
- end
- #==============================================================================#
- # ** Window_ActorMenuStatus
- #==============================================================================#
- class Window_ActorMenuStatus < Window_Base
- BACK_BITMAP_NAME = "" #"Menu_PartyMember" # // Located in System Folder
- #--------------------------------------------------------------------------#
- # * Public Instance Variables
- #--------------------------------------------------------------------------#
- attr_accessor :actor
- def initialize(x, y, actor)
- super( x, y, 336, 80 )
- @actor = actor
- @back_sprite = Sprite.new( self.viewport )
- unless BACK_BITMAP_NAME.empty?
- @back_sprite.bitmap = Cache.system( BACK_BITMAP_NAME )
- self.opacity = 0
- end
- @back_sprite.x = self.x
- @back_sprite.y = self.y
- @back_sprite.z = self.z - 4
- refresh()
- end
- def x=( new_x )
- @back_sprite.x = new_x unless @back_sprite.nil?()
- super( new_x )
- end
- def y=( new_y )
- @back_sprite.y = new_y unless @back_sprite.nil?()
- super( new_y )
- end
- def z=( new_z )
- @back_sprite.z = new_z unless @back_sprite.nil?()
- super( new_z )
- end
- def dispose()
- @back_sprite.dispose() unless @back_sprite.nil?()
- @back_sprite = nil
- super()
- end
- def update()
- super()
- @back_sprite.update() unless @back_sprite.nil?()
- end
- def draw_face( face_name, face_index, x, y, wsize = 96, hsize = 96 )
- bitmap = Cache.face(face_name)
- rect = Rect.new( 0, 0, 0, 0 )
- rect.x = face_index % 4 * 96 + (96 - wsize) / 2
- rect.y = face_index / 4 * 96 + (96 - hsize) / 2
- rect.width = wsize
- rect.height = hsize
- self.contents.blt(x, y, bitmap, rect)
- bitmap.dispose
- end
- def draw_actor_face( actor, x, y, wsize = 96, hsize = 96 )
- draw_face( actor.face_name, actor.face_index, x, y, wsize, hsize )
- end
- def refresh()
- create_contents()
- draw_actor_face( @actor, 0, 0, 96, 48 )
- draw_actor_name( @actor, 100, 0 )
- draw_actor_hp( @actor, 224, 0, 72 )
- draw_actor_mp( @actor, 224, 16, 72 )
- draw_actor_state( @actor, 100, 24, 24*5 )
- end
- end
- #==============================================================================#
- # MenuStatus_FRV
- #==============================================================================#
- class MenuStatus_FRV < FRV::Container_Base # // Container
- def initialize( sx, sy )
- super( 0, 0, 0, 0 ) # // Dummy Container
- @x, @y, @z = sx, sy, 0
- @index = -1
- @windows = {}
- @actor_windows = []
- @reserve_index_start = 0
- @item_max = 0
- @active = true
- @inactive_ax = 10
- @active_ax = 24
- refresh()
- @start_up = true
- @windows.values.each { |w| w.x = @x - w.width }
- @start_count = 0
- end
- def active=( bool )
- @active = bool
- if bool
- @windows.values.each { |w|
- #w.opacity = 255
- #w.contents_opacity = 255
- }
- else
- @windows.values.each { |w|
- #w.opacity = 128
- #w.contents_opacity = 128
- }
- end
- end
- def active() ; return @active end
- def dispose()
- dispose_windows()
- end
- def dispose_windows()
- @actor_windows.clear()
- @windows.values.each { |w| w.dispose }
- @windows.clear()
- end
- def x=( new_x )
- return if @x == new_x
- @x = new_x
- @windows.values.each { |w| w.x = @x }
- end
- def y=( new_y )
- return if @y == new_y
- @y = new_y
- @windows.values.each { |w| w.y = @y }
- end
- def z=( new_z )
- return if @z == new_z
- @z = new_z
- @windows.values.each { |w| w.z = @z }
- end
- def refresh()
- i = 0
- dispose_windows()
- $game_party.members.each { |m|
- winm = "Actor#{i}"
- win = Window_ActorMenuStatus.new( @x + @inactive_ax, 0, m )
- win.y = @y+(win.height*i)
- @windows[winm] = win
- @actor_windows[i] = win
- @actor_windows[i].active = false
- @actor_windows[i].update
- i += 1
- }
- @item_max = @actor_windows.size()
- reset_window_positions()
- update_windows()
- end
- def update()
- update_user_input() unless @start_up or !active()
- update_windows()
- if @start_up
- bre = false
- i = 1
- @windows.values.each { |w|
- wp = w.width / 20
- tx = @x + @inactive_ax
- w.x = [w.x + wp, tx].min if (@start_count / i) > 2
- bre = !(w.x == tx)
- i += 1
- }
- @start_up = bre
- unless @start_up
- update_window_positions()
- end
- @start_count += 1
- else
- update_window_positions()
- end
- end
- def update_windows()
- @windows.values.each { |win| win.update() }
- end
- def update_window_positions()
- for i in 0...@item_max
- @actor_windows[i].x = @x + @inactive_ax
- @actor_windows[i].y = @y + (@actor_windows[i].height*i)
- @actor_windows[i].active = false
- end
- if @index > -1
- @actor_windows[@index].x = @x + @active_ax
- @actor_windows[@index].active = true
- end
- end
- def update_user_input()
- return if @item_max == 0
- if Input.trigger?( Input::UP )
- Sound.play_cursor
- @index -= 1
- @index %= @item_max
- elsif Input.trigger?( Input::DOWN )
- Sound.play_cursor
- @index += 1
- @index %= @item_max
- end
- end
- def reset_window_positions()
- for i in 0...@item_max
- @actor_windows[i].x = @x + @inactive_ax
- end
- end
- end
- #==============================================================================#
- # Window_ImageCommand
- #==============================================================================#
- class Window_ImageCommand < Window_Command
- #--------------------------------------------------------------------------#
- # * new method :get_current_command
- #--------------------------------------------------------------------------#
- def get_current_command() ; return @commands[self.index] end
- #--------------------------------------------------------------------------#
- # * overwrite method :refresh
- #--------------------------------------------------------------------------#
- def refresh()
- self.contents.clear()
- for i in 0...@item_max
- draw_item( i, !Scene_Menu.hide_command?(@commands[i]) )
- end
- end
- #--------------------------------------------------------------------------#
- # * overwrite method :item_rect
- #--------------------------------------------------------------------------#
- def item_rect( index, adapt=true )
- rect = Rect.new( 0, 0, 0, 0 )
- rect.width = ( contents.width + @spacing ) / @column_max - @spacing
- rect.height = WLH
- rect.x = index % @column_max * ( rect.width + @spacing )
- rect.y = index / @column_max * WLH
- if $imported["IEO-BugFixesUpgrades"]
- if IEO::UPGRADE::ADAPTIVE_CURSOR
- if adapt
- tx = FRV::Vocab.menu( @commands[index] )
- rect.width = self.contents.text_size( tx ).width+12
- icon = FRV::Icon.menu( @commands[index] )
- rect.width += 24 if icon > 0
- end
- end
- end
- return rect
- end
- #--------------------------------------------------------------------------#
- # * overwrite method :draw_item
- #--------------------------------------------------------------------------#
- def draw_item( index, enabled = true )
- self.contents.font.size = Font.default_size
- rect = item_rect( index, false )
- rect.x += 4
- rect.width -= 8
- self.contents.clear_rect( rect )
- self.contents.font.color = normal_color
- self.contents.font.color.alpha = enabled ? 255 : 128
- icon = FRV::Icon.menu( @commands[index] )
- if icon > 0
- draw_icon( icon, rect.x, rect.y )
- rect.x += 24 ; rect.width -= 24
- end
- self.contents.draw_text( rect, FRV::Vocab.menu( @commands[index] ) )
- end
- def help_text( index=self.index )
- return FRV::Vocab.menu_help( @commands[index] )
- end
- end
- #==============================================================================#
- # Window_MenuHelp
- #==============================================================================#
- class Window_MenuHelp < IRS::Sprite_Help ; end
- #==============================================================================#
- # Window_MenuGold
- #==============================================================================#
- class Window_MenuGold < IRS::Sprite_Gold ; end
- #==============================================================================#
- # Window_MenuLocation
- #==============================================================================#
- class Window_MenuLocation < IRS::Sprite_Location ; end
- #==============================================================================#
- # Scene_Menu
- #==============================================================================#
- class Scene_Menu < Scene_Base
- #--------------------------------------------------------------------------
- # * overwrite method :start
- #--------------------------------------------------------------------------
- def start()
- super()
- create_menu_background()
- @help_sprite = Window_MenuHelp.new( 0, 0, Graphics.width, 32 )
- create_command_window()
- @gold_window = Window_MenuGold.new( 0, 360, 128, 24 )
- @gold_window.x = Graphics.width - @gold_window.width
- @location_window = Window_MenuLocation.new( 0, 360, @gold_window.x-4, 32 )
- @status_window = MenuStatus_FRV.new( 0, @help_sprite.height )
- @status_window.active = false
- @gold_window.y = Graphics.height - @gold_window.height
- @location_window.y = Graphics.height - @location_window.height
- update_help()
- # // ----------------------------------------------------------------- // #
- @menuback_sprite.bitmap = Cache.system( "Menu_background" )
- @menuback_sprite.opacity= 255
- end
- #--------------------------------------------------------------------------
- # * Termination Processing
- #--------------------------------------------------------------------------
- def terminate()
- super()
- dispose_menu_background()
- @command_window.dispose
- @gold_window.dispose
- @status_window.dispose
- @location_window.dispose
- @help_sprite.dispose
- end
- #--------------------------------------------------------------------------#
- # * overwrite method :create_command_window
- #--------------------------------------------------------------------------#
- def create_command_window()
- coms = $game_system.menu_layout
- @command_window = Window_ImageCommand.new( 160, coms )
- @command_window.index = @menu_index
- @command_window.x = Graphics.width - @command_window.width
- @command_window.y = @help_sprite.height
- @command_window.update()
- end
- #--------------------------------------------------------------------------#
- # * new method :return_scene
- #--------------------------------------------------------------------------#
- def return_scene()
- $scene = Scene_Map.new()
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update()
- super()
- update_menu_background()
- @command_window.update()
- @gold_window.update()
- @status_window.update()
- if @command_window.active
- update_command_selection()
- update_help()
- elsif @status_window.active
- update_actor_selection()
- end
- end
- #--------------------------------------------------------------------------#
- # * new method :update_help
- #--------------------------------------------------------------------------#
- def update_help()
- @help_sprite.set_obj( @command_window.help_text() )
- end
- #--------------------------------------------------------------------------#
- # * overwrite method :update_command_selection
- #--------------------------------------------------------------------------#
- def update_command_selection()
- if Input.trigger?( Input::B )
- Sound.play_cancel
- return_scene()
- elsif Input.trigger?( Input::C )
- com = @command_window.get_current_command
- if com == nil
- Sound.play_buzzer
- return
- end
- if Scene_Menu.hide_command?( com )
- Sound.play_buzzer
- return
- end
- Sound.play_decision()
- if Scene_Menu.need_actor_selection?( com )
- before_actor_selection( com )
- start_actor_selection()
- else
- menu_command( com )
- end
- end
- end
- #--------------------------------------------------------------------------#
- # * alias method :start_actor_selection
- #--------------------------------------------------------------------------#
- alias :frv_ms_start_actor_selection :start_actor_selection unless $@
- def start_actor_selection()
- frv_ms_start_actor_selection()
- imx = @status_window.item_max()
- @status_window.index = imx if @status_window.index > imx
- end
- #--------------------------------------------------------------------------#
- # * overwrite method :update_actor_selection
- #--------------------------------------------------------------------------#
- def update_actor_selection()
- if Input.trigger?( Input::B )
- Sound.play_cancel
- end_actor_selection()
- elsif Input.trigger?( Input::C )
- $game_party.last_actor_index = @status_window.index
- com = @command_window.get_current_command()
- Sound.play_decision
- menu_command( com )
- end
- end
- #--------------------------------------------------------------------------#
- # * alias method :end_actor_selection
- #--------------------------------------------------------------------------#
- alias :frv_ms_end_actor_selection :end_actor_selection unless $@
- def end_actor_selection()
- @status_window.index = -1
- frv_ms_end_actor_selection()
- end
- end
- #==============================================================================#
- # Scene_Item
- #==============================================================================#
- class Scene_Item < Scene_Base
- #--------------------------------------------------------------------------#
- # * overwrite method :return_scene
- #--------------------------------------------------------------------------#
- def return_scene
- $scene = Scene_Menu.new( Scene_Menu.command_index(:item) )
- end
- end
- #==============================================================================#
- # Scene_Skill
- #==============================================================================#
- class Scene_Skill < Scene_Base
- #--------------------------------------------------------------------------#
- # * overwrite method :return_scene
- #--------------------------------------------------------------------------#
- def return_scene
- $scene = Scene_Menu.new( Scene_Menu.command_index(:skill) )
- end
- end
- #==============================================================================#
- # Scene_Equip
- #==============================================================================#
- class Scene_Equip < Scene_Base
- #--------------------------------------------------------------------------#
- # * overwrite method :return_scene
- #--------------------------------------------------------------------------#
- def return_scene
- $scene = Scene_Menu.new( Scene_Menu.command_index(:equip) )
- end
- end
- #==============================================================================#
- # Scene_Status
- #==============================================================================#
- class Scene_Status < Scene_Base
- #--------------------------------------------------------------------------#
- # * overwrite method :return_scene
- #--------------------------------------------------------------------------#
- def return_scene
- $scene = Scene_Menu.new( Scene_Menu.command_index(:status) )
- end
- end
- #==============================================================================#
- # Scene_File
- #==============================================================================#
- class Scene_File < Scene_Base
- #--------------------------------------------------------------------------#
- # * overwrite method :return_scene
- #--------------------------------------------------------------------------#
- def return_scene
- if @from_title
- $scene = Scene_Title.new
- elsif @from_event
- $scene = Scene_Map.new
- else
- $scene = Scene_Menu.new( Scene_Menu.command_index(:save) )
- end
- end
- end
- #==============================================================================#
- # Scene_End
- #==============================================================================#
- class Scene_End < Scene_Base
- #--------------------------------------------------------------------------#
- # * overwrite method :return_scene
- #--------------------------------------------------------------------------#
- def return_scene
- $scene = Scene_Menu.new( Scene_Menu.command_index(:system) )
- end
- end
- #=*==========================================================================*=#
- # ** END OF FILE
- #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment