O TEMA DO FÓRUM ESTÁ EM MANUTENÇÃO. FEEDBACKS AQUI: ACESSAR

ERRO linha 35 Window_Base [XP]

Iniciado por Meezy, 16/04/2017 às 20:29

16/04/2017 às 20:29 Última edição: 17/04/2017 às 00:14 por Meezy
Salve rapaziada,
Adicionei recentemente um novo Menu customizado (Ergo Proxy Menu) ao meu projeto e me deparei com um erro na linha 35 do Window_Base.
Alguém tem alguma ideia do que possa ser?

Screen do Erro:


Script Ergo Proxy Menu utilizado:
#==============================================================================
# Ergo Proxy Menu
# Criado por Atoa
#==============================================================================

module EPM_Config
  Menu_Back_Img = "MenuBackground"
  Menu_Main_Bar = "MenuBar"
  Menu_Help_Bar = "MenuHelpBar"
  Menu_Equip_Bar = "MenuEquiBar"
  Menu_Equip_Img = "MenuEquip"
  Menu_Item_Img = "MenuItem"
  Menu_Skill_Img = "MenuSkill"
  Menu_End_Img = "MenuEnd"
  Menu_Face_Img = "_statusface"
  Menu_Graph_Img = "_graphic"
  Menu_Status_IMG = "MenuStatus"
  Menu_Map_Graph = "_map"
  Opção_Inv1 = "MenuInv"
  Opção_Inv2 = "MenuInvg"
  Opção_Hab1 = "MenuHab"
  Opção_Hab2 = "MenuHabg"
  Opção_Aju1 = "MenuAju"
  Opção_Aju2 = "MenuAjug"
  Opção_Sair1 = "Sair"
  Opção_Sair2 = "Sairg"
  Inventario1 = "MenuItens_off"
  Inventario2 = "MenuItens_on"
  Equipamento1 = "MenuEquip_off"
  Equipamento2 = "MenuEquip_on"
  Evidencias1 = "MenuEvid_off"
  Evidencias2 = "MenuEvid_on"
end

#============================================================================== 
# Game_Actor
#============================================================================== 
class Game_Actor < Game_Battler
  def equip(equip_type, id)
    case equip_type
    when 0
      if id == 0 or $game_party.weapon_number(id) > 0
        $game_party.gain_weapon(@weapon_id, 1)
        @weapon_id = id
        $game_party.lose_weapon(id, 1)
      end
    when 1
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor3_id], $data_armors[id])
        $game_party.gain_armor(@armor3_id, 1)
        @armor3_id = id
        $game_party.lose_armor(id, 1)
      end
    end
  end
end

#============================================================================== 
# Game_Map
#============================================================================== 
class Game_Map
  #--------------------------------------------------------------------------
  def name
    $map_infos[@map_id]
  end
end

#============================================================================== 
# Window_Title
#============================================================================== 
class Scene_Title
  $map_infos = load_data("Data/MapInfos.rxdata")
  for key in $map_infos.keys
    $map_infos[key] = $map_infos[key].name
  end
end

#==============================================================================
# Window_Base
#==============================================================================
class Window_Base < Window
  #--------------------------------------------------------------------------
  include EPM_Config
  #--------------------------------------------------------------------------
  def draw_actor_hp(actor, x, y, width = 144)
    self.contents.font.color = Color.new(0,215,255)
    self.contents.draw_text(x, y, 128, 32, $data_system.words.hp)
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      hp_x = x + width - 48
      flag = false
    end
    self.contents.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.contents.draw_text(hp_x - 48, y, 96, 32, actor.hp.to_s, 2)
    if flag
      self.contents.font.color = Color.new(0,215,255)
      self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
      self.contents.font.color = normal_color
      self.contents.draw_text(hp_x + 60, y, 96, 32, actor.maxhp.to_s)
    end
  end  
  #--------------------------------------------------------------------------
  def draw_actor_sp(actor, x, y, width = 144)
    self.contents.font.color = Color.new(0,215,255)
    self.contents.draw_text(x, y, 128, 32, $data_system.words.sp)
    sp_x = x + width - 108
    flag = true
    self.contents.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
    self.contents.draw_text(sp_x, y, 96, 32, actor.sp.to_s + "%", 2)
  end
  #--------------------------------------------------------------------------
  def draw_item_name(item, x, y)
    if item == nil
      return
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = Color.new(0,215,255)
    self.contents.draw_text(x + 28, y, 256, 32, item.name)
  end
end

