diff --git a/adapter.go b/adapter.go
index f9a2541..142431b 100644
--- a/adapter.go
+++ b/adapter.go
@@ -3,0 +4 @@ import (
+ "grim/element"
@@ -9 +10 @@ type Adapter struct {
- Render func(state []State)
+ Render func(state []element.State)
@@ -12 +13 @@ type Adapter struct {
- events map[string][]func(Event)
+ events map[string][]func(element.Event)
@@ -18 +19 @@ type Adapter struct {
-func (a *Adapter) AddEventListener(name string, callback func(Event)) {
+func (a *Adapter) AddEventListener(name string, callback func(element.Event)) {
@@ -20 +21 @@ func (a *Adapter) AddEventListener(name string, callback func(Event)) {
- a.events = map[string][]func(Event){}
+ a.events = map[string][]func(element.Event){}
@@ -25 +26 @@ func (a *Adapter) AddEventListener(name string, callback func(Event)) {
-func (a *Adapter) DispatchEvent(event Event) {
+func (a *Adapter) DispatchEvent(event element.Event) {
package grim
import (
"image"
)
type Adapter struct {
Init func(width int, height int)
Render func(state []State)
Load func(key string, texture image.Image)
Unload func(key string)
events map[string][]func(Event)
FileSystem FileSystem
// id -> type -> key
Textures map[string]map[string]string
}
func (a *Adapter) AddEventListener(name string, callback func(Event)) {
if a.events == nil {
a.events = map[string][]func(Event){}
}
a.events[name] = append(a.events[name], callback)
}
func (a *Adapter) DispatchEvent(event Event) {
if a.events != nil {
evts := a.events[event.Name]
for _, v := range evts {
v(event)
}
}
}
// !ISSUE: Make a init function
func (a *Adapter) LoadTexture(id, t, key string, texture image.Image) {
a.Load(key, texture)
if a.Textures == nil {
a.Textures = map[string]map[string]string{}
}
if a.Textures[id] == nil {
a.Textures[id] = map[string]string{}
}
a.Textures[id][t] = key
}
func (a *Adapter) UnloadTexture(id, t string) {
a.Unload(a.Textures[id][t])
delete(a.Textures[id], t)
if len(a.Textures[id]) == 0 {
delete(a.Textures[id], t)
}
}
type FileSystem struct {
Paths []string
Sources []string
ReadFile func(path string) ([]byte, error)
WriteFile func(path string, data []byte)
}
func (fs *FileSystem) AddFile(path string) {
fs.Paths = append(fs.Paths, path)
}