Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # * WeightHUD
- #===============================================================================
- class WeightHUD < Window_Base
- # Set true/false if windowskin should be used or not. If not, text will simply
- # be displayed on the screen.
- WINDOWED = true
- # Set the location of the HUD. [X, Y, WIDTH, HEIGHT]
- # I recommend a small X and Y offset if WINDOWED is set to false to have
- # the text placed properly and not to far off the edge of the screen.
- LOCATION = [0, 0, 144, 64]
- # Set the font used for the HUD. [FONT_NAME, FONT_SIZE]
- # A value of nil for either setting will have it simply use the default font
- FONT = ['Calibri', 20]
- # Script Calls:
- # hide_weightHUD(true/false) - Sets the hidden state of the weight HUD
- #-----------------------------------------------------------------------------
- # * initialize
- # Creates a new instance of the HUD
- #-----------------------------------------------------------------------------
- def initialize
- super(*LOCATION)
- self.windowskin = nil unless WINDOWED
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.name = FONT[0] == nil ? Font.default_name : FONT[0]
- self.contents.font.size = FONT[1] == nil ? Font.default_size : FONT[1]
- refresh
- end
- #-----------------------------------------------------------------------------
- # * refresh
- # Clears and redraws the HUD
- #-----------------------------------------------------------------------------
- def refresh
- self.contents.clear
- self.contents.font.color = system_color
- self.contents.draw_text(0, 0, 32, 32, 'WT')
- weight, capacity = $game_party.total_weight, $game_party.weight_capacity
- color = weight > capacity ? crisis_color : normal_color
- self.contents.font.color = color
- self.contents.draw_text(32, 0, 42, 32, weight.to_s, 2)
- self.contents.font.color = normal_color
- self.contents.draw_text(74, 0, 8, 32, '/', 1)
- self.contents.draw_text(82, 0, 42, 32, capacity.to_s)
- end
- end
- #===============================================================================
- # * Game_Party
- #===============================================================================
- class Game_Party
- #-----------------------------------------------------------------------------
- # * refresh_weight
- # Tells Scene_Map that the HUD needs refresh when the values change
- #-----------------------------------------------------------------------------
- alias weight_hud_refresh_weight refresh_weight
- def refresh_weight
- weight_hud_refresh_weight
- if $scene.is_a?(Scene_Map)
- $scene.refresh_weightHUD
- end
- end
- end
- #===============================================================================
- # * Scene_Map
- #===============================================================================
- class Scene_Map
- #-----------------------------------------------------------------------------
- # * main
- # Creates the HUD and disposes it when the scene ends
- #-----------------------------------------------------------------------------
- alias item_weight_main main
- def main
- @weight_hud = WeightHUD.new
- item_weight_main
- @weight_hud.dispose
- end
- #-----------------------------------------------------------------------------
- # * hide_weightHUD
- # Hides/Shows the weight HUD if it is present and not disposed
- #-----------------------------------------------------------------------------
- def hide_weightHUD(bool)
- if @weight_hud != nil && !@weight_hud.disposed?
- @weight_hud.visible = bool
- end
- end
- #-----------------------------------------------------------------------------
- # * refresh_weightHUD
- # Refreshes the weight HUD if it is present and not disposed
- #-----------------------------------------------------------------------------
- def refresh_weightHUD
- if @weight_hud != nil && !@weight_hud.disposed?
- @weight_hud.refresh
- end
- end
- end
- #===============================================================================
- # * Interpreter
- #===============================================================================
- class Interpreter
- #-----------------------------------------------------------------------------
- # * hide_weightHUD
- # Hides/Shows the weight HUD if it is present and not disposed
- #-----------------------------------------------------------------------------
- def hide_weightHUD(value = true)
- if $scene.is_a?(Scene_Map)
- $scene.hide_weightHUD(value)
- end
- end
- end
Add Comment
Please, Sign In to add comment