#============================================================================== # ■ VXAce-RGSS3-31 和風レイアウト [Ver.1.0.0] by Claimh #------------------------------------------------------------------------------ # 和風なレイアウトに変更します。 #============================================================================== # デフォルトフォント設定 Font.default_name = ["HGP行書体", "MS 明朝", "VL Gothic"] Font.default_outline = false Font.default_shadow = false #============================================================================== # ■ Vocab #------------------------------------------------------------------------------ #  用語とメッセージを定義するモジュールです。定数でメッセージなどを直接定義す # るほか、グローバル変数 $data_system から用語データを取得します。 #============================================================================== module Vocab # セーブ/ロード画面 SaveMessage = "どの書に記録しますか?" LoadMessage = "どの書から読み出ししますか?" File = "記録の書" # アクター対象の行動結果 ActorDamage = "%sは %s の傷を受けた!" ActorRecovery = "%sの%sが %s 回復した!" ActorGain = "%sの%sが %s 増えた!" ActorLoss = "%sの%sが %s 減った!" ActorDrain = "%sは%sを %s 奪われた!" ActorNoDamage = "%sには効かない!" ActorNoHit = "%sには当たらない!" # 敵キャラ対象の行動結果 EnemyDamage = "%sに %s の傷を与えた!" EnemyRecovery = "%sの%sが %s 回復した!" EnemyGain = "%sの%sが %s 増えた!" EnemyLoss = "%sの%sが %s 減った!" EnemyDrain = "%sの%sを %s 奪った!" EnemyNoDamage = "%sには効かない!" EnemyNoHit = "%sに当たらない!" # 回避/反射 Evasion = "%sは攻撃をかわした!" MagicEvasion = "%sは術を打ち消した!" MagicReflection = "%sは術を跳ね返した!" CounterAttack = "%sの反撃!" Substitute = "%sが%sをかばった!" end class Bitmap #-------------------------------------------------------------------------- # ● 縦テキスト描画 #-------------------------------------------------------------------------- def draw_h_text(rect, text) t = text.to_s.split(//) x = rect.x y = rect.y t.each_index do |i| h = text_size(t[i]).height case t[i] when "。", "、" plus = h / 2 draw_text(x+plus, y-plus, rect.width, h, t[i], 1) when "っ", "ぁ", "ぃ", "ぅ", "ぇ", "ぉ", "ゃ", "ゅ", "ょ", "ッ", "ァ", "ィ", "ゥ", "ェ", "ォ", "ャ", "ュ", "ョ" plus = h / 5 draw_text(x+plus, y-plus, rect.width, h, t[i], 1) when "\n", "\r"; next else draw_text(x, y, rect.width, h, t[i], 1) end y += h end end #-------------------------------------------------------------------------- # ● 和数字描画 #-------------------------------------------------------------------------- def draw_jnum(rect, num, align=2) draw_text(rect, ConvJnum.conv(num), align) end #-------------------------------------------------------------------------- # ● 和数字描画 <縦> #-------------------------------------------------------------------------- def draw_h_jnum(rect, num, align=2) draw_h_text(rect, ConvJnum.conv(num), align) end end module ConvJnum #-------------------------------------------------------------------------- # ● 和数字変換 #-------------------------------------------------------------------------- def self.conv(num) text = "" if num / 100000000 > 0 text += conv_o(num / 100000000) num %= 100000000 end if num / 10000 > 0 text += conv_m(num / 10000) num %= 10000 end text += conv_s(num) text = "零" if text == "" text end #-------------------------------------------------------------------------- # ● 和数字変換 (億単位) #-------------------------------------------------------------------------- def self.conv_o(num) conv_s(num) + "億 " end #-------------------------------------------------------------------------- # ● 和数字変換 (万単位) #-------------------------------------------------------------------------- def self.conv_m(num) conv_s(num) + "万 " end #-------------------------------------------------------------------------- # ● 和数字変換 (千単位以下) #-------------------------------------------------------------------------- def self.conv_s(num) text = "" if num / 1000 > 0 text += conv_one(num / 1000, false) + "千" num %= 1000 end if num / 100 > 0 text += conv_one(num / 100, false) + "百" num %= 100 end if num / 10 > 0 text += conv_one(num / 10, false) + "十" num %= 10 end if num > 0 text +=conv_one(num, true) end text end def self.conv_one(num, one=false) conv = {1=>"一", 2=>"二", 3=>"三", 4=>"四", 5=>"五", 6=>"六", 7=>"七", 8=>"八", 9=>"九"} one ? conv[num] : (num > 1 ? conv[num] : "") end end class Window_Base < Window #-------------------------------------------------------------------------- # ● 各種文字色の取得 #-------------------------------------------------------------------------- def normal_color; text_color(0); end; # 通常 def system_color; text_color(11); end; # システム def crisis_color; text_color(17); end; # ピンチ def knockout_color; text_color(18); end; # 戦闘不能 def gauge_back_color; text_color(7); end; # ゲージ背景 def hp_gauge_color1; text_color(20); end; # HP ゲージ 1 def hp_gauge_color2; text_color(21); end; # HP ゲージ 2 def mp_gauge_color1; text_color(22); end; # MP ゲージ 1 def mp_gauge_color2; text_color(23); end; # MP ゲージ 2 def mp_cost_color; text_color(31); end; # 消費 MP def power_up_color; text_color(24); end; # 装備 パワーアップ def power_down_color; text_color(25); end; # 装備 パワーダウン def tp_gauge_color1; text_color(28); end; # TP ゲージ 1 def tp_gauge_color2; text_color(29); end; # TP ゲージ 2 def tp_cost_color; text_color(30); end; # 消費 TP #-------------------------------------------------------------------------- # ● 文字の処理 # c : 文字 # text : 描画処理中の文字列バッファ(必要なら破壊的に変更) # pos : 描画位置 {:x, :y, :new_x, :height} #-------------------------------------------------------------------------- def process_character(c, text, pos) case c when "\r" # キャリッジリターンは無視 when "\n" # 改行 process_new_line(text, pos) when "\f" # 改ページ process_new_page(text, pos) when "\e" # 制御文字 process_escape_character(obtain_escape_code(text), text, pos) else # 普通の文字 process_normal_character(c, pos) end end #-------------------------------------------------------------------------- # ● シンプルなステータスの描画 #-------------------------------------------------------------------------- def draw_actor_simple_status(actor, x, y, add=120, width=124) draw_actor_name(actor, x, y) draw_actor_level(actor, x, y + line_height * 1) draw_actor_icons(actor, x, y + line_height * 2) draw_actor_class(actor, x + add, y) draw_actor_hp(actor, x + add, y + line_height * 1, width) draw_actor_mp(actor, x + add, y + line_height * 2, width) end #-------------------------------------------------------------------------- # ● 現在値/最大値を分数形式で描画 # current : 現在値 # max : 最大値 # color1 : 現在値の色 # color2 : 最大値の色 #-------------------------------------------------------------------------- def draw_current_and_max_values(x, y, width, current, max, color1, color2) change_color(color1) xr = x + width if width < 106 draw_text(xr - 50, y, 52, line_height, current, 2) else draw_text(xr - 106, y, 52, line_height, current, 2) change_color(color2) draw_text(xr - 56, y, 12, line_height, "/", 2) draw_text(xr - 52, y, 52, line_height, max, 2) end end end #============================================================================== # ■ Window_J_Base #------------------------------------------------------------------------------ #  ゲーム中の全てのウィンドウのスーパークラスです。 #============================================================================== class Window_J_Base < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(*args) @jmode=true super(*args) end #-------------------------------------------------------------------------- # ● 行の幅を取得 #-------------------------------------------------------------------------- def line_width return 24 end #-------------------------------------------------------------------------- # ● 指定行数に適合するウィンドウの幅を計算 #-------------------------------------------------------------------------- def fitting_width(line_number) line_number * line_width + standard_padding * 2 end #-------------------------------------------------------------------------- # ● テキストの描画 <縦書き> # args : Bitmap#draw_text と同じ #-------------------------------------------------------------------------- def draw_text(*args) return super(*args) unless @jmode if args[0].is_a?(Rect) contents.draw_h_text(args[0], args[1]) else contents.draw_h_text(Rect.new(args[0], args[1], args[2], args[3]), args[4]) end end #-------------------------------------------------------------------------- # ● 制御文字つきテキストの描画 #-------------------------------------------------------------------------- def draw_text_ex(x, y, text) reset_font_settings text = convert_escape_characters(text) pos = {:x => x, :y => y, :new_y => y, :width => calc_line_width(text)} process_character(text.slice!(0, 1), text, pos) until text.empty? end #-------------------------------------------------------------------------- # ● 通常文字の処理 #-------------------------------------------------------------------------- def process_normal_character(c, pos) text_height = c.split(//).inject(0) {|r, t| r+=text_size(t).height} draw_text(pos[:x], pos[:y], line_width, text_height, c) pos[:y] += text_height end #-------------------------------------------------------------------------- # ● 改行文字の処理 #-------------------------------------------------------------------------- def process_new_line(text, pos) pos[:x] -= pos[:width] pos[:y] = pos[:new_y] pos[:width] = calc_line_width(text) end #-------------------------------------------------------------------------- # ● 制御文字によるアイコン描画の処理 #-------------------------------------------------------------------------- def process_draw_icon(icon_index, pos) draw_icon(icon_index, pos[:x]-pos[:width], pos[:y]) pos[:y] += 24 end #-------------------------------------------------------------------------- # ● アイテム名の描画 # enabled : 有効フラグ。false のとき半透明で描画 #-------------------------------------------------------------------------- def draw_item_name(item, x, y, enabled = true, height = 172) return unless item draw_icon(item.icon_index, x, y, enabled) change_color(normal_color, enabled) draw_text(x, y + 24, line_width, height, item.name) end #-------------------------------------------------------------------------- # ● 行の幅を計算 # restore_font_size : 計算後にフォントサイズを元に戻す #-------------------------------------------------------------------------- def calc_line_width(text, restore_font_size = true) result = [line_width, contents.font.size].max last_font_size = contents.font.size text.slice(/^.*$/).scan(/\e[\{\}]/).each do |esc| make_font_bigger if esc == "\e{" make_font_smaller if esc == "\e}" result = [result, contents.font.size].max end contents.font.size = last_font_size if restore_font_size result end #-------------------------------------------------------------------------- # ● 名前の描画 #-------------------------------------------------------------------------- def draw_actor_name_l(actor, x, y, width = 112) @jmode = false draw_actor_name(actor, x, y, width) @jmode = true end #-------------------------------------------------------------------------- # ● レベルの描画 #-------------------------------------------------------------------------- def draw_actor_level_l(actor, x, y) @jmode = false draw_actor_level(actor, x, y) @jmode = true end #-------------------------------------------------------------------------- # ● HP の描画 #-------------------------------------------------------------------------- def draw_actor_hp_l(actor, x, y, width = 124) @jmode = false draw_actor_hp(actor, x, y, width) @jmode = true end #-------------------------------------------------------------------------- # ● MP の描画 #-------------------------------------------------------------------------- def draw_actor_mp_l(actor, x, y, width = 124) @jmode = false draw_actor_mp(actor, x, y, width) @jmode = true end #-------------------------------------------------------------------------- # ● シンプルなステータスの描画 #-------------------------------------------------------------------------- def draw_actor_simple_status(actor, x, y, add=120, width=124) @jmode = false draw_actor_name(actor, x, y, width) draw_actor_level(actor, x, y + line_height * 1) draw_actor_icons(actor, x, y + line_height * 2) draw_actor_class(actor, x + add, y) draw_actor_hp(actor, x + add, y + line_height * 1, width) draw_actor_mp(actor, x + add, y + line_height * 2, width) @jmode = true end #-------------------------------------------------------------------------- # ● シンプルなステータスの描画 <縦パターン> #-------------------------------------------------------------------------- def draw_actor_simple_status2(actor, x, y, width=124) @jmode = false draw_actor_name( actor, x, y + line_height * 0, width) draw_actor_face( actor, x+(width-96)/2, y + line_height * 1, width) #~ draw_actor_class(actor, x, y + 96 + line_height * 1, width) draw_actor_level(actor, x, y + 96 + line_height * 2) draw_actor_hp( actor, x, y + 96 + line_height * 3, width) draw_actor_mp( actor, x, y + 96 + line_height * 4, width) draw_actor_icons(actor, x, y + 96 + line_height * 5, width) @jmode = true end end #============================================================================== # ■ Window_J_Selectable #------------------------------------------------------------------------------ #  カーソルの移動やスクロールの機能を持つウィンドウクラスです。 #============================================================================== class Window_J_Selectable < Window_J_Base #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :index # カーソル位置 attr_reader :help_window # ヘルプウィンドウ attr_accessor :cursor_fix # カーソル固定フラグ attr_accessor :cursor_all # カーソル全選択フラグ #-------------------------------------------------------------------------- # ● オブジェクト初期化 #------------------------------------------------------------------------- def initialize(x, y, width, height) super @index = -1 @handler = {} @cursor_fix = false @cursor_all = false update_padding deactivate end #-------------------------------------------------------------------------- # ● ウィンドウ内容の作成 #-------------------------------------------------------------------------- def create_contents super self.ox = contents_width - base_contents_width end #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max return 1 end #-------------------------------------------------------------------------- # ● 縦に項目が並ぶときの空白の幅を取得 #-------------------------------------------------------------------------- def spacing return 32 end #-------------------------------------------------------------------------- # ● 項目数の取得 #-------------------------------------------------------------------------- def item_max return 0 end #-------------------------------------------------------------------------- # ● 項目の高さを取得 #-------------------------------------------------------------------------- def item_height (height - standard_padding * 2 + spacing) / col_max - spacing end #-------------------------------------------------------------------------- # ● 項目の高さを取得 #-------------------------------------------------------------------------- def item_width line_width end #-------------------------------------------------------------------------- # ● 行数の取得 #-------------------------------------------------------------------------- def row_max [(item_max + col_max - 1) / col_max, 1].max end #-------------------------------------------------------------------------- # ● ウィンドウ内容の幅を計算 #-------------------------------------------------------------------------- def contents_width [super, row_max * item_width].max end #-------------------------------------------------------------------------- # ● ウィンドウ内容の幅を計算 #-------------------------------------------------------------------------- def base_contents_width width - standard_padding * 2 end #-------------------------------------------------------------------------- # ● 下端パディングの更新 #-------------------------------------------------------------------------- def update_padding_bottom surplus = (width - standard_padding * 2) % item_width self.padding_bottom = padding + surplus end #-------------------------------------------------------------------------- # ● 幅の設定 #-------------------------------------------------------------------------- def width=(width) super update_padding end #-------------------------------------------------------------------------- # ● アクティブ状態の変更 #-------------------------------------------------------------------------- def active=(active) super update_cursor call_update_help end #-------------------------------------------------------------------------- # ● カーソル位置の設定 #-------------------------------------------------------------------------- def index=(index) @index = index update_cursor call_update_help end #-------------------------------------------------------------------------- # ● 項目の選択 #-------------------------------------------------------------------------- def select(index) self.index = index if index end #-------------------------------------------------------------------------- # ● 項目の選択解除 #-------------------------------------------------------------------------- def unselect self.index = -1 end #-------------------------------------------------------------------------- # ● 現在の行の取得 #-------------------------------------------------------------------------- def row index / col_max end #-------------------------------------------------------------------------- # ● 先頭の行の取得 #-------------------------------------------------------------------------- def top_row (ox - base_contents_width) / item_width end #-------------------------------------------------------------------------- # ● 先頭の行の設定 #-------------------------------------------------------------------------- def top_row=(row) row = 0 if row < 0 row = row_max - 1 if row > row_max - 1 self.ox = contents_width - base_contents_width - row * item_width end #-------------------------------------------------------------------------- # ● 1 ページに表示できる行数の取得 #-------------------------------------------------------------------------- def page_row_max base_contents_width / item_width end #-------------------------------------------------------------------------- # ● 1 ページに表示できる項目数の取得 #-------------------------------------------------------------------------- def page_item_max page_row_max * col_max end #-------------------------------------------------------------------------- # ● 横選択判定 #-------------------------------------------------------------------------- def horizontal? page_row_max == 1 end #-------------------------------------------------------------------------- # ● 末尾の行の取得 #-------------------------------------------------------------------------- def bottom_row top_row + page_row_max - 1 end #-------------------------------------------------------------------------- # ● 末尾の行の設定 #-------------------------------------------------------------------------- def bottom_row=(row) self.top_row = row - (page_row_max - 1) end #-------------------------------------------------------------------------- # ● 項目を描画する矩形の取得 #-------------------------------------------------------------------------- def item_rect(index) rect = Rect.new rect.width = item_width rect.height = item_height rect.x = contents_width - index / col_max * item_width - item_width rect.y = index % col_max * (item_height + spacing) rect end #-------------------------------------------------------------------------- # ● 項目を描画する矩形の取得(テキスト用) #-------------------------------------------------------------------------- def item_rect_for_text(index) rect = item_rect(index) rect.y += 4 rect.height -= 8 rect end #-------------------------------------------------------------------------- # ● ヘルプウィンドウの設定 #-------------------------------------------------------------------------- def help_window=(help_window) @help_window = help_window call_update_help end #-------------------------------------------------------------------------- # ● 動作に対応するハンドラの設定 # method : ハンドラとして設定するメソッド (Method オブジェクト) #-------------------------------------------------------------------------- def set_handler(symbol, method) @handler[symbol] = method end #-------------------------------------------------------------------------- # ● ハンドラの存在確認 #-------------------------------------------------------------------------- def handle?(symbol) @handler.include?(symbol) end #-------------------------------------------------------------------------- # ● ハンドラの呼び出し #-------------------------------------------------------------------------- def call_handler(symbol) @handler[symbol].call if handle?(symbol) end #-------------------------------------------------------------------------- # ● カーソルの移動可能判定 #-------------------------------------------------------------------------- def cursor_movable? active && open? && !@cursor_fix && !@cursor_all && item_max > 0 end #-------------------------------------------------------------------------- # ● カーソルを下に移動 #-------------------------------------------------------------------------- def cursor_down(wrap = false) if col_max >= 2 && (index < item_max - 1 || (wrap && horizontal?)) select((index + 1) % item_max) end end #-------------------------------------------------------------------------- # ● カーソルを上に移動 #-------------------------------------------------------------------------- def cursor_up(wrap = false) if col_max >= 2 && (index > 0 || (wrap && horizontal?)) select((index - 1 + item_max) % item_max) end end #-------------------------------------------------------------------------- # ● カーソルを右に移動 #-------------------------------------------------------------------------- def cursor_right(wrap = false) if index >= col_max || (wrap && col_max == 1) select((index - col_max + item_max) % item_max) end end #-------------------------------------------------------------------------- # ● カーソルを左に移動 #-------------------------------------------------------------------------- def cursor_left(wrap = false) if index < item_max - col_max || (wrap && col_max == 1) select((index + col_max) % item_max) end end #-------------------------------------------------------------------------- # ● カーソルを 1 ページ後ろに移動 #-------------------------------------------------------------------------- def cursor_pagedown if top_row + page_row_max < row_max self.top_row += page_row_max select([@index + page_item_max, item_max - 1].min) end end #-------------------------------------------------------------------------- # ● カーソルを 1 ページ前に移動 #-------------------------------------------------------------------------- def cursor_pageup if top_row > 0 self.top_row -= page_row_max select([@index - page_item_max, 0].max) end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super process_cursor_move process_handling end #-------------------------------------------------------------------------- # ● カーソルの移動処理 #-------------------------------------------------------------------------- def process_cursor_move return unless cursor_movable? last_index = @index cursor_down (Input.trigger?(:DOWN)) if Input.repeat?(:DOWN) cursor_up (Input.trigger?(:UP)) if Input.repeat?(:UP) cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT) cursor_left (Input.trigger?(:LEFT)) if Input.repeat?(:LEFT) cursor_pagedown if !handle?(:pagedown) && Input.trigger?(:R) cursor_pageup if !handle?(:pageup) && Input.trigger?(:L) Sound.play_cursor if @index != last_index 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) end #-------------------------------------------------------------------------- # ● 決定処理の有効状態を取得 #-------------------------------------------------------------------------- def ok_enabled? handle?(:ok) end #-------------------------------------------------------------------------- # ● キャンセル処理の有効状態を取得 #-------------------------------------------------------------------------- def cancel_enabled? handle?(:cancel) end #-------------------------------------------------------------------------- # ● 決定ボタンが押されたときの処理 #-------------------------------------------------------------------------- def process_ok if current_item_enabled? Sound.play_ok Input.update deactivate call_ok_handler else Sound.play_buzzer end end #-------------------------------------------------------------------------- # ● 決定ハンドラの呼び出し #-------------------------------------------------------------------------- def call_ok_handler call_handler(:ok) end #-------------------------------------------------------------------------- # ● キャンセルボタンが押されたときの処理 #-------------------------------------------------------------------------- def process_cancel Sound.play_cancel Input.update deactivate call_cancel_handler end #-------------------------------------------------------------------------- # ● キャンセルハンドラの呼び出し #-------------------------------------------------------------------------- def call_cancel_handler call_handler(:cancel) end #-------------------------------------------------------------------------- # ● L ボタン(PageUp)が押されたときの処理 #-------------------------------------------------------------------------- def process_pageup Sound.play_cursor Input.update deactivate call_handler(:pageup) end #-------------------------------------------------------------------------- # ● R ボタン(PageDown)が押されたときの処理 #-------------------------------------------------------------------------- def process_pagedown Sound.play_cursor Input.update deactivate call_handler(:pagedown) end #-------------------------------------------------------------------------- # ● カーソルの更新 #-------------------------------------------------------------------------- def update_cursor if @cursor_all cursor_rect.set(0, 0, row_max * item_width, contents.height) self.top_row = 0 elsif @index < 0 cursor_rect.empty else ensure_cursor_visible cursor_rect.set(item_rect(@index)) end end #-------------------------------------------------------------------------- # ● カーソル位置が画面内になるようにスクロール #-------------------------------------------------------------------------- def ensure_cursor_visible self.top_row = row if row < top_row self.bottom_row = row if row > bottom_row end #-------------------------------------------------------------------------- # ● ヘルプウィンドウ更新メソッドの呼び出し #-------------------------------------------------------------------------- def call_update_help update_help if active && @help_window end #-------------------------------------------------------------------------- # ● ヘルプウィンドウの更新 #-------------------------------------------------------------------------- def update_help @help_window.clear end #-------------------------------------------------------------------------- # ● 選択項目の有効状態を取得 #-------------------------------------------------------------------------- def current_item_enabled? return true end #-------------------------------------------------------------------------- # ● 全項目の描画 #-------------------------------------------------------------------------- def draw_all_items item_max.times {|i| draw_item(i) } end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) end #-------------------------------------------------------------------------- # ● 項目の消去 #-------------------------------------------------------------------------- def clear_item(index) contents.clear_rect(item_rect(index)) end #-------------------------------------------------------------------------- # ● 項目の再描画 #-------------------------------------------------------------------------- def redraw_item(index) clear_item(index) if index >= 0 draw_item(index) if index >= 0 end #-------------------------------------------------------------------------- # ● 選択項目の再描画 #-------------------------------------------------------------------------- def redraw_current_item redraw_item(@index) end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear draw_all_items end end #============================================================================== # ■ Window_J_Help #------------------------------------------------------------------------------ #  スキルやアイテムの説明、アクターのステータスなどを表示するウィンドウです。 #============================================================================== class Window_J_Help < Window_J_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(line_number = 2) @line_number = line_number super(0, 0, fitting_width(line_number), Graphics.height) end #-------------------------------------------------------------------------- # ● テキスト設定 #-------------------------------------------------------------------------- def set_text(text) if text != @text @text = text refresh end end #-------------------------------------------------------------------------- # ● クリア #-------------------------------------------------------------------------- def clear set_text("") end #-------------------------------------------------------------------------- # ● アイテム設定 # item : スキル、アイテム等 #-------------------------------------------------------------------------- def set_item(item) set_text(item ? item.description : "") end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear draw_text_ex((@line_number-1)*line_width, 0, @text) end end #============================================================================== # ■ Window_J_Command #------------------------------------------------------------------------------ #  一般的なコマンド選択を行うウィンドウです。 #============================================================================== class Window_J_Command < Window_J_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y) clear_command_list make_command_list super(x, y, window_width, window_height) refresh select(0) activate end #-------------------------------------------------------------------------- # ● ウィンドウ高さの取得 #-------------------------------------------------------------------------- def window_width fitting_width(visible_line_number) end #-------------------------------------------------------------------------- # ● ウィンドウ高さの取得 #-------------------------------------------------------------------------- def window_height Graphics.height end #-------------------------------------------------------------------------- # ● 表示行数の取得 #-------------------------------------------------------------------------- def visible_line_number (item_max * 1.0 / col_max).round end #-------------------------------------------------------------------------- # ● 項目数の取得 #-------------------------------------------------------------------------- def item_max @list.size end #-------------------------------------------------------------------------- # ● コマンドリストのクリア #-------------------------------------------------------------------------- def clear_command_list @list = [] end #-------------------------------------------------------------------------- # ● コマンドリストの作成 #-------------------------------------------------------------------------- def make_command_list end #-------------------------------------------------------------------------- # ● コマンドの追加 # name : コマンド名 # symbol : 対応するシンボル # enabled : 有効状態フラグ # ext : 任意の拡張データ #-------------------------------------------------------------------------- def add_command(name, symbol, enabled = true, ext = nil) @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext}) end #-------------------------------------------------------------------------- # ● コマンド名の取得 #-------------------------------------------------------------------------- def command_name(index) @list[index][:name] end #-------------------------------------------------------------------------- # ● コマンドの有効状態を取得 #-------------------------------------------------------------------------- def command_enabled?(index) @list[index][:enabled] end #-------------------------------------------------------------------------- # ● 選択項目のコマンドデータを取得 #-------------------------------------------------------------------------- def current_data index >= 0 ? @list[index] : nil end #-------------------------------------------------------------------------- # ● 選択項目の有効状態を取得 #-------------------------------------------------------------------------- def current_item_enabled? current_data ? current_data[:enabled] : false end #-------------------------------------------------------------------------- # ● 選択項目のシンボルを取得 #-------------------------------------------------------------------------- def current_symbol current_data ? current_data[:symbol] : nil end #-------------------------------------------------------------------------- # ● 選択項目の拡張データを取得 #-------------------------------------------------------------------------- def current_ext current_data ? current_data[:ext] : nil end #-------------------------------------------------------------------------- # ● 指定されたシンボルを持つコマンドにカーソルを移動 #-------------------------------------------------------------------------- def select_symbol(symbol) @list.each_index {|i| select(i) if @list[i][:symbol] == symbol } end #-------------------------------------------------------------------------- # ● 指定された拡張データを持つコマンドにカーソルを移動 #-------------------------------------------------------------------------- def select_ext(ext) @list.each_index {|i| select(i) if @list[i][:ext] == ext } end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) change_color(normal_color, command_enabled?(index)) draw_text(item_rect_for_text(index), command_name(index), alignment) end #-------------------------------------------------------------------------- # ● アライメントの取得 #-------------------------------------------------------------------------- def alignment return 0 end #-------------------------------------------------------------------------- # ● 決定処理の有効状態を取得 #-------------------------------------------------------------------------- def ok_enabled? return true end #-------------------------------------------------------------------------- # ● 決定ハンドラの呼び出し #-------------------------------------------------------------------------- def call_ok_handler if handle?(current_symbol) call_handler(current_symbol) elsif handle?(:ok) super else activate end end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh clear_command_list make_command_list create_contents super end end