#============================================================================== # ■ VXAce-RGSS3-1 用語辞典[データ] by Claimh #------------------------------------------------------------------------------ # 用語辞典のデータを構築、解析する #============================================================================== #============================================================================== # ■ DictFunc : 用語辞典用関数群 #============================================================================== module DictFunc N_FILE = 0 # 画像ではない(テキスト) C_FILE = 1 # キャラチップ(Graphics/Characters) B_FILE = 2 # バトラー(Graphics/Battler) I_FILE = 3 # アイコン(Graphics/Icons) P_FILE = 4 # ピクチャ(Graphics/Pictures) F_FILE = 5 # 顔グラフィック(Graphics/Face) #============================================================================== # ■ DictFileData:辞典用表示データクラス(描画処理の実行) #============================================================================== class DictFileData #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(type, text, file="", hue=0) @type = type @text = text @file = file @hue = hue end #-------------------------------------------------------------------------- # ● 描画タイプが文字か? #-------------------------------------------------------------------------- def text? return @type == N_FILE end #-------------------------------------------------------------------------- # ● 描画タイプがアイコンか? #-------------------------------------------------------------------------- def icon? return @type == I_FILE end #-------------------------------------------------------------------------- # ● Bitmap描画 #-------------------------------------------------------------------------- def draw_bitmap(bitmap, align, x, y) case @type when N_FILE return if @text == "" or @text.nil? bitmap.draw_text(x, y, bitmap.text_size(@text).width, 24, @text, 0) when C_FILE; draw_dict_character(bitmap, align, x, y, @file, @hue) when B_FILE; draw_dict_battler(bitmap, align, x, y, @file, @hue) when I_FILE; draw_dict_icon(bitmap, align, x, y, @file, @hue) when P_FILE; draw_dict_picture(bitmap, align, x, y, @file) when F_FILE; draw_dict_face(bitmap, align, x, y, @file, @hue) end end #-------------------------------------------------------------------------- # ● 描画アライメント #-------------------------------------------------------------------------- def d_pos_x(align, x, w) case align when 1,4,7; return x when 2,5,8; return x-w/2 when 3,6,9; return x-w end end def d_pos_y(align, y, h) case align when 7,8,9; return y when 4,5,6; return y-h/2 when 1,2,3; return y-h end end #-------------------------------------------------------------------------- # ● キャラクタ描画(Graphics/Characters内の画像を表示) #-------------------------------------------------------------------------- def draw_dict_character(bitmap, align, x, y, character_name, character_index) return if character_name == nil bit = Cache.character(character_name) sign = character_name[/^[\!\$]./] if sign != nil and sign.include?('$') cw = bit.width / 3 ch = bit.height / 4 else cw = bit.width / 12 ch = bit.height / 8 end n = character_index src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch) bitmap.blt( d_pos_x(align, x, src_rect.width), d_pos_y(align, y, src_rect.height), bit, src_rect) end #-------------------------------------------------------------------------- # ● バトラー描画(Graphics/Battlers内の画像を表示) #-------------------------------------------------------------------------- def draw_dict_battler(bitmap, align, x, y, file_name, hue = 0) bit = Cache.battler(file_name, hue) if bitmap.width < bit.width # 横幅を超えるものは中央表示に x = bitmap.width / 2 align = 2 end src_rect = Rect.new(0, 0, bit.width, bit.height) bitmap.blt( d_pos_x(align, x, src_rect.width), d_pos_y(align, y, src_rect.height), bit, src_rect, Dictionary::BT_OPACITY) end #-------------------------------------------------------------------------- # ● アイコン描画(Graphics/Icons内の画像を表示) #-------------------------------------------------------------------------- def draw_dict_icon(bitmap, align, x, y, filename, icon_index) bit = Cache.system(filename) src_rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) bitmap.blt( d_pos_x(align, x, src_rect.width), d_pos_y(align, y, src_rect.height), bit, src_rect) end #-------------------------------------------------------------------------- # ● ピクチャ描画(Graphics/Pictures内の画像を表示) #-------------------------------------------------------------------------- def draw_dict_picture(bitmap, align, x, y, file_name) bit = Cache.picture(file_name) if bitmap.width < bit.width # 横幅を超えるものは中央表示に x = bitmap.width / 2 align = 2 end src_rect = Rect.new(0, 0, bit.width, bit.height) bitmap.blt( d_pos_x(align, x, src_rect.width), d_pos_y(align, y, src_rect.height), bit, src_rect) end #-------------------------------------------------------------------------- # ● 顔グラフィック描画(Graphics/Face内の画像を表示) #-------------------------------------------------------------------------- def draw_dict_face(bitmap, align, x, y, face_name, face_index, size = 96) bit = Cache.face(face_name) src_rect = Rect.new(0, 0, 0, 0) src_rect.x = face_index % 4 * 96 + (96 - size) / 2 src_rect.y = face_index / 4 * 96 + (96 - size) / 2 src_rect.width = size src_rect.height = size bitmap.blt( d_pos_x(align, x, src_rect.width), d_pos_y(align, y, src_rect.height), bit, src_rect) end end #-------------------------------------------------------------------------- # ● マップ名取得 #-------------------------------------------------------------------------- def self.map_name(i) map = load_data(sprintf("Data/Map%03d.rvdata2", i)) return map.display_name end #-------------------------------------------------------------------------- # ● ドロップアイテム取得 #-------------------------------------------------------------------------- def self.drop_item(drop) text = sprintf("( %.2f %)", (100.00 / drop.denominator) ) case drop.kind when 0; return "----" when 1; return $data_items[drop.data_id].name + text when 2; return $data_weapons[drop.data_id].name + text when 3; return $data_armor[drop.data_id].name + text else; return "----" end end #-------------------------------------------------------------------------- # ● エネミーパラメータ取得 #-------------------------------------------------------------------------- def self.enemy_param(id, type) return "" if type < 0 || type > 7 return $data_enemies[id].params[type] end #-------------------------------------------------------------------------- # ● 構文解析[テキスト置換] #-------------------------------------------------------------------------- def self.decode(textdata) text = textdata.dup # \\n[ID]:IDで指定したアクターの名前 text.gsub!(/\\n\[([0-9]+)\]/) { $game_actors[$1.to_i].name } # \\j[ID]:IDで指定したアクターのクラス名 text.gsub!(/\\j\[([0-9]+)\]/) { $data_classes[$game_actors[$1.to_i].class_id].name } # \\J[ID]:IDで指定したクラス名 text.gsub!(/\\J\[([0-9]+)\]/) { $data_classes[$1.to_i].name } # \\e[ID]:IDで指定したエネミーの名前 text.gsub!(/\\e\[([0-9]+)\]/) { $data_enemies[$1.to_i].name } # \\u[ID,type]:IDで指定したエネミーのパラメータ(type) text.gsub!(/\\u\[([0-9]+,(.*?))\]/) { enemy_param($1.to_i, $2.to_i) } # \\g[ID]:IDで指定したエネミーのゴールド text.gsub!(/\\g\[([0-9]+)\]/) { $data_enemies[$1.to_i].gold } # \\k[ID]:IDで指定したエネミーのEXP text.gsub!(/\\k\[([0-9]+)\]/) { $data_enemies[$1.to_i].exp } # \\r[ID]:IDで指定したエネミーのドロップアイテム1 text.gsub!(/\\r\[([0-9]+)\]/) { drop_item($data_enemies[$1.to_i].drop_items[$2.to_i]) } # \\t[ID]:IDで指定したアイテムの名前 text.gsub!(/\\t\[([0-9]+)\]/) { $data_items[$1.to_i].name } # \\T[ID]:IDで指定したアイテムの価格 text.gsub!(/\\T\[([0-9]+)\]/) { $data_items[$1.to_i].price.to_s + $data_system.currency_unit } # \\w[ID]:IDで指定した武器の名前 text.gsub!(/\\w\[([0-9]+)\]/) { $data_weapons[$1.to_i].name } # \\W[ID]:IDで指定した武器の価格 text.gsub!(/\\W\[([0-9]+)\]/) { $data_weapons[$1.to_i].price.to_s + $data_system.currency_unit } # \\a[ID]:IDで指定した防具の名前 text.gsub!(/\\a\[([0-9]+)\]/) { $data_armors[$1.to_i].name } # \\A[ID]:IDで指定した防具の価格 text.gsub!(/\\A\[([0-9]+)\]/) { $data_armors[$1.to_i].price.to_s + $data_system.currency_unit } # \\s[ID]:IDで指定したスキルの名前 text.gsub!(/\\s\[([0-9]+)\]/) { $data_skills[$1.to_i].name } # \\m[ID]:IDで指定したマップ名 text.gsub!(/\\m\[([0-9]+)\]/) { map_name($1.to_i) } # ★撃破数カウンタとの併用 if defined?(DefeatCounter) # \\dID]:IDで指定したアクターがこれまでに撃破したエネミーの総数 text.gsub!(/\\d\[([0-9]+)\]/) { $game_actors.defeat(0, ($1.to_i)).to_s } # \\t[ID]:IDで指定したエネミーが撃破された総数 text.gsub!(/\\t\[([0-9]+)\]/) { $game_actors.defeat(($1.to_i), 0).to_s } end # ★クエストシステムとの併用 if defined?(Quest) # \\q[ID]:IDで指定したクエスト名 text.gsub!(/\\q\[([0-9]+)\]/) { $game_system.quest[$1.to_i].name } end return text end #-------------------------------------------------------------------------- # ● 構文解析[ファイル置換] #-------------------------------------------------------------------------- def self.type_decode(textdata) text = textdata.dup #<< ファイル置換が見つかった時点でリターンする >> # \\n[ID]:IDで指定したアクターのキャラチップ(正面) d_txt = text.gsub(/\\[Nn]\[([0-9]+)\]/) { $game_actors[$1.to_i].character_name + "\\d" + $game_actors[$1.to_i].character_index.to_s } if d_txt != textdata return DictFileData.new(C_FILE, textdata, d_txt.split(/\\d/)[0], d_txt.split(/\\d/)[1].to_i) end # \\b[ID]:IDで指定したアクターの顔グラフィック d_txt = text.gsub(/\\[Bb]\[([0-9]+)\]/) { $game_actors[$1.to_i].face_name + "\\d" + $game_actors[$1.to_i].face_index.to_s } if d_txt != textdata return DictFileData.new(F_FILE, textdata, d_txt.split(/\\d/)[0], d_txt.split(/\\d/)[1].to_i) end # \\e[ID]:IDで指定したエネミーのバトラー d_txt = text.gsub(/\\[Ee]\[([0-9]+)\]/) { $data_enemies[$1.to_i].battler_name + "\\d" + $data_enemies[$1.to_i].battler_hue.to_s } if d_txt != textdata return DictFileData.new(B_FILE, textdata, d_txt.split(/\\d/)[0], d_txt.split(/\\d/)[1].to_i) end # \\t[ID]:IDで指定したアイテムのアイコン d_txt = text.gsub(/\\[Tt]\[([0-9]+)\]/) { "IconSet" + "\\d" + $data_items[$1.to_i].icon_index.to_s } return DictFileData.new(I_FILE, textdata, d_txt.split(/\\d/)[0], d_txt.split(/\\d/)[1].to_i) if d_txt != textdata # \\w[ID]:IDで指定した武器のアイコン d_txt = text.gsub(/\\[Ww]\[([0-9]+)\]/) { "IconSet" + "\\d" + $data_weapons[$1.to_i].icon_index.to_s } return DictFileData.new(I_FILE, textdata, d_txt.split(/\\d/)[0], d_txt.split(/\\d/)[1].to_i) if d_txt != textdata # \\a[ID]:IDで指定した防具のアイコン d_txt = text.gsub(/\\[Aa]\[([0-9]+)\]/) { "IconSet" + "\\d" + $data_armors[$1.to_i].icon_index.to_s } return DictFileData.new(I_FILE, textdata, d_txt.split(/\\d/)[0], d_txt.split(/\\d/)[1].to_i) if d_txt != textdata # \\s[ID]:IDで指定したスキルのアイコン d_txt = text.gsub(/\\[Ss]\[([0-9]+)\]/) { "IconSet" + "\\d" + $data_skills[$1.to_i].icon_index.to_s } return DictFileData.new(I_FILE, textdata, d_txt.split(/\\d/)[0], d_txt.split(/\\d/)[1].to_i) if d_txt != textdata # \\j[ID]:IDで指定したクラスのアイコン d_txt = text.gsub(/\\[Jj]\[([0-9]+)\]/) { "IconSet" + "\\d" + $data_classes[$1.to_i].icon_index.to_s } return DictFileData.new(I_FILE, textdata, d_txt.split(/\\d/)[0], d_txt.split(/\\d/)[1].to_i) if d_txt != textdata # \\p[File]:Graphics/Picturesに入っている画像ファイル d_txt = text.gsub(/\\[Pp]\[(.*?)\]/) { $1 } return DictFileData.new(P_FILE, textdata, d_txt) if d_txt != textdata # \\h[FILE]:Graphics/Charactersに入っている画像ファイル d_txt = text.gsub(/\\[Hh]\[(.*?),(.*?)\]/) { $1.to_s + "\\d" + $2.to_s } return DictFileData.new(C_FILE, textdata, d_txt.split(/\\d/)[0], d_txt.split(/\\d/)[1].to_i) if d_txt != textdata # \\f[FILE]:Graphics/Faceに入っている画像ファイル d_txt = text.gsub(/\\[Ff]\[(.*?),(.*?)\]/) { $1.to_s + "\\d" + $2.to_s } return DictFileData.new(F_FILE, textdata, d_txt.split(/\\d/)[0], d_txt.split(/\\d/)[1].to_i) if d_txt != textdata # テキストのみ return DictFileData.new(N_FILE, textdata) end #-------------------------------------------------------------------------- # ● 用語情報の描画 #-------------------------------------------------------------------------- def self.draw_info_text(bitmap, x, y, w, text_h, txt) txt = "" if txt.nil? text = self.decode(txt) y_org = y xx = 0 line = 0 # 便宜上 text.gsub!(/\\\\/) { "\000" } # \\c[n] : 文字色変更 text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" } # \\+ : ボールド表示 開始/終了 text.gsub!(/\\[+]/) { "\002" } # \\- : イタリック表示 開始/終了 text.gsub!(/\\[-]/) { "\003" } # \\x[n] : X軸方向 n の場所から描画 text.gsub!(/\\[Xx]\[([0-9]+)\]/) { "\004[#{$1}]" } # \\y[n] : 指定行へCR text.gsub!(/\\[Yy]\[([0-9]+)\]/) { "\005[#{$1}]" } # \\i : アイコン表示 text.gsub!(/\\[Ii]\[(.*?+)\]/) { "\006[#{$1}]" } # \\{} : 拡大・縮小 text.gsub!(/\\{/) { "\007" } text.gsub!(/\\}/) { "\008" } # \\n : 改行 text.gsub!(/\\[Nn]/) { "\n" } bold = bitmap.font.bold italic = bitmap.font.italic color = bitmap.font.color.dup size = bitmap.font.size while ((c = text.slice!(/./m)) != nil) break if Dictionary.d_line_max <= line case c when "\000" # \\ の場合、本来の文字に戻す c = "\\" when "\n" # \\n : 改行 xx = 0; y += text_h; line += 1 next # 次の文字へ when "\001" # \\c[n] : 文字色変更 text.sub!(/\[([0-9]+)\]/, "") bitmap.font.color = self.text_color($1.to_i) next # 次の文字へ when "\002" # \\+ : ボールド表示 開始/終了 bitmap.font.bold = !bitmap.font.bold next # 次の文字へ when "\003" # \\- : イタリック表示 開始/終了 bitmap.font.italic = !bitmap.font.italic next # 次の文字へ when "\004" # \\x[n] : X軸方向 n の場所から描画 text.sub!(/\[([0-9]+)\]/, "") xx = $1.to_i next # 次の文字へ when "\005" # \\y[n] : 指定行へCR text.sub!(/\[([0-9]+)\]/, "") y = y_org + $1.to_i * text_h xx = 0 next # 次の文字へ when "\006" # \\i : アイコン表示 text.sub!(/\[(.*?+)\]/, "") xx += self.draw_icon(bitmap, x+xx, y, text_h, $1.to_i) next # 次の文字へ when "\007" # \\{ : 拡大 bitmap.font.size += 8 if bitmap.font.size <= 64 next # 次の文字へ when "\008" # \\} : 縮小 bitmap.font.size -= 8 if bitmap.font.size >= 16 next # 次の文字へ end # 文字を描画 bitmap.draw_text(x+xx, y, 40, text_h, c) # x に描画した文字の幅を加算 xx += bitmap.text_size(c).width # 自動改行 if xx > w xx = 0; y += text_h; line += 1 end end # 念のため、元に戻す bitmap.font.bold = bold bitmap.font.italic = italic bitmap.font.color = color.dup bitmap.font.size = size end #-------------------------------------------------------------------------- # ● 用語情報の描画(Icon) \\icon用 #-------------------------------------------------------------------------- def self.draw_icon(bitmap, x, y, h, icon_index) bit = Cache.system("Iconset") rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) bitmap.blt(x, y, bit, rect) return rect.width end #-------------------------------------------------------------------------- # ● 用語情報の描画色 \\c用 #-------------------------------------------------------------------------- def self.text_color(n) return Cache.system("Window").get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8) end end module Dictionary #-------------------------------------------------------------------------- # ● デザイン : カテゴリリスト visible(active) #-------------------------------------------------------------------------- def self.d_category_visible return (DESIGN != 1) end #-------------------------------------------------------------------------- # ● デザイン : 用語情報 visible #-------------------------------------------------------------------------- def self.d_info_visible return (DESIGN != 0) end #-------------------------------------------------------------------------- # ● デザイン : カテゴリリスト column_max #-------------------------------------------------------------------------- def self.d_category_column return (DESIGN == 3 ? CATEGORY.size : 1) end #-------------------------------------------------------------------------- # ● デザイン : カテゴリリスト column_max #-------------------------------------------------------------------------- def self.d_words_column case DESIGN when 1, 3, 4; return 1 end return 2 end #-------------------------------------------------------------------------- # ● デザイン : カテゴリリスト情報 Rect #-------------------------------------------------------------------------- def self.d_category_rect(c_h) h = SHOW_COLLECT ? (Graphics.height-c_h) : 416 case DESIGN when 3; return Rect.new(0, 0, Graphics.width, c_h) end return Rect.new(0, 0, 180, h) end #-------------------------------------------------------------------------- # ● デザイン : 用語リスト情報 Rect #-------------------------------------------------------------------------- def self.d_words_rect(c_h, d2h) h = SHOW_COLLECT ? (Graphics.height-c_h) : Graphics.height case DESIGN when 1; return Rect.new(0, 0, 180, h) when 2; return Rect.new(180, 0, Graphics.width-180, d2h) when 3; return Rect.new(0, c_h, 180, h-c_h) when 4; return Rect.new(0, c_h, 180, h-c_h) end return Rect.new(180, 0, Graphics.width-180, Graphics.height) end #-------------------------------------------------------------------------- # ● デザイン : 用語情報 Rect #-------------------------------------------------------------------------- def self.d_info_rect(c_h, d2h) case DESIGN when 1,4; return Rect.new(180, 0, Graphics.width-180, Graphics.height) when 2; return Rect.new(180, d2h, Graphics.width-180, Graphics.height-d2h) when 3; return Rect.new(180, c_h, Graphics.width-180, Graphics.height-c_h) end return Rect.new(50, 50, Graphics.width-100, Graphics.height-100) end #-------------------------------------------------------------------------- # ● デザイン : 用語カーソル Rect #-------------------------------------------------------------------------- def self.d_cursor_rect case DESIGN when 1,4; return Rect.new(Graphics.width-24, -10, 0, Graphics.height+44) when 2; return Rect.new(Graphics.width-24, 60, 0, Graphics.height+44) when 3; return Rect.new(Graphics.width-24, 40, 0, Graphics.height+44) end return Rect.new(Graphics.width-78, 40, 0, Graphics.height-6) end #-------------------------------------------------------------------------- # ● デザイン : カテゴリの最大Line数 #-------------------------------------------------------------------------- def self.c_line_max return 1 if DESIGN == 3 return SHOW_COLLECT ? 14 : 16 end #-------------------------------------------------------------------------- # ● デザイン : 用語情報の最大Line数 #-------------------------------------------------------------------------- def self.d_line_max case DESIGN when 0; return 10 when 1,4; return 13 when 2; return 10 when 3; return 12 end end #-------------------------------------------------------------------------- # ● デザイン : カテゴリリスト丸める #-------------------------------------------------------------------------- def self.d_category_shorten return (DESIGN == 4) end end module Dictionary DEFAULT_FLAG = false #============================================================================= # ■ DictData:用語データクラス #============================================================================= class DictData attr_reader :id # 用語ID attr_reader :type # 種類 attr_reader :sub_g # サブ画像 attr_reader :info # 説明文 attr_reader :show_flg # 表示フラグ attr_accessor :color # 表示色 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(id, data) msgbox "DictData:",id, data if data.nil? @id = id @name = data[0] @type = data[1] @sub_g = data[2] @info = data[3] @show_flg = data[4] == nil ? DEFAULT_FLAG : data[4] @color = data[5] == nil ? 1 : data[5] end #-------------------------------------------------------------------------- # ● 用語名[構文解析対応版] #-------------------------------------------------------------------------- def name return DictFunc.decode(@name) end #-------------------------------------------------------------------------- # ● 各パラメータの変更 #-------------------------------------------------------------------------- def name=(n) @name = n update_color end def type=(t) @type = t update_color end def sub_g=(s) @sub_g = s update_color end def info=(i) @info = i update_color end def show_flg=(f) @show_flg = f new_color end #-------------------------------------------------------------------------- # ● 色更新 #-------------------------------------------------------------------------- def new_color @color = 1 if @color != 0 end def update_color @color = 2 if @color == 0 end #-------------------------------------------------------------------------- # ● 種類描画[構文解析対応版] #-------------------------------------------------------------------------- def draw_type(bitmap, x, y) DictFunc.type_decode(@type).draw_bitmap(bitmap, 7, x, y) end def type_icon? return DictFunc.type_decode(@type).icon? end #-------------------------------------------------------------------------- # ● サブ画像描画[構文解析対応版] #-------------------------------------------------------------------------- def draw_sub_g(bitmap, x, y) return if @sub_g.nil? return if DictFunc.type_decode(@sub_g).text? DictFunc.type_decode(@sub_g).draw_bitmap(bitmap, 3, x, y) end #-------------------------------------------------------------------------- # ● ページごとの情報に配列化 #-------------------------------------------------------------------------- def page_text return info.split(/\\p/) end #-------------------------------------------------------------------------- # ● 説明文[改行点ごとに配列化] #-------------------------------------------------------------------------- def info_text(page_i) return page_text[page_i].split(/\\n/) end #-------------------------------------------------------------------------- # ● 説明文の最大ページ数 #-------------------------------------------------------------------------- def max_page return page_text.size end #-------------------------------------------------------------------------- # ● 文字色 #-------------------------------------------------------------------------- def txt_color(normal_color) case @color when 1; return NEW_COLOR when 2; return CHG_COLOR end return normal_color end end #============================================================================= # ■ DictWords :用語カテゴリデータクラス #============================================================================= class DictWords attr_reader :id # カテゴリID #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(id) caller() if id == nil @id = id reset end #-------------------------------------------------------------------------- # ● データリセット #-------------------------------------------------------------------------- def reset @list = {} end #-------------------------------------------------------------------------- # ● IDリスト取得 #-------------------------------------------------------------------------- def keys return [] if WORDS[@id].nil? # 設定おかしいけど継続 if WORDS[@id].is_a?(Hash) return WORDS[@id].keys.sort elsif defined?(DictAutoCreate) # 自動生成Plugin return DictAutoCreate.plugin_auto_ids(WORDS[@id]) end return [] # 設定おかしいけど継続 end #-------------------------------------------------------------------------- # ● データ参照error : 設定にないIDを参照しようとしたときにエラー出力 #-------------------------------------------------------------------------- def print_error(id) p "error ID(wrong setting) : category=#{@id}, id=#{id}" caller() nil end #-------------------------------------------------------------------------- # ● データ参照 #-------------------------------------------------------------------------- def [](id) if @list[id].nil? return print_error(id) if WORDS[@id].nil? # nil返す。NoMethodErrorで落ちるはず if WORDS[@id].is_a?(Hash) return print_error(id) if WORDS[@id][id].nil? # nil返す。NoMethodErrorで落ちるはず @list[id] = DictData.new(id, WORDS[@id][id]) elsif defined?(DictAutoCreate) # 自動生成Plugin @list[id] = DictAutoCreate.plugin_auto_create(WORDS[@id], id) else return print_error(id) # nil返す。NoMethodErrorで落ちるはず end end return @list[id] end #-------------------------------------------------------------------------- # ● カテゴリデータ数 #-------------------------------------------------------------------------- def size return keys.size end #-------------------------------------------------------------------------- # ● カテゴリ名 #-------------------------------------------------------------------------- def name return CATEGORY[@id] end end #============================================================================= # ■ Dictionary :用語辞典データクラス #============================================================================= class Dictionary #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize reset end #-------------------------------------------------------------------------- # ● データリセット #-------------------------------------------------------------------------- def reset @list = {} end #-------------------------------------------------------------------------- # ● IDリスト取得 #-------------------------------------------------------------------------- def keys ids = [] CATEGORY.each_index { |i| ids.push(i) } return ids end #-------------------------------------------------------------------------- # ● データ参照 #-------------------------------------------------------------------------- def [](id) @list[id] = DictWords.new(id) if @list[id].nil? return @list[id] end #-------------------------------------------------------------------------- # ● カテゴリデータ数 #-------------------------------------------------------------------------- def size return CATEGORY.size end end end #============================================================================== # ■ Game_System #============================================================================== class Game_System attr_accessor :dictionary # 辞書データ #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias init_dict initialize def initialize init_dict @dictionary = Dictionary::Dictionary.new end end