Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Map/Compass HUD
- # Version : 1.1
- # Platform : RMXP
- # Author : Companion Wulf
- # Release Date : 23 September 2014
- # Last Update : 21 August 2015
- # Websites : RPG Maker Times - http://blog.rpgmakertimes.info
- # : Companion Blog - http://rpgmakertimes.blogspot.com
- # : Twitter - https://twitter.com/CompanionWulf
- #
- #
- #------------------------------------------------------------------------------
- # * DESCRIPTION *
- #----------------------------------------------------------------------------
- # The Map/Compass HUD places a window on the map displaying the current map
- # location and the party's compass direction (the direction in which it's
- # moving), as well as the XY coordinates.
- #
- # It was initially written specifically for my upcoming RMXP project
- # "Paranormality: Portals", but I decided to release it as a standalone
- # plug-and-play script.
- #
- #----------------------------------------------------------------------------
- # * KNOWN COMPATABILITY ISSUES *
- #----------------------------------------------------------------------------
- # There shouldn't be any compatibility issues as most methods are aliased.
- #
- #------------------------------------------------------------------------------
- # * REQUIRED SCRIPTS *
- #------------------------------------------------------------------------------
- # No additional required scripts are necessary.
- #
- #----------------------------------------------------------------------------
- # * VERSION HISTORY *
- #----------------------------------------------------------------------------
- # The version history tracking will be changing to the following format:
- #
- # Release.Developmental
- #
- # Release numbers indicate public release versions.
- #
- # Developmental updates are for tweaks or bug fixes, and new added methods.
- #
- #------------------------------------------------------------------------------
- # * Updates Version History *
- #------------------------------------------------------------------------------
- # VERSION 2.0+ - RMVX & RMVXA
- # ● Conversions are planned for RMVX and RMVXA in the far future.
- # ● The RMVX version will be added to the planned Q-Engine Map Add-on later.
- #
- #------------------------------------------------------------------------------
- # v1.1 (15-Aug-2015)
- # ● Bug Fix: Rescue when icons not installed correctly and put blank space
- # v1.0 (23-Sep-2014)
- # ● Release: Public script v1.0
- # v0.6 (19-Sep-2014)
- # ● Add: Option to show/hide map icon
- # ● Add: Configuration module for settings
- # v0.4 (16-Sep-2014)
- # ● Bug Fix: Error with script not fetching map info properly
- # ● Add: Compass point icons
- # ● Add: Map location icon
- # v0.1 (15-Sep-2014)
- # ● Began script (originally integrated into "Paranormality: Portals")
- #
- #==============================================================================
- $imported = {} if $imported == nil; $imported["CWMapHUD"] = true
- #===============================================================================
- # ** Map/Compass HUD Configuration **
- #===============================================================================
- module CWMAPHUD_CONFIG
- #============================================================================
- # ** CONFIGURATION **
- #----------------------------------------------------------------------------
- # All of the options below are configurable. There shouldn't be any need to
- # modify anything else, as the script is plug-and-play. Most of the settings
- # are set to "true" by default as applicable.
- #
- # "true" toggles the setting on; "false" toggles it off.
- #----------------------------------------------------------------------------
- SHOW_MAP_ICON = true # Display icon for map next to location
- #----------------------------------------------------------------------------
- # Icons - All icons must be imported into the "Graphics/Icons" folder.
- #----------------------------------------------------------------------------
- MAP_ICON = "map-24x24" # Change to your chosen map icon
- #----------------------------------------------------------------------------
- # Icons for the compass directions must be saved in the following format:
- #
- # Compass-Direction
- #
- # where "Direction" is the cardinal points North, South, East and West.
- #============================================================================
- end
- #==============================================================================
- # ** Bitmap
- #==============================================================================
- class Bitmap
- #--------------------------------------------------------------------------
- # * Object Initialization
- # x : icon x-coordinate
- # y : icon y-coordinate
- # icon_name : name of icon to display
- #--------------------------------------------------------------------------
- def draw_icon(x, y, icon_name)
- bitmap = RPG::Cache.icon(icon_name)
- self.blt(x, y + 8, bitmap, Rect.new(0, 0, 24, 24))
- end
- end
- #==============================================================================
- # ** Game_Map
- #==============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # * Map Name
- #--------------------------------------------------------------------------
- def name
- return $map_names[@map_id]
- end
- end
- #==============================================================================
- # ** Window_Base
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # * Draw Player Coordinates
- # x : Draw x-coordinate
- # y : Draw y-coordinate
- # w : Content width
- # h : Content height
- # a : Text alignment
- #--------------------------------------------------------------------------
- def draw_player_coords(x, y, w, h, a = 1)
- @player_x, @player_y = $game_player.x, $game_player.y
- textx, texty = "X: "+@player_x.to_s, "Y: "+@player_y.to_s
- self.contents.draw_text(x, y, w, h, textx, a)
- self.contents.draw_text(x, y + 22, w, h, texty, a)
- end
- end
- #==============================================================================
- # ** Scene_Title
- #------------------------------------------------------------------------------
- # This class performs title screen processing.
- #==============================================================================
- class Scene_Title
- include CWMAPHUD_CONFIG
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- alias :cwmapao_compass_scnttl_main :main
- def main
- cwmapao_compass_scnttl_main
- get_map_info
- end
- #--------------------------------------------------------------------------
- # * Get Map Info
- #--------------------------------------------------------------------------
- def get_map_info
- $map_names = load_data("Data/MapInfos.rxdata")
- $map_names.keys.each {|key| $map_names[key] = $map_names[key].name}
- end
- end
- #==============================================================================
- # ** Game_Player
- #==============================================================================
- class Scene_Map
- alias :cwmaphud_scnmap_main :main
- def main
- @show_map.dispose unless @show_map.nil?
- @show_map = Window_Location.new(480, 0, false)
- cwmaphud_scnmap_main
- @show_map.dispose unless (@show_map.disposed? || @show_map.nil?)
- end
- alias :cwmaphud_scnmap_update :update
- def update
- @show_map.update unless (@show_map.disposed? || @show_map.nil?)
- cwmaphud_scnmap_update
- end
- alias :cwmaphud_scnmap_transfer_player :transfer_player
- def transfer_player
- cwmaphud_scnmap_transfer_player
- @show_map.dispose unless (@show_map.disposed? || @show_map.nil?)
- @show_map = Window_Location.new(480, 0, false)
- end
- end
- #==============================================================================
- # ** Window_Location
- #------------------------------------------------------------------------------
- # This window displays map location in Status Menu.
- #==============================================================================
- class Window_Location < Window_Base
- include CWMAPHUD_CONFIG
- WLH = 32
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(x = 0, y = 360, from_status = true)
- @from_status = from_status
- @from_status ? height = WLH * 2 + 8 : height = WLH * 4
- super(x, y, 160, height)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.size = 16
- update
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- end
- def update
- self.contents.clear
- self.contents.draw_icon(0, -8, MAP_ICON) if SHOW_MAP_ICON rescue nil
- self.contents.draw_text(0, WLH * 0 - 8, 128, WLH, $game_map.name, 2)
- if @from_status == false
- case $game_player.direction
- when 2; compass = "South"
- when 4; compass = "West"
- when 6; compass = "East"
- when 8; compass = "North"
- end
- self.contents.draw_icon(0, WLH * 1, "compass-"+compass.downcase) rescue nil
- self.contents.draw_text(28, WLH * 1 + 8, 130, WLH, compass)
- draw_player_coords(55, WLH * 1, 60, WLH * 1, 2)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement