# * Reload (load screen improvement) by mewsterus
# * To install, just insert this in a descriptive code slot right above Main
#===============================================================================
# ¦ Window_Load
#-------------------------------------------------------------------------------
#   Edited by mewsterus
#===============================================================================

class Window_Load < Window_Base
  attr_reader   :filename
  attr_reader   :selected
  #-----------------------------------------------------------------------------
  # @ Make the window
  #-----------------------------------------------------------------------------
  def initialize(file_index)
    super(0, 64 + file_index % 4 * 104, 640, 104)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    self.contents_opacity = 155
    self.back_opacity = 160
    @file_index = file_index
    @filename = "Save#{@file_index + 1}.rxdata"
    @selected = false
    refresh
    update
  end
  #-----------------------------------------------------------------------------
  # @ Refresh the window
  #-----------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @time_stamp = Time.at(0)
    @file_exist = FileTest.exist?(@filename)
    if @file_exist
      file = File.open(@filename, "r")
      @time_stamp = file.mtime
      @characters          = Marshal.load(file)
      @frame_count         = Marshal.load(file)
      @game_system         = Marshal.load(file)
      @game_switches       = Marshal.load(file)
      @game_variables      = Marshal.load(file)
      @game_self_switches  = Marshal.load(file)
      @game_screen         = Marshal.load(file)
      @game_actors         = Marshal.load(file)
      @game_party          = Marshal.load(file)
      @game_troop          = Marshal.load(file)
      @game_map            = Marshal.load(file)
      @game_player         = Marshal.load(file)
      @total_sec           = @frame_count / Graphics.frame_rate
      file.close
      self.windowskin = RPG::Cache.windowskin(@game_system.windowskin_name)
      for i in 0...@characters.size
        if $face_enabled
          bitmap = RPG::Cache.picture(@characters[i][0])
          cw = 80
          ch = 80
        else
          bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
          cw = bitmap.rect.width / 4
          ch = bitmap.rect.height / 4
        end
        src_rect = Rect.new(0, 0, cw, ch)
        x = 608 + (i - @characters.size) * 84
        self.contents.blt(x, 80 - ch, bitmap, src_rect)
      end
      hour = @total_sec / 60 / 60
      min = @total_sec / 60 % 60
      sec = @total_sec % 60
      text = sprintf("%02d:%02d:%02d", hour, min, sec)
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 8, 256, 32, text, 2)
      time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
      self.contents.draw_text(4, 40, 256, 32, time_string, 2)
      if $location_enabled
        name = @game_map.name.delete("*").to_s
      else
        name = @game_party.actors[0].name
      end
    else
      self.windowskin = RPG::Cache.windowskin($game_system.windowskin_name)
      name = "[Empty]"
    end
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 8, 600, 32, name)
  end
  #-----------------------------------------------------------------------------
  # @ Update the window
  #-----------------------------------------------------------------------------
  def update
    super
    if @selected
      if self.contents_opacity < 255
        self.contents_opacity += 10
      end
    else
      if self.contents_opacity > 155
        self.contents_opacity -= 10
      end
    end
  end
  #-----------------------------------------------------------------------------
  # @ Accept whether window is selected
  #-----------------------------------------------------------------------------
  def selected=(selected)
    @selected = selected
    update
  end
end

#===============================================================================
# ¦ Window_LoadCommand
#-------------------------------------------------------------------------------
#   Written by mewsterus
#===============================================================================

class Window_LoadCommand < Window_Selectable
  #-----------------------------------------------------------------------------
  # @ Make the window
  #-----------------------------------------------------------------------------
  def initialize
    super(-640, 0, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = 24
    self.back_opacity = 160
    self.index = 0
    @commands = ["New Game", "Delete"]
    @item_max = 2
    @column_max = 2
    draw_item(0)
    draw_item(1)
  end
  #-----------------------------------------------------------------------------
  # @ Draw item
  #-----------------------------------------------------------------------------
  def draw_item(index)
    self.contents.font.color = system_color
    rect = Rect.new(164 + index * 160, 0, 118, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], 1)
  end
  #-----------------------------------------------------------------------------
  # @ Update the window
  #-----------------------------------------------------------------------------
  def update
    if Input.repeat?(Input::DOWN) or Input.repeat?(Input::UP)
      return
    end
    if Input.repeat?(Input::RIGHT)
      if @index < @item_max - 1
        $game_system.se_play($data_system.cursor_se)
        @index += 1
      end
    end
    if Input.repeat?(Input::LEFT)
      if @index > 0
        $game_system.se_play($data_system.cursor_se)
        @index -= 1
      end
    end
    super
  end
  #-----------------------------------------------------------------------------
  # @ Update the cursor
  #-----------------------------------------------------------------------------
  def update_cursor_rect
    if self.active
      self.cursor_rect.set(160 + @index * 160, 0, 128, 32)
    else
      self.cursor_rect.empty
    end
  end
end

#===============================================================================
# ¦ Scene_Load
#-------------------------------------------------------------------------------
#   Edited by mewsterus
#===============================================================================

