From c24ddf94d4e15a4ab804396827e891ffdc13bf53 Mon Sep 17 00:00:00 2001 From: Aokashi Date: Sun, 20 Feb 2022 22:48:39 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=E3=83=91=E3=83=BC=E3=83=84?= =?UTF-8?q?=E7=B7=A8=E9=9B=86=E3=81=AE=E6=A7=8B=E6=88=90=E3=82=B3=E3=83=B3?= =?UTF-8?q?=E3=83=9D=E3=83=BC=E3=83=8D=E3=83=B3=E3=83=88=E3=82=92=E5=88=A5?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AB=E7=8B=AC=E7=AB=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/maker/src/info/PartsEdit.tsx | 2 +- .../src/info/editforms/CommonEditForm.tsx | 4 +- .../src/info/editforms/EditFormUtils.tsx | 437 ------------------ .../maker/src/info/editforms/MapEditForm.tsx | 11 +- .../src/info/editforms/ObjectEditForm.tsx | 26 +- .../src/info/editforms/PartsAppearInput.tsx | 2 +- .../info/editforms/PartsAppearInputItem.tsx | 9 +- .../{PartsEditComponent.ts => definitions.ts} | 0 .../src/info/editforms/utils/CoordInput.tsx | 68 +++ .../info/editforms/utils/ItemPartsInput.tsx | 42 ++ .../src/info/editforms/utils/MessageInput.tsx | 22 + .../src/info/editforms/utils/NumberInput.tsx | 44 ++ .../editforms/utils/ObjectCommonInput.tsx | 32 ++ .../info/editforms/utils/ObjectPartsInput.tsx | 42 ++ .../src/info/editforms/utils/SelectInput.tsx | 68 +++ .../src/info/editforms/utils/StatusInput.tsx | 84 ++++ .../src/info/editforms/utils/StringInput.tsx | 20 + .../src/info/editforms/utils/URLInput.tsx | 24 + .../src/info/editforms/utils/definitions.ts | 27 ++ .../maker/src/info/editforms/utils/index.ts | 36 +- packages/maker/src/wwadata/WWADataState.ts | 2 +- 21 files changed, 509 insertions(+), 493 deletions(-) delete mode 100644 packages/maker/src/info/editforms/EditFormUtils.tsx rename packages/maker/src/info/editforms/{PartsEditComponent.ts => definitions.ts} (100%) create mode 100644 packages/maker/src/info/editforms/utils/CoordInput.tsx create mode 100644 packages/maker/src/info/editforms/utils/ItemPartsInput.tsx create mode 100644 packages/maker/src/info/editforms/utils/MessageInput.tsx create mode 100644 packages/maker/src/info/editforms/utils/NumberInput.tsx create mode 100644 packages/maker/src/info/editforms/utils/ObjectCommonInput.tsx create mode 100644 packages/maker/src/info/editforms/utils/ObjectPartsInput.tsx create mode 100644 packages/maker/src/info/editforms/utils/SelectInput.tsx create mode 100644 packages/maker/src/info/editforms/utils/StatusInput.tsx create mode 100644 packages/maker/src/info/editforms/utils/StringInput.tsx create mode 100644 packages/maker/src/info/editforms/utils/URLInput.tsx create mode 100644 packages/maker/src/info/editforms/utils/definitions.ts diff --git a/packages/maker/src/info/PartsEdit.tsx b/packages/maker/src/info/PartsEdit.tsx index 06c695a..df33880 100644 --- a/packages/maker/src/info/PartsEdit.tsx +++ b/packages/maker/src/info/PartsEdit.tsx @@ -6,7 +6,7 @@ import { PartsType, createEmptyPartsAttribute } from "../classes/WWAData"; import WWAConsts from "../classes/WWAConsts"; import { ObjectEditTable } from "./editforms/ObjectEditForm"; import { MapEditTable } from "./editforms/MapEditForm"; -import { PartsEditAttributeChange, PartsEditMessageChange } from "./editforms/PartsEditComponent"; +import { PartsEditAttributeChange, PartsEditMessageChange } from "./editforms/definitions"; import { Form, Portal, Button, Icon, Dropdown, DropdownItemProps } from "semantic-ui-react"; import PartsChip from "../common/PartsChip"; import { GraphicSelect } from "../common/GraphicSelect"; diff --git a/packages/maker/src/info/editforms/CommonEditForm.tsx b/packages/maker/src/info/editforms/CommonEditForm.tsx index 59808e7..772ae16 100644 --- a/packages/maker/src/info/editforms/CommonEditForm.tsx +++ b/packages/maker/src/info/editforms/CommonEditForm.tsx @@ -1,6 +1,6 @@ import React, { useState } from "react"; -import { URLInput, StringInput, CoordInput } from "./EditFormUtils"; -import { PartsEditComponent } from "./PartsEditComponent"; +import { CoordInput, StringInput, URLInput } from "./utils"; +import { PartsEditComponent } from "./definitions"; import WWAConsts from "../../classes/WWAConsts"; import { convertRelativeValueFromCoord } from "../../common/convertRelativeValue"; diff --git a/packages/maker/src/info/editforms/EditFormUtils.tsx b/packages/maker/src/info/editforms/EditFormUtils.tsx deleted file mode 100644 index b345534..0000000 --- a/packages/maker/src/info/editforms/EditFormUtils.tsx +++ /dev/null @@ -1,437 +0,0 @@ -import React from "react"; -import WWAConsts from "../../classes/WWAConsts"; -import { MoveType } from "../../classes/WWAData"; -import { Input, Dropdown, DropdownItemProps, Form, TextArea, Icon, StrictIconProps, Label, Button } from "semantic-ui-react"; -import { RelativeValue, convertDataValueFromRelativeCoord, convertRelativeValueFromStatus, convertDataValueFromRelativeStatus } from "../../common/convertRelativeValue"; -import BrowseMap from "../../common/BrowseMap"; -import { useState } from "react"; -import { ItemPartsBrowse, ObjectPartsBrowse } from "../../common/BrowseParts"; - -/** - * NOTE: - * このファイルは utils ディレクトリに移行します。 - * utils ディレクトリでは、1コンポーネント1ファイルの構成としています。 - * 型定義については utils/index.ts で定義していますが、定義場所はまだ仮の段階のため、後で移動する可能性があります。 - */ - -/** - * テキストボックスやセレクトボックスで変更が生じた際に実行するコールバック関数の型です。 - */ -type InputChangeFunction = (value: string) => void; -type CoordInputChangeFunction = (x: string, y: string) => void; -type InputChangeFunctionWithName = (value: string, name: string) => void; - -/** - * パーツ編集で必要になるステータス入力値のうち、ステータス1つ分で必要なプロパティを示す型です。 - */ -type NumberEditFormItem = { - label?: string, - value: number -}; - -export const NumberInput: React.FunctionComponent<{ - value: number, - label: string, - name?: string - min?: number, - max?: number - onChange: InputChangeFunction -}> = props => ( - - - { - props.onChange(data.value); - }} - /> - -); - -/** - * 数字を入力するコンポーネントを作成します。 - */ -const createNumberInput = (label: string) => { - return (props: { - value: number, - onChange: InputChangeFunction - }) => ( - - ); -}; - -export const SoundNumberInput = createNumberInput("サウンド番号"); -export const WaitTimeInput = createNumberInput("待ち時間"); - -export const SelectInput: React.FunctionComponent<{ - selectableItems: DropdownItemProps[], - value: number, - label: string, - onChange: InputChangeFunction -}> = props => ( - - - { - if (data.value === undefined) { - return; - } - const value = data.value as string; - props.onChange(value); - }} - /> - -); - -/** - * セレクトボックスのコンポーネントを作成します。 - */ -const createSelectInput = (label: string, selectableItems: DropdownItemProps[]) => { - return (props: { - value: number, - onChange: InputChangeFunction - }) => ( - - ); -}; - -export const MoveTypeInput = createSelectInput("動作属性", [ - { - text: "静止", - value: MoveType.STATIC, - }, { - text: "プレイヤー追尾", - value: MoveType.CHASE_PLAYER - }, { - text: "逃げる", - value: MoveType.RUN_OUT - }, { - text: "うろうろする", - value: MoveType.HANG_AROUND - } -]); -export const PassableInput = createSelectInput("通行区分", [ - { - text: "通行不可", - value: 0 - }, { - text: "通行可", - value: WWAConsts.PASSABLE_OBJECT - } -]); - -export const MessageInput: React.FunctionComponent<{ - value: string, - label: string, - onChange: InputChangeFunction -}> = props => ( - - -