navigation refinement

This commit is contained in:
Spencer Kuzara
2025-08-23 15:48:11 +09:00
parent 71f8edb1a9
commit 63853d6fb1
5 changed files with 272 additions and 149 deletions

View File

@@ -1,164 +1,31 @@
<template>
<div class="fixed bottom-4 right-20 flex items-center gap-10 bg-black/50 px-8 py-3 rounded-lg backdrop-blur text-white/70 text-[12px] z-[100] pointer-events-none select-none border border-white/10">
<!-- Controller Mode -->
<template v-if="hasController">
<div
v-if="showNavigation"
class="flex items-center gap-2"
>
<DPadIcon class="w-8 h-8 opacity-80" />
<span class="font-medium tracking-wide">Navigation</span>
</div>
<div
v-if="showSelect"
class="flex items-center gap-2"
>
<FaceButtons highlight="south" />
<span class="font-medium tracking-wide">Select</span>
</div>
<div
v-if="showBack"
class="flex items-center gap-2"
>
<FaceButtons highlight="east" />
<span class="font-medium tracking-wide">Back</span>
</div>
<div
v-if="showToggleFavorite"
class="flex items-center gap-2"
>
<FaceButtons highlight="north" />
<span class="font-medium tracking-wide">Favorite</span>
</div>
</template>
<!-- Keyboard Mode -->
<template v-else>
<div
v-if="showNavigation"
class="flex items-center gap-2"
>
<ArrowKeysIcon />
<span class="font-medium tracking-wide">Navigation</span>
</div>
<div
v-if="showSelect"
class="flex items-center gap-2"
>
<span class="keycap">Enter</span>
<span class="font-medium tracking-wide">Select</span>
</div>
<div
v-if="showBack"
class="flex items-center gap-2"
>
<span class="keycap">Bkspc</span>
<span class="font-medium tracking-wide">Back</span>
</div>
<div
v-if="showToggleFavorite"
class="flex items-center gap-2"
>
<span class="keycap">F</span>
<span class="font-medium tracking-wide">Favorite</span>
</div>
</template>
<div class="fixed bottom-4 right-20 bg-black/50 px-8 py-3 rounded-lg backdrop-blur border border-white/10 z-[100] pointer-events-none select-none">
<NavigationText
:show-navigation="showNavigation"
:show-select="showSelect"
:show-back="showBack"
:show-toggle-favorite="showToggleFavorite"
:show-menu="showMenu"
/>
</div>
</template>
<script setup lang="ts">
import { onMounted, onUnmounted, ref, defineComponent, h } from 'vue';
/* eslint-disable vue/one-component-per-file */
import NavigationText from './NavigationText.vue';
interface Props {
showNavigation?: boolean;
showSelect?: boolean;
showBack?: boolean;
showToggleFavorite?: boolean;
showMenu?: boolean;
}
withDefaults(defineProps<Props>(), {
showNavigation: true,
showSelect: true,
showBack: true,
showToggleFavorite: false
});
const hasController = ref(false);
let rafId = 0;
function poll(){
const pads = navigator.getGamepads?.() || [];
hasController.value = pads.some(p => p && p.connected);
rafId = requestAnimationFrame(poll);
}
onMounted(() => {
window.addEventListener('gamepadconnected', pollOnce);
window.addEventListener('gamepaddisconnected', pollOnce);
poll();
});
onUnmounted(() => {
cancelAnimationFrame(rafId);
window.removeEventListener('gamepadconnected', pollOnce);
window.removeEventListener('gamepaddisconnected', pollOnce);
});
function pollOnce(){ poll(); }
// Icons rendered via render functions (no runtime template compilation needed)
const DPadIcon = defineComponent({
name: 'DPadIcon',
setup() {
return () => h('svg', { viewBox: '0 0 40 40', class: 'text-white/70', fill: 'none' }, [
h('rect', { x:16, y:4, width:8, height:12, rx:2, class:'fill-white/70' }),
h('rect', { x:16, y:24, width:8, height:12, rx:2, class:'fill-white/70' }),
h('rect', { x:4, y:16, width:12, height:8, rx:2, class:'fill-white/70' }),
h('rect', { x:24, y:16, width:12, height:8, rx:2, class:'fill-white/70' }),
h('rect', { x:16, y:16, width:8, height:8, rx:2, class:'fill-white/40' }),
]);
},
});
const FaceButtons = defineComponent({
name: 'FaceButtons',
props: { highlight: { type: String, default: 'south' } },
setup(props) {
// Render as SVG for crisp alignment; monochrome circles, filled highlight
const mapping: Record<string,{cx:number; cy:number}> = {
north: { cx: 12, cy: 4 },
south: { cx: 12, cy: 20 },
west: { cx: 4, cy: 12 },
east: { cx: 20, cy: 12 },
};
const order = ['north','south','west','east'] as const;
return () => h('svg', { viewBox: '0 0 24 24', class: 'w-8 h-8 text-white/70 translate-y-[1px]' },
order.map(b => h('circle', {
key: b,
cx: mapping[b].cx,
cy: mapping[b].cy,
r: 4,
class: b === props.highlight ? 'fill-white/70' : 'fill-white/15',
}))
);
},
});
// Keyboard arrow cluster icon (render function)
const ArrowKeysIcon = defineComponent({
name: 'ArrowKeysIcon',
setup(){
const key = (x:number,y:number,label:string) => h('g', [
h('rect', { x, y, width:14, height:14, rx:3, class:'fill-white/10 stroke-white/20' }),
h('text', { x: x+7, y: y+9, 'text-anchor':'middle', 'font-size':'8', class:'fill-white/70 select-none' }, label),
]);
return () => h('svg', { viewBox:'0 0 44 30', class:'w-14 h-[28px] text-white/70' }, [
key(15,1,'↑'),
key(1,15,'←'),
key(15,15,'↓'),
key(29,15,'→'),
]);
}
showToggleFavorite: false,
showMenu: false
});
</script>
<style scoped>
.keycap { display:inline-flex; align-items:center; justify-content:center; padding:0.25rem 0.55rem; border-radius:0.375rem; border:1px solid rgba(255,255,255,0.25); background:rgba(255,255,255,0.08); color:rgba(255,255,255,0.85); font-weight:500; line-height:1; font-size:12px; box-shadow:0 2px 0 0 rgba(255,255,255,0.12);}
</style>

View File

@@ -0,0 +1,214 @@
<template>
<div class="flex items-center gap-6 text-white/70 text-[12px]">
<!-- Controller Mode -->
<template v-if="hasController">
<div
v-if="showNavigation"
class="flex items-center gap-2"
>
<DPadIcon class="w-8 h-8 opacity-80" />
<span class="font-medium tracking-wide">Navigation</span>
</div>
<div
v-if="showSelect"
class="flex items-center gap-2"
>
<FaceButtons highlight="south" />
<span class="font-medium tracking-wide">Select</span>
</div>
<div
v-if="showBack"
class="flex items-center gap-2"
>
<FaceButtons highlight="east" />
<span class="font-medium tracking-wide">Back</span>
</div>
<div
v-if="showToggleFavorite"
class="flex items-center gap-2"
>
<FaceButtons highlight="north" />
<span class="font-medium tracking-wide">Favorite</span>
</div>
<div
v-if="showMenu"
class="flex items-center gap-2"
>
<FaceButtons highlight="west" />
<span class="font-medium tracking-wide">Menu</span>
</div>
</template>
<!-- Keyboard Mode -->
<template v-else>
<div
v-if="showNavigation"
class="flex items-center gap-2"
>
<ArrowKeysIcon />
<span class="font-medium tracking-wide">Navigation</span>
</div>
<div
v-if="showSelect"
class="flex items-center gap-2"
>
<span class="keycap">Enter</span>
<span class="font-medium tracking-wide">Select</span>
</div>
<div
v-if="showBack"
class="flex items-center gap-2"
>
<span class="keycap">Bkspc</span>
<span class="font-medium tracking-wide">Back</span>
</div>
<div
v-if="showToggleFavorite"
class="flex items-center gap-2"
>
<span class="keycap">F</span>
<span class="font-medium tracking-wide">Favorite</span>
</div>
<div
v-if="showMenu"
class="flex items-center gap-2"
>
<span class="keycap">X</span>
<span class="font-medium tracking-wide">Menu</span>
</div>
</template>
</div>
</template>
<script setup lang="ts">
import { onMounted, onUnmounted, ref, defineComponent, h } from 'vue';
/* eslint-disable vue/one-component-per-file */
interface Props {
showNavigation?: boolean;
showSelect?: boolean;
showBack?: boolean;
showToggleFavorite?: boolean;
showMenu?: boolean;
}
withDefaults(defineProps<Props>(), {
showNavigation: true,
showSelect: true,
showBack: true,
showToggleFavorite: false,
showMenu: false
});
const hasController = ref(false);
let rafId = 0;
function poll(){
const pads = navigator.getGamepads?.() || [];
hasController.value = pads.some(p => p && p.connected);
rafId = requestAnimationFrame(poll);
}
onMounted(() => {
window.addEventListener('gamepadconnected', pollOnce);
window.addEventListener('gamepaddisconnected', pollOnce);
poll();
});
onUnmounted(() => {
cancelAnimationFrame(rafId);
window.removeEventListener('gamepadconnected', pollOnce);
window.removeEventListener('gamepaddisconnected', pollOnce);
});
function pollOnce(){ poll(); }
// Icons rendered via render functions (no runtime template compilation needed)
const DPadIcon = defineComponent({
name: 'DPadIcon',
setup() {
return () => h('svg', { viewBox: '0 0 40 40', class: 'text-white/70', fill: 'none' }, [
h('rect', { x:16, y:4, width:8, height:12, rx:2, class:'fill-white/70' }),
h('rect', { x:16, y:24, width:8, height:12, rx:2, class:'fill-white/70' }),
h('rect', { x:4, y:16, width:12, height:8, rx:2, class:'fill-white/70' }),
h('rect', { x:24, y:16, width:12, height:8, rx:2, class:'fill-white/70' }),
h('rect', { x:16, y:16, width:8, height:8, rx:2, class:'fill-white/40' }),
]);
},
});
const FaceButtons = defineComponent({
name: 'FaceButtons',
props: { highlight: { type: String, default: 'south' } },
setup(props) {
// Render as SVG for crisp alignment; monochrome circles, filled highlight
const mapping: Record<string,{cx:number; cy:number}> = {
north: { cx: 12, cy: 4 },
south: { cx: 12, cy: 20 },
west: { cx: 4, cy: 12 },
east: { cx: 20, cy: 12 },
};
const order = ['north','south','west','east'] as const;
return () => h('svg', { viewBox: '0 0 24 24', class: 'w-8 h-8 text-white/70 translate-y-[1px]' },
order.map(b => h('circle', {
key: b,
cx: mapping[b].cx,
cy: mapping[b].cy,
r: 4,
class: b === props.highlight ? 'fill-white/70' : 'fill-white/15',
}))
);
},
});
// Keyboard arrow cluster icon (render function)
const ArrowKeysIcon = defineComponent({
name: 'ArrowKeysIcon',
setup(){
const key = (x: number, y: number, arrowPath: string) => h('g', [
h('rect', {
x, y,
width: 12,
height: 12,
rx: 2,
class: 'fill-white/10 stroke-white/25',
'stroke-width': '0.5'
}),
h('path', {
d: arrowPath,
class: 'fill-white/70',
transform: `translate(${x + 6}, ${y + 6})`
})
]);
// Arrow paths centered at origin
const arrows = {
up: 'M 0 -3 L -2 -1 L -1 -1 L -1 3 L 1 3 L 1 -1 L 2 -1 Z',
down: 'M 0 3 L -2 1 L -1 1 L -1 -3 L 1 -3 L 1 1 L 2 1 Z',
left: 'M -3 0 L -1 -2 L -1 -1 L 3 -1 L 3 1 L -1 1 L -1 2 Z',
right: 'M 3 0 L 1 -2 L 1 -1 L -3 -1 L -3 1 L 1 1 L 1 2 Z'
};
return () => h('svg', {
viewBox: '0 0 40 28',
class: 'w-10 h-7 text-white/70',
fill: 'none',
stroke: 'currentColor'
}, [
key(14, 1, arrows.up), // Top arrow
key(1, 14, arrows.left), // Left arrow
key(14, 14, arrows.down), // Down arrow
key(27, 14, arrows.right) // Right arrow
]);
},
});
</script>
<style scoped>
.keycap {
background-color: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
padding: 0.25rem 0.5rem;
border-radius: 0.25rem;
font-size: 10px;
font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
font-weight: 700;
letter-spacing: 0.05em;
}
</style>

