Advertisement
thiago_d_d

Custom Window

Jan 16th, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.87 KB | None | 0 0
  1. #==============================================================
  2. # http://thiagodd.blogspot.com.br
  3. # [TSDA] Custom Window
  4. #   --> Version 1.2
  5. # by thiago_d_d
  6. #
  7. #--------------------------------------------------------------
  8. # * Features
  9. #--------------------------------------------------------------
  10. # + Adds an windows to the map that can show up to 2 variables
  11. #   value. That windows is customizable.
  12. #--------------------------------------------------------------
  13. # * Configuration
  14. #--------------------------------------------------------------
  15. # Edit lines below.
  16. #==============================================================
  17. module TSDA
  18.   #Swicth that activates the HUD
  19.   HUD_SWITCH_ID = 1
  20.   #Variables text
  21.   HUD_TEXT1 = "Var1: "
  22.   HUD_TEXT2 = "Var2: "
  23.   #ID of variables that will be shown
  24.   # Put 0 on VAR2_ID if you don't want to show an second variable.
  25.   VAR1_ID = 1
  26.   VAR2_ID = 2
  27.   #Text Font
  28.   HUD_FONTNAME = "Tahoma"
  29.   HUD_FONTSIZE = 18
  30.   #window ipacity
  31.   HUD_OPACITY = 0
  32.   #position and dimension of the window
  33.   HUD_POSX = 0
  34.   HUD_POSY = 0
  35.   HUD_WIDTH = 224
  36.   HUD_HEIGHT = 96
  37. end
  38. #--------------------------------------------------------------
  39. class Window_S_HUD < Window_Base
  40.   include TSDA
  41.   def initialize
  42.     super(HUD_POSX,HUD_POSY,HUD_WIDTH,HUD_HEIGHT)
  43.     self.contents = Bitmap.new(width - 32, height - 32)
  44.     self.contents.font.name = HUD_FONTNAME
  45.     self.contents.font.size = HUD_FONTSIZE
  46.     self.back_opacity = HUD_OPACITY
  47.     self.opacity = HUD_OPACITY
  48.     @var1 = $game_variables[VAR1_ID]
  49.     @var2 = $game_variables[VAR2_ID]
  50.     self.visible = $game_switches[HUD_SWITCH_ID]
  51.     refresh
  52.   end
  53.   #------------------------------------------------------------
  54.   def update
  55.     super
  56.     if @var1 != $game_variables[VAR1_ID] ||
  57.       @var2 != $game_variables[VAR2_ID]
  58.       refresh
  59.     end
  60.   end
  61.   #------------------------------------------------------------
  62.   def refresh
  63.     self.contents.clear
  64.     w1 = self.contents.text_size(HUD_TEXT1).width
  65.     w2 = self.contents.text_size(HUD_TEXT2).width
  66.     self.contents.font.color = system_color
  67.     self.contents.draw_text(0,0,w1,32,HUD_TEXT1)
  68.     self.contents.draw_text(0,32,w2,32,HUD_TEXT2)
  69.     self.contents.font.color = normal_color
  70.     self.contents.draw_text(w1 + 4,0,194 - w1,32,
  71.     @var1.to_s)
  72.     if VAR2_ID != 0
  73.       self.contents.draw_text(w2 + 4,32,194 - w2,32,
  74.       @var2.to_s)
  75.     end
  76.   end
  77. end
  78. #--------------------------------------------------------------
  79. class Scene_Map
  80.   include TSDA
  81.   alias old_update_hud_s update
  82.   def update
  83.     old_update_hud_s
  84.     @window_hud_s.visible =
  85.     $game_switches[HUD_SWITCH_ID]
  86.     @window_hud_s.update
  87.   end
  88.   #------------------------------------------------------------
  89.   alias old_main_hud_s main
  90.   def main
  91.     @window_hud_s = Window_S_HUD.new
  92.     old_main_hud_s
  93.     @window_hud_s.dispose
  94.   end
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement