daily pastebin goal
24%
SHARE
TWEET

Map/Compass HUD v1.0 - RGSS/RMXP

CompanionWulf Jan 15th, 2015 (edited) 324 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # Map/Compass HUD
  3. #   Version      : 1.1
  4. #   Platform     : RMXP
  5. #   Author       : Companion Wulf
  6. #   Release Date : 23 September 2014
  7. #   Last Update  : 21 August 2015
  8. #   Websites     : RPG Maker Times          - http://blog.rpgmakertimes.info
  9. #                : Companion Blog           - http://rpgmakertimes.blogspot.com
  10. #                : Twitter                  - https://twitter.com/CompanionWulf
  11. #
  12. #
  13. #------------------------------------------------------------------------------
  14. # * DESCRIPTION *
  15. #----------------------------------------------------------------------------
  16. #   The Map/Compass HUD places a window on the map displaying the current map
  17. #   location  and the party's compass direction (the direction  in which it's
  18. #   moving), as well as the XY coordinates.
  19. #
  20. #   It was  initially  written  specifically  for  my  upcoming  RMXP project
  21. #   "Paranormality:  Portals",  but I decided to  release it as  a standalone
  22. #   plug-and-play script.
  23. #
  24. #----------------------------------------------------------------------------
  25. # * KNOWN COMPATABILITY ISSUES *
  26. #----------------------------------------------------------------------------
  27. #   There shouldn't be any compatibility issues as most methods are aliased.
  28. #
  29. #------------------------------------------------------------------------------
  30. # * REQUIRED SCRIPTS *
  31. #------------------------------------------------------------------------------
  32. #   No additional required scripts are necessary.
  33. #
  34. #----------------------------------------------------------------------------
  35. # * VERSION HISTORY *
  36. #----------------------------------------------------------------------------
  37. # The version history tracking will be changing to the following format:
  38. #
  39. #     Release.Developmental
  40. #
  41. # Release numbers indicate public release versions.
  42. #
  43. # Developmental updates are for tweaks or bug fixes, and new added methods.
  44. #
  45. #------------------------------------------------------------------------------
  46. # * Updates Version History *
  47. #------------------------------------------------------------------------------
  48. # VERSION 2.0+ - RMVX & RMVXA
  49. #   ● Conversions are planned for RMVX and RMVXA in the far future.
  50. #   ● The RMVX version will be added to the planned Q-Engine Map Add-on later.
  51. #
  52. #------------------------------------------------------------------------------
  53. # v1.1 (15-Aug-2015)
  54. #   ● Bug Fix: Rescue when icons not installed correctly and put blank space
  55. # v1.0 (23-Sep-2014)
  56. #   ● Release: Public script v1.0
  57. # v0.6 (19-Sep-2014)
  58. #   ● Add: Option to show/hide map icon
  59. #   ● Add: Configuration module for settings
  60. # v0.4 (16-Sep-2014)
  61. #   ● Bug Fix: Error with script not fetching map info properly
  62. #   ● Add: Compass point icons
  63. #   ● Add: Map location icon
  64. # v0.1 (15-Sep-2014)
  65. #   ● Began script (originally integrated into "Paranormality: Portals")
  66. #
  67. #==============================================================================
  68.  
  69. $imported = {} if $imported == nil; $imported["CWMapHUD"] = true
  70.  
  71. #===============================================================================
  72. # ** Map/Compass HUD Configuration **
  73. #===============================================================================
  74. module CWMAPHUD_CONFIG
  75.   #============================================================================
  76.   # ** CONFIGURATION **
  77.   #----------------------------------------------------------------------------
  78.   # All of the options below are configurable.  There shouldn't be  any need to
  79.   # modify anything else, as the script is plug-and-play.  Most of the settings
  80.   # are set to "true" by default as applicable.
  81.   #
  82.   # "true" toggles the setting on; "false" toggles it off.
  83.   #----------------------------------------------------------------------------
  84.   SHOW_MAP_ICON = true      # Display icon for map next to location
  85.  
  86.   #----------------------------------------------------------------------------
  87.   # Icons - All icons must be imported into the "Graphics/Icons" folder.
  88.   #----------------------------------------------------------------------------
  89.   MAP_ICON = "map-24x24" # Change to your chosen map icon
  90.  
  91.   #----------------------------------------------------------------------------
  92.   # Icons for the compass directions must be saved in the following format:
  93.   #
  94.   #     Compass-Direction
  95.   #
  96.   # where "Direction" is the cardinal points North, South, East and West.
  97.   #============================================================================
  98. end
  99.  
  100. #==============================================================================
  101. # ** Bitmap
  102. #==============================================================================
  103. class Bitmap
  104.   #--------------------------------------------------------------------------
  105.   # * Object Initialization
  106.   #     x         : icon x-coordinate
  107.   #     y         : icon y-coordinate
  108.   #     icon_name : name of icon to display
  109.   #--------------------------------------------------------------------------
  110.   def draw_icon(x, y, icon_name)
  111.     bitmap = RPG::Cache.icon(icon_name)
  112.     self.blt(x, y + 8, bitmap, Rect.new(0, 0, 24, 24))
  113.   end
  114. end
  115.  
  116. #==============================================================================
  117. # ** Game_Map
  118. #==============================================================================
  119. class Game_Map
  120.   #--------------------------------------------------------------------------
  121.   # * Map Name
  122.   #--------------------------------------------------------------------------
  123.   def name
  124.     return $map_names[@map_id]
  125.   end
  126. end
  127.  
  128.  
  129. #==============================================================================
  130. # ** Window_Base
  131. #==============================================================================
  132. class Window_Base < Window
  133.   #--------------------------------------------------------------------------
  134.   # * Draw Player Coordinates
  135.   #     x     : Draw x-coordinate
  136.   #     y     : Draw y-coordinate
  137.   #     w     : Content width
  138.   #     h     : Content height
  139.   #     a     : Text alignment
  140.   #--------------------------------------------------------------------------
  141.   def draw_player_coords(x, y, w, h, a = 1)
  142.     @player_x, @player_y = $game_player.x, $game_player.y
  143.     textx, texty = "X: "+@player_x.to_s, "Y: "+@player_y.to_s
  144.     self.contents.draw_text(x, y, w, h, textx, a)
  145.     self.contents.draw_text(x, y + 22, w, h, texty, a)
  146.   end
  147. end
  148.  
  149. #==============================================================================
  150. # ** Scene_Title
  151. #------------------------------------------------------------------------------
  152. #  This class performs title screen processing.
  153. #==============================================================================
  154.  
  155. class Scene_Title
  156.   include CWMAPHUD_CONFIG
  157.   #--------------------------------------------------------------------------
  158.   # * Main Processing
  159.   #--------------------------------------------------------------------------
  160.   alias :cwmapao_compass_scnttl_main :main
  161.   def main
  162.     cwmapao_compass_scnttl_main
  163.     get_map_info
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # * Get Map Info
  167.   #--------------------------------------------------------------------------
  168.   def get_map_info
  169.     $map_names = load_data("Data/MapInfos.rxdata")
  170.     $map_names.keys.each {|key| $map_names[key] = $map_names[key].name}
  171.   end
  172. end
  173.  
  174. #==============================================================================
  175. # ** Game_Player
  176. #==============================================================================
  177.  
  178. class Scene_Map
  179.   alias :cwmaphud_scnmap_main :main
  180.   def main
  181.     @show_map.dispose unless @show_map.nil?
  182.     @show_map = Window_Location.new(480, 0, false)
  183.     cwmaphud_scnmap_main
  184.     @show_map.dispose unless (@show_map.disposed? || @show_map.nil?)
  185.   end
  186.  
  187.   alias :cwmaphud_scnmap_update :update
  188.   def update
  189.     @show_map.update unless (@show_map.disposed? || @show_map.nil?)
  190.     cwmaphud_scnmap_update
  191.   end
  192.    
  193.   alias :cwmaphud_scnmap_transfer_player :transfer_player
  194.   def transfer_player
  195.     cwmaphud_scnmap_transfer_player
  196.     @show_map.dispose unless (@show_map.disposed? || @show_map.nil?)
  197.     @show_map = Window_Location.new(480, 0, false)
  198.   end
  199. end
  200.  
  201. #==============================================================================
  202. # ** Window_Location
  203. #------------------------------------------------------------------------------
  204. #  This window displays map location in Status Menu.
  205. #==============================================================================
  206.  
  207. class Window_Location < Window_Base
  208.     include CWMAPHUD_CONFIG
  209.  
  210.   WLH = 32
  211.   #--------------------------------------------------------------------------
  212.   # * Object Initialization
  213.   #--------------------------------------------------------------------------
  214.   def initialize(x = 0, y = 360, from_status = true)
  215.     @from_status = from_status
  216.     @from_status ? height = WLH * 2 + 8 : height = WLH * 4
  217.     super(x, y, 160, height)
  218.     self.contents = Bitmap.new(width - 32, height - 32)
  219.     self.contents.font.size = 16
  220.     update
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # * Refresh
  224.   #--------------------------------------------------------------------------
  225.   def refresh
  226.   end
  227.   def update
  228.     self.contents.clear
  229.     self.contents.draw_icon(0, -8, MAP_ICON) if SHOW_MAP_ICON rescue nil
  230.     self.contents.draw_text(0, WLH * 0 - 8, 128, WLH, $game_map.name, 2)
  231.     if @from_status == false
  232.       case $game_player.direction
  233.       when 2; compass = "South"
  234.       when 4; compass = "West"
  235.       when 6; compass = "East"
  236.       when 8; compass = "North"
  237.       end
  238.       self.contents.draw_icon(0, WLH * 1, "compass-"+compass.downcase) rescue nil
  239.       self.contents.draw_text(28, WLH * 1 + 8, 130, WLH, compass)
  240.       draw_player_coords(55, WLH * 1, 60, WLH * 1, 2)
  241.     end
  242.   end
  243. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top