Skip to content

Commit f26f273

Browse files
authored
Merge branch 'dev' into editor2
2 parents f18da25 + 3fef9b1 commit f26f273

File tree

8 files changed

+73
-31
lines changed

8 files changed

+73
-31
lines changed

scripts/shared.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { access } from 'fs/promises'
2-
import { uniq, uniqBy } from 'lodash-es'
2+
import { capitalize, uniq, uniqBy } from 'lodash-es'
33
import fetch from 'node-fetch'
44
import { pinyin } from 'pinyin'
55
import simplebig from 'simplebig'
@@ -111,7 +111,7 @@ export async function getOperators() {
111111
if (!prof) {
112112
const enSubProfName =
113113
subProfDictEN?.[op.subProfessionId]?.subProfessionName ||
114-
subProfDictCN[op.subProfessionId].subProfessionName
114+
capitalize(op.subProfessionId)
115115

116116
professions.push({
117117
id: op.profession,
@@ -129,7 +129,7 @@ export async function getOperators() {
129129
} else if (!prof.sub.find((p) => p.id === op.subProfessionId)) {
130130
const enSubProfName =
131131
subProfDictEN?.[op.subProfessionId]?.subProfessionName ||
132-
subProfDictCN[op.subProfessionId].subProfessionName
132+
capitalize(op.subProfessionId)
133133

134134
prof.sub.push({
135135
id: op.subProfessionId,

src/components/editor/DetailedSelect.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ import { FCC } from 'types'
1414

1515
import { Select } from '../Select'
1616

17-
export type DetailedSelectItem =
18-
| DetailedSelectChoice
19-
| { type: 'header'; header: ReactNode }
17+
export type DetailedSelectItem = DetailedSelectHeader | DetailedSelectChoice
18+
export type DetailedSelectHeader = {
19+
type: 'header'
20+
header: ReactNode | (() => ReactNode)
21+
}
22+
2023
export interface DetailedSelectChoice {
2124
type: 'choice'
2225
icon?: IconName
@@ -47,7 +50,11 @@ export const DetailedSelect: FCC<
4750
if (action.type === 'header') {
4851
return (
4952
<li key={'header_' + action.header} className={Classes.MENU_HEADER}>
50-
<H6>{action.header}</H6>
53+
<H6>
54+
{typeof action.header === 'function'
55+
? action.header()
56+
: action.header}
57+
</H6>
5158
</li>
5259
)
5360
}

src/components/editor/action/EditorActionTypeSelect.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ export const EditorActionTypeSelect = (
3131

3232
const menuItems = useMemo<DetailedSelectItem[]>(
3333
() =>
34-
Object.entries(groupBy(ACTION_TYPES, 'group')).flatMap(
35-
([group, items]) => [
36-
{ type: 'header' as const, header: group },
37-
...items,
38-
],
39-
),
34+
Object.values(
35+
groupBy(ACTION_TYPES, (item) => item.group.toString()),
36+
).flatMap((items) => [
37+
{ type: 'header' as const, header: items[0].group },
38+
...items,
39+
]),
4040
[],
4141
)
4242
const selectedAction = findActionType(value)

src/components/editor/operator/sheet/sheetOperator/ProfClassificationWithFilters.tsx

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { Button, Divider, H4, H5 } from '@blueprintjs/core'
22
import { Popover2 } from '@blueprintjs/popover2'
33

44
import clsx from 'clsx'
5+
import { useAtomValue } from 'jotai'
56
import { FC, ImgHTMLAttributes, useEffect, useMemo } from 'react'
67

78
import { PROFESSIONS } from 'models/operator'
89

9-
import { useTranslation } from '../../../../../i18n/i18n'
10+
import { languageAtom, useTranslation } from '../../../../../i18n/i18n'
1011
import {
1112
DEFAULTPROFID,
1213
DEFAULTSUBPROFID,
@@ -25,6 +26,7 @@ export const ProfClassificationWithFilters: FC<
2526
ProfClassificationWithFiltersProp
2627
> = ({ toTop }) => {
2728
const t = useTranslation()
29+
const language = useAtomValue(languageAtom)
2830
const {
2931
useProfFilterState: [{ selectedProf }, setProfFilter],
3032
usePaginationFilterState: [_, setPaginationFilter],
@@ -36,19 +38,31 @@ export const ProfClassificationWithFilters: FC<
3638
id: DEFAULTPROFID.ALL,
3739
name: t.components.editor.operator.sheet.sheetOperator
3840
.ProfClassificationWithFilters.all,
41+
name_en:
42+
t.components.editor.operator.sheet.sheetOperator
43+
.ProfClassificationWithFilters.all,
3944
sub: [],
4045
},
4146
{
4247
id: DEFAULTPROFID.FAV,
4348
name: t.components.editor.operator.sheet.sheetOperator
4449
.ProfClassificationWithFilters.favorites,
50+
name_en:
51+
t.components.editor.operator.sheet.sheetOperator
52+
.ProfClassificationWithFilters.favorites,
4553
sub: [],
4654
},
47-
...PROFESSIONS,
55+
...PROFESSIONS.map((profession) => ({
56+
...profession,
57+
name_en: profession.name_en || profession.name,
58+
})),
4859
{
4960
id: DEFAULTPROFID.OTHERS,
5061
name: t.components.editor.operator.sheet.sheetOperator
5162
.ProfClassificationWithFilters.others,
63+
name_en:
64+
t.components.editor.operator.sheet.sheetOperator
65+
.ProfClassificationWithFilters.others,
5266
sub: [],
5367
},
5468
],
@@ -60,11 +74,17 @@ export const ProfClassificationWithFilters: FC<
6074
id: DEFAULTSUBPROFID.ALL,
6175
name: t.components.editor.operator.sheet.sheetOperator
6276
.ProfClassificationWithFilters.all,
77+
name_en:
78+
t.components.editor.operator.sheet.sheetOperator
79+
.ProfClassificationWithFilters.all,
6380
},
6481
{
6582
id: DEFAULTSUBPROFID.SELECTED,
6683
name: t.components.editor.operator.sheet.sheetOperator
6784
.ProfClassificationWithFilters.selected,
85+
name_en:
86+
t.components.editor.operator.sheet.sheetOperator
87+
.ProfClassificationWithFilters.selected,
6888
},
6989
...(formattedProfessions.find(({ id }) => id === selectedProf[0])?.sub ||
7090
[]),
@@ -95,16 +115,16 @@ export const ProfClassificationWithFilters: FC<
95115
return (
96116
<div className="flex flex-row-reverse relative h-full">
97117
<ul className="h-full flex flex-col w-6 sm:w-12">
98-
{formattedProfessions.map(({ id, name }) => (
118+
{formattedProfessions.map((prof) => (
99119
<ProfIcon
100-
key={id}
101-
profId={id}
102-
name={name}
103-
selected={selectedProf.includes(id)}
120+
key={prof.id}
121+
profId={prof.id}
122+
name={language === 'en' && prof.name_en ? prof.name_en : prof.name}
123+
selected={selectedProf.includes(prof.id)}
104124
onProfClick={() =>
105125
setProfFilter((prev) => ({
106126
...prev,
107-
selectedProf: [id, DEFAULTSUBPROFID.ALL],
127+
selectedProf: [prof.id, DEFAULTSUBPROFID.ALL],
108128
}))
109129
}
110130
/>
@@ -113,22 +133,27 @@ export const ProfClassificationWithFilters: FC<
113133
<Divider className="mr-0" />
114134
<div className="h-full flex flex-col justify-center items-end absolute right-full sm:relative sm:left-0">
115135
<ul>
116-
{subProfs.map(({ id, name }) => (
117-
<li key={id}>
136+
{subProfs.map((subProf) => (
137+
<li key={subProf.id}>
118138
<H4
119139
className={clsx(
120140
'truncate cursor-pointer my-3 opacity-50 hover:underline hover:opacity-90',
121-
selectedProf.includes(id) && '!opacity-100 underline',
122-
name.length > 3 && '!text-base',
141+
selectedProf.includes(subProf.id) && '!opacity-100 underline',
142+
(language === 'en' && subProf.name_en
143+
? subProf.name_en
144+
: subProf.name
145+
).length > 3 && '!text-base',
123146
)}
124147
onClick={() =>
125148
setProfFilter(({ selectedProf, ...rest }) => ({
126-
selectedProf: [selectedProf[0], id],
149+
selectedProf: [selectedProf[0], subProf.id],
127150
...rest,
128151
}))
129152
}
130153
>
131-
{name}
154+
{language === 'en' && subProf.name_en
155+
? subProf.name_en
156+
: subProf.name}
132157
</H4>
133158
</li>
134159
))}

src/components/entity/ELevel.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ export const NeoELevel: FC<{
2626
<div className="flex items-center">
2727
<div className="flex whitespace-pre">
2828
<span className="inline-block font-bold my-auto">{catThree}</span>
29-
{' | '}
30-
<span className="text-xs">{catTwo}</span>
29+
{catTwo && (
30+
<>
31+
{' | '}
32+
<span className="text-xs">{catTwo}</span>
33+
</>
34+
)}
3135
{' | '}
3236
<span className="text-xs">{catOne}</span>
3337
</div>

src/hooks/useLinks.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { useTranslation } from '../i18n/i18n'
12
import { NAV_CONFIG, SOCIAL_CONFIG } from '../links'
23

34
export const useLinks = () => {
5+
useTranslation()
6+
47
const NAV_LINKS = NAV_CONFIG.map(({ to, labelKey, icon }) => ({
58
to,
69
label: labelKey(),

src/i18n/i18n.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ function createDeferredProxy(path: string) {
126126
if (Object.prototype.hasOwnProperty.call(target, prop)) {
127127
return target[prop]
128128
}
129+
if (typeof prop === 'symbol') {
130+
return undefined
131+
}
129132
target[prop] = createDeferredProxy(
130133
(path ? path + '.' : '') + String(prop),
131134
)

src/models/generated/operators.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4868,7 +4868,7 @@
48684868
{ "id": "librator", "name": "解放者", "name_en": "Liberator" },
48694869
{ "id": "fighter", "name": "斗士", "name_en": "Fighter" },
48704870
{ "id": "hammer", "name": "撼地者", "name_en": "Earthshaker" },
4871-
{ "id": "primguard", "name": "本源近卫", "name_en": "本源近卫" }
4871+
{ "id": "primguard", "name": "本源近卫", "name_en": "Primguard" }
48724872
]
48734873
},
48744874
{
@@ -4974,7 +4974,7 @@
49744974
{ "id": "phalanx", "name": "阵法术师", "name_en": "Phalanx Caster" },
49754975
{ "id": "blastcaster", "name": "轰击术师", "name_en": "Blast Caster" },
49764976
{ "id": "primcaster", "name": "本源术师", "name_en": "Primal Caster" },
4977-
{ "id": "soulcaster", "name": "塑灵术师", "name_en": "塑灵术师" }
4977+
{ "id": "soulcaster", "name": "塑灵术师", "name_en": "Soulcaster" }
49784978
]
49794979
}
49804980
]

0 commit comments

Comments
 (0)