Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Memor-X on May 13, 2013, 07:04:26 pm

Title: Making my HUD more efficent
Post by: Memor-X on May 13, 2013, 07:04:26 pm
even though KK20 helped me fix up the main problem i had with my HUD the fundamental problem with it was how it was designed, i choose to copy ForeverZer0's Debug output from CCTS cause it was outputting multiple displays in 1 class (i had 2 cause there was 2 different displays), anyway, i redid my Hud to use Window_Base and it's working a lot more stable now....and by that i mean it doesn't crash when i increase a stat

so anyway, my current problem is now efficiency, even on C.C who is still just a bit more powerful than a stock computer, there's a evident drop in the frame rate, anyway, here is the script

# Xgrid Class
class XGrid

 
  # system varibales
  attr_accessor     :xgrid_hub
  attr_accessor     :xgrid
  attr_accessor     :hud
 
  # inialized values
  def initialize
   
    @xgrid_hub = false
    @xgrid = false
    @hud = nil

  end
 
end

class XGrid_Hud < Window_Base
 
  HEADING_COLOR  = Color.new(255, 255, 0)
  SYSTEM_COLOR   = Color.new(192, 224, 255)
  NORMAL_COLOR   = Color.new(255, 255, 255)
  TOTAL_H_COLOUR = Color.new(200, 255, 200)
  TOTAL_COLOUR   = Color.new(100, 255, 100)
  TOTAL_G_COLOUR = Color.new(40, 241, 215)
  VIEWPORT_Z     = 10000
 
  def initialize
    # Determine dimensions by what type of clock will be created.
    dim = [275,170]
    super(-2, -2, dim[0], dim[1])
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity, self.z = 255, VIEWPORT_Z
    self.contents.font.name = 'Arial'
    self.contents.font.size = 14
    self.contents.font.bold = true
    self.windowskin = RPG::Cache.windowskin('Blizz-ABS Hud')

    # Draw the clock.
    refresh
  end
 
  def refresh
    # Clear the current bitmap.
    self.contents.clear
    # Set local variables equal to different text widths.
    cell = [35,20]
    offert_x = [contents.text_size('Aria Grids').width+10]
    offset_y = [contents.text_size('XGrid Completion').height+5]
   
    # Begin to draw the HUD.
    self.contents.font.color = HEADING_COLOR
    self.contents.draw_text(0, 0, 144, 15, 'XGrid Completion')
    self.contents.font.color = SYSTEM_COLOR
    self.contents.draw_text(offert_x[0]+(cell[0]*0), offset_y[0], 144, 15, 'Aria')
    self.contents.draw_text(offert_x[0]+(cell[0]*1), offset_y[0], 144, 15, 'Cain')
    self.contents.draw_text(offert_x[0]+(cell[0]*2), offset_y[0], 144, 15, 'Sain')
    self.contents.draw_text(offert_x[0]+(cell[0]*3), offset_y[0], 144, 15, 'Kaze')
    self.contents.font.color = TOTAL_H_COLOUR
    self.contents.draw_text(offert_x[0]+(cell[0]*4), offset_y[0], 144, 15, 'Total')
   
    self.contents.font.color = SYSTEM_COLOR
    self.contents.draw_text(0, offset_y[0]+(cell[1]*1), 144, 15, 'Aria Grids')
    self.contents.draw_text(0, offset_y[0]+(cell[1]*2), 144, 15, 'Cain Grids')
    self.contents.draw_text(0, offset_y[0]+(cell[1]*3), 144, 15, 'Sain Grids')
    self.contents.draw_text(0, offset_y[0]+(cell[1]*4), 144, 15, 'Kaze Grids')
    self.contents.font.color = TOTAL_H_COLOUR
    self.contents.draw_text(0, offset_y[0]+(cell[1]*5), 144, 15, 'Total %')
   
    self.contents.font.color = NORMAL_COLOR
    self.contents.draw_text(offert_x[0]+(cell[0]*0), offset_y[0]+(cell[1]*1), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*1), offset_y[0]+(cell[1]*1), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*2), offset_y[0]+(cell[1]*1), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*3), offset_y[0]+(cell[1]*1), 144, 15, '100%')
    self.contents.font.color = TOTAL_COLOUR
    self.contents.draw_text(offert_x[0]+(cell[0]*4), offset_y[0]+(cell[1]*1), 144, 15, '100%')
   
    self.contents.font.color = NORMAL_COLOR
    self.contents.draw_text(offert_x[0]+(cell[0]*0), offset_y[0]+(cell[1]*2), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*1), offset_y[0]+(cell[1]*2), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*2), offset_y[0]+(cell[1]*2), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*3), offset_y[0]+(cell[1]*2), 144, 15, '100%')
    self.contents.font.color = TOTAL_COLOUR
    self.contents.draw_text(offert_x[0]+(cell[0]*4), offset_y[0]+(cell[1]*2), 144, 15, '100%')
   
    self.contents.font.color = NORMAL_COLOR
    self.contents.draw_text(offert_x[0]+(cell[0]*0), offset_y[0]+(cell[1]*3), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*1), offset_y[0]+(cell[1]*3), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*2), offset_y[0]+(cell[1]*3), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*3), offset_y[0]+(cell[1]*3), 144, 15, '100%')
    self.contents.font.color = TOTAL_COLOUR
    self.contents.draw_text(offert_x[0]+(cell[0]*4), offset_y[0]+(cell[1]*3), 144, 15, '100%')
   
    self.contents.font.color = NORMAL_COLOR
    self.contents.draw_text(offert_x[0]+(cell[0]*0), offset_y[0]+(cell[1]*4), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*1), offset_y[0]+(cell[1]*4), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*2), offset_y[0]+(cell[1]*4), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*3), offset_y[0]+(cell[1]*4), 144, 15, '100%')
    self.contents.font.color = TOTAL_COLOUR
    self.contents.draw_text(offert_x[0]+(cell[0]*4), offset_y[0]+(cell[1]*4), 144, 15, '100%')
   
    self.contents.font.color = TOTAL_COLOUR
    self.contents.draw_text(offert_x[0]+(cell[0]*0), offset_y[0]+(cell[1]*5), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*1), offset_y[0]+(cell[1]*5), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*2), offset_y[0]+(cell[1]*5), 144, 15, '100%')
    self.contents.draw_text(offert_x[0]+(cell[0]*3), offset_y[0]+(cell[1]*5), 144, 15, '100%')
    self.contents.font.color = TOTAL_G_COLOUR
    self.contents.draw_text(offert_x[0]+(cell[0]*4), offset_y[0]+(cell[1]*5), 144, 15, '100%')
   
  end
 
  def update
    super
    # Redraw the clock every game minute.
    refresh #if @mins != $game_system.time.minute
  end
 
