Android build v1.1.20
This commit is contained in:
@@ -665,9 +665,7 @@ export function Iwt2RoguelikeUpgradeScreen({
|
||||
setSelectedIndex((current) => moveUpgradeSelection(entries, current, action))
|
||||
return
|
||||
}
|
||||
if (action === 'back' || action === 'pause') {
|
||||
onBack()
|
||||
}
|
||||
if (action === 'back' || action === 'pause') return
|
||||
})
|
||||
|
||||
return (
|
||||
@@ -956,10 +954,8 @@ function nextEnabledIndex(actions: Iwt2NavAction[], current: number, direction:
|
||||
}
|
||||
|
||||
function activeUpgradeEntry(entries: Iwt2UpgradeNavEntry[], index: number) {
|
||||
const bounded = Math.min(index, entries.length - 1)
|
||||
const active = entries[bounded]
|
||||
if (active && !upgradeEntryDisabled(active)) return active
|
||||
return entries.find((entry) => !upgradeEntryDisabled(entry))
|
||||
if (entries.length === 0) return undefined
|
||||
return entries[Math.min(index, entries.length - 1)]
|
||||
}
|
||||
|
||||
function upgradeEntryDisabled(entry: Iwt2UpgradeNavEntry) {
|
||||
@@ -967,30 +963,17 @@ function upgradeEntryDisabled(entry: Iwt2UpgradeNavEntry) {
|
||||
}
|
||||
|
||||
function moveUpgradeSelection(entries: Iwt2UpgradeNavEntry[], current: number, action: string) {
|
||||
const enabledEntries = entries
|
||||
.map((entry, index) => ({ entry, index }))
|
||||
.filter(({ entry }) => !upgradeEntryDisabled(entry))
|
||||
if (enabledEntries.length === 0) return 0
|
||||
if (entries.length === 0) return 0
|
||||
const bounded = Math.min(current, entries.length - 1)
|
||||
const candidate = entries[bounded]
|
||||
const active = candidate && !upgradeEntryDisabled(candidate)
|
||||
? candidate
|
||||
: enabledEntries[0]?.entry
|
||||
if (!active) return bounded
|
||||
const candidates = enabledEntries.filter(({ entry }) => {
|
||||
if (entry === active) return false
|
||||
if (action === 'navigateLeft') return entry.row === active.row && entry.column < active.column
|
||||
if (action === 'navigateRight') return entry.row === active.row && entry.column > active.column
|
||||
if (action === 'navigateUp') return entry.row < active.row
|
||||
return entry.row > active.row
|
||||
})
|
||||
if (candidates.length === 0) return entries.findIndex((entry) => entry === active)
|
||||
candidates.sort((a, b) => {
|
||||
const aPrimary = Math.abs(a.entry.row - active.row) + Math.abs(a.entry.column - active.column)
|
||||
const bPrimary = Math.abs(b.entry.row - active.row) + Math.abs(b.entry.column - active.column)
|
||||
return aPrimary - bPrimary || a.index - b.index
|
||||
})
|
||||
return candidates[0]?.index ?? bounded
|
||||
const active = entries[bounded]
|
||||
const continueIndex = entries.findIndex((entry) => entry.kind === 'upgradeContinue' || entry.kind === 'upgradeLeave')
|
||||
const lastChoiceIndex = Math.max(0, continueIndex >= 0 ? continueIndex - 1 : entries.length - 1)
|
||||
if (action === 'navigateRight') return Math.min(lastChoiceIndex, bounded + 1)
|
||||
if (action === 'navigateLeft') return Math.max(0, bounded - 1)
|
||||
if (action === 'navigateDown') return continueIndex >= 0 ? continueIndex : bounded
|
||||
if (action === 'navigateUp' && active?.kind === 'upgradeContinue') return lastChoiceIndex
|
||||
if (action === 'navigateUp' && active?.kind === 'upgradeLeave') return lastChoiceIndex
|
||||
return bounded
|
||||
}
|
||||
|
||||
function moveSpatialSelection(actions: Iwt2NavAction[], current: number, action: string) {
|
||||
|
||||
Reference in New Issue
Block a user