#============================================================================== # ■ VXAce-RGSS3-33 ワールドマップ [ウィンドウ] by Claimh #============================================================================== #============================================================================== # ■ Window_WorldMapBase : region/town's basic class #============================================================================== class Window_WorldMapBase < Window_Selectable attr_accessor :back_sprite # 背景スプライト #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize @temp_top_row = 0 super(screen_x, screen_y, window_width, window_height) end #-------------------------------------------------------------------------- # ● ウィンドウ位置 #-------------------------------------------------------------------------- def screen_x 0 end #-------------------------------------------------------------------------- # ● ウィンドウ位置 #-------------------------------------------------------------------------- def screen_y 0 end #-------------------------------------------------------------------------- # ● ウィンドウ高さの取得 #-------------------------------------------------------------------------- def window_width 160 end #-------------------------------------------------------------------------- # ● ウィンドウ高さの取得 #-------------------------------------------------------------------------- def window_height fitting_height(visible_line_number) end #-------------------------------------------------------------------------- # ● 表示行数の取得 #-------------------------------------------------------------------------- def visible_line_number item_max > WorldMap::LIST_MAX ? WorldMap::LIST_MAX : item_max end #-------------------------------------------------------------------------- # ● 項目数の取得 #-------------------------------------------------------------------------- def item_max @list.size end #-------------------------------------------------------------------------- # ● 選択中情報 #-------------------------------------------------------------------------- def data @list[@index] end #-------------------------------------------------------------------------- # ● 選択項目の有効状態を取得 #-------------------------------------------------------------------------- def current_item_enabled? enabled?(@index) end #-------------------------------------------------------------------------- # ● 選択項目の有効状態を取得 #-------------------------------------------------------------------------- def enabled?(index) @list[index].enable end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) change_color(normal_color, enabled?(index)) draw_text(item_rect_for_text(index), name(index)) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(info) end #-------------------------------------------------------------------------- # ● 現在マップに遷移 #-------------------------------------------------------------------------- def reset select(map_index) end #-------------------------------------------------------------------------- # ● 高さリセット #-------------------------------------------------------------------------- def reset_height self.height = window_height self.top_row = @temp_top_row update_cursor end #-------------------------------------------------------------------------- # ● 高さ縮小 #-------------------------------------------------------------------------- def resize_height @temp_top_row = self.top_row return unless WorldMap::RESIZE_REGION self.height = fitting_height(1) update_cursor end end #============================================================================== # ■ Window_Region #============================================================================== class Window_Region < Window_WorldMapBase attr_accessor :town_window # タウンウィンドウ #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize make_list super refresh deactivate end #-------------------------------------------------------------------------- # ● リスト作成 #-------------------------------------------------------------------------- def make_list @list = $game_system.worldmap.make_region_list end #-------------------------------------------------------------------------- # ● 選択中リージョン情報 #-------------------------------------------------------------------------- def info data.region_info end #-------------------------------------------------------------------------- # ● 項目名 #-------------------------------------------------------------------------- def name(index) @list[index].region_name end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help return if item_max == 0 super @back_sprite.set_picture(data) unless @back_sprite.nil? @town_window.make_list(data) unless @town_window.nil? end #-------------------------------------------------------------------------- # ● 現在マップのindex #-------------------------------------------------------------------------- def map_index index = 0 r_id = $game_system.worldmap.get_mapid_to_town($game_map.map_id).region_id @list.each_index {|i| index = i if @list[i].region_id == r_id} index end end #============================================================================== # ■ Window_Town #============================================================================== class Window_Town < Window_WorldMapBase attr_accessor :name_window # 名前ウィンドウ attr_reader :list #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize @list = [] @region_id = nil super activate end #-------------------------------------------------------------------------- # ● ウィンドウ位置 #-------------------------------------------------------------------------- def screen_x Graphics.width - window_width end #-------------------------------------------------------------------------- # ● リスト作成 #-------------------------------------------------------------------------- def make_list(region) return if @region_id == region.region_id @region_id = region.region_id @list = region.make_town_list reset_height create_contents refresh select(0) end #-------------------------------------------------------------------------- # ● 選択中リージョン情報 #-------------------------------------------------------------------------- def info data.town_info end #-------------------------------------------------------------------------- # ● 項目名 #-------------------------------------------------------------------------- def name(index) @list[index].town_name end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help return if item_max == 0 super @name_window.set_text(data) unless @name_window.nil? @back_sprite.move(data.map_pos) unless @back_sprite.nil? end #-------------------------------------------------------------------------- # ● 現在マップのindex #-------------------------------------------------------------------------- def map_index index = 0 t_id = $game_system.worldmap.get_mapid_to_town($game_map.map_id).town_id @list.each_index {|i| index = i if @list[i].town_id == t_id} index end end #============================================================================== # ■ Window_TownName #============================================================================== class Window_TownName < Window_Base attr_accessor :arrow #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize @name = nil super(0, 170, 160, fitting_height(1)) self.opacity = 0 hide end #-------------------------------------------------------------------------- # ● 名前設定 #-------------------------------------------------------------------------- def set_text(town) return if @town == town @town = town self.width = contents.text_size(town.town_name).width + 32 create_contents contents.fill_rect(self.contents.rect, WorldMap::NAME_BACK) draw_text(0, 0, contents_width, line_height, @town.town_name, 1) update_pos end #-------------------------------------------------------------------------- # ● 位置更新 #-------------------------------------------------------------------------- def update_pos if WorldMap::W_CENTARING self.x = Graphics.width / 2 - (self.width / 2) else self.x = @town.map_pos.x - (self.width / 2) self.y = @town.map_pos.y - self.height end @arrow.update_point(self.x + self.width / 2, self.y + self.height, !@town.icon.nil?) unless @arrow.nil? end end #============================================================================== # ■ Window_WorldInfo #============================================================================== class Window_WorldInfo < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize @info = nil super(0, Graphics.height - window_height, Graphics.width, window_height) end #-------------------------------------------------------------------------- # ● ウィンドウ高さ #-------------------------------------------------------------------------- def window_height fitting_height(WorldMap::INFO_MAX) end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def set_text(info) return if @info == info @info = info contents.clear WorldMap.draw_info_text(contents, 0, 0, contents.width, line_height, info) end end #============================================================================== # ■ Arrow_TownPoint #============================================================================== class Arrow_TownPoint < Sprite M_ARW=0; M_CHF=1; M_CHB=2 TIM = WorldMap::W_ARROW_TIME MAX = TIM * 4 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(nil) @blink_count = 0 @index = 0 @mode = WorldMap::W_ARROW_TYPE ? M_CHF : M_ARW @mode == M_ARW ? create_arrow_bitmap : create_char_bitmap self.ox = 16 self.oy = 0 self.z = 100 hide.update end #-------------------------------------------------------------------------- # ● Arrowの表示 #-------------------------------------------------------------------------- def show self.visible = true self end #-------------------------------------------------------------------------- # ● Arrowの非表示 #-------------------------------------------------------------------------- def hide self.visible = false self end #-------------------------------------------------------------------------- # ● ArrowBitmap生成 #-------------------------------------------------------------------------- def create_arrow_bitmap self.bitmap = Cache.system(WorldMap::W_ARROWSKIN) @rect = Rect.new(96, 64, 16, 16) update_arrow end #-------------------------------------------------------------------------- # ● CharacterBitmap生成 #-------------------------------------------------------------------------- def create_char_bitmap actor = $game_party.members[0] self.bitmap = Cache.character(actor.character_name) sign = actor.character_name[/^[\!\$]./] if sign != nil and sign.include?('$') cw = self.bitmap.width / 3; ch = self.bitmap.height / 4 else cw = self.bitmap.width / 12; ch = self.bitmap.height / 8 end n = actor.character_index @rect = Rect.new((n%4*3)*cw, (n/4*4)*ch, cw, ch) update_character end #-------------------------------------------------------------------------- # ● 後ろ向きにする #-------------------------------------------------------------------------- def change_char_back @mode = M_CHB @blink_count = 0 update_character end #-------------------------------------------------------------------------- # ● 位置更新 #-------------------------------------------------------------------------- def update_point(x, y, icon) self.x = x + (@mode == M_ARW ? (@rect.width / 2) : 0) self.y = y - (@mode == M_ARW ? (@rect.height * 3/2) : 0) + (icon ? (@rect.height / 2) : 0) end #-------------------------------------------------------------------------- # ● カーソル位置の設定 # index : 新しいカーソル位置 #-------------------------------------------------------------------------- def index=(index) @index = index update end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update @blink_count = (@blink_count + 1) % MAX @mode == M_ARW ? update_arrow : update_character end #-------------------------------------------------------------------------- # ● フレーム更新 : arrow #-------------------------------------------------------------------------- def update_arrow case @blink_count when (TIM * 0); self.src_rect.set( 96, 64, 16, 16) when (TIM * 1); self.src_rect.set(112, 64, 16, 16) when (TIM * 2); self.src_rect.set(112, 80, 16, 16) when (TIM * 3); self.src_rect.set( 96, 80, 16, 16) end end #-------------------------------------------------------------------------- # ● フレーム更新 : character #-------------------------------------------------------------------------- def update_character w = @rect.width; h = @rect.height i = @mode == M_CHF ? 0 : 3 case @blink_count when (TIM * 0); self.src_rect.set(@rect.x + w * 1, @rect.y + h * i, w, h) when (TIM * 1); self.src_rect.set(@rect.x + w * 0, @rect.y + h * i, w, h) when (TIM * 2); self.src_rect.set(@rect.x + w * 1, @rect.y + h * i, w, h) when (TIM * 3); self.src_rect.set(@rect.x + w * 2, @rect.y + h * i, w, h) end end end #============================================================================== # ■ Game_WorldMapPicture #============================================================================== class Game_WorldMapPicture < Game_Picture attr_writer :name attr_accessor :center # 中央表示ON #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0) @center = WorldMap::W_CENTARING end #-------------------------------------------------------------------------- # ● ピクチャの移動 #-------------------------------------------------------------------------- def move(x, y) return unless WorldMap::W_CENTARING @target_x = x @target_y = y @target_zoom_x = @target_zoom_y = WorldMap::W_SELECT_Z @duration = WorldMap::W_SELECT_T end #-------------------------------------------------------------------------- # ● ピクチャのフェードアウト #-------------------------------------------------------------------------- def fadeout @target_zoom_x = @target_zoom_y = WorldMap::W_CANCEL_Z @target_opacity = 0 @duration = WorldMap::W_ENTER_ZOOM_T end #-------------------------------------------------------------------------- # ● ピクチャのフェードアウト #-------------------------------------------------------------------------- def fadein @target_zoom_x = @target_zoom_y = WorldMap::W_ENTER_Z @target_opacity = 0 @duration = WorldMap::W_ENTER_ZOOM_T end #-------------------------------------------------------------------------- # ● ピクチャの中央表示 # name : ファイル名 #-------------------------------------------------------------------------- def show_center(name, duration=WorldMap::W_SELECT_Z) @name = name @target_x = center_x @target_y = center_y @target_zoom_x = @target_zoom_y = 100.0 @duration = duration @x, @y = @target_x, @target_y if @duration == 0 end #-------------------------------------------------------------------------- # ● ピクチャの中央移動 #-------------------------------------------------------------------------- def move_center WorldMap::USE_REGION ? move(center_x, center_y) : move(@target_x, @target_y) @target_zoom_x = @target_zoom_y = 100.0 end #-------------------------------------------------------------------------- # ● ピクチャの中心点X #-------------------------------------------------------------------------- def center_x Cache.picture(@name).width / 2.0 end #-------------------------------------------------------------------------- # ● ピクチャの中心点Y #-------------------------------------------------------------------------- def center_y Cache.picture(@name).height / 2.0 end #-------------------------------------------------------------------------- # ● 移動完了? #-------------------------------------------------------------------------- def move_finish? (@target_x == @x and @target_y == @y) end end #============================================================================== # ■ Sprite_WorldMapPicture #============================================================================== class Sprite_WorldMapPicture < Sprite_Picture attr_reader :picture #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(nil, Game_WorldMapPicture.new) end #-------------------------------------------------------------------------- # ● ピクチャ変更 #-------------------------------------------------------------------------- def set_picture(region) @picture.show_center(region.region_map, 0) draw_map(region) update end #-------------------------------------------------------------------------- # ● マップ描画 #-------------------------------------------------------------------------- def draw_map(region) bit = Cache.picture(@picture.name) self.bitmap.dispose unless self.bitmap.nil? self.bitmap = Bitmap.new(bit.width, bit.height) self.bitmap.blt(0, 0, bit, Rect.new(0, 0, bit.width, bit.height)) draw_icons(region.make_town_list.select {|t| !t.icon.nil?}) end #-------------------------------------------------------------------------- # ● アイコン描画 #-------------------------------------------------------------------------- def draw_icons(town) town.each do |t| WorldMap.draw_icon(bitmap, t.map_pos.x-12, t.map_pos.y, t.icon, WorldMap::POINT_ICON) end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def move(pos) @picture.move(pos.x, pos.y) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update return if bitmap.nil? @picture.update super end #-------------------------------------------------------------------------- # ● 転送元ビットマップの更新 #-------------------------------------------------------------------------- def update_bitmap end #-------------------------------------------------------------------------- # ● 位置の更新 #-------------------------------------------------------------------------- def update_position self.x = center_x + (center_x - @picture.x) * (@picture.zoom_x / 100) - convert_x self.y = center_y + (center_y - @picture.y) * (@picture.zoom_y / 100) - convert_y end #-------------------------------------------------------------------------- # ● 原点の更新 #-------------------------------------------------------------------------- def update_origin self.ox = center_x self.oy = center_y end #-------------------------------------------------------------------------- # ● 画面中心位置 #-------------------------------------------------------------------------- def screen_center_x Graphics.width / 2.0 end def screen_center_y Graphics.height / 2.0 end #-------------------------------------------------------------------------- # ● 中心位置 #-------------------------------------------------------------------------- def center_x @picture.center ? (@picture.x + screen_center_x) : (bitmap.width / 2.0) end def center_y @picture.center ? (@picture.y + screen_center_y) : (bitmap.height / 2.0) end #-------------------------------------------------------------------------- # ● 画面サイズとの差分 X #-------------------------------------------------------------------------- def convert_x center_x - screen_center_x end #-------------------------------------------------------------------------- # ● 画面サイズとの差分 Y #-------------------------------------------------------------------------- def convert_y center_y - screen_center_y end end