From bb9be9592459a1305f1d7d3e00ebe36ec664cff1 Mon Sep 17 00:00:00 2001 From: cuu Date: Thu, 6 Dec 2018 23:49:04 +0800 Subject: [PATCH] complied,backup --- main.go | 16 ++++++++++------ sysgo/UI/UI.go | 10 ++++++---- sysgo/UI/counter_screen.go | 14 ++++++++++---- sysgo/UI/fullscreen.go | 3 +++ sysgo/UI/label.go | 2 ++ sysgo/UI/title_bar.go | 7 ++++--- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/main.go b/main.go index 3a871da..7ac5c3e 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,10 @@ import ( "os" "fmt" + "io/ioutil" + "strconv" + "strings" + gotime "time" "github.com/veandco/go-sdl2/sdl" @@ -11,7 +15,7 @@ import ( "github.com/cuu/gogame/event" // "github.com/cuu/gogame/color" "github.com/cuu/gogame/font" - "github.com/cuu/gogame/time" + //"github.com/cuu/gogame/time" "github.com/cuu/LauncherGoDev/sysgo" @@ -132,7 +136,7 @@ func InspectionTeam(main_screen *UI.MainScreen) { time2 := sysgo.PowerLevels[sysgo.CurPowerLevel].Close time3 := sysgo.PowerLevels[sysgo.CurPowerLevel].PowerOff - if elapsed > gotime.Duration(time1) *gotime.Millisecond && passout_time_stage == 0 { + if elapsed > gotime.Duration(time1) *gotime.Second && passout_time_stage == 0 { fmt.Println("timeout, dim screen ",elapsed) if UI.FileExists(sysgo.BackLight) { @@ -157,7 +161,7 @@ func InspectionTeam(main_screen *UI.MainScreen) { passout_time_stage = 1 // next } everytime_keydown = cur_time - }else if elapsed > gotime.Duration(time2) *gotime.Millisecond && passout_time_stage == 1 { + }else if elapsed > gotime.Duration(time2) *gotime.Second && passout_time_stage == 1 { fmt.Println("timeout, close screen ", elapsed) if UI.FileExists(sysgo.BackLight) { @@ -172,7 +176,7 @@ func InspectionTeam(main_screen *UI.MainScreen) { } everytime_keydown = cur_time - }else if elapsed > gotime.Duration(time3) * gotime.Millisecond && passout_time_stage == 2{ + }else if elapsed > gotime.Duration(time3) * gotime.Second && passout_time_stage == 2{ fmt.Println("Power Off counting down") @@ -191,7 +195,7 @@ func InspectionTeam(main_screen *UI.MainScreen) { } - gotime.Sleep(UI.DT * gotime.Millisecond) + gotime.Sleep(gotime.Duration(UI.DT) * gotime.Millisecond) } } @@ -245,7 +249,7 @@ func run() int { if ev.Type == event.KEYDOWN { everytime_keydown = gotime.Now() if RestoreLastBackLightBrightness(main_screen) == false { - return + continue } if ev.Data["Key"] == "Q" { diff --git a/sysgo/UI/UI.go b/sysgo/UI/UI.go index 90cd258..fa35a36 100644 --- a/sysgo/UI/UI.go +++ b/sysgo/UI/UI.go @@ -58,22 +58,24 @@ func Init() { fonts_path["noto"] = fmt.Sprintf("%s/NotoSansMono-Regular.ttf", skinpath) fonts_path["notocjk"] = fmt.Sprintf("%s/NotoSansCJK-Regular.ttf" ,skinpath) - for i:=12;i<41;i++ { + for i:=10;i<41;i++ { keyname := fmt.Sprintf("varela%d",i) Fonts[ keyname ] = font.Font(fonts_path["varela"],i) } - + + Fonts["varela120"] = font.Font(fonts_path["varela"],120) + for i:=10;i<26;i++ { keyname := fmt.Sprintf("veramono%d", i) Fonts[keyname] = font.Font(fonts_path["veramono"],i) } - for i:= 10;i<18;i++ { + for i:= 10;i<28;i++ { keyname := fmt.Sprintf("notosansmono%d", i) Fonts[keyname] = font.Font(fonts_path["noto"], i) } - for i:=10;i<18;i++ { + for i:=10;i<28;i++ { keyname := fmt.Sprintf("notosanscjk%d",i) Fonts[keyname] = font.Font(fonts_path["notocjk"],i) } diff --git a/sysgo/UI/counter_screen.go b/sysgo/UI/counter_screen.go index 6b820d7..9c97d3f 100644 --- a/sysgo/UI/counter_screen.go +++ b/sysgo/UI/counter_screen.go @@ -1,9 +1,16 @@ package UI import ( - + "fmt" gotime "time" - + "github.com/veandco/go-sdl2/ttf" + + "github.com/cuu/gogame/color" + "github.com/cuu/gogame/event" + "github.com/cuu/gogame/surface" + + "github.com/cuu/LauncherGoDev/sysgo" + ) type CounterScreen struct { FullScreen @@ -97,7 +104,7 @@ func (self *CounterScreen) StartCounter() { self.Counting = true - self.TheTicker.Start() + self.TheTicker = gotime.NewTicker(500 * gotime.Millisecond) go self.Interval() @@ -136,7 +143,6 @@ func (self *CounterScreen) Init() { number_str := fmt.Sprintf("%d",self.Number) self.NumberLabel.Init(number_str,self.CounterFont,self.FGColor) - self.TheTicker = gotime.NewTicker(500 * gotime.Millisecond) self.TickerStoped = make(chan bool,1) } diff --git a/sysgo/UI/fullscreen.go b/sysgo/UI/fullscreen.go index 55f4b44..bdc1c02 100644 --- a/sysgo/UI/fullscreen.go +++ b/sysgo/UI/fullscreen.go @@ -2,8 +2,11 @@ package UI import ( + "github.com/veandco/go-sdl2/sdl" "github.com/cuu/gogame/surface" + "github.com/cuu/gogame/rect" + ) type FullScreen struct { diff --git a/sysgo/UI/label.go b/sysgo/UI/label.go index 622d3d9..712bf7f 100644 --- a/sysgo/UI/label.go +++ b/sysgo/UI/label.go @@ -9,6 +9,8 @@ import ( "github.com/cuu/gogame/rect" "github.com/cuu/gogame/color" "github.com/cuu/gogame/font" + "github.com/cuu/gogame/draw" + ) type LabelInterface interface { diff --git a/sysgo/UI/title_bar.go b/sysgo/UI/title_bar.go index ab78599..a98b5ad 100644 --- a/sysgo/UI/title_bar.go +++ b/sysgo/UI/title_bar.go @@ -7,6 +7,7 @@ import ( "strconv" "bufio" "strings" + "os/exec" gotime "time" "github.com/veandco/go-sdl2/sdl" @@ -140,7 +141,7 @@ func NewTitleBar() *TitleBar { } -func (t *TitleBar) RoundRobinCheck() { +func (self *TitleBar) RoundRobinCheck() { for { if self.InLowBackLight < 0 { @@ -166,7 +167,7 @@ func (t *TitleBar) RoundRobinCheck() { } } -func (t *TitleBar) UpdateWifiStrength() { +func (self *TitleBar) UpdateWifiStrength() { self.Draw(self.Title) } @@ -213,7 +214,7 @@ func (self *TitleBar) SyncSoundVolume() { } // for outside widget to update sound icon -func (t *TitleBar) SetSoundVolume(vol int) { +func (self *TitleBar) SetSoundVolume(vol int) { snd_segs := [][]int{ []int{0,10}, []int{10,30}, []int{30,70},[]int{70,100} } ge := 0