add style management
This commit is contained in:
@@ -125,6 +125,8 @@ func main() {
|
||||
Offsets: ui.Offsets{Top: 1, Left: 2, Bottom: -2, Right: -2},
|
||||
Container: l,
|
||||
}},
|
||||
ui.StyleActive,
|
||||
false,
|
||||
)
|
||||
book := ui.NewBookDetails(&book.Book{
|
||||
Title: "test title",
|
||||
@@ -136,6 +138,8 @@ func main() {
|
||||
Offsets: ui.Offsets{Top: 1, Left: 2, Bottom: 0, Right: 0},
|
||||
Container: book,
|
||||
}},
|
||||
ui.StyleInactive,
|
||||
false,
|
||||
)
|
||||
|
||||
container := ui.NewContainer(
|
||||
@@ -155,6 +159,7 @@ func main() {
|
||||
|
||||
// init UI state
|
||||
state.Set("ui_state", IN_MENU)
|
||||
screen.PostEvent(NewEventLoadBook(l.SelectedID()))
|
||||
|
||||
// UI loop
|
||||
for {
|
||||
@@ -168,21 +173,26 @@ func main() {
|
||||
if curr == IN_MENU {
|
||||
if v.Key() == tcell.KeyUp && l.Selected() > 0 {
|
||||
l.SetSelected(l.Selected() - 1)
|
||||
screen.PostEvent(NewEventLoadBook(l.SelectedID()))
|
||||
}
|
||||
if v.Key() == tcell.KeyDown && l.Selected() < len(l.ListMembers())-1 {
|
||||
l.SetSelected(l.Selected() + 1)
|
||||
screen.PostEvent(NewEventLoadBook(l.SelectedID()))
|
||||
}
|
||||
if v.Rune() == 'q' {
|
||||
screen.Fini()
|
||||
fmt.Printf("Thank you for playing Wing Commander!\n\n")
|
||||
return
|
||||
}
|
||||
if v.Key() == tcell.KeyRight {
|
||||
screen.PostEvent(NewEventLoadBook(l.SelectedID()))
|
||||
if v.Key() == tcell.KeyEnter {
|
||||
activeBook.SetStyle(ui.StyleActive)
|
||||
menu.SetStyle(ui.StyleInactive)
|
||||
state.Set("ui_state", IN_BOOK)
|
||||
}
|
||||
} else if curr == IN_BOOK {
|
||||
if v.Key() == tcell.KeyLeft {
|
||||
if v.Key() == tcell.KeyEsc {
|
||||
activeBook.SetStyle(ui.StyleInactive)
|
||||
menu.SetStyle(ui.StyleActive)
|
||||
state.Set("ui_state", IN_MENU)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user