-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import { ConfigDefinitionBuilder } from '../../../../modules/config/configDefinitionBuilder.js'; | ||
import { PluginCommandSchema, PluginHistorySchema } from '../../../../modules/config/configSchema.js'; | ||
import { createBooleanParam, createCommand, createNumberParam, createSelectParam } from '../../../../modules/config/createParameter.js'; | ||
import { dedent } from '@qnighy/dedent'; | ||
|
||
const histories: PluginHistorySchema[] = [ | ||
{ | ||
date: "2024/06/07", | ||
version: "1.0.0", | ||
description: "公開", | ||
} | ||
]; | ||
|
||
const targetSelectParam = createSelectParam("target", { | ||
text: "対象", | ||
description: "画像の変更をカスタマイズする対象を選びます。", | ||
options: [ | ||
{ | ||
name: "プレイヤー", | ||
value: -1 | ||
}, | ||
{ | ||
name: "このイベント", | ||
value: 0, | ||
}, | ||
{ | ||
name: "他のイベント", | ||
value: 1, | ||
}, | ||
], | ||
default: 0, | ||
}); | ||
|
||
const targetEventIdParam = createNumberParam("targetEventId", { | ||
text: "対象イベントID", | ||
description: "対象が他のイベントの場合のみ、対象となるイベントIDを設定します。", | ||
default: 0, | ||
}); | ||
|
||
const commands: PluginCommandSchema[] = [ | ||
createCommand("hackChangeImage", { | ||
text: "画像の変更カスタム", | ||
description: "対象の画像の変更コマンドをカスタマイズします。", | ||
args: [ | ||
targetSelectParam, | ||
targetEventIdParam, | ||
createSelectParam("direction", { | ||
text: "向き", | ||
description: "画像の変更によって、キャラクターの向きを設定します。", | ||
options: [ | ||
{ | ||
name: "変更しない", | ||
value: 0, | ||
}, | ||
{ | ||
name: "下", | ||
value: 2, | ||
}, | ||
{ | ||
name: "左", | ||
value: 4, | ||
}, | ||
{ | ||
name: "右", | ||
value: 6, | ||
}, | ||
{ | ||
name: "上", | ||
value: 8, | ||
}, | ||
], | ||
default: 0, | ||
}), | ||
createSelectParam("pattern", { | ||
text: "パターン", | ||
description: "画像の変更によって、キャラクターのパターンを設定します。", | ||
options: [ | ||
{ | ||
name: "左", | ||
value: 0, | ||
}, | ||
{ | ||
name: "真ん中", | ||
value: 1, | ||
}, | ||
{ | ||
name: "右", | ||
value: 2, | ||
}, | ||
], | ||
default: 1, | ||
}), | ||
createBooleanParam("fixPattern", { | ||
text: "パターンを固定する", | ||
description: "画像の変更によってキャラクターのパターンを固定します。", | ||
default: true, | ||
}), | ||
], | ||
}), | ||
createCommand("unfixPattern", { | ||
text: "パターン固定の解除", | ||
description: "パターン固定状態を解除します。", | ||
args: [ | ||
targetSelectParam, | ||
targetEventIdParam, | ||
], | ||
}), | ||
]; | ||
|
||
export const config = new ConfigDefinitionBuilder( | ||
"ChangeImageWithPattern", | ||
2024, | ||
"画像の変更で向きやパターンを設定する" | ||
) | ||
.withHistories(histories) | ||
.withLicense("MIT") | ||
.withCommands(commands) | ||
.withHelp(dedent`画像の変更で向きやパターンを設定できるようにします。`) | ||
.build(); |
21 changes: 21 additions & 0 deletions
21
src/codes/ChangeImageWithPattern/plugin/ChangeImageWithPattern.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// <reference path="../../../typings/rmmz.d.ts" /> | ||
|
||
type ChangeImageWith = { | ||
direction: number; | ||
pattern: number; | ||
fixPattern: boolean; | ||
}; | ||
|
||
declare interface Game_Character { | ||
_changeImageWith: ChangeImageWith; | ||
_isPatternFixed: boolean; | ||
|
||
setChangeImageWith(changeImageWith: ChangeImageWith): void; | ||
setChangeImageWithDirection(direction: number): void; | ||
setChangeImageWithPattern(pattern: number): void; | ||
setChangeImageWithFixPattern(fixPattern: boolean): void; | ||
|
||
isPatternFixed(): boolean; | ||
fixPattern(): void; | ||
unfixPattern(): void; | ||
} |
97 changes: 97 additions & 0 deletions
97
src/codes/ChangeImageWithPattern/plugin/DarkPlasma_ChangeImageWithPattern.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/// <reference path="./ChangeImageWithPattern.d.ts" /> | ||
|
||
import { pluginName } from '../../../common/pluginName'; | ||
import { command_hackChangeImage, command_unfixPattern, parseArgs_hackChangeImage, parseArgs_unfixPattern } from '../config/_build/DarkPlasma_ChangeImageWithPattern_commands'; | ||
|
||
PluginManager.registerCommand(pluginName, command_hackChangeImage, function (this: Game_Interpreter, args) { | ||
const parsedArgs = parseArgs_hackChangeImage(args); | ||
const target = parsedArgs.target === 1 | ||
? this.character(parsedArgs.targetEventId) | ||
: this.character(parsedArgs.target); | ||
target?.setChangeImageWith({ | ||
direction: parsedArgs.direction, | ||
pattern: parsedArgs.pattern, | ||
fixPattern: parsedArgs.fixPattern, | ||
}); | ||
}); | ||
|
||
PluginManager.registerCommand(pluginName, command_unfixPattern, function (this: Game_Interpreter, args) { | ||
const parsedArgs = parseArgs_unfixPattern(args); | ||
const target = parsedArgs.target === 1 | ||
? this.character(parsedArgs.targetEventId) | ||
: this.character(parsedArgs.target); | ||
target?.unfixPattern(); | ||
}); | ||
|
||
function Game_Character_ChangeImageWithPatternMixIn(gameCharacter: Game_Character) { | ||
const _initMembers = gameCharacter.initMembers; | ||
gameCharacter.initMembers = function () { | ||
_initMembers.call(this); | ||
this._changeImageWith = { | ||
direction: 0, | ||
pattern: 1, | ||
fixPattern: false, | ||
}; | ||
this._isPatternFixed = false; | ||
}; | ||
|
||
gameCharacter.setChangeImageWith = function (changeImageWith) { | ||
this.setChangeImageWithDirection(changeImageWith.direction); | ||
this.setChangeImageWithPattern(changeImageWith.pattern); | ||
this.setChangeImageWithFixPattern(changeImageWith.fixPattern); | ||
}; | ||
|
||
gameCharacter.setChangeImageWithDirection = function (direction) { | ||
this._changeImageWith.direction = direction; | ||
}; | ||
|
||
gameCharacter.setChangeImageWithPattern = function (pattern) { | ||
this._changeImageWith.pattern = pattern; | ||
}; | ||
|
||
gameCharacter.setChangeImageWithFixPattern = function (fixPattern) { | ||
this._changeImageWith.fixPattern = fixPattern; | ||
}; | ||
|
||
const _processMoveCommand = gameCharacter.processMoveCommand; | ||
gameCharacter.processMoveCommand = function (command) { | ||
_processMoveCommand.call(this, command); | ||
if (command.code === Game_Character.ROUTE_CHANGE_IMAGE) { | ||
if (this._changeImageWith.direction) { | ||
/** | ||
* 明示的に指定するため、向き固定を貫通する | ||
*/ | ||
const isDirectionFixed = this.isDirectionFixed(); | ||
this.setDirectionFix(false); | ||
this.setDirection(this._changeImageWith.direction); | ||
this.setDirectionFix(isDirectionFixed); | ||
} | ||
this.setPattern(this._changeImageWith.pattern); | ||
if (this._changeImageWith.fixPattern) { | ||
this.fixPattern(); | ||
} | ||
} | ||
}; | ||
|
||
const _updatePattern = gameCharacter.updatePattern; | ||
gameCharacter.updatePattern = function () { | ||
if (this.isPatternFixed()) { | ||
return; | ||
} | ||
_updatePattern.call(this); | ||
}; | ||
|
||
gameCharacter.isPatternFixed = function () { | ||
return this._isPatternFixed; | ||
}; | ||
|
||
gameCharacter.fixPattern = function () { | ||
this._isPatternFixed = true; | ||
}; | ||
|
||
gameCharacter.unfixPattern = function () { | ||
this._isPatternFixed = false; | ||
}; | ||
} | ||
|
||
Game_Character_ChangeImageWithPatternMixIn(Game_Character.prototype); |