Advertisement
Guest User

Simple Gold Hud

a guest
Dec 29th, 2011
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.18 KB | None | 0 0
  1. #==============================================================================
  2. #   Simple Gold Window
  3. #   Author: Nicke
  4. #   Created: 06/06/2011
  5. #   Edited: 05/12/2011
  6. #   Version: 1.1a
  7. #   Optimized/modified by Jet and IceDragon so credits to them too!
  8. #==============================================================================
  9. # Instructions
  10. # -----------------------------------------------------------------------------
  11. # To install this script, open up your script editor and copy/paste this script
  12. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  13. #==============================================================================
  14. ($imported ||= {})["NICKE-GoldWindow"] = true
  15.  
  16. module NICKE
  17.   module GOLD_SETTINGS
  18. #==============================================================================#
  19. # ** Settings
  20. #==============================================================================#
  21.     # GOLD_FONT     |FONT|      |SIZE|     |COLOR|             |SHADOW|
  22.       GOLD_FONT = ["Rockwell",    14,   Color.new(255,215,100),  true]
  23.      
  24.     # GOLD_WINDOW     |X|      |Y|       |Z|        |OPACITY|     |SKIN|
  25.       GOLD_WINDOW =  [498,     422,     99700,          0,          ""]
  26.      
  27.     # GOLD     |ICON|   |VISIBLITY|   |SHOW_ICON|    |SHOW_VOCAB|
  28.       GOLD =   [3300,       1,          true,          false]
  29.    
  30.     # GOLD_COUNT   |SOUND|   |VOL|   |PITCH|    |PLAY|
  31.     GOLD_COUNT =    ["",      60,     100,      false]  
  32.    
  33.     # Count timer for updating the gold.
  34.     GOLD_COUNT_WAIT = 1
  35.     # The time lapse between gold count changing.
  36.     GOLD_CHANGING = 2
  37.    
  38.   end
  39. end
  40. # *** Don't edit below unless you know what you are doing. ***
  41. #==============================================================================#
  42. # ** Window_Base
  43. #------------------------------------------------------------------------------
  44. #  Method for drawing the gold.
  45. #==============================================================================#
  46. include NICKE::GOLD_SETTINGS
  47. class Window_Base < Window
  48.  
  49.   def draw_gold(value, x, y, width)
  50.     cx = contents.text_size(Vocab::gold).width
  51.     self.contents.font.name = GOLD_FONT[0]
  52.     self.contents.font.size = GOLD_FONT[1]
  53.     self.contents.font.color = GOLD_FONT[2]
  54.     self.contents.font.shadow = GOLD_FONT[3]
  55.     self.contents.draw_text(x - 16, y, width-cx-2, WLH, value, 2)
  56.     #// If true change x and y postion.
  57.     self.contents.draw_text(x - 20, y, width-cx-2, WLH, Vocab::gold, 2) if GOLD[3] == true
  58.   end
  59.  
  60. end
  61. #==============================================================================
  62. # ** Simple_Gold_Window
  63. #------------------------------------------------------------------------------
  64. #  This window displays the amount of gold and draw an icon.
  65. #==============================================================================
  66. class Simple_Gold_Window < Window_Base
  67.  
  68.   def initialize(x, y)
  69.     super(x, y, 250, 300)
  70.     @last_gold = $game_party.gold # // Used for updating.
  71.     @wait_period = GOLD_COUNT_WAIT # // Used for a wait period for gold count changing.
  72.     refresh
  73.   end
  74.  
  75.   def refresh
  76.     self.contents.clear
  77.     draw_gold(@last_gold, 4, 0, 120) # // Draw gold.
  78.     draw_icon(GOLD[0], 94, 0) if GOLD[2] == true
  79.   end
  80.  
  81.   def update
  82.     super
  83.     @wait_period -= 1 if @wait_period != 0
  84.     if @last_gold != $game_party.gold and @wait_period == 0 # // If gold has changed, refresh.
  85.       if @last_gold < $game_party.gold
  86.         @last_gold += 1
  87.       else
  88.         @last_gold -= 1
  89.       end
  90.       if self.visible
  91.         RPG::SE.new(GOLD_COUNT[0], GOLD_COUNT[1], [2]).play if GOLD_COUNT[3]
  92.       end
  93.       refresh
  94.       @wait_period = GOLD_CHANGING
  95.     end
  96.   end
  97.  
  98. end
  99.  
  100. #==============================================================================
  101. # ** Scene_Map
  102. #------------------------------------------------------------------------------
  103. #  Show gold window on the map.
  104. #==============================================================================
  105. class Scene_Map < Scene_Base
  106.  
  107.   alias nicke_gold_window_start start unless $@
  108.   def start(*args, &block)
  109.     nicke_gold_window_start(*args, &block)
  110.     create_gold_window
  111.     @gold_window.visible = $game_switches[GOLD[1]]
  112.   end
  113.  
  114.   alias nicke_gold_window_terminate terminate unless $@
  115.   def terminate(*args, &block)
  116.     nicke_gold_window_terminate(*args, &block)
  117.     dispose_gold_window
  118.   end
  119.  
  120.   def create_gold_window
  121.     @gold_window = Simple_Gold_Window.new(GOLD_WINDOW[0], GOLD_WINDOW[1])
  122.     @gold_window.z = GOLD_WINDOW[2]
  123.     @gold_window.opacity = GOLD_WINDOW[3]
  124.     @gold_window.windowskin = Cache.system(GOLD_WINDOW[4]) unless GOLD_WINDOW[4] == ""
  125.   end
  126.  
  127.   def dispose_gold_window
  128.     @gold_window.dispose unless @gold_window.nil?
  129.     @gold_window = nil
  130.   end
  131.  
  132.   alias nicke_gold_window_update update unless $@
  133.   def update(*args, &block)
  134.     nicke_gold_window_update(*args, &block)
  135.     @gold_window.update
  136.     @gold_window.visible = $game_switches[GOLD[1]]
  137.   end
  138.  
  139. end # END OF FILE
  140.  
  141. #=*==========================================================================*=#
  142. # ** END OF FILE
  143. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement