IceDragon200

Nicke-MapNameHud

Jun 15th, 2011
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.04 KB | None | 0 0
  1. #==============================================================================
  2. #   Simple Map HUD
  3. #   Author: Nicke
  4. #   Created: 07/06/2011
  5. #   Edited: 15/06/2011
  6. #   Version: 1.0
  7. #==============================================================================
  8. # Instructions
  9. # -----------------------------------------------------------------------------
  10. # To install this script, open up your script editor and copy/paste this script
  11. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  12. #==============================================================================
  13. $imported = {} if $imported == nil
  14. $imported["NICKE-MAP"] = true
  15.  
  16. module NICKE
  17.   module MAP_HUD
  18. #==============================================================================#
  19. # ** Settings
  20. #==============================================================================#
  21.   MAP_HUD_FONT = ["Rockwell"]            # Font name.
  22.   MAP_HUD_SIZE = 18                      # Font size.
  23.   MAP_HUD_COLOR = Color.new(255,215,100) # Font color.
  24.   MAP_HUD_SHADOW = true                  # Font shadow.
  25.   X_MAP_HUD = -12                        # X position.
  26.   Y_MAP_HUD = -20                        # Y position.
  27.   Z_MAP_HUD = 200                        # Z order.
  28.   OPACITY = 0                            # Opacity level.
  29.   SHOW_ICON = true                       # Icon visibility.
  30.   ICON_INDEX = 153                       # Map icon ID to be displayed.
  31.   VISIBLE_SWITCH = 8                     # Switch ID to turn on/off the map window.    
  32.   SHOW_MAP_ID = nil                      # Show map for ID(s). nil to turn it off.  
  33.  
  34.   ANCIENT_CAVERNS = "Ancient Caverns"    
  35.  
  36.   MAPNAME_REPLACE = {                    # Map ID => "ReplacedName"
  37.   } # Don't remove this line!
  38.  
  39.   # Method for replacing the map name.
  40.   def self.replace_mapname(oldname, map_id)    
  41.     case map_id
  42.     when 8, 16..19, 21, 24..28, 30..34 ; return ANCIENT_CAVERNS
  43.     end
  44.     return MAPNAME_REPLACE[map_id] if MAPNAME_REPLACE.has_key?(map_id)
  45.     return oldname
  46.   end
  47.  
  48.   end
  49. end
  50. # *** Don't edit below unless you know what you are doing. ***
  51. #==============================================================================#
  52. # ** Game_Map
  53. #------------------------------------------------------------------------------
  54. #  Method for reading the map id and name.
  55. #==============================================================================#
  56. class Game_Map
  57.   attr_reader :name
  58.   #--------------------------------------------------------------------------
  59.   # *setup
  60.   #--------------------------------------------------------------------------
  61.   alias nicke_map_hud_setup setup
  62.   def setup(map_id)
  63.     nicke_map_hud_setup(map_id)
  64.     @map_infos = load_data("Data/MapInfos.rvdata") if @map_infos.nil?
  65.     @name = NICKE::MAP_HUD.replace_mapname(@map_infos[@map_id].name, @map_id)
  66.   end  
  67. end
  68.  
  69. #==============================================================================#
  70. # ** Window_Base
  71. #------------------------------------------------------------------------------
  72. #  Method for drawing the gold.
  73. #==============================================================================#
  74. class Window_Base < Window
  75.  
  76.   def draw_map_hud(x, y)
  77.     self.contents.font.name  = NICKE::MAP_HUD::MAP_HUD_FONT
  78.     self.contents.font.size  = NICKE::MAP_HUD::MAP_HUD_SIZE
  79.     self.contents.font.color = NICKE::MAP_HUD::MAP_HUD_COLOR
  80.     self.contents.font.shadow = NICKE::MAP_HUD::MAP_HUD_SHADOW
  81.     self.contents.draw_text(x + 30, y, 260, 32, $game_map.name.to_s, 0)
  82.   end
  83.  
  84. end
  85.  
  86. #==============================================================================
  87. # ** Simple_Map_HUD
  88. #------------------------------------------------------------------------------
  89. #  This window displays the current location.
  90. #==============================================================================
  91. class Simple_Map_HUD < Window_Base
  92.  
  93.   def initialize(x, y)
  94.     super(x, y, 260, WLH + 38)
  95.     @map_id = $game_map.map_id
  96.     refresh()
  97.   end
  98.  
  99.   def refresh()
  100.     self.contents.clear()
  101.     draw_map_hud( 0, 0 )
  102.     if NICKE::MAP_HUD::SHOW_ICON != false
  103.       draw_icon(NICKE::MAP_HUD::ICON_INDEX, 0, 6)
  104.     end
  105.   end
  106.  
  107.   def update()
  108.     super()
  109.     if @map_id != $game_map.map_id
  110.       refresh()
  111.       @map_id = $game_map.map_id
  112.     end  
  113.   end
  114.  
  115. end
  116.  
  117. #==============================================================================
  118. # ** Scene_Map
  119. #------------------------------------------------------------------------------
  120. #  Show a location window on the map.
  121. #==============================================================================
  122. class Scene_Map < Scene_Base
  123.    
  124.   alias nicke_map_hud_start start unless $@
  125.   def start(*args)
  126.     create_map_hud
  127.     @map_hud.visible = $game_switches[NICKE::MAP_HUD::VISIBLE_SWITCH]
  128.     if NICKE::MAP_HUD::SHOW_MAP_ID != nil
  129.       if NICKE::MAP_HUD::SHOW_MAP_ID.include?($game_map.map_id)
  130.          @map_hud.visible = true
  131.       else
  132.         @map_hud.visible = false
  133.       end
  134.     end
  135.     nicke_map_hud_start(*args)
  136.   end
  137.  
  138.   alias nicke_map_hud_terminate terminate unless $@
  139.   def terminate
  140.     nicke_map_hud_terminate
  141.     dispose_map_hud
  142.   end
  143.  
  144.   def create_map_hud
  145.     @map_hud = Simple_Map_HUD.new(NICKE::MAP_HUD::X_MAP_HUD,
  146.     NICKE::MAP_HUD::Y_MAP_HUD)
  147.     @map_hud.opacity = NICKE::MAP_HUD::OPACITY
  148.     @map_hud.z = NICKE::MAP_HUD::Z_MAP_HUD
  149.   end
  150.  
  151.   def dispose_map_hud
  152.     @map_hud.dispose unless @map_hud.nil?
  153.     @map_hud = nil
  154.   end
  155.  
  156.   alias nicke_map_hud_update update unless $@
  157.   def update
  158.     nicke_map_hud_update
  159.     @map_hud.update
  160.     @map_hud.visible = $game_switches[NICKE::MAP_HUD::VISIBLE_SWITCH]
  161.     if NICKE::MAP_HUD::SHOW_MAP_ID != nil
  162.       if NICKE::MAP_HUD::SHOW_MAP_ID.include?($game_map.map_id)
  163.          @map_hud.visible = true
  164.       else
  165.         @map_hud.visible = false
  166.       end
  167.     end
  168.   end
  169.  
  170. end # END OF FILE
  171.  
  172. #=*==========================================================================*=#
  173. # ** END OF FILE
  174. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment