feat(nds): improve some button interactions
This commit is contained in:
@@ -8,8 +8,8 @@ const QUIT_SIZE = assets.images.achievements.quit.rect.width;
|
|||||||
const QUIT_X = Math.floor(LOGICAL_WIDTH / 2 - QUIT_SIZE / 2);
|
const QUIT_X = Math.floor(LOGICAL_WIDTH / 2 - QUIT_SIZE / 2);
|
||||||
const QUIT_Y = 135;
|
const QUIT_Y = 135;
|
||||||
|
|
||||||
useKeyDown(({ key }) => {
|
useKeyDown(({ key, repeated }) => {
|
||||||
if (store.isIntro || store.isOutro) return;
|
if (store.isIntro || store.isOutro || repeated) return;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "NDS_B":
|
case "NDS_B":
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ onClick((x, y) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
useKeyDown(({ key }) => {
|
useKeyDown(({ key, repeated }) => {
|
||||||
if (props.yOffset !== 0) return;
|
if (props.yOffset !== 0 || repeated) return;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "NDS_START":
|
case "NDS_START":
|
||||||
case "NDS_A":
|
case "NDS_A":
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ const { selected, selectorPosition } = useButtonNavigation({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleActivateB = () => {
|
||||||
|
if (store.isIntro || store.isOutro) return;
|
||||||
|
store.animateOutro();
|
||||||
|
};
|
||||||
|
|
||||||
const actionateButton = async (button: (typeof selected)["value"]) => {
|
const actionateButton = async (button: (typeof selected)["value"]) => {
|
||||||
const [action, verbKey, content] = ACTIONS[button];
|
const [action, verbKey, content] = ACTIONS[button];
|
||||||
const verb = $t(verbKey);
|
const verb = $t(verbKey);
|
||||||
@@ -118,6 +123,6 @@ const actionateButton = async (button: (typeof selected)["value"]) => {
|
|||||||
"
|
"
|
||||||
:b-label="$t('common.quit')"
|
:b-label="$t('common.quit')"
|
||||||
:a-label="$t(`contact.actions.${ACTIONS[selected][0]}`)"
|
:a-label="$t(`contact.actions.${ACTIONS[selected][0]}`)"
|
||||||
@activate-b="store.animateOutro()"
|
@activate-b="handleActivateB"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -162,7 +162,8 @@ onRender((ctx) => {
|
|||||||
ctx.fillStyle = `rgba(0, 0, 0, ${store.isIntro ? store.intro.fadeOpacity : store.isOutro ? store.outro.fadeOpacity : 0})`;
|
ctx.fillStyle = `rgba(0, 0, 0, ${store.isIntro ? store.intro.fadeOpacity : store.isOutro ? store.outro.fadeOpacity : 0})`;
|
||||||
ctx.fillRect(0, 0, LOGICAL_WIDTH, LOGICAL_HEIGHT);
|
ctx.fillRect(0, 0, LOGICAL_WIDTH, LOGICAL_HEIGHT);
|
||||||
});
|
});
|
||||||
useKeyDown(({ key }) => {
|
|
||||||
|
useKeyDown(({ key, repeated }) => {
|
||||||
if (
|
if (
|
||||||
currentAnimation ||
|
currentAnimation ||
|
||||||
store.isIntro ||
|
store.isIntro ||
|
||||||
@@ -185,11 +186,15 @@ useKeyDown(({ key }) => {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "NDS_B":
|
case "NDS_B":
|
||||||
|
if (repeated) break;
|
||||||
|
|
||||||
startButtonAnimation("quit");
|
startButtonAnimation("quit");
|
||||||
store.animateOutro();
|
store.animateOutro();
|
||||||
break;
|
break;
|
||||||
case "NDS_A":
|
case "NDS_A":
|
||||||
case "NDS_START":
|
case "NDS_START":
|
||||||
|
if (repeated) break;
|
||||||
|
|
||||||
startButtonAnimation("link");
|
startButtonAnimation("link");
|
||||||
setTimeout(
|
setTimeout(
|
||||||
() => (store.showConfirmationPopup = true),
|
() => (store.showConfirmationPopup = true),
|
||||||
|
|||||||
@@ -221,8 +221,8 @@ export const useButtonNavigation = <T extends Record<string, Rect>>({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
useKeyDown(({ key }) => {
|
useKeyDown(({ key, repeated }) => {
|
||||||
if (blockInteractions.value) return;
|
if (blockInteractions.value || repeated) return;
|
||||||
|
|
||||||
const currentButton = selectedButton.value as Entry;
|
const currentButton = selectedButton.value as Entry;
|
||||||
const currentNav = navigation[currentButton];
|
const currentNav = navigation[currentButton];
|
||||||
|
|||||||
Reference in New Issue
Block a user