nekosune

Untitled

Nov 7th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.94 KB | None | 0 0
  1. #==============================================================================
  2. #   XS - Moon Hud
  3. #   Original Author: Nicke
  4. #   Edited by: Nekosune
  5. #   Created: 02/04/2012
  6. #   Edited: 09/04/2012
  7. #   Version: 1.0a
  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. # A small hud to Moon phase on the map.
  15. #
  16. # *** Only for RPG Maker VX Ace. ***
  17. #==============================================================================
  18. ($imported ||= {})["NEKO-MOON_HUD"] = true
  19.  
  20. module NEKO
  21.   module MOON_HUD
  22.   #--------------------------------------------------------------------------#
  23.   # * Settings
  24.   #--------------------------------------------------------------------------#
  25.       # FONT = [name, size, color, bold, shadow]
  26.       FONT = [["Verdana"], 14, Color.new(255,255,255), true, true]
  27.  
  28.       # HUD = [width, x, y, z, opacity, skin]
  29.       HUD = [270, 295, -5,  200, 0, nil]
  30.  
  31.       # VAR_HUD_SWITCH = switch_id
  32.       VAR_HUD_SWITCH = 1
  33.       HOUR_VAR=2
  34.       MIN_VAR=1
  35.       # VAR_LIST = [variable_id, vocab (nil), icon_index (nil), x, y]
  36.       VAR_LIST = [] # Don't remove!
  37.       VAR_LIST[0] = [4, nil, nil] # Set variable_id to same variable as DAYB from Time script
  38.       # Set the symbol for the amount.
  39.       # Can be set to "" to disable.
  40.       # SYMBOL = string
  41.       SYMBOL = ""
  42.  
  43.       # The space beetween the variables.
  44.       # SPACING = number
  45.       SPACING = 24
  46.  
  47.   end
  48. end
  49. # *** Don't edit below unless you know what you are doing. ***
  50. #==============================================================================#
  51. # ** Window_Var_Hud
  52. #------------------------------------------------------------------------------
  53. #  Class for drawing the variable hud.
  54. #==============================================================================#
  55. class Window_Var_Hud < Window_Base
  56.  
  57.   def initialize
  58.     # // Method to initialize the var hud window.
  59.     super(0, 0, window_width, fitting_height(NEKO::MOON_HUD::VAR_LIST.size+1))
  60.     refresh
  61.   end
  62.  
  63.   def window_width
  64.     # // Method to return the width.
  65.     return NEKO::MOON_HUD::HUD[0]
  66.   end
  67.  
  68.   def draw_var(var, unit, x, y, width)
  69.     # // Method to draw a variable with the content.
  70.     vl=$game_variables[var]
  71.     vl=vl%28
  72.     moon="New Moon"
  73.     if vl >3 and vl <=7
  74.         moon="Waxing Crescent"
  75.     elsif vl >7 and vl <=10
  76.         moon="First Quater"
  77.     elsif vl >10 and vl <=14
  78.         moon="Waxing Gibbeous"
  79.     elsif vl >14 and vl <=17
  80.         moon="Full Moon"
  81.     elsif vl >17 and vl <=21
  82.         moon="Waning Gibbeous"
  83.     elsif vl >21 and vl <=24
  84.         moon="Third Quater"
  85.     elsif vl >24 and vl<=28
  86.         moon="Waning Crescent"
  87.     elsif vl >28
  88.         moon="New Moon"
  89.     end
  90.     value = "#{moon}#{NEKO::MOON_HUD::SYMBOL}"
  91.     contents.font = Font.new(NEKO::MOON_HUD::FONT[0], NEKO::MOON_HUD::FONT[1])
  92.     contents.font.color = NEKO::MOON_HUD::FONT[2]
  93.     contents.font.bold = NEKO::MOON_HUD::FONT[3]
  94.     contents.font.shadow = NEKO::MOON_HUD::FONT[4]
  95.    
  96.     draw_text(x, y, width - 60, line_height, value, 2)
  97.     draw_text(x, y, width - 18, line_height, unit, 2) unless unit.nil?
  98.     value="Day: #{$game_variables[var]} %02d:%02d" % [$game_variables[NEKO::MOON_HUD::HOUR_VAR],$game_variables[NEKO::MOON_HUD::MIN_VAR]]
  99.     debug(y)
  100.     debug(y+NEKO::MOON_HUD::SPACING)
  101.     debug(value)
  102.     draw_text(x, y+NEKO::MOON_HUD::SPACING, width - 60, line_height, value, 2)
  103.     reset_font_settings
  104.   end
  105.  
  106.   def refresh
  107.     # // Method to refresh the variable hud.
  108.     contents.clear
  109.     draw_var_hud
  110.   end
  111.  
  112.   def draw_var_hud
  113.     # // Method to draw the var hud.
  114.     y = 0
  115.     @vars = {}
  116.     for i in NEKO::MOON_HUD::VAR_LIST
  117.       x = i[1].nil? ? 32 : -10
  118.       draw_var(i[0], i[1], x, y, contents.width - 8)
  119.       draw_icon(i[2], 210, y - 2) unless i[2].nil?
  120.       y += NEKO::MOON_HUD::SPACING
  121.       @vars[i[0]] = $game_variables[NEKO::MOON_HUD::MIN_VAR]
  122.     end
  123.   end
  124.  
  125.   def update
  126.     # // Method to update the variable hud if a value has been changed.
  127.     super
  128.     for i in NEKO::MOON_HUD::VAR_LIST
  129.       refresh if($game_variables[NEKO::MOON_HUD::MIN_VAR] != @vars[i[0]])
  130.     end
  131.   end
  132.  
  133. end
  134. #==============================================================================
  135. # ** Scene_Map
  136. #------------------------------------------------------------------------------
  137. #  Show variable hud on the map.
  138. #==============================================================================
  139. class Scene_Map < Scene_Base
  140.  
  141.   alias neko_var_hud_window_start start
  142.   def start(*args, &block)
  143.     # // Method to start the var hud window on the map.
  144.     neko_var_hud_window_start(*args, &block)
  145.     create_var_hud_window
  146.     @var_hud_window.visible = $game_switches[NEKO::MOON_HUD::VAR_HUD_SWITCH]
  147.   end
  148.  
  149.   alias neko_var_hud_window_terminate terminate
  150.   def terminate(*args, &block)
  151.     # // Method to terminate the var hud window on the map.
  152.     neko_var_hud_window_terminate(*args, &block)
  153.   end
  154.  
  155.   def create_var_hud_window
  156.     # // Method to create the variable window.
  157.     @var_hud_window = Window_Var_Hud.new
  158.     @var_hud_window.x = NEKO::MOON_HUD::HUD[1]
  159.     @var_hud_window.y = NEKO::MOON_HUD::HUD[2]
  160.     @var_hud_window.z = NEKO::MOON_HUD::HUD[3]
  161.     @var_hud_window.opacity = NEKO::MOON_HUD::HUD[4]
  162.     @var_hud_window.windowskin = Cache.system(NEKO::MOON_HUD::HUD[5]) unless NEKO::MOON_HUD::HUD[5].nil?
  163.   end
  164.  
  165.   alias neko_var_hud_window_update update
  166.   def update(*args, &block)
  167.     # // Method to update the var hud window on the map.
  168.     neko_var_hud_window_update(*args, &block)
  169.     @var_hud_window.visible = $game_switches[NEKO::MOON_HUD::VAR_HUD_SWITCH]
  170.   end
  171.  
  172. end # END OF FILE
  173.  
  174. #=*==========================================================================*=#
  175. # ** END OF FILE
  176. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment