statusbar messages improvements
This commit is contained in:
parent
849502e99f
commit
334c39da64
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
ui "github.com/gizak/termui/v3"
|
||||
"github.com/sqshq/sampler/console"
|
||||
"github.com/sqshq/sampler/storage"
|
||||
"image"
|
||||
)
|
||||
|
||||
|
@ -13,19 +14,30 @@ const (
|
|||
|
||||
type StatusBar struct {
|
||||
*ui.Block
|
||||
keyBindings []string
|
||||
configFileName string
|
||||
keyBindings []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.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{
|
||||
Block: NewBlock("", false, palette),
|
||||
configFileName: configFileName,
|
||||
Block: NewBlock("", false, palette),
|
||||
text: text,
|
||||
keyBindings: []string{
|
||||
"(Q) quit",
|
||||
"(P) pause",
|
||||
"(q) quit",
|
||||
"(p) pause",
|
||||
"(<->) selection",
|
||||
"(ESC) reset alerts",
|
||||
},
|
||||
|
@ -33,13 +45,9 @@ func NewStatusLine(configFileName string, palette console.Palette) *StatusBar {
|
|||
}
|
||||
|
||||
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.SetString(fmt.Sprintf(" %s", console.AppLicenseWarning), 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)
|
||||
}
|
||||
buffer.Fill(ui.NewCell(' ', ui.NewStyle(console.ColorClear, console.MenuColorBackground)), s.GetRect())
|
||||
buffer.SetString(s.text, ui.NewStyle(console.MenuColorText, console.MenuColorBackground), s.Min)
|
||||
|
||||
indent := bindingsIndent
|
||||
for _, binding := range s.keyBindings {
|
||||
|
|
|
@ -14,7 +14,7 @@ const (
|
|||
RowsCount = 40
|
||||
AppTitle = "sampler"
|
||||
AppVersion = "0.9.0"
|
||||
AppLicenseWarning = "UNLICENSED. FOR PERSONAL USE ONLY. VISIT SAMPLER.DEV"
|
||||
AppLicenseWarning = "UNLICENSED. FOR PERSONAL USE ONLY. VISIT WWW.SAMPLER.DEV"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
23
main.go
23
main.go
|
@ -48,10 +48,20 @@ func main() {
|
|||
palette := console.GetPalette(*cfg.Theme)
|
||||
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}
|
||||
|
||||
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 {
|
||||
cpt := runchart.NewRunChart(c, palette)
|
||||
|
@ -83,15 +93,6 @@ func main() {
|
|||
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.HandleEvents()
|
||||
}
|
||||
|
|
|
@ -4,3 +4,5 @@ package storage
|
|||
// version
|
||||
// launch count
|
||||
// components count by type
|
||||
// OS
|
||||
// window size
|
||||
|
|
Loading…
Reference in New Issue