//=============================================================================
// Splash Screen.js
//=============================================================================

/*:
 * @plugindesc Creates a Splash Screen before the Title is shown.
 * @author Soulpour777
 *
 * @param SplashImage
 * @desc The name of the Splash Screen Image you use.
 * @default Splash1
 *
 * 
* @param MusicName
* @desc The name of the music you wanted to use in the splash screen.
* @default Theme1
*
* @param MusicVolume
* @desc The volume of the music used in the splash screen.
* @default 100
*
* @param MusicPitch
* @desc The pitch of the music used in the splash screen.
* @default 100
*
* @param MusicPanning
* @desc The panning value of the music used in the splash screen.
* @default 0 
 */


var params = PluginManager.parameters('Splash Screen Ex');
var splash_items = String(params['SplashImage'] || "Splash1");
var _splashScreen_music_name = String(params['MusicName'] || "Theme1");
var _splashScreen_music_volume = Number(params['MusicVolume'] || 100);
var _splashScreen_music_pitch = Number(params['MusicPitch'] || 100);
var _splashScreen_music_pan = Number(params['MusicPanning'] || 0);;
//-----------------------------------------------------------------------------
// Scene_Splash
//
// The scene class of the splash screen.

Scene_Boot.prototype.start = function() {
    Scene_Base.prototype.start.call(this);
    SoundManager.preloadImportantSounds();
    if (DataManager.isBattleTest()) {
        DataManager.setupBattleTest();
        SceneManager.goto(Scene_Battle);
    } else if (DataManager.isEventTest()) {
        DataManager.setupEventTest();
        SceneManager.goto(Scene_Map);
    } else {
        this.checkPlayerLocation();
        DataManager.setupNewGame();
        SceneManager.goto(Scene_Splash);
        Window_TitleCommand.initCommandPosition();
    }
    this.updateDocumentTitle();
};


function Scene_Splash() {
    this.initialize.apply(this, arguments);
}

Scene_Splash.prototype = Object.create(Scene_Base.prototype);
Scene_Splash.prototype.constructor = Scene_Splash;
Scene_Splash.prototype.splash_image = splash_items;

Scene_Splash.prototype.initialize = function() {
    Scene_Base.prototype.initialize.call(this);
};

Scene_Splash.prototype.create = function() {
    Scene_Base.prototype.create.call(this);
    this.playSplashMusic();
    this.createBackground();   
};

Scene_Splash.prototype.start = function() {
    Scene_Base.prototype.start.call(this);
    this.startFadeIn(this.slowFadeSpeed(), false);
};

Scene_Splash.prototype.update = function() {
    if (this.isActive() && !this.isBusy() && this.isTriggered()) {
        this.gotoTitle();
    }
    Scene_Base.prototype.update.call(this);
};

Scene_Splash.prototype.stop = function() {
    Scene_Base.prototype.stop.call(this);
    this.fadeOutAll();
};

Scene_Splash.prototype.terminate = function() {
    Scene_Base.prototype.terminate.call(this);
    AudioManager.stopAll();
};

Scene_Splash.prototype.playSplashMusic = function() {
    AudioManager.stopMe();
    AudioManager.stopBgs();
    var audio = {
      name: _splashScreen_music_name,
      volume: _splashScreen_music_volume,
      pitch: _splashScreen_music_pitch,
      pan: _splashScreen_music_pan
    }    
    AudioManager.playBgm(audio);
};

Scene_Splash.prototype.createBackground = function() {
    this._backSprite = new Sprite();
    this._backSprite.bitmap = ImageManager.loadSystem(this.splash_image);
    this.addChild(this._backSprite);    
    
};

Scene_Splash.prototype.isTriggered = function() {
    return Input.isTriggered('ok') || TouchInput.isTriggered();
};

Scene_Splash.prototype.gotoTitle = function() {
    SceneManager.goto(Scene_Title);
};