ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Add dockable Art tools, animation and previews, guarded asset workflows, and the Web Asset Studio built on the shared Art Core. Expand English and Russian documentation, interactive Try scenes, examples and editor icons. Add audio waveform navigation, source analysis, guarded previews and a browser Worker mixer. Preserve source changes and recovery with bounded checks, and strengthen native, browser and interoperability CI. Prepare version 0.12.5 and manually built native artifact candidates. Fix the production site image demo build dependency. Reuse immutable scene indices when capturing keyframes. Wait for real Persist save/load completion in component tests. Stabilize browser Game View captures outside pointer hover. Aseprite interchange and persistent Audio EDL recovery remain limited; the artifact workflow does not publish releases or change stable.
144 lines
3.8 KiB
Go
144 lines
3.8 KiB
Go
package web
|
|
|
|
import (
|
|
"aego/core/mathx"
|
|
"aego/platform"
|
|
"aego/platform/input"
|
|
)
|
|
|
|
// inputFence delays Inspector keys one UI frame for focus, preserving order without delaying game-view input.
|
|
type inputFence struct {
|
|
hit func(mathx.Vec2, bool) bool
|
|
start mathx.Vec2
|
|
armed bool
|
|
wait bool
|
|
delayed bool
|
|
}
|
|
|
|
func (f *inputFence) reset() {
|
|
f.armed, f.wait, f.delayed = false, false, false
|
|
}
|
|
|
|
func pointerEvent(kind platform.EventKind) bool {
|
|
switch kind {
|
|
case platform.EvMouseDown, platform.EvMouseUp, platform.EvMouseMove, platform.EvMouseWheel:
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func modifierKey(scan input.Scancode) bool {
|
|
return scan >= input.KeyLCtrl && scan <= input.KeyRGUI
|
|
}
|
|
|
|
func interruptsFence(kind platform.EventKind) bool {
|
|
switch kind {
|
|
case platform.EvQuit, platform.EvWindowFocusLost, platform.EvWindowResized, platform.EvWindowMinimized,
|
|
platform.EvDropBegin, platform.EvDropFile, platform.EvDropText, platform.EvDropComplete:
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// dispatch consumes a prefix and emits browser text captured before input was enabled only if delayed input still belongs to the canvas and text field.
|
|
func (f *inputFence) dispatch(events []platform.Event, focused, textInput bool, emit func(platform.Event)) int {
|
|
if f.hit == nil {
|
|
for _, ev := range events {
|
|
emit(ev)
|
|
}
|
|
return len(events)
|
|
}
|
|
if f.delayed {
|
|
// Interrupt stale Inspector input when focus, scene, viewport or modal state changes.
|
|
interrupt := !focused || !f.hit(f.start, true)
|
|
for _, ev := range events {
|
|
interrupt = interrupt || interruptsFence(ev.Kind)
|
|
}
|
|
if interrupt {
|
|
for _, ev := range events {
|
|
if !isHeldInput(ev.Kind) {
|
|
emit(ev)
|
|
}
|
|
}
|
|
f.reset()
|
|
return len(events)
|
|
}
|
|
}
|
|
if f.wait {
|
|
f.wait = false
|
|
return 0
|
|
}
|
|
replay, keyboard, action := f.delayed, false, false
|
|
for i, ev := range events {
|
|
// Deliver earlier delayed keys before a later click can change their target.
|
|
if replay && keyboard && pointerEvent(ev.Kind) {
|
|
return i
|
|
}
|
|
// Keep each non-modifier key and its modifiers in a separate frame to preserve editing order.
|
|
if replay && action && (ev.Kind == platform.EvKeyDown || ev.Kind == platform.EvKeyUp) &&
|
|
(modifierKey(ev.Key.Scan) || ev.Kind == platform.EvKeyDown) {
|
|
return i
|
|
}
|
|
if interruptsFence(ev.Kind) {
|
|
f.armed = false
|
|
}
|
|
if replay && ev.Kind == platform.EvTextInput && !textInput {
|
|
continue
|
|
}
|
|
switch ev.Kind {
|
|
case platform.EvMouseDown:
|
|
f.armed = ev.Mouse.Button == input.MouseLeft && f.hit(ev.Mouse.Pos, false)
|
|
f.start = ev.Mouse.Pos
|
|
case platform.EvMouseMove:
|
|
if ev.Mouse.Pos.Sub(f.start).Len() >= 3 {
|
|
f.armed = false
|
|
}
|
|
case platform.EvMouseUp:
|
|
clicked := f.armed && ev.Mouse.Button == input.MouseLeft && ev.Mouse.Pos.Sub(f.start).Len() < 3 && f.hit(ev.Mouse.Pos, true)
|
|
f.armed = false
|
|
emit(ev)
|
|
if clicked {
|
|
f.wait, f.delayed = true, true
|
|
return i + 1
|
|
}
|
|
continue
|
|
case platform.EvKeyDown:
|
|
keyboard = true
|
|
if !modifierKey(ev.Key.Scan) {
|
|
action = true
|
|
}
|
|
case platform.EvKeyUp:
|
|
keyboard = true
|
|
case platform.EvTextInput:
|
|
keyboard = true
|
|
action = true
|
|
}
|
|
emit(ev)
|
|
if replay && textInput && ev.Kind == platform.EvKeyDown && ev.TextN > 0 {
|
|
emit(platform.Event{Kind: platform.EvTextInput, Text: ev.Text, TextN: ev.TextN, Window: ev.Window})
|
|
}
|
|
}
|
|
f.delayed = false
|
|
return len(events)
|
|
}
|
|
|
|
// discardHeldInput prevents stale input reaching a new Inspector while preserving releases and system events.
|
|
func discardHeldInput(events []platform.Event) []platform.Event {
|
|
out := events[:0]
|
|
for _, ev := range events {
|
|
if isHeldInput(ev.Kind) {
|
|
continue
|
|
}
|
|
out = append(out, ev)
|
|
}
|
|
return out
|
|
}
|
|
|
|
func isHeldInput(kind platform.EventKind) bool {
|
|
switch kind {
|
|
case platform.EvKeyDown, platform.EvTextInput, platform.EvMouseDown, platform.EvMouseMove, platform.EvMouseWheel:
|
|
return true
|
|
}
|
|
return false
|
|
}
|