mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 07:58:51 +01:00
remove AsyncStart ,add SDL_Delay in event loop
This commit is contained in:
parent
ef5523faf5
commit
83086d9381
@ -507,9 +507,8 @@ func (self *BluetoothPage) ShowBox(msg string) {
|
||||
}
|
||||
|
||||
func (self *BluetoothPage) HideBox() {
|
||||
self.Draw()
|
||||
self.ShowingMessageBox = false
|
||||
self.Screen.SwapAndShow()
|
||||
self.Screen.Refresh()
|
||||
}
|
||||
|
||||
func (self *BluetoothPage) Init() {
|
||||
|
||||
8
main.go
8
main.go
@ -20,7 +20,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/clockworkpi/LauncherGoDev/sysgo"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
@ -487,8 +487,8 @@ func run() int {
|
||||
main_screen.KeyDown(ev)
|
||||
main_screen.LastKeyDown = everytime_keydown
|
||||
}
|
||||
|
||||
gotime.Sleep(50 * gotime.Millisecond)
|
||||
//gotime.Sleep(50 * gotime.Millisecond)
|
||||
time.SDL_Delay(20)
|
||||
}
|
||||
|
||||
return 0
|
||||
@ -502,9 +502,7 @@ func main() {
|
||||
//runtime.GOMAXPROCS(1)
|
||||
|
||||
os.Setenv("SDL_VIDEO_CENTERED", "1")
|
||||
gogame.AsyncStart(func() {
|
||||
exitcode = run()
|
||||
})
|
||||
|
||||
os.Exit(exitcode)
|
||||
}
|
||||
|
||||
@ -223,9 +223,7 @@ func (self *MainScreen) Init() {
|
||||
|
||||
//self.GenList() // load predefined plugin list,ready to be injected ,or ,as a .so for dynamic loading
|
||||
go func() {
|
||||
sdl.Do(func() {
|
||||
self.RefreshLoop()
|
||||
})
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
@ -102,6 +102,8 @@ type TitleBar struct {
|
||||
InLowBackLight int
|
||||
InAirPlaneMode bool
|
||||
|
||||
WifiStrength int
|
||||
|
||||
SkinManager *SkinManager //set by MainScreen
|
||||
|
||||
icon_base_path string /// SkinMap("gameshell/titlebar_icons/")
|
||||
@ -136,6 +138,7 @@ func NewTitleBar() *TitleBar {
|
||||
t.TimeFont = Fonts["varela12"]
|
||||
|
||||
t.InLowBackLight = -1
|
||||
t.WifiStrength = 0
|
||||
return t
|
||||
|
||||
}
|
||||
@ -212,23 +215,22 @@ func (self *TitleBar) IsWifiConnectedNow() bool {
|
||||
}
|
||||
|
||||
func (self *TitleBar) UpdateWifiStrength() {
|
||||
self.GetWifiStrength()
|
||||
self.Draw(self.Title)
|
||||
}
|
||||
|
||||
func (t *TitleBar) GetWifiStrength() int {
|
||||
func (self *TitleBar) GetWifiStrength() int {
|
||||
qua := 0
|
||||
cli := fmt.Sprintf("sudo iwconfig %s | grep Signal | /usr/bin/awk '{print $4}' | /usr/bin/cut -d'=' -f2", sysgo.WifiDev)
|
||||
|
||||
cli := fmt.Sprintf("sudo iwgetid %s -r",sysgo.WifiDev)
|
||||
out := System(cli)
|
||||
if len(out) > 2{
|
||||
if strings.Contains(out, "No") == false {
|
||||
out = strings.TrimSuffix(out, "\n")
|
||||
stren, err := strconv.ParseInt(out, 10, 0)
|
||||
if err == nil {
|
||||
qua = 2 * (int(stren) + 100)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
cli = fmt.Sprintf("sudo nmcli -t -f SSID,SIGNAL dev wifi list | grep \"^%s:\" | cut -d : -f 2",out)
|
||||
out = System(cli)
|
||||
|
||||
out = strings.TrimSuffix(out, "\n")
|
||||
qua,_ = strconv.Atoi(out)
|
||||
}
|
||||
|
||||
segs := [][]int{[]int{-2, -1}, []int{0, 25}, []int{25, 50}, []int{50, 75}, []int{75, 100}}
|
||||
@ -244,7 +246,7 @@ func (t *TitleBar) GetWifiStrength() int {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
self.WifiStrength = ge
|
||||
return ge
|
||||
}
|
||||
|
||||
@ -522,7 +524,7 @@ func (self *TitleBar) Draw(title string) {
|
||||
self.Icons["battery"].NewCoord(start_x+self.IconWidth+self.IconWidth+8, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2)
|
||||
|
||||
if self.IsWifiConnectedNow() == true {
|
||||
ge := self.GetWifiStrength()
|
||||
ge := self.WifiStrength
|
||||
//fmt.Println("wifi ge: ",ge)
|
||||
if ge > 0 {
|
||||
self.Icons["wifistatus"].SetIconIndex(ge)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user