mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 07:58:51 +01:00
add TitleBar UpdateTimeLocation
This commit is contained in:
parent
fe210d5561
commit
6f4bbe62dd
@ -259,6 +259,10 @@ func (self *TimeZoneListPage) Click() {
|
||||
err := cpCmd.Run()
|
||||
if err != nil{
|
||||
fmt.Println(err)
|
||||
}else {
|
||||
|
||||
self.Screen.TitleBar.UpdateTimeLocation()
|
||||
|
||||
}
|
||||
fmt.Println("add ",cur_li.Path)
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"bufio"
|
||||
"strings"
|
||||
"os/exec"
|
||||
"io/ioutil"
|
||||
gotime "time"
|
||||
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
@ -109,6 +110,7 @@ type TitleBar struct {
|
||||
|
||||
icon_base_path string /// SkinMap("gameshell/titlebar_icons/")
|
||||
|
||||
MyTimeLocation *gotime.Location
|
||||
|
||||
TitleFont *ttf.Font
|
||||
TimeFont *ttf.Font
|
||||
@ -405,6 +407,9 @@ func (self *TitleBar) Init(main_screen *MainScreen) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
self.UpdateTimeLocation()
|
||||
|
||||
}
|
||||
|
||||
func (self *TitleBar) ClearCanvas() {
|
||||
@ -421,6 +426,29 @@ func (self *TitleBar) ClearCanvas() {
|
||||
}
|
||||
|
||||
|
||||
func (self *TitleBar) UpdateTimeLocation() {
|
||||
|
||||
d,err := ioutil.ReadFile("/etc/localtime")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
self.MyTimeLocation,err = gotime.LoadLocationFromTZData("local", d)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
self.MyTimeLocation = nil
|
||||
}
|
||||
}
|
||||
|
||||
func (self *TitleBar) GetLocalTime() gotime.Time {
|
||||
if self.MyTimeLocation == nil {
|
||||
return gotime.Now()
|
||||
}else {
|
||||
return gotime.Now().In(self.MyTimeLocation)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (self *TitleBar) Draw(title string) {
|
||||
self.ClearCanvas()
|
||||
self.Title = title
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user