Advertisement
Guest User

XS - Gold Hud

a guest
Apr 5th, 2012
703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.37 KB | None | 0 0
  1. #==============================================================================
  2. #   Simple Gold Hud
  3. #   Author: Nicke
  4. #   Created: 06/06/2012
  5. #   Edited: 01/04/2012
  6. #   Version: 1.0b
  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. # *** Only for RPG Maker VX Ace. ***
  14. #==============================================================================
  15. ($imported ||= {})["XAIL-SIMPLE-GOLD-HUD"] = true
  16.  
  17. module XAIL
  18.   module GOLD
  19.   #--------------------------------------------------------------------------#
  20.   # * Settings
  21.   #--------------------------------------------------------------------------#
  22.     # FONT = [name, size, color, bold, shadow ]
  23.     FONT = [["Verdana"], 20, Color.new(255,200,100), true, true]
  24.  
  25.     # GOLD_WINDOW = [width, x, y , opacity, skin ]
  26.     WINDOW =  [160, 405, -5,  200, 0, ""]
  27.  
  28.     # GOLD = [icon, switch_id, show_icon, show_vocab, count_switch ]
  29.     GOLD =   [361, 99, true, false, 2]
  30.  
  31.     # GOLD_COUNT = [ sound, vol, pitch, play ]
  32.     GOLD_COUNT = ["", 60, 100, false]
  33.  
  34.     # Count timer for updating the gold.
  35.     GOLD_COUNT_WAIT = 4
  36.     # The time lapse between gold count changing.
  37.     GOLD_CHANGING = 1
  38.   end
  39. end
  40. # *** Don't edit below unless you know what you are doing. ***
  41. #==============================================================================#
  42. # ** Window_Gold_Hud
  43. #------------------------------------------------------------------------------
  44. #  Class for drawing the gold.
  45. #==============================================================================#
  46. class Window_Gold_Hud < Window_Base
  47.  
  48.   def initialize
  49.     # // Method to initialize the gold window.
  50.     super(0, 0, window_width, fitting_height(1))
  51.     @last_gold = $game_party.gold
  52.     @wait_period = XAIL::GOLD::GOLD_COUNT_WAIT
  53.     refresh
  54.   end
  55.  
  56.   def window_width
  57.     # // Method to return the width.
  58.     return XAIL::GOLD::WINDOW[0]
  59.   end
  60.  
  61.   def draw_gold(value, unit, x, y, width)
  62.     # // Method to draw the gold.
  63.     cx = text_size(unit).width
  64.     contents.font = Font.new(XAIL::GOLD::FONT[0], XAIL::GOLD::FONT[1])
  65.     contents.font.color = XAIL::GOLD::FONT[2]
  66.     contents.font.bold = XAIL::GOLD::FONT[3]
  67.     contents.font.shadow = XAIL::GOLD::FONT[4]
  68.     # // Draw gold.
  69.     draw_text(x, y, width - cx - 2, line_height, value, 2)
  70.     # // Draw vocab.
  71.     draw_text(x, y, width, line_height, unit, 2) if XAIL::GOLD::GOLD[3]
  72.     reset_font_settings
  73.   end
  74.  
  75.   def refresh
  76.     # // Method to refresh the gold.
  77.     contents.clear
  78.     if $game_switches[XAIL::GOLD::GOLD[4]]
  79.       draw_gold($game_party.gold, Vocab::currency_unit, -10, 0, contents.width - 8)
  80.     else
  81.       draw_gold(@last_gold, Vocab::currency_unit, -10, 0, contents.width - 8)
  82.     end
  83.     draw_icon(XAIL::GOLD::GOLD[0], 100, -2) if XAIL::GOLD::GOLD[2]
  84.   end
  85.  
  86.   def update
  87.     # // Method to update the gold.
  88.     super
  89.     @wait_period -= 1 if @wait_period != 0
  90.     if @last_gold != $game_party.gold and @wait_period == 0
  91.       if @last_gold < $game_party.gold
  92.         @last_gold += 1
  93.       else
  94.         @last_gold -= 1
  95.       end
  96.       if self.visible
  97.         RPG::SE.new(XAIL::GOLD::GOLD_COUNT[0], XAIL::GOLD::GOLD_COUNT[1], XAIL::GOLD::GOLD_COUNT[2]).play if XAIL::GOLD::GOLD_COUNT[3]
  98.       end
  99.       refresh
  100.       @wait_period = XAIL::GOLD::GOLD_CHANGING
  101.     end
  102.   end
  103.  
  104. end
  105. #==============================================================================
  106. # ** Scene_Map
  107. #------------------------------------------------------------------------------
  108. #  Show gold window on the map.
  109. #==============================================================================
  110. class Scene_Map < Scene_Base
  111.  
  112.   alias xail_gold_window_start start unless $@
  113.   def start(*args, &block)
  114.     # // Method to start the gold window on the map.
  115.     xail_gold_window_start(*args, &block)
  116.     create_gold_window
  117.     @gold_window.visible = $game_switches[XAIL::GOLD::GOLD[1]]
  118.   end
  119.  
  120.   alias xail_gold_window_terminate terminate unless $@
  121.   def terminate(*args, &block)
  122.     # // Method to terminate the gold window on the map.
  123.     xail_gold_window_terminate(*args, &block)
  124.     dispose_gold_window
  125.   end
  126.  
  127.   def create_gold_window
  128.     # // Method to create the gold window.
  129.     @gold_window = Window_Gold_Hud.new
  130.     @gold_window.x = XAIL::GOLD::WINDOW[1]
  131.     @gold_window.y = XAIL::GOLD::WINDOW[2]
  132.     @gold_window.z = XAIL::GOLD::WINDOW[3]
  133.     @gold_window.opacity = XAIL::GOLD::WINDOW[4]
  134.     @gold_window.windowskin = Cache.system(XAIL::GOLD::WINDOW[5]) unless XAIL::GOLD::WINDOW[5] == ""
  135.   end
  136.  
  137.   def dispose_gold_window
  138.     # // Method to dispose the gold window.
  139.     @gold_window.dispose unless @gold_window.nil?
  140.     @gold_window = nil
  141.   end
  142.  
  143.   alias xail_gold_window_update update unless $@
  144.   def update(*args, &block)
  145.     # // Method to update the gold window on the map.
  146.     xail_gold_window_update(*args, &block)
  147.     @gold_window.update
  148.     @gold_window.visible = $game_switches[XAIL::GOLD::GOLD[1]]
  149.   end
  150.  
  151. end # END OF FILE
  152.  
  153. #=*==========================================================================*=#
  154. # ** END OF FILE
  155. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement