/*:
* @plugindesc Choice's backGround Picture.
* 
* @author mrcopra          Read Help
* 
* @param Choice Switch
* @desc Which switch you want use to enable choices pictures 
* @default 1
*
* @param Picture Id
* @desc The id of picture you want use
* @default 1
*
* @param Picture Name
* @desc The name of picture you want use and it will numbered
* @default Choice
* 
* 
* @param Picture Origin
* @desc 
* @default 1
* 
* @param Picture X
* @desc 
* @default 400
* 
* @param Picture Y
* @desc 
* @default 300
* 
* @param Picture Scale X
* @desc 
* @default 100
* 
* @param Picture Scale Y
* @desc 
* @default 100
* 
* @param Picture Opacity
* @desc 
* @default 255
* 
* @param Picture Blend Mode
* @desc 
* @default 0
* 
* @help 
* Example:
* if you choose the name of picture 'Choice' it will be:
* Choice1.png  for choice 1
* Choice2.png  for choice 2 
* and go on
* 
* Don't forget to disable the switch
*/
 (function() {
     
     var parameters = PluginManager.parameters('ChoicesPic');
     var sw = Number(parameters['Choice Switch'] || 1);
     var picId = Number(parameters['Picture Id'] || 1);
          var picName = String(parameters['Picture Name'] || 'Choice');
               var picOrigin= Number(parameters['Picture Origin'] || 1);
     var picX = Number(parameters['Picture X'] || 400);
          var picY = Number(parameters['Picture Y'] || 300);
               var picScaleX = Number(parameters['Picture Scale X'] || 100);
     var picScaleY = Number(parameters['Picture Scale Y'] || 100);
          var picOpacity = Number(parameters['Picture Opacity'] || 255);
          var picBlend = Number(parameters['Picture Blend Mode'] || 0);
    

var happyPluginCommands = Game_Interpreter.prototype.pluginCommand;

Game_Interpreter.prototype.pluginCommand = function(command, args)
{
    happyPluginCommands.call(this, command, args);

    if (command == 'choice')
     {}};
 Window_ChoiceList.prototype.start = function() {
    if  ($gameSwitches.value(sw)){
    $gameSystem.saveBgm();}
    this.updatePlacement();
    this.updateBackground();
    this.refresh();
    this.selectDefault();
    this.open();
    this.activate();
        
};

Window_ChoiceList.prototype.callOkHandler = function() {
    $gameMessage.onChoice(this.index());
    this._messageWindow.terminateMessage();
    this.close();
      if  ($gameSwitches.value(sw)){
         $gameSystem.replayBgm();
     $gameScreen.erasePicture(picId);}

};
Window_ChoiceList.prototype.callCancelHandler = function() {
    $gameMessage.onChoice($gameMessage.choiceCancelType());
    this._messageWindow.terminateMessage();
    this.close();
      if  ($gameSwitches.value(sw)){
         $gameSystem.replayBgm();
     $gameScreen.erasePicture(picId);}
};
Window_Selectable.prototype.processCursorMove = function() {
        

    if (this.isCursorMovable()) {
        var lastIndex = this.index();
        var num = lastIndex+1;
   

   
    // Change 
        if ($gameSwitches.value(sw)) {

            $gameScreen.showPicture(picId, picName+num, picOrigin, picX, picY, picScaleX, picScaleY, picOpacity, picBlend);
            AudioManager.playBgm({name: num, volume:100, pitch:100, pan:0});
             }; //else {
        //         if ($gameSwitches.value(30)== true) {
        //             AudioManager.playBgm({name: num, volume:100, pitch:100, pan:0});
        //     $gameScreen.showPicture(1,picName+ num, 1, 300, 300, 100, 100, 255, 0);
        //     }
        // }
        
        if (Input.isRepeated('down')) {
            this.cursorDown(Input.isTriggered('down'));
        }
        if (Input.isRepeated('up')) {
            this.cursorUp(Input.isTriggered('up'));
        }
        if (Input.isRepeated('right')) {
            this.cursorRight(Input.isTriggered('right'));
        }
        if (Input.isRepeated('left')) {
            this.cursorLeft(Input.isTriggered('left'));
        }
        if (!this.isHandled('pagedown') && Input.isTriggered('pagedown')) {
            this.cursorPagedown();
        }
        if (!this.isHandled('pageup') && Input.isTriggered('pageup')) {
            this.cursorPageup();
        }
        if (this.index() !== lastIndex) {
            SoundManager.playCursor();      
        }
    }
};

     
 })();