#==============================================================================
# Window_Help
#==============================================================================
class Window_Help < Window_Base
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 671, 73)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
  end
  #--------------------------------------------------------------------------
  def set_text(text, align = 0)
    if text != @text or align != @align
      self.contents.clear
      bitmap = RPG::Cache.windowskin(Menu_Help_Bar)
      cw = bitmap.width
      ch = bitmap.height
      src_rect = Rect.new(0, 0, cw, ch)
      self.contents.blt(0, 0, bitmap, src_rect)
      self.contents.font.name = "Geo Sans"
      self.contents.font.size = 22
      self.contents.font.color = Color.new(0,215,255)
      self.contents.draw_text(180, 4, self.width - 226, 32, text, align)
      @text = text
      @align = align
      @actor = nil
    end
    self.visible = true
  end
end

#==============================================================================
# Window_Back
#==============================================================================
class Window_Back < Window_Base
  def initialize
    super(0,0, 640, 480)
    self.opacity = 0
    self.contents = Bitmap.new(width - 32, height - 32)
    bitmap = RPG::Cache.windowskin(Menu_Skill_Img) if $scene.is_a?(Scene_Skill)
    bitmap = RPG::Cache.windowskin(Menu_Item_Img) if $scene.is_a?(Scene_Item)
    bitmap = RPG::Cache.windowskin(Menu_Equip_Img) if $scene.is_a?(Scene_Equip)
    bitmap = RPG::Cache.windowskin(Menu_End_Img) if $scene.is_a?(Scene_End)
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(0, 0, bitmap, src_rect, 192)
  end
end

#==============================================================================
# Window_Item
#==============================================================================
class Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize(type = 0)
    super(0, 128, 472, 320)
    @column_max = 1
    self.opacity = 0
    @type = type
    refresh
    self.index = 0
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  end
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i]) if @type == 0 and $data_items[i].price > 0
        @data.push($data_items[i]) if @type == 1 and $data_items[i].price == 0
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = "Geo Sans"
      self.contents.font.size = 22
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    self.contents.font.color = Color.new(0,215,255)
    x = 48
    y = index * 32
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.draw_text(x + 28, y, 232, 32, item.name)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
   def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
      return
    end
    row = @index / @column_max
    if row < self.top_row
      self.top_row = row
    end
    if row > self.top_row + (self.page_row_max - 1)
      self.top_row = row - (self.page_row_max - 1)
    end
    cursor_width = 224
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 32 - self.oy
    self.cursor_rect.set(x + 44, y, cursor_width, 32)
  end
end

#==============================================================================
# Window_Skill
#==============================================================================
class Window_Skill < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0,192, 472, 288)
    @actor = actor
    @column_max = 1
    self.opacity = 0
    refresh
    self.index = 0
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  end
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.skills.size
      skill = $data_skills[@actor.skills[i]]
      if skill != nil
        @data.push(skill)
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = "Geo Sans"
      self.contents.font.size = 22
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    if @actor.skill_can_use?(skill.id)
      self.contents.font.color = Color.new(0,215,255)
    else
      self.contents.font.color = Color.new(0,165,205)
    end
    x = 48
    y = index * 32
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == Color.new(0,215,255) ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
    self.contents.draw_text(x + 192, y, 96, 32, skill.sp_cost.to_s + "%", 2)
  end
  #--------------------------------------------------------------------------
   def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
      return
    end
    row = @index / @column_max
    if row < self.top_row
      self.top_row = row
    end
    if row > self.top_row + (self.page_row_max - 1)
      self.top_row = row - (self.page_row_max - 1)
    end
    cursor_width = 224
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 32 - self.oy
    self.cursor_rect.set(x + 44, y, cursor_width, 32)
  end
end

#==============================================================================
# Window_SkillStatus
#==============================================================================
class Window_SkillStatus < Window_Base
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 118, 671, 73)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    self.contents.font.name = "Geo Sans"
    self.contents.font.size = 22
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    bitmap = RPG::Cache.windowskin(Menu_Help_Bar)
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(0, 0, bitmap, src_rect)
    draw_actor_hp(@actor, 222, 6, 172)
    draw_actor_sp(@actor, 418, 6, 172)
  end
end