end

class XGrid_Char
 
  def initialize
    @elm = [XGrid_Grid_Stats.new,XGrid_Inve_Stats.new,XGrid_Char_Status.new]
  end
 
  def update
    @elm[0].update
    @elm[1].update
    @elm[2].update
  end
 
  def dispose
    @elm[0].dispose
    @elm[1].dispose
    @elm[2].dispose
   
    @elm = nil
  end

end

class XGrid_Grid_Stats < Window_Base
 
  HEADING_COLOR  = Color.new(255, 255, 0)
  SYSTEM_COLOR   = Color.new(192, 224, 255)
  NORMAL_COLOR   = Color.new(255, 255, 255)
  TOTAL_H_COLOUR = Color.new(200, 255, 200)
  TOTAL_COLOUR   = Color.new(100, 255, 100)
  TOTAL_G_COLOUR = Color.new(40, 241, 215)
  VIEWPORT_Z     = 10000
 
  ARIA = Color.new(229, 127, 255)
  SAIN = Color.new(0, 128, 255)
  CAIN = Color.new(254, 0, 0)
  KAZE = Color.new(0, 146, 64)
 
  def initialize
    # Determine dimensions by what type of clock will be created.
    dim = [260,190]
    super(-5, -7, dim[0], dim[1])
    self.contents = Bitmap.new(width - 5, height - 5)
    self.back_opacity, self.z = 255, VIEWPORT_Z
    self.contents.font.name = 'Arial'
    self.contents.font.size = 14
    self.contents.font.bold = true
    self.windowskin = RPG::Cache.windowskin('Blizz-ABS Hud')

    # Draw the clock.
    refresh
  end
 
  def refresh
    # Clear the current bitmap.
    self.contents.clear
    # Set local variables equal to different text widths.
    cell = [35,20]
    slash = [contents.text_size('9999').width,0]
    num = [contents.text_size('STR').width+10,contents.text_size('Limit Gates').width+10]
    max = [contents.text_size('/').width+5,0]
    col2 = [(num[0]+slash[0]+max[0])+30,0]
   
    self.contents.font.color = HEADING_COLOR
    # Begin to draw the HUD.
    self.contents.draw_text(0, 0, 144, 15, 'Grid Stats')
    self.contents.font.color = SYSTEM_COLOR
   
    self.contents.draw_text(0, (cell[1]*1), 144, 15, 'Grid: '+'GRID')
    self.contents.draw_text(0, (cell[1]*2), 144, 15, 'HP ')
    self.contents.draw_text(0, (cell[1]*3), 144, 15, 'MP ')
    self.contents.draw_text(0, (cell[1]*4), 144, 15, 'STR')
    self.contents.draw_text(0, (cell[1]*5), 144, 15, 'DEX')
    self.contents.draw_text(0, (cell[1]*6), 144, 15, 'AGI')
    self.contents.draw_text(0, (cell[1]*7), 144, 15, 'INT')
    self.contents.font.color = NORMAL_COLOR
    self.contents.draw_text((num[0]), (cell[1]*2), 144, 15, '999')
    self.contents.draw_text((num[0]), (cell[1]*3), 144, 15, '999')
    self.contents.draw_text((num[0]), (cell[1]*4), 144, 15, '999')
    self.contents.draw_text((num[0]), (cell[1]*5), 144, 15, '999')
    self.contents.draw_text((num[0]), (cell[1]*6), 144, 15, '999')
    self.contents.draw_text((num[0]), (cell[1]*7), 144, 15, '999')
    self.contents.font.color = SYSTEM_COLOR
    self.contents.draw_text((num[0]+slash[0]), (cell[1]*2), 144, 15, '/')
    self.contents.draw_text((num[0]+slash[0]), (cell[1]*3), 144, 15, '/')
    self.contents.draw_text((num[0]+slash[0]), (cell[1]*4), 144, 15, '/')
    self.contents.draw_text((num[0]+slash[0]), (cell[1]*5), 144, 15, '/')
    self.contents.draw_text((num[0]+slash[0]), (cell[1]*6), 144, 15, '/')
    self.contents.draw_text((num[0]+slash[0]), (cell[1]*7), 144, 15, '/')
    self.contents.font.color = NORMAL_COLOR
    self.contents.draw_text((num[0]+slash[0]+max[0]), (cell[1]*2), 144, 15, '999')
    self.contents.draw_text((num[0]+slash[0]+max[0]), (cell[1]*3), 144, 15, '999')
    self.contents.draw_text((num[0]+slash[0]+max[0]), (cell[1]*4), 144, 15, '999')
    self.contents.draw_text((num[0]+slash[0]+max[0]), (cell[1]*5), 144, 15, '999')
    self.contents.draw_text((num[0]+slash[0]+max[0]), (cell[1]*6), 144, 15, '999')
    self.contents.draw_text((num[0]+slash[0]+max[0]), (cell[1]*7), 144, 15, '999')
   
    self.contents.font.color = SYSTEM_COLOR
    self.contents.draw_text(col2[0], (cell[1]*2), 144, 15, 'Limit Gates')
    self.contents.draw_text(col2[0], (cell[1]*3), 144, 15, 'Level Locks')
    self.contents.draw_text(col2[0], (cell[1]*4), 144, 15, 'Skill')
    self.contents.draw_text(col2[0], (cell[1]*5), 144, 15, 'Nodes')
    self.contents.draw_text(col2[0], (cell[1]*7), 144, 15, 'Character')
    self.contents.font.color = NORMAL_COLOR
    self.contents.draw_text(col2[0]+(num[1]), (cell[1]*2), 144, 15, '999')
    self.contents.draw_text(col2[0]+(num[1]), (cell[1]*3), 144, 15, '999')
    self.contents.draw_text(col2[0]+(num[1]), (cell[1]*4), 144, 15, '999')
    self.contents.draw_text(col2[0]+(num[1]), (cell[1]*5), 144, 15, '999')
    self.contents.font.color = SYSTEM_COLOR
    self.contents.draw_text(col2[0]+(num[1]+slash[0]), (cell[1]*2), 144, 15, '/')
    self.contents.draw_text(col2[0]+(num[1]+slash[0]), (cell[1]*3), 144, 15, '/')
    self.contents.draw_text(col2[0]+(num[1]+slash[0]), (cell[1]*4), 144, 15, '/')
    self.contents.draw_text(col2[0]+(num[1]+slash[0]), (cell[1]*5), 144, 15, '/')
    self.contents.font.color = NORMAL_COLOR
    self.contents.draw_text(col2[0]+(num[1]+slash[0]+max[0]), (cell[1]*2), 144, 15, '999')
    self.contents.draw_text(col2[0]+(num[1]+slash[0]+max[0]), (cell[1]*3), 144, 15, '999')
    self.contents.draw_text(col2[0]+(num[1]+slash[0]+max[0]), (cell[1]*4), 144, 15, '999')
    self.contents.draw_text(col2[0]+(num[1]+slash[0]+max[0]), (cell[1]*5), 144, 15, '999')
   
    self.contents.font.color = ARIA
    self.contents.draw_text(col2[0]-10+(num[1]+(15*1)), (cell[1]*7), 144, 15, 'A')
    self.contents.font.color = CAIN
    self.contents.draw_text(col2[0]-10+(num[1]+(15*2)), (cell[1]*7), 144, 15, 'C')
    self.contents.font.color = SAIN
    self.contents.draw_text(col2[0]-10+(num[1]+(15*3)), (cell[1]*7), 144, 15, 'S')
    self.contents.font.color = KAZE
    self.contents.draw_text(col2[0]-10+(num[1]+(15*4)), (cell[1]*7), 144, 15, 'K')

    # Set instance variable. Used to check when to next refresh.
    #@mins = $game_system.time.minute
  end
 
  def update
    super
    # Redraw the clock every game minute.
    refresh #if @mins != $game_system.time.minute
  end
 
