Advertisement
Dark_Paladin

DKP Resource Hud v1.0

Jun 10th, 2013
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.02 KB | None | 0 0
  1. ###############################################################################
  2. # DKP Resource Hud v1.0
  3. #     Platform: VX Ace
  4. #       Author: Dark Paladin
  5. #  Description: A resources hud for my city builder series.
  6. # Terms of use: You MAY use this script for your Non-commercial Projects.
  7. #    You MAY use this script for Commercial projects without my permission.
  8. #    Credit is appreciated but not needed.
  9. # This script requires: Catchext
  10. # As of this moment there is not a switch to turn it on/off. I may add one in
  11. # the future but not any time soon.
  12. ###############################################################################
  13. # Instructions
  14. #------------------------------------------------------------------------------
  15. # To install this script, open up your script editor and copy/paste this script
  16. # to an open slot below  Materials but above  Main. Remember to save.
  17. # Place the "hud" image in Graphics/DPmenu/Hud/ Creating folders when needed.
  18. #
  19. # ** Only for RPG Maker VX Ace. **
  20. #==============================================================================
  21. module Hud_config
  22. #==============================================================================
  23. # ** Dkp Hud
  24. #==============================================================================
  25. #------------------------------------------------------------------------------
  26. # Config Area
  27. #------------------------------------------------------------------------------
  28.        Var1 = 1     # Variable ID #1
  29.        Var2 = 2     # Variable ID #2
  30.        Var3 = 3     # Variable ID #3
  31.        Var4 = 4     # Variable ID #4  
  32.   Var1_Icon = 298   # Variable Icon ID #1
  33.   Var2_Icon = 331   # Variable Icon ID #2
  34.   Var3_Icon = 359   # Variable Icon ID #3
  35.   Var4_Icon = 117   # Variable Icon ID #4
  36. Hud_picture = "hud" # Name of file for hud background
  37.   Gold_Icon = 361   # Gold Icon ID
  38.  Font_Color = 3     # Font Color
  39.     Opacity = 50     # Opacity of the default window
  40.  
  41. end
  42. #############DO NOT EDIT PAST HERE UNLESS YOU KNOW WHAT YOUR DOING#############
  43. #------------------------------------------------------------------------------
  44. # Initialize
  45. #------------------------------------------------------------------------------
  46. class Scene_Map < Scene_Base
  47.   alias dkp_hud_window_start start
  48.   def start
  49.     dkp_hud_window_start
  50.     create_hud_window
  51.   end
  52.   alias dkp_hud_window_update update
  53.   def update
  54.     dkp_hud_window_update
  55.     @hud_window.refresh
  56.     @hud_window2.refresh
  57.     @hud_window3.refresh
  58.     @hud_window4.refresh
  59.     @hud_window5.refresh
  60.   end
  61.   def create_hud_window
  62.     @hud_back = Dkp_hudback.new
  63.     @hud_window = Dkp_hud1.new
  64.         @hud_window.x = 0
  65.         @hud_window.y = -10
  66.     @hud_window2 = Dkp_hud2.new
  67.     @hud_window2.x = 105
  68.         @hud_window2.y = -10
  69.     @hud_window3 = Dkp_hud3.new
  70.     @hud_window3.x = 210
  71.         @hud_window3.y = -10
  72.     @hud_window4 = Dkp_hud4.new
  73.     @hud_window4.x = 320
  74.         @hud_window4.y = -10
  75.     @hud_window5 = Dkp_hud5.new
  76.     @hud_window5.x = 435
  77.         @hud_window5.y = -10
  78.   end
  79.   def dispose_hud_window
  80.     @hud_window.dispose
  81.     @hud_window2.dispose
  82.     @hud_window3.dispose
  83.     @hud_window4.dispose
  84.     @hud_window5.dispose
  85.   end
  86.   def refresh
  87.     contents.clear
  88.     create_hud_window
  89.   end
  90. end
  91.  
  92. class Dkp_hudback < Window_Base
  93.     def initialize
  94.         super(0, 0, window_width, fitting_height(0.4))
  95.         self.opacity = Hud_config::Opacity
  96.         refresh
  97.     end  
  98.     def refresh
  99.         create_image_hud
  100.     end  
  101.   def window_width
  102.         return 544
  103.     end
  104.   def create_image_hud
  105.         @hud_sprite = Sprite.new
  106.         bitmap = Cachext.dphud(Hud_config::Hud_picture)
  107.         @hud_sprite.bitmap = bitmap
  108.         @hud_sprite.x = 0
  109.         @hud_sprite.y = 0
  110.     end
  111.   def update
  112.    refresh
  113.   end
  114. end
  115. class Dkp_hud1 < Window_Base
  116.     def initialize
  117.         super(0, 0, window_width, fitting_height(1))
  118.         self.opacity = 0
  119.         refresh
  120.     end  
  121.     def refresh
  122.         contents.clear
  123.         draw_var(var, draw_icon(Hud_config::Var1_Icon, 0, 0, enabled = true), 4, 0, contents.width - 10)
  124.     end  
  125.     def draw_var(value, unit, x, y, width)
  126.         def var_color;      text_color(Hud_config::Font_Color);  end;
  127.         cx = text_size(unit).width
  128.         change_color(var_color)
  129.         draw_text(x, y, width - cx - 2, line_height, value, 2)
  130.         change_color(var_color)
  131.         draw_text(x, y, width, line_height, unit, 2)
  132.     end
  133.     def window_width
  134.         return 120
  135.     end
  136.     def var
  137.         $game_variables[Hud_config::Var1]
  138.     end
  139.   def update
  140.    refresh
  141.   end
  142. end
  143.  
  144. class Dkp_hud2 < Window_Base
  145.     def initialize
  146.         super(0, 0, window_width, fitting_height(1))
  147.         self.opacity = 0
  148.         refresh
  149.     end  
  150.     def refresh
  151.         contents.clear
  152.         draw_var(var, draw_icon(Hud_config::Var2_Icon, 0, 0, enabled = true), 4, 0, contents.width - 10)
  153.     end  
  154.     def draw_var(value, unit, x, y, width)
  155.         def var_color;      text_color(Hud_config::Font_Color);  end;
  156.         cx = text_size(unit).width
  157.         change_color(var_color)
  158.         draw_text(x, y, width - cx - 2, line_height, value, 2)
  159.         change_color(var_color)
  160.         draw_text(x, y, width, line_height, unit, 2)
  161.     end
  162.     def window_width
  163.         return 120
  164.     end
  165.     def var
  166.         $game_variables[Hud_config::Var2]
  167.     end  
  168. end
  169.  
  170. class Dkp_hud3 < Window_Base
  171.     def initialize
  172.         super(0, 0, window_width, fitting_height(1))
  173.         self.opacity = 0
  174.         refresh
  175.     end  
  176.     def refresh
  177.         contents.clear
  178.         draw_var(var, draw_icon(Hud_config::Var3_Icon, 0, 0, enabled = true), 4, 0, contents.width - 10)
  179.     end  
  180.     def draw_var(value, unit, x, y, width)
  181.         def var_color;      text_color(Hud_config::Font_Color);  end;
  182.         cx = text_size(unit).width
  183.         change_color(var_color)
  184.         draw_text(x, y, width - cx - 2, line_height, value, 2)
  185.         change_color(var_color)
  186.         draw_text(x, y, width, line_height, unit, 2)
  187.     end
  188.     def window_width
  189.         return 120
  190.     end
  191.     def var
  192.         $game_variables[Hud_config::Var3]
  193.     end  
  194. end
  195. class Dkp_hud4 < Window_Base
  196.     def initialize
  197.         super(0, 0, window_width, fitting_height(1))
  198.         self.opacity = 0
  199.         refresh
  200.     end  
  201.     def refresh
  202.         contents.clear
  203.         draw_var(var, draw_icon(Hud_config::Var4_Icon, 0, 0, enabled = true), 4, 0, contents.width - 10)
  204.     end  
  205.     def draw_var(value, unit, x, y, width)
  206.         def var_color;      text_color(Hud_config::Font_Color);  end;
  207.         cx = text_size(unit).width
  208.         change_color(var_color)
  209.         draw_text(x, y, width - cx - 2, line_height, value, 2)
  210.         change_color(var_color)
  211.         draw_text(x, y, width, line_height, unit, 2)
  212.     end
  213.     def window_width
  214.         return 120
  215.     end
  216.     def var
  217.         $game_variables[Hud_config::Var4]
  218.     end  
  219. end
  220. class Dkp_hud5 < Window_Base
  221.     def initialize
  222.         super(0, 0, window_width, fitting_height(1))
  223.         self.opacity = 0
  224.         refresh
  225.     end  
  226.     def refresh
  227.         contents.clear
  228.         draw_var(var, draw_icon(Hud_config::Gold_Icon, 0, 0, enabled = true), 4, 0, contents.width - 10)
  229.     end  
  230.     def draw_var(value, unit, x, y, width)
  231.         def var_color;      text_color(Hud_config::Font_Color);  end;
  232.         cx = text_size(unit).width
  233.         change_color(var_color)
  234.         draw_text(x, y, width - cx - 2, line_height, value, 2)
  235.         change_color(var_color)
  236.         draw_text(x, y, width, line_height, unit, 2)
  237.     end
  238.     def window_width
  239.         return 120
  240.     end
  241.     def var
  242.         $game_party.gold
  243.     end  
  244. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement