#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
# 選單畫面中,顯示隊伍成員狀態的視窗
#==============================================================================
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● 定義案例變量
#--------------------------------------------------------------------------
attr_reader :pending_index # 保留位置(整隊用)
#--------------------------------------------------------------------------
# ● 初始化物件
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, window_width, window_height)
refresh
end
#--------------------------------------------------------------------------
# ● 取得列數 #by DisillusionSky Chen from Facebook
#--------------------------------------------------------------------------
def col_max(line)
case line
when 1
return 4
when 2
return (item_max - 4 < 0 ? 0 : item_max - 4)
end
end
#--------------------------------------------------------------------------
# ● 取得行間距的寬度 #
#--------------------------------------------------------------------------
def spacing
return 0
end
#--------------------------------------------------------------------------
# ● 取得專案數
#--------------------------------------------------------------------------
def item_max
$game_party.members.size
end
#--------------------------------------------------------------------------
# ● 取得專案的寬度 #by DisillusionSky Chen from Facebook
#--------------------------------------------------------------------------
def item_width(line)
case line
when 1
return 180
when 2
def item_width_s
return (window_width.to_f - standard_padding * 2) / col_max(2)
end
if item_width_s > 96
return 96
else
item_width_s
end
end
end
#--------------------------------------------------------------------------
# ● 取得專案的高度 #
#--------------------------------------------------------------------------
def item_height
return 320
end
#--------------------------------------------------------------------------
# ● 取得行數 #
#--------------------------------------------------------------------------
def row_max
return 2
end
#--------------------------------------------------------------------------
# ● 取得視窗的寬度 #
#--------------------------------------------------------------------------
def window_width
Graphics.width + standard_padding * 2
end
#--------------------------------------------------------------------------
# ● 取得視窗的高度 #
#--------------------------------------------------------------------------
def window_height
Graphics.height * 2
end
#--------------------------------------------------------------------------
# ● 取得當前行 #by DisillusionSky Chen from Facebook
#--------------------------------------------------------------------------
def row
index / col_max(1) > 0 ? 1 : 2 ### 避免選擇第二行過後時產生第三行以後的誤判
end
#--------------------------------------------------------------------------
# ● 取得專案的繪制矩形 #by DisillusionSky Chen from Facebook
#--------------------------------------------------------------------------
# index >= col_max(1) --> 索引在第二行時
def item_rect(index)
rect = Rect.new
rect.width = (index >= col_max(1) ? item_width(2) : item_width(1))### 專案矩形的寬度-該行的專案寬度
rect.height = item_height
unless index >= col_max(1) #索引在第一行時
rect.x = index % col_max(1) * (item_width(1) + spacing)###
else # 索引在第二行時
rect.x = (index - col_max(1)) * (item_width(2) + spacing)###
end
rect.y = (index / col_max(1)>0 ? 1 : 0) * item_height###
rect
end
#--------------------------------------------------------------------------
# ● 游標向下搬移 #by DisillusionSky Chen from Facebook
#--------------------------------------------------------------------------
def cursor_down(wrap = false)
if index < col_max(1)
select(col_max(1))
end
end
#--------------------------------------------------------------------------
# ● 游標向上搬移 #by DisillusionSky Chen from Facebook
#--------------------------------------------------------------------------
def cursor_up(wrap = false)
if index >= col_max(1)
select(col_max(1)-1)
end
end
#--------------------------------------------------------------------------
# ● 游標向右搬移 #
#--------------------------------------------------------------------------
def cursor_right(wrap = false)
if col_max(1) >= 2 && (index < item_max - 1 || (wrap && horizontal?))
select((index + 1) % item_max)
end
end
#--------------------------------------------------------------------------
# ● 游標向左搬移 #
#--------------------------------------------------------------------------
def cursor_left(wrap = false)
if col_max(1) >= 2 && (index > 0 || (wrap && horizontal?))
select((index - 1 + item_max) % item_max)
end
end
#--------------------------------------------------------------------------
# ● 繪制備戰角色肖像圖 #
# enabled : 有效的標志。false 的時候使用半透明效果繪制
#--------------------------------------------------------------------------
def draw_wait_face(face_name, face_index, x, y, enabled = true)
bitmap = Cache.face(face_name)
def face_index_x
if item_width(2) < 96
return (96 - item_width(2)) / 2
else
return 0
end
end
def face_index_width
if item_width(2) < 96
return item_width(2)
else
return 96
end
end
rect = Rect.new(face_index % 4 * 96 + face_index_x, face_index / 4 * 96, face_index_width, 96)
contents.blt(x, y, bitmap, rect)
bitmap.dispose
end
#--------------------------------------------------------------------------
# ● 繪制角色肖像圖 #
#--------------------------------------------------------------------------
def draw_wait_actor_face(actor, x, y, enabled = true)
draw_wait_face(actor.face_name, actor.face_index, x, y, enabled)
end
#--------------------------------------------------------------------------
# ● 繪制專案 #
#--------------------------------------------------------------------------
def draw_item(index)
if index >= col_max(1)
draw_item_small(index)
else
draw_item_large(index)
end
end
#--------------------------------------------------------------------------
# ● 繪制大專案 #
#--------------------------------------------------------------------------
def draw_item_large(index)
actor = $game_party.members[index]
enabled = $game_party.battle_members.include?(actor)
rect = item_rect(index)
draw_item_background(index)
draw_actor_body(actor, rect.x, rect.y, enabled)
draw_actor_name(actor, rect.x, rect.y + item_height - line_height * 4)
draw_actor_level(actor, rect.x, rect.y + item_height - line_height * 3)
draw_actor_icons(actor, rect.x + 120, rect.y + item_height - line_height * 3)
draw_actor_class(actor, rect.x + 120, rect.y + item_height - line_height * 4)
draw_actor_hp(actor, rect.x, rect.y + item_height - line_height * 2)
draw_actor_mp(actor, rect.x, rect.y + item_height - line_height * 1)
end
#--------------------------------------------------------------------------
# ● 繪制小專案 #
#--------------------------------------------------------------------------
def draw_item_small(index)
actor = $game_party.members[index]
enabled = $game_party.battle_members.include?(actor)
rect = item_rect(index)
draw_item_background(index)
draw_wait_actor_face(actor, rect.x, rect.y, enabled)
draw_actor_name(actor, rect.x, rect.y + line_height * 4)
end
#--------------------------------------------------------------------------
# ● 繪制專案的背景
#--------------------------------------------------------------------------
def draw_item_background(index)
if index == @pending_index
contents.fill_rect(item_rect(index), pending_color)
end
end
#--------------------------------------------------------------------------
# ● 按下確定鍵時的處理
#--------------------------------------------------------------------------
def process_ok
super
$game_party.menu_actor = $game_party.members[index]
end
#--------------------------------------------------------------------------
# ● 返回上一個選擇的位置
#--------------------------------------------------------------------------
def select_last
select($game_party.menu_actor.index || 0)
end
#--------------------------------------------------------------------------
# ● 設定保留位置(整隊用)
#--------------------------------------------------------------------------
def pending_index=(index)
last_pending_index = @pending_index
@pending_index = index
redraw_item(@pending_index)
redraw_item(last_pending_index)
end
end