feat: 工具栏整合成一个组件

This commit is contained in:
unanmed 2025-09-28 16:31:16 +08:00
parent 7276380482
commit 206bed7dc0
3 changed files with 26 additions and 31 deletions

View File

@ -117,6 +117,7 @@ const MainScene = defineComponent(() => {
magicDef: 0 magicDef: 0
}); });
const replayStatus: ReplayingStatus = reactive({ const replayStatus: ReplayingStatus = reactive({
replaying: false,
playing: false, playing: false,
speed: 1, speed: 1,
played: 0, played: 0,
@ -129,7 +130,6 @@ const MainScene = defineComponent(() => {
jumpCount: 0, jumpCount: 0,
springCount: 0, springCount: 0,
floor: 'MT0', floor: 'MT0',
replaying: false,
replayStatus, replayStatus,
night: 0 night: 0
}); });
@ -161,8 +161,8 @@ const MainScene = defineComponent(() => {
rightStatus.skillDesc = HeroSkill.getSkillDesc(); rightStatus.skillDesc = HeroSkill.getSkillDesc();
rightStatus.night = NightSpecial.getNight(floor); rightStatus.night = NightSpecial.getNight(floor);
rightStatus.floor = floor; rightStatus.floor = floor;
rightStatus.replaying = core.isReplaying();
const { pausing, speed, toReplay, totalList } = core.status.replay; const { pausing, speed, toReplay, totalList } = core.status.replay;
replayStatus.replaying = core.isReplaying();
replayStatus.playing = !pausing; replayStatus.playing = !pausing;
replayStatus.speed = speed; replayStatus.speed = speed;
replayStatus.played = totalList.length - toReplay.length; replayStatus.played = totalList.length - toReplay.length;

View File

@ -12,12 +12,7 @@ import { transitionedColor } from '../use';
import { linear } from 'mutate-animate'; import { linear } from 'mutate-animate';
import { Scroll } from '../components'; import { Scroll } from '../components';
import { getArea, MinimapDrawer } from '@motajs/legacy-ui'; import { getArea, MinimapDrawer } from '@motajs/legacy-ui';
import { import { MixedToolbar, ReplayingStatus } from './toolbar';
NumpadToolbar,
PlayingToolbar,
ReplayingStatus,
ReplayingToolbar
} from './toolbar';
import { HeroSkill } from '@user/data-state'; import { HeroSkill } from '@user/data-state';
import { openViewMap } from './viewmap'; import { openViewMap } from './viewmap';
import { mainUIController } from './controller'; import { mainUIController } from './controller';
@ -55,8 +50,6 @@ export interface IRightHeroStatus {
springCount: number; springCount: number;
/** 当前楼层 */ /** 当前楼层 */
floor: FloorIds; floor: FloorIds;
/** 是否正在录像播放 */
replaying: boolean;
/** 录像播放状态 */ /** 录像播放状态 */
replayStatus: ReplayingStatus; replayStatus: ReplayingStatus;
/** 极昼永夜 */ /** 极昼永夜 */
@ -216,11 +209,6 @@ export const RightStatusBar = defineComponent<StatusBarProps<IRightHeroStatus>>(
const font2 = new Font('normal', 16); const font2 = new Font('normal', 16);
const minimap = ref<Sprite>(); const minimap = ref<Sprite>();
const inNumpad = ref(false);
const onNumpad = () => {
inNumpad.value = !inNumpad.value;
};
const s = p.status; const s = p.status;
const skill = computed(() => const skill = computed(() =>
@ -395,22 +383,10 @@ export const RightStatusBar = defineComponent<StatusBarProps<IRightHeroStatus>>(
lineWidth={1} lineWidth={1}
zIndex={-20} zIndex={-20}
></g-line> ></g-line>
{inNumpad.value ? ( <MixedToolbar
<NumpadToolbar
loc={[0, 367, 180, 113]}
onNumpad={onNumpad}
/>
) : s.replaying ? (
<ReplayingToolbar
loc={[0, 367, 180, 113]} loc={[0, 367, 180, 113]}
status={s.replayStatus} status={s.replayStatus}
/> />
) : (
<PlayingToolbar
loc={[0, 367, 180, 113]}
onNumpad={onNumpad}
/>
)}
</container> </container>
); );
}; };

View File

@ -145,6 +145,8 @@ export const PlayingToolbar = defineComponent<
}, toolbarProps); }, toolbarProps);
export interface ReplayingStatus { export interface ReplayingStatus {
/** 是否处在录像播放状态 */
replaying: boolean;
/** 是否正在播放 */ /** 是否正在播放 */
playing: boolean; playing: boolean;
/** 录像播放速度 */ /** 录像播放速度 */
@ -378,3 +380,20 @@ export const NumpadToolbar = defineComponent<
</container> </container>
); );
}, toolbarProps); }, toolbarProps);
export const MixedToolbar = defineComponent<ReplayingProps>(props => {
const inNumpad = ref(false);
const onNumpad = () => {
inNumpad.value = !inNumpad.value;
};
return () =>
inNumpad.value ? (
<NumpadToolbar loc={props.loc} onNumpad={onNumpad} />
) : props.status.replaying ? (
<ReplayingToolbar loc={props.loc} status={props.status} />
) : (
<PlayingToolbar loc={props.loc} onNumpad={onNumpad} />
);
}, replayingProps);