(function () {
	const _Scene_Base_createWindowLayer = Scene_Base.prototype.createWindowLayer;
	Scene_Equip.prototype.createWindowLayer = function () {
		_Scene_Base_createWindowLayer.call(this);
		this._windowLayer.x = 0;
		this._windowLayer.y = 0;
	};

	//#####################　メニューの背景変える　#####################
	Scene_Equip.prototype.createBackground = function () {
		this._backgroundSprite_sira = new Sprite();
		this._backgroundSprite_yozu = new Sprite();
		var name = $gameParty.menuActor()._name;
		this._backgroundSprite_sira.bitmap = ImageManager.loadSystem("menu_equip_back_sira");
		this._backgroundSprite_yozu.bitmap = ImageManager.loadSystem("menu_equip_back_yozu");
		if (name == "Shirayuki") {
			this._backgroundSprite_yozu.hide();
		} else if (name == "Yotsuru") {
			this._backgroundSprite_sira.hide();
		}

		this.addChild(this._backgroundSprite_yozu);
		this.addChild(this._backgroundSprite_sira);

		this._backgroundTextSprite = new Sprite(new Bitmap(Graphics.width, Graphics.height));
		var b = this._backgroundTextSprite.bitmap;
		b.fontFace = "serif";
		b.fontSize = 32;
		b.textColor = "#000000";
		b.drawTextM("装備", 22, 20, 200, 22, "center");
		this.addChild(this._backgroundTextSprite);

		this._backgroundTextSprite2 = new Sprite(ImageManager.loadSystem("menu_equip_seifuku_1"));
		this._backgroundTextSprite2.x = 838;
		this._backgroundTextSprite2.y = 630;

		//this.addChild(this._backgroundTextSprite2);
	};
	// 背景切り替え
	Scene_Equip.prototype.refreshActor = function () {
		const actor = this.actor();
		this._statusWindow.setActor(actor);
		this._slotWindow.setActor(actor);
		this._itemWindow.setActor(actor);

		if (actor._name == "Shirayuki") {
			this._backgroundSprite_sira.show();
			this._backgroundSprite_yozu.hide();
		} else if (actor._name == "Yotsuru") {
			this._backgroundSprite_sira.hide();
			this._backgroundSprite_yozu.show();
		}
	};
	Scene_Equip.prototype.create = function () {
		Scene_MenuBase.prototype.create.call(this);
		this.createStatusWindow();
		this.createCommandWindow();
		this.createSlotWindow();
		this.createItemWindow();
		this.createHelpWindow();

		this._itemWindow.setHelpWindow(this._helpWindow);
		this.refreshActor();
	};

	//最強と全て外すを消去し、別キャラクター追加
	Window_EquipCommand.prototype.makeCommandList = function () {
		this.addCommand(TextManager.equip2, "equip");
		this.addCommand("別キャラクター", "pagedown");
	};

	Scene_Equip.prototype.commandWindowRect = function () {
		const wx = 270;
		const wy = -14;
		const ww = 400;
		const wh = 58 + 38;
		return new Rectangle(wx, wy, ww, wh);
	};
	Window_EquipCommand.prototype.maxCols = function () {
		return 2;
	};

	// デザイン関係
	//カーソルの変更
	Window_EquipCommand.prototype.loadWindowskin = function () {
		this.windowskin = ImageManager.loadSystem("Window");
		this.menu_item_skin = ImageManager.loadSystem("menu_item_categoly_select");
		this.menu_cursor_skin = ImageManager.loadSystem("menu_item_categoly_cursor");

		if (!this.menu_item_skin.isReady()) {
			this.menu_item_skin.addLoadListener(() => {
				this.refresh(); // 画像がロードされたら再描画
			});
			return;
		}
	};

	Window_EquipCommand.prototype.lineHeight = function () {
		return 58;
	};

	Window_EquipCommand.prototype._refreshCursor = function () {
		const drect = this._cursorRect.clone();
		const srect = { x: 0, y: 0, width: 126, height: 58 };
		const m = 0;
		for (const child of this._cursorSprite.children) {
			child.bitmap = this.menu_cursor_skin;
		}
		this._setRectPartsGeometry(this._cursorSprite, srect, drect, m);
	};
	//カーソルを微調整、あとカーソルを常に不透明に
	Window_EquipCommand.prototype._updateCursor = function () {
		this._cursorSprite.alpha = 255;
		this._cursorSprite.visible = this.isOpen() && this.cursorVisible;
		this._cursorSprite.x = this._cursorRect.x;
		this._cursorSprite.y = this._cursorRect.y - 4;
	};
	//未選択コマンドの背景を画像に
	Window_EquipCommand.prototype.drawItemBackground = function (index) {
		const rect = this.itemRect(index);
		if (this.menu_item_skin.isReady()) {
			const bitmap = this.menu_item_skin;
			const dx = rect.x;
			const dy = rect.y;
			const dw = rect.width;
			const dh = rect.height;
			this.contentsBack.blt(bitmap, 0, 0, 126, 58, dx, dy - 4, dw, dh);
		}
	};

	//カーソルが来た時、アイテムの文字名の色を変更する
	Window_EquipCommand.prototype.drawItem = function (index) {
		const rect = this.itemLineRect(index);
		const align = this.itemTextAlign();
		this.resetTextColor();
		if (index == this._index) {
			this.changeTextColor("#000000");
		}
		this.changePaintOpacity(this.isCommandEnabled(index));
		//文字をちょっと下にする
		this.drawTextS(this.commandName(index), rect.x, rect.y + 8, rect.width, align);
	};

	//セレクトするたびに背景をリフレッシュ
	Window_EquipCommand.prototype.select = function (index) {
		this._index = index;

		this.contents.clear();
		this.contentsBack.clear();
		this.drawAllItems();

		this.refreshCursor();
		this.callUpdateHelp();
	};
	//↑のセレクトでの不具合を出ないようにする
	Window_EquipCommand.prototype.drawAllItems = function () {
		this.contents.fontFace = "serif";
		const topIndex = this.topIndex();
		for (let i = 0; i < this.maxVisibleItems(); i++) {
			const index = topIndex + i;

			if (this._list && index < this.maxItems()) {
				//選択ちゅうだけ背景なくす
				if (i != this._index) {
					this.drawItemBackground(index);
				}
				this.drawItem(index);
			}
		}
	};

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

	// ###########################################################
	// ################### ステータスウィンドウ ####################
	// ###########################################################
	Scene_Equip.prototype.statusWindowRect = function () {
		const ww = 700;
		const wh = 250;
		const wx = 0;
		const wy = 450;
		return new Rectangle(wx, wy, ww, wh);
	};
	Scene_Equip.prototype.createStatusWindow = function () {
		const rect = this.statusWindowRect();
		this._statusWindow = new Window_EquipStatus(rect);
		this.addWindow(this._statusWindow);
	};

	Window_EquipStatus.prototype._refreshAllParts = function () {
		this._padding = 0;
		//this._refreshBack();
		//this._refreshFrame();
		this._refreshCursor();
		this._refreshArrows();
		this._refreshPauseSign();
	};
	Window_EquipStatus.prototype.resetFontSettings = function () {
		this.contents.fontFace = "ヒラギノ明朝 ProN W3";
		this.contents.fontSize = $gameSystem.mainFontSize();
		this.resetTextColor();
	};

	Window_EquipStatus.prototype.refresh = function () {
		this.contents.clear();
		if (this._actor) {
			const nameRect = this.itemLineRect(0);
			//this.drawActorName(this._actor, nameRect.x, 0, nameRect.width);
			//this.drawActorFace(this._actor, nameRect.x, nameRect.height);
			this.drawAllParams();

			this.changeTextColor("#000000");
			this.contents.fontFace = "serif";
			this.contents.fontSize = 22;
			this.drawTextM("アーティファクト", 65, 204, 300);
			//var weap = this._actor.equips()[6];
			//if (weap) {
			this.contents.fontSize = 26;
			this.changeTextColor("#FFFFFF");
			if ($gameParty.menuActor()._actorId === 1) {
				this.drawTextM($gameVariables.value(225), 290, 203, 300);
			} else {
				this.drawTextM($gameVariables.value(226), 290, 203, 300);
			}
			//}
		}
	};

	Window_EquipStatus.prototype.drawAllParams = function () {
		this.contents.fontSize = 25;
		for (let i = 0; i < 5; i++) {
			const x = this.itemPadding() + 40;
			const y = i * 28 + 27;
			this.drawItem(x, y, 2 + i);
		}
	};
	Window_EquipStatus.prototype.drawItem = function (x, y, paramId) {
		const paramX = 150;
		const paramWidth = this.paramWidth();
		const rightArrowWidth = this.rightArrowWidth();
		this.drawParamName(x, y, paramId);
		if (this._actor) {
			this.drawCurrentParam(paramX, y, paramId);
		}
		this.drawRightArrow(paramX - 30, y);
		if (this._tempActor) {
			//this.drawNewParam(paramX + paramWidth + rightArrowWidth, y, paramId);
		}
	};

	Window_EquipStatus.prototype.drawParamName = function (x, y, paramId) {
		const width = this.paramX() - this.itemPadding() * 2;
		this.changeTextColor("#000000");
		this.contents.fontFace = "serif";
		this.contents.fontSize = 19;
		this.drawTextM(TextManager.param(paramId), x, y, width);
	};

	Window_EquipStatus.prototype.drawCurrentParam = function (x, y, paramId) {
		const paramWidth = this.paramWidth();
		this.changeTextColor("#000000");
		this.drawTextM(this._actor.paramBase(paramId), x, y, paramWidth, "right");

		this.changeTextColor("#FFFFFF");
		this.drawText(this._actor.param(paramId) - this._actor.paramBase(paramId), 238, y, paramWidth, "right");
	};

	Window_EquipStatus.prototype.drawRightArrow = function (x, y) {
		const rightArrowWidth = this.rightArrowWidth();
		this.changeTextColor("#000000");
		this.drawTextM("：", x, y, rightArrowWidth, "center");
		this.changeTextColor("#FFFFFF");
		this.drawTextM("＋", x + 104, y, rightArrowWidth, "center");
	};

	// ###########################################################
	// ###################### 装備欄スロット ######################
	// ###########################################################
	Scene_Equip.prototype.slotWindowRect = function () {
		const wx = 740;
		const wy = 80;
		const ww = Graphics.boxWidth - wx;
		const wh = Graphics.boxHeight - wy;
		return new Rectangle(wx, wy, ww, wh);
	};

	//コマンド変更
	Scene_Equip.prototype.createCommandWindow = function () {
		const rect = this.commandWindowRect();
		this._commandWindow = new Window_EquipCommand(rect);
		this._commandWindow.setHelpWindow(this._helpWindow);
		this._commandWindow.setHandler("equip", this.commandEquip.bind(this));
		//キーボードでの誤操作防止
		//this._commandWindow.setHandler("optimize", this.commandOptimize.bind(this));
		//this._commandWindow.setHandler("clear", this.commandClear.bind(this));
		this._commandWindow.setHandler("cancel", this.popScene.bind(this));
		this._commandWindow.setHandler("pagedown", this.nextActor.bind(this));
		this._commandWindow.setHandler("pageup", this.previousActor.bind(this));
		this.addWindow(this._commandWindow);
	};

	Scene_Equip.prototype.onSlotOk = function () {
		if (this._slotWindow.index() === 6) {
			if ($gameParty.menuActor()._actorId === 1) {
				$gameTemp.reserveCommonEvent(907);
			} else {
				$gameTemp.reserveCommonEvent(908);
			}

			SceneManager.goto(Scene_Map);
		} else {
			this._slotWindow.hide();
			this._itemWindow.show();
			this._itemWindow.activate();
			this._itemWindow.forceSelect(0);
			this._helpWindow.show();
		}
	};

	//装備欄
	Window_EquipSlot.prototype.maxCols = function () {
		return 1;
	};

	Window_EquipSlot.prototype.initialize = function (rect) {
		Window_StatusBase.prototype.initialize.call(this, rect);
		this._actor = null;
		this.refresh();

		// 装備禁止の時は１
		this.CBR_ban = 0;
	};

	Window_EquipSlot.prototype.maxItems = function () {
		return this._actor ? this._actor.equipSlots().length - this.CBR_ban : 0;
	};

	Window_EquipSlot.prototype.itemRect = function (index) {
		const maxCols = this.maxCols();
		var itemWidth = 498;
		const itemHeight = this.itemHeight() + 16;
		const colSpacing = this.colSpacing();
		const rowSpacing = this.rowSpacing() + 16;
		var row = index;
		var x = 30;

		var y = row * itemHeight + rowSpacing / 2 - this.scrollBaseY() + 48;

		if (2 < index) {
			y += 41;
		}

		if (index == 6) {
			y += 44;
		}

		const width = itemWidth - colSpacing;
		const height = itemHeight - rowSpacing;
		return new Rectangle(x, y, width, height);
	};

	Window_EquipSlot.prototype.loadWindowskin = function () {
		this.windowskin = ImageManager.loadSystem("Window");
		this.menu_item_skin = ImageManager.loadSystem("menu_equip_item");
		this.menu_cursor_skin = ImageManager.loadSystem("menu_equip_cursor");

		// キャラクターイメージの描写
		// const sprite = new Sprite(ImageManager.loadCharacter("00_MainChara01"));
		// sprite.setFrame(0, 0, 48, 48);
		// sprite.x = 300; // 表示位置（調整可）
		// sprite.y = 500;

		// this.fuku_sp = sprite;
		// this.addChild(sprite);
	};

	Window_EquipSlot.prototype._createCursorSprite = function () {
		this._cursorSprite = new Sprite();
		for (let i = 0; i < 9; i++) {
			this._cursorSprite.addChild(new Sprite());
		}
		this._clientArea.addChild(this._cursorSprite);
	};

	Window_EquipSlot.prototype._updateCursor = function () {
		this._cursorSprite.alpha = 255;
		this._cursorSprite.visible = this.isOpen() && this.cursorVisible;
		this._cursorSprite.x = this._cursorRect.x;
		this._cursorSprite.y = this._cursorRect.y;

		const b = this._cursorTextSprite.bitmap;
		b.clear();
		b.fontFace = "serif";
		b.fontSize = 24;
		b.textColor = "#000000";
		b.drawTextM(this.index() === 6 ? "服装変更" : "装備", 0, 0, b.width, b.height, "center");
	};

	Window_EquipSlot.prototype._refreshCursor = function () {
		const drect = this._cursorRect.clone();
		const srect = { x: 0, y: 0, width: 170, height: 60 };
		const m = 0;
		for (const child of this._cursorSprite.children) {
			if (!child.CBR_flag) {
				child.bitmap = this.menu_cursor_skin;
			}
		}
		this._setRectPartsGeometry2(this._cursorSprite, srect, drect, m);

		// すでに作っていなければ作成
		if (!this._cursorTextSprite) {
			this._cursorTextSprite = new Sprite(new Bitmap(100, 32));
			this._cursorTextSprite.CBR_flag = true;

			this._cursorTextSprite.x = 30;
			this._cursorTextSprite.y = 14;

			const b = this._cursorTextSprite.bitmap;
			b.clear();
			b.fontFace = "serif";
			b.fontSize = 24;
			b.textColor = "#000000";
			b.drawTextM("装備", 0, 0, b.width, b.height, "center");

			this._cursorSprite.addChild(this._cursorTextSprite);
		}
	};

	Window_EquipSlot.prototype.refresh = function () {
		this.hideAdditionalSprites();
		Window_Selectable.prototype.refresh.call(this);

		this.contents.fontFace = "serif";
		this.contents.fontSize = 24;
		this.contents.textColor = "#000000";
		this.drawTextM("アクセサリー", 128, 10, 300, "center");
		this.drawTextM("パッシブスキル", 128, 232, 300, "center");
		this.drawTextM("服装変更", 128, 454, 300, "center");

		this.contents.fontSize = 20;
		this.contents.textColor = "#FFFFFF";
		if (this.CBR_ban) {
			this.drawTextS("更衣条件：露出開発度がＢ以上", 224, 505, 300, "left");
		} else {
			const fuku_id = $gameParty.menuActor()._name == "Shirayuki" ? 204 : 205;
			this.drawText(["制服", "裸", "制服", "裸"][$gameVariables.value(fuku_id)], 224, 505, 300, "left");
		}
	};

	Window_EquipSlot.prototype._setRectPartsGeometry2 = function (sprite, srect, drect, m) {
		const dx = drect.x;
		const dy = drect.y;
		const dw = drect.width;
		const dh = drect.height;
		const children = sprite.children;
		sprite.move(dx, dy);
		for (const child of children) {
			child.visible = dw > 0 && dh > 0;
		}
	};
	Window_EquipSlot.prototype.refreshCursor = function () {
		if (this._cursorAll) {
			this.refreshCursorForAll();
		} else if (this.index() >= 0) {
			const rect = this.itemRect(this.index());
			this.setCursorRect(rect.x + 7, rect.y - 8, rect.width, rect.height);
		} else {
			this.setCursorRect(0, 0, 0, 0);
		}
	};

	Window_EquipSlot.prototype.drawItemBackground = function () {};

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

	Window_EquipSlot.prototype.drawItem = function (index) {
		if (this._actor) {
			const slotName = this.actorSlotName(this._actor, index);
			const item = this.itemAt(index);
			const slotNameWidth = this.slotNameWidth();
			const rect = this.itemLineRect(index);
			const itemWidth = rect.width - slotNameWidth;
			//this.changeTextColor(ColorManager.systemColor());
			this.changePaintOpacity(this.isEnabled(index));
			//this.drawText(slotName, rect.x, rect.y, slotNameWidth, rect.height);
			this.drawItemName(item, rect.x + slotNameWidth + 10, rect.y, itemWidth);
			this.changePaintOpacity(true);
		}
	};
	Window_EquipSlot.prototype.drawItemName = function (item, x, y, width) {
		if (item) {
			const iconY = y + (this.lineHeight() - ImageManager.iconHeight) / 2;
			const delta = ImageManager.standardIconWidth - ImageManager.iconWidth;
			const textMargin = ImageManager.standardIconWidth + 4;
			const itemWidth = Math.max(0, width - textMargin);
			this.resetTextColor();
			//this.drawIcon(item.iconIndex, x + delta / 2, iconY);
			this.drawText(item.name, x + textMargin, y, itemWidth);
		}
	};

	// ###########################################################
	// ##################### アイテム一覧ウィンドウ ###################
	// ###########################################################
	Scene_Equip.prototype.createItemWindow = function () {
		const rect = this.itemWindowRect();
		this._itemWindow = new Window_EquipItem(rect);
		this._itemWindow.setHelpWindow(this._helpWindow);
		this._itemWindow.setStatusWindow(this._statusWindow);
		this._itemWindow.setHandler("ok", this.onItemOk.bind(this));
		this._itemWindow.setHandler("cancel", this.onItemCancel.bind(this));
		this._itemWindow.hide();
		this._slotWindow.setItemWindow(this._itemWindow);
		this.addWindow(this._itemWindow);
	};

	Scene_Equip.prototype.itemWindowRect = function () {
		const wx = 0;
		const wh = Graphics.height;
		const wy = Graphics.height - wh;
		const ww = Graphics.width;

		return new Rectangle(wx, wy, ww, wh);
	};
	Window_EquipItem.prototype.initialize = function (rect) {
		Window_ItemList.prototype.initialize.call(this, rect);
		this._actor = null;
		this._slotId = 0;

		this._customBackgroundSprite = new Sprite(ImageManager.loadSystem("menu_equip_item_back")); // img/system/text.png
		this._customBackgroundSprite.opacity = 255;
		this.addChildToBack(this._customBackgroundSprite);

		this._bSprite = new Sprite(new Bitmap(Graphics.width, Graphics.height));
		var b = this._bSprite.bitmap;
		b.fontFace = "serif";
		b.fontSize = 18;
		b.textColor = "#000000";
		b.drawTextM("所持数", 570, 72, 200, 22, "center");
		this.addChild(this._bSprite);

		// windowが重なっても透過させる
		this._isWindow = false;
	};
	Window_EquipItem.prototype.maxCols = function () {
		return 1;
	};

	Scene_Equip.prototype.hideItemWindow = function () {
		this._slotWindow.show();
		this._slotWindow.activate();
		this._itemWindow.hide();
		this._itemWindow.deselect();
		this._helpWindow.hide();
	};
	Window_EquipItem.prototype.paint = function () {
		if (this.contents) {
			this.contents.clear();
			this.contentsBack.clear();
			this.drawAllItems();
		}
	};
	//未選択コマンドの背景を画像に
	Window_EquipItem.prototype.drawItemBackground = function (index) {
		const rect = this.itemRect(index);
		if (this.menu_item_skin) {
			const bitmap = this.menu_item_skin;
			const dx = rect.x;
			const dy = rect.y;
			const dw = rect.width;
			const dh = rect.height;
			this.contentsBack.blt(bitmap, 0, 0, 588, 40, dx, dy, dw, dh);
		}
	};
	const _Window_EquipItem_update = Window_EquipItem.prototype.update;
	Window_EquipItem.prototype.update = function () {
		_Window_EquipItem_update.call(this);
		if (this._customBackgroundSprite && this._customBackgroundSprite.bitmap) {
			this._customBackgroundSprite.x = 0;
			this._customBackgroundSprite.y = 0;
			this._customBackgroundSprite.scale.x = this.width / this._customBackgroundSprite.bitmap.width;
			this._customBackgroundSprite.scale.y = this.height / this._customBackgroundSprite.bitmap.height;
		}
	};

	const _Window_EquipItem_destroy = Window_EquipItem.prototype.destroy;
	Window_EquipItem.prototype.destroy = function (options) {
		if (this._customBackgroundSprite) {
			this.removeChild(this._customBackgroundSprite);
			this._customBackgroundSprite.destroy();
			this._customBackgroundSprite = null;
		}
		_Window_EquipItem_destroy.call(this, options);
	};

	// ウィンドウの背景を変更する
	Window_EquipItem.prototype.updateBackOpacity = function () {
		this.backOpacity = 255;
	};

	//カーソルの変更
	Window_EquipItem.prototype.loadWindowskin = function () {
		this.windowskin = ImageManager.loadSystem("Window");
		this.menu_cursor_skin = ImageManager.loadSystem("menu_item_selected");
		this.menu_item_skin = ImageManager.loadSystem("menu_item_selected_2");
	};
	Window_EquipItem.prototype.drawItemName = function (item, x, y, width) {
		if (item) {
			const iconY = y + (this.lineHeight() - ImageManager.iconHeight) / 2;
			const delta = ImageManager.standardIconWidth - ImageManager.iconWidth;
			const textMargin = ImageManager.standardIconWidth + 4;
			const itemWidth = Math.max(0, width - textMargin);
			this.resetTextColor();
			this.contents.fontSize = $gameSystem.mainFontSize();
			this.contents.fontFace = "serif";
			//this.drawIcon(item.iconIndex, x + delta / 2, iconY);
			this.changeTextColor("#000000");
			this.drawTextS(item.name, x + textMargin + 24, y, itemWidth);
			this.resetTextColor();
		}
	};
	Window_EquipItem.prototype.drawItemNumber = function (item, x, y, width) {
		if (this.needsNumber()) {
			this.changeTextColor("#000000");
			this.drawTextS($gameParty.numItems(item), x - 30, y, width, "right");
			this.resetTextColor();
		}
	};
	Window_EquipItem.prototype._refreshCursor = function () {
		const drect = this._cursorRect.clone();
		const srect = { x: 0, y: 40, width: 588, height: 40 };
		const m = 0;
		for (const child of this._cursorSprite.children) {
			child.bitmap = this.menu_item_skin;
		}
		this._setRectPartsGeometry(this._cursorSprite, srect, drect, m);
	};

	//########### ウィンドウのセレクトをセンタリングする ###################
	Object.defineProperty(Window_EquipItem.prototype, "innerWidth", {
		get: function () {
			return 500;
		},
		configurable: true
	});

	// アイテム表示領域の変更
	Object.defineProperty(Window_EquipItem.prototype, "innerHeight", {
		get: function () {
			return 440;
		},
		configurable: true
	});

	Object.defineProperty(Window_EquipItem.prototype, "innerRect", {
		get: function () {
			return new Rectangle(264, this._padding, this.innerWidth, this.innerHeight);
		},
		configurable: true
	});
	Window_EquipItem.prototype._createClientArea = function () {
		this._clientArea = new Sprite();
		this._clientArea.filters = [new PIXI.filters.AlphaFilter()];
		this._clientArea.filterArea = new Rectangle();
		this._clientArea.move(264, this._padding);
		this.addChild(this._clientArea);
	};
	Window_EquipItem.prototype._updateClientArea = function () {
		const pad = this._padding;
		this._clientArea.move(264, pad);
		this._clientArea.x = 264 - this.origin.x;
		this._clientArea.y = pad - this.origin.y + 93;
		if (this.innerWidth > 0 && this.innerHeight > 0) {
			this._clientArea.visible = this.isOpen();
		} else {
			this._clientArea.visible = false;
		}
	};

	// 表示領域をズラした分だけマウス操作のエリアを調整
	Window_EquipItem.prototype.hitTest = function (x, y) {
		y -= 93;

		if (this.innerRect.contains(x, y)) {
			const cx = this.origin.x + x - 264;
			const cy = this.origin.y + y - this.padding;
			const topIndex = this.topIndex();
			for (let i = 0; i < this.maxVisibleItems(); i++) {
				const index = topIndex + i;
				if (index < this.maxItems()) {
					const rect = this.itemRect(index);
					if (rect.contains(cx, cy)) {
						return index;
					}
				}
			}
		}
		return -1;
	};

	// ホイールの挙動が認識される範囲修正
	Window_EquipItem.prototype.isTouchedInsideFrame = function () {
		const touchPos = new Point(TouchInput.x, TouchInput.y - 93);
		const localPos = this.worldTransform.applyInverse(touchPos);
		return this.innerRect.contains(localPos.x, localPos.y);
	};

	// スクロールの矢印の位置を微調整
	Window_EquipItem.prototype._refreshArrows = function () {
		const w = this._width;
		const h = this._height;
		const p = 24;
		const q = p / 2;
		const sx = 96 + p;
		const sy = 0 + p;
		this._downArrowSprite.bitmap = this._windowskin;
		this._downArrowSprite.anchor.x = 0.5;
		this._downArrowSprite.anchor.y = 0.5;
		this._downArrowSprite.setFrame(sx + q, sy + q + p, p, q);
		this._downArrowSprite.move(w / 2 - 120, h - q - 154);
		this._upArrowSprite.bitmap = this._windowskin;
		this._upArrowSprite.anchor.x = 0.5;
		this._upArrowSprite.anchor.y = 0.5;
		this._upArrowSprite.setFrame(sx + q, sy, p, q);
		this._upArrowSprite.move(w / 2 - 120, q + 84);
	};

	//ウィンドウのバックグラウンド
	Window_EquipItem.prototype._refreshAllParts = function () {
		// this._refreshBack();
		// this._refreshFrame();
		this._refreshCursor();
		this._refreshArrows();
		this._refreshPauseSign();
	};

	// ###########################################################
	// ###################### ヘルプウィンドウ ####################
	// ###########################################################
	Scene_Equip.prototype.createHelpWindow = function () {
		const rect = this.helpWindowRect();
		this._helpWindow = new Window_EquipHelp(rect);
		this._helpWindow.hide();
		//this._itemWindow.hide();
		this.addWindow(this._helpWindow);
	};

	Scene_MenuBase.prototype.helpWindowRect = function () {
		const ww = 720;
		const wx = 40;
		const wh = 89;
		const wy = 570;
		return new Rectangle(wx, wy, ww, wh);
	};

	function Window_EquipHelp() {
		this.initialize(...arguments);
	}
	Window_EquipHelp.prototype = Object.create(Window_Help.prototype);
	Window_EquipHelp.prototype.constructor = Window_EquipHelp;

	const _Window_EquipHelp_initialize = Window_EquipHelp.prototype.initialize;

	Window_EquipHelp.prototype.initialize = function (rect) {
		_Window_EquipHelp_initialize.call(this, rect);
		this._customBackgroundSprite = new Sprite();
		this._customBackgroundSprite.bitmap = ImageManager.loadSystem("menu_equip_help_back"); // img/system/text.png
		this._customBackgroundSprite.opacity = 255;
		this.addChildToBack(this._customBackgroundSprite);

		// windowが重なっても透過させる
		this._isWindow = false;
	};

	const _Window_EquipHelp_update = Window_EquipHelp.prototype.update;
	Window_EquipHelp.prototype.update = function () {
		_Window_EquipHelp_update.call(this);
		if (this._customBackgroundSprite && this._customBackgroundSprite.bitmap) {
			this._customBackgroundSprite.x = 0;
			this._customBackgroundSprite.y = 10;
			this._customBackgroundSprite.scale.x = this.width / this._customBackgroundSprite.bitmap.width;
			this._customBackgroundSprite.scale.y = this.height / this._customBackgroundSprite.bitmap.height;
		}
	};

	const _Window_EquipHelp_destroy = Window_EquipHelp.prototype.destroy;
	Window_EquipHelp.prototype.destroy = function (options) {
		if (this._customBackgroundSprite) {
			this.removeChild(this._customBackgroundSprite);
			this._customBackgroundSprite.destroy();
			this._customBackgroundSprite = null;
		}
		_Window_EquipHelp_destroy.call(this, options);
	};

	Window_EquipHelp.prototype.refresh = function () {
		const rect = this.baseTextRect();
		this.contents.clear();

		this.contents.fontFace = "serif";
		this.changeTextColor("#000000");
		this.contents.fontSize = 20;
		this.drawTextM("概要", 0, -3, 80, "center");

		this.changeTextColor("#FFFFFF");
		this.drawTextExS(this._text, rect.x + 88, rect.y + 2, rect.width);
	};

	//ウィンドウのバックグラウンド
	Window_EquipHelp.prototype._refreshAllParts = function () {
		//this._refreshBack();
		//this._refreshFrame();
		this._refreshCursor();
		this._refreshArrows();
		this._refreshPauseSign();
	};
})();