class Scene_Load
  #-----------------------------------------------------------------------------
  # @ Main loop
  #-----------------------------------------------------------------------------
  def main
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.title($data_system.title_name)
    @top_window = Window_LoadCommand.new
    @savefile_windows = []
    for i in 0..3
      @savefile_windows.push(Window_Load.new(i))
    end
    @savefile_windows[0].x = 640
    @savefile_windows[1].x = -640
    @savefile_windows[2].x = 640
    @savefile_windows[3].x = -640
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      if @savefile_windows[0].x > 0
        @savefile_windows[0].x -= 64
      end
      if @savefile_windows[1].x < 0
        @savefile_windows[1].x += 64
      end
      if @savefile_windows[2].x > 0
        @savefile_windows[2].x -= 64
      end
      if @savefile_windows[3].x < 0
        @savefile_windows[3].x += 64
      end
      if @top_window.x < 0
        @top_window.x += 64
      else
        update
      end
      if $scene != self
        break
      end
    end
    unless @scene_title
      @sprite.dispose
    end
    for i in 0..10
      @top_window.x += 64
      @savefile_windows[0].x -= 64
      @savefile_windows[1].x += 64
      @savefile_windows[2].x -= 64
      @savefile_windows[3].x += 64
      Graphics.update
    end
    Graphics.freeze
    @top_window.dispose
    for i in @savefile_windows
      i.dispose
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the screen
  #-----------------------------------------------------------------------------
  def update
    unless @delete
      @top_window.update
    end
    for i in @savefile_windows
      i.update
    end
    if @top_window.active
      update_top
      return
    end
    if @file_active
      update_file
      return
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the top window
  #-----------------------------------------------------------------------------
  def update_top
    if Input.trigger?(Input::C)
      case @top_window.index
      when 0
        command_new_game
        return
      when 1
        @delete = true
        $game_system.se_play($data_system.decision_se)
        @top_window.active = false
        @file_active = true
        @file_index = 0
        @savefile_windows[@file_index].selected = true
        return
      end
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Title.new
      @scene_title = true
      return
    end
    if Input.repeat?(Input::DOWN)
      $game_system.se_play($data_system.cursor_se)
      @top_window.active = false
      @file_active = true
      @file_index = 0
      @savefile_windows[@file_index].selected = true
      return
    end
    if Input.trigger?(Input::UP)
      $game_system.se_play($data_system.cursor_se)
      @top_window.active = false
      @file_active = true
      @file_index = 3
      @savefile_windows[@file_index].selected = true
      return
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the file windows
  #-----------------------------------------------------------------------------
  def update_file
    if Input.trigger?(Input::C)
      if @delete
        if FileTest.exist?("Save#{@file_index + 1}.rxdata")
          $game_system.se_play($data_system.decision_se)
          File.delete("Save#{@file_index + 1}.rxdata")
          @savefile_windows[@file_index].refresh
          @delete = false
          @savefile_windows[@file_index].selected = false
          @file_active = false
          @top_window.active = true
        else
          $game_system.se_play($data_system.buzzer_se)
        end
        return
      end
      on_decision("Save#{@file_index + 1}.rxdata")
      return
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      if @delete
        @delete = false
        @savefile_windows[@file_index].selected = false
        @file_active = false
        @top_window.active = true
        return
      end
      $scene = Scene_Title.new
      @scene_title = true
      return
    end
    if Input.repeat?(Input::DOWN)
      unless @file_index < 3 or @delete
        if Input.trigger?(Input::DOWN)
          $game_system.se_play($data_system.cursor_se)
          @savefile_windows[@file_index].selected = false
          @file_active = false
          @top_window.active = true
          return
        end
      end
      if Input.trigger?(Input::DOWN) or @file_index < 3
        $game_system.se_play($data_system.cursor_se)
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 1) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
    if Input.repeat?(Input::UP)
      unless @file_index > 0 or @delete
        $game_system.se_play($data_system.cursor_se)
        @savefile_windows[@file_index].selected = false
        @file_active = false
        @top_window.active = true
        return
      end
      if Input.trigger?(Input::UP) or @file_index > 0
        $game_system.se_play($data_system.cursor_se)
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 3) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
  end
  #-----------------------------------------------------------------------------
  # @ Decision command
  #-----------------------------------------------------------------------------
  def on_decision(filename)
    unless FileTest.exist?(filename)
      command_new_game
      return
    end
    $game_system.se_play($data_system.load_se)
    $game_temp          = Game_Temp.new
    file = File.open(filename, "rb")
    characters = Marshal.load(file)
    Graphics.frame_count = Marshal.load(file)
    $game_system        = Marshal.load(file)
    $game_switches      = Marshal.load(file)
    $game_variables     = Marshal.load(file)
    $game_self_switches = Marshal.load(file)
    $game_screen        = Marshal.load(file)
    $game_actors        = Marshal.load(file)
    $game_party         = Marshal.load(file)
    $game_troop         = Marshal.load(file)
    $game_map           = Marshal.load(file)
    $game_player        = Marshal.load(file)
    if $game_system.magic_number != $data_system.magic_number
      $game_map.setup($game_map.map_id)
      $game_player.center($game_player.x, $game_player.y)
    end
    $game_party.refresh
    file.close
    $game_system.bgm_play($game_system.playing_bgm)
    $game_system.bgs_play($game_system.playing_bgs)
    $game_map.update
    $scene = Scene_Map.new
    @scene_title = false
  end
  #--------------------------------------------------------------------------
  # @ Generate new game
  #--------------------------------------------------------------------------
  def command_new_game
    $game_system.se_play($data_system.decision_se)
    Audio.bgm_stop
    Graphics.frame_count = 0
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
    $game_party.setup_starting_members
    $game_map.setup($data_system.start_map_id)
    $game_player.moveto($data_system.start_x, $data_system.start_y)
    $game_player.refresh
    $game_map.autoplay
    $game_map.update
    $scene = Scene_Map.new
    @scene_title = false
  end
end

    Source: geocities.com/mewsterus/scripts

               ( geocities.com/mewsterus)