#==============================================================================
# Window_EquipRight
#==============================================================================
class Window_EquipRight < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 524, 174)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    @actor = actor
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.name = "Geo Sans"
    self.contents.font.size = 22
    bitmap = RPG::Cache.windowskin(Menu_Equip_Bar)
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(0, 0, bitmap, src_rect, 176)
    @data = []
    @data.push($data_weapons[@actor.weapon_id])
    @data.push($data_armors[@actor.armor3_id])
    @item_max = @data.size
    self.contents.font.color = normal_color
    self.contents.draw_text(56 + 4,8 + 32 * 1, 92, 32, $data_system.words.weapon)
    self.contents.draw_text(40 + 4,8 + 32 * 2, 92, 32, $data_system.words.armor3)
    draw_item_name(@data[0],56 + 76,8 + 32 * 1)
    draw_item_name(@data[1],40 + 76,8 + 32 * 2)
  end
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
      return
    end
    row = @index / @column_max
    if row < self.top_row
      self.top_row = row
    end
    if row > self.top_row + (self.page_row_max - 1)
      self.top_row = row - (self.page_row_max - 1)
    end
    cursor_width = 256
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 32 - self.oy
    self.cursor_rect.set(x + 128 - (@index * 16), y + 40, cursor_width, 32)
  end
end

#==============================================================================
# Window_EquipItem
#==============================================================================
class Window_EquipItem < Window_Selectable
  #--------------------------------------------------------------------------
  attr_accessor :data
  #--------------------------------------------------------------------------
  def initialize(actor, equip_type)
    super(0, 224, 432, 256)
    self.opacity = 0
    @actor = actor
    @equip_type = equip_type
    @column_max = 1
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    if @equip_type == 0
      weapon_set = $data_classes[@actor.class_id].weapon_set
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
          @data.push($data_weapons[i])
        end
      end
    end
    if @equip_type != 0
      armor_set = $data_classes[@actor.class_id].armor_set
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0 and armor_set.include?(i)
          if $data_armors[i].kind == @equip_type-1
            @data.push($data_armors[i])
          end
        end
      end
    end
    @item_max = @data.size
    row = @data.size > 0 ? row_max * 32 : 32
    self.contents = Bitmap.new(width - 32, row)
    self.contents.font.name = "Geo Sans"
    self.contents.font.size = 22
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  def data
    return @data == nil ? @data = [] : @data
  end
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    x = 48
    y = index * 32
    case item
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = Color.new(0,215,255)
    self.contents.draw_text(x + 28, y, 272, 32, item.name, 0)
  end
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
      return
    end
    row = @index / @column_max
    if row < self.top_row
      self.top_row = row
    end
    if row > self.top_row + (self.page_row_max - 1)
      self.top_row = row - (self.page_row_max - 1)
    end
    cursor_width = 244
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 32 - self.oy
    self.cursor_rect.set(x + 44 , y, cursor_width, 32)
  end
end

#==============================================================================
# Window_Command_End 
#==============================================================================
class Window_Command_End < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize(width, commands)
    super(0, 0, width, commands.size * 32 + 32)
    @item_max = commands.size
    @commands = commands
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    self.contents.font.name = "Geo Sans"
    self.contents.font.size = 22
    self.opacity = 0
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, Color.new(0,215,255))
    end
  end
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
    self.contents.draw_text(rect, @commands[index])
  end
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
      return
    end
    row = @index / @column_max
    if row < self.top_row
      self.top_row = row
    end
    if row > self.top_row + (self.page_row_max - 1)
      self.top_row = row - (self.page_row_max - 1)
    end
    cursor_width = 192
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 32 - self.oy
    self.cursor_rect.set(x - 2, y, cursor_width, 28)
  end
end

#==============================================================================
# Window_Face_Display
#==============================================================================
class Window_Face_Display < Window_Base
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 486, 166)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Geo Sans"
    self.contents.font.size = 22
    self.opacity = 0
    refresh
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    actor = $game_party.actors[0]
    bitmap = RPG::Cache.windowskin(actor.name + Menu_Face_Img)
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(0, 0, bitmap, src_rect)
    self.contents.font.color = Color.new(0,215,255)
#    self.contents.draw_text(192, 52, 200, 32, actor.name)
  end
end

#==============================================================================
# Window_EP_Status
#==============================================================================
class Window_EP_Status < Window_Base
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 460, 320)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Geo Sans"
    self.contents.font.size = 22
    self.opacity = 0
    refresh
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @actor = $game_party.actors[0]
    bitmap = RPG::Cache.windowskin(Menu_Status_IMG)
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(0, 0, bitmap, src_rect, 232)
    draw_actor_hp(@actor, 112,16, 172)
    draw_actor_sp(@actor, 98, 48, 172)
    draw_actor_state(@actor, 84, 80)
    self.contents.font.color = Color.new(0,215,255)
    draw_item_name($data_weapons[@actor.weapon_id], 70, 112)
    draw_item_name($data_armors[@actor.armor3_id], 56, 144)
  end
