alter-egoism/js/plugins/CBR_eroStatus_rireki.js

246 lines
7.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function Window_EroStatus_rireki_select() {
this.initialize(...arguments);
}
function Window_EroStatus_rireki_view() {
this.initialize(...arguments);
}
CBR_eroRireki = null;
DataManager._databaseFiles.push({ name: "CBR_eroRireki", src: "CBR_h_event_data.json" });
(function () {
// ########################################################
// ################### 履歴セレクト ######################
// ########################################################
Window_EroStatus_rireki_select.prototype = Object.create(Window_Selectable.prototype);
Window_EroStatus_rireki_select.prototype.constructor = Window_EroStatus_rireki_select;
Window_EroStatus_rireki_select.prototype.initialize = function (rect) {
Window_Selectable.prototype.initialize.call(this, rect);
//最初に0番目って指定、commandではデフォでやってるけど
// デフォではアクティブに
this.makeList();
this.select(0);
this.activate();
};
Window_EroStatus_rireki_select.prototype.numVisibleRows = function () {
return 5;
};
Window_EroStatus_rireki_select.prototype.makeList = function () {
var ary = $gameVariables.value(143) || [];
// var ary = [
// { id: 100, type: 0 },
// { id: 9, type: 0 },
// { id: 9, type: 0 },
// { id: 9, type: 0 },
// { id: 1, type: 0 },
// { id: 2, type: 1 },
// { id: 3, type: 0 },
// { id: 4, type: 0 },
// { id: 5, type: 0 },
// { id: 6, type: 0 },
// { id: 7, type: 0 },
// { id: 8, type: 0 },
// { id: 9, type: 0 }
// ];
var name = $gameParty.menuActor().name();
var ary2 = ary.filter((e) => CBR_eroRireki[e.id].actor == name);
this._list = ary2;
this.refresh();
this.callUpdateHelp();
};
Window_EroStatus_rireki_select.prototype.maxItems = function () {
return this._list.length || 0;
};
Window_EroStatus_rireki_select.prototype.setViewWindow = function (viewWindow) {
this._viewWindow = viewWindow;
};
//右のウィンドウにデータを渡す
Window_EroStatus_rireki_select.prototype.callUpdateHelp = function () {
if (this.active && this._viewWindow) {
this.updateHelp();
}
};
Window_EroStatus_rireki_select.prototype.updateHelp = function () {
if (this._list[this.index()]) {
this._viewWindow.setItem(CBR_eroRireki[this._list[this.index()].id]);
}
};
Window_EroStatus_rireki_select.prototype.drawItem = function (index) {
const info = CBR_eroRireki[this._list[index].id];
const rect = this.itemRectWithPadding(index);
this.resetTextColor();
//this.changePaintOpacity(this.isEnabled(savefileId));
//this.drawTitle(savefileId, rect.x, rect.y + 4);
//数値だったら
//if (Number.isFinite(info)) {
this.drawContents(info, rect, index);
//}
};
Window_EroStatus_rireki_select.prototype.drawContents = function (info, rect, index) {
const bottom = rect.y + rect.height;
//var newFlag = $gameVariables.value(144);
this.contents.fontFace = "serif";
this.contents.fontSize = 22;
var type = this._list[index].type;
if (type === 0) {
this.changeTextColor("#FF0000");
this.drawTextM("NEW", 10, rect.y + 2, 200, "left");
}
this.changeTextColor("#000000");
this.drawTextM(info.title, 112, rect.y + 2, 400, "left");
// const lineHeight = this.lineHeight();
// const y2 = bottom - lineHeight - 4;
// if (y2 >= lineHeight) {
// this.drawPlaytime(info, rect.x, y2, rect.width);
// }
};
Window_EroStatus_rireki_select.prototype.select = function (index) {
if (this._index != index && this._list[this.index()]) {
if (this._list[this.index()].type == 0) {
var data_ary = $gameVariables.value(143) || [];
var idx = data_ary.findIndex((e) => e.id === this._list[this.index()].id);
if (idx !== -1) {
data_ary[idx].type = 1;
this._list[this.index()].type = 1;
$gameVariables.setValue(143, data_ary);
this.refresh();
}
}
}
this._index = index;
this.refreshCursor();
this.callUpdateHelp();
};
// ################# カーソルの変更 ##################
Window_EroStatus_rireki_select.prototype.loadWindowskin = function () {
this.windowskin = ImageManager.loadSystem("Window");
this.menu_cursor_skin = ImageManager.loadSystem("menu_item_selected_l");
this.menu_item_skin = ImageManager.loadSystem("menu_item_selected_2_l");
if (!this.menu_item_skin.isReady()) {
this.menu_item_skin.addLoadListener(() => {
this.refresh(); // 画像がロードされたら再描画
});
return;
}
};
//56×200にする
Window_EroStatus_rireki_select.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);
};
//未選択コマンドの背景を画像に
Window_EroStatus_rireki_select.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);
}
};
Window_EroStatus_rireki_select.prototype._refreshAllParts = function () {
//this._refreshBack();
//this._refreshFrame();
this._refreshCursor();
this._refreshArrows();
this._refreshPauseSign();
};
// ########################################################
// ################### 履歴のビュー ######################
// ########################################################
Window_EroStatus_rireki_view.prototype = Object.create(Window_Base.prototype);
Window_EroStatus_rireki_view.prototype.constructor = Window_EroStatus_rireki_view;
Window_EroStatus_rireki_view.prototype.initialize = function (rect) {
Window_Base.prototype.initialize.call(this, rect);
this.refresh();
};
// padding0を適用させる
Object.defineProperty(Window_EroStatus_rireki_view.prototype, "padding", {
get: function () {
return 0;
},
set: function (value) {
this._padding = 0;
this._refreshAllParts();
},
configurable: true
});
Window_EroStatus_rireki_view.prototype.setItem = function (data) {
this._data = data;
this.refresh();
};
Window_EroStatus_rireki_view.prototype._refreshAllParts = function () {
// this._refreshBack();
// this._refreshFrame();
this._refreshCursor();
this._refreshArrows();
this._refreshPauseSign();
};
Window_EroStatus_rireki_view.prototype.refresh = function () {
const rect = this.baseTextRect();
this.contents.clear();
var bitmap = ImageManager.loadSystem("erost_rireki_back");
this.contents.blt(bitmap, 0, 0, 1280, 720, 0, 0);
if (!bitmap.isReady()) {
bitmap.addLoadListener(() => {
this.refresh(); // 画像がロードされたら再描画
});
return;
}
if (this._data) {
this.contents.fontSize = 17;
var sY = 38;
var lineY = 36;
var sX = 61;
var lineX = 363;
var lineX2 = 62;
this.changeTextColor("#000000");
this.drawTextS("Partner", sX, sY, 200);
this.drawTextS("Race", sX + lineX, sY, 200);
this.drawTextS("Location", sX + lineX * 2 - 10, sY, 200);
this.drawTextS("Details", sX, sY + lineY - 4, 200);
this.resetTextColor();
this.contents.fontFace = "serif";
this.contents.fontSize = 20;
this.drawTextS(this._data.target, sX + lineX2, sY, 800);
this.drawTextS(this._data.job, sX + lineX2 + lineX, sY, 800);
this.drawTextS(this._data.place, sX + lineX2 + lineX + lineX, sY, 800);
this.drawTextExS(this._data.text, sX + lineX2, sY + lineY, 800);
}
};
})();