feat(nds): add pressed state for all buttons
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
const { onRender, onClick } = useScreen();
|
||||
const { onRender, onClick, onMouseDown } = useScreen();
|
||||
const store = useAchievementsScreen();
|
||||
const achievementsStore = useAchievementsStore();
|
||||
const { assets } = useAssets();
|
||||
@@ -8,6 +8,22 @@ const QUIT_SIZE = assets.images.achievements.quit.rect.width;
|
||||
const QUIT_X = Math.floor(LOGICAL_WIDTH / 2 - QUIT_SIZE / 2);
|
||||
const QUIT_Y = 135;
|
||||
|
||||
const quitPressed = ref(false);
|
||||
|
||||
const handleMouseUp = () => {
|
||||
quitPressed.value = false;
|
||||
};
|
||||
|
||||
onMounted(() => document.addEventListener("mouseup", handleMouseUp));
|
||||
onUnmounted(() => document.removeEventListener("mouseup", handleMouseUp));
|
||||
|
||||
onMouseDown((x, y) => {
|
||||
if (store.isIntro || store.isOutro) return;
|
||||
if (rectContains([QUIT_X, QUIT_Y, QUIT_SIZE, QUIT_SIZE], [x, y])) {
|
||||
quitPressed.value = true;
|
||||
}
|
||||
});
|
||||
|
||||
useKeyDown(({ key, repeated }) => {
|
||||
if (store.isIntro || store.isOutro || repeated) return;
|
||||
|
||||
@@ -76,7 +92,10 @@ onRender((ctx) => {
|
||||
: store.isOutro
|
||||
? store.outro.stage2Opacity
|
||||
: 1;
|
||||
assets.images.achievements.quit.draw(ctx, QUIT_X, QUIT_Y);
|
||||
(quitPressed.value
|
||||
? assets.images.achievements.quitPressed
|
||||
: assets.images.achievements.quit
|
||||
).draw(ctx, QUIT_X, QUIT_Y);
|
||||
});
|
||||
|
||||
defineOptions({
|
||||
|
||||
Reference in New Issue
Block a user