Advertisement
Zetu

Z17 AltHUD

Jul 4th, 2011
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.80 KB | None | 0 0
  1.                           #==========================#
  2.                           # Z17 Alternate HUD  v1.01 #
  3.                           #===#==================#===#
  4.                               #     by: Zetu     #
  5.                               #==================#
  6.  
  7. class Scene_Battle < Scene_Base
  8.  
  9.   alias zreq_create_info_viewport create_info_viewport
  10.   def create_info_viewport
  11.     zreq_create_info_viewport
  12.     @info_viewport.rect.y -= 128
  13.     @info_viewport.rect.height += 128
  14.     @status_window.x -= 128
  15.     @status_window.width += 128
  16.     @status_window.y += 128
  17.     @status_window.refresh
  18.     @party_command_window.y += 72
  19.     @party_command_window.column_max = @party_command_window.item_max
  20.     @party_command_window.height = 56
  21.     @party_command_window.width *= @party_command_window.item_max
  22.     @party_command_window.spacing = 0
  23.     @party_command_window.create_contents
  24.     @party_command_window.refresh
  25.   end
  26.  
  27.   def start_target_enemy_selection
  28.     @target_enemy_window = Window_TargetEnemy.new
  29.     @target_enemy_window.y = @info_viewport.rect.y
  30.     @actor_command_window.active = false
  31.     @status_window.visible = false
  32.     @target_enemy_window.width += 128
  33.     @target_enemy_window.y += 128
  34.   end
  35.  
  36.   def end_target_enemy_selection
  37.     @status_window.visible = true
  38.     @target_enemy_window.dispose
  39.     @target_enemy_window = nil
  40.     if @actor_command_window.index == 0
  41.       @actor_command_window.active = true
  42.     end
  43.   end
  44.  
  45.   def start_target_actor_selection
  46.     @target_actor_window = Window_BattleStatus.new
  47.     @target_actor_window.index = 0
  48.     @target_actor_window.active = true
  49.     @target_actor_window.y = @info_viewport.rect.y + 128
  50.     @target_actor_window.width += 128
  51.     @target_actor_window.refresh
  52.     @actor_command_window.active = false
  53.     @status_window.visible = false
  54.   end
  55.  
  56.   def end_target_actor_selection
  57.     @target_actor_window.dispose
  58.     @target_actor_window = nil
  59.     @status_window.visible = true
  60.   end
  61.  
  62.   def update_info_viewport
  63.     @party_command_window.update
  64.     @actor_command_window.update
  65.     @status_window.update
  66.     offset_party_window
  67.     offset_command_window
  68.   end
  69.  
  70.   def offset_party_window
  71.     if @party_command_window.active and @party_command_window.x < 0
  72.       @party_command_window.x += 16
  73.     elsif @actor_command_window.active and @party_command_window.x > -@party_command_window.width
  74.       @party_command_window.x -= 16
  75.     end
  76.   end
  77.  
  78.   def offset_command_window
  79.     if @actor_command_window.active and @actor_command_window.x > 544 - @actor_command_window.width
  80.       @actor_command_window.x -= 16
  81.     elsif (@party_command_window.active or !@skill_window.nil?) and @actor_command_window.x < 544
  82.       @actor_command_window.x += 16
  83.     end
  84.   end
  85.  
  86.   def set_offset_window(window, x1, x2, type = 0)
  87.     case type
  88.     when 0
  89.       windowa = @party_command_window
  90.       windowb = @actor_command_window
  91.     when 1
  92.       windowa = @actor_command_window
  93.       windowb = @party_command_window
  94.     end
  95.     if @party_command_window.active and window.x < x1
  96.       window.x -= 16
  97.     elsif @actor_command_window.active and window.x > x2
  98.       window.x += 16
  99.     end
  100.   end
  101.  
  102. end
  103.  
  104. class Window_Selectable < Window_Base
  105.   attr_writer :column_max
  106.   attr_writer :spacing
  107. end
  108.  
  109. class Window_BattleStatus < Window_Selectable
  110.  
  111.   alias zreq_initialize initialize
  112.   def initialize
  113.     zreq_initialize
  114.     @column_max = Game_Party::MAX_MEMBERS
  115.   end
  116.  
  117.   def refresh
  118.     self.contents.clear
  119.     @item_max = $game_party.members.size
  120.     create_contents
  121.     for i in 0...@item_max
  122.       draw_item(i)
  123.     end
  124.   end
  125.  
  126.   def draw_item(index)
  127.     rect = Rect.new(index*128+4, 0, 120, 96)
  128.     self.contents.clear_rect(rect)
  129.     self.contents.font.color = normal_color
  130.     actor = $game_party.members[index]
  131.     x = rect.x
  132.     y = rect.y
  133.     draw_actor_face(actor, x+16, y, 64, 96)
  134.     draw_actor_name(actor, x, y-6)
  135.     draw_actor_state(actor, x, y+40, 48)
  136.     draw_actor_hp(actor, x, y+58, 120)
  137.     draw_actor_mp(actor, x, y+74, 120)
  138.   end
  139.  
  140.   def update_cursor
  141.     if @index < 0
  142.       self.cursor_rect.empty
  143.     else
  144.       rect = Rect.new(index*128, 0, 128, 96)
  145.       self.cursor_rect = rect
  146.     end
  147.   end
  148.  
  149. end
  150.  
  151. class Window_Base < Window
  152.  
  153.   def draw_face(face_name, face_index, x, y, size1 = 96, size2 = 96)
  154.     bitmap = Cache.face(face_name)
  155.     rect = Rect.new(0, 0, 0, 0)
  156.     rect.x = face_index % 4 * 96 + (96 - size2) / 2
  157.     rect.y = face_index / 4 * 96 + (96 - size1) / 2
  158.     rect.width = size2
  159.     rect.height = size1
  160.     self.contents.blt(x, y, bitmap, rect)
  161.     bitmap.dispose
  162.   end
  163.  
  164.   def draw_actor_face(actor, x, y, size1 = 96, size2 = -1)
  165.     size2 = size1 if size2 == -1
  166.     draw_face(actor.face_name, actor.face_index, x, y, size1, size2)
  167.   end
  168.  
  169. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement