Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 03/25/2011
- #==============================================================================#
- # IEO::MENU_SYSTEM
- #==============================================================================#
- module IEO
- module MENU_SYSTEM
- MENU_LAYOUT = [
- :item,
- :skill,
- :equip,
- :status,
- :swap,
- :save,
- :system
- ]
- MS_YSPACING = 128 #96
- MS_RECTHEIGHT = 96
- MAX_MEMBERS = 3
- TOTAL_MEMBERS = 4
- end
- end
- #==============================================================================#
- # Scene_Menu
- #==============================================================================#
- class Scene_Menu < Scene_Base
- def menu_command(command)
- menulay = IEO::MENU_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
- $scene = Scene_Status.new(@status_window.index)
- when :save
- $scene = Scene_File.new(true, false, false)
- when :system
- $scene = Scene_End.new
- # // Party swapping
- when :swap
- start_swap_window
- @status_window.active = false
- end
- end
- 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
- # // Party swapping
- when :swap ; return $game_party.all_members.size < 4
- end
- end
- 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
- end
- #--------------------------------------------------------------------------#
- # * new method :start_swap_window
- #--------------------------------------------------------------------------#
- def start_swap_window
- @partyswap_window = Window_MenuPartySwap.new(0, 0)
- @partyswap_window.x = (Graphics.width - @partyswap_window.width) / 2
- @partyswap_window.y = (Graphics.height - @partyswap_window.height) / 2
- @partyswap_window.active = true
- end
- #--------------------------------------------------------------------------#
- # * overwrite method :update
- #--------------------------------------------------------------------------#
- def update
- super
- update_menu_background
- @command_window.update
- @gold_window.update
- @status_window.update
- if @command_window.active
- update_command_selection
- elsif @status_window.active
- update_actor_selection
- else
- update_swap_window unless @partyswap_window.nil?
- end
- end
- #--------------------------------------------------------------------------#
- # * new method :update_swap_window
- #--------------------------------------------------------------------------#
- def update_swap_window
- unless @partyswap_window.nil?
- @partyswap_window.update
- sindex = @status_window.index
- raid = @partyswap_window.current_actor
- raid = raid.nil? ? 0 : raid.id
- if Input.trigger?(Input::C)
- Sound.play_equip
- $game_party.change_battler_at(sindex, raid)
- end_swap_window
- @status_window.active = true
- @status_window.refresh
- elsif Input.trigger?(Input::B)
- Sound.play_cancel
- end_swap_window
- @status_window.active = true
- @status_window.refresh
- end
- end
- end
- #--------------------------------------------------------------------------#
- # * new method :end_swap_window
- #--------------------------------------------------------------------------#
- def end_swap_window
- @partyswap_window.dispose unless @partyswap_window.nil?
- end
- end
- #==============================================================================#
- # IEO::Vocab
- #==============================================================================#
- module IEO
- 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
- # // Party swapping
- when :swap ; return "Party"
- else ; return ""
- end
- end
- end
- end
- #==============================================================================#
- # IEO::Icon
- #==============================================================================#
- module IEO
- module Icon
- module_function
- def menu(command) ; return 0 end
- end
- end
- #==============================================================================
- # ** Game_Actor
- #------------------------------------------------------------------------------
- #==============================================================================
- class Game_Actor
- attr_accessor :party_lock
- alias ieo030_setup setup unless $@
- def setup(actor_id)
- @party_lock = false
- ieo030_setup(actor_id)
- end
- end # Game_Actor
- #==============================================================================
- # ** Game_Party
- #------------------------------------------------------------------------------
- # credit to Yanfly for almost everything following
- #==============================================================================
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # * constants
- #--------------------------------------------------------------------------
- TOTAL_MEMBERS = IEO::MENU_SYSTEM::TOTAL_MEMBERS
- MAX_MEMBERS = IEO::MENU_SYSTEM::MAX_MEMBERS
- #--------------------------------------------------------------------------
- # * public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :actors
- attr_accessor :battlers
- #--------------------------------------------------------------------------
- # * overwrite method: members
- #--------------------------------------------------------------------------
- def members ; return battle_members end
- #--------------------------------------------------------------------------
- # * new method: battle_members
- #--------------------------------------------------------------------------
- def battle_members
- if @battlers == nil
- @battlers = Array.new(MAX_MEMBERS).map! { |ele| ele = 0}
- for i in 0..([@actors.size, MAX_MEMBERS].min - 1)
- @battlers[i] = @actors[i]
- end
- end
- result = []
- for id in @battlers
- result.push($game_actors[id]) unless $game_actors[id] == nil
- end
- return result
- end
- def all_battle_members
- battle_members if @battlers == nil
- result = []
- for id in @battlers
- result.push($game_actors[id])
- end
- return result
- end
- #--------------------------------------------------------------------------
- # * new method: party_members
- #--------------------------------------------------------------------------
- def party_members
- result = []
- for member in battle_members
- result.push(member)
- end
- for member in all_members
- result.push(member) unless result.include?(member)
- end
- return result
- end
- #--------------------------------------------------------------------------
- # * new method: all_members
- #--------------------------------------------------------------------------
- def all_members
- result = []
- @actors.each { |aid| result << $game_actors[aid] if aid > 0}
- return result
- end
- def battle_party_size ; return MAX_MEMBERS end
- def add_actor(actor_id)
- if @actors.size < TOTAL_MEMBERS and !@actors.include?(actor_id)
- @actors.push(actor_id)
- $game_player.refresh
- end
- end
- #--------------------------------------------------------------------------
- # * new method: set_battlers
- #--------------------------------------------------------------------------
- def set_battlers(*args)
- battle_members if @battlers == nil
- old_bats = @battlers.clone
- @battlers.clear
- bats = *args
- for i in 0...battle_party_size
- bat = old_bats[i]
- @battlers[i] = 0
- @battlers[i] = old_bats[bat] if @actors.include?(bat)
- end
- $game_player.refresh
- end
- def change_battler_at(index, aid)
- battle_members if @battlers == nil
- @battlers[index] = aid
- end
- def get_empty_index
- for i in 0...battle_party_size
- return i if @battlers[i] == 0
- end
- return nil
- end
- #--------------------------------------------------------------------------
- # * alias method: add_actor
- #--------------------------------------------------------------------------
- alias add_actor_pss add_actor unless $@
- def add_actor(actor_id)
- last_size = @actors.size
- add_actor_pss(actor_id)
- if last_size < @actors.size
- battle_members if @battlers == nil
- for i in 0..(@battlers.size-1)
- if @battlers[i] == 0
- @battlers[i] = actor_id unless battle_members.size == battle_party_size
- break
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * alias method: remove_actor
- #--------------------------------------------------------------------------
- alias remove_actor_pss remove_actor unless $@
- def remove_actor(actor_id)
- battle_members if @battlers == nil
- @battlers[@battlers.index(actor_id)] = 0 if @battlers.include?(actor_id)
- remove_actor_pss(actor_id)
- end
- def battle_members_full?
- return battle_members.compact.size >= battle_party_size
- end
- end
- #==============================================================================#
- # Window_MenuStatus
- #==============================================================================#
- class Window_MenuStatus < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- # x : window X coordinate
- # y : window Y coordinate
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, 384, 416)
- @y_spacing = IEO::MENU_SYSTEM::MS_YSPACING
- @rect_height = IEO::MENU_SYSTEM::MS_RECTHEIGHT
- refresh
- self.active = false
- self.index = -1
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- @item_max = $game_party.members.size
- for actor in $game_party.members
- draw_actor_face(actor, 2, actor.index * @y_spacing + 2, 92)
- x = 104
- y = actor.index * @y_spacing + WLH / 2
- draw_actor_name(actor, x, y)
- draw_actor_class(actor, x + 120, y)
- draw_actor_level(actor, x, y + WLH * 1)
- draw_actor_state(actor, x, y + WLH * 2)
- draw_actor_hp(actor, x + 120, y + WLH * 1)
- draw_actor_mp(actor, x + 120, y + WLH * 2)
- if $imported["IEO-SkillLevelSystem"]
- rect = Rect.new(x+24, y, 96, 24)
- draw_actor_skl_p(actor, rect)
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Update cursor
- #--------------------------------------------------------------------------
- def update_cursor
- if @index < 0 # No cursor
- self.cursor_rect.empty
- elsif @index < @item_max # Normal
- self.cursor_rect.set(0, @index * @y_spacing, contents.width, @rect_height)
- elsif @index >= 100 # Self
- self.cursor_rect.set(0, (@index - 100) * @y_spacing, contents.width, @rect_height)
- else # All
- self.cursor_rect.set(0, 0, contents.width, self.height-32)
- end
- end
- end
- #==============================================================================#
- # Window_MenuCommand
- #==============================================================================#
- class Window_MenuCommand < Window_Command
- def get_current_command ; return @commands[self.index] end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_item(i, !Scene_Menu.hide_command?(@commands[i]))
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- # index : item number
- # enabled : enabled flag. When false, draw semi-transparently.
- #--------------------------------------------------------------------------
- def draw_item(index, enabled = true)
- rect = item_rect(index)
- 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 = IEO::Icon.menu(@commands[index])
- draw_icon(icon, rect.x, rect.y)
- if icon > 0
- rect.x += 24 ; rect.width -= 24
- end
- self.contents.draw_text(rect, IEO::Vocab.menu(@commands[index]))
- end
- end
- class Window_MenuPartySwap < Window_Selectable
- HEIGHT_PUSH = 72
- def initialize(px, py)
- @character_rect = Rect.new(0, 0, 32, 32)
- super(px, py, Graphics.width, HEIGHT_PUSH+32)
- @actors = $game_party.battle_members
- @item_max = $game_party.battle_party_size
- self.index = 0
- @smindex = nil
- refresh if init_refresh?
- end
- def init_refresh? ; return true end
- def current_actor ; return @actors[self.index] end
- def get_actor_at(index) ; return @actors[index] end
- def refresh
- self.contents.clear
- @actors = []
- for mem in $game_party.all_members.compact
- @actors.push(mem) unless $game_party.battle_members.include?(mem)
- end
- @actors.push(nil)
- @item_max = @actors.size
- @column_max = [1, @item_max].max
- create_contents
- for i in 0...@item_max
- draw_item(i)
- end
- end
- def draw_item(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- actor = @actors[index]
- unless actor.nil?
- aname = actor.name
- aclass = actor.class.name
- alevel = actor.level
- ash = (rect.height-@character_rect.height)/2
- locked = actor.party_lock
- ch = @character_rect.height
- draw_actor_graphic(actor, rect.x+16, rect.y+@character_rect.height+ash+4, !locked)
- self.contents.font.color.alpha = locked ? 128 : 255
- self.contents.font.size = 12
- self.contents.draw_text(rect.x+3,rect.y - 4,rect.width,24,aname)
- self.contents.draw_text(rect.x,rect.y+18,rect.width-2,24,"Lv.",2)
- self.contents.draw_text(rect.x,rect.y+28,rect.width-2,24,alevel,2)
- self.contents.draw_text(rect.x,rect.y+17+ch,rect.width-3,24,aclass,2)
- end
- end
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- rect.width = @character_rect.width + 32
- rect.height = @character_rect.height + (HEIGHT_PUSH-32)
- rect.x = index * (rect.width + 10)
- rect.y = 0
- return rect
- end
- #--------------------------------------------------------------------------
- # * Draw Actor Walking Graphic
- # actor : actor
- # x : draw spot x-coordinate
- # y : draw spot y-coordinate
- #--------------------------------------------------------------------------
- def draw_actor_graphic(actor, x, y, enabled=true)
- draw_character(actor.character_name, actor.character_index, x, y, enabled)
- end
- #--------------------------------------------------------------------------
- # * Draw Character Graphic
- # character_name : Character graphic filename
- # character_index : Character graphic index
- # x : draw spot x-coordinate
- # y : draw spot y-coordinate
- #--------------------------------------------------------------------------
- def draw_character(character_name, character_index, x, y, enabled=true)
- return if character_name == nil
- bitmap = Cache.character(character_name)
- sign = character_name[/^[\!\$]./]
- if sign != nil and sign.include?('$')
- cw = bitmap.width / 3
- ch = bitmap.height / 4
- else
- cw = bitmap.width / 12
- ch = bitmap.height / 8
- end
- n = character_index
- src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
- self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect, enabled ? 255 : 128)
- end
- end
- #==============================================================================#
- # Scene_Menu
- #==============================================================================#
- class Scene_Menu < Scene_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- # menu_index : command cursor's initial position
- #--------------------------------------------------------------------------
- def initialize(menu_index = 0)
- @menu_index = menu_index
- end
- #--------------------------------------------------------------------------
- # * Create Command Window
- #--------------------------------------------------------------------------
- def create_command_window
- s1 = Vocab::item
- s2 = Vocab::skill
- s3 = Vocab::equip
- s4 = Vocab::status
- s5 = Vocab::save
- s6 = Vocab::game_end
- coms = IEO::MENU_SYSTEM::MENU_LAYOUT
- @command_window = Window_MenuCommand.new(160, coms)
- @command_window.index = @menu_index
- end
- #--------------------------------------------------------------------------
- # * Update Command Selection
- #--------------------------------------------------------------------------
- def update_command_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- $scene = Scene_Map.new
- 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)
- start_actor_selection
- else
- menu_command(com)
- end
- end
- end
- #--------------------------------------------------------------------------
- # * 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
- end
Advertisement
Add Comment
Please, Sign In to add comment