feat(nds): add pressed state for all buttons
This commit is contained in:
@@ -4,6 +4,8 @@ const props = withDefaults(
|
||||
x: number;
|
||||
y: number;
|
||||
opacity?: number;
|
||||
pressed: string | null;
|
||||
isAnyOtherMenuOpen: boolean;
|
||||
}>(),
|
||||
{
|
||||
opacity: 1,
|
||||
@@ -12,39 +14,16 @@ const props = withDefaults(
|
||||
|
||||
const { onRender } = useScreen();
|
||||
|
||||
const settingsStore = useSettingsStore();
|
||||
const menusContext = inject<{
|
||||
isSubmenuSelected: ComputedRef<boolean>;
|
||||
selectedSubmenuParent: ComputedRef<string | null>;
|
||||
}>("menusContext")!;
|
||||
|
||||
const { assets } = useAssets();
|
||||
|
||||
// TODO: i don't like this
|
||||
const isAnyOtherMenuOpen = computed(() => {
|
||||
if (settingsStore.currentSubMenu) {
|
||||
return !settingsStore.currentSubMenu.startsWith("touchScreen");
|
||||
}
|
||||
if (menusContext.isSubmenuSelected.value) {
|
||||
return menusContext.selectedSubmenuParent.value !== "touchScreen";
|
||||
}
|
||||
return false;
|
||||
});
|
||||
const { assets } = useAssets((a) => a.images.settings.topScreen.touchScreen);
|
||||
|
||||
onRender((ctx) => {
|
||||
ctx.globalAlpha = props.opacity;
|
||||
if (isAnyOtherMenuOpen.value) {
|
||||
assets.images.settings.topScreen.touchScreen.touchScreenDisabled.draw(
|
||||
ctx,
|
||||
props.x,
|
||||
props.y,
|
||||
);
|
||||
if (props.pressed === "touchScreen") {
|
||||
assets.touchScreenPressed.draw(ctx, props.x, props.y);
|
||||
} else if (props.isAnyOtherMenuOpen) {
|
||||
assets.touchScreenDisabled.draw(ctx, props.x, props.y);
|
||||
} else {
|
||||
assets.images.settings.topScreen.touchScreen.touchScreen.draw(
|
||||
ctx,
|
||||
props.x,
|
||||
props.y,
|
||||
);
|
||||
assets.touchScreen.draw(ctx, props.x, props.y);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user