function Window_EroStatus_kiroku() {
	this.initialize(...arguments);
}

(function () {
	Window_EroStatus_kiroku.prototype = Object.create(Window_Base.prototype);
	Window_EroStatus_kiroku.prototype.constructor = Window_EroStatus_kiroku;

	// padding0を適用させる
	Object.defineProperty(Window_EroStatus_kiroku.prototype, "padding", {
		get: function () {
			return 0;
		},
		set: function (value) {
			this._padding = 0;
			this._refreshAllParts();
		},
		configurable: true
	});

	Window_EroStatus_kiroku.prototype.initialize = function (rect) {
		Window_Base.prototype.initialize.call(this, rect);
		this._padding = 0;
		this._margin = 0;
		this.refresh();
	};

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

	Window_EroStatus_kiroku.prototype.refresh = function () {
		this.contents.clear();
		var actor = $gameParty.menuActor();
		var chara = actor.name() == "Shirayuki" ? "sira" : "yozu";

		var bitmap = ImageManager.loadSystem("erost_kiroku_frame");
		this.contents.blt(bitmap, 0, 0, 1280, 720, 0, -65);
		if (!bitmap.isReady()) {
			bitmap.addLoadListener(() => {
				this.refresh(); // 画像がロードされたら再描画
			});
			return;
		}
		this.contents.fontFace = "serif";
		this.contents.fontSize = 18;
		var sX = 24;
		var sY = 547;
		var lineX = 172;
		var lineX2 = 228;
		var sX2 = 622;

		this.changeTextColor("#FFFFFF");
		this.drawTextS("Partner:", sX + lineX, sY, 200);
		this.drawTextS("Race:", sX + lineX + lineX2, sY, 200);

		this.drawTextS("Partner:", sX + sX2 + lineX, sY, 200);
		this.drawTextS("Race:", sX + sX2 + lineX + lineX2, sY, 200);

		var ary = {
			sira: {
				switch: { virgin: 202, anal_virgin: 203 },
				vari: { virgin: 242, anal_virgin: 243 }
			},
			yozu: {
				switch: { virgin: 205, anal_virgin: 206 },
				vari: { virgin: 322, anal_virgin: 323 }
			}
		};

		if ($gameSwitches.value(ary[chara].switch.virgin)) {
			if ($gameVariables.value(ary[chara].vari.virgin) != 0) {
				const d1 = CBR_eroRireki[$gameVariables.value(ary[chara].vari.virgin) - 1];
				this.drawTextS(d1.target, sX + lineX + 62, sY, 300);
				this.drawTextS(d1.job, sX + lineX + lineX2 + 62, sY, 300);
				this.drawTextExS(d1.text, sX, sY + 32, 300);
			}
		}

		if ($gameSwitches.value(ary[chara].switch.anal_virgin)) {
			if ($gameVariables.value(ary[chara].vari.anal_virgin) != 0) {
				const d2 = CBR_eroRireki[$gameVariables.value(ary[chara].vari.anal_virgin) - 1];
				this.drawTextS(d2.target, sX + sX2 + lineX + 62, sY, 300);
				this.drawTextS(d2.job, sX + sX2 + lineX + lineX2 + 62, sY, 300);
				this.drawTextExS(d2.text, sX + sX2, sY + 32, 300);
			}
		}

		this.changeTextColor("#000000");
		this.drawTextS("Virginity Loss", sX, sY, 200);
		this.drawTextS("Anal Virginity Loss", sX + sX2, sY, 200);

		this.contents.fontSize = 20;

		var sY = 25;
		var lineY = 27;
		var sX = 330;
		var lineX = 314;
		var skip = 0;
		var w = 288;
		var sX2 = 144;

		var width = this.textWidth("H Experience");
		this.drawTextS("H Experience", sX - width / 2 + sX2, 0, width);

		var width = this.textWidth("Partners");
		this.drawTextS("Partners", sX - width / 2 + sX2 + lineX, 0, width);
		var width = this.textWidth("Climax/Ejaculation");
		this.drawTextS("Climax/Ejaculation", sX - width / 2 + sX2 + lineX, lineY * 4 + 2, width);
		var width = this.textWidth("Situations");
		this.drawTextS("Situations", sX - width / 2 + sX2 + lineX, lineY * 12 + 4, width);

		var width = this.textWidth("Sex Work");
		this.drawTextS("Sex Work", sX - width / 2 + sX2 + lineX * 2, 0, width);
		var width = this.textWidth("Births");
		this.drawTextS("Births", sX - width / 2 + sX2 + lineX * 2, lineY * 7 + 2, width);

		this.contents.fontSize = 18;
		this.changeTextColor("#FFFFFF");
		var list = [
			{ text: "Sex", sira: 262, yozu: 342 },
			{ text: "Anal Sex", sira: 263, yozu: 343 },
			{ text: "Fellatio", sira: 264, yozu: 344 },
			{ text: "Titjob", sira: 265, yozu: 345 },
			{ text: "Handjob", sira: 266, yozu: 346 },
			{ text: "Cunnilingus", sira: 267, yozu: 347 },
			{ text: "Kiss", sira: 268, yozu: 348 },
			{ text: "Breast Grope", sira: 269, yozu: 349 },
			{ text: "Ass Grope", sira: 270, yozu: 350 },
			{ text: "Fingering", sira: 271, yozu: 351 },
			{ text: "Anal Play", sira: 272, yozu: 352 },
			{ text: "Masturbation", sira: 273, yozu: 353 },
			{ text: "Anal Masturbation", sira: 274, yozu: 354 },
			{ text: "Toilet", sira: 275, yozu: 355 },
			{ text: "Exhibition Play", sira: 276, yozu: 356 },
			{ text: "Deflowering", sira: 278, yozu: 358 },
			{ text: "Lesbian Sex", sira: 279, yozu: 359 },
			{ text: "Incest", sira: 280, yozu: 360 }
		];
		for (var i = 0; i < 18; i++) {
			//左上のコンテンツ
			this.drawTextS(list[i].text, sX, sY + lineY * i, 300);
			this.drawTextS(
				`${$gameVariables.value(list[i][chara]).clamp(0, 9999999)} ${list[i].unit ? list[i].unit : "x"}`,
				sX,
				sY + lineY * i,
				w,
				"right"
			);
		}

		var list = [
			{ text: "Human", sira: 259, yozu: 339, unit: "x" },
			{ text: "Monster", sira: 260, yozu: 340, unit: "x" },
			{ text: "Beast", sira: 261, yozu: 341, unit: "x" },
			{ text: "s", sira: 0, yozu: 0 },
			{ text: "Climax", sira: 281, yozu: 361 },
			{ text: "Squirting", sira: 282, yozu: 362 },
			{ text: "Bukkake", sira: 283, yozu: 363, unit: "cc" },
			{ text: "Vaginal Cumshot", sira: 284, yozu: 364, unit: "cc" },
			{ text: "Anal Cumshot", sira: 285, yozu: 365, unit: "cc" },
			{ text: "Oral Cumshot", sira: 286, yozu: 366, unit: "cc" },
			{ text: "Breast Milk", sira: 287, yozu: 367, unit: "cc" },
			{ text: "s", sira: 0, yozu: 0 },
			{ text: "Sex with People", sira: 288, yozu: 368 },
			{ text: "Interspecies Sex", sira: 289, yozu: 369 },
			{ text: "Orgy", sira: 290, yozu: 370 },
			{ text: "Rape", sira: 291, yozu: 371 },
			{ text: "Sexual Harassment", sira: 292, yozu: 372 },
			{ text: "Service", sira: 293, yozu: 373 },
			{ text: "Combat Sex", sira: 308, yozu: 388 }
		];
		skip = 0;
		for (var i = 0; i < 19; i++) {
			//左上のコンテンツ
			if (list[i].text == "s") {
				skip += 2;
				continue;
			}

			this.drawTextS(list[i].text, sX + lineX, sY + lineY * i + skip, 300);
			this.drawTextS(
				`${$gameVariables.value(list[i][chara]).clamp(0, 9999999)} ${list[i].unit ? list[i].unit : "x"}`,
				sX + lineX,
				sY + lineY * i + skip,
				w,
				"right"
			);
		}
		skip = 0;
		var list = [
			{ text: "Sex Work", sira: 294, yozu: 374 },
			{ text: "Sex Work Earnings", sira: 295, yozu: 375, unit: "Yen" },
			{ text: "Prostitution", sira: 296, yozu: 376 },
			{ text: "Prostitution Earnings", sira: 297, yozu: 377, unit: "Yen" },
			{ text: "Breast Milk Sales", sira: 298, yozu: 378 },
			{ text: "Milk Sales Earnings", sira: 299, yozu: 379, unit: "Yen" },
			{ text: "s", sira: 0, yozu: 0 },
			{ text: "Pregnancy", sira: 300, yozu: 380 },
			{ text: "Birth", sira: 301, yozu: 381 },
			{ text: "Abortion", sira: 302, yozu: 382 },
			{ text: "Miscarriage", sira: 303, yozu: 383 },
			{ text: "Human Birth", sira: 304, yozu: 384, unit: "x" },
			{ text: "Monster Birth", sira: 305, yozu: 385, unit: "x" },
			{ text: "Beast Birth", sira: 306, yozu: 386, unit: "x" },
			{ text: "Egg Laying", sira: 307, yozu: 387 }
		];
		for (var i = 0; i < 15; i++) {
			//左上のコンテンツ
			if (list[i].text == "s") {
				skip += 2;
				continue;
			}

			this.drawTextS(list[i].text, sX + lineX * 2, sY + lineY * i + skip, 300);
			this.drawTextS(
				`${$gameVariables.value(list[i][chara]).clamp(0, 9999999)} ${list[i].unit ? list[i].unit : "x"}`,
				sX + lineX * 2,
				sY + lineY * i + skip,
				w,
				"right"
			);
		}
	};
})();
