(function () {
	//#####################　メニューの背景変える　#####################
	Scene_Menu.prototype.createBackground = function () {
		this._backgroundSprite = new Sprite();
		this._backgroundSprite.bitmap = ImageManager.loadSystem("menu_back");

		//アクターidが若い順に
		var party = $gameParty.allMembers();

		var sira = party.find(function (e) {
			return e._name == "Shirayuki";
		});

		var yozu = party.find(function (e) {
			return e._name == "Yotsuru";
		});

		if (sira) {
			var sp = new Sprite();
			sp.bitmap = ImageManager.loadSystem("menu_sira");
			sp.x = 0;
			sp.y = 33;
			this._backgroundSprite.addChild(sp);
		}

		if (yozu) {
			var sp = new Sprite();
			sp.bitmap = ImageManager.loadSystem("menu_yozu");
			sp.x = Graphics.width - 447;
			sp.y = 33;
			this._backgroundSprite.addChild(sp);
		}

		var sp = new Sprite();
		sp.bitmap = ImageManager.loadSystem("menu_label");
		sp.x = 0;
		sp.y = Graphics.height - 50;
		this._backgroundSprite.addChild(sp);

		var sp = new Sprite(new Bitmap(Graphics.width, 50));
		sp.x = 0;
		sp.y = 666;
		sp.bitmap.fontSize = 22;
		sp.bitmap.textColor = "#FFFFFF";

		var data_map_name_list = [
			{
				id: 3,
				disp_name: "Prologue"
			},
			{
				id: 4,
				disp_name: "Military Base"
			},
			{
				id: 5,
				disp_name: "Military Base"
			},
			{
				id: 6,
				disp_name: "Some Downtown Area"
			},
			{
				id: 7,
				disp_name: "Cemetery"
			},
			{
				id: 8,
				disp_name: "Abiko's Laboratory"
			},
			{
				id: 9,
				disp_name: "Suburban Hotel"
			},
			{
				id: 10,
				disp_name: "Iris Academy"
			},
			{
				id: 11,
				disp_name: "Iris Academy"
			},
			{
				id: 12,
				disp_name: "Iris Academy"
			},
			{
				id: 13,
				disp_name: "Iris Academy"
			},
			{
				id: 14,
				disp_name: "Iris Academy"
			},
			{
				id: 15,
				disp_name: "Iris Academy"
			},
			{
				id: 16,
				disp_name: "Iris Academy"
			},
			{
				id: 17,
				disp_name: "Iris Academy"
			},
			{
				id: 18,
				disp_name: "Iris Academy"
			},
			{
				id: 19,
				disp_name: "Iris Academy"
			},
			{
				id: 20,
				disp_name: "Iris Academy"
			},
			{
				id: 21,
				disp_name: "Iris Academy"
			},
			{
				id: 22,
				disp_name: "Iris Academy"
			},
			{
				id: 23,
				disp_name: "Iris Academy"
			},
			{
				id: 24,
				disp_name: "Iris Academy"
			},
			{
				id: 25,
				disp_name: "Iris Academy"
			},
			{
				id: 26,
				disp_name: "Iris Academy"
			},
			{
				id: 27,
				disp_name: "Iris Academy"
			},
			{
				id: 28,
				disp_name: "Iris Academy"
			},
			{
				id: 29,
				disp_name: "Iris Academy"
			},
			{
				id: 30,
				disp_name: "Iris Academy"
			},
			{
				id: 31,
				disp_name: "Iris Academy"
			},
			{
				id: 32,
				disp_name: "Iris Academy"
			},
			{
				id: 33,
				disp_name: "Iris Academy"
			},
			{
				id: 34,
				disp_name: "Iris Academy"
			},
			{
				id: 35,
				disp_name: "Iris Academy"
			},
			{
				id: 36,
				disp_name: "Iris Academy"
			},
			{
				id: 37,
				disp_name: "Iris Academy"
			},
			{
				id: 38,
				disp_name: "Iris Academy"
			},
			{
				id: 39,
				disp_name: "Iris Academy"
			},
			{
				id: 40,
				disp_name: "Iris Academy"
			},
			{
				id: 41,
				disp_name: "Iris Academy"
			},
			{
				id: 42,
				disp_name: "Iris Academy"
			},
			{
				id: 43,
				disp_name: "Iris Academy"
			},
			{
				id: 44,
				disp_name: "Academy Girls' Dormitory"
			},
			{
				id: 45,
				disp_name: "Academy Girls' Dormitory"
			},
			{
				id: 46,
				disp_name: "Academy Girls' Dormitory"
			},
			{
				id: 47,
				disp_name: "Academy Girls' Dormitory"
			},
			{
				id: 48,
				disp_name: "Academy Girls' Dormitory"
			},
			{
				id: 49,
				disp_name: "Academy Girls' Dormitory"
			},
			{
				id: 50,
				disp_name: "Academy Girls' Dormitory"
			},
			{
				id: 51,
				disp_name: "Academy Girls' Dormitory"
			},
			{
				id: 52,
				disp_name: "Academy Boys' Dormitory"
			},
			{
				id: 53,
				disp_name: "Academy Boys' Dormitory"
			},
			{
				id: 54,
				disp_name: "Academy Boys' Dormitory"
			},
			{
				id: 55,
				disp_name: "Academy Boys' Dormitory"
			},
			{
				id: 56,
				disp_name: "Academy Boys' Dormitory"
			},
			{
				id: 57,
				disp_name: "Iris Academy"
			},
			{
				id: 58,
				disp_name: "Iris Academy"
			},
			{
				id: 59,
				disp_name: "Trial Cave"
			},
			{
				id: 60,
				disp_name: "Trial Cave"
			},
			{
				id: 61,
				disp_name: "Trial Cave"
			},
			{
				id: 62,
				disp_name: "Trial Cave"
			},
			{
				id: 63,
				disp_name: "Trial Cave"
			},
			{
				id: 64,
				disp_name: "Okutada Mountain"
			},
			{
				id: 65,
				disp_name: "Okutada Mountain"
			},
			{
				id: 66,
				disp_name: "Okutada Mountain"
			},
			{
				id: 67,
				disp_name: "Okutada Mountain"
			},
			{
				id: 68,
				disp_name: "Okutada Mountain"
			},
			{
				id: 69,
				disp_name: "Okutada Mountain"
			},
			{
				id: 70,
				disp_name: "Okutada Mountain"
			},
			{
				id: 71,
				disp_name: "Okutada Mountain"
			},
			{
				id: 72,
				disp_name: "Kamiyado"
			},
			{
				id: 73,
				disp_name: "Kamiyado"
			},
			{
				id: 74,
				disp_name: "Kamiyado"
			},
			{
				id: 75,
				disp_name: "Kamiyado"
			},
			{
				id: 76,
				disp_name: "Kamiyado"
			},
			{
				id: 77,
				disp_name: "Kamiyado"
			},
			{
				id: 78,
				disp_name: "Kamiyado"
			},
			{
				id: 79,
				disp_name: "Kamiyado"
			},
			{
				id: 80,
				disp_name: "Kamiyado"
			},
			{
				id: 81,
				disp_name: "Monster Research Lab"
			},
			{
				id: 82,
				disp_name: "Kamiyado"
			},
			{
				id: 83,
				disp_name: "Kamiyado"
			},
			{
				id: 84,
				disp_name: "Kamiyado"
			},
			{
				id: 85,
				disp_name: "Kamiyado"
			},
			{
				id: 86,
				disp_name: "Chichitake Cave"
			},
			{
				id: 87,
				disp_name: "Chichitake Cave"
			},
			{
				id: 88,
				disp_name: "Chichitake Cave"
			},
			{
				id: 89,
				disp_name: "Chichitake Cave"
			},
			{
				id: 90,
				disp_name: "Chichitake Cave"
			},
			{
				id: 91,
				disp_name: "Chichitake Cave"
			},
			{
				id: 92,
				disp_name: "Oshika Forest"
			},
			{
				id: 93,
				disp_name: "Kamaiki Town"
			},
			{
				id: 94,
				disp_name: "Kamaiki Town"
			},
			{
				id: 95,
				disp_name: "Kamaiki Town"
			},
			{
				id: 96,
				disp_name: "Kamaiki Town"
			},
			{
				id: 97,
				disp_name: "Tsukuba Peak"
			},
			{
				id: 98,
				disp_name: "Tsukuba Peak"
			},
			{
				id: 99,
				disp_name: "Tsukuba Peak"
			},
			{
				id: 100,
				disp_name: "Tsukuba Peak"
			},
			{
				id: 101,
				disp_name: "Tsukuba Peak"
			},
			{
				id: 102,
				disp_name: "Tsukuba Peak"
			},
			{
				id: 103,
				disp_name: "Tsukuba Peak"
			},
			{
				id: 104,
				disp_name: "Iris Headquarters"
			},
			{
				id: 105,
				disp_name: "Iris Headquarters"
			},
			{
				id: 106,
				disp_name: "Iris Headquarters"
			},
			{
				id: 107,
				disp_name: "Iris Headquarters"
			},
			{
				id: 108,
				disp_name: "Iris Headquarters"
			},
			{
				id: 109,
				disp_name: "Iris Headquarters"
			},
			{
				id: 110,
				disp_name: "Iris Headquarters"
			},
			{
				id: 111,
				disp_name: "Iris Headquarters"
			},
			{
				id: 112,
				disp_name: "Iris Headquarters"
			},
			{
				id: 113,
				disp_name: "Iris Headquarters"
			},
			{
				id: 114,
				disp_name: "Iris Headquarters"
			},
			{
				id: 115,
				disp_name: "Iris Dungeon"
			},
			{
				id: 116,
				disp_name: "Iris Dungeon"
			},
			{
				id: 117,
				disp_name: "Iris Dungeon"
			},
			{
				id: 118,
				disp_name: "Iris Dungeon"
			},
			{
				id: 119,
				disp_name: "Iris Dungeon"
			},
			{
				id: 120,
				disp_name: "Ichinotani Fishing Park"
			},
			{
				id: 121,
				disp_name: "Ichinotani Fishing Park"
			},
			{
				id: 122,
				disp_name: "Ichinotani Fishing Park"
			},
			{
				id: 123,
				disp_name: "Ichinotani Fishing Park"
			},
			{
				id: 124,
				disp_name: "Ichinotani Fishing Park"
			},
			{
				id: 125,
				disp_name: "Ichinotani Fishing Park"
			},
			{
				id: 126,
				disp_name: "Kamaiki Town Abandoned Building"
			},
			{
				id: 127,
				disp_name: "Kamaiki Town Abandoned Building"
			},
			{
				id: 128,
				disp_name: "Kamaiki Town Abandoned Building"
			},
			{
				id: 129,
				disp_name: "Kamaiki Town Abandoned Building"
			},
			{
				id: 130,
				disp_name: "Kamaiki Town Abandoned Building"
			},
			{
				id: 131,
				disp_name: "Kamaiki Town Abandoned Building"
			},
			{
				id: 132,
				disp_name: "Kamaiki Town Abandoned Building"
			},
			{
				id: 133,
				disp_name: "Kamaiki Town Abandoned Building"
			},
			{
				id: 134,
				disp_name: "Akagi Pass"
			},
			{
				id: 135,
				disp_name: "Akagi Pass"
			},
			{
				id: 136,
				disp_name: "Akagi Pass"
			},
			{
				id: 137,
				disp_name: "Akagi Pass"
			},
			{
				id: 138,
				disp_name: "Akagi Pass"
			},
			{
				id: 139,
				disp_name: "Akagi Pass"
			},
			{
				id: 140,
				disp_name: "Meikyo Wharf"
			},
			{
				id: 141,
				disp_name: "Meikyo Wharf"
			},
			{
				id: 142,
				disp_name: "Meikyo Wharf"
			},
			{
				id: 143,
				disp_name: "Shibuno"
			},
			{
				id: 144,
				disp_name: "Shibuno"
			},
			{
				id: 145,
				disp_name: "Rubik"
			},
			{
				id: 146,
				disp_name: "Rubik"
			},
			{
				id: 147,
				disp_name: "Rubik"
			},
			{
				id: 148,
				disp_name: "Rubik"
			},
			{
				id: 149,
				disp_name: "Rubik"
			},
			{
				id: 150,
				disp_name: "Aoiyama Cemetery"
			},
			{
				id: 151,
				disp_name: "Aoiyama Cemetery"
			},
			{
				id: 152,
				disp_name: "Aoiyama Cemetery"
			},
			{
				id: 153,
				disp_name: "Aoiyama Cemetery"
			},
			{
				id: 154,
				disp_name: "Shirakawa Research Institute Ruins"
			},
			{
				id: 155,
				disp_name: "Shirakawa Research Institute Ruins"
			},
			{
				id: 156,
				disp_name: "Shirakawa Research Institute Ruins"
			},
			{
				id: 157,
				disp_name: "Shirakawa Research Institute Ruins"
			},
			{
				id: 158,
				disp_name: "Shirakawa Research Institute Ruins"
			},
			{
				id: 159,
				disp_name: "Shirakawa Research Institute Ruins"
			},
			{
				id: 160,
				disp_name: "Center Hotel"
			},
			{
				id: 161,
				disp_name: "Center Hotel"
			},
			{
				id: 162,
				disp_name: "Center Hotel"
			},
			{
				id: 163,
				disp_name: "Center Hotel"
			},
			{
				id: 164,
				disp_name: "Center Hotel"
			},
			{
				id: 165,
				disp_name: "Center Hotel"
			},
			{
				id: 166,
				disp_name: "Center Hotel"
			},
			{
				id: 167,
				disp_name: "Center Hotel"
			},
			{
				id: 168,
				disp_name: "Kamaiki Town"
			},
			{
				id: 169,
				disp_name: "Nexus Future Hideout"
			},
			{
				id: 170,
				disp_name: "Nexus Future Hideout"
			},
			{
				id: 171,
				disp_name: "Nexus Future Hideout"
			},
			{
				id: 172,
				disp_name: "Nexus Future Hideout"
			},
			{
				id: 173,
				disp_name: "Erodoll Dungeon"
			},
			{
				id: 174,
				disp_name: "Erodoll Dungeon"
			},
			{
				id: 175,
				disp_name: "Erodoll Dungeon"
			},
			{
				id: 176,
				disp_name: "Erodoll Dungeon"
			},
			{
				id: 177,
				disp_name: "Erodoll Dungeon"
			},
			{
				id: 178,
				disp_name: "Erodoll Dungeon"
			},
			{
				id: 179,
				disp_name: "Erodoll Dungeon"
			},
			{
				id: 180,
				disp_name: "Hayama Highlands"
			},
			{
				id: 181,
				disp_name: "Hayama Highlands"
			},
			{
				id: 182,
				disp_name: "Hayama Highlands"
			},
			{
				id: 183,
				disp_name: "Hayama Highlands"
			},
			{
				id: 184,
				disp_name: "Hayama Highlands"
			},
			{
				id: 185,
				disp_name: "Sendai Dungeon"
			},
			{
				id: 186,
				disp_name: "Sendai Dungeon"
			},
			{
				id: 187,
				disp_name: "Sendai Dungeon"
			},
			{
				id: 188,
				disp_name: "Sendai Dungeon"
			},
			{
				id: 189,
				disp_name: "Sendai Dungeon"
			},
			{
				id: 190,
				disp_name: "Magical Crime Prison"
			},
			{
				id: 191,
				disp_name: "Magical Crime Prison"
			},
			{
				id: 192,
				disp_name: "Magical Crime Prison"
			},
			{
				id: 193,
				disp_name: "Magical Crime Prison"
			},
			{
				id: 194,
				disp_name: "Magical Crime Prison"
			},
			{
				id: 195,
				disp_name: "Magical Crime Prison"
			},
			{
				id: 196,
				disp_name: "Yaba Island"
			},
			{
				id: 197,
				disp_name: "Yaba Island"
			},
			{
				id: 198,
				disp_name: "Yaba Island"
			},
			{
				id: 199,
				disp_name: "Yaba Island Cave"
			},
			{
				id: 200,
				disp_name: "Yaba Island Cave"
			},
			{
				id: 201,
				disp_name: "Yaba Island Cave"
			},
			{
				id: 202,
				disp_name: "Yaba Island Cave"
			},
			{
				id: 203,
				disp_name: "Yaba Island Cave"
			},
			{
				id: 204,
				disp_name: "Tochigi Dungeon"
			},
			{
				id: 205,
				disp_name: "Tochigi Dungeon"
			},
			{
				id: 206,
				disp_name: "Tochigi Dungeon"
			},
			{
				id: 207,
				disp_name: "Tochigi Dungeon"
			},
			{
				id: 208,
				disp_name: "Tochigi Dungeon"
			},
			{
				id: 209,
				disp_name: "Tochigi Dungeon"
			},
			{
				id: 210,
				disp_name: "Tochigi Dungeon"
			},
			{
				id: 211,
				disp_name: "Tochigi Dungeon"
			},
			{
				id: 212,
				disp_name: "East Capital Ancient Ruins"
			},
			{
				id: 213,
				disp_name: "East Capital Ancient Ruins"
			},
			{
				id: 214,
				disp_name: "East Capital Ancient Ruins"
			},
			{
				id: 215,
				disp_name: "East Capital Ancient Ruins"
			},
			{
				id: 216,
				disp_name: "East Capital Ancient Ruins"
			},
			{
				id: 217,
				disp_name: "East Capital Ancient Ruins"
			},
			{
				id: 218,
				disp_name: "East Capital Ancient Ruins"
			},
			{
				id: 219,
				disp_name: "East Capital Ancient Ruins"
			},
			{
				id: 220,
				disp_name: "East Capital Ancient Ruins"
			},
			{
				id: 221,
				disp_name: "Kamiyado Underground Passage"
			},
			{
				id: 222,
				disp_name: "Kamiyado Underground Passage"
			},
			{
				id: 223,
				disp_name: "Kamiyado Underground Passage"
			},
			{
				id: 224,
				disp_name: "Kamiyado Underground Passage"
			},
			{
				id: 225,
				disp_name: "Dahlia's Hideout"
			},
			{
				id: 226,
				disp_name: "Dahlia's Hideout"
			},
			{
				id: 227,
				disp_name: "Dahlia's Hideout"
			},
			{
				id: 228,
				disp_name: "Dahlia's Hideout"
			},
			{
				id: 229,
				disp_name: "Dahlia's Hideout"
			},
			{
				id: 230,
				disp_name: "Dahlia's Hideout"
			},
			{
				id: 231,
				disp_name: "Dahlia's Hideout"
			},
			{
				id: 232,
				disp_name: "Fuji Sea of Trees"
			},
			{
				id: 233,
				disp_name: "Fuji Sea of Trees"
			},
			{
				id: 234,
				disp_name: "Mount Fuji"
			},
			{
				id: 235,
				disp_name: "Mount Fuji"
			},
			{
				id: 236,
				disp_name: "Mount Fuji"
			},
			{
				id: 237,
				disp_name: "Mount Fuji"
			},
			{
				id: 238,
				disp_name: "Mount Fuji"
			},
			{
				id: 239,
				disp_name: "Mount Fuji"
			},
			{
				id: 240,
				disp_name: "Mount Fuji"
			},
			{
				id: 241,
				disp_name: "Dimensional Rift"
			},
			{
				id: 242,
				disp_name: "Torikage Peak"
			},
			{
				id: 243,
				disp_name: "Torikage Peak"
			},
			{
				id: 244,
				disp_name: "Torikage Peak"
			},
			{
				id: 245,
				disp_name: "Torikage Peak"
			},
			{
				id: 246,
				disp_name: "Torikage Peak"
			},
			{
				id: 247,
				disp_name: "Road to Seien Church"
			},
			{
				id: 248,
				disp_name: "Road to Seien Church"
			},
			{
				id: 249,
				disp_name: "Road to Seien Church"
			},
			{
				id: 250,
				disp_name: "Seien Church"
			},
			{
				id: 251,
				disp_name: "Seien Church"
			},
			{
				id: 252,
				disp_name: "Seien Church"
			},
			{
				id: 253,
				disp_name: "Underground Arena"
			},
			{
				id: 254,
				disp_name: "Underground Arena"
			},
			{
				id: 255,
				disp_name: "Road to Iris Headquarters"
			},
			{
				id: 256,
				disp_name: "Road to Iris Headquarters"
			},
			{
				id: 257,
				disp_name: "Road to Iris Headquarters"
			},
			{
				id: 259,
				disp_name: "Shibuno"
			},
			{
				id: 260,
				disp_name: "Shibuno"
			},
			{
				id: 261,
				disp_name: "Dahlia's Hideout"
			},
			{
				id: 262,
				disp_name: "Dahlia's Hideout"
			},
			{
				id: 269,
				disp_name: "Monster Research Lab"
			},
			{
				id: 270,
				disp_name: "Special Facility"
			},
			{
				id: 272,
				disp_name: "Sagara Dungeon"
			},
			{
				id: 273,
				disp_name: "Sagara Dungeon"
			},
			{
				id: 274,
				disp_name: "Special Facility"
			},
			{
				id: 275,
				disp_name: "Sagara Dungeon"
			},
			{
				id: 276,
				disp_name: "Sagara Dungeon"
			}
		];
		sp.bitmap.drawText($gameVariables.value(2), 130, 0, 300, 50, "left");

		var mapdata = data_map_name_list.find((e) => e.id == $gameMap._mapId);
		sp.bitmap.drawText(mapdata ? mapdata.disp_name : "？？？", 538, 0, 300, 50, "left");
		sp.bitmap.drawText($gameParty.gold(), 920, 0, 300, 50, "right");

		this._backgroundSprite.addChild(sp);

		this.addChild(this._backgroundSprite);
	};

	Scene_Menu.prototype.start = function () {
		Scene_MenuBase.prototype.start.call(this);
		//this._statusWindow.refresh();
	};
	Scene_Menu.prototype.create = function () {
		Scene_MenuBase.prototype.create.call(this);
		//this.createGoldWindow();
		this.createStatusWindow();
		this.createCommandWindow();
	};

	// ####################### キャラクターを選択する時のwindow ########################
	Scene_Menu.prototype.statusWindowRect = function () {
		const ww = Graphics.width;
		const wh = Graphics.height;
		const wx = 0;
		const wy = 0;
		return new Rectangle(wx, wy, ww, wh);
	};
	Scene_Menu.prototype.createStatusWindow = function () {
		const rect = this.statusWindowRect();
		this._statusWindow = new Window_MainMenuStatus(rect);
		this.addWindow(this._statusWindow);
	};

	function Window_MainMenuStatus() {
		this.initialize(...arguments);
	}
	Window_MainMenuStatus.prototype = Object.create(Window_MenuStatus.prototype);
	Window_MainMenuStatus.prototype.constructor = Window_MainMenuStatus;

	Window_MainMenuStatus.prototype.loadWindowskin = function () {
		this.windowskin = ImageManager.loadSystem("Window");
		this.menu_cursor_skin = ImageManager.loadSystem("menu_select");

		var party = $gameParty.allMembers();
		for (ac of party) {
			this._backgroundTextSprite = new Sprite(new Bitmap(200, 26));
			if (ac.name() == "Shirayuki") {
				this._backgroundTextSprite.x = 50;
				this._backgroundTextSprite.y = 412 + 30;
			} else {
				this._backgroundTextSprite.x = 1000 + 23;
				this._backgroundTextSprite.y = 412 + 30;
			}

			var b = this._backgroundTextSprite.bitmap;
			//グラデーションの描写
			const ctx = b.context;
			const grd = ctx.createLinearGradient(0, -20, 220, 0);
			grd.addColorStop(0, "rgba(255, 255, 255, 1)");
			grd.addColorStop(0.8, "rgba(255, 255, 255, 0)");
			ctx.fillStyle = grd;
			ctx.fillRect(0, 0, 200, 30);

			b.fontFace = "Times New Roman";
			b.fontSize = 22;
			b.textColor = "#FFFFFF";
			b.drawText(`LV　${ac._level}`, 8, 0, 200, 26, "left");
			this.addChild(this._backgroundTextSprite);
		}
	};

	Window_MainMenuStatus.prototype.maxCols = function () {
		return 2; // アクターの最大表示数
	};
	Window_MainMenuStatus.prototype.lineHeight = function () {
		return 650;
	};

	Window_MainMenuStatus.prototype.updatePadding = function () {
		this.padding = 0;
	};
	//セレクト位置を特殊仕様に
	Window_MainMenuStatus.prototype.itemRect = function (index) {
		const maxCols = this.maxCols();
		const itemWidth = this.itemWidth();
		const itemHeight = this.itemHeight();
		const colSpacing = this.colSpacing();
		const rowSpacing = this.rowSpacing();

		var party = $gameParty.allMembers();
		//夜鶴が戦闘の時
		var flag = index;
		if (party[0]._name == "Yotsuru") {
			var flag = index ? 0 : 1;
		}

		const col = flag % maxCols;
		const row = Math.floor(flag / maxCols);
		const x = col * (itemWidth + 195);
		const y = row * itemHeight + rowSpacing / 2 - this.scrollBaseY();
		const width = 440;
		const height = 650;
		return new Rectangle(x, y, width, height);
	};
	Window_MainMenuStatus.prototype.selectLast = function () {
		this.smoothSelect(0);
	};
	Window_MainMenuStatus.prototype._refreshAllParts = function () {
		//this._refreshBack();
		//this._refreshFrame();
		this._refreshCursor();
		this._refreshArrows();
		this._refreshPauseSign();
	};

	var Window_MainMenuStatus_refresh = Window_MainMenuStatus.prototype.refresh;
	Window_MainMenuStatus.prototype.refresh = function () {
		Window_MainMenuStatus_refresh.call(this);

		var party = $gameParty.allMembers();

		for (var i = 0; i < party.length; i++) {
			var x = 50;
			var y = 390 + 30;

			if (party[i]._name == "Yotsuru") {
				x += 950 + 23;
			}

			this.drawActor_st(party[i], x, y);
		}
	};

	Window_MainMenuStatus.prototype.drawActor_st = function (ac, x, y) {
		this.placeGauge(ac, "lv", x, y);
		this.placeGauge(ac, "hp", x, y + 50);
		this.placeGauge(ac, "mp", x, y + 100);
		this.placeGauge(ac, "exp", x, y + 150);

		// "人間", "魔物", etc., are set in common events with a 122 for variable 71 so these would also have to be translated, therefore, leave them as is
		var temp = [
			["人間", "Pregnant: Human"],
			["魔物", "Pregnant: Monster"],
			["ゴブリン", "Pregnant: Goblin"],
			["魔犬", "Pregnant: Demon Dog"],
			["魔豚", "Pregnant: Demon Pig"],
			["妖馬", "Pregnant: Demon Horse"],
			["卵", "Pregnant: Egg"],
			["触手", "Pregnant: Tentacle"],
			["犬", "Pregnant: Dog"],
			["豚", "Pregnant: Pig"],
			["馬", "Pregnant: Horse"],
			["オーク", "Pregnant: Orc"],
		];
		var st_text = "";
		var ac_var = [
			[182, 65, 184],
			[183, 66, 185]
		];
		var a = ac.name() == "Shirayuki" ? 0 : 1;

		var preg_state = $gameVariables.value(ac_var[a][0]);

		if (preg_state < 2) {
			if (ac.isStateAffected(4)) {
				st_text += "On the pill";
			} else if ($gameVariables.value(ac_var[a][1]) == 0) {
				st_text += "Cycle: Safe day";
			} else if ($gameVariables.value(ac_var[a][1]) == 1) {
				st_text += "Cycle: Normal day";
			} else {
				st_text += "Cycle: Risky day";
			}
		} else if (preg_state == 2) {
			st_text += "Pregnant: Early stage";
		} else {
			var idx = temp.findIndex((e) => e[0] == $gameVariables.value(ac_var[a][2]));
			if (idx !== -1) {
				st_text += temp[idx][1];
			}
		}

		this.contents.fontFace = "serif";
		this.contents.fontSize = 20;
		this.changeTextColor("#FFFFFF");
		this.drawText(st_text, x, 274 + 30, 180, "left");
	};

	Window_MainMenuStatus.prototype.placeGauge = function (actor, type, x, y) {
		const key = "actor%1-gauge-%2".format(actor.actorId(), type);
		const sprite = this.createInnerSprite(key, Sprite_Gauge_Main_Menu);
		sprite.setup(actor, type);
		sprite.move(x, y);
		sprite.show();
	};

	//コマンド欄の名前削除
	Window_MainMenuStatus.prototype.drawItem = function (index) {};
	//コマンド欄の背景削除
	Window_MainMenuStatus.prototype.drawItemBackground = function (index) {};
	Window_MainMenuStatus.prototype._refreshCursor = function () {
		const drect = this._cursorRect.clone();
		const srect = { x: 0, y: 0, width: 400, height: 250 };
		const m = 4;
		for (const child of this._cursorSprite.children) {
			child.bitmap = this.menu_cursor_skin;
		}
		this._setRectPartsGeometry(this._cursorSprite, srect, drect, m);
	};
	//カーソルを顔の位置の為に微調整
	Window_MainMenuStatus.prototype._updateCursor = function () {
		this._cursorSprite.alpha = this._makeCursorAlpha();
		this._cursorSprite.visible = this.isOpen() && this.cursorVisible;
		this._cursorSprite.x = this._cursorRect.x - this.index() * 88;
		var party = $gameParty.allMembers();

		//this._cursorSprite.x += 750 * this.index();
		// 夜鶴が戦闘の時;
		if (party[0]._name == "Yotsuru") {
			var temp = 84;
			this._cursorSprite.x -= temp + 2 * temp * this.index() * -1;
		}
		this._cursorSprite.y = this._cursorRect.y - 8;
	};

	// やっつけ
	Window_MainMenuStatus.prototype.cursorLeft = function (wrap) {
		const index = Math.max(0, this.index());
		const maxItems = this.maxItems();
		const maxCols = this.maxCols();
		const horizontal = this.isHorizontal();
		if (maxItems > 1) {
			if (maxCols >= 2 && (index > 0 || (wrap && horizontal))) {
				this.smoothSelect((index - 1 + maxItems) % maxItems);
			} else if (index == 0) {
				this.smoothSelect(1);
			}
		}
	};

	Window_MainMenuStatus.prototype.cursorRight = function (wrap) {
		const index = this.index();
		const maxItems = this.maxItems();
		const maxCols = this.maxCols();
		const horizontal = this.isHorizontal();
		if (maxItems > 1) {
			if (maxCols >= 2 && (index < maxItems - 1 || (wrap && horizontal))) {
				this.smoothSelect((index + 1) % maxItems);
			} else if (index == 1) {
				this.smoothSelect(0);
			}
		}
	};

	//カーソルを欄の大きさに合わせて伸ばさないようにする、マウス操作の為
	Window_MainMenuStatus.prototype._setRectPartsGeometry = function (sprite, srect, drect, m) {
		const sx = srect.x;
		const sy = srect.y;
		const sw = srect.width;
		const sh = srect.height;
		const dx = drect.x;
		const dy = drect.y;
		const dw = drect.width;
		const dh = drect.height;
		const smw = sw - m * 2;
		const smh = sh - m * 2;
		const dmw = dw - m * 2;
		const dmh = dh - m * 2;
		const children = sprite.children;
		sprite.setFrame(0, 0, dw, dh);
		sprite.move(dx, dy);
		// corner
		children[0].setFrame(sx, sy, m, m);
		children[1].setFrame(sx + sw - m, sy, m, m);
		children[2].setFrame(sx, sy + sw - m, m, m);
		children[3].setFrame(sx + sw - m, sy + sw - m, m, m);
		children[0].move(0, 0);
		children[1].move(dw - m, 0);
		children[2].move(0, dh - m);
		children[3].move(dw - m, dh - m);
		// edge
		children[4].move(m, 0);
		children[5].move(m, dh - m);
		children[6].move(0, m);
		children[7].move(dw - m, m);
		children[4].setFrame(sx + m, sy, smw, m);
		children[5].setFrame(sx + m, sy + sw - m, smw, m);
		children[6].setFrame(sx, sy + m, m, smh);
		children[7].setFrame(sx + sw - m, sy + m, m, smh);
		children[4].scale.x = dmw / smw;
		children[5].scale.x = dmw / smw;
		children[6].scale.y = dmh / smh;
		children[7].scale.y = dmh / smh;
		// center
		if (children[8]) {
			children[8].setFrame(sx + m, sy + m, smw, smh);
			children[8].move(m, m);
			//children[8].scale.x = dmw / smw;
			//children[8].scale.y = dmh / smh;
		}
		for (const child of children) {
			child.visible = dw > 0 && dh > 0;
		}
	};

	// ################ コマンドウィンドウ ########################
	Scene_Menu.prototype.commandWindowRect = function () {
		const ww = 380;
		const wh = 700;
		const wx = (Graphics.width - ww) / 2;
		const wy = 20;
		return new Rectangle(wx, wy, ww, wh);
	};

	Scene_Menu.prototype.createCommandWindow = function () {
		const rect = this.commandWindowRect();
		const commandWindow = new Window_MainMenuCommand(rect);
		commandWindow.setHandler("item", this.commandItem.bind(this));
		commandWindow.setHandler("skill", this.commandPersonal.bind(this));
		commandWindow.setHandler("equip", this.commandPersonal.bind(this));

		commandWindow.setHandler("eroStatus", this.commandPersonal.bind(this));

		commandWindow.setHandler("formation", this.commandFormation.bind(this));
		commandWindow.setHandler("options", this.commandOptions.bind(this));
		commandWindow.setHandler("save", this.commandSave.bind(this));
		commandWindow.setHandler("gameEnd", this.commandGameEnd.bind(this));
		commandWindow.setHandler("cancel", this.popScene.bind(this));

		commandWindow.setHandler("travel", this.commandTravel.bind(this));
		commandWindow.setHandler("ev_rec", this.commandEv_rec.bind(this));
		commandWindow.setHandler("side_episode", this.commandSideEpisode.bind(this));

		//コマンドの画像、微調整
		this._commandSprite = new Sprite();
		this._commandSprite.x = 50;
		this._commandSprite.y = -15;
		this._commandSprite.bitmap = ImageManager.loadSystem("menu_command");
		commandWindow.addChild(this._commandSprite);

		this.addWindow(commandWindow);
		this._commandWindow = commandWindow;
	};

	//################### メインメニューのコマンド ####################
	function Window_MainMenuCommand() {
		this.initialize(...arguments);
	}

	Window_MainMenuCommand.prototype = Object.create(Window_MenuCommand.prototype);
	Window_MainMenuCommand.prototype.constructor = Window_MainMenuCommand;

	Window_MainMenuCommand.prototype.addMainCommands = function () {
		const enabled = this.areMainCommandsEnabled();
		if (this.needsCommand("item")) {
			this.addCommand(TextManager.item, "item", enabled);
		}
		if (this.needsCommand("skill")) {
			this.addCommand(TextManager.skill, "skill", enabled);
		}
		if (this.needsCommand("equip")) {
			this.addCommand(TextManager.equip, "equip", enabled);
		}

		this.addCommand("Fast Travel", "travel", true); //trueで有効化
		this.addCommand("Event Log", "ev_rec", true); //trueで有効化
		this.addCommand("Side Episodes", "side_episode", true); //trueで有効化

		//if (this.needsCommand("status")) {
		this.addCommand(TextManager.status, "eroStatus", enabled);
		//}
	};

	Scene_Menu.prototype.onPersonalOk = function () {
		switch (this._commandWindow.currentSymbol()) {
			case "skill":
				SceneManager.push(Scene_Skill);
				break;
			case "equip":
				SceneManager.push(Scene_Equip);
				break;
			case "eroStatus":
				SceneManager.push(Scene_eroStatus);
				break;
		}
	};

	Window_MainMenuCommand.prototype.addFormationCommand = function () {};
	//選択時のカーソル
	Window_MainMenuCommand.prototype.loadWindowskin = function () {
		this.windowskin = ImageManager.loadSystem("Window");
		this.menu_cursor_skin = ImageManager.loadSystem("menu_cursor");
	};

	Window_MainMenuCommand.prototype._refreshCursor = function () {
		const drect = this._cursorRect.clone();
		const srect = { x: 0, y: 0, width: 380, height: 36 };
		const m = 4;
		for (const child of this._cursorSprite.children) {
			child.bitmap = this.menu_cursor_skin;
		}
		this._setRectPartsGeometry(this._cursorSprite, srect, drect, m);
	};

	//間隔含めたラインの高さ
	Window_MainMenuCommand.prototype.lineHeight = function () {
		return 56;
	};

	//コマンド欄の間隔、マウス操作の為なくす
	Window_MainMenuCommand.prototype.rowSpacing = function () {
		return 0;
	};

	Window_MainMenuCommand.prototype._refreshAllParts = function () {
		//this._refreshBack();
		//this._refreshFrame();
		this._refreshCursor();
		this._refreshArrows();
		this._refreshPauseSign();
	};

	// ファストトラベルの処理、スイッチ129が無い場合実行する
	Window_MainMenuCommand.prototype.processOk = function () {
		if (this.index() === 3 && !$gameSwitches.value(129)) {
			// 新たに処理を加える
			SoundManager.playBuzzer();
		} else {
			if (this.isCurrentItemEnabled()) {
				this.playOkSound();
				this.updateInputData();
				this.deactivate();
				this.callOkHandler();
			} else {
				this.playBuzzerSound();
			}
		}
	};

	//コマンド欄の名前削除
	Window_MainMenuCommand.prototype.drawItem = function (index) {};
	//コマンド欄の背景削除
	Window_MainMenuCommand.prototype.drawItemBackground = function (index) {};

	//カーソルを欄の大きさに合わせて伸ばさないようにする、マウス操作の為
	Window_MainMenuCommand.prototype._setRectPartsGeometry = function (sprite, srect, drect, m) {
		const sx = srect.x;
		const sy = srect.y;
		const sw = srect.width;
		const sh = srect.height;
		const dx = drect.x;
		const dy = drect.y;
		const dw = drect.width;
		const dh = drect.height;
		const smw = sw - m * 2;
		const smh = sh - m * 2;
		const dmw = dw - m * 2;
		const dmh = dh - m * 2;
		const children = sprite.children;
		sprite.setFrame(0, -16, dw, dh);
		sprite.move(dx, dy);
		// corner
		children[0].setFrame(sx, sy, m, m);
		children[1].setFrame(sx + sw - m, sy, m, m);
		children[2].setFrame(sx, sy + sw - m, m, m);
		children[3].setFrame(sx + sw - m, sy + sw - m, m, m);
		children[0].move(0, 0);
		children[1].move(dw - m, 0);
		children[2].move(0, dh - m);
		children[3].move(dw - m, dh - m);
		// edge
		children[4].move(m, 0);
		children[5].move(m, dh - m);
		children[6].move(0, m);
		children[7].move(dw - m, m);
		children[4].setFrame(sx + m, sy, smw, m);
		children[5].setFrame(sx + m, sy + sw - m, smw, m);
		children[6].setFrame(sx, sy + m, m, smh);
		children[7].setFrame(sx + sw - m, sy + m, m, smh);
		children[4].scale.x = dmw / smw;
		children[5].scale.x = dmw / smw;
		children[6].scale.y = dmh / smh;
		children[7].scale.y = dmh / smh;
		// center
		if (children[8]) {
			children[8].setFrame(sx + m, sy + m, smw, smh);
			children[8].move(m, m);
			children[8].scale.x = dmw / smw;
			//children[8].scale.y = dmh / smh;
		}
		for (const child of children) {
			child.visible = dw > 0 && dh > 0;
		}
	};
})();
