/*:
* 静寂之夜
* @param 菜单位置 - x
* @default 0
* @param 菜单位置 - y
* @default 0
* @param 图片位置 - x
* @default 100
* @param 图片位置 - y
* @default 100
* @param 金币位置 - x
* @default 10
* @param 金币位置 - y
* @default 300
* @param 选项文字
* @default 选项
* @param 选项事件
* @default 1
* @plugindesc 图片位置:img/pic/pic.png
*/

var params = PluginManager.parameters("menu");

var mx = Number(params["菜单位置 - x"]);
var my = Number(params["菜单位置 - y"]);
var gx = Number(params["金币位置 - x"]);
var gy = Number(params["金币位置 - y"]);
var px = Number(params["图片位置 - x"]);
var py = Number(params["图片位置 - y"]);
var s = String(params["选项文字"]);
var e = Number(params["选项事件"]);

Scene_Menu.prototype.createStatusWindow = function() {
    this._statusWindow = new Window_MenuStatus(0, 0);
    this._statusWindow.y = -this._statusWindow.height;
    this.addWindow(this._statusWindow);
};
Scene_Menu.prototype.createGoldWindow = function() {
    this._goldWindow = new Window_Gold(0, 0);
    this._goldWindow.x = gx
    this._goldWindow.y = gy
    this.addWindow(this._goldWindow);
};
Scene_Menu.prototype.createCommandWindow = function() {
    this._commandWindow = new Window_MenuCommand(mx, my);
    this._commandWindow.setHandler('item',      this.commandItem.bind(this));
    this._commandWindow.setHandler('skill',     this.commandPersonal.bind(this));
    this._commandWindow.setHandler('equip',     this.commandPersonal.bind(this));
    this._commandWindow.setHandler('status',    this.commandPersonal.bind(this));
    this._commandWindow.setHandler('formation', this.commandFormation.bind(this));
    this._commandWindow.setHandler('options',   this.commandOptions.bind(this));
    this._commandWindow.setHandler('save',      this.commandSave.bind(this));
    this._commandWindow.setHandler('gameEnd',   this.commandGameEnd.bind(this));
    this._commandWindow.setHandler('cancel',    this.popScene.bind(this));

    this._commandWindow.setHandler('new', this.newcommand.bind(this));

    this.addWindow(this._commandWindow);
};
Scene_Menu.prototype.newcommand = function() {
    SceneManager.pop();
    $gameTemp.reserveCommonEvent(e);
};
Window_MenuCommand.prototype.addMainCommands = function () {
    var enabled = this.areMainCommandsEnabled();
    this.addCommand(TextManager.item, 'item', enabled);
    this.addCommand(s, 'new', true);
};
Window_MenuCommand.prototype.addFormationCommand = function() {
    if (this.needsCommand('formation')) {
    }
};
ImageManager.loadMenuPic = function() {
    return this.loadBitmap('img/pic/', "pic", 0, true);
};
Scene_Menu.prototype.create = function() {
    Scene_MenuBase.prototype.create.call(this);
    this.createCommandWindow();
    this.createGoldWindow();
    this.createStatusWindow();
    this._pic = new Sprite(ImageManager.loadMenuPic());
    this.addChild(this._pic);
    this._pic.x = px;
    this._pic.y = py;
};
Scene_Item.prototype.createItemWindow = function() {
    var wy = this._helpWindow.height;
    var wh = Graphics.boxHeight - wy;
    this._itemWindow = new Window_ItemList(0, wy, Graphics.boxWidth, wh);
    this._itemWindow.setHelpWindow(this._helpWindow);
    this._itemWindow.setHandler('ok',     this.onItemOk.bind(this));
    this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
    this.addWindow(this._itemWindow);
};
Window_ItemList.prototype.makeItemList = function() {
    this._data = $gameParty.allItems().filter(function(item) {
        return true;
    }, this);
    if (this.includes(null)) {
        this._data.push(null);
    }
};
Scene_Item.prototype.create = function() {
    Scene_ItemBase.prototype.create.call(this);
    this.createHelpWindow();
    this.createItemWindow();
    this.createActorWindow();
    
    this._itemWindow.setCategory();
    this._itemWindow.activate();
    this._itemWindow.selectLast();
};
Scene_Item.prototype.onItemCancel = function() {
    SceneManager.pop();
};