end

#==============================================================================
# Scene_Equip
#==============================================================================
class Scene_Equip
  #--------------------------------------------------------------------------
  def initialize(ep_comand_objects = nil, ep_inventory_objects = nil, inv_index = 0)
    @ep_comand_objects, @ep_inventory_objects, @inv_index = ep_comand_objects, ep_inventory_objects, inv_index
    @actor_index = @equip_index = 0
  end
  #--------------------------------------------------------------------------
  def main
    @actor = $game_party.actors[0]
    @help_window = Window_Help.new
    @help_window.x, @help_window.y = -698,64
    @item_window_back = Window_Back.new
    @item_window_back.y = 482
    @right_window = Window_EquipRight.new(@actor)
    @right_window.x, @right_window.y = - 540 ,78
    @item_window1 = Window_EquipItem.new(@actor, 0)
    @item_window2 = Window_EquipItem.new(@actor, 3)
    @right_window.help_window = @help_window
    @item_window1.help_window = @help_window
    @item_window2.help_window = @help_window
    @right_window.index = @equip_index
    @equip_menu_start = true
    refresh
    @item_window1.y = @item_window2.y = 502
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self and @equip_menu_end == false
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @right_window.dispose
    @item_window1.dispose
    @item_window2.dispose
  end
  #--------------------------------------------------------------------------
  def refresh
    @item_window1.visible = (@right_window.index == 0)
    @item_window2.visible = (@right_window.index == 1)
    case @right_window.index
    when 0
      @item_window = @item_window1
    when 1
      @item_window = @item_window2
    end
  end
  #--------------------------------------------------------------------------
  def update
    refresh
    return start_equip_window if @equip_menu_start
    return end_equip_window if @equip_menu_end
    @right_window.update
    @item_window.update
    if @right_window.active
      update_right
      return
    end
    if @item_window.active
      update_item
      return
    end
  end
  #--------------------------------------------------------------------------
  def start_equip_window
    @item_window_back.y -= 48 if @item_window_back.y > 224
    @item_window1.y -= 48 if @item_window1.y > 224
    @item_window2.y -= 48 if @item_window2.y > 224
    @right_window.x += 58 if @right_window.x < -32
    @help_window.x += 64 if @help_window.x < -192
    @equip_menu_start = false if @help_window.x >= -192 and @right_window.x >= -32 and
                                 @item_window1.y <= 224 and @item_window2.y <= 224
  end
  #--------------------------------------------------------------------------
  def end_equip_window
    @item_window_back.y += 48 if @item_window_back.y < 482
    @item_window1.y += 48 if @item_window1.y < 502
    @item_window2.y += 48 if @item_window2.y < 502
    @right_window.x -= 58 if @right_window.x > -540
    @help_window.x -= 64 if @help_window.x > -640
    @equip_menu_end = false if @help_window.x <= -640 and @right_window.x <= -540 and
                               @item_window1.y >= 502 and @item_window2.y >= 502
  end
  #--------------------------------------------------------------------------
  def update_right
    if Input.trigger?(Input::B) or Input.trigger?(Input::A)
      @equip_menu_end = true
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(0, @ep_comand_objects, @ep_inventory_objects, false,
                              false, false,@inv_index, true, true, false)
      return
    end
    if Input.trigger?(Input::C)
      if @actor.equip_fix?(@right_window.index) or @item_window.data.size == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      @right_window.active = false
      @item_window.active = true
      @item_window.index = 0
      return
    end
  end
end

