#=begin
#------------------------------------------------------------------------------#
# 原版Galv's Army Manager
#------------------------------------------------------------------------------#
# For: RPGMAKER VX ACE
# Version 1.0
# Requested by Rue
#-------------------------------------------------------------------------------
# 有修改,改成自己适用
#-------------------------------------------------------------------------------
module Tan_party
CMDS = {
:status => ["状态", :Scene_Status, 121],
:skill => ["技能", :Scene_Skill, 14],
:order => ["移动", :order, 12],
:dismiss => ["离队", :dismiss, 187],
}
#不能移动的角色ID
NO_ORDER = [1]
#不能离队的角色ID
NO_DISMISS = [1]
end
class Game_Party
attr_accessor :last_atroop
end # Game_Party
#--------------------------------------------------------------------------
# ● 总界面
#--------------------------------------------------------------------------
class Scene_Army < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 开始
#--------------------------------------------------------------------------
def start
super
create_help_window
create_troop_window #人物窗口
create_command_window #选项窗口
create_face_window
create_menu3_bg # 背景
end
#--------------------------------------------------------------------------
# ☆ 生背景图形
#--------------------------------------------------------------------------
def create_menu3_bg
$menuback_sprite = Sprite.new
$menuback_sprite.bitmap = Cache.system("Army_back")
end
def create_help_window
@help_window = Window_ArmyHelp.new
@help_window.viewport = @viewport
@help_window.x = 0
end
def create_troop_window #人物窗口
wx = 0
wy = @help_window.height
ww = Graphics.width
wh = Graphics.height - @help_window.height
@troop_window = Window_Troops.new(wx,wy,ww,wh)
@troop_window.help_window = @help_window
@troop_window.viewport = @viewport
@troop_window.activate
@troop_window.set_handler(:ok, method(:on_troop_ok))
@troop_window.set_handler(:cancel, method(:return_scene))
@troop_window.opacity = 0 #窗口透明
end
def create_command_window
wx = Graphics.width / 2 #选项窗口
wy = (Graphics.height - @help_window.height) / 2
@command_window = Window_ArmyCommand.new(wx,wy)
@command_window.viewport = @viewport
Tan_party::CMDS.each { |cmd|
handle = cmd[1][0].delete(' ').downcase.to_sym
@command_window.set_handler(handle, method(:cmd))
}
@command_window.set_handler(:cancel, method(:back_to_troop))
@command_window.y -= @command_window.height - @help_window.height
@command_window.hide.deactivate
end
def create_face_window # 头像
ww = @command_window.width
wh = @command_window.height
wx = @command_window.x
wy = @command_window.y
@face_window = Window_ArmyFace.new(wx,wy,ww,wh)
@face_window.viewport = @viewport
@face_window.hide
end
def cmd # 确认键
list = Tan_party::CMDS.to_a
cmd = @command_window.index
symbol = list[cmd][1][1]
if custom_action(symbol)
custom_on_command_ok(symbol)
else
SceneManager.party2call(list[cmd][1][1])
end
end
def custom_action(symbol) #移动处理
case symbol
when :dismiss, :order
return true
else
return false
end
end
def custom_on_command_ok(symbol) #离队处理
case symbol
when :dismiss
do_dismiss
when :order
start_ordering
end
end
def start_ordering
if Tan_party::NO_ORDER.include?($game_party.last_atroop.id)
Sound.play_buzzer
else
@troop_window.order_on
@ordering = true
end
back_to_troop
end
def do_dismiss
@troop_window.dismiss
back_to_troop
end
def on_troop_ok
if @ordering
@troop_window.swap_actor
@ordering = false
back_to_troop
else
$game_party.last_atroop = actor
$game_party.menu_actor = actor
@command_window.refresh
@face_window.refresh
@command_window.show.activate
@face_window.show.activate
end
end
def back_to_troop
@command_window.hide.deactivate
@face_window.hide
@troop_window.activate
end
def return_scene
if @troop_window.ordering_on
@ordering = false
@troop_window.cancel_ordering
@troop_window.activate
else
$game_party.last_atroop = nil
SceneManager.return
end
end
def actor; @troop_window.actor; end
end
#--------------------------------------------------------------------------
# ● 帮助窗口
#--------------------------------------------------------------------------
class Window_ArmyHelp < Window_Help
def initialize
super(1)
end
def set_text(text)
if text != @text
@text = text
refresh
end
end
def clear
set_text("")
@actor = nil
end
def set_item(actor)
@actor = actor
set_text(actor ? create_text(actor) : "")
refresh
end
def create_text(actor) # 绘制帮助人物信息
n = actor.name
c = actor.class.name
#t = actor.nickname
l = Vocab::level_a + actor.level.to_s
text = n + " - " + l + " " + c + " " #+ t
return text
end
def refresh
contents.clear
contents.font.size = 21 if Graphics.height < 480
if @actor
offset = Graphics.width >= 640 ? 0 : -90
draw_actor_hp(@actor, 355 + offset, 0)
draw_actor_mp(@actor, 490 + offset, 0)
draw_text(12, 0, 330 + offset, line_height, @text)
end
end
end
#--------------------------------------------------------------------------
# ● 队伍窗口
#--------------------------------------------------------------------------
class Window_Troops < Window_Selectable
attr_accessor :pending_index
attr_accessor :ordering_on
def initialize(x, y, width, height)
super
@data = []
@last_index ||= 0
@animtime = 0
@walk = 0
@pending_index = -1
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 10; end
def col_max; return 6; end
def item_max; @data ? @data.size : 1; end
def actor; @data && index >= 0 ? @data[index] : nil; end
def current_item_enabled?
enable?(@data[index])
end
def include?(actor)
return false if actor.nil?
return true
end
def enable?(actor)
return false if !actor
return false if @ordering_on && Tan_party::NO_ORDER.include?(actor.id)
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_atroop) || 0)
end
def swap_actor
$game_party.swap_order($game_party.last_atroop.index,index)
@pending_index = -1
@ordering_on = nil
refresh
end
def actor_rect(index) # 第一行文字X,Y
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 - 10, rect.y + 38 + offset,
enable?(actor),index)
end
end
def draw_actor_text(actor, x, y, enabled = true, w) #人物图框信息
return unless actor
change_color(normal_color, enabled)
contents.font.size = 18 #第一行字体大小
draw_text(x, y, w , line_height, actor.name,1) #第一行字体X,Y
#lvl = Vocab::level_a + actor.level.to_s
#cname = actor.class.name
#draw_text(x + 10, y - 40, w, line_height, lvl,0)
# def text_color(n)
# n = 2
# windowskin.get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8)
# end
cname = actor.nickname
contents.font.size = 15 #第二行字体大小
draw_text(x - 20, y + 18, w + 40, 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 update_help
@help_window.set_item(actor)
end
def refresh
make_item_list
create_contents
draw_all_items
end
def order_on
@ordering_on = true
@pending_index = index
refresh
end
def cancel_ordering
@ordering_on = nil
@pending_index = -1
refresh
end
def dismiss
#$game_party.remove_actor(actor.id)
$game_party.tan_remove_actor(actor.id,true)
refresh
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_ArmyCommand < 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 = []
Tan_party::CMDS.each { |cmd|
text = cmd[1][0]
handle = text.delete(' ').downcase.to_sym
add_command(text,handle,check_enabled(cmd[0]))
@cmd_index << cmd[0]
}
end
def check_enabled(cmd)
#return false if $game_party.last_atroop == nil
return false if cmd == :dismiss && $game_party.members.count <= 20
if $game_party.last_atroop
return false if cmd == :dismiss && Tan_party::NO_DISMISS.include?($game_party.last_atroop.id)
return false if cmd == :order && Tan_party::NO_ORDER.include?($game_party.last_atroop.id)
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(Tan_party::CMDS[@cmd_index[index]][2],0,recti.y)
end
end
#--------------------------------------------------------------------------
# ● 脸图窗口
#--------------------------------------------------------------------------
class Window_ArmyFace < Window_Base
def initialize(x,y,w,h)
super(x - w,y,w,h)
self.opacity = 255
self.back_opacity = 255
end
def draw_cont
fy = (contents.height - 96) / 2
fx = (contents.width - 96) / 2
draw_actor_face($game_party.last_atroop, fx, fy)
end
def refresh
contents.clear
draw_cont
end
end
#--------------------------------------------------------------------------
# 菜单界面将原先的队伍管理修改成新的队伍管理
#--------------------------------------------------------------------------
class Scene_Menu
#--------------------------------------------------------------------------
# ● 指令“整队”
#--------------------------------------------------------------------------
def command_formation
SceneManager.call(Scene_Army)
end
end
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |