Add some freewheelin' palette entry action
parent
094fae0302
commit
3547c2b7d4
|
@ -28,6 +28,19 @@
|
||||||
let primaryColorIndex: number = 1
|
let primaryColorIndex: number = 1
|
||||||
let secondaryColorIndex: number = 0
|
let secondaryColorIndex: number = 0
|
||||||
|
|
||||||
|
// Oh no, what are you doing, step palette~
|
||||||
|
function stepPalette(step: number, primary: boolean) {
|
||||||
|
if (primary) {
|
||||||
|
primaryColorIndex += step
|
||||||
|
if (primaryColorIndex < 0) primaryColorIndex = focusedFile?.canvas.palette.length-1
|
||||||
|
if (primaryColorIndex >= focusedFile?.canvas.palette.length) primaryColorIndex = 0
|
||||||
|
} else {
|
||||||
|
secondaryColorIndex += step
|
||||||
|
if (secondaryColorIndex < 0) secondaryColorIndex = focusedFile?.canvas.palette.length-1
|
||||||
|
if (secondaryColorIndex >= focusedFile?.canvas.palette.length) secondaryColorIndex = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let showImport: boolean = false
|
let showImport: boolean = false
|
||||||
let importValid: boolean = false
|
let importValid: boolean = false
|
||||||
let importFile: data.StackistFileV1 = null
|
let importFile: data.StackistFileV1 = null
|
||||||
|
@ -127,6 +140,10 @@
|
||||||
<Shortcut global cmd='move down' keys={['arrowdown']} on:trigger={()=>toolMove.shift({file: focusedFile}, {x: 0, y: 1, id: 0})} />
|
<Shortcut global cmd='move down' keys={['arrowdown']} on:trigger={()=>toolMove.shift({file: focusedFile}, {x: 0, y: 1, id: 0})} />
|
||||||
<Shortcut global cmd='brush' keys={['b']} on:trigger={()=>swapTool(toolBrush)} />
|
<Shortcut global cmd='brush' keys={['b']} on:trigger={()=>swapTool(toolBrush)} />
|
||||||
<Shortcut global cmd='brushToPicker' keys={['alt']} on:trigger={()=>currentTool===toolBrush?swapTool(toolPicker):null} on:release={()=>previousTool===toolBrush&¤tTool===toolPicker?swapTool(toolBrush):null} />
|
<Shortcut global cmd='brushToPicker' keys={['alt']} on:trigger={()=>currentTool===toolBrush?swapTool(toolPicker):null} on:release={()=>previousTool===toolBrush&¤tTool===toolPicker?swapTool(toolBrush):null} />
|
||||||
|
<Shortcut global cmd='previousPrimaryPaletteEntry' keys={['alt+wheelup']} on:trigger={()=>stepPalette(-1, true)}/>
|
||||||
|
<Shortcut global cmd='nextPrimaryPaletteEntry' keys={['alt+wheeldown']} on:trigger={()=>stepPalette(1, true)}/>
|
||||||
|
<Shortcut global cmd='previousSecondaryPaletteEntry' keys={['alt+shift+wheelup']} on:trigger={()=>stepPalette(-1, false)}/>
|
||||||
|
<Shortcut global cmd='nextSecondaryPaletteEntry' keys={['alt+shift+wheeldown']} on:trigger={()=>stepPalette(1, false)}/>
|
||||||
<Shortcut global cmd='fill' keys={['f']} on:trigger={()=>swapTool(toolFill)} />
|
<Shortcut global cmd='fill' keys={['f']} on:trigger={()=>swapTool(toolFill)} />
|
||||||
<Shortcut global cmd='picker' keys={['i']} on:trigger={()=>swapTool(toolPicker)} />
|
<Shortcut global cmd='picker' keys={['i']} on:trigger={()=>swapTool(toolPicker)} />
|
||||||
<Shortcut global cmd='erase' keys={['e']} on:trigger={()=>swapTool(toolErase)} />
|
<Shortcut global cmd='erase' keys={['e']} on:trigger={()=>swapTool(toolErase)} />
|
||||||
|
|
|
@ -71,6 +71,29 @@
|
||||||
keys.delete(key.toLowerCase())
|
keys.delete(key.toLowerCase())
|
||||||
keystring = keysToString([...keys])
|
keystring = keysToString([...keys])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
window.addEventListener('wheel', (event: WheelEvent) => {
|
||||||
|
if (event.deltaY < 0 || event.deltaX < 0) {
|
||||||
|
keys.add('wheelup')
|
||||||
|
} else if (event.deltaY > 0 || event.deltaX > 0) {
|
||||||
|
keys.add('wheeldown')
|
||||||
|
}
|
||||||
|
|
||||||
|
keystring = keysToString([...keys])
|
||||||
|
|
||||||
|
let cur = get(currentShortcuts)
|
||||||
|
for (let shortcut of get(shortcuts)) {
|
||||||
|
if (shortcut.group !== cur.group) continue
|
||||||
|
if (!shortcut.global && shortcut.id !== cur.id) continue
|
||||||
|
if (shortcut.keys.includes(keystring)) {
|
||||||
|
shortcut.trigger()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
keys.delete('wheelup')
|
||||||
|
keys.delete('wheeldown')
|
||||||
|
})
|
||||||
|
|
||||||
window.addEventListener('blur', () => {
|
window.addEventListener('blur', () => {
|
||||||
keys.clear()
|
keys.clear()
|
||||||
keystring = ''
|
keystring = ''
|
||||||
|
|
|
@ -274,6 +274,7 @@
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (e.altKey) return
|
||||||
if (e.deltaY < 0) {
|
if (e.deltaY < 0) {
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
offsetX--
|
offsetX--
|
||||||
|
|
|
@ -15,9 +15,21 @@
|
||||||
primaryColorIndex = index
|
primaryColorIndex = index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function handleWheel(event: WheelEvent) {
|
||||||
|
if (event.deltaX < 0) {
|
||||||
|
secondaryColorIndex = (secondaryColorIndex - 1 + file.canvas.palette.length) % file.canvas.palette.length
|
||||||
|
} else if (event.deltaX > 0) {
|
||||||
|
secondaryColorIndex = (secondaryColorIndex + 1) % file.canvas.palette.length
|
||||||
|
}
|
||||||
|
if (event.deltaY < 0) {
|
||||||
|
primaryColorIndex = (primaryColorIndex - 1 + file.canvas.palette.length) % file.canvas.palette.length
|
||||||
|
} else if (event.deltaY > 0) {
|
||||||
|
primaryColorIndex = (primaryColorIndex + 1) % file.canvas.palette.length
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<main>
|
<main on:wheel={handleWheel}>
|
||||||
{#if file}
|
{#if file}
|
||||||
{#each file.canvas.palette as palette, paletteIndex}
|
{#each file.canvas.palette as palette, paletteIndex}
|
||||||
<span on:click={paletteClick} x-index={paletteIndex} class='entry{paletteIndex===primaryColorIndex?' primary':''}{paletteIndex===secondaryColorIndex?' secondary':''}'>
|
<span on:click={paletteClick} x-index={paletteIndex} class='entry{paletteIndex===primaryColorIndex?' primary':''}{paletteIndex===secondaryColorIndex?' secondary':''}'>
|
||||||
|
|
Loading…
Reference in New Issue