#==============================================================================
# Scene_Item
#==============================================================================
class Scene_Item
  #--------------------------------------------------------------------------
  def initialize(ep_comand_objects = nil, ep_inventory_objects = nil, inv_index = 0, item_type = 0)
    @ep_comand_objects, @ep_inventory_objects, @inv_index, @item_type = ep_comand_objects, 
    ep_inventory_objects, inv_index, item_type 
  end
  #--------------------------------------------------------------------------  
  def main
    @help_window = Window_Help.new
    @help_window.x, @help_window.y = -698,64
    @item_window_back = Window_Back.new
    @item_window_back.y = 502
    @item_window = Window_Item.new(@item_type)
    @item_window.y = 478
    @item_window.help_window = @help_window
    @target_window = Window_Target.new
    @target_window.visible = false
    @target_window.active = false
    @item_menu_start = true
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self and @item_menu_end == false
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @item_window.dispose
    @target_window.dispose
  end
  #--------------------------------------------------------------------------
  def update
    @target_window.active = false
    return start_item_window if @item_menu_start
    return end_item_window if @item_menu_end
    @help_window.update
    @item_window.update
    @target_window.update
    if @item_window.active
      update_item
      return
    end
  end
  #--------------------------------------------------------------------------
  def start_item_window
    @item_window_back.y -= 48 if @item_window_back.y > 160
    @item_window.y -= 48 if @item_window.y > 172
    @help_window.x += 64 if @help_window.x < -192
    @item_menu_start = false if @item_window.y <= 172 and @help_window.x >= -192
  end
  #--------------------------------------------------------------------------
  def end_item_window
    @item_window_back.y += 48 if @item_window_back.y < 502
    @item_window.y += 48 if @item_window.y < 498
    @help_window.x -= 64 if @help_window.x > -640
    @item_menu_end = false if @item_window.y >= 498 and @help_window.x <= -640
  end
  #--------------------------------------------------------------------------
  alias kahh_ep_menu_update_item update_item
  def update_item
    if Input.trigger?(Input::B) or Input.trigger?(Input::A)
      @item_menu_end = true
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(0, @ep_comand_objects, @ep_inventory_objects, false,
                              false, false,@inv_index, true, true, false)
      return
    end
  end
end

#==============================================================================
# Scene_Skill
#==============================================================================
class Scene_Skill
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0, ep_comand_objects = nil)
    @actor_index = actor_index
    @ep_comand_objects = ep_comand_objects
  end
  #--------------------------------------------------------------------------
  def main
    @actor = $game_party.actors[@actor_index]
    @help_window = Window_Help.new
    @help_window.x, @help_window.y = -698,64
    @status_window = Window_SkillStatus.new(@actor)
    @status_window.x = -698
    @skill_window_back = Window_Back.new
    @skill_window_back.y = 498
    @skill_window = Window_Skill.new(@actor)
    @skill_window.y = 516
    @skill_window.help_window = @help_window
    @target_window = Window_Target.new
    @target_window.visible = false
    @target_window.active = false
    @skill_menu_start = true
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self and @skill_menu_end == false
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @status_window.dispose
    @skill_window.dispose
    @skill_window_back.dispose
    @target_window.dispose
  end
  #--------------------------------------------------------------------------
  def update
    return start_skill_window if @skill_menu_start
    return end_skill_window if @skill_menu_end
    @help_window.update
    @status_window.update
    @skill_window.update
    @target_window.update
    if @skill_window.active
      update_skill
      return
    end
  end
  #--------------------------------------------------------------------------
  def start_skill_window
    @skill_window.y -= 48 if @skill_window.y > 184
    @skill_window_back.y -= 48 if @skill_window_back.y > 184
    @help_window.x += 64 if @help_window.x < -192
    @status_window.x += 64 if @status_window.x < -192
    @skill_menu_start = false if @skill_window.y <= 184 and @help_window.x >= -192
  end
  #--------------------------------------------------------------------------
  def end_skill_window
    @skill_window.y += 48 if @skill_window.y < 516
    @skill_window_back.y += 48 if @skill_window_back.y < 516
    @help_window.x -= 64 if @help_window.x > -698
    @status_window.x -= 64 if @status_window.x > -698
    @skill_menu_end = false if @skill_window.y >= 516 and @help_window.x <= -698
  end
  #--------------------------------------------------------------------------
  def update_skill
    if Input.trigger?(Input::B) or Input.trigger?(Input::A)
      @skill_menu_end = true
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(1, @ep_comand_objects)
      return
    end
  end
end

