IceDragon200

Window-Kore

May 14th, 2011
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.78 KB | None | 0 0
  1. class Window_ActorMenuStatus < Window_Base
  2.  
  3.   attr_accessor :actor
  4.  
  5.   def initialize(x, y, actor)
  6.     super(x, y, 360, 96)
  7.     @actor = actor
  8.     refresh
  9.   end
  10.  
  11.   def refresh
  12.     create_contents
  13.     draw_actor_name(@actor, 4, 0)
  14.     draw_actor_level(@actor, 140, 0)
  15.     draw_actor_hp(@actor, 240, 0)
  16.     draw_actor_mp(@actor, 254, 32)
  17.   end
  18.  
  19. end
  20.  
  21. class MenuStatus_FF8 # // Container
  22.  
  23.   attr_reader :x
  24.   attr_reader :y
  25.   attr_accessor :index
  26.  
  27.   def initialize( x, y )
  28.     @x, @y = x, y
  29.     @index = 0
  30.     @windows = {}
  31.     @actor_windows = []
  32.     @item_max = 0
  33.   end
  34.  
  35.   def x=( new_x )
  36.     return if @x == new_x
  37.     @x = new_x
  38.     @windows.values.each { |w| w.x = @x }
  39.   end
  40.  
  41.   def y=( new_y )
  42.     return if @y == new_y
  43.     @y = new_y
  44.     @windows.values.each { |w| w.x = @y }
  45.   end
  46.  
  47.   def refresh()
  48.     i = 0
  49.     @actor_windows.clear
  50.     @windows.values.each { |w| w.dispose }
  51.     @windows.clear
  52.     $game_party.members.each { |m|
  53.       winm = "Actor#{i}"
  54.       win = Window_ActorMenuStatus.new( 20, 56+(96*i), m )
  55.       @windows[winm] = win
  56.       @actor_windows[i] = win
  57.       i += 1
  58.     }
  59.     @item_max = @actor_windows.size()
  60.   end
  61.  
  62.   def update()
  63.     @windows.each { |win| win.update() }
  64.     update_user_input()
  65.   end
  66.  
  67.   def update_user_input()
  68.     return if @item_max == 0
  69.     if Input.trigger?( Input::UP )
  70.       Sound.play_cursor
  71.       reset_window_positions()
  72.       @index -= 1
  73.       @index %= @item_max
  74.       @actor_windows[@index].x = 40
  75.     elsif Input.trigger?( Input::DOWN )
  76.       Sound.play_cursor
  77.       @index += 1
  78.       @index %= @item_max
  79.       @actor_windows[@index].x = 40
  80.     end
  81.   end
  82.  
  83.   def reset_window_positions()
  84.     for i in 0...@item_max
  85.       @actor_windows[i].x = 20
  86.     end
  87.   end
  88.  
  89. end
Advertisement
Add Comment
Please, Sign In to add comment