IceDragon200

FRV-Status

Jun 4th, 2011
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.73 KB | None | 0 0
  1. # // Last Modified :03/17/2012
  2. #==============================================================================#
  3. # ** FRV::STATUS
  4. #==============================================================================#
  5. module FRV
  6.   module STATUS
  7.    
  8.     DRAW_ELEMENTS = [
  9.       1..9
  10.     ]
  11.    
  12.     def self.ranks( value )
  13.       case value
  14.       when (-999)..(-100) ; return :f
  15.       when (-99)..0       ; return :e
  16.       when 1..50          ; return :d
  17.       when 51..100        ; return :c
  18.       when 101..150       ; return :b  
  19.       when 151..999       ; return :a # // Actually cap is 200
  20.       end  
  21.     end
  22.    
  23.     RANK_TEXTS = {
  24.       :a => "W",
  25.       :b => "W",
  26.       :c => "N",
  27.       :d => "R",
  28.       :e => "R",
  29.       :f => "R"
  30.     }
  31.    
  32.     RANK_COLORS = {
  33.       :a => 18,
  34.       :b => 17,
  35.       :c => 0,
  36.       :d => 16,
  37.       :e => 16,
  38.       :f => 16
  39.     }
  40.    
  41.   #--------------------------------------------------------------------------#
  42.   # * Convert all Ranges to Integers
  43.   #--------------------------------------------------------------------------#
  44.     DRAW_ELEMENTS = ::FRV.convert_integer_array( DRAW_ELEMENTS )
  45.  
  46.   end
  47. end
  48.  
  49. #==============================================================================#
  50. # ** FRV::Window_StatusBase
  51. #==============================================================================#
  52. class FRV::Window_StatusBase < ::Window_Selectable
  53.  
  54.   attr_accessor :actor
  55.  
  56.   #--------------------------------------------------------------------------#
  57.   # * super method :initialize
  58.   #--------------------------------------------------------------------------#  
  59.   def initialize( actor, x, y, width, height )
  60.     super( x, y, width, height )
  61.     @actor = actor
  62.     refresh()
  63.   end
  64.  
  65.   #--------------------------------------------------------------------------#
  66.   # * new method :refresh
  67.   #--------------------------------------------------------------------------#  
  68.   def refresh()
  69.   end
  70.  
  71.   #--------------------------------------------------------------------------
  72.   # * Draw Parameters
  73.   #     x : Draw spot X coordinate
  74.   #     y : Draw spot Y coordinate
  75.   #--------------------------------------------------------------------------
  76.   def draw_parameters( x, y, param_spacing=WLH )
  77.     draw_actor_parameter(@actor, x, y + param_spacing * 0, 0)
  78.     draw_actor_parameter(@actor, x, y + param_spacing * 1, 1)
  79.     draw_actor_parameter(@actor, x, y + param_spacing * 2, 2)
  80.     draw_actor_parameter(@actor, x, y + param_spacing * 3, 3)
  81.   end
  82.  
  83.   #--------------------------------------------------------------------------
  84.   # * Draw Equipment
  85.   #     x : Draw spot X coordinate
  86.   #     y : Draw spot Y coordinate
  87.   #--------------------------------------------------------------------------
  88.   def draw_equipments( x, y )
  89.     self.contents.font.color = system_color
  90.     self.contents.draw_text( x, y, 120, WLH, Vocab::equip )
  91.     for i in 0..4
  92.       draw_item_name( @actor.equips[i], x + 16, y + WLH * (i + 1) )
  93.     end
  94.   end
  95.  
  96. end
  97.  
  98. #==============================================================================#
  99. # FRV::Window_StatusMain
  100. #==============================================================================#
  101. class FRV::Window_StatusMain < ::FRV::Window_StatusBase
  102.  
  103.   #--------------------------------------------------------------------------#
  104.   # * new method :refresh
  105.   #--------------------------------------------------------------------------#  
  106.   def refresh()
  107.     create_contents()
  108.     draw_actor_face( @actor, 0, 0 )
  109.     draw_actor_name( @actor, 100, 4 )
  110.     draw_actor_hp( @actor, 100, 42 )
  111.     draw_actor_mp( @actor, 100, 56 )
  112.     draw_actor_level( @actor, 4, 96-24 )
  113.     draw_actor_state( @actor, 100, 26, 128 )
  114.     draw_parameters( self.width / 2, 4 )
  115.   end
  116.  
  117. end
  118.  
  119. #==============================================================================#
  120. # FRV::Window_StatusEquipment
  121. #==============================================================================#
  122. class FRV::Window_StatusEquipment < ::FRV::Window_StatusBase
  123.  
  124.   #--------------------------------------------------------------------------#
  125.   # * new method :refresh
  126.   #--------------------------------------------------------------------------#  
  127.   def refresh()
  128.     create_contents()
  129.     draw_equipments( 4, 4 )
  130.   end
  131.  
  132. end
  133.  
  134. #==============================================================================#
  135. # FRV::Window_StatusElements
  136. #==============================================================================#
  137. class FRV::Window_StatusElements < ::FRV::Window_StatusBase
  138.  
  139.   WLH = 36 # // Default 24, try editing this in the future if you add new elements
  140.  
  141.   #--------------------------------------------------------------------------#
  142.   # * Public Instance Variables
  143.   #--------------------------------------------------------------------------#
  144.   attr_accessor :actor
  145.  
  146.   #--------------------------------------------------------------------------#
  147.   # * new method :refresh
  148.   #--------------------------------------------------------------------------#  
  149.   def refresh()
  150.     @elements = FRV::STATUS::DRAW_ELEMENTS
  151.     @item_max = @elements.size
  152.     @spacing = 2
  153.     @column_max = 2 # // Uses 2 columns
  154.     create_contents()
  155.     for i in 0...@item_max
  156.       draw_item(i)
  157.     end  
  158.   end
  159.  
  160.   #--------------------------------------------------------------------------
  161.   # * Get rectangle for displaying items
  162.   #     index : item number
  163.   #--------------------------------------------------------------------------
  164.   def item_rect(index)
  165.     rect = Rect.new(0, 0, 0, 0)
  166.     rect.width = (contents.width + @spacing) / @column_max - @spacing
  167.     rect.height = WLH
  168.     rect.x = index % @column_max * (rect.width + @spacing)
  169.     rect.y = index / @column_max * rect.height
  170.     return rect
  171.   end
  172.  
  173.   #--------------------------------------------------------------------------#
  174.   # * new method :draw_item
  175.   #--------------------------------------------------------------------------#  
  176.   def draw_item( index, enabled=true )
  177.     rect = item_rect( index )
  178.     ele = @elements[index]
  179.     val = @actor.element_rate( ele )  
  180.     rank = FRV::STATUS.ranks( val )
  181.     nm  = $data_system.elements[ele]
  182.     draw_icon( FRV::Icon.element( ele ), rect.x, rect.y+((rect.height-24)/2) )
  183.     self.contents.font.size = Font.default_size - 4
  184.     rect.x += 24 ; rect.width -= 24
  185.     self.contents.font.bold = true
  186.     self.contents.font.color = normal_color
  187.     self.contents.draw_text( rect, nm )
  188.     self.contents.font.bold = Font.default_bold
  189.     self.contents.font.size = Font.default_size #- 2
  190.     self.contents.font.color = text_color( FRV::STATUS::RANK_COLORS[rank] )
  191.     rect.width -= 4
  192.     self.contents.draw_text( rect, sprintf("%s", FRV::STATUS::RANK_TEXTS[rank]), 2 )
  193.     #self.contents.font.color = system_color
  194.     #self.contents.draw_text( rect, sprintf("%s%", val), 2 )
  195.     self.contents.font.size = Font.default_size
  196.   end
  197.  
  198. end
  199.  
  200. #==============================================================================#
  201. # Window_StatusHelp
  202. #==============================================================================#
  203. class Window_StatusHelp < IRS::Sprite_Help ; end
  204.  
  205. #==============================================================================#
  206. # Scene_Status
  207. #==============================================================================#
  208. class Scene_Status < Scene_Base
  209.  
  210.   #--------------------------------------------------------------------------#
  211.   # * overwrite method :start
  212.   #--------------------------------------------------------------------------#
  213.   def start()
  214.     super()
  215.     create_menu_background()
  216.     @actor = $game_party.members[@actor_index]
  217.     @help_window   = Window_StatusHelp.new( 0, 0, Graphics.width, 32 )
  218.     @status_window = FRV::Window_StatusMain.new( @actor, 0, 32,
  219.      Graphics.width, 128+12 )
  220.     @equip_window  = FRV::Window_StatusEquipment.new( @actor,
  221.      0, @status_window.y + @status_window.height,
  222.      Graphics.width/2, Graphics.height - (@status_window.y + @status_window.height) - 32 )  
  223.     @element_window= FRV::Window_StatusElements.new( @actor,
  224.      Graphics.width/2, @status_window.y + @status_window.height,
  225.      Graphics.width/2, Graphics.height - (@status_window.y + @status_window.height) - 32 )  
  226.     @inputhelp_window = Window_StatusHelp.new( 0, Graphics.height-32, Graphics.width, 32 )
  227.     @inputhelp_window.align = 1
  228.     @inputhelp_window.set_text("Use A and S to switch Characters")
  229.     # // ----------------------------------------------------------------- // #
  230.     @menuback_sprite.bitmap = Cache.system( "Menu_background" )
  231.     @menuback_sprite.opacity= 255  
  232.   end
  233.  
  234.   #--------------------------------------------------------------------------#
  235.   # * overwrite method :terminate
  236.   #--------------------------------------------------------------------------#
  237.   def terminate()
  238.     super()
  239.     dispose_menu_background()
  240.     @help_window.dispose()
  241.     @status_window.dispose()
  242.     @equip_window.dispose()
  243.     @element_window.dispose()
  244.     @inputhelp_window.dispose()
  245.   end
  246.  
  247.   #--------------------------------------------------------------------------#
  248.   # * overwrite method :update
  249.   #--------------------------------------------------------------------------#
  250.   def update()
  251.     update_menu_background()
  252.     @status_window.update()
  253.     if Input.trigger?(Input::B)
  254.       Sound.play_cancel
  255.       return_scene()
  256.     elsif Input.trigger?(Input::Y)
  257.       Sound.play_cursor
  258.       next_actor()
  259.     elsif Input.trigger?(Input::X)
  260.       Sound.play_cursor
  261.       prev_actor()
  262.     end
  263.     super()
  264.   end
  265.  
  266. end  
  267. #=*==========================================================================*=#
  268. # ** END OF FILE
  269. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment