#============================================================================== # ■ VXAce-RGSS3-33 ワールドマップ [データ] by Claimh #============================================================================== #============================================================================== # ■ Game_System #============================================================================== class Game_System #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :worldmap # 世界地図情報 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias init_map_system initialize def initialize init_map_system @worldmap = WorldMap::WorldMapInfo.new end end #============================================================================== # ■ WorldMapInfo : ワールドマップ情報クラス #============================================================================== class WorldMap::WorldMapInfo #-------------------------------------------------------------------------- # ● 初期化 #-------------------------------------------------------------------------- def initialize reset end def reset @region = {} end #-------------------------------------------------------------------------- # ● リージョンID配列 #-------------------------------------------------------------------------- def ids WorldMap::REGION.keys.sort end #-------------------------------------------------------------------------- # ● データ取得 #-------------------------------------------------------------------------- def [](r_id) @region[r_id] = WorldMap::RegionInfo.new(r_id) if @region[r_id].nil? @region[r_id] end #-------------------------------------------------------------------------- # ● エイリアスリンク変換処理 #-------------------------------------------------------------------------- def conv_aliaslink(map_id) WorldMap::ALIAS_LINK[map_id].nil? ? map_id : WorldMap::ALIAS_LINK[map_id] end #-------------------------------------------------------------------------- # ● タウン情報検索 #-------------------------------------------------------------------------- def search_town(map_id) ids.each do |r_id| self.[](r_id).ids.each do |t_id| return @region[r_id][t_id] if @region[r_id][t_id].map_id == map_id end end nil end #-------------------------------------------------------------------------- # ● マップツリーからタウン情報を検索 #-------------------------------------------------------------------------- def search_tree_town(map_id) map = load_data(sprintf("Data/MapInfos.rvdata2")) loop do map_id = map[map_id].parent_id return nil if map_id == 0 info = search_town(conv_aliaslink(map_id)) return info unless info.nil? end nil end #-------------------------------------------------------------------------- # ● 現在のマップIDからタウン情報を参照する #-------------------------------------------------------------------------- def get_mapid_to_town(map_id) info = search_town(conv_aliaslink(map_id)) return info unless info.nil? info = search_tree_town(map_id) if WorldMap::ALIAS_TREE return info unless info.nil? msgbox "呼び出し位置がリージョンに登録されてません map_id=#{map_id}" exit end #-------------------------------------------------------------------------- # ● 地域名の配列リストを作成する #-------------------------------------------------------------------------- def make_region_list ids.select {|r_id| self.[](r_id).visible }.collect {|r_id| @region[r_id]} end end #============================================================================= # ■ RegionInfo : リージョン情報クラス #----------------------------------------------------------------------------- # このクラスは $game_system.worldmap[リージョンID] で参照できます。 #============================================================================= class WorldMap::RegionInfo #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :region_id # 地域ID attr_accessor :region_name # 地域名 attr_accessor :region_map # 地図ファイル名 attr_accessor :region_info # 地域説明文 attr_reader :town # 地点情報 attr_writer :visible # 表示ON/OFF attr_accessor :enable # 選択許可 #-------------------------------------------------------------------------- # ● 初期化 #-------------------------------------------------------------------------- def initialize(id) @region_id = id region = WorldMap::REGION[id] @region_name = region[0] @region_map = region[1].dup @region_info = region[2].dup @town = {} @visible = region[4].nil? ? false : region[4] @enable = true end #-------------------------------------------------------------------------- # ● タウンID配列 #-------------------------------------------------------------------------- def visible @visible or WorldMap::DEBUG end #-------------------------------------------------------------------------- # ● タウンID配列 #-------------------------------------------------------------------------- def ids WorldMap::REGION[@region_id][WorldMap::R_TOWN].keys.sort end #-------------------------------------------------------------------------- # ● データ取得 #-------------------------------------------------------------------------- def [](town_id) @town[town_id] = WorldMap::TownInfo.new(@region_id, town_id) if @town[town_id].nil? @town[town_id] end #-------------------------------------------------------------------------- # ● マップのビットマップ取得 #-------------------------------------------------------------------------- def map_bitmap Cache.picture(@region_map) end #-------------------------------------------------------------------------- # ● 地点名の配列リストを作成する #-------------------------------------------------------------------------- def make_town_list ids.select {|t_id| self.[](t_id).visible }.collect {|t_id| @town[t_id]} end end #============================================================================= # ■ TownInfo : 移動地点情報クラス #----------------------------------------------------------------------------- # このクラスは $game_system.worldmap[リージョンID][タウンID] で参照できます。 #============================================================================= class WorldMap::TownInfo #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :region_id # 地域ID attr_reader :town_id # 地点ID attr_accessor :map_id # マップID attr_accessor :map_pos # 地図位置 attr_accessor :player # 移動後:プレイヤー位置 attr_accessor :icon # 表示アイコン attr_accessor :town_info # 地点情報 attr_writer :visible # 表示ON/OFF attr_accessor :enable # 選択許可 #-------------------------------------------------------------------------- # ● 初期化 #-------------------------------------------------------------------------- def initialize(region_id, town_id) @region_id = region_id @town_id = town_id town = WorldMap::REGION[@region_id][WorldMap::R_TOWN][@town_id] @map_id = town[0] @map_pos = town[1].dup @player = town[2].dup @icon = town[3].nil? ? nil : town[3] @town_info = town[4].dup @visible = town[5].nil? ? false : town[5] @enable = true end #-------------------------------------------------------------------------- # ● タウンID配列 #-------------------------------------------------------------------------- def visible @visible or WorldMap::DEBUG end #-------------------------------------------------------------------------- # ● 移動地点名 #-------------------------------------------------------------------------- def town_name load_data(sprintf("Data/Map%03d.rvdata2", @map_id)).display_name end end module WorldMap #-------------------------------------------------------------------------- # ● 構文解析[テキスト置換] #-------------------------------------------------------------------------- def self.decode(textdata) text = textdata.dup # \\n[ID]:IDで指定したアクターの名前 text.gsub!(/\\n\[([0-9]+)\]/) { $game_actors[$1.to_i].name } # \\e[ID]:IDで指定したエネミーの名前 text.gsub!(/\\e\[([0-9]+)\]/) { $data_enemies[$1.to_i].name } # \\m[ID]:IDで指定したマップ名 text.gsub!(/\\m\[([0-9]+)\]/) { map_name($1.to_i) } text 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 INFO_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, $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, icon_index, file="Iconset") bit = Cache.system(file) rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) bitmap.blt(x, y, bit, rect) rect.width end #-------------------------------------------------------------------------- # ● 用語情報の描画色 \\c用 #-------------------------------------------------------------------------- def self.text_color(n) Cache.system("Window").get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8) end end