QuasiXi

[GTBS] Hud 1.0

Feb 1st, 2014
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.90 KB | None | 0 0
  1. #===============================================================================
  2. # GTBS info Hud + ATB Order list
  3. # made for GTBS 2.4
  4. #
  5. # Atb orderlist is shown only if you gtbs mode is set for ATB.
  6. # Hud displayes cursors x,y,h and battle turn.
  7. # ( Not sure if battle turn is correct, didn't test it much. )
  8. #
  9. # Few settings in module Quasi to help set up the order list window.
  10. # Windows are kind of big, so would look best with image backgrounds or a
  11. # a bigger window Res
  12. #
  13. # For image backgrounds, backimages should be placed in 'Graphics/Pictures/GTBS/'
  14. # For the Hud its called 'Hud.png'
  15. # and for ATB List 'ATB_Win.png'
  16. #
  17. # The ATB window can use pictures for the order list instead of names.
  18. # Pictures should be in 'Graphics/Pictures/GTBS/Atb/'
  19. # and they should be named after the actor/enemy.
  20. # If picture isn't found it uses the actors name instead.
  21. # * Make sure the pictures size is the same at ATB_PIC_SIZE
  22. #
  23. # There's not much settings for the postions, but they can be manually edited.
  24. # No settings for the Hud window, if you want to change it, you have to do that
  25. # manually.
  26. #
  27. # By Quasi
  28. # 2/1/14
  29. #===============================================================================
  30. module Quasi
  31.   # Displays the pictures horizontal
  32.   # if false, it switchs the x with y, and the windows width with height
  33.   ATB_HORI      = false
  34.  
  35.   # Sets if you want the hud and atb window to hide when skill or item
  36.   # windows are displayed.
  37.   ATB_HIDE      = true
  38.  
  39.   ATB_WIN_POS   = 0 # 0 = top, 1 = bottom
  40.   ATB_WIN_W     = (28 * 7) + 32  #Windows Width = (ATB_SPACING * ATB_SIZE) + Padding
  41.   ATB_WIN_H     = 64 # Window height
  42.  
  43.   ATB_PIC_SIZE  = [24,24] # [width, height]
  44.   ATB_SIZE      = 7 # How many actors to display
  45.   ATB_SPACING   = 28 # Leaves 2 pixel spacing between 24x24
  46.   ATB_Y         = 0 # Lowers Y for actor pics
  47.  
  48.   # Colors/outline for Actors Order Pic
  49.   ATB_COLOR_ACTOR   = Color.new(0,255,0,255) #Blue
  50.   ATB_COLOR_ENEMY   = Color.new(255,0,0,255) #Red
  51.   ATB_COLOR_CURRENT = Color.new(0,0,255,255) #Green
  52. end
  53. #===============================================================================
  54. # Changes to [GTBS] Scene_Battle
  55. # Adds windows + hides
  56. #
  57. # Overwrites:
  58. # update_selected
  59. #
  60. # Alias:
  61. # setup_start_atb, exit_wait_phase, exit_process_action, create_windows, update,
  62. # place_update, actor_menu_open, update_window_item, update_window_skill,
  63. # cleanup_mini, transition_start_placement_mini
  64. #
  65. #===============================================================================
  66. class Scene_Battle_TBS
  67.   Win_Place = 'place'
  68.   Win_ATB = 'win_atb'
  69.   Win_Hud = 'hud'
  70.  
  71.   alias quasi_setup_start_atb setup_start_atb
  72.   alias quasi_exit_wait_phase exit_wait_phase
  73.   alias quasi_exit_process_action exit_process_action
  74.   alias quasi_exit_ai_processing exit_ai_processing
  75.   alias quasi_hud create_windows
  76.   alias quasi_hud_update update
  77.   alias quasi_hud_place_update place_update
  78.   alias quasi_hud_open actor_menu_open
  79.   alias quasi_hud_item update_window_item
  80.   alias quasi_hud_skill update_window_skill
  81.  
  82.   def create_windows
  83.     quasi_hud
  84.     @windows[Win_Hud] = Window_GTBS_Hud.new
  85.   end
  86.  
  87.   def setup_start_atb
  88.     quasi_setup_start_atb
  89.     @windows[Win_ATB] = Window_AtbList.new(@active_battler, populate_list)
  90.     if Quasi::ATB_HORI == true
  91.       @windows[Menu_Actor].y = @windows[Win_ATB].height if Quasi::ATB_WIN_POS == 0
  92.     else
  93.       @windows[Menu_Actor].x = @windows[Win_ATB].width
  94.     end
  95.   end
  96.  
  97.   def exit_wait_phase
  98.     quasi_exit_wait_phase
  99.     return unless @windows[Win_ATB]
  100.     @windows[Win_ATB].list = populate_list
  101.   end
  102.  
  103.   def exit_process_action
  104.     quasi_exit_process_action
  105.     return unless @windows[Win_ATB]
  106.     @windows[Win_ATB].list = populate_list
  107.   end
  108.  
  109.   def exit_ai_processing
  110.     quasi_exit_ai_processing
  111.     return unless @windows[Win_ATB]
  112.     @windows[Win_ATB].list = populate_list
  113.   end
  114.  
  115.   def actor_menu_open
  116.     quasi_hud_open
  117.     @windows[Win_Hud].show
  118.     return unless @windows[Win_ATB]
  119.     @windows[Win_ATB].show
  120.   end
  121.  
  122.   def update_window_item
  123.     if Quasi::ATB_HIDE == true
  124.       @windows[Win_Hud].hide
  125.       @windows[Win_ATB].hide if @windows[Win_ATB]
  126.     end
  127.     quasi_hud_item
  128.   end
  129.  
  130.   def update_window_skill
  131.     if Quasi::ATB_HIDE == true
  132.       @windows[Win_Hud].hide
  133.       @windows[Win_ATB].hide if @windows[Win_ATB]
  134.     end
  135.     quasi_hud_skill
  136.   end
  137.  
  138.   #----------------------------------------------------------------------------
  139.   # Update Process
  140.   #----------------------------------------------------------------------------
  141.   def update
  142.     quasi_hud_update
  143.     if @windows[Win_Hud].cursor_x != @cursor.x
  144.       @windows[Win_Hud].cursor_x = @cursor.x
  145.     end
  146.     if @windows[Win_Hud].cursor_y != @cursor.y
  147.       @windows[Win_Hud].cursor_y = @cursor.y
  148.     end
  149.     if @windows[Win_Hud].turn != tbs_turn_count
  150.       @windows[Win_Hud].turn = tbs_turn_count
  151.     end
  152.   end
  153.  
  154.   def place_update
  155.     quasi_hud_place_update
  156.     if @windows[Win_Hud].cursor_x != @cursor.x
  157.       @windows[Win_Hud].cursor_x = @cursor.x
  158.     end
  159.     if @windows[Win_Hud].cursor_y != @cursor.y
  160.       @windows[Win_Hud].cursor_y = @cursor.y
  161.     end
  162.   end
  163.  
  164.   #-------------------------------------------------------------------------
  165.   # Update_Selected - returns cursor selected actor
  166.   # Changed Win_Status move from 9(upper right) to 3(bottom right)
  167.   #-------------------------------------------------------------------------
  168.   def update_selected
  169.     #no select when exiting
  170.     if @battle_exiting
  171.       @selected = nil
  172.      
  173.     #fast update if @cursor didn't change position
  174.     elsif @selected.nil? or not @selected.at_xy_coord(@cursor.x, @cursor.y)
  175.       @selected = nil
  176.       battler = $game_map.occupied_by?(@cursor.x, @cursor.y)
  177.       if battler != nil
  178.       #for battler in tactics_all
  179.       #  next if battler.nil?
  180.       #  if battler.at_xy_coord(@cursor.x, @cursor.y)
  181.           @selected =  battler
  182.           @windows[Win_Status].update(battler)
  183.           #Modified to be hard coded to top right checking.
  184.           mx = Graphics.width - @windows[Win_Status].width
  185.           mw = Graphics.width
  186.           my = 0
  187.           mv = @windows[Win_Status].height
  188.           if @spriteset.cursor.x.between?(mx, mw) && @spriteset.cursor.y.between?(my,mv)
  189.             @windows[Win_Status].move_to(3);
  190.           else
  191.             @windows[Win_Status].move_to(3);
  192.           end
  193.           return
  194.       #  end
  195.       end
  196.     end
  197.   end
  198. end
  199.  
  200. #===============================================================================
  201. # Add Hide in [GTBS] Side Battle
  202. #===============================================================================
  203. class Scene_Battle_TBS
  204.   alias quasi_cleanup_mini cleanup_mini
  205.   alias quasi_transition_start_placement_mini transition_start_placement_mini
  206.  
  207.   def transition_start_placement_mini
  208.     quasi_transition_start_placement_mini
  209.     @windows[Win_Hud].hide
  210.     return unless @windows[Win_ATB]
  211.     @windows[Win_ATB].hide
  212.   end
  213.  
  214.   def cleanup_mini
  215.     quasi_cleanup_mini
  216.     @windows[Win_Hud].show
  217.     return unless @windows[Win_ATB]
  218.     @windows[Win_ATB].show
  219.   end
  220. end
  221.  
  222. #===============================================================================
  223. # Windows_Status_GTBS
  224. #===============================================================================
  225. class Windows_Status_GTBS < TBS_Window_Base
  226.   def initialize(actor = nil)
  227.     super(0, 0, 250, 155)
  228.     create_contents
  229.     ensure_open
  230.     setup_gauges
  231.     move_to(4)
  232.     setup_temp
  233.     refresh
  234.     @win_help = nil;
  235.   end
  236. end
  237.  
  238. #===============================================================================
  239. # Window ActList
  240. #===============================================================================
  241. class Window_AtbList < TBS_Window_Base
  242.   Max_Updates = 400
  243.  
  244.   #--------------------------------------------------------------
  245.   # * Object Initialization
  246.   #--------------------------------------------------------------
  247.   def initialize(actor, act_list = nil)
  248.     if Quasi::ATB_HORI == true
  249.       w = Quasi::ATB_WIN_W
  250.       h = Quasi::ATB_WIN_H
  251.     else
  252.       w = Quasi::ATB_WIN_H
  253.       h = Quasi::ATB_WIN_W
  254.     end
  255.     if Quasi::ATB_WIN_POS == 0
  256.       x = 0
  257.       y = 0
  258.     else
  259.       x = 0
  260.       y = Graphics.height - h - 72
  261.     end
  262.     super(x, y, w, h)
  263.     @act_list = act_list  
  264.     @actor = actor
  265.     @item_max =1
  266.     create_back
  267.     refresh
  268.   end
  269.  
  270.   def create_back
  271.     if FileTest.exist?('Graphics/Pictures/GTBS/ATB_Win.png')
  272.       @back = Sprite.new
  273.       @back.bitmap = Cache.picture('GTBS/ATB_Win.png')
  274.       @back.z = 0
  275.       self.opacity = 0
  276.     else
  277.       self.opacity = GTBS::CONTROL_OPACITY
  278.     end
  279.   end
  280.  
  281.   def list=(newlist)
  282.     return if @act_list == newlist
  283.     @act_list = newlist
  284.     refresh
  285.   end
  286.  
  287.   #--------------------------------------------------------------
  288.   # * Refresh
  289.   #--------------------------------------------------------------
  290.   def refresh
  291.     self.contents.clear
  292.     for i in 0...Quasi::ATB_SIZE
  293.       draw_list_item(i)
  294.     end
  295.   end
  296.  
  297.   #--------------------------------------------------------------
  298.   # * Draw List Item
  299.   #--------------------------------------------------------------
  300.   def draw_list_item(i)
  301.     if @act_list[i].is_a?(Array)
  302.       string = @act_list[i][0].name
  303.       string += "("+@act_list[i][1][0].name+")"
  304.     else
  305.       string = @act_list[i].name
  306.     end
  307.    
  308.     w = Quasi::ATB_PIC_SIZE[0]
  309.     h = Quasi::ATB_PIC_SIZE[1]
  310.    
  311.     if Quasi::ATB_HORI == true
  312.       x = (Quasi::ATB_SPACING * i) + 1
  313.       y = Quasi::ATB_Y
  314.     else
  315.       y = (Quasi::ATB_SPACING * i) + 1
  316.       x = Quasi::ATB_Y
  317.     end
  318.    
  319.     if i == 0
  320.       color = Quasi::ATB_COLOR_CURRENT
  321.       if Quasi::ATB_HORI == true
  322.         y += 5
  323.       else
  324.         x +=5
  325.       end
  326.     elsif @act_list[i].actor?
  327.       color = Quasi::ATB_COLOR_ACTOR
  328.     elsif @act_list[i].enemy?
  329.       color = Quasi::ATB_COLOR_ENEMY
  330.     else
  331.       color = Quasi::ATB_COLOR_CURRENT
  332.     end
  333.    
  334.     rect = Rect.new(x,y,w,h)
  335.     rectbg = Rect.new(x-1,y-1,w+2,h+2)
  336.     rectbg2 = Bitmap.new(self.width, self.height)
  337.     rectbg2.fill_rect(x-1, y-1, w+2, h+2, color)
  338.     contents.blt(rectbg.x, rectbg.y, rectbg2, rectbg)
  339.    
  340.     if FileTest.exist?("Graphics/Pictures/GTBS/Atb/#{string}.png")
  341.       rectbg = Bitmap.new(w, h)
  342.       rectbg = Cache.picture("GTBS/Atb/#{string}")
  343.       rect2 = Rect.new(0,0,self.width,self.height)
  344.       self.contents.blt(x, y, rectbg, rect2)
  345.     else
  346.       self.contents.draw_text(rect,"#{string}")
  347.     end
  348.   end
  349. end
  350.  
  351.  
  352.  
  353. #===============================================================================
  354. # Window GTBS Hud
  355. #===============================================================================
  356. class Window_GTBS_Hud < TBS_Window_Base
  357.   def initialize
  358.     super(0, 0, 150, 100)
  359.     move_to(9)
  360.     @cursor_x = 0
  361.     @cursor_y = 0
  362.     @turn = 0
  363.     create_back
  364.     refresh
  365.   end
  366.  
  367.   def create_back
  368.     if FileTest.exist?('Graphics/Pictures/GTBS/Hud.png')
  369.       @back = Sprite.new
  370.       @back.bitmap = Cache.picture('GTBS/Hud.png')
  371.       @back.z = 0
  372.       self.opacity = 0
  373.     else
  374.       self.opacity = GTBS::CONTROL_OPACITY
  375.     end
  376.   end
  377.  
  378.   def cursor_x
  379.     return @cursor_x
  380.   end
  381.  
  382.   def cursor_x=(x)
  383.     @cursor_x = x
  384.     refresh
  385.   end
  386.  
  387.   def cursor_y
  388.     return @cursor_x
  389.   end
  390.  
  391.   def cursor_y=(y)
  392.     @cursor_y = y
  393.     refresh
  394.   end
  395.  
  396.   def turn
  397.     return @turn
  398.   end
  399.  
  400.   def turn=(turn)
  401.     @turn = turn
  402.     refresh
  403.   end
  404.  
  405.   def refresh
  406.     contents.clear
  407.     x = self.width - (125 + 32 )
  408.     turn = @turn / 2
  409.     turn = 1 if @turn == 0
  410.     contents.draw_text(x, 0, 125, 32, "Turn:" + turn.to_s, 2)
  411.     contents.draw_text(x,24,125,32,"X: " + @cursor_x.to_s + " Y: " + @cursor_y.to_s, 2)
  412.  
  413.     return unless Layy_Meta.active
  414.     h = $game_map.get_altitude(@cursor_x, @cursor_y)
  415.     contents.draw_text(x,48,125,32,"H: " + h.to_s, 2)
  416.   end
  417. end
Advertisement
Add Comment
Please, Sign In to add comment