#==============================================================================
#                     「ヘルプウィンドウonマップ」(ACE) Ver.1.1
#   製作者:奈々(なな)
#   へぷたなすくろーる http://heptanas.mamagoto.com/
#
#   ◇利用規約
#   この素材はフリーゲームにのみご利用頂けます。
#   シェアウェア、販売作品への利用は原則として禁止します。(詳細はブログ参照)
#   利用される場合はスクリプト作成者として「奈々」とURLを明記し
#   配布時にブログで利用規約の確認と、利用報告を行って下さい。
#
#------------------------------------------------------------------------------
#   
#   イベントで制御できる「ヘルプウィンドウ」をマップ上に表示します。
#   特徴としてはメッセージウィンドウと違い、操作を奪わないため
#   移動やキー入力などを邪魔せずにメッセージを表示できます。
#   主にイベントによる自作メニューや移動中のガイドなどにご活用下さい。
#   
#   使い方は、まず初期設定で行数等を指定します。
#   次に表示はイベントコマンドの「スクリプト」を使います。
#   
#   n7_map_help("text")       textの文章を表示
#   n7_map_help_add("text")   testの文章を追加(改行)
#   
#   textの書き方はデータベースの説明文と同じですが
#   改行には\nと書き、\i[n]などは\\i[n]と書く必要があります。
#   また()省略か空白""の指定で、文章を消去しウィンドウを閉じます。
#   
#   基本的な使い方としては
#   ・ウィンドウを表示
#   n7_map_help("一行目の文章") 
#   n7_map_help_add("二行目の文章")
#   ・ウィンドウを閉じる
#   n7_map_help
#   という感じでイベントを組んで下さい。
#   
#==============================================================================

#◇初期設定
module Nana
module Map_Help

  LINE = 2                   #ウィンドウの行数
  
  OPACITY = 255              #ウィンドウの不透明度
  
  POSITION = 0               #ウィンドウの位置
                             #(Y座標を指定、また-1なら下、-2なら中央に配置)
  
end
end

#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
#  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
# このクラスのインスタンスは $game_map で参照されます。
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :help_text                # ヘルプウィンドウのテキスト
  attr_accessor :help_text2               # ヘルプ更新の比較用
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias initialize_maphelp initialize
  def initialize
    initialize_maphelp
    help_text = ""
    help_text2 = ""
  end
end

#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
#  マップ画面の処理を行うクラスです。
#==============================================================================

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # ● 全ウィンドウの作成
  #--------------------------------------------------------------------------
  alias create_all_windows_maphelp create_all_windows
  def create_all_windows
    create_all_windows_maphelp
    create_help_window
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウの作成
  #--------------------------------------------------------------------------
  def create_help_window
    @help_window = Window_Help.new(Nana::Map_Help::LINE)
    case Nana::Map_Help::POSITION
    when -1
      @help_window.y = Graphics.height - @help_window.height
    when -2
      @help_window.y = (Graphics.height - @help_window.height) / 2
    else
      @help_window.y = Nana::Map_Help::POSITION
    end
    @help_window.opacity = Nana::Map_Help::OPACITY
    @help_window.openness = 0
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias update_maphelp update
  def update
    update_maphelp
    
    if $game_map.help_text != $game_map.help_text2
      @help_window.set_text($game_map.help_text)
      $game_map.help_text2 = $game_map.help_text
      
      if $game_map.help_text == ""
        @help_window.close
      else
        @help_window.open
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 場所移動前の処理
  #--------------------------------------------------------------------------
  alias pre_transfer_maphelp pre_transfer
  def pre_transfer
    pre_transfer_maphelp
    $game_map.help_text = ""
  end
end

#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウの文章設定
  #--------------------------------------------------------------------------
  def n7_map_help(text = "")
    $game_map.help_text = text
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウの文章追加(一行モード)
  #--------------------------------------------------------------------------
  def n7_map_help_add(text = "")
    $game_map.help_text += "\n"
    $game_map.help_text += text
  end
end