#==============================================================================
# Scene_End
#==============================================================================
class Scene_End
  #--------------------------------------------------------------------------
  def initialize(ep_comand_objects = nil)
    @ep_comand_objects = ep_comand_objects
  end
  #--------------------------------------------------------------------------
  def main
    s1 = "Ir à Tela de Título"
    s2 = "Sair do Jogo"
    s3 = "Voltar"
    @command_window = Window_Command_End.new(256, [s1, s2, s3])
    @command_window.x, @command_window.y = 204,496
    @end_window_back = Window_Back.new
    @end_window_back.x, @end_window_back.y = 166,480
    @end_menu_start = true
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self and @end_menu_end == false
        break
      end
    end
    Graphics.freeze
    @command_window.dispose
    @end_window_back.dispose
    @ep_comand_objects.each {|x| x.dispose} if $scene == nil
    if $scene.is_a?(Scene_Title)
      @ep_comand_objects.each {|x| x.dispose}
      Graphics.transition
      Graphics.freeze
    end
  end
  #--------------------------------------------------------------------------
  alias kahh_ep_menu_update update
  def update
    return start_end_window if @end_menu_start
    return end_end_window if @end_menu_end
    if Input.trigger?(Input::B) or Input.trigger?(Input::A)
      @end_menu_end = true
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(3, @ep_comand_objects)
      return
    end
    kahh_ep_menu_update
  end
  #--------------------------------------------------------------------------
  def start_end_window
    @command_window.y -= 48 if @command_window.y > 184
    @end_window_back.y -= 48 if @end_window_back.y > 184
    @end_menu_start = false if @command_window.y <= 184 and @end_window_back.y <= 184
  end
  #--------------------------------------------------------------------------
  def end_end_window
    @command_window.y += 48 if @command_window.y < 496
    @end_window_back.y += 48 if @end_window_back.y < 480
    @end_menu_end = false if @command_window.y >= 496 and @end_window_back.y >= 480
  end
  #--------------------------------------------------------------------------
  def command_to_title
    @end_menu_end = false
    $game_system.se_play($data_system.decision_se)
    Audio.bgm_fade(800)
    Audio.bgs_fade(800)
    Audio.me_fade(800)
    $scene = Scene_Title.new
  end
  #--------------------------------------------------------------------------
  def command_shutdown
    @end_menu_end = false
    $game_system.se_play($data_system.decision_se)
    Audio.bgm_fade(800)
    Audio.bgs_fade(800)
    Audio.me_fade(800)
    $scene = nil
  end
  #--------------------------------------------------------------------------
  def command_cancel
    @end_menu_end = true
    $game_system.se_play($data_system.decision_se)
    $scene = Scene_Menu.new(3, @ep_comand_objects)
  end
end

