IceDragon200

FRV-Core

Jun 4th, 2011
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.59 KB | None | 0 0
  1. # // Last Modified :06/08/2011
  2. #==============================================================================#
  3. # FRV
  4. #==============================================================================#
  5. module FRV
  6.  
  7.   module_function()
  8.  
  9.   # Credit to Yanfly for the range to array method
  10.   #--------------------------------------------------------------------------
  11.   # convert_integer_array
  12.   #--------------------------------------------------------------------------
  13.   def convert_integer_array( array )
  14.     result = []
  15.     array.each { |i|
  16.       case i
  17.       when Range; result |= i.to_a
  18.       when Integer; result |= [i]
  19.       end }
  20.     return result
  21.   end
  22.  
  23. end
  24.  
  25. #==============================================================================#
  26. # Window_Base
  27. #==============================================================================#
  28. class Window_Base < Window
  29.  
  30.   #--------------------------------------------------------------------------
  31.   # * Draw HP
  32.   #     actor : actor
  33.   #     x     : draw spot x-coordinate
  34.   #     y     : draw spot y-coordinate
  35.   #     width : Width
  36.   #--------------------------------------------------------------------------
  37.   def draw_actor_hp(actor, x, y, width = 120)
  38.     draw_actor_hp_gauge(actor, x, y, width)
  39.     self.contents.font.color = system_color
  40.     self.contents.draw_text(x, y, 30, WLH, Vocab::hp_a)
  41.     self.contents.font.color = hp_color(actor)
  42.     last_font_size = self.contents.font.size
  43.     xr = x + width
  44.     self.contents.font.size = 18
  45.     if width < 120
  46.       self.contents.draw_text(xr - 44, y, 44, WLH, actor.hp, 2)
  47.     else
  48.       self.contents.draw_text(xr - 99, y, 44, WLH, actor.hp, 2)
  49.       self.contents.font.color = normal_color
  50.       self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
  51.       self.contents.draw_text(xr - 44, y, 44, WLH, actor.maxhp, 2)
  52.     end
  53.     self.contents.font.size = last_font_size
  54.   end
  55.  
  56.   #--------------------------------------------------------------------------
  57.   # * Draw MP
  58.   #     actor : actor
  59.   #     x     : draw spot x-coordinate
  60.   #     y     : draw spot y-coordinate
  61.   #     width : Width
  62.   #--------------------------------------------------------------------------
  63.   def draw_actor_mp(actor, x, y, width = 120)
  64.     draw_actor_mp_gauge(actor, x, y, width)
  65.     self.contents.font.color = system_color
  66.     self.contents.draw_text(x, y, 30, WLH, Vocab::mp_a)
  67.     self.contents.font.color = mp_color(actor)
  68.     last_font_size = self.contents.font.size
  69.     xr = x + width
  70.     self.contents.font.size = 18
  71.     if width < 120
  72.       self.contents.draw_text(xr - 44, y, 44, WLH, actor.mp, 2)
  73.     else
  74.       self.contents.draw_text(xr - 99, y, 44, WLH, actor.mp, 2)
  75.       self.contents.font.color = normal_color
  76.       self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
  77.       self.contents.draw_text(xr - 44, y, 44, WLH, actor.maxmp, 2)
  78.     end
  79.     self.contents.font.size = last_font_size
  80.   end
  81.  
  82.   #--------------------------------------------------------------------------
  83.   # * Draw HP gauge
  84.   #     actor : actor
  85.   #     x     : draw spot x-coordinate
  86.   #     y     : draw spot y-coordinate
  87.   #     width : Width
  88.   #--------------------------------------------------------------------------
  89.   def draw_actor_hp_gauge(actor, x, y, width = 120)
  90.     #gw = width * actor.hp / actor.maxhp
  91.     gc1 = hp_gauge_color1
  92.     gc2 = hp_gauge_color2
  93.     #self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
  94.     #self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
  95.     val, max = actor.hp, actor.maxhp
  96.     rect = Rect.new( x, y+WLH-6, width, 4 )
  97.     draw_round_grad_bar( rect, val, max, gc1, gc2, gauge_back_color )
  98.   end
  99.  
  100.   #--------------------------------------------------------------------------
  101.   # * Draw MP Gauge
  102.   #     actor : actor
  103.   #     x     : draw spot x-coordinate
  104.   #     y     : draw spot y-coordinate
  105.   #     width : Width
  106.   #--------------------------------------------------------------------------
  107.   def draw_actor_mp_gauge(actor, x, y, width = 120)
  108.     #gw = width * actor.mp / [actor.maxmp, 1].max
  109.     gc1 = mp_gauge_color1
  110.     gc2 = mp_gauge_color2
  111.     #self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
  112.     #self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
  113.     val, max = actor.mp, actor.maxmp
  114.     rect = Rect.new( x, y+WLH-6, width, 4 )
  115.     draw_round_grad_bar( rect, val, max, gc1, gc2, gauge_back_color )
  116.   end
  117.    
  118. end
  119.  
  120. #==============================================================================#
  121. # FRV::Container_Base
  122. #==============================================================================#
  123. class FRV::Container_Base
  124.  
  125.   #--------------------------------------------------------------------------#
  126.   # * Public Instance Variables
  127.   #--------------------------------------------------------------------------#  
  128.   attr_accessor :x
  129.   attr_accessor :y
  130.   attr_accessor :z
  131.   attr_accessor :width
  132.   attr_accessor :height
  133.   attr_accessor :opacity
  134.   attr_accessor :index
  135.   attr_accessor :item_max
  136.   attr_accessor :active
  137.  
  138.   #--------------------------------------------------------------------------#
  139.   # * overwrite method :initialize
  140.   #--------------------------------------------------------------------------#
  141.   def initialize( x=0, y=0, width=0, height=0 )
  142.     @x, @y, @z, @width, @height, @opacity = x, y, 0, width, height, 255
  143.     @index, @item_max = 0, 0
  144.     @active = true
  145.   end
  146.  
  147. end  
  148. #=*==========================================================================*=#
  149. # ** END OF FILE
  150. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment