#============================================================================== # ** Region Names # Author: Hime # Version: 1.1 # Date: May 5, 2012 #------------------------------------------------------------------------------ # ** Change log # 1.1 # -created a custom region window # -now shows the party leader by default # 1.0 May 5, 2012 # -initial release #------------------------------------------------------------------------------ # This script automatically tracks region changing (through region ID's) # and will display a message when you move to a new region # # To use, in the notebox field for your maps, add the following # # 1: region 1 name # 2: region 2 name # 10: region 10 name # # # The region name you wrote will be displayed automatically #------------------------------------------------------------------------------ # This scripted was adapated from Yanfly's Region Battlebacks # You can see the symmetry #============================================================================== $imported = {} if $imported.nil? module Tsuki module Region_Names #the message that is displayed when entering a new region Entrance_Message = "Entering " #If gab window is installed, use that instead Use_Gab = false end end module Tsuki module Regex module Map Region_Names_On = /<(?:REGION_NAMES|region names)>/i Region_Names_Off = /<\/(?:REGION_NAMES|region names)>/i Region_Names_ID = /(\d+):[ ](.*)/i end end end class RPG::Map attr_accessor :region_names def load_notetags_region_names @region_names = {} @region_battlebacks_on = false self.note.split(/[\r\n]+/).each do |line| case line when Tsuki::Regex::Map::Region_Names_On @region_names_on = true when Tsuki::Regex::Map::Region_Names_Off @region_names_on = false when Tsuki::Regex::Map::Region_Names_ID next unless @region_names_on rid = $1.to_i @region_names[rid] = "" if @region_names[rid].nil? @region_names[rid] = $2.to_s end end end end class Game_Map alias tsuki_regionNames_setup setup def setup(map_id) tsuki_regionNames_setup(map_id) @map.load_notetags_region_names end def region_names return @map.region_names end def region_name name = region_names[$game_player.region_id] return name if name else "" end end class Game_Player < Game_Character #attr_reader :last_region alias tsuki_regionNames_initialize initialize def initialize tsuki_regionNames_initialize @last_region = 0 @region_changed = false end alias tsuki_regionNames_update update def update tsuki_regionNames_update @region_changed = @last_region != region_id && region_id != 0 @last_region = region_id if region_id != 0 end def region_changed? @region_changed end end class Scene_Map < Scene_Base alias tsuki_regionName_update_scene update_scene def update_scene tsuki_regionName_update_scene update_region_change unless scene_changing? end def update_region_change if $game_player.region_changed? message = Tsuki::Region_Names::Entrance_Message + $game_map.region_name if $imported["YEA-GabWindow"] && Tsuki::Region_Names::Use_Gab Game_Interpreter.new.gab(message, 0) else @region_name_window.open(message) end end end alias tsuki_regionName_create_all_windows create_all_windows def create_all_windows tsuki_regionName_create_all_windows create_region_location_window end #-------------------------------------------------------------------------- # * Create Region Name Window #-------------------------------------------------------------------------- def create_region_location_window @region_name_window = Window_RegionName.new end end #============================================================================== # ** Window_RegionName #------------------------------------------------------------------------------ # This window displays the region name on the map. #============================================================================== class Window_RegionName < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(300, 0, window_width, fitting_height(1)) self.opacity = 0 self.contents_opacity = 0 @show_count = 0 refresh end #-------------------------------------------------------------------------- # * Get Window Width #-------------------------------------------------------------------------- def window_width return 240 end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super if @show_count > 0 && $game_map.name_display update_fadein @show_count -= 1 else update_fadeout end end #-------------------------------------------------------------------------- # * Update Fadein #-------------------------------------------------------------------------- def update_fadein self.contents_opacity += 16 end #-------------------------------------------------------------------------- # * Update Fadeout #-------------------------------------------------------------------------- def update_fadeout self.contents_opacity -= 16 end #-------------------------------------------------------------------------- # * Open Window #-------------------------------------------------------------------------- def open(name) refresh(name) @show_count = 150 self.contents_opacity = 0 self end #-------------------------------------------------------------------------- # * Close Window #-------------------------------------------------------------------------- def close @show_count = 0 self end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh(name="") contents.clear unless name.empty? || @show_count == 150 draw_background(contents.rect) draw_text(contents.rect, name, 1) end end #-------------------------------------------------------------------------- # * Draw Background #-------------------------------------------------------------------------- def draw_background(rect) temp_rect = rect.clone temp_rect.width /= 2 contents.gradient_fill_rect(temp_rect, back_color2, back_color1) temp_rect.x = temp_rect.width contents.gradient_fill_rect(temp_rect, back_color1, back_color2) end #-------------------------------------------------------------------------- # * Get Background Color 1 #-------------------------------------------------------------------------- def back_color1 Color.new(0, 0, 0, 192) end #-------------------------------------------------------------------------- # * Get Background Color 2 #-------------------------------------------------------------------------- def back_color2 Color.new(0, 0, 0, 0) end end