#============================================================================== # ■ オートマッピング機能を追加するスクリプト # Ver 0.01 2017/04/09 # http://fweb.midi.co.jp/~mikagami/atelier/ #------------------------------------------------------------------------------ # # ダンジョン等の地図を参照する機能を追加します。 # 主な機能は次のとおりです。 # ・白地図を埋めていくオートマッピング機能 # ・画面隅に周辺地図を表示できます # ・マッピング画面にて取得した地図を一覧表示する機能 # # 主な使用方法 # ・マップ設定のメモ欄に「*MAP_AUTO」と入力すると、そのマップに移動したときに #  自動的にオートマッピング形式の地図を追加します。 # ・マップ設定のメモ欄に「*MAP_OPEN」と入力すると、そのマップに移動したときに #  自動的に全開状態の地図を追加します。 # ・任意の地図を追加したい場合、スクリプトで「Mapping.mapping_allopen(map_id)」 #  (map_idはマップのID)を実行して下さい。 # ・任意の地図を削除したい場合、スクリプトで「$game_party.mappings[map_id]=nil」 #  (map_idはマップのID)を実行して下さい。 # ・下の★の設定値を適宜変更して下さい。 # # ※注意! # ・マップのループには対応しておりません(ループしているように表示されません)。 # ・マップ上のイベントを表示する機能はありません。 # ・他のスクリプトと競合が起こるかもしれません。 # ・ひととおりの動作確認はしていますが、不具合ゼロを保障するものではありません。 # ・このスクリプトの著作権は著者にあります。 #  ですがスクリプトの利用や改造・再配布に著者の許可は必要ありません。 #  著者には未完成な部分の補完や改造依頼に対する対応義務はありません。 #  他者に改造依頼するより、あなた自身が改造すれば、みんなが幸せになります。 # #============================================================================== module Mapping #-------------------------------------------------------------------------- # ● 動作設定 #-------------------------------------------------------------------------- CAMP_MAPPING_SCENE = true # ★メニュー画面にコマンド「地図」を追加する #-------------------------------------------------------------------------- # ● キー設定 #-------------------------------------------------------------------------- KEY_MAPPING_SCENE = :R # ★マッピング画面へのショートカットキー。使用しない場合は nil KEY_MAPPING_POS = :L # ★周辺地図の表示位置を変更するキー。右下⇒左下⇒非表示を繰り返す。使用しない場合は nil # 下の VAR_MAPPING_POS が-1以下なら無効。 #-------------------------------------------------------------------------- # ● 使用する変数No #-------------------------------------------------------------------------- VAR_MAPPING_POS = 10 # ★周辺地図の表示位置を保持する変数No 変数内数値=1,2,3 # ゲーム中、表示位置を変更しない場合は -1:右下 -2:左下 -3:非表示 VAR_MAPPING_OPA = -178 # ★周辺地図の不透明度を保持する変数No 変数内数値=0..255 # ゲーム中、不透明度を変更しない場合は -1..-255(-255=不透過) #-------------------------------------------------------------------------- # ● 使用するスイッチNo #-------------------------------------------------------------------------- SWT_MAPPING_HIDDEN = -1 # ★周辺地図を一時的に非表示にするスイッチNo。使用しない場合は -1 # ON=非表示、OFF=表示 SWT_CAMP_MAP_DIS = -1 # ★マッピング画面への移行を一時的に無効にするスイッチNo。使用しない場合は -1 # ON=移行できない、OFF=移行できる #-------------------------------------------------------------------------- # ● 定数 #-------------------------------------------------------------------------- SIGN_MAP_AUTO = "*MAP_AUTO" # ★マップのメモ欄に記入する文字列。オートマッピング SIGN_MAP_OPEN = "*MAP_OPEN" # ★マップのメモ欄に記入する文字列。最初から地図全開 MAP_TILE_SIZE = 3 # ★地図の1マスの大きさ MAP_LINE_SIZE = 1 # ★地図のタイル間の線の太さ REGION_BLOCK = -1 # ★通行不可マスとして表示するリージョンNo REGION_MOVE = 55 # ★移動マス(階段等)として表示するリージョンNo REGION_OBJECT = 47 # ★その他のモノとして表示するリージョンNo MAPPING_RANGE = 6 # ★地図を埋める範囲。主人公からの距離マス CAMP_MAPPING_TITLE = "地図" # ★メニュー画面のコマンドの文字列 #-------------------------------------------------------------------------- # ● 地図の色の指定 #-------------------------------------------------------------------------- COLOR_BLOCK = Color.new(180, 180, 180) # ★通行不可マスの色 COLOR_FLOOR = Color.new(255, 255, 255) # ★通行可能マスの色 COLOR_LINE = Color.new( 64, 64, 64) # ★カベの色 COLOR_MOVE = Color.new( 64, 255, 0) # ★移動マス(階段等)の色 COLOR_OBJECT = Color.new(255, 160, 0) # ★その他のモノの色 COLOR_ACTOR = Color.new(255, 0, 0) # ★主人公キャラクタの現在地の色 #-------------------------------------------------------------------------- # ● 周辺地図の設定 #-------------------------------------------------------------------------- MAP_RECT = Rect.new(0, 0, 120, 90) # ★周辺地図の大きさ #-------------------------------------------------------------------------- # ● 指定した地図を全開状態にする。スクリプトで実行する。 #-------------------------------------------------------------------------- def self.mapping_allopen(map_id) $game_party.mappings[map_id] = Game_Mapping.new(map_id, 2) end #-------------------------------------------------------------------------- # ● マッピング準備。Game_Map の setup 時に呼ばれる。またはスクリプトで実行する #-------------------------------------------------------------------------- def self.setup_mapping(map_id, map_mode = 0) $game_party.create_mapping # マッピングデータ初期作成 return if map_mode < 0 if !$game_party.mappings[map_id] $game_party.mappings[map_id] = Game_Mapping.new(map_id, map_mode) end end #-------------------------------------------------------------------------- # ● マッピングする #-------------------------------------------------------------------------- def self.mapping(map_id, x, y, range = MAPPING_RANGE) return if !$game_party.mappings[map_id] return if range <= 0 return if $game_party.mappings[map_id].automap[x, y] > 1 # マッピング済 for pos in get_mapping_arr(x, y, range) ix = pos[0]; iy = pos[1] next if ix < 0 || iy < 0 next if ix >= $game_party.mappings[map_id].automap.xsize || iy >= $game_party.mappings[map_id].automap.ysize value = (x == ix && y == iy) ? 2 : 1 $game_party.mappings[map_id].automap[ix, iy] = value if $game_party.mappings[map_id].automap[ix, iy] < value end end #-------------------------------------------------------------------------- # ● マッピングする範囲を座標の配列で返す #-------------------------------------------------------------------------- def self.get_mapping_arr(x, y, range) result = [] for ix in (x - range - 1)..(x + range); for iy in (y - range - 1)..(y + range) next if (ix - x) ** 2 + (iy - y) ** 2 > (range ** 2 + (range + 1) ** 2) / 2 result.push([ix, iy]) end; end return result end #-------------------------------------------------------------------------- # ● 主人公座標を簡易マップ座標に変換 #-------------------------------------------------------------------------- def self.get_map_point(x = $game_player.x, y = $game_player.y) ix = x * (MAP_TILE_SIZE + MAP_LINE_SIZE) + MAP_LINE_SIZE + MAP_TILE_SIZE / 2 iy = y * (MAP_TILE_SIZE + MAP_LINE_SIZE) + MAP_LINE_SIZE + MAP_TILE_SIZE / 2 return [ix, iy] end #-------------------------------------------------------------------------- # ● マップデータの取得 #-------------------------------------------------------------------------- def self.load_mapdata(map_id) return load_data(sprintf("Data/Map%03d.rvdata2", map_id)) end #-------------------------------------------------------------------------- # ● マップ画像の作成 #-------------------------------------------------------------------------- def self.create_map_bitmap(map_id) map = load_mapdata(map_id) tile_interval = MAP_TILE_SIZE + MAP_LINE_SIZE bitmap = Bitmap.new(map.width * tile_interval + MAP_LINE_SIZE, map.height * tile_interval + MAP_LINE_SIZE) bitmap.fill_rect(bitmap.rect, COLOR_FLOOR) tileset = $data_tilesets[map.tileset_id] map.width.times do |x|; map.height.times do |y| color = nil color_u = nil; color_b = nil; color_l = nil; color_r = nil if (map.data[x, y, 3] >> 8) == REGION_BLOCK || map.data[x, y, 0] == 0 color = COLOR_BLOCK color_u = COLOR_LINE; color_b = COLOR_LINE color_l = COLOR_LINE; color_r = COLOR_LINE else 2.downto(0) do |z| flag = tileset.flags[map.data[x, y, z]] next if flag & 0x10 != 0 # [☆] : 通行に影響しない color_b = COLOR_LINE if flag & 0x01 == 0x01 # 下 通行不可 color_l = COLOR_LINE if flag & 0x02 == 0x02 # 左 通行不可 color_r = COLOR_LINE if flag & 0x04 == 0x04 # 右 通行不可 color_u = COLOR_LINE if flag & 0x08 == 0x08 # 上 通行不可 color = COLOR_BLOCK if color_b && color_l && color_r && color_u color = COLOR_MOVE if (map.data[x, y, 3] >> 8) == REGION_MOVE color = COLOR_OBJECT if (map.data[x, y, 3] >> 8) == REGION_OBJECT break end end bitmap.fill_rect(x * tile_interval + MAP_LINE_SIZE, y * tile_interval + MAP_LINE_SIZE, MAP_TILE_SIZE, MAP_TILE_SIZE, color) if color bitmap.fill_rect(x * tile_interval, y * tile_interval, MAP_TILE_SIZE + MAP_LINE_SIZE * 2, MAP_LINE_SIZE, color_u) if color_u bitmap.fill_rect(x * tile_interval, (y + 1) * tile_interval, MAP_TILE_SIZE + MAP_LINE_SIZE * 2, MAP_LINE_SIZE, color_b) if color_b bitmap.fill_rect(x * tile_interval, y * tile_interval, MAP_LINE_SIZE, MAP_TILE_SIZE + MAP_LINE_SIZE * 2, color_l) if color_l bitmap.fill_rect((x + 1) * tile_interval, y * tile_interval, MAP_LINE_SIZE, MAP_TILE_SIZE + MAP_LINE_SIZE * 2, color_r) if color_r end; end return bitmap end #-------------------------------------------------------------------------- # ● マップマスク画像の作成 #-------------------------------------------------------------------------- def self.create_map_v_bitmap(map_id) map = $game_party.mappings[map_id].automap return Bitmap.new(1, 1) if !map tile_interval = MAP_TILE_SIZE + MAP_LINE_SIZE bitmap = Bitmap.new(map.xsize * tile_interval + MAP_LINE_SIZE, map.ysize * tile_interval + MAP_LINE_SIZE) bitmap.fill_rect(bitmap.rect, COLOR_BLOCK) map.xsize.times do |x|; map.ysize.times do |y| next if map[x, y] == 0 bitmap.clear_rect(x * tile_interval, y * tile_interval, tile_interval + MAP_LINE_SIZE, tile_interval + MAP_LINE_SIZE) end; end return bitmap end #-------------------------------------------------------------------------- # ● マッププレイヤー画像の作成 #-------------------------------------------------------------------------- def self.create_map_p_bitmap(map_id) bm_map = Cache.mapping(map_id) bitmap = Bitmap.new(bm_map.width, bm_map.height) if map_id == $game_map.map_id px = $game_player.x * (MAP_TILE_SIZE + MAP_LINE_SIZE) py = $game_player.y * (MAP_TILE_SIZE + MAP_LINE_SIZE) tile_size = MAP_TILE_SIZE + MAP_LINE_SIZE * 2 bitmap.fill_rect(px, py, tile_size, tile_size, COLOR_ACTOR) bitmap.blur end return bitmap end #-------------------------------------------------------------------------- # ● 周辺地図用のプレイヤー現在位置画像の作成 #-------------------------------------------------------------------------- def self.create_map_p_bitmap2 w = MAP_TILE_SIZE + MAP_LINE_SIZE * 2 + 4 bitmap = Bitmap.new(w, w) bitmap.fill_rect(2, 2, bitmap.rect.width - 4, bitmap.rect.height - 4, COLOR_ACTOR) bitmap.blur return bitmap end #-------------------------------------------------------------------------- # ● マッピングデータの差異チェック #-------------------------------------------------------------------------- def self.mapping_equal?(data1, data2) return false if !data1.is_a?(Table) return false if !data2.is_a?(Table) return false if data1.xsize != data2.xsize return false if data1.ysize != data2.ysize data1.xsize.times do |x|; data2.ysize.times do |y| return false if data1[x, y] != data2[x, y] end; end return true end #-------------------------------------------------------------------------- # ● 周辺地図が一時的に非表示か? #-------------------------------------------------------------------------- def self.mapping_hidden? return false if SWT_MAPPING_HIDDEN < 0 return $game_switches[SWT_MAPPING_HIDDEN] end #-------------------------------------------------------------------------- # ● 周辺地図の表示位置を取得 #-------------------------------------------------------------------------- def self.get_mapping_pos return VAR_MAPPING_POS * -1 if VAR_MAPPING_POS < 0 $game_variables[VAR_MAPPING_POS] = 1 if $game_variables[VAR_MAPPING_POS] == 0 return $game_variables[VAR_MAPPING_POS] end #-------------------------------------------------------------------------- # ● 周辺地図の表示位置を変更 #-------------------------------------------------------------------------- def self.change_mapping_pos return false if VAR_MAPPING_POS < 0 $game_variables[VAR_MAPPING_POS] += 1 $game_variables[VAR_MAPPING_POS] = 1 if $game_variables[VAR_MAPPING_POS] > 3 return true end #-------------------------------------------------------------------------- # ● 周辺地図の不透明度を取得 #-------------------------------------------------------------------------- def self.get_mapping_opacity return VAR_MAPPING_OPA * -1 if VAR_MAPPING_OPA < 0 return $game_variables[VAR_MAPPING_OPA] end #-------------------------------------------------------------------------- # ● マッピング画面への移行が一時的に無効か? #-------------------------------------------------------------------------- def self.camp_map_disabled? return false if SWT_CAMP_MAP_DIS < 0 return $game_switches[SWT_CAMP_MAP_DIS] end #-------------------------------------------------------------------------- # ● エディタによるマップデータ更新等で生じたマッピングデータの不整合を修正する #-------------------------------------------------------------------------- def self.maintenance $game_party.create_mapping for map_id in 1..$game_party.mappings.size map = $game_party.mappings[map_id] next if !map automap1 = map.automap.clone $game_party.mappings[map_id] = Game_Mapping.new(map_id) automap2 = $game_party.mappings[map_id].automap automap2.xsize.times do |x|; automap2.ysize.times do |y| next if automap1.xsize <= x next if automap1.ysize <= y automap2[x, y] = automap1[x, y] end; end end end end module Cache #-------------------------------------------------------------------------- # ★ マッピング画像の取得 #-------------------------------------------------------------------------- def self.mapping(map_id) foldername = "Mapping/" filename = sprintf("%03d", map_id) path = foldername + filename @cache.delete(path) if @cache.include?(path) && @cache[path].disposed? return load_bitmap(foldername, filename) if @cache.include?(path) @cache[path] = Mapping.create_map_bitmap(map_id) return @cache[path] end end module DataManager #-------------------------------------------------------------------------- # ◎ データが更新されている場合はマップを再読み込み(★再定義) #-------------------------------------------------------------------------- def self.reload_map_if_updated if $game_system.version_id != $data_system.version_id $game_map.setup($game_map.map_id) $game_player.center($game_player.x, $game_player.y) $game_player.make_encounter_count Mapping.maintenance # ★ end end end module RPG class Map #-------------------------------------------------------------------------- # ★ 地図モードの取得 #-------------------------------------------------------------------------- def mapping? sig = Mapping::SIGN_MAP_AUTO return 1 if @note[/#{Regexp.quote sig}/] sig = Mapping::SIGN_MAP_OPEN return 2 if @note[/#{Regexp.quote sig}/] return -1 end end end #============================================================================== # ■ Game_Mapping #------------------------------------------------------------------------------ #  地図の取得やオートマッピングの状態を保存するクラス。Game_Party 内で保持する。 #============================================================================== class Game_Mapping #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :map_name # 地図名 attr_accessor :automap # オートマッピングのデータ #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(map_id, open_flag = 0) map = Mapping.load_mapdata(map_id) @map_name = map.display_name == "" ? $data_mapinfos[map_id].name : map.display_name @automap = Table.new(map.width, map.height) open_flag = map.mapping? if open_flag == 0 if open_flag == 2 map.width.times do |x|; map.height.times do |y| @automap[x, y] = 2 end; end end end end class Game_Party < Game_Unit #-------------------------------------------------------------------------- # ★ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :mappings # マッピングデータ #-------------------------------------------------------------------------- # ★ マッピングオブジェクト作成 #-------------------------------------------------------------------------- def create_mapping @mappings = [] if !@mappings end end class Game_Map #-------------------------------------------------------------------------- # ◎ セットアップ #-------------------------------------------------------------------------- alias _mikagami001_setup setup def setup(map_id) _mikagami001_setup(map_id) Mapping.setup_mapping(map_id, mapping?) end #-------------------------------------------------------------------------- # ★ 地図モードの取得 #-------------------------------------------------------------------------- def mapping? return @map.mapping? end end class Game_Player < Game_Character #-------------------------------------------------------------------------- # ◎ 指定位置に移動 #-------------------------------------------------------------------------- alias _mikagami001_moveto moveto def moveto(x, y) _mikagami001_moveto(x, y) on_mapping end #-------------------------------------------------------------------------- # ◎ 歩数増加 #-------------------------------------------------------------------------- alias _mikagami001_increase_steps increase_steps def increase_steps _mikagami001_increase_steps on_mapping end #-------------------------------------------------------------------------- # ◎ マッピングする #-------------------------------------------------------------------------- def on_mapping Mapping.mapping($game_map.map_id, @x, @y) end end #============================================================================== # ■ Spriteset_Mapping #------------------------------------------------------------------------------ #  マップ画面に表示する、周辺地図のスプライトやをまとめたクラスです。 #============================================================================== class Spriteset_Mapping #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize create_sprite end #-------------------------------------------------------------------------- # ● いろいろ作成 #-------------------------------------------------------------------------- def create_sprite @map_viewport = Viewport.new(Mapping::MAP_RECT) @map_viewport.tone = Tone.new(-16, -16, -16, 0) @map_viewport.z = 120 @map_sprite = Sprite.new(@map_viewport) @map_sprite.x = @map_viewport.rect.width / 2 @map_sprite.y = @map_viewport.rect.height / 2 @map_sprite_p = Sprite.new(@map_viewport) @map_sprite_p.x = @map_viewport.rect.width / 2 @map_sprite_p.y = @map_viewport.rect.height / 2 @map_sprite_p.bitmap = Mapping.create_map_p_bitmap2 @map_sprite_p.ox = @map_sprite_p.bitmap.rect.width / 2 @map_sprite_p.oy = @map_sprite_p.bitmap.rect.height / 2 end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose @map_sprite.dispose @map_sprite_p.dispose @map_viewport.dispose end #-------------------------------------------------------------------------- # ● 表示マップの変更 #-------------------------------------------------------------------------- def setup(map_id) return if @map_id == map_id @map_id = map_id @mapping_data = nil @map_sprite.ox = Mapping.get_map_point[0] @map_sprite.oy = Mapping.get_map_point[1] end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update setup($game_map.map_id) update_map_scroll if update_visible update_map_bitmap update_map_position update_map_opacity update_map_p_flash @map_sprite.update @map_sprite_p.update @map_viewport.update end end #-------------------------------------------------------------------------- # ● 表示状態のチェック #-------------------------------------------------------------------------- def update_visible visible = true if !$game_party.mappings[@map_id] || Mapping.mapping_hidden? || Mapping.get_mapping_pos == 3 visible = false end @map_viewport.visible = visible return visible end #-------------------------------------------------------------------------- # ● 地図画像の更新 #-------------------------------------------------------------------------- def update_map_bitmap mapping_data = $game_party.mappings[@map_id].automap.clone return if Mapping.mapping_equal?(mapping_data, @mapping_data) @mapping_data = mapping_data bm_map = Cache.mapping(@map_id) bm_v = Mapping.create_map_v_bitmap(@map_id) bitmap = Bitmap.new(bm_map.width, bm_map.height) bitmap.blt(0, 0, bm_map, bitmap.rect) bitmap.blt(0, 0, bm_v, bitmap.rect) @map_sprite.bitmap.dispose if @map_sprite.bitmap bm_v.dispose @map_sprite.bitmap = bitmap end #-------------------------------------------------------------------------- # ● 地図スクロールの更新 #-------------------------------------------------------------------------- def update_map_scroll map_pos = Mapping.get_map_point @map_sprite.ox += 1 if @map_sprite.ox < map_pos[0] @map_sprite.ox -= 1 if @map_sprite.ox > map_pos[0] @map_sprite.oy += 1 if @map_sprite.oy < map_pos[1] @map_sprite.oy -= 1 if @map_sprite.oy > map_pos[1] end #-------------------------------------------------------------------------- # ● 地図表示位置の更新 #-------------------------------------------------------------------------- def update_map_position pos = Mapping.get_mapping_pos return if @map_pos == pos @map_pos = pos space = 12 rect = @map_viewport.rect if pos == 2 # 左下 rect.x = space rect.y = Graphics.height - rect.height - space else # 右下 rect.x = Graphics.width - rect.width - space rect.y = Graphics.height - rect.height - space end @map_viewport.rect = rect end #-------------------------------------------------------------------------- # ● 地図の不透明度の更新 #-------------------------------------------------------------------------- def update_map_opacity opa = Mapping.get_mapping_opacity return if @map_sprite.opacity == opa @map_sprite.opacity = opa end #-------------------------------------------------------------------------- # ● 現在地の点滅の更新 #-------------------------------------------------------------------------- def update_map_p_flash @map_p_value = -4 if !@map_p_value @map_sprite_p.opacity += @map_p_value @map_p_value = 4 if @map_sprite_p.opacity <= 50 @map_p_value = -4 if @map_sprite_p.opacity >= 230 end end class Spriteset_Map #-------------------------------------------------------------------------- # ◎ オブジェクト初期化 #-------------------------------------------------------------------------- alias _mikagami001_initialize initialize def initialize @spriteset_mapping = Spriteset_Mapping.new _mikagami001_initialize end #-------------------------------------------------------------------------- # ◎ 解放 #-------------------------------------------------------------------------- alias _mikagami001_dispose dispose def dispose @spriteset_mapping.dispose _mikagami001_dispose end #-------------------------------------------------------------------------- # ◎ フレーム更新 #-------------------------------------------------------------------------- alias _mikagami001_update update def update _mikagami001_update @spriteset_mapping.update end end #============================================================================== # ■ Window_Mapping #------------------------------------------------------------------------------ #  マッピング画面で表示する地図のウィンドウです。 #============================================================================== class Window_Mapping < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(map_id = nil) super(0, 0, Graphics.width, Graphics.height) @move_speed = 2 create_map_sprite setup(map_id) end #-------------------------------------------------------------------------- # ● マップスプライトの作成 #-------------------------------------------------------------------------- def create_map_sprite @map_viewport = Viewport.new(self.x + 16, self.y + 64, self.width - 32, self.height - 80) @map_sprite = Sprite.new(@map_viewport) @map_sprite.x = @map_viewport.rect.width / 2 @map_sprite.y = @map_viewport.rect.height / 2 @map_sprite_p = Sprite.new(@map_viewport) @map_sprite_p.x = @map_viewport.rect.width / 2 @map_sprite_p.y = @map_viewport.rect.height / 2 @map_viewport.z = self.z + 1 end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose @map_sprite.dispose @map_sprite_p.dispose @map_viewport.dispose super end #-------------------------------------------------------------------------- # ● 表示マップの変更 #-------------------------------------------------------------------------- def setup(map_id) return if @map_id == map_id @map_id = map_id bm_map = Cache.mapping(@map_id) bm_v = Mapping.create_map_v_bitmap(@map_id) bitmap = Bitmap.new(bm_map.width, bm_map.height) bitmap.blt(0, 0, bm_map, bitmap.rect) bitmap.blt(0, 0, bm_v, bitmap.rect) @map_sprite.bitmap.dispose if @map_sprite.bitmap bm_v.dispose @map_sprite.bitmap = bitmap @map_sprite.ox = @map_sprite.bitmap.width / 2 @map_sprite.oy = @map_sprite.bitmap.height / 2 @map_sprite_p.bitmap.dispose if @map_sprite_p.bitmap && !@map_sprite_p.bitmap.disposed? @map_sprite_p.bitmap = Mapping.create_map_p_bitmap(@map_id) @map_sprite_p.ox = @map_sprite_p.bitmap.width / 2 @map_sprite_p.oy = @map_sprite_p.bitmap.height / 2 @map_sprite.zoom_x = @map_sprite.zoom_y = 1.0 @map_sprite_p.zoom_x = @map_sprite_p.zoom_y = 1.0 refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear text = $game_party.mappings[@map_id].map_name draw_text(10, 0, contents.width - 10, line_height, text) contents.fill_rect(0, line_height * 1, contents_width, 1, normal_color) f_size = contents.font.size contents.font.size = 20 text = "Q: Zoom − W: Zoom + Cancel: Map List" draw_text(16, line_height + 4, contents.width - 32, line_height, text, 2) contents.font.size = f_size end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super update_map_sprite end #-------------------------------------------------------------------------- # ● 地図スプライトの更新 #-------------------------------------------------------------------------- def update_map_sprite @map_p_value = -4 if !@map_p_value @map_sprite_p.opacity += @map_p_value @map_p_value = 4 if @map_sprite_p.opacity <= 50 @map_p_value = -4 if @map_sprite_p.opacity >= 230 @map_viewport.update @map_sprite.update @map_sprite_p.update end #-------------------------------------------------------------------------- # ● 決定やキャンセルなどのハンドリング処理 #-------------------------------------------------------------------------- def process_handling super return unless open? && active process_left if Input.press?(:LEFT) process_right if Input.press?(:RIGHT) process_up if Input.press?(:UP) process_down if Input.press?(:DOWN) return process_zoom(0.5) if Input.trigger?(:L) return process_zoom(2.0) if Input.trigger?(:R) end #-------------------------------------------------------------------------- # ● 左移動の処理 #-------------------------------------------------------------------------- def process_left @map_sprite.ox += @move_speed if @map_sprite && @map_sprite.ox < @map_sprite.width @map_sprite_p.ox = @map_sprite.ox end #-------------------------------------------------------------------------- # ● 右移動の処理 #-------------------------------------------------------------------------- def process_right @map_sprite.ox -= @move_speed if @map_sprite && @map_sprite.ox > 0 @map_sprite_p.ox = @map_sprite.ox end #-------------------------------------------------------------------------- # ● 上移動の処理 #-------------------------------------------------------------------------- def process_up @map_sprite.oy += @move_speed if @map_sprite && @map_sprite.oy < @map_sprite.height @map_sprite_p.oy = @map_sprite.oy end #-------------------------------------------------------------------------- # ● 下移動の処理 #-------------------------------------------------------------------------- def process_down @map_sprite.oy -= @move_speed if @map_sprite && @map_sprite.oy > 0 @map_sprite_p.oy = @map_sprite.oy end #-------------------------------------------------------------------------- # ● 地図ズームの処理 #-------------------------------------------------------------------------- def process_zoom(zoom) return if !@map_sprite zoom_after = @map_sprite.zoom_x * zoom return if zoom_after < 1.0 return if zoom_after > 4.0 Sound.play_cursor @map_sprite_p.zoom_x = @map_sprite.zoom_x = zoom_after @map_sprite_p.zoom_y = @map_sprite.zoom_y = zoom_after end end #============================================================================== # ■ Window_MappingList #------------------------------------------------------------------------------ #  マッピング画面で表示する地図リストのウィンドウです。 #============================================================================== class Window_MappingList < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(8, line_height + 16, 100, 100) @data = [] refresh end #-------------------------------------------------------------------------- # ● 項目数の取得 #-------------------------------------------------------------------------- def item_max @data ? @data.size : 1 end #-------------------------------------------------------------------------- # ● アイテムの取得 #-------------------------------------------------------------------------- def item @data && index >= 0 ? @data[index] : nil end #-------------------------------------------------------------------------- # ● 選択項目の有効状態を取得 #-------------------------------------------------------------------------- def current_item_enabled? enable?(@data[index]) end #-------------------------------------------------------------------------- # ● アイテムを許可状態で表示するかどうか #-------------------------------------------------------------------------- def enable?(item) item != nil end #-------------------------------------------------------------------------- # ● アイテムリストの作成 #-------------------------------------------------------------------------- def make_item_list list = [] for i in 1..$data_mapinfos.size info = $data_mapinfos[i] list[info.order] = i end list.compact! for map_id in list next if !$game_party.mappings[map_id] @data.push(map_id) end @data.push(nil) if @data.empty? end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] rect = item_rect(index) rect.x += 2; rect.width -= 4 change_color(normal_color, enable?(item)) contents.draw_text(rect, map_name(item)) end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh make_item_list create_window_size create_contents draw_all_items end #-------------------------------------------------------------------------- # ● ウィンドウのサイズを変更する #-------------------------------------------------------------------------- def create_window_size bm = Bitmap.new(1, 1) w = 100 item_max.times {|i| w = [w, bm.text_size(map_name(@data[i])).width].max } self.width = [w + standard_padding * 2 + 8, Graphics.width - 16].min self.height = [item_height * item_max + standard_padding * 2, Graphics.height - line_height - 24].min end #-------------------------------------------------------------------------- # ● 地図名の取得 #-------------------------------------------------------------------------- def map_name(map_id) return "地図がありません" if map_id == nil return $game_party.mappings[map_id].map_name end #-------------------------------------------------------------------------- # ● 指定したマップIDの地図を選択 #-------------------------------------------------------------------------- def select_map(map_id) select(@data.index(map_id) || 0) end end #============================================================================== # ■ Scene_Mapping #------------------------------------------------------------------------------ #  マッピング画面の処理を行うクラスです。 #============================================================================== class Scene_Mapping < Scene_MenuBase #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super create_map_window create_list_window if $game_party.mappings[$game_map.map_id] @list_window.select_map($game_map.map_id) on_list_ok else @list_window.select(0) @mapping_window.setup(@list_window.item) on_map_cancel end end #-------------------------------------------------------------------------- # ● マッピングウィンドウの作成 #-------------------------------------------------------------------------- def create_map_window @mapping_window = Window_Mapping.new(nil) @mapping_window.set_handler(:cancel, method(:on_map_cancel)) end #-------------------------------------------------------------------------- # ● リストウィンドウの作成 #-------------------------------------------------------------------------- def create_list_window @list_window = Window_MappingList.new @list_window.set_handler(:ok, method(:on_list_ok)) @list_window.set_handler(:cancel, method(:return_scene)) @list_window.z += 10 @list_window.deactivate end #-------------------------------------------------------------------------- # ● マッピングでキャンセルボタン押下 #-------------------------------------------------------------------------- def on_map_cancel @mapping_window.deactivate @list_window.show.activate end #-------------------------------------------------------------------------- # ● リストで決定ボタン押下 #-------------------------------------------------------------------------- def on_list_ok @list_window.hide @mapping_window.setup(@list_window.item) @mapping_window.activate end end class Window_MenuCommand < Window_Command #-------------------------------------------------------------------------- # ◎ 独自コマンドの追加用 #-------------------------------------------------------------------------- alias _mikagami001_add_original_commands add_original_commands def add_original_commands if Mapping::CAMP_MAPPING_SCENE enabled = !Mapping.camp_map_disabled? enabled = false if $game_party.mappings.size <= 0 add_command(Mapping::CAMP_MAPPING_TITLE, :mapping, enabled) end end end class Scene_Menu < Scene_MenuBase #-------------------------------------------------------------------------- # ◎ コマンドウィンドウの作成 #-------------------------------------------------------------------------- alias _mikagami001_create_command_window create_command_window def create_command_window _mikagami001_create_command_window @command_window.set_handler(:mapping, method(:command_mapping)) end #-------------------------------------------------------------------------- # ★ コマンド[地図] #-------------------------------------------------------------------------- def command_mapping SceneManager.call(Scene_Mapping) end end class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # ◎ シーン遷移に関連する更新 #-------------------------------------------------------------------------- alias _mikagami001_update_scene update_scene def update_scene _mikagami001_update_scene update_mapping_key unless scene_changing? end #-------------------------------------------------------------------------- # ★ マッピング関係のキー判定 #-------------------------------------------------------------------------- def update_mapping_key call_mapping if Mapping::KEY_MAPPING_SCENE && Input.trigger?(Mapping::KEY_MAPPING_SCENE) on_mapping_pos if Mapping::KEY_MAPPING_POS && Input.trigger?(Mapping::KEY_MAPPING_POS) end #-------------------------------------------------------------------------- # ★ マップ画面の呼び出し #-------------------------------------------------------------------------- def call_mapping return if Mapping.camp_map_disabled? return if $game_party.mappings.size <= 0 Sound.play_ok SceneManager.call(Scene_Mapping) end #-------------------------------------------------------------------------- # ★ 周辺地図の表示位置を変更 #-------------------------------------------------------------------------- def on_mapping_pos return if !$game_party.mappings[$game_map.map_id] return if Mapping.mapping_hidden? Sound.play_cursor if Mapping.change_mapping_pos end end