IceDragon200

Nicke-GoldWindow (OP)

Jun 6th, 2011
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.76 KB | None | 0 0
  1. #==============================================================================
  2. #   Simple Gold Window
  3. #   Author: Nicke
  4. #   Created: 06/06/2011
  5. #   Edited: 06/06/2011
  6. #   Version: 1.0
  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. $imported = {} if $imported == nil
  14. $imported["NICKE-GoldWindow"] = true
  15.  
  16. module NICKE
  17.   module GOLD_WINDOW
  18.   #--------------------------------------------------------------------------#
  19.   # * Settings
  20.   #--------------------------------------------------------------------------#
  21.     GOLD_FONT = ["Rockwell"]                # Font name.
  22.     GOLD_SIZE = 16                          # Font size.
  23.     GOLD_COLOR = Color.new(255,215,100)     # Font color.
  24.     X_GOLD_WINDOW = 0#505                     # X position of Gold window.
  25.     Y_GOLD_WINDOW = 0#372                     # Y position of Gold window.
  26.     OPACITY = 0                             # Opacity for Gold window.
  27.     ICON_INDEX = 147                        # Gold icon ID to be displayed.
  28.     VISIBLE_SWITCH = 7                      # Switch ID to turn on/off the gold window.
  29.     SHOW_VOCAB = false                      # Show system term for gold.
  30.   end
  31. end
  32.  
  33. #Don't edit below!
  34.  
  35. #==============================================================================#
  36. # ** Window_Base
  37. #------------------------------------------------------------------------------
  38. #  Method for drawing the gold.
  39. #==============================================================================#
  40. class Window_Base < Window
  41.  
  42.   def draw_gold(value, x, y, width)
  43.     cx = contents.text_size(Vocab::gold).width
  44.     self.contents.font.name  = NICKE::GOLD_WINDOW::GOLD_FONT
  45.     self.contents.font.size  = NICKE::GOLD_WINDOW::GOLD_SIZE
  46.     self.contents.font.color = NICKE::GOLD_WINDOW::GOLD_COLOR
  47.     self.contents.draw_text(x - 25, y, width-cx-2, WLH, value, 2)
  48.     if NICKE::GOLD_WINDOW::SHOW_VOCAB != false
  49.       self.contents.draw_text(x - 20, y, width-cx-2, WLH, Vocab::gold, 2)
  50.     end
  51.   end
  52.  
  53. end
  54. #==============================================================================
  55. # ** Simple_Gold_Window
  56. #------------------------------------------------------------------------------
  57. #  This window displays the amount of gold and draw an icon.
  58. #==============================================================================
  59. class Simple_Gold_Window < Window_Base
  60.   #--------------------------------------------------------------------------
  61.   # * Object Initialization
  62.   #     x : window X coordinate
  63.   #     y : window Y coordinate
  64.   #--------------------------------------------------------------------------
  65.   def initialize(x, y)
  66.     super(x, y, 150, WLH + 32)
  67.     @last_gold = -1 # // Used for updating, set it to some crazy value that can never be right
  68.     refresh
  69.   end
  70.  
  71.   #--------------------------------------------------------------------------#
  72.   # * Refresh
  73.   #--------------------------------------------------------------------------#
  74.   def refresh
  75.     self.contents.clear
  76.     draw_gold($game_party.gold, 4, 0, 120)
  77.     draw_icon(NICKE::GOLD_WINDOW::ICON_INDEX, 94, 0)
  78.   end
  79.  
  80.   #--------------------------------------------------------------------------#
  81.   # * Update
  82.   #--------------------------------------------------------------------------#
  83.   def update()
  84.     super() # // Now here is where you can make use of the super method :3
  85.     if @last_gold != $game_party.gold # // If gold has changed, refresh.
  86.       refresh ; @last_gold = $game_party.gold  
  87.     end  
  88.   end
  89.  
  90. end
  91.  
  92.  
  93. #==============================================================================
  94. # ** Scene_Map
  95. #------------------------------------------------------------------------------
  96. #  Show gold window on the map.
  97. #==============================================================================
  98. class Scene_Map < Scene_Base
  99.    
  100.   alias nicke_gold_window_start start unless $@
  101.   def start(*args) # // Start never has any parameters anyway ;(*args) example
  102.     create_gold_window()
  103.     @gold_window.visible = $game_switches[NICKE::GOLD_WINDOW::VISIBLE_SWITCH]
  104.     nicke_gold_window_start(*args)
  105.   end
  106.  
  107.   alias nicke_gold_window_terminate terminate unless $@
  108.   def terminate() # // I just like adding the () after method_names :3 helps with identifying them
  109.     nicke_gold_window_terminate()
  110.     dispose_gold_window() # // command_window? its usppose to be the gold @___@
  111.   end
  112.  
  113.   def create_gold_window()
  114.     @gold_window = Simple_Gold_Window.new(NICKE::GOLD_WINDOW::X_GOLD_WINDOW, NICKE::GOLD_WINDOW::Y_GOLD_WINDOW)
  115.     @gold_window.opacity = NICKE::GOLD_WINDOW::OPACITY
  116.     @gold_window.z = 200 # // Cause I had a lot of stuff that covered it up @__@
  117.   end
  118.  
  119.   def dispose_gold_window()
  120.     @gold_window.dispose unless @gold_window.nil?() # // If the window isn't nil, dispose it :3
  121.     @gold_window = nil  # // even after disposing, the variable isn't always set back to nil, this ensures it
  122.   end
  123.  
  124.   alias nicke_gold_window_update update unless $@
  125.   def update()
  126.     nicke_gold_window_update()
  127.     @gold_window.update()
  128.     # // Avoid unncessary refreshs
  129.     # // Since the switch can never be nil here, just assign its value to the window.visible
  130.     @gold_window.visible = $game_switches[NICKE::GOLD_WINDOW::VISIBLE_SWITCH]
  131.   end
  132.  
  133. end # END OF FILE
  134.  
  135. #=*==========================================================================*=#
  136. # ** END OF FILE
  137. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment