#==============================================================================
# ■ VXAce-RGSS3-16 鍛冶屋 [ウィンドウクラス] by Claimh
#==============================================================================
#==============================================================================
# ■ Window_BsSysCmd
#==============================================================================
class Window_BsSysCmd < Window_HorzCommand
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, fitting_height(2))
end
#--------------------------------------------------------------------------
# ● 桁數の取得
#--------------------------------------------------------------------------
def col_max
item_max
end
#--------------------------------------------------------------------------
# ● コマンドリストの作成
#--------------------------------------------------------------------------
def make_command_list
Blacksmith::SYS_CMD.each_index do |i|
add_command(Blacksmith.sys_cmd[i], Blacksmith.sys_symbol(i))
end
end
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
Graphics.width - 160
end
#--------------------------------------------------------------------------
# ● 固定?
#--------------------------------------------------------------------------
def fix?
item_max == 1
end
#--------------------------------------------------------------------------
# ● 終了コマンド?
#--------------------------------------------------------------------------
def exit?
data == 2
end
#--------------------------------------------------------------------------
# ● indexデータ
#--------------------------------------------------------------------------
def data
Blacksmith::SYS_CMD[@index]
end
end
#==============================================================================
# ■ Window_BsModCmd
#==============================================================================
class Window_BsModCmd < Window_BsSysCmd
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
[url=home.php?mod=space&uid=34008]@sys[/url] = Blacksmith::SYS_CMD[0]
super
end
#--------------------------------------------------------------------------
# ● システム設定
#--------------------------------------------------------------------------
def data=(d)
[url=home.php?mod=space&uid=34008]@sys[/url] = d
clear_command_list
make_command_list
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● コマンドリストの作成
#--------------------------------------------------------------------------
def make_command_list
Blacksmith::MOD_CMD.each_index do |i|
add_command(Blacksmith.mod_cmd(@sys)[i], Blacksmith.mod_symbol(i))
end
end
#--------------------------------------------------------------------------
# ● indexデータ
#--------------------------------------------------------------------------
def data
Blacksmith::MOD_CMD[@index]
end
end
#==============================================================================
# ■ Window_BsCtg
#==============================================================================
class Window_BsCtg < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
@type = 0
super(0, fitting_height(2), Graphics.width - 160, fitting_height(1))
hide.z = 200
@index_s = [0, 0]
end
#--------------------------------------------------------------------------
# ● 固定?
#--------------------------------------------------------------------------
def fix?
Blacksmith.ctg(@type).size == 1
end
#--------------------------------------------------------------------------
# ● 桁數の取得
#--------------------------------------------------------------------------
def col_max
item_max
end
#--------------------------------------------------------------------------
# ● 項目數の取得
#--------------------------------------------------------------------------
def item_max
Blacksmith.ctg(@type).size
end
#--------------------------------------------------------------------------
# ● 橫に項目が並ぶときの空白の幅を取得
#--------------------------------------------------------------------------
def spacing
return 8
end
#--------------------------------------------------------------------------
# ● 項目を描畫する矩形の取得
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new
rect.width = 24
rect.height = item_height
rect.x = index % col_max * (item_width + spacing)
rect.y = index / col_max * item_height
rect
end
#--------------------------------------------------------------------------
# ● ■更
#--------------------------------------------------------------------------
def change(t)
@index_s[@type] = Blacksmith::S_INDEX ? [url=home.php?mod=space&uid=370741]@Index[/url] : 0
@type = t
@list = t == 0 ? Blacksmith::WT_ICON : Blacksmith::AT_ICON
create_contents
refresh
self.index = @index_s[@type]
self.index = 0 if @index < 0
end
#--------------------------------------------------------------------------
# ● 左シフト
#--------------------------------------------------------------------------
def shift_l
Sound.play_cursor
old_index = @index
cursor_left(true)
redraw_item(old_index)
redraw_item(@index)
end
#--------------------------------------------------------------------------
# ● 右シフト
#--------------------------------------------------------------------------
def shift_r
Sound.play_cursor
old_index = @index
cursor_right(true)
redraw_item(old_index)
redraw_item(@index)
end
#--------------------------------------------------------------------------
# ● 項目の描畫
#--------------------------------------------------------------------------
def draw_item(index)
draw_icon(@list[index], item_rect(index).x, 0, index == @index)
end
end
#==============================================================================
# ■ Sprite_BsTAG
#==============================================================================
class Sprite_BsTAG < Sprite
W = 100
H = 14
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, z, tag)
@viewport = Viewport.new(x, y, W, H)
super(@viewport)
self.viewport.z = z
self.bitmap = Bitmap.new(W, H)
self.bitmap.font.size = 12
self.bitmap.font.color = Color.new(192, 224, 255, 255)
refresh(tag)
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def dispose
super
@viewport.dispose
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh(tag)
self.bitmap.clear
self.bitmap.draw_text(0, 0, W, H, tag)
end
#--------------------------------------------------------------------------
# ● ウィンドウの表示
#--------------------------------------------------------------------------
def show
self.visible = true
self
end
#--------------------------------------------------------------------------
# ● ウィンドウの非表示
#--------------------------------------------------------------------------
def hide
self.visible = false
self
end
end
#==============================================================================
# ■ Window_BsListDummy
#==============================================================================
class Window_BsListDummy < Window_Base
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh(data=nil)
contents.clear
return if data.nil?
draw_item(data)
end
#--------------------------------------------------------------------------
# ● 項目描畫
#--------------------------------------------------------------------------
def draw_item(data)
change_color(normal_color, data.enable?)
x = 4
y = 0
draw_item_name(data.obj, x, y, data.enable?, 220)
if data.equip_actors.size > 0
draw_text(tag_p_x-60, y, 80, line_height, "[E]", 2)
end
draw_text(tag_n_x-50, y, 80, line_height, data.num.to_s, 2)
end
#--------------------------------------------------------------------------
# ● タグ位置(價格)
#--------------------------------------------------------------------------
def tag_p_x
self.x + self.width - 160
end
#--------------------------------------------------------------------------
# ● タグ位置(所持數)
#--------------------------------------------------------------------------
def tag_n_x
self.x + self.width - 60
end
end
#==============================================================================
# ■ Window_BsListCmn
#==============================================================================
class Window_BsListCmn < Window_Selectable
attr_accessor :pt_window
attr_accessor :sts_window
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, w, h)
super(x, y, w, h)
create_tag
@pt_window = @sts_window = nil
end
#--------------------------------------------------------------------------
# ● タグスプライト鍛造
#--------------------------------------------------------------------------
def create_tag
@sprite_p = Sprite_BsTAG.new(tag_p_x, self.y+2, win_z+10, "價格")
@sprite_n = Sprite_BsTAG.new(tag_n_x, self.y+2, win_z+10, "所持數")
end
#--------------------------------------------------------------------------
# ● タグ位置(價格)
#--------------------------------------------------------------------------
def tag_p_x
self.x + self.width - 160
end
#--------------------------------------------------------------------------
# ● タグ位置(所持數)
#--------------------------------------------------------------------------
def tag_n_x
self.x + self.width - 60
end
#--------------------------------------------------------------------------
# ● offset位置(sublist用)
#--------------------------------------------------------------------------
def offset
return 0
end
#--------------------------------------------------------------------------
# ● オブジェクト開放
#--------------------------------------------------------------------------
def dispose
super
@sprite_p.dispose
@sprite_n.dispose
end
#--------------------------------------------------------------------------
# ● 決定やキャンセルなどのハンドリング■理
#--------------------------------------------------------------------------
def process_handling
return unless open? && active
return process_ok if ok_enabled? && Input.trigger?(:C)
return process_cancel if cancel_enabled? && Input.trigger?(:B)
return process_pagedown if handle?(:pagedown) && Input.trigger?(:R)
return process_pageup if handle?(:pageup) && Input.trigger?(:L)
return process_info if handle?(:info) && Input.trigger?(:A)
return call_handler(:right) if Input.repeat?(:RIGHT)
return call_handler(:left) if Input.repeat?(:LEFT)
end
#--------------------------------------------------------------------------
# ● 決定ボタンが押されたときの■理
#--------------------------------------------------------------------------
def process_ok
super
call_handler(:alert) unless current_item_enabled?
end
#--------------------------------------------------------------------------
# ● L ボタン(PageUp)が押されたときの■理
#--------------------------------------------------------------------------
def process_pageup
Sound.play_cursor
Input.update
call_handler(:pageup)
end
#--------------------------------------------------------------------------
# ● R ボタン(PageDown)が押されたときの■理
#--------------------------------------------------------------------------
def process_pagedown
Sound.play_cursor
Input.update
call_handler(:pagedown)
end
#--------------------------------------------------------------------------
# ● 情報表示■理
#--------------------------------------------------------------------------
def process_info
if !data.nil?
Sound.play_ok
Input.update
deactivate
call_handler(:info)
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# ● 選■項目の有■狀態を取得
#--------------------------------------------------------------------------
def current_item_enabled?
enable?
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item == nil ? "" : item.description)
@pt_window.item = @sts_window.item = self.data
end
end
#==============================================================================
# ■ Window_BsList
#==============================================================================
class Window_BsList < Window_BsListCmn
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(sys=0, mod=0, ctg=0)
r = Rect.new
r.y = fitting_height(2) + fitting_height(1)
r.width = Graphics.width-120
r.height = Graphics.height - r.y - fitting_height(3)
@data = [nil, nil, nil, nil]
@tmp_bit = Bitmap.new(1, 1)
@bitmap = [[],[],[],[]]
@index_s = [[],[],[],[]]
@sys = [url=home.php?mod=space&uid=277847]@MOD[/url] = @ctg = -1
super(r.x, r.y, r.width, r.height)
@dmy_win = Window_BsListDummy.new(r.x, r.y, r.width, r.height)
self.z = win_z
change_t(sys*2+mod, ctg)
hide.dummy_show
end
#--------------------------------------------------------------------------
# ● ウィンドウのZ軸
#--------------------------------------------------------------------------
def win_z
return 200
end
#--------------------------------------------------------------------------
# ● ダミーウィンドウの表示
#--------------------------------------------------------------------------
def dummy_show
@dmy_win.show
self
end
#--------------------------------------------------------------------------
# ● ダミーウィンドウの非表示
#--------------------------------------------------------------------------
def dummy_hide
@dmy_win.hide
self
end
#--------------------------------------------------------------------------
# ● オブジェクト開放
#--------------------------------------------------------------------------
def dispose
super
@tmp_bit.dispose
@bitmap.each_index { |i| dispose_bitmap(i) }
@dmy_win.dispose
end
#--------------------------------------------------------------------------
# ● Bitmap開放
#--------------------------------------------------------------------------
def dispose_bitmap(t)
return if @bitmap[t].nil? or @bitmap[t].empty?
@bitmap[t].each do |b|
unless b.nil?
b.dispose
b = nil
end
end
end
#--------------------------------------------------------------------------
# ● 項目數の取得
#--------------------------------------------------------------------------
def item_max
return 0 if @data[type].nil?
@data[type][@ctg].size
end
#--------------------------------------------------------------------------
# ● 動作タイプ
#--------------------------------------------------------------------------
C_W=0;C_A=1;S_W=2;S_A=3
def type
return (@sys*2 + @mod)
end
#--------------------------------------------------------------------------
# ● 動作タイプ
#--------------------------------------------------------------------------
def type=(t)
@sys = t / 2
[url=home.php?mod=space&uid=277847]@MOD[/url] = t % 2
@sprite_p.refresh(@sys==0 ? "價格" : "裝備")
end
#--------------------------------------------------------------------------
# ● カテゴリ
#--------------------------------------------------------------------------
def category(t)
Blacksmith.ctg(t).size
end
#--------------------------------------------------------------------------
# ● 鍛造/強化
#--------------------------------------------------------------------------
def sys_create?
return (@sys == 0)
end
#--------------------------------------------------------------------------
# ● システムモード切り替え
#--------------------------------------------------------------------------
def change_t(t, c=0)
if self.type != t
push_index(self.type, @ctg)
self.type = t
@ctg = c
refresh_data(t) if @data[t].nil?
self.contents = @bitmap[t][c]
pop_index(t, c)
else
change_c(c)
end
end
#--------------------------------------------------------------------------
# ● カテゴリ切り替え
#--------------------------------------------------------------------------
def change_c(c)
if @ctg != c
push_index(self.type, @ctg)
@ctg = c
self.contents = @bitmap[self.type][c]
pop_index(self.type, c)
else
pop_index(self.type, c)
end
end
#--------------------------------------------------------------------------
# ● Index復元
#--------------------------------------------------------------------------
def pop_index(t, c)
self.index = (@index_s[t][c] < 0 ? 0 : @index_s[t][c])
end
#--------------------------------------------------------------------------
# ● Index記憶
#--------------------------------------------------------------------------
def push_index(t, c)
return if t < 0 or c < 0
@index_s[t][c] = Blacksmith::S_INDEX ? @index : 0
end
#--------------------------------------------------------------------------
# ● データ初期化
#--------------------------------------------------------------------------
def refresh_data(t)
case t
when C_W; @data[t] = $game_system.bs.c_w.make_list
when C_A; @data[t] = $game_system.bs.c_a.make_list
when S_W; @data[t] = $game_system.bs.s_w.make_list
when S_A; @data[t] = $game_system.bs.s_a.make_list
end
refresh_t_bitmap(t)
end
#--------------------------------------------------------------------------
# ● ビットマップ初期化
#--------------------------------------------------------------------------
def refresh_t_bitmap(t)
dispose_bitmap(t)
@bitmap[t] = []
@index_s[t] = []
category(t).times { |c| refresh_bitmap(t, c) }
end
#--------------------------------------------------------------------------
# ● カテゴリビットマップ初期化
#--------------------------------------------------------------------------
def refresh_bitmap(t, c)
num = @data[t][c].size
num = num == 0 ? 1 : num
@bitmap[t][c].dispose unless @bitmap[t][c].nil?
@bitmap[t][c] = Bitmap.new(contents_width, num * line_height)
@bitmap[t][c].font.color = normal_color
@index_s[t][c] = -1
i_refresh(t, c)
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def i_refresh(t, c)
self.contents = @bitmap[t][c]
contents.clear
@data[t][c].size.times {|i| draw_item(t, c, i) }
end
#--------------------------------------------------------------------------
# ● 全項目の描畫
#--------------------------------------------------------------------------
def draw_all_items
item_max.times {|i| draw_item(self.type, @ctg, i) }
end
#--------------------------------------------------------------------------
# ● 差分リフレッシュ
#--------------------------------------------------------------------------
def diff_refresh
@bitmap.each_index do |t|
refresh_data(t) unless @data[t].nil?
end
t = self.type
c = @ctg
self.contents = @bitmap[t][c]
@item_max = @data[t][c].size
self.index = @index >= @data[t][c].size ? (@data[t][c].size-1) : @index
self.index = 0 if @index < 0
end
#--------------------------------------------------------------------------
# ● 項目描畫
#--------------------------------------------------------------------------
def draw_item(t, c, i)
itm = data_i(t, c, i)
change_color(normal_color, itm.enable?)
x = 4
y = i * line_height
draw_item_name(itm.obj, x, y, itm.enable?, 220)
if t / 2 == 0 # create
draw_text(tag_p_x-60, y, 80, line_height, itm.price.to_s, 2)
elsif itm.equip_actors.size > 0
draw_text(tag_p_x-60, y, 80, line_height, "[E]", 2)
end
draw_text(tag_n_x-50, y, 80, line_height, itm.num.to_s, 2)
end
#--------------------------------------------------------------------------
# ● アイテム取得
#--------------------------------------------------------------------------
def item_list
return @data[self.type][@ctg]
end
def data_i(t, c, i)
return nil if i < 0 or i >= @data[t][c].size
return @data[t][c][i]
end
def data
return data_i(self.type, @ctg, @index)
end
def item_i(t, c, i)
return nil if i < 0 or i >= @data[t][c].size
return @data[t][c][i].obj
end
def item
return item_i(self.type, @ctg, @index)
end
#--------------------------------------------------------------------------
# ● 有■Index?
#--------------------------------------------------------------------------
def enable_i?(t, c, i)
d = data_i(t, c, i)
return (d.nil? ? false : d.enable?)
end
def enable?
return enable_i?(self.type, @ctg, @index)
end
#--------------------------------------------------------------------------
# ● ダミーウィンドウのリフレッシュ
#--------------------------------------------------------------------------
def dummy_refresh
@dmy_win.refresh(data)
end
#--------------------------------------------------------------------------
# ● ダミーウィンドウのクリア
#--------------------------------------------------------------------------
def dummy_clear
@dmy_win.refresh(nil)
end
end
#==============================================================================
# ■ Window_BsSList
#==============================================================================
class Window_BsSList < Window_BsListCmn
attr_accessor :pt_window
attr_accessor :sts_window
OFFSET = 16
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(win)
@data = nil
@slist = []
l = line_height + standard_padding
super(win.x+offset, win.y+l, win.width-offset, win.height-l)
hide
end
def win_z
return 210
end
def offset
return 16
end
#--------------------------------------------------------------------------
# ● ウィンドウの表示
#--------------------------------------------------------------------------
def show
@sprite_p.show
@sprite_n.show
super
end
#--------------------------F------------------------------------------------
# ● ウィンドウの非表示
#--------------------------------------------------------------------------
def hide
@sprite_p.hide
@sprite_n.hide
super
end
#--------------------------------------------------------------------------
# ● 項目數の取得
#--------------------------------------------------------------------------
def item_max
@slist.size
end
#--------------------------------------------------------------------------
# ● 起動
#--------------------------------------------------------------------------
def startup(data)
show.activate
if @data != data
@data = data
@slist = @data.make_slist
create_contents
change_color(normal_color)
refresh
end
self.index = 0
end
#--------------------------------------------------------------------------
# ● 項目描畫
#--------------------------------------------------------------------------
def draw_item(index)
itm = data_i(index)
change_color(normal_color, enable_i?(index))
r = item_rect_for_text(index)
draw_item_name(itm.obj, r.x, r.y, enable_i?(index), 220)
draw_text(tag_p_x-60-offset, r.y, 80, line_height, itm.price.to_s, 2)
draw_text(tag_n_x-50-offset, r.y, 80, line_height, itm.num.to_s, 2)
end
#--------------------------------------------------------------------------
# ● アイテム取得
#--------------------------------------------------------------------------
def data_i(i)
return nil if i < 0
return @slist[i]
end
def data
return data_i(@index)
end
def item_i(i)
return nil if i < 0
return @slist[i].obj
end
def item
return item_i(@index)
end
#--------------------------------------------------------------------------
# ● 有■Index?
#--------------------------------------------------------------------------
def enable_i?(i)
return data_i(i).enable?
end
def enable?
return enable_i?(@index)
end
end
#==============================================================================
# ■ Window_BsActors
#==============================================================================
class Window_BsActors < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
@hh = @page = 0
@item = nil
clear_exchange
y = fitting_height(2) + fitting_height(1)
h = Graphics.height - y - fitting_height(3)
super(Graphics.width-120, y, 120, h)
unselect
refresh
end
#--------------------------------------------------------------------------
# ● 固定パターン?
#--------------------------------------------------------------------------
def fix?
item_max < page_size
end
#--------------------------------------------------------------------------
# ● 裝備交換可能か?
#--------------------------------------------------------------------------
def equip_exchange_ok?(actor, item)
return true unless @exchange
return false unless actor.equips.include?(item)
equip_change_ok?(actor, item)
end
#--------------------------------------------------------------------------
# ● 裝備可能か?
#--------------------------------------------------------------------------
def equip_ok?(actor, item)
return false unless actor.equippable?(item)
actor.slot_list(item.etype_id).any? { |s| actor.equip_change_ok?(s) }
end
#--------------------------------------------------------------------------
# ● 裝備交換可能slotか?
#--------------------------------------------------------------------------
def equip_change_ok?(actor, item)
actor.slot_list(item.etype_id).any? { |s| actor.equip_change_ok?(s) }
end
#--------------------------------------------------------------------------
# ● 可否判定
#--------------------------------------------------------------------------
def enable_i?(index)
return false if @item.nil? or index < 0
a = data_i(index)
return false if !equip_exchange_ok?(a, @equip_item)
equip_ok?(a, @item.obj)
end
def enable?
return enable_i?(@index)
end
#--------------------------------------------------------------------------
# ● アクター情報
#--------------------------------------------------------------------------
def data_i(index)
return nil if index < 0
$game_party.members[index]
end
def actor
data_i(@index)
end
#--------------------------------------------------------------------------
# ● 裝備交換モード
#--------------------------------------------------------------------------
def set_exchange(equip_item)
@exchange = true
@equip_item = equip_item
refresh
end
def clear_exchange(re=false)
@exchange = false
@equip_item = nil
refresh if re
end
#--------------------------------------------------------------------------
# ● 項目數の取得
#--------------------------------------------------------------------------
def item_max
$game_party.members.size
end
#--------------------------------------------------------------------------
# ● 項目の高さを取得
#--------------------------------------------------------------------------
def item_height
h = height - standard_padding * 2
h / page_size
end
#--------------------------------------------------------------------------
# ● 選■項目の有■狀態を取得
#--------------------------------------------------------------------------
def current_item_enabled?
enable?
end
#--------------------------------------------------------------------------
# ● 一度に表示できるアクターの人數
#--------------------------------------------------------------------------
def page_size
return 4
end
#--------------------------------------------------------------------------
# ● 最大ページ數の取得
#--------------------------------------------------------------------------
def page_max
(item_max + page_size - 1) / page_size
end
#--------------------------------------------------------------------------
# ● 項目數の取得
#--------------------------------------------------------------------------
def next_page
@page = (@page + 1) % page_max
self.top_row = @page * page_size
end
#--------------------------------------------------------------------------
# ● アイテムの設定
# item : 新しいアイテム
#--------------------------------------------------------------------------
def item=(item)
return if @item == item
@item = item
refresh
end
#--------------------------------------------------------------------------
# ● 項目の描畫
#--------------------------------------------------------------------------
def draw_item(index)
actor = data_i(index)
r = item_rect(index)
e = enable_i?(index)
hh = (r.height+32)/2
draw_actor_graphic(actor, 20, r.y + hh, e)
return if @item.nil? or !@item.obj.is_a?(RPG::EquipItem)
return unless equip_ok?(actor, @item.obj)
prms = @item.obj.is_a?(RPG::Weapon) ? [2,4] : [3,5]
equips = actor.equips.select { |a| a != nil }
equips = equips.select { |a| a.etype_id == @item.obj.etype_id }
r.y += r.height / 2 - line_height
prms.each_index do |i|
diff = diff_item_param(equips, prms[i])
draw_item_diff(28, r.y+i*(line_height),diff, e, prms[i])
end
end
#--------------------------------------------------------------------------
# ● グラフィックの描畫
#--------------------------------------------------------------------------
def draw_actor_graphic(actor, x, y, enble)
return if actor == nil
bitmap = Cache.character(actor.character_name)
sign = actor.character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = actor.character_index
src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect, enble ? 255 : translucent_alpha)
end
#--------------------------------------------------------------------------
# ● アイテムパラメータ差分取得
#--------------------------------------------------------------------------
def diff_item_param(equips, prm)
e_items = equips.sort { |a, b| b.params[prm] - a.params[prm] }
new_prm = e_items.empty? ? 0 : e_items[0].params[prm]
return @item.obj.params[prm] - new_prm
end
#--------------------------------------------------------------------------
# ● 裝備差分■の描畫
#--------------------------------------------------------------------------
def draw_item_diff(x, y, change, able, prm)
change_color(param_change_color(change), able)
draw_text(x, y, contents_width-x-4, line_height, Vocab::param(prm)+sprintf("%+d",change), 2)
end
end
#==============================================================================
# ■ Window_BsYesNo
#==============================================================================
class Window_BsYesNo < Window_Selectable
CMD = ["はい", "いいえ"]
#--------------------------------------------------------------------------
# ● X座標
#--------------------------------------------------------------------------
def xx(w)
(Graphics.width-w) / 2
end
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
h = fitting_height(3)
y = (Graphics.height - h) / 2
super(xx(200), y, 200, h)
hide.z = 500
@text = ""
end
#--------------------------------------------------------------------------
# ● 桁數の取得
#--------------------------------------------------------------------------
def col_max
item_max
end
#--------------------------------------------------------------------------
# ● 項目數の取得
#--------------------------------------------------------------------------
def item_max
CMD.size
end
#--------------------------------------------------------------------------
# ● テキスト表示
#--------------------------------------------------------------------------
def set_text(type, item=nil)
@text = Blacksmith::MesCmd.conv_text(type, item)
w = contents.text_size(@text).width
self.width = w + standard_padding * 2
self.x = xx(self.width)
create_contents
refresh
show.activate.index = 1
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_text(4, line_height*0, contents_width, line_height, @text)
draw_text(4, line_height*1, contents_width, line_height, "裝備しますか?")
item_max.times { |i| draw_item(i) }
end
#--------------------------------------------------------------------------
# ● 項目の描畫
# index : 項目番號
#--------------------------------------------------------------------------
def draw_item(index)
draw_text(item_rect_for_text(index), CMD[index], 1)
end
#--------------------------------------------------------------------------
# ● 項目を描畫する矩形の取得
#--------------------------------------------------------------------------
def item_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 + item_height*2
rect
end
end
#==============================================================================
# ■ Window_BsCaution
#==============================================================================
class Window_BsCaution < Window_Selectable
#--------------------------------------------------------------------------
# ● X座標
#--------------------------------------------------------------------------
def xx(w)
(Graphics.width-w) / 2
end
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
h = fitting_height(1)
y = (Graphics.height - h) / 2
super(xx(240), y, 240, h)
@callback = nil
hide.z = 600
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def set_text(type, item=nil)
text = Blacksmith::MesCmd.conv_text(type, item)
w = contents.text_size(text).width
self.width = w + standard_padding * 2
self.x = xx(self.width)
create_contents
draw_text(0, 0, w, line_height, text, 1)
show.activate.pause = true
set_callback(nil)
end
#--------------------------------------------------------------------------
# ● Callback登錄
#--------------------------------------------------------------------------
def set_callback(callback=nil)
@callback = callback
end
def get_callback
@callback
end
end
#==============================================================================
# ■ Window_BsStatus
#==============================================================================
class Window_BsStatus < Window_Selectable
M_MTRL = 0 # 素材アイテムステータス
M_ITEM = 1 # ■成アイテムステータス
M_PARTY = 2 # パーティーステータス
M_ACTOR = 3 # アクターステータス
PATTERN = Blacksmith::ST_PTN # 切り替えの並び順
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(type=0)
@mode = M_MTRL
@type = type
@item = nil
super(0, Graphics.height-fitting_height(3), Graphics.width, fitting_height(3))
mode_reset(type)
refresh
end
#--------------------------------------------------------------------------
# ● 項目數の取得
#--------------------------------------------------------------------------
def item_max
case @mode
when M_MTRL; return 6
when M_ITEM; return 8
when M_PARTY; return ($game_party.members.size + page_size - 1) / page_size
when M_ACTOR; return $game_party.members.size
end
return 0
end
#--------------------------------------------------------------------------
# ● 橫に項目が並ぶときの空白の幅を取得
#--------------------------------------------------------------------------
def spacing
return 16
end
#--------------------------------------------------------------------------
# ● 桁數の取得
#--------------------------------------------------------------------------
def col_max
case @mode
when M_MTRL; return 2
when M_ITEM; return 4
when M_PARTY; return page_size
when M_ACTOR; return 1
end
return 0
end
#--------------------------------------------------------------------------
# ● 桁數の取得
#--------------------------------------------------------------------------
def page_size
case @mode
when M_MTRL; return 1
when M_ITEM; return 1
when M_PARTY; return 4
when M_ACTOR; return 1
end
return 0
end
#--------------------------------------------------------------------------
# ● 固定パターン?
#--------------------------------------------------------------------------
def fix?
return (PATTERN.size <= 1)
end
#--------------------------------------------------------------------------
# ● アイテムの設定
# item : 新しいアイテム
#--------------------------------------------------------------------------
def item=(item)
return if @item == item
@item = item
refresh
end
#--------------------------------------------------------------------------
# ● モードチェンジ[local]
#--------------------------------------------------------------------------
def change_local_mode
@local_idx += 1
if @local_idx >= item_max
@local_idx = 0
next_mode_t
end
refresh
end
#--------------------------------------------------------------------------
# ● モードチェンジ
#--------------------------------------------------------------------------
def change_mode
case @mode
when M_MTRL,M_ITEM; next_mode_t; refresh
when M_PARTY,M_ACTOR; change_local_mode
end
end
#--------------------------------------------------------------------------
# ● モードリセット
#--------------------------------------------------------------------------
def mode_reset(type)
@mode = M_MTRL
@type = type
next_mode if @type == 1 and !fix?
@local_idx = 0
end
#--------------------------------------------------------------------------
# ● 次のモードへ遷移
#--------------------------------------------------------------------------
def next_mode_t
next_mode
next_mode if @type == 1 and @mode == M_ITEM and !fix?
end
def next_mode
@mode = PATTERN[((PATTERN.index(@mode) + 1) % PATTERN.size)]
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
return if @item == nil
case @mode
when M_MTRL; refresh_material
when M_ITEM; refresh_item
when M_PARTY; refresh_party
when M_ACTOR; refresh_actor
end
end
#--------------------------------------------------------------------------
# ● リフレッシュ : M_MTRL
#--------------------------------------------------------------------------
def refresh_material
return if @type == 1
change_color(normal_color)
@item.cond.size.times { |i| draw_material_i(i) }
end
#--------------------------------------------------------------------------
# ● 項目描畫 : M_MTRL
#--------------------------------------------------------------------------
def draw_material_i(index)
c = @item.cond[index]
r = item_rect(index)
change_color(normal_color, c.enable)
draw_item_name(c.obj, r.x, r.y, c.enable)
draw_text(r.x+190, r.y, 30, line_height, c.pt_num, 2)
draw_text(r.x+220, r.y, 16, line_height, "/")
draw_text(r.x+224, r.y, 30, line_height, c.num, 2)
end
#--------------------------------------------------------------------------
# ● リフレッシュ : M_ITEM
#--------------------------------------------------------------------------
def refresh_item
draw_item_name(@item.obj, 4, 0, true, 220)
text = @item.obj.is_a?(RPG::Weapon) ?
$data_system.weapon_types[@item.obj.wtype_id] :
$data_system.armor_types[@item.obj.atype_id]
draw_text(240, 0, 120, line_height, "[#{text}]")
# draw_text(240. 0, 120, line_height, $data_system.terms.etype[@item.obj.etype_id])
draw_item_prms
end
#--------------------------------------------------------------------------
# ● アイテムの上昇パラメータ描畫 : M_ITEM
#--------------------------------------------------------------------------
def draw_item_prms
8.times do |i|
r = item_prm_rect(i)
r.width -= 10
change_color(system_color)
draw_text(r, $data_system.terms.params[i])
change_color(param_change_color(@item.obj.params[i]))
draw_text(r, sprintf("%+d", @item.obj.params[i]), 2)
end
end
#--------------------------------------------------------------------------
# ● リフレッシュ : M_PARTY
#--------------------------------------------------------------------------
def refresh_party
start_index = @local_idx * page_size
size = [page_size, $game_party.members.size - start_index].min
size.times { |i| draw_item_party(i) }
end
#--------------------------------------------------------------------------
# ● 項目描畫 : M_PARTY
#--------------------------------------------------------------------------
def draw_item_party(index)
actor = $game_party.members[index + @local_idx * page_size]
case @item.obj
when RPG::Item; draw_item_party_i(actor, item_rect(index).x)
when RPG::Weapon; draw_item_party_e(actor, item_rect(index).x, [2, 4])
when RPG::Armor; draw_item_party_e(actor, item_rect(index).x, [3, 5])
end
end
#--------------------------------------------------------------------------
# ● 項目描畫 : M_PARTY : RPG::Item
#--------------------------------------------------------------------------
def draw_item_party_i(actor, x)
draw_actor_name(actor, x, 0)
draw_actor_hp(actor, x, line_height+4)
draw_actor_mp(actor, x, line_height*2+4)
end
#--------------------------------------------------------------------------
# ● 項目描畫 : M_PARTY : RPG::Weapon/Armor
#--------------------------------------------------------------------------
def draw_item_party_e(actor, x, prms)
able = actor.equippable?(@item.obj)
change_color(normal_color, able)
draw_text(x, 0, 112, line_height, actor.name)
prms.each_index do |i|
change_color(system_color, able)
draw_text(x, (i+1)*line_height, 82, line_height, $data_system.terms.params[prms[i]])
end
draw_diff_prms(actor, prms, x+10, line_height) if able
end
#--------------------------------------------------------------------------
# ● パラメータ差分描畫
#--------------------------------------------------------------------------
def draw_diff_prms(actor, prms, x, y)
equips = actor.equips.select { |a| a != nil }
equips = equips.select { |a| a.etype_id == @item.obj.etype_id }
prms.each_index do |i|
diff = diff_item_param(equips, prms[i], prms[0])
draw_item_diff(x, y+i*line_height, diff)
end
end
#--------------------------------------------------------------------------
# ● アイテムパラメータ差分取得
#--------------------------------------------------------------------------
def diff_item_param(equips, prm, dprm)
e_items = equips.sort { |a, b| b.params[dprm] - a.params[dprm] }
e_prm = e_items.empty? ? 0 : e_items[0].params[prm]
return @item.obj.params[prm] - e_prm
end
#--------------------------------------------------------------------------
# ● 裝備差分■の描畫
#--------------------------------------------------------------------------
def draw_item_diff(x, y, change)
change_color(param_change_color(change))
draw_text(x, y, 110, line_height, sprintf("%+d", change), 2)
end
#--------------------------------------------------------------------------
# ● リフレッシュ : M_ACTOR
#--------------------------------------------------------------------------
def refresh_actor
actor = $game_party.members[@local_idx]
able = @item.obj.is_a?(RPG::Item) ? true : actor.equippable?(@item.obj)
type = @item.obj.is_a?(RPG::Item) ? -1 : @item.obj.etype_id
change_color(normal_color, able)
draw_text(0, 0, 120, line_height, actor.name)
case @item.obj
when RPG::Item; draw_item_actor_i(actor)
when RPG::Weapon; draw_item_actor_w(actor, able)
when RPG::Armor; draw_item_actor_a(actor, able)
end
end
#--------------------------------------------------------------------------
# ● 項目の描畫 : M_ACTOR : RPG::Item
#--------------------------------------------------------------------------
def draw_item_actor_i(actor)
draw_actor_level(actor, 128, 0)
end
#--------------------------------------------------------------------------
# ● 裝備中アイテム描畫
#--------------------------------------------------------------------------
def draw_equip_items(items, able)
x = 128
text = " / "
items.size.times do |i|
if i > 0
draw_text(x, 0, 32, line_height, text)
x += contents.text_size(text).width
end
draw_item_name(items[i], x, 0, able)
x += 24 + contents.text_size(items[i].name).width
end
end
#--------------------------------------------------------------------------
# ● 項目の描畫 : M_ACTOR : RPG::Weapon
#--------------------------------------------------------------------------
def draw_item_actor_w(actor, able)
weapons = actor.weapons
draw_equip_items(weapons, able)
draw_diff_equip_params(actor, weapons, 2, able)
end
#--------------------------------------------------------------------------
# ● 項目の描畫 : M_ACTOR : RPG::Armor
#--------------------------------------------------------------------------
def draw_item_actor_a(actor, able)
armors = actor.armors.select { |a| a.etype_id == @item.obj.etype_id }
draw_equip_items(armors, able)
draw_diff_equip_params(actor, armors, 3, able)
end
#--------------------------------------------------------------------------
# ● 全パラメータの■動■描畫 : M_ACTOR
#--------------------------------------------------------------------------
def draw_diff_equip_params(actor, equips, dprm, able)
8.times do |i|
r = item_prm_rect(i)
change_color(system_color, able)
draw_text(r.x, r.y, 82, line_height, $data_system.terms.params[i])
draw_item_diff(r.x+r.width-120, r.y, diff_item_param(equips, i, dprm)) if able
end
end
#--------------------------------------------------------------------------
# ● 項目を描畫する矩形の取得
#--------------------------------------------------------------------------
def item_prm_rect(index)
rect = Rect.new
rect.width = contents_width / 4
rect.height = line_height
rect.x = index / 2 * rect.width
rect.y = index % 2 * line_height + line_height
rect
end
end
#==============================================================================
# ■ Window_BsItemInfo
#==============================================================================
class Window_BsItemInfo < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
r = Rect.new
r.y = fitting_height(2) + fitting_height(1)
r.width = Graphics.width-120
r.height = Graphics.height - r.y - fitting_height(3)
@data = nil
super(r.x, r.y, r.width, r.height)
hide
self.z = 700
end
#--------------------------------------------------------------------------
# ● 表示可否
#--------------------------------------------------------------------------
def enable?
Blacksmith::ENABLE_INFO
end
#--------------------------------------------------------------------------
# ● 桁數の取得
#--------------------------------------------------------------------------
def col_max
return 2
end
#--------------------------------------------------------------------------
# ● 決定やキャンセルなどのハンドリング■理
#--------------------------------------------------------------------------
def process_handling
return unless open? && active
return process_ok if ok_enabled? && Input.trigger?(:C)
return process_cancel if cancel_enabled? && Input.trigger?(:B)
return process_pagedown if handle?(:pagedown) && Input.trigger?(:R)
return process_pageup if handle?(:pageup) && Input.trigger?(:L)
return process_info if handle?(:info) && Input.trigger?(:A)
end
#--------------------------------------------------------------------------
# ● L ボタン(PageUp)が押されたときの■理
#--------------------------------------------------------------------------
def process_pageup
Sound.play_cursor
Input.update
call_handler(:pageup)
end
#--------------------------------------------------------------------------
# ● R ボタン(PageDown)が押されたときの■理
#--------------------------------------------------------------------------
def process_pagedown
Sound.play_cursor
Input.update
call_handler(:pagedown)
end
#--------------------------------------------------------------------------
# ● 情報表示■理
#--------------------------------------------------------------------------
def process_info
Sound.play_ok
Input.update
hide.deactivate
call_handler(:info)
end
#--------------------------------------------------------------------------
# ● 表示ON
#--------------------------------------------------------------------------
def item=(data)
show.activate
self.pause = true
return if @data == data
@data = data
refresh
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
return if @data.nil?
draw_item_name(@data, 4, 0, true, 220)
text = @data.is_a?(RPG::Weapon) ?
$data_system.weapon_types[@data.wtype_id] :
$data_system.armor_types[@data.atype_id]
draw_text(240, 0, 120, line_height, "[#{text}]")
# draw_text(220. 0, 120, line_height, $data_system.terms.etype[@data.etype_id])
draw_options
end
#--------------------------------------------------------------------------
# ● オプション表示
#--------------------------------------------------------------------------
def draw_options
# 特になし…。
end
end