end

class XGrid_Inve_Stats < Window_Base
 
  HEADING_COLOR  = Color.new(255, 255, 0)
  SYSTEM_COLOR   = Color.new(192, 224, 255)
  NORMAL_COLOR   = Color.new(255, 255, 255)
  TOTAL_H_COLOUR = Color.new(200, 255, 200)
  TOTAL_COLOUR   = Color.new(100, 255, 100)
  TOTAL_G_COLOUR = Color.new(40, 241, 215)
  VIEWPORT_Z     = 10000
 
  ARIA = Color.new(229, 127, 255)
  SAIN = Color.new(0, 128, 255)
  CAIN = Color.new(254, 0, 0)
  KAZE = Color.new(0, 146, 64)
 
  def initialize
    # Determine dimensions by what type of clock will be created.
    dim = [160,245]
    super(640-dim[0]+1, -7, dim[0], dim[1])
    self.contents = Bitmap.new(width - 5, height - 5)
    self.back_opacity, self.z = 255, VIEWPORT_Z
    self.contents.font.name = 'Arial'
    self.contents.font.size = 14
    self.contents.font.bold = true
    self.windowskin = RPG::Cache.windowskin('Blizz-ABS Hud')

    # Draw the clock.
    refresh
  end
 
  def refresh
    # Clear the current bitmap.
    self.contents.clear
    # Set local variables equal to different text widths.
    cell = [35,20]
    heading = [contents.text_size('Magix').width+10,contents.text_size('Limit').width+10]
    col2 = [heading[0]+contents.text_size('99').width+20,0]
    section2 = [(cell[1]*6),0]
    s2heading = [contents.text_size('Char Lv.').width+10,0]
   
    self.contents.font.color = HEADING_COLOR
    # Begin to draw the HUD.
    self.contents.draw_text(0, 0, 144, 15, 'System Stats')
    self.contents.font.color = SYSTEM_COLOR
   
    self.contents.draw_text(0, (cell[1]*1), 144, 15, 'Sphere Stock:')
    self.contents.draw_text(0, (cell[1]*2), 144, 15, 'Power')
    self.contents.draw_text(0, (cell[1]*3), 144, 15, 'Mind')
    self.contents.draw_text(0, (cell[1]*4), 144, 15, 'Speed')
    self.contents.draw_text(0, (cell[1]*5), 144, 15, 'Magix')
    self.contents.font.color = NORMAL_COLOR
    self.contents.draw_text(heading[0], (cell[1]*2), 144, 15, '99')
    self.contents.draw_text(heading[0], (cell[1]*3), 144, 15, '99')
    self.contents.draw_text(heading[0], (cell[1]*4), 144, 15, '99')
    self.contents.draw_text(heading[0], (cell[1]*5), 144, 15, '99')
    self.contents.font.color = SYSTEM_COLOR
    self.contents.draw_text(col2[0], (cell[1]*2), 144, 15, 'Tetra')
    self.contents.draw_text(col2[0], (cell[1]*3), 144, 15, 'Char')
    self.contents.draw_text(col2[0], (cell[1]*4), 144, 15, 'Limit')
    self.contents.font.color = NORMAL_COLOR
    self.contents.draw_text(col2[0]+heading[1], (cell[1]*2), 144, 15, '99')
    self.contents.draw_text(col2[0]+heading[1], (cell[1]*3), 144, 15, '99')
    self.contents.draw_text(col2[0]+heading[1], (cell[1]*4), 144, 15, '99')
   
    self.contents.font.color = SYSTEM_COLOR
    self.contents.draw_text(0, section2[0]+(cell[1]*1), 144, 15, 'Misc:')
    self.contents.draw_text(0, section2[0]+(cell[1]*2), 144, 15, 'Stage')
    self.contents.draw_text(0, section2[0]+(cell[1]*3), 144, 15, 'Char Lv.')
    self.contents.draw_text(0, section2[0]+(cell[1]*4), 144, 15, 'GP')
    self.contents.font.color = NORMAL_COLOR
    self.contents.draw_text(s2heading[0], section2[0]+(cell[1]*2), 144, 15, '99')
    self.contents.draw_text(s2heading[0], section2[0]+(cell[1]*3), 144, 15, '99')
    self.contents.draw_text(s2heading[0], section2[0]+(cell[1]*4), 144, 15, '999999999999')
   
    # Set instance variable. Used to check when to next refresh.
    #@mins = $game_system.time.minute
  end
 
  def update
    super
    # Redraw the clock every game minute.
    refresh #if @mins != $game_system.time.minute
  end
 