View File

@@ -66,7 +66,13 @@
</div>
<div class="modal-footer">
<span class="modal-hint">← → Navigate • Backspace to close</span>
<NavigationText
:show-navigation="true"
:show-select="false"
:show-back="true"
:show-toggle-favorite="false"
:show-menu="false"
/>
</div>
</div>
</div>
@@ -74,6 +80,7 @@
<script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue';
import NavigationText from './NavigationText.vue';
const props = defineProps<{ urls: string[]; startIndex?: number }>();
const emit = defineEmits(['close']);

View File

@@ -235,7 +235,13 @@
<p>{{ rom?.summary }}</p>
</div>
<div class="modal-footer">
<span class="modal-hint">↑↓ Scroll • Backspace to close</span>
<NavigationText
:show-navigation="true"
:show-select="false"
:show-back="true"
:show-toggle-favorite="false"
:show-menu="false"
/>
</div>
</div>
</div>
@@ -326,7 +332,13 @@
</div>
</div>
<div class="modal-footer">
<span class="modal-hint">Backspace to close</span>
<NavigationText
:show-navigation="false"
:show-select="false"
:show-back="true"
:show-toggle-favorite="false"
:show-menu="false"
/>
</div>
</div>
</div>
@@ -336,6 +348,14 @@
:start-index="selectedShot"
@close="showLightbox=false"
/>
<NavigationHint
:show-navigation="true"
:show-select="true"
:show-back="true"
:show-toggle-favorite="false"
:show-menu="false"
/>
</div>
</template>
@@ -345,8 +365,10 @@ import { formatDistanceToNow } from 'date-fns';
import { useRoute, useRouter } from 'vue-router';
import romApi from '@/services/api/rom';
import type { DetailedRomSchema } from '@/__generated__/models/DetailedRomSchema';
import ScreenshotLightbox from '@/console/components/ScreenshotLightbox.vue';
import ScreenshotLightbox from '@/console/components/ScreenshotLightbox.vue';
import BackButton from '@/console/components/BackButton.vue';
import NavigationText from '@/console/components/NavigationText.vue';
import NavigationHint from '@/console/components/NavigationHint.vue';
import { useInputScope } from '@/console/composables/useInputScope';
import type { InputAction } from '@/console/input/actions';
import { getCoreForPlatform } from '@/console/constants/cores';
@@ -448,6 +470,7 @@ function handleAction(action: InputAction): boolean {
return false;
case 'details':
if(action==='moveLeft') { selectedZone.value='play'; return true; }
if(action==='moveUp') { selectedZone.value='description'; return true; }
if(action==='moveDown') {
if(rom.value?.user_states?.length){ selectedZone.value='states'; selectedStateIndex.value = 0; return true; }
if(screenshotUrls.value.length){ selectedZone.value='shots'; selectedShot.value = 0; nextTick(scrollShotsToSelected); } return true; }

View File

@@ -79,6 +79,17 @@
>
{{ saveError }}
</p>
<!-- Navigation Hints -->
<div class="mt-4 pt-3 border-t border-white/10">
<NavigationText
:show-navigation="true"
:show-select="true"
:show-back="true"
:show-toggle-favorite="false"
:show-menu="false"
/>
</div>
</div>
</div>
</div>
@@ -92,6 +103,7 @@ import type { DetailedRomSchema } from '@/__generated__/models/DetailedRomSchema
import { getSupportedEJSCores, getControlSchemeForPlatform, areThreadsRequiredForEJSCore, getDownloadPath } from '@/utils';
import firmwareApi from '@/services/api/firmware';
import { useInputScope } from '@/console/composables/useInputScope';
import NavigationText from '@/console/components/NavigationText.vue';
import api from '@/services/api';
const route = useRoute();