dead-bunny/js/plugins/Nore_ScreenShot.js
2025-01-12 01:21:39 -06:00

179 lines
5.4 KiB
JavaScript

/*:ja
* @target MZ
* @author ル
*
* @command changeEroId
* @text エロIDが変わる
*
*/
var Nore;
(function (Nore) {
var pluginName = "Nore_ScreenShot";
PluginManager.registerCommand(pluginName, "changeEroId", function (args) {
if (!(SceneManager._scene instanceof Scene_Map)) {
console.error("マップ以外ではスクリーンショットを取れません");
return;
}
var scene = SceneManager._scene;
scene._screenShotManager = new ScreenShotManager();
$gameAvJacketMaker.clear();
p("エロID変化");
});
Nore.recordingFlag = false;
function startRecording() {
Nore.recordingFlag = true;
console.info("スクリーンショット作成開始");
return true;
}
Nore.startRecording = startRecording;
function takeScreenShot(fileName) {
if (!(SceneManager._scene instanceof Scene_Map)) {
console.error("マップ以外ではスクリーンショットを取れません");
return;
}
var scene = SceneManager._scene;
scene.hideForSnapshot();
var bitmap = SceneManager.snap();
var fileFullPath = directoryPath() + "/" + fileName;
var data = bitmap._canvas.toDataURL("image/" + "png").replace(/^.*,/, "");
StorageManager.fsMkdir(directoryPath());
StorageManager.fsWriteFile(fileFullPath, new Buffer(data, "base64"));
}
Nore.takeScreenShot = takeScreenShot;
function takeScreenShotBitmap(fileName, bitmap) {
var fileFullPath = directoryPath() + "/" + fileName;
var data = bitmap._canvas.toDataURL("image/" + "png").replace(/^.*,/, "");
StorageManager.fsMkdir(directoryPath());
StorageManager.fsWriteFile(fileFullPath, new Buffer(data, "base64"));
}
Nore.takeScreenShotBitmap = takeScreenShotBitmap;
function directoryPath() {
var p = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, "screenshot");
if (p.match(/^\/([A-Z]\:)/)) {
p = p.slice(1);
}
var result = decodeURIComponent(p);
if (result[0] == "/") {
return "." + result;
}
return result;
}
})(Nore || (Nore = {}));
var ScreenShotManager = /** @class */ (function () {
function ScreenShotManager() {
this._lastEroImageList = [];
this._takeScreenShotMap = {};
this._screenShotCount = 0;
}
ScreenShotManager.prototype.update = function () {
if (!Nore.recordingFlag) {
return;
}
if (!$gameSwitches.value(26)) {
return;
}
var list = this.removeUpper10Index($gameAvJacketMaker.eroImageList());
if (this.isChanged(list)) {
this.takeScreenShot(list);
}
};
ScreenShotManager.prototype.takeScreenShot = function (newList) {
this._lastEroImageList = newList;
var key = JsonEx.stringify(this._lastEroImageList);
if (this._takeScreenShotMap[key]) {
return;
}
//p(this._lastEroImageList)
var eroId = this.pasrseEroId(this._lastEroImageList);
if (this.isEroIdChanged(eroId)) {
console.error("eroId が変化しています:" + eroId + " " + this._lastEroId);
return;
}
this._lastEroId = eroId;
this.putTakeScreenShotMap(newList);
this._screenShotCount++;
//p(key)
var fileName =
eroId +
"_" +
this.screenShotId() +
"_" +
this._screenShotCount.padZero(3) +
".png";
Nore.takeScreenShot(fileName);
};
ScreenShotManager.prototype.removeUpper10Index = function (newList) {
var result = [];
for (var k = 0; k < newList.length; k++) {
if (newList[k].contains("back")) {
continue;
}
var list = newList[k].split("_");
if (list.length >= 4) {
var index = parseInt(list[3]);
if (index >= 10) {
continue;
}
}
result.push(newList[k]);
}
return result;
};
ScreenShotManager.prototype.screenShotId = function () {
return $gameVariables.value(89).padZero(2);
};
/*isAnimeNotChanged(lastList: Array<string>) {
}*/
ScreenShotManager.prototype.putTakeScreenShotMap = function (newList) {
var key = JsonEx.stringify(this._lastEroImageList);
this._takeScreenShotMap[key] = true;
for (var i = 0; i < 20; i++) {
var otherList = [];
for (var k = 0; k < newList.length; k++) {
var list = newList[k].split("_");
if (list.length >= 4) {
var fileId = parseInt(list[2]);
if (fileId < 100) {
return;
}
var baseId = Math.round(fileId / 100) * 100;
var newFile =
list[0] + "_" + list[1] + "_" + (baseId + i) + "_" + list[3];
if (list.length == 5) {
newFile += "_" + list[4];
}
otherList.push(newFile);
}
}
if (otherList.length == 0) {
return;
}
//p(otherList)
var key2 = JsonEx.stringify(otherList);
this._takeScreenShotMap[key2] = true;
}
};
ScreenShotManager.prototype.isEroIdChanged = function (eroId) {
if (!this._lastEroId) {
return false;
}
return eroId != this._lastEroId;
};
ScreenShotManager.prototype.pasrseEroId = function (list) {
var splitList = list[0].split("_");
return splitList[0] + "_" + splitList[1];
};
ScreenShotManager.prototype.isChanged = function (list) {
if (this._lastEroImageList.length != list.length) {
return true;
}
for (var i = 0; i < list.length; i++) {
if (list[i] != this._lastEroImageList[i]) {
return true;
}
}
return false;
};
return ScreenShotManager;
})();