end

class XGrid_Char_Status < Window_Base
 
  HEADING_COLOR  = Color.new(255, 255, 0)
  SYSTEM_COLOR   = Color.new(192, 224, 255)
  NORMAL_COLOR   = Color.new(255, 255, 255)
  TOTAL_H_COLOUR = Color.new(200, 255, 200)
  TOTAL_COLOUR   = Color.new(100, 255, 100)
  TOTAL_G_COLOUR = Color.new(40, 241, 215)
  UNEQUIPED      = Color.new(175, 175, 175)
  VIEWPORT_Z     = 10000
 
  EXION = [Color.new(229, 127, 255),Color.new(0, 128, 255),
           Color.new(254, 0, 0),Color.new(0, 146, 64)]
 
  def initialize
    # Determine dimensions by what type of clock will be created.
    dim = [255,170]
    super(160, 240, dim[0], dim[1])
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity, self.z = 255, VIEWPORT_Z
    self.contents.font.name = 'Arial'
    self.contents.font.size = 14
    self.contents.font.bold = true
    self.windowskin = RPG::Cache.windowskin('Blizz-ABS Hud')

    # Draw the clock.
    refresh
  end
 
  def refresh
    # Clear the current bitmap.
    self.contents.clear
    # Set local variables equal to different text widths.
    cell = [35,20]
    heading = [contents.text_size('STR').width+10,contents.text_size('999999').width+10]
    value = [contents.text_size('999999').width+10,0]
   
    self.contents.font.color = HEADING_COLOR
    # Begin to draw the HUD.
    self.contents.draw_text(0, (cell[1]*0), 144, 15, $game_actors[1].name+' Stats')
    self.contents.font.color = SYSTEM_COLOR
    self.contents.draw_text(((heading[0]+value[0])*0), (cell[1]*1), 144, 15, 'HP')
    self.contents.draw_text(((heading[0]+value[0])*1), (cell[1]*1), 144, 15, 'MP')
    self.contents.draw_text(((heading[0]+value[0])*2), (cell[1]*1), 144, 15, 'STR')
   
    self.contents.font.color = NORMAL_COLOR
    self.contents.draw_text(((heading[0]+value[0])*0)+heading[0], (cell[1]*1), 144, 15, '999999')
    self.contents.draw_text(((heading[0]+value[0])*1)+heading[0], (cell[1]*1), 144, 15, '999999')
    self.contents.draw_text(((heading[0]+value[0])*2)+heading[0], (cell[1]*1), 144, 15, $game_actors[1].str.to_s)
   
    self.contents.font.color = SYSTEM_COLOR
    self.contents.draw_text(((heading[0]+value[0])*0), (cell[1]*2), 144, 15, 'DEX')
    self.contents.draw_text(((heading[0]+value[0])*1), (cell[1]*2), 144, 15, 'AGI')
    self.contents.draw_text(((heading[0]+value[0])*2), (cell[1]*2), 144, 15, 'INT')
   
    self.contents.font.color = NORMAL_COLOR
    self.contents.draw_text(((heading[0]+value[0])*0)+heading[0], (cell[1]*2), 144, 15, '999999')
    self.contents.draw_text(((heading[0]+value[0])*1)+heading[0], (cell[1]*2), 144, 15, '999999')
    self.contents.draw_text(((heading[0]+value[0])*2)+heading[0], (cell[1]*2), 144, 15, '999999')
   
    self.contents.font.color = SYSTEM_COLOR
    self.contents.draw_text(0, (cell[1]*3), 144, 15, 'Exion')
    self.contents.font.color = UNEQUIPED
   
    self.contents.draw_text((heading[1]*0), (cell[1]*4), 144, 15, 'Fivian')   # Fire
    self.contents.draw_text((heading[1]*1), (cell[1]*4), 144, 15, 'Ita')      # Ice
    self.contents.draw_text((heading[1]*2), (cell[1]*4), 144, 15, 'Ikado')    # Thunder
    self.contents.draw_text((heading[1]*3), (cell[1]*4), 144, 15, 'Uti')      # Water
    self.contents.draw_text((heading[1]*4), (cell[1]*4), 144, 15, 'Marcos')   # Earth
   
    self.contents.draw_text((heading[1]*0), (cell[1]*5), 144, 15, 'Ace')     # Wind
    self.contents.draw_text((heading[1]*1), (cell[1]*5), 144, 15, 'Theti')   # Light
    self.contents.draw_text((heading[1]*2), (cell[1]*5), 144, 15, 'Moe')     # Darkness
    self.contents.draw_text((heading[1]*3), (cell[1]*5), 144, 15, 'Seraph')  # Mind
    self.contents.draw_text((heading[1]*4), (cell[1]*5), 144, 15, 'Roxas')   # Ballance
   
    self.contents.draw_text((heading[1]*2), (cell[1]*6), 144, 15, 'Mema') # Secret
   
  end
 
  def update
    super
    # Redraw the clock every game minute.
    refresh #if @mins != $game_system.time.minute
  end
 
