# ***** BETTER STATUS WINDOW *****
#    A script by Travis F.
# (c) 2018 Zetaform Games / Travis F.
#
# Feel free to use this script in any game you want.
# No, seriously. Any game. Even if it goes commercial!
# (Though a bit of credit would be nice in that case...)
#==============================================================================
#
#
# This script will organise the status screen into different windows,
# so that it'll look neater. It also adds a profile section, called the
# Bio in this script, that you can turn off if you wish.
# Install this script above Main.
#
# Configuration:
# This switch will enable/disable
# the bio at the bottom of the status screen.

SHOWBIO = true

# Now configure the bio entries here.
def get_actor_bio()
  case
    when @actor.name == "Aluxes" then
      l0 = "Age 30"
      l1 = "An excellent fighter."
      l2 = "Wards off the undead with his"
      l3 = "expertly-crafted blade."
    when @actor.name == "Basil" then
      l0 = "Age 32"
      l1 = "Having worked as a castle"
      l2 = "guard before, his skills"
      l3 = "are the best of the best."
    when @actor.name == "Gloria" then
      l0 = "Age 26"
      l1 = "A reliable cleric."
      l2 = "Very confident about what"
      l3 = "she gets herself into."
    when @actor.name == "Hilda" then
      l0 = "Age 36"
      l1 = "She's been trained in"
      l2 = "using magic attacks."
      l3 = "They do lots of damage!"  
  end
  self.contents.draw_text(64, 0, 192, 24, l0, 2)
  self.contents.draw_text(0, 24, 320, 32, l1)
  self.contents.draw_text(0, 48, 320, 32, l2)
  self.contents.draw_text(0, 72, 320, 32, l3)
end
# That's it! You're done!

#==============================================================================

# This status window will display basic stats about the current actor.
# It will be on the left side.

#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#==============================================================================

class Window_Status < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 320, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 40, 112)
    draw_actor_name(@actor, 4, 0)
    draw_actor_class(@actor, 4 + 144, 0)
    draw_actor_level(@actor, 96, 32)
    draw_actor_state(@actor, 96, 64)
    draw_actor_hp(@actor, 96, 112, 172)
    draw_actor_sp(@actor, 96, 144, 172)
    draw_actor_parameter(@actor, 96, 192, 0)
    draw_actor_parameter(@actor, 96, 224, 1)
    draw_actor_parameter(@actor, 96, 256, 2)
    draw_actor_parameter(@actor, 96, 304, 3)
    draw_actor_parameter(@actor, 96, 336, 4)
    draw_actor_parameter(@actor, 96, 368, 5)
    draw_actor_parameter(@actor, 96, 400, 6)
  end
end

#==============================================================================
# This status window displays the EXP of the current actor.
# It will be in the upper right corner.

#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#==============================================================================

class Window_StatusTop < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(320, 0, 320, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 192, 32, "Total EXP:")
    self.contents.draw_text(0, 32, 192, 32, "Next Level:")
    self.contents.font.color = normal_color
    self.contents.draw_text(0 + 160, 0, 84, 32, @actor.exp_s, 2)
    self.contents.draw_text(0 + 160, 32, 84, 32, @actor.next_rest_exp_s, 2)
  end
end

#==============================================================================
# This status window displays equipped items of the current actor.
# It will be to the right centre.
# If the Bio is disabled, it will take up the rest of the vertical space.

#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#==============================================================================

class Window_StatusBottom < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    if SHOWBIO == true
        super(320, 96, 320, 240)
    else
        super(320, 96, 320, 384)
    end
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 128, 32, "Equipment:")
    draw_item_name($data_weapons[@actor.weapon_id], 0 + 16, 32)
    draw_item_name($data_armors[@actor.armor1_id], 0 + 16, 64)
    draw_item_name($data_armors[@actor.armor2_id], 0 + 16, 96)
    draw_item_name($data_armors[@actor.armor3_id], 0 + 16, 128)
    draw_item_name($data_armors[@actor.armor4_id], 0 + 16, 160)
  end
  def dummy
    self.contents.font.color = system_color
    self.contents.draw_text(0, 112, 96, 32, $data_system.words.weapon)
    self.contents.draw_text(0, 176, 96, 32, $data_system.words.armor1)
    self.contents.draw_text(0, 240, 96, 32, $data_system.words.armor2)
    self.contents.draw_text(0, 304, 96, 32, $data_system.words.armor3)
    self.contents.draw_text(0, 368, 96, 32, $data_system.words.armor4)
    draw_item_name($data_weapons[@actor.weapon_id], 0 + 24, 144)
    draw_item_name($data_armors[@actor.armor1_id], 0 + 24, 208)
    draw_item_name($data_armors[@actor.armor2_id], 0 + 24, 272)
    draw_item_name($data_armors[@actor.armor3_id], 0 + 24, 336)
    draw_item_name($data_armors[@actor.armor4_id], 0 + 24, 400)
  end
end

#==============================================================================
# This window will display the bio, if enabled.
# Configure bio entries here.

#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#==============================================================================
class Window_StatusBio < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(320, 336, 320, 144)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 48, 24, "Bio:")
    self.contents.font.color = normal_color
    get_actor_bio()
  end
end


#==============================================================================
# Replace the Status Scene to fit the new windows.

#==============================================================================
# ** Scene_Status
#------------------------------------------------------------------------------
#  This class performs status screen processing.
#==============================================================================

class Scene_Status
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_index : actor index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_party.actors[@actor_index]
    # Make status window
    @status_window = Window_Status.new(@actor)
    @status_window_top = Window_StatusTop.new(@actor)
    if SHOWBIO == true
    @status_window_bio = Window_StatusBio.new(@actor)
    end
    @status_window_bottom = Window_StatusBottom.new(@actor)
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @status_window.dispose
    @status_window_top.dispose
    if SHOWBIO == true 
    @status_window_bio.dispose
    end
    @status_window_bottom.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(3)
      return
    end
    # If R button was pressed
    if Input.trigger?(Input::R)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next actor
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Switch to different status screen
      $scene = Scene_Status.new(@actor_index)
      return
    end
    # If L button was pressed
    if Input.trigger?(Input::L)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To previous actor
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # Switch to different status screen
      $scene = Scene_Status.new(@actor_index)
      return
    end
  end
end