2020-03-26 22:03:31 +00:00
|
|
|
//go:generate boxy
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fyne.io/fyne"
|
|
|
|
"fyne.io/fyne/app"
|
|
|
|
"fyne.io/fyne/dialog"
|
|
|
|
"fyne.io/fyne/widget"
|
2020-03-26 22:59:43 +00:00
|
|
|
"github.com/minizbot2012/orbbind/keymap/orbweaver"
|
2020-05-01 05:39:07 +00:00
|
|
|
"github.com/minizbot2012/orbbind/ui/baseui"
|
2020-03-26 22:59:43 +00:00
|
|
|
"github.com/minizbot2012/orbbind/ui/mainpage"
|
2020-04-15 22:56:04 +00:00
|
|
|
"github.com/minizbot2012/orbbind/ui/sidepage"
|
2020-03-26 22:03:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
ap := app.NewWithID("com.minizbot2012.orbbind")
|
|
|
|
window := ap.NewWindow("Orbweaver Rebinding")
|
2020-05-01 05:39:07 +00:00
|
|
|
window.SetMaster()
|
|
|
|
|
2020-03-26 22:03:31 +00:00
|
|
|
omap := &orbweaver.PKM{}
|
2020-05-01 05:39:07 +00:00
|
|
|
pages := make(map[string]baseui.PageWithBindings)
|
|
|
|
pages["main"] = mainpage.NewMainPage(window, omap)
|
|
|
|
pages["side"] = sidepage.NewSidePage(window, omap)
|
|
|
|
tabs := widget.NewTabContainer(pages["main"].Create(), pages["side"].Create())
|
|
|
|
tabs.Resize(fyne.NewSize(640, 480))
|
2020-05-09 04:29:30 +00:00
|
|
|
main := tabs
|
2020-05-01 05:39:07 +00:00
|
|
|
window.Resize(fyne.NewSize(640, 500))
|
2020-05-09 04:29:30 +00:00
|
|
|
mainMenu := fyne.NewMainMenu(fyne.NewMenu("File", fyne.NewMenuItem("Save", func() {
|
2020-05-01 05:39:07 +00:00
|
|
|
dialog.ShowFileSave(func(writer fyne.FileWriteCloser, err error) {
|
|
|
|
if err != nil {
|
|
|
|
dialog.ShowError(err, window)
|
|
|
|
return
|
|
|
|
}
|
2020-05-09 04:35:59 +00:00
|
|
|
if writer != nil {
|
|
|
|
orbweaver.SaveIntoKeymap(omap, writer)
|
|
|
|
}
|
2020-03-26 22:03:31 +00:00
|
|
|
}, window)
|
|
|
|
}), fyne.NewMenuItem("Load", func() {
|
2020-05-01 05:39:07 +00:00
|
|
|
dialog.ShowFileOpen(func(reader fyne.FileReadCloser, err error) {
|
|
|
|
if err != nil {
|
|
|
|
dialog.ShowError(err, window)
|
|
|
|
return
|
2020-04-15 22:55:03 +00:00
|
|
|
}
|
2020-05-09 04:35:59 +00:00
|
|
|
if reader != nil {
|
|
|
|
omap = orbweaver.LoadFile(reader)
|
|
|
|
pages["main"].SetBindings(omap)
|
|
|
|
pages["side"].SetBindings(omap)
|
|
|
|
}
|
2020-03-26 22:03:31 +00:00
|
|
|
}, window)
|
2020-05-01 05:39:07 +00:00
|
|
|
})))
|
|
|
|
window.SetMainMenu(mainMenu)
|
2020-05-09 04:29:30 +00:00
|
|
|
|
2020-05-01 05:39:07 +00:00
|
|
|
window.SetContent(main)
|
2020-03-26 22:03:31 +00:00
|
|
|
window.ShowAndRun()
|
|
|
|
}
|