Skip to content

Commit

Permalink
1.1.0 画像ファイル名に制御文字を使用可能にする
Browse files Browse the repository at this point in the history
  • Loading branch information
elleonard committed Apr 13, 2024
1 parent 9f55999 commit 5a399db
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/codes/ComposePicture/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { createCommand, createFileParam, createNumberParam, createSelectParam, c
import { dedent } from '@qnighy/dedent';

const histories: PluginHistorySchema[] = [
{
date: "2024/04/13",
version: "1.1.0",
description: '画像ファイル名に制御文字を使用可能にする',
},
{
date: "2024/04/13",
version: "1.0.0",
Expand Down
8 changes: 7 additions & 1 deletion src/codes/ComposePicture/plugin/ComposePicture.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
/// <reference path="../../../typings/rmmz.d.ts" />

declare interface Game_Temp {
_dummyWindow: Window_Base;

dummyWindow(): Window_Base;
}

declare interface Game_Screen {
/**
* 同じ情報の合成ピクチャ情報を何度も生成しない
Expand Down Expand Up @@ -37,7 +43,7 @@ declare interface Sprite_Picture {
_additionalSprites: Sprite_Picture[];
_forceUpdateCompose: boolean;

additionalPictureIds(): number[];
additionalPictureNames(): string[];
updateCompose(): void;
mustBeComposed(): boolean;
composePicture(additionalSprites: Sprite_Picture[]): void;
Expand Down
23 changes: 19 additions & 4 deletions src/codes/ComposePicture/plugin/DarkPlasma_ComposePicture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ PluginManager.registerCommand(pluginName, command_composePicture, function (args
);
});

function Game_Temp_ComposePictureMixIn(gameTemp: Game_Temp) {
gameTemp.dummyWindow = function () {
if (!this._dummyWindow) {
this._dummyWindow = new Window_Base(new Rectangle(0, 0, 0, 0));
}
return this._dummyWindow;
};
}

Game_Temp_ComposePictureMixIn(Game_Temp.prototype);

function Game_Screen_ComposePictureMixIn(gameScreen: Game_Screen) {
gameScreen.allocateAdditionalPicture = function (name, origin, offsetX, offsetY, scaleX, scaleY, opacity, blendMode) {
const key = `${name}:${origin}:${offsetX}:${offsetY}:${scaleX}:${scaleY}:${opacity}:${blendMode}`;
Expand Down Expand Up @@ -101,6 +112,10 @@ Game_Picture_ComposePictureMixIn(Game_Picture.prototype);
class Game_AdditionalPicture extends Game_Picture {
_pictureId: number;

name() {
return $gameTemp.dummyWindow().convertEscapeCharacters(super.name());
}

setPictureId(id: number) {
this._pictureId = id;
}
Expand All @@ -117,9 +132,9 @@ function Sprite_Picture_ComposePictureMixIn(spritePicture: Sprite_Picture) {
this.updateCompose();
};

spritePicture.additionalPictureIds = function () {
spritePicture.additionalPictureNames = function () {
return this.children.filter((child): child is Sprite_Picture => child instanceof Sprite_Picture && child.picture() instanceof Game_AdditionalPicture)
.map(sprite => (sprite.picture() as Game_AdditionalPicture).pictureId());
.map(sprite => (sprite.picture() as Game_AdditionalPicture).name());
};

spritePicture.mustBeComposed = function () {
Expand All @@ -131,10 +146,10 @@ function Sprite_Picture_ComposePictureMixIn(spritePicture: Sprite_Picture) {
return true;
}
/**
* 設定されている被合成ピクチャID一覧と、実際の被合成ピクチャID一覧が順序含めて等しい場合は更新不要
* 設定されている被合成ピクチャ名一覧と、実際の被合成ピクチャ名一覧が順序含めて等しい場合は更新不要
*/
return JSON.stringify(picture.additionalPictures()
.map(additionalPicture => additionalPicture.pictureId())) !== JSON.stringify(this.additionalPictureIds());
.map(additionalPicture => additionalPicture.name())) !== JSON.stringify(this.additionalPictureNames());
};

spritePicture.updateCompose = function () {
Expand Down

0 comments on commit 5a399db

Please sign in to comment.