################################################################################
#===============================================================================
# ~** Mission Manager V 0.1 **~
#-------------------------------------------------------------------------------
# Written by : Kain Nobel
# Version   : 0.1
# Last Update : 06/14/2008
# Created   : 06/11/2008
#===============================================================================
# ~**Advanced Text Reader **~
#-------------------------------------------------------------------------------
# Written by : Woratana
# Re-Coded specifically for the Mission Manager System.
#===============================================================================
################################################################################
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ~**         Text Reader Setup Constants              **~
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
################################################################################
class Text_Settings
 Active     = true
 Visible     = true
 Open      = 30
 Scroll_Speed  = 5
 Directory    = "Data/Texts/"
 Sub_Directory  = ""
 BG_Picture   = ""
 Opacity     = 160
 Width      = 614
 Height     = 448
 OX       = 16
 OY       = 16
 Auto_Scroll   = false
 Auto_Speed   = 1.5
 Auto_Skip    = true
 Auto_Close   = false
end
################################################################################
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~**Â Â Â Â Â Â Â Â Â Mission Setup Constants - BEGINÂ Â Â Â Â Â Â Â Â Â Â **~ #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
################################################################################
Mission_Title   = "~* [ M I S S I O N  M A N A G E R  V 0 . 1 ] *~"
Mission_FontName = "Georgia"
Mission_FontSize = 22
Mission_Italics  = false
#-------------------------------------------------------------------------------
# ** Main Mission Categories
#-------------------------------------------------------------------------------
Mission_Categories = {
 1  => "Mission I",
 2  => "Mission II",
 3  => "Mission III",
 4  => "Mission IV",
 5  => "Mission V",
 6  => "Mission VI",
 7  => "Mission VII",
 8  => "Mission VIII",
 9  => "Mission IX",
 10 => "Mission X",
 11 => "Mission XI",
 12 => "Mission XII",
 13 => "Mission XIII",
 14 => "Mission XIV",
 15 => "Mission XV",
 16 => "Mission XVI",
 17 => "Mission XVII",
 18 => "Mission XVIII",
 19 => "Mission XIX",
 20 => "Mission XX",
 21 => "Mission XXI",
 22 => "Mission XXII",
 23 => "Mission XXIII",
 24 => "Mission XXIV",
 25 => "Mission XXV",
 26 => "Mission XXVI",
 27 => "Mission XXVII",
 28 => "Mission XXVIII",
 29 => "Mission XXIX",
 30 => "Mission XXX",
 31 => "Mission XXXI",
 32 => "Mission XXXII",
 33 => "Mission XXXIII",
 34 => "Mission XXXIV",
 35 => "Mission XXXV",
 36 => "Mission XXXVI",
 37 => "Mission XXXVII",
 38 => "Mission XXXVIII",
 39 => "Mission XXXIX",
 40 => "Mission XXXX"
}
#-------------------------------------------------------------------------------
# ** Mission Selectables Â
#-------------------------------------------------------------------------------
Mission_Selectables = {
 # Category 1, Missions 1...5
 1  => "Spelunking in the Tunnels of Midgar",
 2  => "Pick up the Colonel's Dry Cleaning",
 3  => "Secret Meeting in the Alley",
 4  => "Pardon Me, but do you have any Grey Pupon?",
 5  => "The Rise of a New Breed of Chaos!"
 # Etc, etc, etc...
}
#-------------------------------------------------------------------------------
# ** Mission Objectives
#-------------------------------------------------------------------------------
Mission_Objectives = {
 # Category 1, Mission 1
 1  => [1, 1, "Obtain 3 orbs of power"],
 2  => [1, 1, "Talk to crackhead in tunnels"],
 3  => [1, 1, "Obtain 3 orbs of speed @_@"],
 4  => [1, 1, "Get back to HQ imediately!"],
 # Category 1, Mission 2
 1  => [1, 2, "Take the train to Sector 6"],
 2  => [1, 2, "Go through the park, to Wall Market"],
 3  => [1, 2, "Enter the Hot Press!"]
}
#-------------------------------------------------------------------------------
# ** Mission Rewards
#-------------------------------------------------------------------------------
Mission_Rewards = {
 1  => "Reward I",
 2  => "Reward II",
 3  => "Reward III",
 4  => "Reward IV"
}
#===============================================================================
################################################################################
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~**Â Â Â Â Â Â Â Â Â Â Mission Setup Constants - ENDÂ Â Â Â Â Â Â Â Â Â Â **~ #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
################################################################################
#===============================================================================
# ** Game_Mission
#-------------------------------------------------------------------------------
#Â Â This class performs generic commands used for the Mission system.
#===============================================================================
class Game_Mission
 # [Attributes]----------------------------------------------------------------
 attr_accessor  :categories
 attr_accessor  :missions
 attr_accessor  :briefing
 attr_accessor  :objectives
 attr_accessor  :rewards
 #-----------------------------------------------------------------------------
 # * Initialize Method
 #-----------------------------------------------------------------------------
 def initialize#(c = 1, m = 1, o = 1)
  @current_mission = nil
  @categories    = []
  @missions     = []
  @briefing     = []
  @objectives    = []
  @rewards     = []
 end
 #-----------------------------------------------------------------------------
 # * Define Categories
 #-----------------------------------------------------------------------------
 def categories
  return Mission_Categories
 end
 #-----------------------------------------------------------------------------
 # * Define Missions
 #-----------------------------------------------------------------------------
 def missions
  return Mission_Selectables
 end
 #-----------------------------------------------------------------------------
 # * Define Objectives
 #-----------------------------------------------------------------------------
 def objectives
  return Mission_Objectives
 end
 #-----------------------------------------------------------------------------
 # * Define Rewards
 #-----------------------------------------------------------------------------
 def rewards
  return Mission_Rewards
 end
 #-----------------------------------------------------------------------------
 # * Add Category
 #-----------------------------------------------------------------------------
 def category_add(n, boolean = true)
  unless n == nil
   @categories.push(n, boolean)
  end
 end
 #-----------------------------------------------------------------------------
 # * Delete Category
 #-----------------------------------------------------------------------------
 def category_delete(n)
  unless n == nil
   @categories.delete(n)
  end
 end
 #-----------------------------------------------------------------------------
 # * Lock Category
 #-----------------------------------------------------------------------------
 def category_lock(n)
  unless n == nil
   # Simply reuses category_add and sets boolean to false
   category_add(n, false)
  end
 end
 #-----------------------------------------------------------------------------
 # * Add Mission
 #-----------------------------------------------------------------------------
 def mission_add(n, boolean = true)
  unless n == nil
   @missions.push(n, boolean)
  end
 end
 #-----------------------------------------------------------------------------
 # * Delete Mission
 #-----------------------------------------------------------------------------
 def mission_delete(n)
  unless n == nil
   @missions.delete(n)
  end
 end
 #-----------------------------------------------------------------------------
 # * Lock Mission
 #-----------------------------------------------------------------------------
 def mission_lock(n)
  unless n == nil
   # Simply reuses mission_add and sets boolean to false
   mission_add(n, false)
  end
 end
 #-----------------------------------------------------------------------------
 # * Add Objective
 #-----------------------------------------------------------------------------
 def objective_add(n, boolean = true)
  unless n == nil
   @objectives.push(n, boolean)
  end
 end
 #-----------------------------------------------------------------------------
 # * Delete Objective
 #-----------------------------------------------------------------------------
 def objective_delete(n)
  unless n == nil
   @objectives.delete(n)
  end
 end
 #-----------------------------------------------------------------------------
 # * Lock Objective
 #-----------------------------------------------------------------------------
 def objective_lock(n)
  unless n == nil
   # Simply reuses objective_add and sets boolean to false
   objective_add(n, false)
  end
 end
 #-----------------------------------------------------------------------------
 # * Start Mission
 #-----------------------------------------------------------------------------
 def start_mission(category = 1, mission = 1)
  @current_mission.push(category, mission)
 end
 #-----------------------------------------------------------------------------
 # * Complete Mission
 #-----------------------------------------------------------------------------
 def complete_mission(category = 1, mission = 1, boolean = false)
  @current_mission.push(category, mission, boolean)
 end
 #-----------------------------------------------------------------------------
 # * Fail Mission
 #-----------------------------------------------------------------------------
 def mission_failed(category = 1, mission = 1)
  # Simply reuses Complete Mission and sets 'fail' boolean to true
  complete_mission(category, mission, true)
 end
 #-----------------------------------------------------------------------------
 # * Objective Complete
 #-----------------------------------------------------------------------------
 def complete_objective(n = 1, boolean = false)
  @current_mission.objective(n, boolean)
 end
 #-----------------------------------------------------------------------------
 # * Fail Objective
 #-----------------------------------------------------------------------------
 def fail_objective(n = 1)
  # Simply reuses Complete Objective and sets 'fail' boolean to true
  @current_mission.objective(n, true)
 end