end

class Scene_Map
 
  alias xgrid_main main
  def main
   
    # Main loop.
    xgrid_main

  end
 
  alias xgrid_upd update
  def update
    xgrid_upd
   
    if $xgrid.hud == nil
      if $xgrid.xgrid == true
        $xgrid.hud = XGrid_Char.new
      end
      if $xgrid.xgrid_hub == true
        $xgrid.hud = XGrid_Hud.new
      end
    end
   
    if $xgrid.hud != nil
      if $xgrid.xgrid == true || $xgrid.xgrid_hub == true
        $xgrid.hud.update
      else
        $xgrid.hud = $xgrid.hud.dispose
      end
    end
  end
end


you will also need to add
$xgrid = XGrid.new
in Scene_Title line 127 (in command_new_game)

here are the 4 events you will need, each event has a single call script with the code specified

Event 1 Activate

$xgrid.xgrid_hub = true

Event 2 deactivate

$xgrid.xgrid_hub = false
$xgrid.xgrid = false

Event 3 Activate Hub

$xgrid.xgrid = false
$xgrid.xgrid_hub = true

Event 4 Activate Grid

$xgrid.xgrid_hub = false
$xgrid.xgrid = true


Event 1 need to be triggered first, it will display the hub HUD, the second event deactivates the HUD and need to be run whenever you switch between them, the 3rd and 4th events activate the named HUDs (Hub and Grid)

