Now sidebindings

pull/3/head
Minizbot2012 4 years ago
parent 6b36eff1d9
commit 3203a70b57
No known key found for this signature in database
GPG Key ID: 977C8ADE12361917

@ -9,6 +9,7 @@ import (
"fyne.io/fyne/widget"
"github.com/Minizbot2012/orbbind/keymap/orbweaver"
"github.com/Minizbot2012/orbbind/ui/mainpage"
sidepage "github.com/Minizbot2012/orbbind/ui/side"
)
func main() {
@ -17,7 +18,9 @@ func main() {
window.Resize(fyne.NewSize(480, 480))
omap := &orbweaver.PKM{}
nmp := mainpage.NewMainPage(window, omap)
nsp := sidepage.NewSidePage(window, omap)
tabs := widget.NewTabContainer(nmp.Create())
tabs.Append(nsp.Create())
tabs.Resize(window.Content().Size())
window.SetMainMenu(fyne.NewMainMenu(fyne.NewMenu("File", fyne.NewMenuItem("Save", func() {
dialog.ShowFileSave(func(p string) {
@ -27,6 +30,7 @@ func main() {
dialog.ShowFileOpen(func(p string) {
omap = orbweaver.LoadFile(p)
nmp.SetBindings(omap)
nsp.SetBindings(omap)
}, window)
}))))
window.SetContent(tabs)

@ -24,7 +24,7 @@ func (mp *Page) createButtons() {
for i := 0; i < 4; i++ {
for j := 0; j < 5; j++ {
id := (j + i*5 + 1)
mp.dev["B"+strconv.Itoa(id)] = widget.NewButton(strconv.Itoa((j+i*5)+1), func() {
mp.dev["B"+strconv.Itoa(id)] = widget.NewButton(strconv.Itoa(id), func() {
popup := bind.NewBindPage(id, mp.parent, mp.binds.MIP[id-1])
dialog.ShowCustomConfirm("Binding", "Set", "Cancel", popup.Create(string(id)), func(b bool) {
if b {
@ -33,7 +33,6 @@ func (mp *Page) createButtons() {
}, mp.parent)
})
mp.dev["V"].(*fyne.Container).AddObject(mp.dev["B"+strconv.Itoa(id)])
}
}
}

@ -0,0 +1,53 @@
package sidepage
import (
"strconv"
"fyne.io/fyne"
"fyne.io/fyne/dialog"
"fyne.io/fyne/layout"
"fyne.io/fyne/widget"
"github.com/Minizbot2012/orbbind/keymap/orbweaver"
"github.com/Minizbot2012/orbbind/ui/baseui"
"github.com/Minizbot2012/orbbind/ui/bind"
)
//Page Overweave side button configs
type Page struct {
baseui.PageWithBindings
binds *orbweaver.PKM
dev map[string]fyne.CanvasObject
parent fyne.Window
}
//SetBindings Loads bindings from SIP
func (p *Page) SetBindings(o *orbweaver.PKM) {
p.binds = o
}
//Create Creates the page
func (p *Page) Create() *widget.TabItem {
p.dev = make(map[string]fyne.CanvasObject)
strs := []string{"Upper Button", "Dpad Up", "Dpad Right", "Dpad Down", "Dpad Left", "Lower Button"}
for j := 0; j < 6; j++ {
id := j + 1
p.dev["B"+strconv.Itoa(id)] = widget.NewButton(strs[j], func() {
popup := bind.NewBindPage(id, p.parent, p.binds.SIP[id-1])
dialog.ShowCustomConfirm("Binding", "Set", "Cancel", popup.Create(string(id)), func(b bool) {
if b {
p.binds.SIP[popup.Bind.Bindid-1] = popup.Bind.Bound
}
}, p.parent)
})
}
cont := fyne.NewContainerWithLayout(layout.NewBorderLayout(p.dev["B2"], p.dev["B4"], p.dev["B5"], p.dev["B3"]), p.dev["B2"], p.dev["B4"], p.dev["B5"], p.dev["B3"], widget.NewVBox(p.dev["B1"], p.dev["B6"]))
return widget.NewTabItem("Side Config", cont)
}
//NewSidePage Creates a new side configuration page
func NewSidePage(parent fyne.Window, pkm *orbweaver.PKM) *Page {
p := &Page{}
p.binds = pkm
p.parent = parent
return p
}
Loading…
Cancel
Save