feat(settings): animate transition to submenu (background and sliding)

This commit is contained in:
2026-02-09 17:00:16 +01:00
parent c96f323317
commit 6a0a0baaaa
12 changed files with 198 additions and 52 deletions

View File

@@ -1,8 +1,14 @@
<script setup lang="ts">
const props = defineProps<{
x: number;
y: number;
}>();
const props = withDefaults(
defineProps<{
x: number;
y: number;
opacity?: number;
}>(),
{
opacity: 1,
},
);
const { onRender } = useScreen();
@@ -10,6 +16,7 @@ const settingsStore = useSettingsStore();
const menusContext = inject<{
isSubmenuSelected: ComputedRef<boolean>;
selectedSubmenuParent: ComputedRef<string | null>;
selectedSubmenuExtraOffsetY: ComputedRef<number>;
}>("menusContext")!;
const { assets } = useAssets();
@@ -29,29 +36,38 @@ const isAnyOtherMenuOpen = computed(() => {
const animation = useMenuAnimation("user", isOpen);
const submenuExtraOffset = (submenu: string) =>
settingsStore.selectedButton === submenu
? menusContext.selectedSubmenuExtraOffsetY.value
: 0;
onRender((ctx) => {
ctx.globalAlpha = props.opacity;
ctx.translate(props.x, props.y);
if (isOpen.value || animation.playing) {
assets.images.settings.topScreen.user.birthday.draw(
ctx,
-48 + animation.stage2Offset,
-48 + animation.stage1Offset,
-48 + animation.stage1Offset + submenuExtraOffset("userBirthday"),
);
assets.images.settings.topScreen.user.snake.draw(
ctx,
48 - animation.stage2Offset,
-48 + animation.stage1Offset,
-48 + animation.stage1Offset + submenuExtraOffset("userSnake"),
);
assets.images.settings.topScreen.user.color.draw(
ctx,
0,
-96 + animation.stage2Offset + animation.stage1Offset,
-96 +
animation.stage2Offset +
animation.stage1Offset +
submenuExtraOffset("userColor"),
);
assets.images.settings.topScreen.user.userName.draw(
ctx,
0,
-48 + animation.stage1Offset,
-48 + animation.stage1Offset + submenuExtraOffset("userUserName"),
);
assets.images.settings.topScreen.user.userActive.draw(ctx, 0, 0);