def custom_action(symbol)
case symbol
when :dismiss,:sw,:in_out
return true
else
return false
end
end
def custom_on_command_ok(symbol)
case symbol
when :dismiss
do_dismiss
when :sw
do_sw
when :in_out
do_in_out
end
end
def terminate
super
end
def update
super
end
#--------------------------------------------------------------------------
# ● 队伍窗口:确定
#--------------------------------------------------------------------------
def on_party1_ok
$game_party.last_party1 = @party1_window.select_actor
@command_window.refresh
@face_window.refresh
@command_window.show.activate
@face_window.show.activate
end
#--------------------------------------------------------------------------
# ● 队伍窗口:取消
#--------------------------------------------------------------------------
def return_scene1
$game_party.last_party1 = nil
$game_party.last_party2 = nil
$game_party.inparty = true
SceneManager.return
end
#--------------------------------------------------------------------------
# ● 仓库窗口:确定
#--------------------------------------------------------------------------
def on_party2_ok
$game_party.last_party2 = @party2_window.select_actor
@command_window.refresh
@face_window.refresh
@command_window.show.activate
@face_window.show.activate
end
#--------------------------------------------------------------------------
# ● 仓库窗口:取消
#--------------------------------------------------------------------------
def return_scene2
do_sw
end
#--------------------------------------------------------------------------
# ● 命令窗口:取消
#--------------------------------------------------------------------------
def back_to_myscene
@command_window.hide.deactivate
@face_window.hide
if $game_party.inparty == true
@party1_window.activate
else
@party2_window.activate
end
end
#--------------------------------------------------------------------------
# ● 命令窗口:切换
#--------------------------------------------------------------------------
def do_sw
if $game_party.inparty == true
$game_party.inparty = false
@command_window.hide.deactivate
@face_window.hide
@party2_window.activate
else
$game_party.inparty = true
@command_window.hide.deactivate
@face_window.hide
@party1_window.activate
end
end
#--------------------------------------------------------------------------
# ● 命令窗口:存入、取出
#--------------------------------------------------------------------------
def do_in_out
if $game_party.inparty == true
#存入仓库
$game_party.party2_add_actor(@party1_window.select_actor.id)
$game_party.remove_actor(@party1_window.select_actor.id)
@command_window.hide.deactivate
@face_window.hide
@party1_window.refresh
@party2_window.refresh
@party1_window.activate
else
#取出
$game_party.add_actor(@party2_window.select_actor.id)
$game_party.party2_remove_actor(@party2_window.select_actor.id)
if $game_party.party2_all_members.count <= 0
@party1_window.refresh
@party2_window.refresh
do_sw
else
@command_window.hide.deactivate
@face_window.hide
@party1_window.refresh
@party2_window.refresh
@party2_window.activate
end
end
end
#--------------------------------------------------------------------------
# ● 命令窗口:放生
#--------------------------------------------------------------------------
def do_dismiss
if $game_party.inparty == true
$game_party.tan_remove_actor(@party1_window.select_actor.id,true)
@command_window.hide.deactivate
@face_window.hide
@party1_window.refresh
@party1_window.activate
else
$game_party.party2_remove_actor(@party2_window.select_actor.id,true)
@command_window.hide.deactivate
@face_window.hide
@party2_window.refresh
@party2_window.activate
end
end
end
#--------------------------------------------------------------------------
# ● 队伍窗口
#--------------------------------------------------------------------------
class Window_Party1 < Window_Selectable
def initialize(x, y, width, height)
super(x, y, width, height) @data = []
@last_index ||= 0
@animtime = 0 @walk = 0
refresh
select_last
end
def item_width
(width - standard_padding * 2 + spacing) / col_max - spacing
end
def item_height; item_width; end
def spacing; return 1; end
def col_max; return 2; end
def item_max; @data ? @data.size : 1; end
def select_actor; @data && index >= 0 ? @data[index] : nil; end
def current_item_enabled?
enable?(@data[index])
end
def enable?(actor)
return false if !actor
return true
end
def include?(actor)
return false if actor.nil?
return true
end
def make_item_list
@data = $game_party.members.select {|actor| include?(actor) }
@data.push(nil) if include?(nil)
end
def select_last
select(@data.index($game_party.last_party1) || 0)
end
def actor_rect(index)
rect = Rect.new
rect.width = item_width
rect.height = item_height
rect.x = index % col_max * (item_width + spacing)
rect.y = index / col_max * item_height
rect
end
def offset
Graphics.height < 480 ? 0 : 10
end
def draw_item(index)
actor = @data[index]
if actor
rect = actor_rect(index)
rect.width -= 4
draw_actor_text(actor,rect.x + 2,rect.y + 38 + offset, enable?(actor),
rect.width)
draw_character(actor.character_name, actor.character_index,
rect.x + item_width / 1.6 - 1, rect.y + 38 + offset,
enable?(actor),index)
end
end
def draw_actor_text(actor, x, y, enabled = true, w)
return unless actor
#icon1 = get_icon(:actor,actor)
#icon2 = get_icon(:weapon,actor)
#draw_icon(icon1, x + 6, y - 20, enabled)
#draw_icon(icon2, x + 6, y - 20, enabled)
change_color(normal_color, enabled)
contents.font.size = 18
draw_text(x, y, w, line_height, actor.name,1)
contents.font.size = 16
lvl = Vocab::level_a + actor.level.to_s
cname = actor.class.name
draw_text(x + 10, y - 40, w, line_height, lvl,0)
draw_text(x, y + 16, w, line_height, cname,1)
end
def draw_character(character_name, character_index, x, y,enabled,i)
return unless character_name
bitmap = Cache.character(character_name)
sign = character_name[/^[\!\$]./]
if sign && sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = character_index
step = 0
step = @walk if enabled && i == index
src_rect = Rect.new((n%4*3+1+step)*cw, (n/4*4)*ch, cw, ch)
contents.blt(x - cw / 2, y - ch, bitmap, src_rect, enabled ? 255 : 150)
end
def refresh
make_item_list
create_contents
draw_all_items
end
def update
super
update_walk
redraw_item(index)
end
def update_walk
@animtime += 1
if @animtime == 10
case @walk
when 1; @walk -= 1
when -1; @walk += 1
when 0
if @step == 1
@walk = -1; @step = 0
else
@walk = 1; @step = 1
end
end
@animtime = 0
end
end
def cursor_down(wrap = false); super; cursor_move_extras; end
def cursor_up(wrap = false); super; cursor_move_extras; end
def cursor_left(wrap = false); super; cursor_move_extras; end
def cursor_right(wrap = false); super; cursor_move_extras; end
def cursor_move_extras
@walk = 0
@animtime = 0
redraw_item(@last_index)
@last_index = index
end
end
#--------------------------------------------------------------------------
# ● 仓库窗口
#--------------------------------------------------------------------------
class Window_Party2 < Window_Selectable
def initialize(x, y, width, height)
super(x, y, width, height)
@data = []
@last_index ||= 0
@animtime = 0
@walk = 0
refresh
select_last
end
def item_width
(width - standard_padding * 2 + spacing) / col_max - spacing
end
def item_height; item_width; end
def spacing; return 1; end
def col_max; return 3; end
def item_max; @data ? @data.size : 0; end
def select_actor; @data && index >= 0 ? @data[index] : nil; end
def current_item_enabled?
enable?(@data[index])
end
def enable?(actor)
return false if !actor
return true
end
def include?(actor)
return false if actor.nil?
return true
end
def make_item_list
@data = $game_party.party2_all_members.select {|actor| include?(actor) }
@data.push(nil) if include?(nil)
end
def select_last
select(@data.index($game_party.last_party2) || 0)
end
def actor_rect(index)
rect = Rect.new
rect.width = item_width
rect.height = item_height
rect.x = index % col_max * (item_width + spacing)
rect.y = index / col_max * item_height
rect
end
def offset
Graphics.height < 480 ? 0 : 10
end
def draw_item(index)
actor = @data[index]
if actor
rect = actor_rect(index)
rect.width -= 4
draw_actor_text(actor,rect.x + 2,rect.y + 38 + offset, enable?(actor),
rect.width)
draw_character(actor.character_name, actor.character_index,
rect.x + item_width / 1.6 - 1, rect.y + 38 + offset,
enable?(actor),index)
end
end
def draw_actor_text(actor, x, y, enabled = true, w)
return unless actor
#icon1 = get_icon(:actor,actor)
#icon2 = get_icon(:weapon,actor)
#draw_icon(icon1, x + 6, y - 20, enabled)
#draw_icon(icon2, x + 6, y - 20, enabled)
change_color(normal_color, enabled)
contents.font.size = 18
draw_text(x, y, w, line_height, actor.name,1)
contents.font.size = 16
lvl = Vocab::level_a + actor.level.to_s
cname = actor.class.name
draw_text(x + 10, y - 40, w, line_height, lvl,0)
draw_text(x, y + 16, w, line_height, cname,1)
end
def draw_character(character_name, character_index, x, y,enabled,i)
return unless character_name
bitmap = Cache.character(character_name)
sign = character_name[/^[\!\$]./]
if sign && sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = character_index
step = 0
step = @walk if enabled && i == index
src_rect = Rect.new((n%4*3+1+step)*cw, (n/4*4)*ch, cw, ch)
contents.blt(x - cw / 2, y - ch, bitmap, src_rect, enabled ? 255 : 150)
end
def refresh
make_item_list
create_contents
draw_all_items
end
def update
super
update_walk
redraw_item(index)
end
def update_walk
@animtime += 1
if @animtime == 10
case @walk
when 1; @walk -= 1
when -1; @walk += 1
when 0
if @step == 1
@walk = -1; @step = 0
else
@walk = 1; @step = 1
end
end
@animtime = 0
end
end
def cursor_down(wrap = false); super; cursor_move_extras; end
def cursor_up(wrap = false); super; cursor_move_extras; end
def cursor_left(wrap = false); super; cursor_move_extras; end
def cursor_right(wrap = false); super; cursor_move_extras; end
def cursor_move_extras
@walk = 0
@animtime = 0
redraw_item(@last_index)
@last_index = index
end
end
#--------------------------------------------------------------------------
# ● 命令窗口
#--------------------------------------------------------------------------
class Window_Party2Command < Window_Command
def initialize(x,y)
super(x,y)
self.opacity = 255
self.back_opacity = 255
end
def window_width; return 160; end
def visible_line_number; item_max; end
def make_command_list
@cmd_index = []
PARTY2::CMDS.each { |cmd|
if $game_party.inparty == true
text = cmd[1][0]
else
text = cmd[1][1]
end
handle = cmd[1][2]#.delete(' ').downcase.to_sym
add_command(text,handle,check_enabled(cmd[0]))
@cmd_index << cmd[0]
}
end
def check_enabled(cmd)
if $game_party.inparty == true
actor = $game_party.last_party1
if actor == nil
return false
else
return false if cmd == :in_out && PARTY2::NO_INPARTY2.include?(actor.id)#不能存入仓库的角色ID
return false if cmd == :dismiss && PARTY2::NO_DISMISS.include?(actor.id)#不能离队的角色
end
return false if cmd == :in_out && $game_party.members.count <= 1#队伍不能为空:最后一人不能存入仓库
return false if cmd == :dismiss && $game_party.members.count <= 1#队伍不能为空:最后一人不能放生
return false if cmd == :in_out && $game_party.party2_all_members.count >= PARTY2::PARTY2MAX#仓库已满
return false if cmd == :sw && $game_party.party2_all_members.count <= 0#仓库为空不能切换
else
actor = $game_party.last_party2
if actor == nil
return false
else
return false if cmd == :dismiss && PARTY2::NO_DISMISS.include?(actor.id)#不能离队的角色
end
return false if cmd == :in_out && $game_party.all_members.count >= PARTY2::PARTY1MAX#队伍已满
end
return true
end
def draw_item(index)
change_color(normal_color, command_enabled?(index))
recti = item_rect_for_text(index)
recti.x += 26
draw_text(recti, command_name(index), alignment)
draw_icon(PARTY2::CMDS[@cmd_index[index]][3],0,recti.y)
end
end