end
################################################################################
#===============================================================================
# ** Window_MissionHeader
#===============================================================================
class Window_MissionHeader < Window_Base
 #-----------------------------------------------------------------------------
 # * Initialize Method
 #-----------------------------------------------------------------------------
 def initialize
  super(0, 0, 640, 64)
  self.contents = Bitmap.new(width - 32, height - 32)
  self.visible = true
  self.opacity = CMS_Opacity
  refresh
 end
 #-----------------------------------------------------------------------------
 # * Refresh Method
 #-----------------------------------------------------------------------------
 def refresh
  self.contents.clear
  self.contents.draw_text(-16, -10, 640, 48, Mission_Title, 1)
 end
end
################################################################################
#===============================================================================
# ** Window_MissionCategory
#-------------------------------------------------------------------------------
#Â Â This is the list of main mission categories, which will take you to the list
# of sub missions that fall into the respective category.
#===============================================================================
class Window_MissionCategory < Window_Selectable
 #-----------------------------------------------------------------------------
 # * Initialize Method
 #-----------------------------------------------------------------------------
 def initialize
  super(0, 64, 192, 416)
  self.contents = Bitmap.new(width - 32, height - 32)
  @game = Game_Mission.new
  @item_max = Mission_Categories.size
  @commands = []
  refresh
  self.opacity = CMS_Opacity
  self.visible = true
  self.active = true
  self.index = 0
 end
 #-----------------------------------------------------------------------------
 # * Define Category
 #-----------------------------------------------------------------------------
 def category
  return @data[self.index]
 end
 #-----------------------------------------------------------------------------
 # * Refresh
 #-----------------------------------------------------------------------------
 def refresh
  # If contents doesn't equal nil
  if self.contents != nil
   self.contents.dispose
   self.contents = nil
  end
  # Create Data array
  @data = []
  # For information within the Mission Categories
  for i in 0...Mission_Categories.size * 2
   # If Category ID is more than 1
   if @game.categories[i] != nil
    # Push category into data array
    @data.push(@game.categories[i])
   end
  end
  # Item max is reset to size of data array
  @item_max = @data.size
  # If Item Max is more than 0
  if @item_max > 0
   #self.contents = Bitmap.new(width - 32, @item_max * 64)
   self.contents = Bitmap.new(width - 32, row_max * 32)
   # For information in Item Max
   for i in 0...@item_max
    # Draw Mission Category
    draw_item(i)
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Draw_Item
 #-----------------------------------------------------------------------------
 def draw_item(index)
  # Mission name is determined by data array index
  mission = @data[index]
  for i in 0...mission.size + 1
   unless i == nil
    # Set Y coordinate of Mission Category command
    y = index * 32
    # Create new Rect
    rect = Rect.new(0, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.font.color = normal_color
    self.contents.draw_text(0, y, 192, 32, mission)
   end
  end
 end
end
################################################################################
#===============================================================================
# ** Window_MissionSelect
#-------------------------------------------------------------------------------
#Â Â This is the list of main mission categories, which will take you to the list
# of sub missions that fall into the respective category.
#===============================================================================
class Window_MissionSelect < Window_Selectable
 #-----------------------------------------------------------------------------
 # * Initialize Method
 #-----------------------------------------------------------------------------
 def initialize(mission_list = 0)
  super(192, 64, 448, 416)
  self.contents = Bitmap.new(width - 32, height - 32)
  @game = Game_Mission.new
  @item_max = Mission_Selectables.size - 3
  @commands = []
  refresh
  self.opacity = CMS_Opacity
  self.visible = true
  self.active = false
  self.index = 0
 end
 #-----------------------------------------------------------------------------
 # * Define Category
 #-----------------------------------------------------------------------------
 def mission(category)
  unless category == nil
   return @data[self.index][category]
  end
 end
 #-----------------------------------------------------------------------------
 # * Update Mission List
 #-----------------------------------------------------------------------------
 def update_list(category)
  @category = category
  refresh
 end
 #-----------------------------------------------------------------------------
 # * Refresh
 #-----------------------------------------------------------------------------
 def refresh
  # If contents doesn't equal nil
  if self.contents != nil
   self.contents.dispose
   self.contents = nil
  end
  # Create Data array
  @data = []
  # For information within the Mission Categories
  for i in 0...Mission_Selectables.size + 1
   # If Category ID is more than 1
   if @game.missions[i] != nil and
    @game.missions[0] == @category
    # Push category into data array
    @data.push(@game.missions[i])
   end
  end
  # Item max is reset to size of data array
  @item_max = @data.size
  # If Item Max is more than 0
  if @item_max > 0
   self.contents = Bitmap.new(width - 32, row_max * 32)
   # For information in Item Max
   for i in 0...@item_max
    # Draw Mission Category
    draw_item(i)
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Draw_Item
 #-----------------------------------------------------------------------------
 def draw_item(index)
  # Mission name is determined by data array index
  selectable = @data[index]
  # Set Y coordinate of Mission Category command
  y = index * 32
  # Create new Rect
  rect = Rect.new(0, y, self.width - 32, 32)
  self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  self.contents.font.color = normal_color
  self.contents.draw_text(0, y, 448, 32, selectable.to_s)
 end
end
################################################################################
#===============================================================================
# ** Scene_Mission
#-------------------------------------------------------------------------------
#Â Â This plays out the mission select scene, and allows you to pick which
# mission you need to complete.
#===============================================================================
class Scene_Mission
 #-----------------------------------------------------------------------------
 # * Initialize Method
 #-----------------------------------------------------------------------------
 def initialize(category = 0, mission = 0)
  @filename = "/Missions/Category[#{category}]/Mission[#{mission}]"
 end
 #-----------------------------------------------------------------------------
 # * Main Method
 #-----------------------------------------------------------------------------
 def main
  # View Map behind windows.
  if CMS_ShowMap == true
   @spriteset = Spriteset_Map.new
  end
  # Setup easy Game_Mission variable
  @game = Game_Mission.new
  # Create Window_MissionHeader
  @header = Window_MissionHeader.new
  # Create Window_MissionCategory
  @category = Window_MissionCategory.new
  #@category.active = true
  # Create Window_MissionSelect
  @mission = Window_MissionSelect.new
  # Create Window_MissionBriefing
  if FileTest.exist?(@filename)
   @briefing = Window_Reader.new(@filename)
  else
   @briefing = Window_Reader.new("")
  end
  # Create Window_MissionConfirm
  #@confirm = Window_MissionConfirm.new
  @confirm = Window_Command.new(180, ["Accept Mission", "Forget it!"])
  @confirm.x = 448
  @confirm.y = 372
  @confirm.z = 1100
  @confirm.opacity = CMS_Opacity * 1.25
  @confirm.visible = false
  @confirm.active = false
  # 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
  @header.dispose
  @category.dispose
  @mission.dispose
  @briefing.dispose
  @confirm.dispose
  # Dispose of Map Background
  @spriteset.dispose if CMS_ShowMap
 end
 #-----------------------------------------------------------------------------
 # * Update Method
 #-----------------------------------------------------------------------------
 def update
  # Update Windows
  @category.update
  @mission.update
  @briefing.update
  @confirm.update
  # Create Quick Window Object
  @scene = [@category, @mission, @briefing, @confirm]
  # Check Activity
  if Input.trigger?(Input::A)
   print("Category :", @category.active,
      " Mission :", @mission.active,
      " Confirm :", @confirm.active)
  end
  # Window Category Update
  if @category.active == true
   update_category
   return
  end
  # Window Mission Update
  if @mission.active == true
   update_mission
   return
  end
  # Window Briefing Update
  if @briefing.active == true
   update_briefing
   return
  end
  # Window Confirm Update
  if @confirm.active == true
   update_confirm
   #return
  end
 end
 #-----------------------------------------------------------------------------
 # * Update Category Window
 #-----------------------------------------------------------------------------
 def update_category
  # If B Button Pressed
  if Input.trigger?(Input::B)
   # Play Cancel SE
   $game_system.se_play($data_system.cancel_se)
   # Go Back to Main Menu
   $scene = Scene_Menu.new(CMS_Index_Mission)
  end
  # If C Button Pressed
  if Input.trigger?(Input::C)
   # Play Decision SE
   $game_system.se_play($data_system.decision_se)
   # Category Update
   @scene[0].active = false
   # Mission Update
   @scene[1].active = true
  end
  # Briefing Update
  @scene[2].visible, @scene[2].active = false, false
  # Confirm Update
  @scene[3].visible, @scene[3].active = false, false
 end
 #-----------------------------------------------------------------------------
 # * Update Mission Window
 #-----------------------------------------------------------------------------
 def update_mission
  # If B Button Pressed
  if Input.trigger?(Input::B)
   # Play Cancel SE
   $game_system.se_play($data_system.cancel_se)
   # Category Update
   @scene[0].active = true
   # Mission Update
   @scene[1].active = false
  end
  # If C Button Pressed
  if Input.trigger?(Input::C)
   # Play Decision SE
   $game_system.se_play($data_system.decision_se)
   # Get Category Index, Mission Index
   $game_temp.mission_call = true
   @n1, @n2 = @scene[0].index + 1, @scene[1].index + 1
   @filename = "Category[#{@n1}]/Mission[#{@n2}].txt"
   # Switch to Text_Reader Scene
   $scene = Text_Reader.new(@filename)
  end
  # Confirm Update
  @scene[3].visible, @scene[3].active = false, false
 end
 #-----------------------------------------------------------------------------
 # * Update Confirm
 #-----------------------------------------------------------------------------
 def update_confirm
  # If B Button Pressed
  if Input.trigger?(Input::B)
   # Play Cancel SE
   $game_system.se_play($data_system.cancel_se)
   # Reader Update
   @window.active = true
   @confirm.active, @confirm.visible = false, false
  end
  # If C Button Pressed
  if Input.trigger?(Input::C)
   # Play Decision SE
   $game_system.se_play($data_system.decision_se)
   # Confirm Mission Data
   print("Confirm Mission Data")
  end
 end
end
################################################################################
#===============================================================================
# ~** Advanced Text Reader **~
#-------------------------------------------------------------------------------
#Â Â This class controls the "Text_Reader" scene, and reads settings from the
# Text_Settings class.
#===============================================================================
class Text_Reader < Text_Settings
 #-----------------------------------------------------------------------------
 # * Initialize (filename)
 #-----------------------------------------------------------------------------
 def initialize(filename)
  @open     = Open
  @scroll_speed = Scroll_Speed
  @directory  = Directory
  @subdirectory = Sub_Directory
  @background  = BG_Picture
  @opacity   = Opacity
  @width    = Width
  @height    = Height
  @ox      = OX
  @oy      = OY
  @auto_scroll = Auto_Scroll
  @auto_speed  = Auto_Speed
  @auto_skip  = Auto_Skip
  @auto_close  = Auto_Close
  @filename   = filename
  @mission   = $game_temp.mission_call
 end
 #-----------------------------------------------------------------------------
 # * Main Method
 #-----------------------------------------------------------------------------
 def main
  if BG_Picture != ""
   viewport = Viewport.new(0, 0, 640, 480)
   @bg = Sprite.new(viewport)
   @bg.bitmap = RPG::Cache.picture(@background)
  else
   @bg = Spriteset_Map.new
  end
  file = File.open(@directory + @filename)
  @text = []
  for i in file.readlines
   @text.push i.sub(/\n/) {}
  end
  # Create Text Reader Window
  @window = Window_Reader.new(@text)
  unless @mission != true
   @confirm = Window_Command.new(180, ["Accept Mission", "Forget it!"])
   @confirm.x = 448
   @confirm.y = 372
   @confirm.z = 1100
   @confirm.opacity = CMS_Opacity * 1.25
   @confirm.visible = false
   @confirm.active = false
  end
  # 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
  @window.dispose
  @confirm.dispose if @mission
  @bg.dispose
 end
 #-----------------------------------------------------------------------------
 # * Update Method
 #-----------------------------------------------------------------------------
 def update
  @window.update
  @confirm.update if @mission
  @oy_arg = @window.oy + 320 < @window.contents.height ? true : false
  @window.oy += Auto_Speed if Auto_Scroll and @oy_arg
  # Reader Update Call
  if @window.active == true
   update_reader
   return
  end
  # Confirm Update Call
  if @confirm.active == true
   update_confirm
   return
  end
 end
 #-----------------------------------------------------------------------------
 # * Update Reader
 #-----------------------------------------------------------------------------
 def update_reader
  # Update with Auto-Scroll
  if @auto_scroll and @oy_arg
   @window.oy += @auto_speed
   if Input.press?(Input::C) and @auto_skip
    @window.oy += @auto_speed
   end
   if Input.press?(Input::B) and @auto_close
    $game_system.se_play($data_system.cancel_se)
    while @window.opacity > 0
     @window.opacity -= @open
     @window.contents_opacity -= @open
     Graphics.update
    end
    @window.dispose
    $scene = Scene_Map.new
   end
  end
  # If Called With Mission
  if @mission and @window.active == true
   @stop = true
   # If C Button Pressed
   if Input.trigger?(Input::C)
    # Play Decision SE
    $game_system.se_play($data_system.decision_se)
    # Update Confirm Window
    @window.active = false
    @confirm.active = true
    @confirm.visible = true
   end
   # If B Button Pressed
   if Input.trigger?(Input::B)
    # Play Cancel SE
    $game_system.se_play($data_system.cancel_se)
    # Go back to Scene_Mission
    $game_temp.mission_call = false
    $scene = Scene_Mission.new
   end
   # If DOWN Button Pressed
   if Input.press?(Input::DOWN)
    @window.oy += @scroll_speed if @oy_arg
   end
   # If UP Button Pressed
   if Input.press?(Input::UP)
    @window.oy -= @scroll_speed if @window.oy > 0
   end
  # If Called Normally
  else
   # Once scroll meets bottom
   @stop = true
   # If C or B Button Pressed
   if Input.trigger?(Input::B) or Input.trigger?(Input::C)
    $game_system.se_play($data_system.cancel_se)
    while @window.opacity > 0
     @window.opacity -= @open
     @window.contents_opacity -= @open
     Graphics.update
    end
    $scene = Scene_Map.new
   end
   # If DOWN Button Pressed
   if Input.press?(Input::DOWN)
    @window.oy += @scroll_speed if @oy_arg
   end
   # If UP Button Pressed
   if Input.press?(Input::UP)
    @window.oy -= @scroll_speed if @window.oy > 0
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Update Confirm
 #-----------------------------------------------------------------------------
 def update_confirm
  # If B Button Pressed
  if Input.trigger?(Input::B)
   # Play Cancel SE
   $game_system.se_play($data_system.cancel_se)
   # Briefing Update
   @window.active = true
   # Confirm Update
   @confirm.visible, @confirm.active = false, false
  end
  # If C Button Pressed
  if Input.trigger?(Input::C)
   # Play Decision SE
   $game_system.se_play($data_system.decision_se)
   # Confirm Mission Data
   print("Confirm Mission Data")
  end
 end
end
################################################################################
#===============================================================================
# ** Window_Reader
#-------------------------------------------------------------------------------
#Â Â This window displays text kept in the Text Document folder.
#===============================================================================
class Window_Reader < Window_Base
 # [Attributes]----------------------------------------------------------------
 attr_accessor :firstline
 attr_accessor :nowline
 #-----------------------------------------------------------------------------
 # * Initialize (Text) Method
 #-----------------------------------------------------------------------------
 def initialize(text)
  super(Text_Settings::OX,Text_Settings::OY,Text_Settings::Width,Text_Settings::Height)
  self.opacity = 0
  self.contents_opacity = 0
  self.active = Text_Settings::Active
  self.visible = Text_Settings::Visible
  @text = text
  @align = 0
  draw_text
 end
 #-----------------------------------------------------------------------------
 # * Update Method
 #-----------------------------------------------------------------------------
 def update
  if self.opacity < Text_Settings::Opacity
   self.opacity += Text_Settings::Open
   self.contents_opacity += Text_Settings::Open
  end
 end
 #-----------------------------------------------------------------------------
 # * Draw Text
 #-----------------------------------------------------------------------------
 def draw_text
  self.contents = Bitmap.new(width - 32, @text.size * 24 + 32)
  line_index = 0
  for i in 0..@text.size
   if !@text[i].nil?
    text = decorate_text(@text[i])
    self.contents.font.size = 20
    self.contents.draw_text(0, line_index * 24, width - 32, 24, text, @align)
   end
   line_index += 1
  end
 end
 #-----------------------------------------------------------------------------
 # * Decorate Text (Text)
 #-----------------------------------------------------------------------------
 def decorate_text(text)
  #---------------------------------------------------------------------------
  # * Bold
  # [b] : ON
  # [/b] : OFF
  #---------------------------------------------------------------------------
  a = text.scan(/(\[b\])/)
  if $1.to_s != ""
   self.contents.font.bold = true
   text.sub!(/\[b\]/) {}
  end
  a = text.scan(/(\[\/b\])/)
  if $1.to_s != ""
   self.contents.font.bold = false
   text.sub!(/\[\/b\]/) {}
  end
  #---------------------------------------------------------------------------
  # * Italics
  # [b] : ON
  # [/b] : OFF
  #---------------------------------------------------------------------------
  a = text.scan(/(\[i\])/)
  if $1.to_s != ""
   self.contents.font.italic = true
   text.sub!(/\[i\]/) {}
  end
  a = text.scan(/(\[\/i\])/)
  if $1.to_s != ""
   self.contents.font.italic = false
   text.sub!(/\[\/i\]/) {}
  end
  #---------------------------------------------------------------------------
  # * Indent [indent]
  #---------------------------------------------------------------------------
  a = text.scan(/(\[indent\])/)
  if $1.to_s != ""
   text.sub!(/\[indent\]/) {"   "}
  end
  #---------------------------------------------------------------------------
  # Center Align
  #---------------------------------------------------------------------------
  a = text.scan(/(\[center\])/)
  if $1.to_s != ""
   @align = 1
   text.sub!(/\[center\]/) {}
  end
  #---------------------------------------------------------------------------
  # Left AlignÂ
  #---------------------------------------------------------------------------
  a = text.scan(/(\[left\])/)
  if $1.to_s != ""
   @align = 0
   text.sub!(/\[left\]/) {}
  end
  #---------------------------------------------------------------------------
  # Right Align
  #---------------------------------------------------------------------------
  a = text.scan(/(\[right\])/)
  if $1.to_s != ""
   @align = 2
   text.sub!(/\[right\]/) {}
  end
  #---------------------------------------------------------------------------
  # Reset Text [reset]
  #---------------------------------------------------------------------------
  a = text.scan(/(\[reset\])/)
  if $1.to_s != ""
   self.contents.font.bold  = false
   self.contents.font.italic = false
   @align = 0
   text.sub!(/\[reset\]/) {}
  end
  return text
 end
end