module YEA
module COMMAND_WINDOW_ICONS
ICON_HASH ={
"Items" => 260, # Menu scene. Item scene. Battle scene.
"Equipment" => 436, # Menu scene.
"Status" => 122, # Menu scene.
"Save" => 286, # Menu scene.
"Relations" => 122, # Menu scene.
} # Do not remove this.
end # COMMAND_WINDOW_ICONS
end # YEA
class Window_Command < Window_Selectable
def use_icon?(text)
return YEA::COMMAND_WINDOW_ICONS::ICON_HASH.include?(text)
end
def command_icon(text)
return YEA::COMMAND_WINDOW_ICONS::ICON_HASH[text]
end
def draw_item(index)
enabled = command_enabled?(index)
change_color(normal_color, enabled)
rect = item_rect_for_text(index)
text = command_name(index)
if use_icon?(text)
draw_icon_text(rect.clone, text, alignment, enabled)
else
draw_text(rect, text, alignment)
end
end
def draw_icon_text(rect, text, alignment, enabled)
cw = text_size(text).width
icon = command_icon(text)
draw_icon(icon, rect.x, rect.y, enabled)
rect.x += 24
rect.width -= 24
draw_text(rect, text, alignment)
end
end # Window_Command
class Window_Base < Window
def draw_actor_simple_status(actor, x, y)
draw_actor_hp(actor, x, y)
draw_actor_mp(actor, x, y + line_height * 1)
end
end
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :pending_index # Pending position (for formation)
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, window_width, window_height)
@pending_index = -1
refresh
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
Graphics.width - 0
end
#--------------------------------------------------------------------------
# * Get Window Height
#--------------------------------------------------------------------------
def window_height
Graphics.height - 160
end
#███████████████████████████████████████████████████████████████████████████████
#███████████████████████████████Euphoria Was Here███████████████████████████████
def col_max
return 2
end
#███████████████████████████████████████████████████████████████████████████████
#--------------------------------------------------------------------------
# * Get Number of Items
#--------------------------------------------------------------------------
def item_max
$game_party.members.size
end
#--------------------------------------------------------------------------
# * Get Item Height
#--------------------------------------------------------------------------
def item_height
(height - 16 * 2) / 2
end
#--------------------------------------------------------------------------
# * Get Item Width
#--------------------------------------------------------------------------
def item_width
(width - 16 * 2) / 2
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
actor = $game_party.members[index]
enabled = $game_party.battle_members.include?(actor)
rect = item_rect(index)
draw_item_background(index)
# calculate grid
#███████████████████████████████████████████████████████████████████████████████
#███████████████████████████████████And Here████████████████████████████████████
x = (index.even?) ? 0 : 276
#███████████████████████████████████████████████████████████████████████████████
y = (index / 2).to_i
y = (128) * y
draw_actor_face(actor, x + 1, y + 1, true)
draw_actor_simple_status(actor, x + 108, y)
draw_item_name(actor.equips[0], x + 108, y + 48, true)
draw_item_name(actor.equips[1], x + 108, y + 72, true)
end
#███████████████████████████████████████████████████████████████████████████████
#███████████████████████████████████And Here████████████████████████████████████
def item_rect(index)
rect = Rect.new
rect.width = 244
rect.height = item_height
if index == 1 #This
rect.x = index % col_max * (item_width + spacing) - 12 #Was
elsif index == 3 #Kind
rect.x = index % col_max * (item_width + spacing) - 12 #Of
else #Sloppy
rect.x = index % col_max * (item_width + spacing) #Coding,
end #Sorry!
rect.y = index / col_max * item_height
rect
end
#███████████████████████████████████████████████████████████████████████████████
#--------------------------------------------------------------------------
# * Draw Background for Item
#--------------------------------------------------------------------------
def draw_item_background(index)
if index == @pending_index
contents.fill_rect(item_rect(index), pending_color)
end
end
#--------------------------------------------------------------------------
# * Processing When OK Button Is Pressed
#--------------------------------------------------------------------------
def process_ok
super
$game_party.menu_actor = $game_party.members[index]
end
#--------------------------------------------------------------------------
# * Restore Previous Selection Position
#--------------------------------------------------------------------------
def select_last
select($game_party.menu_actor.index || 0)
end
#--------------------------------------------------------------------------
# * Set Pending Position (for Formation)
#--------------------------------------------------------------------------
def pending_index=(index)
last_pending_index = @pending_index
@pending_index = index
redraw_item(@pending_index)
redraw_item(last_pending_index)
end
end
#==============================================================================
# ** Window_MenuCommand
#------------------------------------------------------------------------------
# This command window appears on the menu screen.
#==============================================================================
class Window_MenuCommand < Window_Command
#--------------------------------------------------------------------------
# * Initialize Command Selection Position (Class Method)
#--------------------------------------------------------------------------
def self.init_command_position
@@last_command_symbol = nil
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0)
select_last
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return 544
end
#--------------------------------------------------------------------------
# * Get Number of Lines to Show
#--------------------------------------------------------------------------
def visible_line_number
item_max
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
add_main_commands
add_formation_command
add_original_commands
add_save_command
add_game_end_command
end
#--------------------------------------------------------------------------
# * Add Main Commands to List
#--------------------------------------------------------------------------
def add_main_commands
add_command(Vocab::item, :item, main_commands_enabled)
add_command(Vocab::equip, :equip, main_commands_enabled)
add_command(Vocab::status, :status, main_commands_enabled)
end
#--------------------------------------------------------------------------
# * Add Formation to Command List
#--------------------------------------------------------------------------
def add_formation_command
end
#--------------------------------------------------------------------------
# * For Adding Original Commands
#--------------------------------------------------------------------------
def add_original_commands
end
#--------------------------------------------------------------------------
# * Add Save to Command List
#--------------------------------------------------------------------------
def add_save_command
add_command(Vocab::save, :save, save_enabled)
end
#--------------------------------------------------------------------------
# * Add Exit Game to Command List
#--------------------------------------------------------------------------
def add_game_end_command
end
#--------------------------------------------------------------------------
# * Add Save to Command List
#--------------------------------------------------------------------------
def add_save_command
add_command(Vocab::save, :save, save_enabled)
end
#--------------------------------------------------------------------------
# * Get Activation State of Main Commands
#--------------------------------------------------------------------------
def main_commands_enabled
$game_party.exists
end
#--------------------------------------------------------------------------
# * Get Activation State of Formation
#--------------------------------------------------------------------------
def formation_enabled
$game_party.members.size >= 2 && !$game_system.formation_disabled
end
#--------------------------------------------------------------------------
# * Get Activation State of Save
#--------------------------------------------------------------------------
def save_enabled
!$game_system.save_disabled
end
#--------------------------------------------------------------------------
# * Processing When OK Button Is Pressed
#--------------------------------------------------------------------------
def process_ok
@@last_command_symbol = current_symbol
super
end
#--------------------------------------------------------------------------
# * Restore Previous Selection Position
#--------------------------------------------------------------------------
def select_last
select_symbol(@@last_command_symbol)
end
# =-=-=-=-
#--------------------------------------------------------------------------
# * Get Number of Lines to Show
#--------------------------------------------------------------------------
def visible_line_number
return 1
end
#--------------------------------------------------------------------------
# * Get Digit Count
#--------------------------------------------------------------------------
def col_max
return 4
end
#--------------------------------------------------------------------------
# * Get Spacing for Items Arranged Side by Side
#--------------------------------------------------------------------------
def spacing
return 8
end
#--------------------------------------------------------------------------
# * Calculate Width of Window Contents
#--------------------------------------------------------------------------
def contents_width
(item_width + spacing) * item_max - spacing
end
#--------------------------------------------------------------------------
# * Calculate Height of Window Contents
#--------------------------------------------------------------------------
def contents_height
item_height
end
#--------------------------------------------------------------------------
# * Get Leading Digits
#--------------------------------------------------------------------------
def top_col
ox / (item_width + spacing)
end
#--------------------------------------------------------------------------
# * Set Leading Digits
#--------------------------------------------------------------------------
def top_col=(col)
col = 0 if col < 0
col = col_max - 1 if col > col_max - 1
self.ox = col * (item_width + spacing)
end
#--------------------------------------------------------------------------
# * Get Trailing Digits
#--------------------------------------------------------------------------
def bottom_col
top_col + col_max - 1
end
#--------------------------------------------------------------------------
# * Set Trailing Digits
#--------------------------------------------------------------------------
def bottom_col=(col)
self.top_col = col - (col_max - 1)
end
#--------------------------------------------------------------------------
# * Scroll Cursor to Position Within Screen
#--------------------------------------------------------------------------
def ensure_cursor_visible
self.top_col = index if index < top_col
self.bottom_col = index if index > bottom_col
end
#--------------------------------------------------------------------------
# * Get Rectangle for Displaying Items
#--------------------------------------------------------------------------
def item_rect(index)
rect = super
rect.x = index * (item_width + spacing)
rect.y = 0
rect
end
#--------------------------------------------------------------------------
# * Get Alignment
#--------------------------------------------------------------------------
def alignment
return 1
end
#--------------------------------------------------------------------------
# * Move Cursor Down
#--------------------------------------------------------------------------
def cursor_down(wrap = false)
end
#--------------------------------------------------------------------------
# * Move Cursor Up
#--------------------------------------------------------------------------
def cursor_up(wrap = false)
end
#--------------------------------------------------------------------------
# * Move Cursor One Page Down
#--------------------------------------------------------------------------
def cursor_pagedown
end
#--------------------------------------------------------------------------
# * Move Cursor One Page Up
#--------------------------------------------------------------------------
def cursor_pageup
end
#-=-=-=-=-=-=-=-=
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs the menu screen processing.
#==============================================================================
class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
create_command_window
create_gold_window
create_status_window
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_MenuCommand.new
@command_window.y = 32
@command_window.set_handler(:item, method(:command_item))
@command_window.set_handler(:equip, method(:command_personal))
@command_window.set_handler(:status, method(:command_personal))
@command_window.set_handler(:save, method(:command_save))
@command_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# * Create Gold Window
#--------------------------------------------------------------------------
def create_gold_window
end
#--------------------------------------------------------------------------
# * Create Status Window
#--------------------------------------------------------------------------
def create_status_window
@status_window = Window_MenuStatus.new(@command_window.width, 0)
@status_window.x = 0
@status_window.y = 128
end
#--------------------------------------------------------------------------
# * [Item] Command
#--------------------------------------------------------------------------
def command_item
SceneManager.call(Scene_Item)
end
#--------------------------------------------------------------------------
# * [Skill], [Equipment] and [Status] Commands
#--------------------------------------------------------------------------
def command_personal
@status_window.select_last
@status_window.activate
@status_window.set_handler(:ok, method(:on_personal_ok))
@status_window.set_handler(:cancel, method(:on_personal_cancel))
end
#--------------------------------------------------------------------------
# * [Formation] Command
#--------------------------------------------------------------------------
def command_formation
@status_window.select_last
@status_window.activate
@status_window.set_handler(:ok, method(:on_formation_ok))
@status_window.set_handler(:cancel, method(:on_formation_cancel))
end
#--------------------------------------------------------------------------
# * [Save] Command
#--------------------------------------------------------------------------
def command_save
SceneManager.call(Scene_Save)
end
#--------------------------------------------------------------------------
# * [Exit Game] Command
#--------------------------------------------------------------------------
def command_game_end
SceneManager.call(Scene_End)
end
#--------------------------------------------------------------------------
# * [OK] Personal Command
#--------------------------------------------------------------------------
def on_personal_ok
case @command_window.current_symbol
when :skill
SceneManager.call(Scene_Skill)
when :equip
SceneManager.call(Scene_Equip)
when :status
SceneManager.call(Scene_Status)
end
end
#--------------------------------------------------------------------------
# * [Cancel] Personal Command
#--------------------------------------------------------------------------
def on_personal_cancel
@status_window.unselect
@command_window.activate
end
#--------------------------------------------------------------------------
# * Formation [OK]
#--------------------------------------------------------------------------
def on_formation_ok
if @status_window.pending_index >= 0
$game_party.swap_order(@status_window.index,
@status_window.pending_index)
@status_window.pending_index = -1
@status_window.redraw_item(@status_window.index)
else
@status_window.pending_index = @status_window.index
end
@status_window.activate
end
#--------------------------------------------------------------------------
# * Formation [Cancel]
#--------------------------------------------------------------------------
def on_formation_cancel
if @status_window.pending_index >= 0
@status_window.pending_index = -1
@status_window.activate
else
@status_window.unselect
@command_window.activate
end
end
end