#==============================================================================
# Window_SwitchParty class definition
#------------------------------------------------------------------------------
# A window that displays all 4 character slots in the party, and offers a
# cursor to modify it.
#
# By exseiken, October 04, 2004
#==============================================================================
class Window_SwitchParty < Window_Selectable
#----------------------------------------------------------------------------
# Create public access variables
#----------------------------------------------------------------------------
attr_reader :new_party # The party shown in the window [R-O]
#----------------------------------------------------------------------------
# Window's constructor. Create the window's contents, makes a copy of the
# current party, then stocks it into member variable new_party, for later
# use.
#----------------------------------------------------------------------------
def initialize()
# create the window and its contents
super(0, 0, 256, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
# copy the party
@new_party = $game_party.actors.clone
# always 4 party members
@item_max = 4
# select the first character
if @new_party.size > 0
@index = @new_party.index(@new_party.first )
else
@index = 0
end
# draw the window's contents
refresh
# update the cursor rectangle
update_cursor_rect
end
#----------------------------------------------------------------------------
# Return the actor currently selected.
#----------------------------------------------------------------------------
def actor
# return the selected actor, or nil if none
@new_party[@index]
end
#----------------------------------------------------------------------------
# Update the contents of the window: clear the contents bitmap, then rebuild
# it.
#----------------------------------------------------------------------------
def refresh
# clear the contents of the bitmap
self.contents.clear
# draw each non-null party member
for i in
0..@new_party.size - 1
# get the actor
actor = @new_party[i]
# if the actor is valid, draw it on the screen
if actor != nil
# calculate the y coordinate
y = 116 * i
# draw the actor's graphic
draw_actor_graphic(actor, 24, y + 80)
# draw the actor's name
draw_actor_name(actor, 64, y + 32)
end
end
end
#----------------------------------------------------------------------------
# Update the position rectangle of the cursor.
#----------------------------------------------------------------------------
def update_cursor_rect
# reset the cursor rectangle
self.cursor_rect.set(0, 116 * @index, width - 32, 96)
end
#----------------------------------------------------------------------------
# Change the actor selected for another, then redraw the entire window.
#
# Parameters:
# actors: The actor that will replace the selected one
#----------------------------------------------------------------------------
def change_selection(actor)
# change the actor (can be nil to remove it)
@new_party[@index] = actor
# redraw the window
refresh
end
#----------------------------------------------------------------------------
# Update the help window. (Here, the help window is really the actor status
# window.)
#----------------------------------------------------------------------------
def update_help
# draw the selected actor's name, level, status conditions and stats
@help_window.draw_actor_status(@new_party[@index])
end
end
#==============================================================================
# Window_SwitchReserve class definition
#------------------------------------------------------------------------------
# A window that displays all characters available to pick in the party. Offers
# a cursor to select them
#
# By exseiken, October 04, 2004
#==============================================================================
class Window_SwitchReserve < Window_Selectable
#----------------------------------------------------------------------------
# Window constructor. Create the contents bitmap and fill it with all
# characters that are not into the party, but that are loaded in the data
# member of the Game_Actors global object.
#
# Parameters:
# max_size: The maximum of characters that can fit into that
# window
#----------------------------------------------------------------------------
def initialize(max_size)
# initialize the window and its contents
super(256, 128, 384, 352)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
# initialize the list for the first time
@actor_list = $game_actors.data.clone
# remove currently active party members
$game_party.actors.each do |actor|
@actor_list[actor.actor_id] = nil
end
# remove all actors that are unavailable
$game_actors.data.each do |actor|
if actor != nil and actor.unavailable
@actor_list[actor.actor_id] = nil
end
end
# remove all holes in the list
@actor_list.compact!
# set the maximum of characters the list can contain
@item_max = max_size
# 2 columns, 5 rows
@column_max = 2
@row_max = 5
# select the first item
@index = 0
# default: unactive
self.active = false
# draw the window's contents
refresh
# draw the cursor rectangle
update_cursor_rect
end
#----------------------------------------------------------------------------
# Update the contents of the window: clear the contents bitmap, then rebuild
# it.
#----------------------------------------------------------------------------
def refresh
# clear the contents of the bitmap
self.contents.clear
# display all actors
for i in
0..@actor_list.size # get the concerned actor
actor = @actor_list[i]
# if the actor is non-nil, draw it
if actor != nil
# get the coordinates
x = (i & 0x01) == 1 ? 176 : 0
y = (i >> 0x01) * 64
# draw the actor's sprite
draw_actor_graphic(actor, x + 24, y + 48)
# draw the actor's name
draw_actor_name(actor, x + 64, y + 16)
end
end
end
#----------------------------------------------------------------------------
# Update the position rectangle of the cursor.
#----------------------------------------------------------------------------
def update_cursor_rect
# if the screen is not active, don't display the cursor
if not active
self.cursor_rect.empty
# otherwise, display it
else
self.cursor_rect.set((@index & 0x01) == 1 ? 176 : 0, (@index >> 0x01) * 64, 176, 64)
end
end
#----------------------------------------------------------------------------
# Takes a character, put in into the list at the selected position, and
# returns the character that was presently there. If there was no
# character, returns nil.
#
# Parameters:
# actor_to_switch: The character to put at the selected position
#----------------------------------------------------------------------------
def swap_characters(actor_to_switch)
# store the old actor (needed for swapping)
old_actor = @actor_list[@index]
# put the new actor at the place
@actor_list[@index] = actor_to_switch
# redraw the window
refresh
# return the old actor
return old_actor
end
#----------------------------------------------------------------------------
# Update the help window. (Here, the help window is really the actor status
# window.)
#----------------------------------------------------------------------------
def update_help
# draw the selected actor's name, level, status conditions and stats
@help_window.draw_actor_status(@actor_list[@index])
end
end
#==============================================================================
# Window_SwitchStatus class definition
#------------------------------------------------------------------------------
# A window that displays the status of a character being selected.
#
# By exseiken, October 04, 2004
#==============================================================================
class Window_SwitchStatus < Window_Base
#----------------------------------------------------------------------------
# Construct the window: create the contents bitmap.
#----------------------------------------------------------------------------
def initialize
# create the window and initialize its contents
super(256, 0, 384, 128)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
end
#----------------------------------------------------------------------------
# Draw the status on an actor on the window's contents.
#
# Parameters:
# actor: The actor to put on the screen
#----------------------------------------------------------------------------
def draw_actor_status(actor)
# clear the contents of the bitmap
self.contents.clear
# if the actor to draw is nil, leave the window empty
if actor == nil
return
end
# draw the actor's graphic
def draw_actor_face(actor, x, y)
end
draw_actor_face(actor, x - 200, y + 80)
# draw the actor's name, level
draw_actor_name(actor, 114, 0)
draw_actor_level(actor, 188, 0)
# draw_actor_hp_meter_line(actor, x + -145, y + 50, width = 133, height = 8)
draw_actor_hp(actor, 114, 32)
# draw_actor_sp_meter_line(actor, x + -145, y + 80, width = 133, height = 8)
draw_actor_sp(actor, 114, 64)
end
end