statusbar messages improvements
This commit is contained in:
parent
849502e99f
commit
334c39da64
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
ui "github.com/gizak/termui/v3"
|
ui "github.com/gizak/termui/v3"
|
||||||
"github.com/sqshq/sampler/console"
|
"github.com/sqshq/sampler/console"
|
||||||
|
"github.com/sqshq/sampler/storage"
|
||||||
"image"
|
"image"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,18 +15,29 @@ const (
|
||||||
type StatusBar struct {
|
type StatusBar struct {
|
||||||
*ui.Block
|
*ui.Block
|
||||||
keyBindings []string
|
keyBindings []string
|
||||||
configFileName string
|
text string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStatusLine(configFileName string, palette console.Palette) *StatusBar {
|
func NewStatusLine(configFileName string, palette console.Palette, license *storage.License) *StatusBar {
|
||||||
block := *ui.NewBlock()
|
block := *ui.NewBlock()
|
||||||
block.Border = false
|
block.Border = false
|
||||||
|
|
||||||
|
text := fmt.Sprintf(" %s %s | ", console.AppTitle, console.AppVersion)
|
||||||
|
|
||||||
|
if license == nil || !license.Purchased || !license.Valid {
|
||||||
|
text += console.AppLicenseWarning
|
||||||
|
} else if license.Username != nil {
|
||||||
|
text += fmt.Sprintf("%s | licensed to %s", configFileName, *license.Username)
|
||||||
|
} else {
|
||||||
|
text += fmt.Sprintf("%s | licensed to %s", configFileName, *license.Company)
|
||||||
|
}
|
||||||
|
|
||||||
return &StatusBar{
|
return &StatusBar{
|
||||||
Block: NewBlock("", false, palette),
|
Block: NewBlock("", false, palette),
|
||||||
configFileName: configFileName,
|
text: text,
|
||||||
keyBindings: []string{
|
keyBindings: []string{
|
||||||
"(Q) quit",
|
"(q) quit",
|
||||||
"(P) pause",
|
"(p) pause",
|
||||||
"(<->) selection",
|
"(<->) selection",
|
||||||
"(ESC) reset alerts",
|
"(ESC) reset alerts",
|
||||||
},
|
},
|
||||||
|
@ -33,13 +45,9 @@ func NewStatusLine(configFileName string, palette console.Palette) *StatusBar {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StatusBar) Draw(buffer *ui.Buffer) {
|
func (s *StatusBar) Draw(buffer *ui.Buffer) {
|
||||||
buffer.Fill(ui.NewCell(' ', ui.NewStyle(console.ColorClear, console.MenuColorBackground)), s.GetRect())
|
|
||||||
|
|
||||||
if false { // TODO check license
|
buffer.Fill(ui.NewCell(' ', ui.NewStyle(console.ColorClear, console.MenuColorBackground)), s.GetRect())
|
||||||
buffer.SetString(fmt.Sprintf(" %s", console.AppLicenseWarning), ui.NewStyle(console.MenuColorText, console.MenuColorBackground), s.Min)
|
buffer.SetString(s.text, ui.NewStyle(console.MenuColorText, console.MenuColorBackground), s.Min)
|
||||||
} else {
|
|
||||||
buffer.SetString(fmt.Sprintf(" %s %s @ %s", console.AppTitle, console.AppVersion, s.configFileName), ui.NewStyle(console.MenuColorText, console.MenuColorBackground), s.Min)
|
|
||||||
}
|
|
||||||
|
|
||||||
indent := bindingsIndent
|
indent := bindingsIndent
|
||||||
for _, binding := range s.keyBindings {
|
for _, binding := range s.keyBindings {
|
||||||
|
|
|
@ -14,7 +14,7 @@ const (
|
||||||
RowsCount = 40
|
RowsCount = 40
|
||||||
AppTitle = "sampler"
|
AppTitle = "sampler"
|
||||||
AppVersion = "0.9.0"
|
AppVersion = "0.9.0"
|
||||||
AppLicenseWarning = "UNLICENSED. FOR PERSONAL USE ONLY. VISIT SAMPLER.DEV"
|
AppLicenseWarning = "UNLICENSED. FOR PERSONAL USE ONLY. VISIT WWW.SAMPLER.DEV"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
23
main.go
23
main.go
|
@ -48,10 +48,20 @@ func main() {
|
||||||
palette := console.GetPalette(*cfg.Theme)
|
palette := console.GetPalette(*cfg.Theme)
|
||||||
width, height := ui.TerminalDimensions()
|
width, height := ui.TerminalDimensions()
|
||||||
|
|
||||||
lout := layout.NewLayout(width, height, component.NewStatusLine(opt.ConfigFile, palette), component.NewMenu(palette), component.NewIntro(palette))
|
license := storage.GetLicense()
|
||||||
|
// TODO storage.UpdateStats()
|
||||||
|
|
||||||
|
lout := layout.NewLayout(width, height, component.NewStatusLine(opt.ConfigFile, palette, license), component.NewMenu(palette), component.NewIntro(palette))
|
||||||
starter := &Starter{lout, player, opt, cfg}
|
starter := &Starter{lout, player, opt, cfg}
|
||||||
|
|
||||||
license := storage.GetLicense()
|
if license == nil {
|
||||||
|
lout.RunIntro()
|
||||||
|
storage.InitLicense()
|
||||||
|
} else if !license.Purchased /* && random */ {
|
||||||
|
// TODO lout.showNagWindow() with timeout and OK button
|
||||||
|
// TODO verify license
|
||||||
|
// TODO send stats
|
||||||
|
}
|
||||||
|
|
||||||
for _, c := range cfg.RunCharts {
|
for _, c := range cfg.RunCharts {
|
||||||
cpt := runchart.NewRunChart(c, palette)
|
cpt := runchart.NewRunChart(c, palette)
|
||||||
|
@ -83,15 +93,6 @@ func main() {
|
||||||
starter.start(cpt, cpt.Consumer, c.ComponentConfig, []config.Item{c.Item}, c.Triggers)
|
starter.start(cpt, cpt.Consumer, c.ComponentConfig, []config.Item{c.Item}, c.Triggers)
|
||||||
}
|
}
|
||||||
|
|
||||||
if license == nil {
|
|
||||||
lout.RunIntro()
|
|
||||||
storage.InitLicense()
|
|
||||||
} else if !license.Purchased /* && random */ {
|
|
||||||
// TODO lout.showNagWindow() with timeout and OK button
|
|
||||||
// TODO verify license
|
|
||||||
// TODO send stats
|
|
||||||
}
|
|
||||||
|
|
||||||
handler := event.NewHandler(lout, opt)
|
handler := event.NewHandler(lout, opt)
|
||||||
handler.HandleEvents()
|
handler.HandleEvents()
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,3 +4,5 @@ package storage
|
||||||
// version
|
// version
|
||||||
// launch count
|
// launch count
|
||||||
// components count by type
|
// components count by type
|
||||||
|
// OS
|
||||||
|
// window size
|
||||||
|
|
Loading…
Reference in New Issue