//------------------------------------------------------------------------------
// Lamp : Open source game middleware
// Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//------------------------------------------------------------------------------

/** @file
 * サウンドサンプル 静的サウンド実装
 * @author Junpee
 */

#include <LampBasic.h>
#include <Framework/System/BasicFramework.h>
#include <Sound/System/LampSound.h>
#include <Sound/System/SoundManager.h>
#include <Sound/Stereo/StaticSound.h>
#include <Sound/Stereo/StreamSound.h>//

// Lampのネームスペースを有効にする
using namespace Lamp;

//------------------------------------------------------------------------------
// クラス定義。通常はヘッダファイルに格納する
//------------------------------------------------------------------------------
/**
 * サウンドサンプル 静的サウンド
 */
class SampleSoundStaticSound : public BasicFramework{
public:
	/**
	 * コンストラクタ
	 */
	SampleSoundStaticSound(const String& command) :
	  BasicFramework("SampleSoundStaticSound"), command_(command){}

	/**
	 * 初期化
	 * @return 初期化に成功すればtrueを返す
	 */
	virtual bool initialize();

	/**
	 * 後始末
	 */
	virtual void finalize();

	/**
	 * 実行
	 */
	virtual void run();

	/**
	 * 情報描画
	 */
	virtual void drawInformation();

private:
	// コマンド文字列
	String command_;
	// 情報文字列
	String informationString_;
	// サウンド
	StaticSound* sound_;
//	StreamSound* sound_;

};
//------------------------------------------------------------------------------
// プログラムエントリポイント
//------------------------------------------------------------------------------
// メイン関数
int WINAPI WinMain(
	HINSTANCE instance, HINSTANCE previousInstance, LPSTR command, int show){
	SampleSoundStaticSound tutorial(command);
	return tutorial.execute(instance);
}
//------------------------------------------------------------------------------
// クラス実装
//------------------------------------------------------------------------------
// 初期化
bool SampleSoundStaticSound::initialize(){
	sound_ = LampSound::getSoundManager()->createStaticSound(
		"../../Media/Sound/SampleSE1.ogg");
	if(sound_ != NULL){
		sound_->applyCommentOption();
		sound_->play();
	}
/*
	sound_ = LampSound::getSoundManager()->createStreamSound(command_);
	if(sound_ != NULL){
		sound_->applyCommentOption();
		sound_->play();
	}
*/
	return true;
}
//------------------------------------------------------------------------------
// 後始末
void SampleSoundStaticSound::finalize(){
	LampSound::getSoundManager()->destroy(sound_);
}
//------------------------------------------------------------------------------
// 実行
void SampleSoundStaticSound::run(){
	if(sound_ != NULL){ informationString_ += sound_->toString(); }
	// サウンドエディタを導入したい
}
//------------------------------------------------------------------------------
// 情報描画
void SampleSoundStaticSound::drawInformation(){
	BasicFramework::drawInformation();
	drawInformationString(informationString_);
	informationString_ = "";
}
//------------------------------------------------------------------------------