here's the problems



i'm wondering where in my HUD Classes it needs improvement to make it more efficient, the main problem is what i want fixed up more than anything cause the first one only happens on Aura and she's getting old (she can't run Vista, only XP)

NOTE: any of the white Text, the 4 colored letters in the top left window, the word "GRID" next to "grid:" and the Exion List in the bottom window are dynamic, i'm just using static values at the moment, also, the bottom window doesn't have a place yet, still thinking on where i should put it
Title: Re: Making my HUD more efficent
Post by: KK20 on May 14, 2013, 08:33:20 pm
You're calling drawing methods every frame. Drawing anything takes a lot of time and memory, resulting in lag. A 'refresh' method should really only be called once when changes (e.g. stats) are made. If you need to update something specific every frame (like the time), make a separate method for that, using a 'draw_rect' to clear the contents of an area.

Side-note, the order in which you talked to the events does not factor into causing more or less lag. I went 1 to 4 and instantly hit lag.
Title: Re: Making my HUD more efficent
Post by: Memor-X on May 14, 2013, 08:51:23 pm
Quote from: KK20 on May 14, 2013, 08:33:20 pm
You're calling drawing methods every frame. Drawing anything takes a lot of time and memory, resulting in lag. A 'refresh' method should really only be called once when changes (e.g. stats) are made. If you need to update something specific every frame (like the time), make a separate method for that, using a 'draw_rect' to clear the contents of an area.


starting with the basics, how would i check when $actors[1].str is changed, the only why i can see that i go about doing that is that when i want to $actors[1].str i should store it in a variable then in the update where i output $actors[1].str i have an if statement which checks $actors[1].str against the original value and if they aren't the same output $actors[1].str and set the original value variable to be the same as $actors[1].str but i'm not sure if that's what your supposed to do

Quote from: KK20 on May 14, 2013, 08:33:20 pm
Side-note, the order in which you talked to the events does not factor into causing more or less lag. I went 1 to 4 and instantly hit lag.


event 4 calls up the Grid HUD which always lags even on C.C, reason why i want to fix it, it's just that when you go 1 -> 2 -> 3-> 2 the lag you originally got from 1 doesn't occur even though the HUD is the exact same
Title: Re: Making my HUD more efficent
Post by: KK20 on May 15, 2013, 02:03:37 am
Yes, that is essentially how you should go about doing it. If you want to do something crazy, you can alias all the 'stat=' methods in Game_Battler and assign a global variable to true, then make the HUD update when this global variable is true.

I could not experience, nor notice, any lag through that method you described. I also cannot see anything obvious in your code as to why it would do that. It probably won't be a matter of concern anymore once you edit the script.
Title: Re: Making my HUD more efficent
Post by: Memor-X on May 15, 2013, 02:36:15 am
Quote from: KK20 on May 15, 2013, 02:03:37 am
I could not experience, nor notice, any lag through that method you described. I also cannot see anything obvious in your code as to why it would do that. It probably won't be a matter of concern anymore once you edit the script.


well the method i described only shows lag on Aura, my laptop, she's running windows XP and is 5-6 years old, maybe older, i can't remember when my mum got her and mum game her to me about 3 years ago cause i apparently needed a laptop to work on second life at uni during the Project course, at the time she came with Vista but when i did a factory restore to wipe out all my brother's crap she was in XP, later found out Harvey Norman where my mum got the laptop before just went and upgraded the laptop to Vista using a Vista Upgrade Disk while still selling it with it's original XP Factory Setting Restore Disks.

anyway, Aura can no longer be upgraded to Vista cause she doesn't have the recommended RAM, i think one of them burned out or something, it could just be that Aura is kinda shoody ever since some dickhead hacker tried to install something on her and the AIDA in her reacted and cut the net connection but something was installed and all i could get after login in was a white screen, with no response from the keyboard or mouse, one good example is an encryption extension for Game Maker works fine on C.C but will always fail in Aura

Quote from: KK20 on May 14, 2013, 08:33:20 pm
You're calling drawing methods every frame.


given that i need to do a check now to see when i update, i still have to re-draw the entire hud when there is a change because of the first line
self.contents.clear
, is there a way i can update my dynamic text (white Text, the 4 colored letters in the top left window, the word "GRID" next to "grid:" and the Exion List in the bottom window) cause i thought i had to use .clear and rebuild the entire thing when i wanted to update
Title: Re: Making my HUD more efficent
Post by: KK20 on May 15, 2013, 12:11:06 pm
Quote from: KK20 on May 14, 2013, 08:33:20 pm
If you need to update something specific every frame (like the time), make a separate method for that, using a 'draw_rect' to clear the contents of an area.

To elaborate on this statement, using
self.contents.draw_rect(x, y, width, height, Color.new(0,0,0,0))
is the equivalent of using an eraser in a rectangular area. Some of the default RMXP scripts use this method (as do a lot of custom scripts).

'clear' returns the same effect as
self.contents.draw_rect(0, 0, self.contents.width, self.contents.height, Color.new(0,0,0,0))
It is not necessary to call 'clear' every time when redrawing a window. It's just that, usually, when redrawing contents in a window, all of the information displayed is most likely outdated and needs to be updated.