From e3edac3d55f260d58a73be546924a8c868760738 Mon Sep 17 00:00:00 2001
From: unanmed <1319491857@qq.com>
Date: Tue, 24 Jun 2025 23:28:36 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=BE=E7=BD=AE=E7=95=8C=E9=9D=A2?=
=?UTF-8?q?=E6=8D=A2=E7=94=A8=E6=96=B0=E7=9A=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../client-modules/src/action/hotkey.ts | 3 -
.../client-modules/src/render/action.ts | 11 +++-
.../src/render/components/choices.tsx | 12 ++--
.../src/render/components/misc.tsx | 4 +-
.../client-modules/src/render/index.tsx | 2 +-
.../client-modules/src/render/ui/save.tsx | 2 +
.../client-modules/src/render/ui/settings.tsx | 56 +++++++++++++------
7 files changed, 61 insertions(+), 29 deletions(-)
diff --git a/packages-user/client-modules/src/action/hotkey.ts b/packages-user/client-modules/src/action/hotkey.ts
index fa8ec08..0931247 100644
--- a/packages-user/client-modules/src/action/hotkey.ts
+++ b/packages-user/client-modules/src/action/hotkey.ts
@@ -489,9 +489,6 @@ gameKey
.realize('fly', () => {
core.useFly(true);
})
- .realize('menu', () => {
- core.openSettings(true);
- })
.realize('replay', () => {
core.ui._drawReplay();
})
diff --git a/packages-user/client-modules/src/render/action.ts b/packages-user/client-modules/src/render/action.ts
index 99606b5..0a70389 100644
--- a/packages-user/client-modules/src/render/action.ts
+++ b/packages-user/client-modules/src/render/action.ts
@@ -1,6 +1,12 @@
import { gameKey } from '@motajs/system-action';
import { MAIN_WIDTH, MAIN_HEIGHT } from './shared';
-import { saveSave, mainUIController, openStatistics, saveLoad } from './ui';
+import {
+ saveSave,
+ mainUIController,
+ openStatistics,
+ saveLoad,
+ openSettings
+} from './ui';
export function createAction() {
gameKey
@@ -12,5 +18,8 @@ export function createAction() {
})
.realize('load', () => {
saveLoad(mainUIController, [0, 0, MAIN_WIDTH, MAIN_HEIGHT]);
+ })
+ .realize('menu', () => {
+ openSettings(mainUIController, [420, 240, 240, 400, 0.5, 0.5]);
});
}
diff --git a/packages-user/client-modules/src/render/components/choices.tsx b/packages-user/client-modules/src/render/components/choices.tsx
index 96c403e..ad6b81d 100644
--- a/packages-user/client-modules/src/render/components/choices.tsx
+++ b/packages-user/client-modules/src/render/components/choices.tsx
@@ -144,7 +144,7 @@ export const ConfirmBox = defineComponent<
@@ -444,11 +444,13 @@ export const Choices = defineComponent<
}
});
key.realize('moveDown', () => {
+ const page = pageCom.value?.now() ?? 0;
if (selected.value === choiceCountPerPage.value - 1) {
- pageCom.value?.movePage(1);
- selected.value = 0;
+ if (page < pages.value - 1) {
+ pageCom.value?.movePage(1);
+ selected.value = 0;
+ }
} else {
- const page = pageCom.value?.now() ?? 1;
const index = page * choiceCountPerPage.value + selected.value;
if (index < props.choices.length - 1) {
selected.value++;
@@ -458,7 +460,7 @@ export const Choices = defineComponent<
key.realize('moveLeft', () => pageCom.value?.movePage(-1));
key.realize('moveRight', () => pageCom.value?.movePage(1));
key.realize('confirm', () => {
- const page = pageCom.value?.now() ?? 1;
+ const page = pageCom.value?.now() ?? 0;
const index = page * choiceCountPerPage.value + selected.value;
emit('choose', props.choices[index][0]);
});
diff --git a/packages-user/client-modules/src/render/components/misc.tsx b/packages-user/client-modules/src/render/components/misc.tsx
index b1b82db..bad8289 100644
--- a/packages-user/client-modules/src/render/components/misc.tsx
+++ b/packages-user/client-modules/src/render/components/misc.tsx
@@ -309,8 +309,8 @@ export const Selection = defineComponent(props => {
isWinskin.value ? core.material.images.images[props.winskin!] : null
);
const fixedLoc = computed(() => {
- const [x = 0, y = 0, width = 200, height = 200] = props.loc;
- return [x + 1, y + 1, width - 2, height - 2];
+ const [x = 0, y = 0, width = 200, height = 200, ax, ay] = props.loc;
+ return [x + 1, y + 1, width - 2, height - 2, ax, ay];
});
const renderWinskin = (canvas: MotaOffscreenCanvas2D) => {
diff --git a/packages-user/client-modules/src/render/index.tsx b/packages-user/client-modules/src/render/index.tsx
index 0c8af78..be9bb9d 100644
--- a/packages-user/client-modules/src/render/index.tsx
+++ b/packages-user/client-modules/src/render/index.tsx
@@ -38,7 +38,7 @@ export function createRender() {
mainRenderer.show();
});
- Font.setDefaults(new Font('normal'));
+ Font.setDefaults(new Font('normal', 18));
}
export * from './components';
diff --git a/packages-user/client-modules/src/render/ui/save.tsx b/packages-user/client-modules/src/render/ui/save.tsx
index 86572da..56f9de0 100644
--- a/packages-user/client-modules/src/render/ui/save.tsx
+++ b/packages-user/client-modules/src/render/ui/save.tsx
@@ -204,7 +204,9 @@ export const Save = defineComponent(
const index = getIndex(i, page);
promises.push(getSave(index + 1));
}
+ const before = now.value;
const data = await Promise.all(promises);
+ if (before !== now.value) return;
data.forEach((v, i) => {
if (v) {
diff --git a/packages-user/client-modules/src/render/ui/settings.tsx b/packages-user/client-modules/src/render/ui/settings.tsx
index b20e7f5..f9bfa12 100644
--- a/packages-user/client-modules/src/render/ui/settings.tsx
+++ b/packages-user/client-modules/src/render/ui/settings.tsx
@@ -1,6 +1,7 @@
import { ElementLocator } from '@motajs/render';
import {
GameUI,
+ IUIMountable,
SetupComponentOptions,
UIComponentProps
} from '@motajs/system-ui';
@@ -21,13 +22,15 @@ import { getAllSavesData, getSaveData, syncFromServer } from '../utils';
import { getInput } from '../components/input';
import { openStatistics } from './statistics';
-export interface SettingsProps extends Partial, UIComponentProps {
+export interface MainSettingsProps
+ extends Partial,
+ UIComponentProps {
loc: ElementLocator;
}
-const settingsProps = {
+const mainSettingsProps = {
props: ['loc', 'controller', 'instance']
-} satisfies SetupComponentOptions;
+} satisfies SetupComponentOptions;
const enum MainChoice {
SystemSetting,
@@ -43,7 +46,7 @@ const enum MainChoice {
Back
}
-export const MainSettings = defineComponent(props => {
+export const MainSettings = defineComponent(props => {
const choices: ChoiceItem[] = [
[MainChoice.SystemSetting, '系统设置'],
[MainChoice.VirtualKey, '虚拟键盘'],
@@ -106,9 +109,11 @@ export const MainSettings = defineComponent(props => {
choices={choices}
width={240}
onChoose={choose}
+ maxHeight={400}
+ interval={8}
/>
);
-}, settingsProps);
+}, mainSettingsProps);
const enum ReplayChoice {
Start,
@@ -120,7 +125,7 @@ const enum ReplayChoice {
Back
}
-export const ReplaySettings = defineComponent(props => {
+export const ReplaySettings = defineComponent(props => {
const choice: ChoiceItem[] = [
[ReplayChoice.Start, '从头回放录像'],
[ReplayChoice.StartFromSave, '从存档开始回放'],
@@ -186,9 +191,10 @@ export const ReplaySettings = defineComponent(props => {
choices={choice}
width={240}
onChoose={choose}
+ interval={8}
/>
);
-}, settingsProps);
+}, mainSettingsProps);
const enum GameInfoChoice {
Statistics,
@@ -199,7 +205,7 @@ const enum GameInfoChoice {
Back
}
-export const GameInfo = defineComponent(props => {
+export const GameInfo = defineComponent(props => {
const choices: ChoiceItem[] = [
[GameInfoChoice.Statistics, '数据统计'],
[GameInfoChoice.Project, '查看工程'],
@@ -272,9 +278,10 @@ export const GameInfo = defineComponent(props => {
choices={choices}
width={240}
onChoose={choose}
+ interval={8}
/>
);
-});
+}, mainSettingsProps);
const enum SyncSaveChoice {
// ----- 主菜单
@@ -289,7 +296,7 @@ const enum SyncSaveChoice {
NowSave
}
-export const SyncSave = defineComponent(props => {
+export const SyncSave = defineComponent(props => {
const choices: ChoiceItem[] = [
[SyncSaveChoice.ToServer, '同步存档至服务器'],
[SyncSaveChoice.FromServer, '从服务器加载存档'],
@@ -340,11 +347,12 @@ export const SyncSave = defineComponent(props => {
width={240}
choices={choices}
onChoose={choose}
+ interval={8}
/>
);
-});
+}, mainSettingsProps);
-export const SyncSaveSelect = defineComponent(props => {
+export const SyncSaveSelect = defineComponent(props => {
const choices: ChoiceItem[] = [
[SyncSaveChoice.AllSaves, '同步全部存档'],
[SyncSaveChoice.NowSave, '同步当前存档'],
@@ -392,11 +400,12 @@ export const SyncSaveSelect = defineComponent(props => {
width={240}
choices={choices}
onChoose={choose}
+ interval={8}
/>
);
-});
+}, mainSettingsProps);
-export const DownloadSaveSelect = defineComponent(props => {
+export const DownloadSaveSelect = defineComponent(props => {
const choices: ChoiceItem[] = [
[SyncSaveChoice.AllSaves, '下载全部存档'],
[SyncSaveChoice.NowSave, '下载当前存档'],
@@ -460,11 +469,12 @@ export const DownloadSaveSelect = defineComponent(props => {
width={240}
choices={choices}
onChoose={choose}
+ interval={8}
/>
);
-});
+}, mainSettingsProps);
-export const ClearSaveSelect = defineComponent(props => {
+export const ClearSaveSelect = defineComponent(props => {
const choices: ChoiceItem[] = [
[SyncSaveChoice.AllSaves, '清空全部塔存档'],
[SyncSaveChoice.NowSave, '清空当前塔存档'],
@@ -568,9 +578,10 @@ export const ClearSaveSelect = defineComponent(props => {
width={240}
choices={choices}
onChoose={choose}
+ interval={8}
/>
);
-});
+}, mainSettingsProps);
/** @see {@link MainSettings} */
export const MainSettingsUI = new GameUI('main-settings', MainSettings);
@@ -592,3 +603,14 @@ export const ClearSaveSelectUI = new GameUI(
'clear-save-select',
ClearSaveSelect
);
+
+export function openSettings(
+ controller: IUIMountable,
+ loc: ElementLocator,
+ props?: MainSettingsProps
+) {
+ controller.open(MainSettingsUI, {
+ ...props,
+ loc
+ });
+}