2023-11-23 22:05:22 +03:00
|
|
|
package gg
|
|
|
|
|
|
|
|
import (
|
2023-11-23 23:12:41 +03:00
|
|
|
//"github.com/hajimehoshi/ebiten/v2"
|
2023-11-23 22:05:22 +03:00
|
|
|
)
|
|
|
|
|
2024-05-28 11:24:12 +03:00
|
|
|
import "surdeus.su/core/gg/mx"
|
|
|
|
|
2023-12-24 15:05:34 +03:00
|
|
|
func diffEm[V comparable](s1, s2 []V) []V {
|
2023-11-23 22:05:22 +03:00
|
|
|
combinedSlice := append(s1, s2...)
|
2023-12-24 15:05:34 +03:00
|
|
|
dm := make(map[V]int)
|
2023-11-23 22:05:22 +03:00
|
|
|
for _, v := range combinedSlice {
|
|
|
|
if _, ok := dm[v]; ok {
|
|
|
|
// remove element later as it exist in both slice.
|
|
|
|
dm[v] += 1
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
// new entry, add in map!
|
|
|
|
dm[v] = 1
|
|
|
|
}
|
2023-12-24 15:05:34 +03:00
|
|
|
var retSlice []V
|
2023-11-23 22:05:22 +03:00
|
|
|
for k, v := range dm {
|
|
|
|
if v == 1 {
|
|
|
|
retSlice = append(retSlice, k)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return retSlice
|
|
|
|
}
|
|
|
|
|
2024-05-28 11:24:12 +03:00
|
|
|
// The type represents event of a
|
|
|
|
// key getting pressed down.
|
2023-11-23 22:05:22 +03:00
|
|
|
type KeyDown struct {
|
|
|
|
Key
|
|
|
|
}
|
|
|
|
|
2024-05-28 11:24:12 +03:00
|
|
|
// The type represents event of a
|
|
|
|
// key getting pressed up.
|
2023-11-23 22:05:22 +03:00
|
|
|
type KeyUp struct {
|
|
|
|
Key
|
|
|
|
}
|
|
|
|
|
2024-05-28 11:24:12 +03:00
|
|
|
// The type represents event of a
|
|
|
|
// mouse button being pressed down.
|
2023-11-23 22:05:22 +03:00
|
|
|
type MouseButtonDown struct {
|
|
|
|
MouseButton
|
2024-05-28 11:24:12 +03:00
|
|
|
Position mx.Vector
|
2023-11-23 22:05:22 +03:00
|
|
|
}
|
|
|
|
|
2024-05-28 11:24:12 +03:00
|
|
|
// The type represents event of a
|
|
|
|
// mouse button being pressed up.
|
2023-11-23 22:05:22 +03:00
|
|
|
type MouseButtonUp struct {
|
|
|
|
MouseButton
|
2024-05-28 11:24:12 +03:00
|
|
|
Positon mx.Vector
|
2023-11-23 22:05:22 +03:00
|
|
|
}
|
|
|
|
|
2024-05-28 11:24:12 +03:00
|
|
|
// The type represents
|
|
|
|
// event of moving the mouse.
|
2023-11-23 22:05:22 +03:00
|
|
|
type MouseMove struct {
|
2024-05-28 11:24:12 +03:00
|
|
|
// Real and absolute deltas
|
|
|
|
// for the mouse movement.
|
|
|
|
RealDelta, AbsDelta mx.Vector
|
2023-12-24 15:05:34 +03:00
|
|
|
}
|
|
|
|
|
2024-05-28 11:24:12 +03:00
|
|
|
// The type represents event
|
|
|
|
// of a wheel change.
|
2023-12-24 15:05:34 +03:00
|
|
|
type WheelChange struct {
|
2024-05-28 11:24:12 +03:00
|
|
|
Offset mx.Vector
|
2023-11-23 22:05:22 +03:00
|
|
|
}
|
|
|
|
|
2024-06-01 16:07:28 +03:00
|
|
|
type KeyboardEvents struct {
|
|
|
|
KeyDowns []KeyDown
|
|
|
|
KeyUps []KeyUp
|
|
|
|
}
|
|
|
|
|
|
|
|
type MouseEvents struct {
|
|
|
|
ButtonDowns []MouseButtonDown
|
|
|
|
ButtonUps []MouseButtonUp
|
|
|
|
Move *MouseMove
|
|
|
|
WheelChange *WheelChange
|
|
|
|
}
|
|
|
|
|
|
|
|
type Events struct {
|
|
|
|
Keyboard KeyboardEvents
|
|
|
|
Mouse MouseEvents
|
|
|
|
}
|
|
|
|
|
2023-11-23 22:05:22 +03:00
|
|
|
type EventChan chan any
|
|
|
|
|