#==============================================================================
# Scene_Menu
#==============================================================================
class Scene_Menu
  #--------------------------------------------------------------------------
  include EPM_Config
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0,ep_comand_objects = nil, ep_inventory_objects = nil,  
    main_menu_active = true, menu_start = true, menu_end = false, inv_index = 0,
    inv_menu_active = false, inv_menu_start = false, inv_menu_end = false)
    @menu_index, @ep_comand_objects, @ep_inventory_objects, @main_menu_active,
    @menu_start, @menu_end, @inv_index, @inv_menu_active, @inv_menu_start, @inv_menu_end =
    menu_index, ep_comand_objects, ep_inventory_objects, main_menu_active,
    menu_start, menu_end, inv_index, inv_menu_active, inv_menu_start, inv_menu_end
  end
  #--------------------------------------------------------------------------
  def main
    $game_system.windowskin_name = "MenuWS"
    @actor = $game_party.actors[0]
    if @ep_comand_objects == nil
      ep_back_image = Sprite.new
      ep_back_image.bitmap = RPG::Cache.windowskin(Menu_Back_Img)
      ep_back_image.z = 0
      ep_command_image = Sprite.new
      ep_command_image.bitmap = RPG::Cache.windowskin(Menu_Main_Bar)
      ep_command_image.x, ep_command_image.y = 648, 12,
      ep_command_inv = Sprite.new
      ep_command_inv.bitmap = RPG::Cache.windowskin(Opção_Inv1)
      ep_command_inv.x, ep_command_inv.y = 664, 0
      ep_command_hab = Sprite.new
      ep_command_hab.bitmap = RPG::Cache.windowskin(Opção_Hab1)
      ep_command_hab.x, ep_command_hab.y = 792, 0
      ep_command_aju = Sprite.new
      ep_command_aju.bitmap = RPG::Cache.windowskin(Opção_Aju1)
      ep_command_aju.x, ep_command_aju.y = 912, 0
      ep_command_sair = Sprite.new
      ep_command_sair.bitmap = RPG::Cache.windowskin(Opção_Sair1)
      ep_command_sair.x, ep_command_sair.y = 990, 0
      ep_graph_display = Sprite.new
      ep_graph_display.bitmap = RPG::Cache.windowskin(@actor.name + Menu_Graph_Img)
      ep_graph_display.x, ep_graph_display.y, ep_graph_display.z = 652, 12, 200
      ep_map_graphic = Sprite.new
      ep_map_graphic.bitmap = RPG::Cache.windowskin($game_map.name + Menu_Map_Graph)
      ep_map_graphic.x, ep_map_graphic.y, ep_map_graphic.z = 436, 504, 201
    end
    if @ep_main_menu_objects == nil
      ep_face_display = Window_Face_Display.new
      ep_face_display.x, ep_face_display.y = -494, 40
      ep_status_display = Window_EP_Status.new
      ep_status_display.x, ep_status_display.y = -16, 492
    end
    if @ep_inventary_objects == nil
      ep_inventory_itm = Sprite.new
      ep_inventory_itm.bitmap = RPG::Cache.windowskin(Inventario1)
      ep_inventory_itm.x, ep_inventory_itm.y = -494, 80
      ep_inventory_eqp = Sprite.new
      ep_inventory_eqp.bitmap = RPG::Cache.windowskin(Equipamento1)
      ep_inventory_eqp.x, ep_inventory_eqp.y = -494,174
      ep_inventory_evd = Sprite.new
      ep_inventory_evd.bitmap = RPG::Cache.windowskin(Evidencias1)
      ep_inventory_evd.x, ep_inventory_evd.y = -494,272
    end
    @ep_comand_objects = [ep_back_image, ep_command_image, ep_command_inv, ep_command_hab, 
      ep_command_aju, ep_command_sair, ep_graph_display, ep_map_graphic] if @ep_comand_objects == nil
    @ep_main_menu_objects = [ep_status_display, ep_face_display] if @ep_main_menu_objects == nil
    @ep_inventory_objects = [ep_inventory_itm, ep_inventory_eqp, ep_inventory_evd] if @ep_inventory_objects == nil
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self and @menu_end == false and @inv_menu_end == false
        break
      end
    end
    Graphics.freeze
    if $scene.is_a?(Scene_Map)
      @ep_comand_objects.each {|x| x.dispose}
      @ep_main_menu_objects.each {|x| x.dispose}
      @ep_inventory_objects.each {|x| x.dispose}
      $game_system.windowskin_name = $data_system.windowskin_name
    end
  end
  #--------------------------------------------------------------------------
  def update
    update_selected_comand
    update_inventory_comand
    return end_item_window if @inv_menu_end
    return start_main_windows if @menu_start
    return end_main_windows if @menu_end
    return start_item_window if @inv_menu_start     
    if @main_menu_active
      update_command
      return
    end
    if @inv_menu_active
      update_inventory
      return
    end
  end
  #--------------------------------------------------------------------------
  def update_selected_comand
    inv = @menu_index == 0 ? Opção_Inv2 : Opção_Inv1
    hab = @menu_index == 1 ? Opção_Hab2 : Opção_Hab1
    aju = @menu_index == 2 ? Opção_Aju2 : Opção_Aju1
    sair = @menu_index == 3 ? Opção_Sair2 : Opção_Sair1
    @ep_comand_objects[2].bitmap = RPG::Cache.windowskin(inv)
    @ep_comand_objects[3].bitmap = RPG::Cache.windowskin(hab)
    @ep_comand_objects[4].bitmap = RPG::Cache.windowskin(aju)
    @ep_comand_objects[5].bitmap = RPG::Cache.windowskin(sair)
  end
  #--------------------------------------------------------------------------
  def update_inventory_comand
    itm = @inv_index == 0 ? Inventario2 : Inventario1
    eqp = @inv_index == 1 ? Equipamento2 : Equipamento1
    evd = @inv_index == 2 ? Evidencias2 : Evidencias1
    @ep_inventory_objects[0].bitmap = RPG::Cache.windowskin(itm)
    @ep_inventory_objects[1].bitmap = RPG::Cache.windowskin(eqp)
    @ep_inventory_objects[2].bitmap = RPG::Cache.windowskin(evd)
  end
  #--------------------------------------------------------------------------
  def start_main_windows
    @ep_comand_objects[1].x -= 64 if @ep_comand_objects[1].x > 48
    @ep_comand_objects[2].x -= 64 if @ep_comand_objects[2].x > 64
    @ep_comand_objects[3].x -= 64 if @ep_comand_objects[3].x > 192
    @ep_comand_objects[4].x -= 64 if @ep_comand_objects[4].x > 312
    @ep_comand_objects[5].x -= 64 if @ep_comand_objects[5].x > 390
    @ep_comand_objects[6].x -= 36 if @ep_comand_objects[6].x > 412
    @ep_comand_objects[7].y -= 36 if @ep_comand_objects[7].y > 288
    @ep_main_menu_objects[0].y -= 36 if @ep_main_menu_objects[0].y > 192
    @ep_main_menu_objects[1].x += 56 if @ep_main_menu_objects[1].x < -32
    @menu_start = false if @ep_comand_objects[1].x <= 48 and @ep_main_menu_objects[0].y <= 192 and 
                           @ep_comand_objects[6].x <= 412 and @ep_main_menu_objects[1].x >= -32
  end
  #--------------------------------------------------------------------------
  def end_main_windows
    if $scene.is_a?(Scene_Map)
      @ep_comand_objects[1].x += 64 if @ep_comand_objects[1].x < 648
      @ep_comand_objects[2].x += 64 if @ep_comand_objects[2].x < 664
      @ep_comand_objects[3].x += 64 if @ep_comand_objects[3].x < 792
      @ep_comand_objects[4].x += 64 if @ep_comand_objects[4].x < 912
      @ep_comand_objects[5].x += 64 if @ep_comand_objects[5].x < 990
      @ep_comand_objects[6].x += 36 if @ep_comand_objects[6].x < 652
      @ep_comand_objects[7].y += 36 if @ep_comand_objects[7].y < 504
    end
    @ep_main_menu_objects[0].y += 36 if @ep_main_menu_objects[0].y < 492
    @ep_main_menu_objects[1].x -= 56 if @ep_main_menu_objects[1].x > -494
    if $scene.is_a?(Scene_Map)
      @menu_end = false if @ep_comand_objects[1].x >= 648 and @ep_main_menu_objects[0].y >= 492 and 
                           @ep_comand_objects[6].x >= 652 and @ep_main_menu_objects[1].x <= -494
    else
      @menu_end = false if @ep_main_menu_objects[0].y >= 480 and @ep_main_menu_objects[1].x <= -494
    end
  end
  #--------------------------------------------------------------------------
  def start_item_window 
    @ep_inventory_objects.each {|x| x.x += 56} if @ep_inventory_objects[0].x < -32
    @inv_menu_start= false if @ep_inventory_objects[0].x >= -32
  end
  #--------------------------------------------------------------------------
  def end_item_window 
    @ep_inventory_objects.each {|x| x.x -= 56} if @ep_inventory_objects[0].x > -494
    @inv_menu_end = false if @ep_inventory_objects[0].x <= -494
  end
  #--------------------------------------------------------------------------
  def update_command
    if Input.trigger?(Input::B) or Input.trigger?(Input::A)
      @menu_end = true
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::LEFT)
      @menu_index -= 1
      @menu_index = @menu_index < 0 ? 3 : @menu_index
      $game_system.se_play($data_system.cursor_se)
      return
    end
    if Input.trigger?(Input::RIGHT)
      @menu_index += 1
      @menu_index = @menu_index > 3 ? 0 : @menu_index
      $game_system.se_play($data_system.cursor_se)
      return
    end
    if Input.trigger?(Input::C)
      case @menu_index
      when 0
        @menu_end = @inv_menu_start = @inv_menu_active = true
        @main_menu_active = false 
        @inv_index = 0
        $game_system.se_play($data_system.decision_se)
      when 1
        @menu_end = true
        if $game_party.actors[0].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Skill.new(0,0,@ep_comand_objects)
      when 2
        @menu_end = true
        if $game_party.actors[0].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Help.new(0, @ep_comand_objects)
      when 3
        @menu_end = true
        if $game_party.actors[0].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_End.new(@ep_comand_objects)
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  def update_inventory
    if Input.trigger?(Input::B) or Input.trigger?(Input::A)
      @menu_start = @inv_menu_end = @main_menu_active = true
      @inv_menu_active = false 
      $game_system.se_play($data_system.cancel_se)
      return
    end
    if Input.trigger?(Input::UP)
      @inv_index -= 1
      @inv_index = @inv_index < 0 ? 2 : @inv_index
      $game_system.se_play($data_system.cursor_se)
      return
    end
    if Input.trigger?(Input::DOWN)
      @inv_index += 1
      @inv_index = @inv_index > 2 ? 0 : @inv_index
      $game_system.se_play($data_system.cursor_se)
      return
    end
    if Input.trigger?(Input::C)
      case @inv_index
      when 0
        @inv_menu_end = true
        if $game_party.actors[0].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Item.new(@ep_comand_objects, @ep_inventory_objects, @inv_index)
      when 1
        @inv_menu_end = true
        if $game_party.actors[0].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Equip.new(@ep_comand_objects, @ep_inventory_objects, @inv_index)
      when 2
        @inv_menu_end = true
        if $game_party.actors[0].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Item.new(@ep_comand_objects, @ep_inventory_objects, @inv_index, 1)
      end
    end
  end
end