Skip to content

Commit

Permalink
1.0.0 装備シーンで装備品の詳細説明を表示する
Browse files Browse the repository at this point in the history
  • Loading branch information
elleonard committed Apr 16, 2024
1 parent 9c5f0f9 commit 931af6e
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/codes/EquipDetail/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { ConfigDefinitionBuilder } from '../../../../modules/config/configDefinitionBuilder.js';
import { PluginHistorySchema } from '../../../../modules/config/configSchema.js';
import { createSelectParam } from '../../../../modules/config/createParameter.js';
import { dedent } from '@qnighy/dedent';

const histories: PluginHistorySchema[] = [
{
date: "2024/04/17",
version: "1.0.0",
description: "公開",
}
];

const parameters = [
createSelectParam('openDetailKey', {
text: '詳細説明ボタン',
description: '詳細説明を開くためのボタンを設定します。',
options: [
{
name: 'pageup',
},
{
name: 'pagedown',
},
{
name: 'shift',
},
{
name: 'control',
},
{
name: 'tab',
},
],
default: 'shift',
}),
];

export const config = new ConfigDefinitionBuilder(
"EquipDetail",
2024,
"装備シーンで装備品の詳細説明を表示する"
)
.withHistories(histories)
.withLicense("MIT")
.withParameters(parameters)
.withBaseDependency({
name: 'DarkPlasma_CustomKeyHandler',
version: '1.3.0',
})
.withOrderAfterDependency({
name: 'DarkPlasma_CustomKeyHandler',
})
.withHelp(dedent`装備シーンの装備にカーソルを合わせて特定のボタンを押すと
装備詳細説明ウィンドウを開きます。
装備のメモ欄に下記のような記述で詳細説明を記述できます。
<detail:詳細説明文。
~~~~。>`)
.build();
85 changes: 85 additions & 0 deletions src/codes/EquipDetail/plugin/DarkPlasma_EquipDetail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/// <reference path="./EquipDetail.d.ts" />

import { settings } from '../config/_build/DarkPlasma_EquipDetail_parameters';
import { Window_DetailText } from '../../../common/window/detailWindow';

function Scene_Equip_DetailMixIn(sceneEquip: Scene_Equip) {
const _create = sceneEquip.create;
sceneEquip.create = function () {
_create.call(this);
this.createDetailWindow();
};

const _createSlotWindow = sceneEquip.createSlotWindow;
sceneEquip.createSlotWindow = function () {
_createSlotWindow.call(this);
this._slotWindow.setHandler('detail', () => this.toggleDetailWindow(this._slotWindow));
};

const _createItemWindow = sceneEquip.createItemWindow;
sceneEquip.createItemWindow = function () {
_createItemWindow.call(this);
this._itemWindow.setHandler('detail', () => this.toggleDetailWindow(this._itemWindow));
};

sceneEquip.createDetailWindow = function () {
this._detailWindowLayer = new WindowLayer();
this._detailWindowLayer.x = (Graphics.width - Graphics.boxWidth) / 2;
this._detailWindowLayer.y = (Graphics.height - Graphics.boxHeight) / 2;
this.addChild(this._detailWindowLayer);
this._detailWindow = new Window_DetailText(this.detailWindowRect());
this._detailWindowLayer.addChild(this._detailWindow);
this._itemWindow.setDetailWindow(this._detailWindow);
this._slotWindow.setDetailWindow(this._detailWindow);
};

sceneEquip.detailWindowRect = function () {
return this.slotWindowRect();
};

sceneEquip.toggleDetailWindow = function (activeWindow) {
activeWindow.activate();
this._detailWindow.scrollTo(0, 0);
if (!this._detailWindow.visible) {
this._detailWindow.show();
} else {
this._detailWindow.hide();
}
};
}

Scene_Equip_DetailMixIn(Scene_Equip.prototype);

Window_CustomKeyHandlerMixIn(settings.openDetailKey, Window_EquipSlot.prototype, 'detail');
Window_CustomKeyHandlerMixIn(settings.openDetailKey, Window_EquipItem.prototype, 'detail');

function Window_Equip_DetailMixIn(windowClass: Window_EquipSlot|Window_EquipItem) {
windowClass.setDetailWindow = function (detailWindow) {
this._detailWindow = detailWindow;
};

const _setHelpWindowItem = windowClass.setHelpWindowItem;
windowClass.setHelpWindowItem = function (item) {
_setHelpWindowItem.call(this, item);
this._detailWindow?.setItem(item as DataManager.NoteHolder);
};

const _isCursorMovable = windowClass.isCursorMovable;
windowClass.isCursorMovable = function () {
return _isCursorMovable.call(this) && (!this._detailWindow || !this._detailWindow.visible);
};

const _isOkEnabled = windowClass.isOkEnabled;
windowClass.isOkEnabled = function () {
return _isOkEnabled.call(this) && (!this._detailWindow || !this._detailWindow.visible);
};

const _processCancel = windowClass.processCancel;
windowClass.processCancel = function () {
this._detailWindow?.hide();
_processCancel.call(this);
};
}

Window_Equip_DetailMixIn(Window_EquipSlot.prototype);
Window_Equip_DetailMixIn(Window_EquipItem.prototype);
25 changes: 25 additions & 0 deletions src/codes/EquipDetail/plugin/EquipDetail.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/// <reference path="../../../typings/rmmz.d.ts" />
/// <reference path="../../CustomKeyHandler/CustomKeyHandler.d.ts" />
/// <reference path="../../CustomKeyHandler/CustomKeyHandlerExport.d.ts" />
/// <reference path="../../../common/window/detailWindow.d.ts" />

declare interface Scene_Equip {
_detailWindowLayer: WindowLayer;
_detailWindow: Window_DetailText;

createDetailWindow(): void;
detailWindowRect(): Rectangle;
toggleDetailWindow(activeWindow: Window_EquipSlot|Window_EquipItem): void;
}

declare interface Window_EquipSlot {
_detailWindow?: Window_DetailText;

setDetailWindow(detailWindow: Window_DetailText): void;
}

declare interface Window_EquipItem {
_detailWindow?: Window_DetailText;

setDetailWindow(detailWindow: Window_DetailText): void;
}
17 changes: 17 additions & 0 deletions src/common/window/detailWindow.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// <reference path="../../typings/rmmz.d.ts" />

declare class Window_DetailText extends Window_Scrollable {
_text: string;

initialize(rect: Rectangle): void;
setItem(item: DataManager.NoteHolder|null): void;
setText(text: string): void;
drawDetail(detail: string): void;
baseLineY(): number;
heightAdjustment(): number;
refresh(): void;
processCursorMove(): void;
isCursorMovable(): boolean;
cursorDown(): void;
cursorUp(): void;
}

0 comments on commit 931af6e

Please sign in to comment.