One more huge refactoring and quick connect widget working.

Refactored the way URTrator working with profiles - now everything
that could be taken from internal cache will be taken from cache.
The very same as with servers.

Moved all callbacks from callbacks to events, so we achieve full
asynchronity here and can launch anything in goroutines :).

Moved MainWindow-related game launching functions into another
file (mainwindow_launch.go).

Made quick connect widget working. Note, that even if you're on
Favorites and trying to connect to one of favorited servers but
with quick connect - you still have to choose right profile
near Launch button!

Maybe something else I forget.
This commit is contained in:
2016-10-08 19:57:33 +05:00
parent 4421e29695
commit e2a9298f85
14 changed files with 587 additions and 371 deletions

View File

@@ -17,13 +17,13 @@ import (
type Eventer struct {
// Events
events map[string]map[string]func()
events map[string]map[string]func(data map[string]string)
}
func (e *Eventer) AddEventHandler(event string, handler func()) {
func (e *Eventer) AddEventHandler(event string, handler func(data map[string]string)) {
_, ok := e.events[event]
if !ok {
e.events[event] = make(map[string]func())
e.events[event] = make(map[string]func(data map[string]string))
}
event_id_raw := make([]byte, 16)
crand.Read(event_id_raw)
@@ -36,10 +36,10 @@ func (e *Eventer) Initialize() {
}
func (e *Eventer) initializeStorage() {
e.events = make(map[string]map[string]func())
e.events = make(map[string]map[string]func(data map[string]string))
}
func (e *Eventer) LaunchEvent(event string) error {
func (e *Eventer) LaunchEvent(event string, data map[string]string) error {
_, ok := e.events[event]
if !ok {
return errors.New("Event " + event + " not found!")
@@ -47,7 +47,7 @@ func (e *Eventer) LaunchEvent(event string) error {
fmt.Println("Launching event " + event)
for _, val := range e.events[event] {
val()
val(data)
}
return nil