mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2026-03-19 02:12:46 +01:00
go fmt ./...
This commit is contained in:
@@ -3,23 +3,21 @@ package About
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"strings"
|
||||
|
||||
"os/exec"
|
||||
|
||||
"strings"
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/cuu/gogame/surface"
|
||||
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
type InfoPageListItem struct{
|
||||
type InfoPageListItem struct {
|
||||
UI.Widget
|
||||
Labels map[string]UI.LabelInterface
|
||||
Icons map[string]UI.IconItemInterface
|
||||
@@ -27,18 +25,18 @@ type InfoPageListItem struct{
|
||||
|
||||
Parent UI.PageInterface
|
||||
|
||||
Flag string
|
||||
Flag string
|
||||
}
|
||||
|
||||
func NewInfoPageListItem() *InfoPageListItem {
|
||||
i := &InfoPageListItem{}
|
||||
i.Labels = make(map[string]UI.LabelInterface)
|
||||
i.Icons = make( map[string]UI.IconItemInterface)
|
||||
i.Icons = make(map[string]UI.IconItemInterface)
|
||||
i.Fonts = make(map[string]*ttf.Font)
|
||||
|
||||
i.Height = 20
|
||||
i.Width = 0
|
||||
|
||||
i.Width = 0
|
||||
|
||||
return i
|
||||
}
|
||||
|
||||
@@ -46,58 +44,57 @@ func (self *InfoPageListItem) Init(text string) {
|
||||
l := UI.NewLabel()
|
||||
l.PosX = 10
|
||||
l.SetCanvasHWND(self.Parent.GetCanvasHWND())
|
||||
l.Init(text,self.Fonts["normal"],nil)
|
||||
l.Init(text, self.Fonts["normal"], nil)
|
||||
|
||||
self.Labels["Text"] = l
|
||||
|
||||
|
||||
}
|
||||
|
||||
func (self *InfoPageListItem) SetSmallText( text string) {
|
||||
func (self *InfoPageListItem) SetSmallText(text string) {
|
||||
l := UI.NewMultiLabel()
|
||||
l.SetCanvasHWND(self.Parent.GetCanvasHWND())
|
||||
l.Init(text,self.Fonts["small"],nil)
|
||||
l.Init(text, self.Fonts["small"], nil)
|
||||
|
||||
self.Labels["Small"] = l
|
||||
|
||||
_,h_ := self.Labels["Small"].Size()
|
||||
if h_>= self.Height {
|
||||
_, h_ := self.Labels["Small"].Size()
|
||||
if h_ >= self.Height {
|
||||
self.Height = h_ + 10
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *InfoPageListItem) Draw() {
|
||||
x_,_ := self.Labels["Text"].Coord()
|
||||
self.Labels["Text"].NewCoord(x_,self.PosY)
|
||||
x_, _ := self.Labels["Text"].Coord()
|
||||
self.Labels["Text"].NewCoord(x_, self.PosY)
|
||||
self.Labels["Text"].Draw()
|
||||
|
||||
if _, ok := self.Labels["Small"]; ok {
|
||||
w_,_ := self.Labels["Text"].Size()
|
||||
self.Labels["Small"].NewCoord(w_+16,self.PosY)
|
||||
w_, _ := self.Labels["Text"].Size()
|
||||
self.Labels["Small"].NewCoord(w_+16, self.PosY)
|
||||
self.Labels["Small"].Draw()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
type AboutPage struct {
|
||||
UI.Page
|
||||
AList map[string]map[string]string
|
||||
ListFontObj *ttf.Font
|
||||
Scrolled int
|
||||
BGwidth int
|
||||
BGheight int
|
||||
DrawOnce bool
|
||||
Scroller *UI.ListScroller
|
||||
AList map[string]map[string]string
|
||||
ListFontObj *ttf.Font
|
||||
Scrolled int
|
||||
BGwidth int
|
||||
BGheight int
|
||||
DrawOnce bool
|
||||
Scroller *UI.ListScroller
|
||||
|
||||
MyList []*InfoPageListItem
|
||||
Icons map[string]UI.IconItemInterface
|
||||
Icons map[string]UI.IconItemInterface
|
||||
}
|
||||
|
||||
func NewAboutPage() *AboutPage {
|
||||
p := &AboutPage{}
|
||||
|
||||
p.FootMsg = [5]string{"Nav","","","Back",""}
|
||||
|
||||
p.FootMsg = [5]string{"Nav", "", "", "Back", ""}
|
||||
|
||||
p.AList = make(map[string]map[string]string)
|
||||
|
||||
@@ -105,15 +102,15 @@ func NewAboutPage() *AboutPage {
|
||||
p.BGheight = 300
|
||||
p.DrawOnce = false
|
||||
|
||||
p.MyList = make([]*InfoPageListItem,0)
|
||||
p.MyList = make([]*InfoPageListItem, 0)
|
||||
|
||||
p.ListFontObj = UI.Fonts["varela13"]
|
||||
|
||||
p.Index = 0
|
||||
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
return p
|
||||
|
||||
|
||||
}
|
||||
|
||||
func (self *AboutPage) Uname() {
|
||||
@@ -122,221 +119,217 @@ func (self *AboutPage) Uname() {
|
||||
out["key"] = "uname"
|
||||
out["label"] = "Kernel:"
|
||||
|
||||
out_bytes, err := exec.Command("uname","-srmo").Output()
|
||||
out_bytes, err := exec.Command("uname", "-srmo").Output()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
out["value"] = ""
|
||||
}
|
||||
|
||||
|
||||
out_str := strings.Trim(string(out_bytes), "\t\n")
|
||||
|
||||
out["value"]= out_str
|
||||
|
||||
out["value"] = out_str
|
||||
|
||||
self.AList["uname"] = out
|
||||
}
|
||||
|
||||
|
||||
func (self *AboutPage) CpuMhz() {
|
||||
|
||||
lines, err := UI.ReadLines("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")
|
||||
UI.ShowErr(err)
|
||||
|
||||
mhz ,err := strconv.ParseInt(lines[0], 10, 64)
|
||||
lines, err := UI.ReadLines("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")
|
||||
UI.ShowErr(err)
|
||||
mhz_float := float64(mhz)/1000.0
|
||||
|
||||
out := make(map[string]string)
|
||||
out["key"] = "cpuscalemhz"
|
||||
out["label"]="CPU Mhz:"
|
||||
out["value"] = strconv.FormatFloat(mhz_float, 'f', 2, 64)
|
||||
|
||||
self.AList["cpuscalemhz"] = out
|
||||
|
||||
|
||||
mhz, err := strconv.ParseInt(lines[0], 10, 64)
|
||||
UI.ShowErr(err)
|
||||
mhz_float := float64(mhz) / 1000.0
|
||||
|
||||
out := make(map[string]string)
|
||||
out["key"] = "cpuscalemhz"
|
||||
out["label"] = "CPU Mhz:"
|
||||
out["value"] = strconv.FormatFloat(mhz_float, 'f', 2, 64)
|
||||
|
||||
self.AList["cpuscalemhz"] = out
|
||||
|
||||
}
|
||||
|
||||
func (self *AboutPage) CpuInfo() {
|
||||
last_processor := 0
|
||||
if UI.FileExists("/proc/cpuinfo") == false {
|
||||
return
|
||||
}
|
||||
|
||||
cpuinfos,err := UI.ReadLines("/proc/cpuinfo")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
for _,v := range cpuinfos {
|
||||
if strings.HasPrefix(v,"processor") {
|
||||
parts := strings.Split(v,":")
|
||||
if cur_processor_number,err := strconv.Atoi(strings.Trim(parts[1],"\r\n ")); err == nil {
|
||||
if cur_processor_number > last_processor {
|
||||
last_processor = cur_processor_number
|
||||
}
|
||||
}else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if strings.HasPrefix(v,"model name") {
|
||||
parts := strings.Split(v,":")
|
||||
processor := make(map[string]string)
|
||||
processor["key"] = "processor"
|
||||
processor["label"] = "Processor:"
|
||||
processor["value"] = strings.Trim(parts[1],"\r\n ")
|
||||
self.AList["processor"] = processor
|
||||
}
|
||||
|
||||
if strings.HasPrefix(v,"cpu MHz") {
|
||||
parts := strings.Split(v,":")
|
||||
cpumhz := make(map[string]string)
|
||||
cpumhz["key"] = "cpumhz"
|
||||
cpumhz["label"] = "CPU MHz:"
|
||||
cpumhz["value"] = strings.Trim(parts[1],"\r\n ")
|
||||
self.AList["cpumhz"] = cpumhz
|
||||
}
|
||||
|
||||
if strings.HasPrefix(v,"cpu cores") {
|
||||
parts := strings.Split(v,":")
|
||||
cpucores := make(map[string]string)
|
||||
cpucores["key"] = "cpucores"
|
||||
cpucores["label"] = "CPU cores:"
|
||||
cpucores["value"] = strings.Trim(parts[1],"\r\n ")
|
||||
self.AList["cpucores"] = cpucores
|
||||
}
|
||||
|
||||
if strings.HasPrefix(v,"Features") {
|
||||
parts := strings.Split(v,":")
|
||||
f_ := make(map[string]string)
|
||||
f_["key"] = "features"
|
||||
f_["label"] = "Features:"
|
||||
f_["value"] = strings.Trim(parts[1],"\r\n ")
|
||||
self.AList["features"] = f_
|
||||
}
|
||||
|
||||
if strings.HasPrefix(v,"flags") {
|
||||
parts := strings.Split(v,":")
|
||||
flags := make(map[string]string)
|
||||
flags["key"] = "flags"
|
||||
flags["label"] = "Flags:"
|
||||
flags["value"] = strings.TrimSpace(parts[1])
|
||||
self.AList["flags"] = flags
|
||||
}
|
||||
}
|
||||
|
||||
if last_processor > 0 {
|
||||
arm_cores := make(map[string]string)
|
||||
arm_cores["key"]= "armcores"
|
||||
arm_cores["label"] = "CPU cores:"
|
||||
arm_cores["value"] = strconv.Itoa(last_processor + 1)
|
||||
|
||||
self.AList["armcores"] = arm_cores
|
||||
}
|
||||
|
||||
last_processor := 0
|
||||
if UI.FileExists("/proc/cpuinfo") == false {
|
||||
return
|
||||
}
|
||||
|
||||
cpuinfos, err := UI.ReadLines("/proc/cpuinfo")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range cpuinfos {
|
||||
if strings.HasPrefix(v, "processor") {
|
||||
parts := strings.Split(v, ":")
|
||||
if cur_processor_number, err := strconv.Atoi(strings.Trim(parts[1], "\r\n ")); err == nil {
|
||||
if cur_processor_number > last_processor {
|
||||
last_processor = cur_processor_number
|
||||
}
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
if strings.HasPrefix(v, "model name") {
|
||||
parts := strings.Split(v, ":")
|
||||
processor := make(map[string]string)
|
||||
processor["key"] = "processor"
|
||||
processor["label"] = "Processor:"
|
||||
processor["value"] = strings.Trim(parts[1], "\r\n ")
|
||||
self.AList["processor"] = processor
|
||||
}
|
||||
|
||||
if strings.HasPrefix(v, "cpu MHz") {
|
||||
parts := strings.Split(v, ":")
|
||||
cpumhz := make(map[string]string)
|
||||
cpumhz["key"] = "cpumhz"
|
||||
cpumhz["label"] = "CPU MHz:"
|
||||
cpumhz["value"] = strings.Trim(parts[1], "\r\n ")
|
||||
self.AList["cpumhz"] = cpumhz
|
||||
}
|
||||
|
||||
if strings.HasPrefix(v, "cpu cores") {
|
||||
parts := strings.Split(v, ":")
|
||||
cpucores := make(map[string]string)
|
||||
cpucores["key"] = "cpucores"
|
||||
cpucores["label"] = "CPU cores:"
|
||||
cpucores["value"] = strings.Trim(parts[1], "\r\n ")
|
||||
self.AList["cpucores"] = cpucores
|
||||
}
|
||||
|
||||
if strings.HasPrefix(v, "Features") {
|
||||
parts := strings.Split(v, ":")
|
||||
f_ := make(map[string]string)
|
||||
f_["key"] = "features"
|
||||
f_["label"] = "Features:"
|
||||
f_["value"] = strings.Trim(parts[1], "\r\n ")
|
||||
self.AList["features"] = f_
|
||||
}
|
||||
|
||||
if strings.HasPrefix(v, "flags") {
|
||||
parts := strings.Split(v, ":")
|
||||
flags := make(map[string]string)
|
||||
flags["key"] = "flags"
|
||||
flags["label"] = "Flags:"
|
||||
flags["value"] = strings.TrimSpace(parts[1])
|
||||
self.AList["flags"] = flags
|
||||
}
|
||||
}
|
||||
|
||||
if last_processor > 0 {
|
||||
arm_cores := make(map[string]string)
|
||||
arm_cores["key"] = "armcores"
|
||||
arm_cores["label"] = "CPU cores:"
|
||||
arm_cores["value"] = strconv.Itoa(last_processor + 1)
|
||||
|
||||
self.AList["armcores"] = arm_cores
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *AboutPage) MemInfo() {
|
||||
lines, err := UI.ReadLines("/proc/meminfo")
|
||||
UI.ShowErr(err)
|
||||
|
||||
for _,line := range lines {
|
||||
if strings.HasPrefix(line,"MemTotal") {
|
||||
parts := strings.Split(line,":")
|
||||
kb := strings.Replace(parts[1],"KB","",-1)
|
||||
kb = strings.Replace(kb,"kB","",-1)
|
||||
kb = strings.TrimSpace(kb)
|
||||
kb_int,_ := strconv.ParseInt(kb,10,64)
|
||||
kb_float := float64(kb_int)/1000.0
|
||||
memory := make(map[string]string)
|
||||
memory["key"] = "memory"
|
||||
memory["label"] = "Memory:"
|
||||
memory["value"] = strconv.FormatFloat(kb_float,'f',2,64) + " MB"
|
||||
self.AList["memory"] = memory
|
||||
break
|
||||
}
|
||||
}
|
||||
lines, err := UI.ReadLines("/proc/meminfo")
|
||||
UI.ShowErr(err)
|
||||
|
||||
for _, line := range lines {
|
||||
if strings.HasPrefix(line, "MemTotal") {
|
||||
parts := strings.Split(line, ":")
|
||||
kb := strings.Replace(parts[1], "KB", "", -1)
|
||||
kb = strings.Replace(kb, "kB", "", -1)
|
||||
kb = strings.TrimSpace(kb)
|
||||
kb_int, _ := strconv.ParseInt(kb, 10, 64)
|
||||
kb_float := float64(kb_int) / 1000.0
|
||||
memory := make(map[string]string)
|
||||
memory["key"] = "memory"
|
||||
memory["label"] = "Memory:"
|
||||
memory["value"] = strconv.FormatFloat(kb_float, 'f', 2, 64) + " MB"
|
||||
self.AList["memory"] = memory
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *AboutPage) GenList() {
|
||||
self.MyList = nil
|
||||
self.MyList = make([]*InfoPageListItem,0)
|
||||
|
||||
start_x := 0
|
||||
start_y := 10
|
||||
last_height := 0
|
||||
|
||||
for _,u := range ( []string{"processor","armcores","cpuscalemhz","features","memory","uname"} ) {
|
||||
if val, ok := self.AList[u]; ok {
|
||||
|
||||
self.MyList = make([]*InfoPageListItem, 0)
|
||||
|
||||
start_x := 0
|
||||
start_y := 10
|
||||
last_height := 0
|
||||
|
||||
for _, u := range []string{"processor", "armcores", "cpuscalemhz", "features", "memory", "uname"} {
|
||||
if val, ok := self.AList[u]; ok {
|
||||
|
||||
li := NewInfoPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + last_height
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFontObj
|
||||
li.Fonts["small"] = UI.Fonts["varela12"]
|
||||
|
||||
if self.AList[u]["label"] != "" {
|
||||
li.Init( self.AList[u]["label"] )
|
||||
}else {
|
||||
li.Init( self.AList[u]["key"])
|
||||
}
|
||||
|
||||
li.Fonts["small"] = UI.Fonts["varela12"]
|
||||
|
||||
if self.AList[u]["label"] != "" {
|
||||
li.Init(self.AList[u]["label"])
|
||||
} else {
|
||||
li.Init(self.AList[u]["key"])
|
||||
}
|
||||
|
||||
li.Flag = val["key"]
|
||||
li.SetSmallText(val["value"])
|
||||
last_height += li.Height
|
||||
|
||||
self.MyList = append(self.MyList,li)
|
||||
li.SetSmallText(val["value"])
|
||||
last_height += li.Height
|
||||
|
||||
self.MyList = append(self.MyList, li)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (self *AboutPage) Init() {
|
||||
|
||||
if self.Screen != nil {
|
||||
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||
self.HWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = surface.Surface(self.Screen.Width,self.BGheight)
|
||||
self.CanvasHWND = surface.Surface(self.Screen.Width, self.BGheight)
|
||||
}
|
||||
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
bgpng := UI.NewIconItem()
|
||||
bgpng.ImgSurf = UI.MyIconPool.GetImgSurf("about_bg")
|
||||
bgpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
bgpng.Parent = self
|
||||
bgpng.Adjust(0,0,self.BGwidth,self.BGheight,0)
|
||||
|
||||
self.Icons["bg"] = bgpng
|
||||
bgpng := UI.NewIconItem()
|
||||
bgpng.ImgSurf = UI.MyIconPool.GetImgSurf("about_bg")
|
||||
bgpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
bgpng.Parent = self
|
||||
bgpng.Adjust(0, 0, self.BGwidth, self.BGheight, 0)
|
||||
|
||||
self.Icons["bg"] = bgpng
|
||||
|
||||
self.CpuInfo()
|
||||
self.MemInfo()
|
||||
self.CpuMhz()
|
||||
self.MemInfo()
|
||||
self.CpuMhz()
|
||||
self.Uname()
|
||||
|
||||
|
||||
self.GenList()
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
|
||||
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
self.Scroller.SetCanvasHWND(self.HWND)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (self *AboutPage) ScrollDown() {
|
||||
dis := 10
|
||||
if UI.Abs(self.Scrolled) < ( self.BGheight - self.Height)/2 + 50 {
|
||||
if UI.Abs(self.Scrolled) < (self.BGheight-self.Height)/2+50 {
|
||||
self.PosY -= dis
|
||||
self.Scrolled -= dis
|
||||
}
|
||||
@@ -352,7 +345,7 @@ func (self *AboutPage) ScrollUp() {
|
||||
|
||||
func (self *AboutPage) OnLoadCb() {
|
||||
self.Scrolled = 0
|
||||
self.PosY = 0
|
||||
self.PosY = 0
|
||||
self.DrawOnce = false
|
||||
}
|
||||
|
||||
@@ -362,8 +355,7 @@ func (self *AboutPage) OnReturnBackCb() {
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
|
||||
func (self *AboutPage) KeyDown( ev *event.Event) {
|
||||
func (self *AboutPage) KeyDown(ev *event.Event) {
|
||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
@@ -380,54 +372,51 @@ func (self *AboutPage) KeyDown( ev *event.Event) {
|
||||
self.ScrollDown()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *AboutPage) Draw() {
|
||||
if self.DrawOnce == false {
|
||||
|
||||
self.ClearCanvas()
|
||||
|
||||
self.Icons["bg"].NewCoord(self.Width/2, self.Height/2 + (self.BGheight - UI.Height)/2 + self.Screen.TitleBar.Height)
|
||||
self.Icons["bg"].Draw()
|
||||
|
||||
for _,v := range self.MyList {
|
||||
self.Icons["bg"].NewCoord(self.Width/2, self.Height/2+(self.BGheight-UI.Height)/2+self.Screen.TitleBar.Height)
|
||||
self.Icons["bg"].Draw()
|
||||
|
||||
for _, v := range self.MyList {
|
||||
v.Draw()
|
||||
}
|
||||
|
||||
|
||||
self.DrawOnce = true
|
||||
}
|
||||
|
||||
if self.HWND != nil {
|
||||
surface.Fill(self.HWND, &color.Color{255,255,255,255})
|
||||
surface.Fill(self.HWND, &color.Color{255, 255, 255, 255})
|
||||
|
||||
rect_ := rect.Rect(self.PosX,self.PosY,self.Width,self.Height)
|
||||
surface.Blit(self.HWND,self.CanvasHWND,&rect_, nil)
|
||||
|
||||
self.Scroller.UpdateSize(self.BGheight,UI.Abs(self.Scrolled)*3)
|
||||
rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
|
||||
surface.Blit(self.HWND, self.CanvasHWND, &rect_, nil)
|
||||
|
||||
self.Scroller.UpdateSize(self.BGheight, UI.Abs(self.Scrolled)*3)
|
||||
self.Scroller.Draw()
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
type AboutPlugin struct {
|
||||
UI.Plugin
|
||||
Page UI.PageInterface
|
||||
}
|
||||
|
||||
|
||||
func (self *AboutPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *AboutPlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.Page = NewAboutPage()
|
||||
self.Page.SetScreen( main_screen)
|
||||
self.Page.SetScreen(main_screen)
|
||||
self.Page.SetName("About")
|
||||
self.Page.Init()
|
||||
}
|
||||
|
||||
func (self *AboutPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *AboutPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushPage(self.Page)
|
||||
main_screen.Draw()
|
||||
@@ -436,11 +425,3 @@ func (self *AboutPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
}
|
||||
|
||||
var APIOBJ AboutPlugin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,170 +1,164 @@
|
||||
package Airplane
|
||||
|
||||
import (
|
||||
//"fmt"
|
||||
//"io/ioutil"
|
||||
//"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
//"fmt"
|
||||
//"io/ioutil"
|
||||
//"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
//"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
//"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/time"
|
||||
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
type AirplanePage struct {
|
||||
UI.Page
|
||||
|
||||
ListFontObj *ttf.Font
|
||||
|
||||
BGwidth int
|
||||
BGheight int
|
||||
|
||||
Scrolled int
|
||||
Scroller *UI.ListScroller
|
||||
|
||||
airwire_y int //0
|
||||
dialog_index int//0
|
||||
|
||||
Icons map[string]UI.IconItemInterface
|
||||
UI.Page
|
||||
|
||||
ListFontObj *ttf.Font
|
||||
|
||||
BGwidth int
|
||||
BGheight int
|
||||
|
||||
Scrolled int
|
||||
Scroller *UI.ListScroller
|
||||
|
||||
airwire_y int //0
|
||||
dialog_index int //0
|
||||
|
||||
Icons map[string]UI.IconItemInterface
|
||||
}
|
||||
|
||||
func NewAirplanePage() *AirplanePage {
|
||||
p := &AirplanePage{}
|
||||
p := &AirplanePage{}
|
||||
p.PageIconMargin = 20
|
||||
p.SelectedIconTopOffset = 20
|
||||
p.EasingDur = 10
|
||||
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.ListFontObj = UI.MyLangManager.TrFont("varela13")
|
||||
p.FootMsg = [5]string{ "Nav","Rescue","","Back","Toggle"}
|
||||
|
||||
p.BGwidth = UI.Width
|
||||
p.BGheight = UI.Height-24-20
|
||||
|
||||
p.Icons = make( map[string]UI.IconItemInterface )
|
||||
|
||||
return p
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.ListFontObj = UI.MyLangManager.TrFont("varela13")
|
||||
p.FootMsg = [5]string{"Nav", "Rescue", "", "Back", "Toggle"}
|
||||
|
||||
p.BGwidth = UI.Width
|
||||
p.BGheight = UI.Height - 24 - 20
|
||||
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *AirplanePage) GenList() {
|
||||
self.MyList = nil
|
||||
self.MyList = nil
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (self *AirplanePage) Init() {
|
||||
if self.Screen != nil {
|
||||
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||
self.HWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = surface.Surface(self.Screen.Width,self.Screen.Height)
|
||||
}
|
||||
}
|
||||
|
||||
self.PosX = self.Index*self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
|
||||
airwire := UI.NewIconItem()
|
||||
airwire.ImgSurf = UI.MyIconPool.GetImgSurf("airwire")
|
||||
airwire.MyType = UI.ICON_TYPES["STAT"]
|
||||
airwire.Parent = self
|
||||
airwire.Adjust(0,0,5,43,0)
|
||||
self.Icons["airwire"] = airwire
|
||||
if self.Screen != nil {
|
||||
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||
self.HWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = surface.Surface(self.Screen.Width, self.Screen.Height)
|
||||
}
|
||||
}
|
||||
|
||||
GS := UI.NewIconItem()
|
||||
GS.ImgSurf = UI.MyIconPool.GetImgSurf("GS")
|
||||
GS.MyType = UI.ICON_TYPES["STAT"]
|
||||
GS.Parent = self
|
||||
GS.Adjust(0,0,72,95,0)
|
||||
self.Icons["GS"] = GS
|
||||
|
||||
DialogBoxs := UI.NewMultiIconItem()
|
||||
DialogBoxs.ImgSurf = UI.MyIconPool.GetImgSurf("DialogBoxs")
|
||||
DialogBoxs.MyType = UI.ICON_TYPES["STAT"]
|
||||
DialogBoxs.Parent = self
|
||||
DialogBoxs.IconWidth = 134
|
||||
DialogBoxs.IconHeight = 93
|
||||
DialogBoxs.Adjust(0,0,134,372,0)
|
||||
self.Icons["DialogBoxs"] = DialogBoxs
|
||||
|
||||
self.GenList()
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
self.Scroller.SetCanvasHWND(self.HWND)
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
airwire := UI.NewIconItem()
|
||||
airwire.ImgSurf = UI.MyIconPool.GetImgSurf("airwire")
|
||||
airwire.MyType = UI.ICON_TYPES["STAT"]
|
||||
airwire.Parent = self
|
||||
airwire.Adjust(0, 0, 5, 43, 0)
|
||||
self.Icons["airwire"] = airwire
|
||||
|
||||
GS := UI.NewIconItem()
|
||||
GS.ImgSurf = UI.MyIconPool.GetImgSurf("GS")
|
||||
GS.MyType = UI.ICON_TYPES["STAT"]
|
||||
GS.Parent = self
|
||||
GS.Adjust(0, 0, 72, 95, 0)
|
||||
self.Icons["GS"] = GS
|
||||
|
||||
DialogBoxs := UI.NewMultiIconItem()
|
||||
DialogBoxs.ImgSurf = UI.MyIconPool.GetImgSurf("DialogBoxs")
|
||||
DialogBoxs.MyType = UI.ICON_TYPES["STAT"]
|
||||
DialogBoxs.Parent = self
|
||||
DialogBoxs.IconWidth = 134
|
||||
DialogBoxs.IconHeight = 93
|
||||
DialogBoxs.Adjust(0, 0, 134, 372, 0)
|
||||
self.Icons["DialogBoxs"] = DialogBoxs
|
||||
|
||||
self.GenList()
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
self.Scroller.SetCanvasHWND(self.HWND)
|
||||
|
||||
}
|
||||
|
||||
func (self *AirplanePage) ScrollUp() {
|
||||
dis := 10
|
||||
|
||||
if self.PosY < 0 {
|
||||
self.PosY += dis
|
||||
self.Scrolled += dis
|
||||
}
|
||||
dis := 10
|
||||
|
||||
if self.PosY < 0 {
|
||||
self.PosY += dis
|
||||
self.Scrolled += dis
|
||||
}
|
||||
}
|
||||
|
||||
func (self *AirplanePage) ScrollDown() {
|
||||
dis := 10
|
||||
|
||||
if UI.Abs(self.Scrolled) < (self.BGheight - self.Height) / 2 + 0 {
|
||||
self.PosY -= dis
|
||||
self.Scrolled -=dis
|
||||
}
|
||||
dis := 10
|
||||
|
||||
if UI.Abs(self.Scrolled) < (self.BGheight-self.Height)/2+0 {
|
||||
self.PosY -= dis
|
||||
self.Scrolled -= dis
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (self *AirplanePage) ToggleModeAni() {
|
||||
|
||||
out := UI.System("sudo rfkill list | grep yes | cut -d \" \" -f3")
|
||||
|
||||
if strings.Contains(out,"yes") {
|
||||
data := self.EasingData(0,43)
|
||||
|
||||
for _,v := range data {
|
||||
self.airwire_y -= v
|
||||
self.dialog_index = 2
|
||||
time.BlockDelay(40)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
UI.System("sudo rfkill unblock all")
|
||||
self.Screen.TitleBar.InAirPlaneMode = false
|
||||
|
||||
}else {
|
||||
data := self.EasingData(0,43)
|
||||
for i, j := 0, len(data)-1; i < j; i, j = i+1, j-1 { // reverse data
|
||||
data[i], data[j] = data[j], data[i]
|
||||
}
|
||||
for _,v := range data {
|
||||
self.airwire_y += v
|
||||
self.dialog_index = 3
|
||||
time.BlockDelay(40)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
UI.System("sudo rfkill block all")
|
||||
self.Screen.TitleBar.InAirPlaneMode = true
|
||||
}
|
||||
|
||||
out := UI.System("sudo rfkill list | grep yes | cut -d \" \" -f3")
|
||||
|
||||
if strings.Contains(out, "yes") {
|
||||
data := self.EasingData(0, 43)
|
||||
|
||||
for _, v := range data {
|
||||
self.airwire_y -= v
|
||||
self.dialog_index = 2
|
||||
time.BlockDelay(40)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
UI.System("sudo rfkill unblock all")
|
||||
self.Screen.TitleBar.InAirPlaneMode = false
|
||||
|
||||
} else {
|
||||
data := self.EasingData(0, 43)
|
||||
for i, j := 0, len(data)-1; i < j; i, j = i+1, j-1 { // reverse data
|
||||
data[i], data[j] = data[j], data[i]
|
||||
}
|
||||
for _, v := range data {
|
||||
self.airwire_y += v
|
||||
self.dialog_index = 3
|
||||
time.BlockDelay(40)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
UI.System("sudo rfkill block all")
|
||||
self.Screen.TitleBar.InAirPlaneMode = true
|
||||
}
|
||||
}
|
||||
|
||||
func (self *AirplanePage) ToggleMode() {
|
||||
@@ -173,70 +167,69 @@ func (self *AirplanePage) ToggleMode() {
|
||||
|
||||
func (self *AirplanePage) UnBlockAll() {
|
||||
|
||||
self.Screen.MsgBox.SetText("TurningOn")
|
||||
self.Screen.MsgBox.Draw()
|
||||
UI.System("sudo rfkill unblock all")
|
||||
self.Screen.TitleBar.InAirPlaneMode = false
|
||||
self.Screen.MsgBox.SetText("TurningOn")
|
||||
self.Screen.MsgBox.Draw()
|
||||
UI.System("sudo rfkill unblock all")
|
||||
self.Screen.TitleBar.InAirPlaneMode = false
|
||||
}
|
||||
|
||||
func (self *AirplanePage) OnLoadCb() {
|
||||
self.Scrolled = 0
|
||||
self.PosY = 0
|
||||
//self.DrawOnce = false
|
||||
|
||||
out := UI.System("sudo rfkill list | grep yes | cut -d \" \" -f3")
|
||||
|
||||
if strings.Contains(out,"yes") {
|
||||
self.Screen.TitleBar.InAirPlaneMode = true
|
||||
self.airwire_y = 50+43
|
||||
self.dialog_index = 1
|
||||
}else {
|
||||
self.dialog_index = 0
|
||||
self.airwire_y = 50
|
||||
self.Screen.TitleBar.InAirPlaneMode = false
|
||||
}
|
||||
self.Scrolled = 0
|
||||
self.PosY = 0
|
||||
//self.DrawOnce = false
|
||||
|
||||
out := UI.System("sudo rfkill list | grep yes | cut -d \" \" -f3")
|
||||
|
||||
if strings.Contains(out, "yes") {
|
||||
self.Screen.TitleBar.InAirPlaneMode = true
|
||||
self.airwire_y = 50 + 43
|
||||
self.dialog_index = 1
|
||||
} else {
|
||||
self.dialog_index = 0
|
||||
self.airwire_y = 50
|
||||
self.Screen.TitleBar.InAirPlaneMode = false
|
||||
}
|
||||
}
|
||||
|
||||
func (self *AirplanePage) KeyDown(ev *event.Event) {
|
||||
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
self.ToggleModeAni()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["X"] {
|
||||
self.UnBlockAll()
|
||||
self.Screen.SwapAndShow()
|
||||
time.BlockDelay(1000)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
self.ToggleModeAni()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["X"] {
|
||||
self.UnBlockAll()
|
||||
self.Screen.SwapAndShow()
|
||||
time.BlockDelay(1000)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
}
|
||||
|
||||
func (self *AirplanePage) Draw() {
|
||||
|
||||
self.ClearCanvas()
|
||||
self.Icons["DialogBoxs"].NewCoord(145,23)
|
||||
self.Icons["airwire"].NewCoord(80,self.airwire_y)
|
||||
|
||||
self.Icons["DialogBoxs"].SetIconIndex(self.dialog_index)
|
||||
|
||||
self.Icons["DialogBoxs"].DrawTopLeft()
|
||||
|
||||
self.Icons["airwire"].Draw()
|
||||
|
||||
self.Icons["GS"].NewCoord(98,118)
|
||||
self.Icons["GS"].Draw()
|
||||
|
||||
if self.HWND != nil {
|
||||
surface.Fill(self.HWND, &color.Color{255,255,255,255})
|
||||
rect_ := rect.Rect(self.PosX,self.PosY,self.Width,self.Height)
|
||||
surface.Blit(self.HWND,self.CanvasHWND,&rect_,nil)
|
||||
}
|
||||
self.ClearCanvas()
|
||||
self.Icons["DialogBoxs"].NewCoord(145, 23)
|
||||
self.Icons["airwire"].NewCoord(80, self.airwire_y)
|
||||
|
||||
self.Icons["DialogBoxs"].SetIconIndex(self.dialog_index)
|
||||
|
||||
self.Icons["DialogBoxs"].DrawTopLeft()
|
||||
|
||||
self.Icons["airwire"].Draw()
|
||||
|
||||
self.Icons["GS"].NewCoord(98, 118)
|
||||
self.Icons["GS"].Draw()
|
||||
|
||||
if self.HWND != nil {
|
||||
surface.Fill(self.HWND, &color.Color{255, 255, 255, 255})
|
||||
rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
|
||||
surface.Blit(self.HWND, self.CanvasHWND, &rect_, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package Airplane
|
||||
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||
)
|
||||
@@ -16,21 +16,20 @@ import (
|
||||
/******************************************************************************/
|
||||
type AirplanePlugin struct {
|
||||
UI.Plugin
|
||||
AirplanePage *AirplanePage
|
||||
AirplanePage *AirplanePage
|
||||
}
|
||||
|
||||
|
||||
func (self *AirplanePlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *AirplanePlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.AirplanePage = NewAirplanePage()
|
||||
self.AirplanePage.SetScreen( main_screen)
|
||||
self.AirplanePage.SetScreen(main_screen)
|
||||
self.AirplanePage.SetName("Airplane")
|
||||
self.AirplanePage.Init()
|
||||
self.AirplanePage.Init()
|
||||
}
|
||||
|
||||
func (self *AirplanePlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *AirplanePlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.AirplanePage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.AirplanePage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
@@ -1,156 +1,155 @@
|
||||
package Bluetooth
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
//"os"
|
||||
//"log"
|
||||
//"strings"
|
||||
|
||||
//"github.com/fatih/structs"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/rect"
|
||||
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/font"
|
||||
*/
|
||||
"github.com/cuu/gogame/time"
|
||||
"github.com/cuu/gogame/event"
|
||||
//"github.com/godbus/dbus"
|
||||
//"github.com/muka/go-bluetooth/api"
|
||||
//"github.com/muka/go-bluetooth/bluez"
|
||||
//"github.com/muka/go-bluetooth/bluez/profile"
|
||||
"github.com/muka/go-bluetooth/bluez/profile/device"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"fmt"
|
||||
//"os"
|
||||
//"log"
|
||||
//"strings"
|
||||
|
||||
//"github.com/fatih/structs"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/rect"
|
||||
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/font"
|
||||
*/
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/time"
|
||||
//"github.com/godbus/dbus"
|
||||
//"github.com/muka/go-bluetooth/api"
|
||||
//"github.com/muka/go-bluetooth/bluez"
|
||||
//"github.com/muka/go-bluetooth/bluez/profile"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/muka/go-bluetooth/bluez/profile/device"
|
||||
)
|
||||
|
||||
type BleAgentPairPage struct {
|
||||
UI.Page
|
||||
|
||||
Pin string
|
||||
Pass string
|
||||
DevObj *device.Device1
|
||||
Leader *BluetoothPlugin
|
||||
UI.Page
|
||||
|
||||
Pin string
|
||||
Pass string
|
||||
DevObj *device.Device1
|
||||
Leader *BluetoothPlugin
|
||||
}
|
||||
|
||||
func NewBleAgentPairPage() *BleAgentPairPage {
|
||||
p := &BleAgentPairPage{}
|
||||
p.PageIconMargin = 20
|
||||
p := &BleAgentPairPage{}
|
||||
p.PageIconMargin = 20
|
||||
p.SelectedIconTopOffset = 20
|
||||
p.EasingDur = 10
|
||||
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.FootMsg = [5]string{"Nav.","","","Back",""}
|
||||
|
||||
return p
|
||||
p.FootMsg = [5]string{"Nav.", "", "", "Back", ""}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *BleAgentPairPage) Init() {
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
|
||||
}
|
||||
|
||||
func (self *BleAgentPairPage) ShowPinCode(device string,pincode string) {
|
||||
fmt.Println( fmt.Sprintf("ShowPinCode %s %d" ,device,pincode))
|
||||
if self.Screen.CurPage() != self {
|
||||
self.Screen.PushPage(self)
|
||||
self.ClearCanvas()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
self.Pin = pincode
|
||||
txt := self.Pin
|
||||
if len(self.Pin) > 0 {
|
||||
txt = fmt.Sprintf("Pin code: %s",self.Pin)
|
||||
}
|
||||
|
||||
self.Screen.MsgBox.SetText(txt)
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
func (self *BleAgentPairPage) ShowPinCode(device string, pincode string) {
|
||||
fmt.Println(fmt.Sprintf("ShowPinCode %s %d", device, pincode))
|
||||
if self.Screen.CurPage() != self {
|
||||
self.Screen.PushPage(self)
|
||||
self.ClearCanvas()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
self.Pin = pincode
|
||||
txt := self.Pin
|
||||
if len(self.Pin) > 0 {
|
||||
txt = fmt.Sprintf("Pin code: %s", self.Pin)
|
||||
}
|
||||
|
||||
self.Screen.MsgBox.SetText(txt)
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
func (self *BleAgentPairPage) ShowPassKey(device string,passkey uint32,entered uint16) {
|
||||
fmt.Println(fmt.Sprintf("ShowPassKey %06d %d",passkey,entered) )
|
||||
if self.Screen.CurPage() != self {
|
||||
self.Screen.PushPage(self)
|
||||
self.ClearCanvas()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
self.Pass = fmt.Sprintf("%06d",passkey)
|
||||
txt := self.Pass
|
||||
if len(self.Pass) > 0 {
|
||||
txt = fmt.Sprintf("Pair code: %s",self.Pass)
|
||||
}
|
||||
|
||||
self.Screen.MsgBox.SetText(txt)
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
func (self *BleAgentPairPage) ShowPassKey(device string, passkey uint32, entered uint16) {
|
||||
fmt.Println(fmt.Sprintf("ShowPassKey %06d %d", passkey, entered))
|
||||
if self.Screen.CurPage() != self {
|
||||
self.Screen.PushPage(self)
|
||||
self.ClearCanvas()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
self.Pass = fmt.Sprintf("%06d", passkey)
|
||||
txt := self.Pass
|
||||
if len(self.Pass) > 0 {
|
||||
txt = fmt.Sprintf("Pair code: %s", self.Pass)
|
||||
}
|
||||
|
||||
self.Screen.MsgBox.SetText(txt)
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
}
|
||||
|
||||
func (self *BleAgentPairPage) PairOKCb() {
|
||||
self.ClearCanvas()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
self.Screen.MsgBox.SetText("Device paired")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
time.BlockDelay(1500)
|
||||
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
self.Screen.FootBar.ResetNavText()
|
||||
|
||||
self.ClearCanvas()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
self.Screen.MsgBox.SetText("Device paired")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
time.BlockDelay(1500)
|
||||
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
self.Screen.FootBar.ResetNavText()
|
||||
|
||||
}
|
||||
|
||||
func (self *BleAgentPairPage) PairErrorCb( err_msg string) {
|
||||
self.ClearCanvas()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
self.Screen.MsgBox.SetText(err_msg)
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
time.BlockDelay(1500)
|
||||
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
self.Screen.FootBar.ResetNavText()
|
||||
func (self *BleAgentPairPage) PairErrorCb(err_msg string) {
|
||||
self.ClearCanvas()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
self.Screen.MsgBox.SetText(err_msg)
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
time.BlockDelay(1500)
|
||||
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
self.Screen.FootBar.ResetNavText()
|
||||
|
||||
}
|
||||
|
||||
func (self *BleAgentPairPage) KeyDown(ev *event.Event) {
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||
if self.DevObj != nil {
|
||||
err := self.DevObj.CancelPairing()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||
if self.DevObj != nil {
|
||||
err := self.DevObj.CancelPairing()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
}
|
||||
|
||||
func (self *BleAgentPairPage) Draw() {
|
||||
// DoNothing
|
||||
// DoNothing
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,55 +1,54 @@
|
||||
package Bluetooth
|
||||
|
||||
import (
|
||||
//"fmt"
|
||||
|
||||
//bleapi "github.com/muka/go-bluetooth/api"
|
||||
//"github.com/muka/go-bluetooth/bluez/profile"
|
||||
"github.com/muka/go-bluetooth/bluez/profile/device"
|
||||
//"fmt"
|
||||
|
||||
//bleapi "github.com/muka/go-bluetooth/api"
|
||||
//"github.com/muka/go-bluetooth/bluez/profile"
|
||||
"github.com/muka/go-bluetooth/bluez/profile/device"
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
var NetItemDefaultHeight = 30
|
||||
|
||||
type NetItemMultiIcon struct {
|
||||
UI.MultiIconItem
|
||||
CanvasHWND *sdl.Surface // self._Parent._CanvasHWND
|
||||
CanvasHWND *sdl.Surface // self._Parent._CanvasHWND
|
||||
Parent UI.WidgetInterface //
|
||||
}
|
||||
|
||||
func NewNetItemMultiIcon() *NetItemMultiIcon{
|
||||
func NewNetItemMultiIcon() *NetItemMultiIcon {
|
||||
p := &NetItemMultiIcon{}
|
||||
p.IconIndex = 0
|
||||
p.IconWidth = 18
|
||||
p.IconHeight = 18
|
||||
|
||||
p.Width = 18
|
||||
p.Height = 18
|
||||
p.IconHeight = 18
|
||||
|
||||
p.Width = 18
|
||||
p.Height = 18
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *NetItemMultiIcon) Draw() {
|
||||
_,h_ := self.Parent.Size()
|
||||
dest_rect := rect.Rect(self.PosX,self.PosY+(h_-self.Height)/2, self.Width,self.Height)
|
||||
area_rect := rect.Rect(0,self.IconIndex*self.IconHeight,self.IconWidth,self.IconHeight)
|
||||
surface.Blit(self.CanvasHWND,self.ImgSurf,&dest_rect,&area_rect)
|
||||
|
||||
_, h_ := self.Parent.Size()
|
||||
dest_rect := rect.Rect(self.PosX, self.PosY+(h_-self.Height)/2, self.Width, self.Height)
|
||||
area_rect := rect.Rect(0, self.IconIndex*self.IconHeight, self.IconWidth, self.IconHeight)
|
||||
surface.Blit(self.CanvasHWND, self.ImgSurf, &dest_rect, &area_rect)
|
||||
|
||||
}
|
||||
|
||||
type NetItemIcon struct {
|
||||
UI.IconItem
|
||||
CanvasHWND *sdl.Surface
|
||||
Parent UI.WidgetInterface
|
||||
Parent UI.WidgetInterface
|
||||
}
|
||||
|
||||
func NewNetItemIcon() *NetItemIcon {
|
||||
@@ -60,76 +59,72 @@ func NewNetItemIcon() *NetItemIcon {
|
||||
}
|
||||
|
||||
func (self *NetItemIcon) Draw() {
|
||||
_,h_ := self.Parent.Size()
|
||||
_, h_ := self.Parent.Size()
|
||||
|
||||
dest_rect := rect.Rect(self.PosX,self.PosY+(h_-self.Height)/2,self.Width,self.Height)
|
||||
dest_rect := rect.Rect(self.PosX, self.PosY+(h_-self.Height)/2, self.Width, self.Height)
|
||||
|
||||
surface.Blit(self.CanvasHWND, self.ImgSurf, &dest_rect, nil)
|
||||
|
||||
surface.Blit(self.CanvasHWND,self.ImgSurf,&dest_rect,nil)
|
||||
|
||||
}
|
||||
|
||||
type NetItem struct {
|
||||
UI.Widget
|
||||
|
||||
Channel string //'10'
|
||||
Stren string //19%
|
||||
|
||||
Icons map[string]UI.IconItemInterface
|
||||
Labels map[string]UI.LabelInterface
|
||||
|
||||
IsActive bool
|
||||
FontObj *ttf.Font
|
||||
RSSI int // 0
|
||||
MacAddr string //
|
||||
Parent *BluetoothPage
|
||||
Path string ///org/bluez/hci0/dev_34_88_5D_97_FF_26
|
||||
Props *device.Device1Properties
|
||||
Device *device.Device1
|
||||
}
|
||||
UI.Widget
|
||||
|
||||
Channel string //'10'
|
||||
Stren string //19%
|
||||
|
||||
Icons map[string]UI.IconItemInterface
|
||||
Labels map[string]UI.LabelInterface
|
||||
|
||||
IsActive bool
|
||||
FontObj *ttf.Font
|
||||
RSSI int // 0
|
||||
MacAddr string //
|
||||
Parent *BluetoothPage
|
||||
Path string ///org/bluez/hci0/dev_34_88_5D_97_FF_26
|
||||
Props *device.Device1Properties
|
||||
Device *device.Device1
|
||||
}
|
||||
|
||||
func NewNetItem() *NetItem {
|
||||
p:= &NetItem{}
|
||||
|
||||
p.Height = NetItemDefaultHeight
|
||||
|
||||
p := &NetItem{}
|
||||
|
||||
p.Height = NetItemDefaultHeight
|
||||
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
p.Icons = make( map[string]UI.IconItemInterface)
|
||||
|
||||
return p
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
|
||||
return p
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (self *NetItem) SetActive(act bool) {
|
||||
self.IsActive = act
|
||||
self.IsActive = act
|
||||
|
||||
}
|
||||
|
||||
func (self *NetItem) Init(_label string) {
|
||||
|
||||
func (self *NetItem) Init( _label string) {
|
||||
|
||||
self.MacAddr = self.Props.Address
|
||||
self.SetActive(self.Props.Connected)
|
||||
|
||||
|
||||
name_label := UI.NewLabel()
|
||||
name_label.PosX = 12
|
||||
|
||||
name_label.CanvasHWND = self.Parent.CanvasHWND
|
||||
|
||||
mac_addr := self.MacAddr
|
||||
if len(self.Props.Name) > 3 {
|
||||
mac_addr = self.Props.Name
|
||||
}
|
||||
|
||||
self.RSSI = int(self.Props.RSSI)
|
||||
|
||||
name_label.Init(mac_addr,self.FontObj,nil)
|
||||
|
||||
self.Labels["mac_addr"] = name_label
|
||||
|
||||
done_icon := NewNetItemIcon()
|
||||
self.MacAddr = self.Props.Address
|
||||
self.SetActive(self.Props.Connected)
|
||||
|
||||
name_label := UI.NewLabel()
|
||||
name_label.PosX = 12
|
||||
|
||||
name_label.CanvasHWND = self.Parent.CanvasHWND
|
||||
|
||||
mac_addr := self.MacAddr
|
||||
if len(self.Props.Name) > 3 {
|
||||
mac_addr = self.Props.Name
|
||||
}
|
||||
|
||||
self.RSSI = int(self.Props.RSSI)
|
||||
|
||||
name_label.Init(mac_addr, self.FontObj, nil)
|
||||
|
||||
self.Labels["mac_addr"] = name_label
|
||||
|
||||
done_icon := NewNetItemIcon()
|
||||
done_icon.ImgSurf = UI.MyIconPool.GetImgSurf("done")
|
||||
done_icon.CanvasHWND = self.Parent.GetCanvasHWND()
|
||||
done_icon.Parent = self
|
||||
@@ -139,32 +134,32 @@ func (self *NetItem) Init( _label string) {
|
||||
}
|
||||
|
||||
func (self *NetItem) Connect() {
|
||||
|
||||
if self.Device != nil {
|
||||
self.Device.Connect()
|
||||
}
|
||||
|
||||
if self.Device != nil {
|
||||
self.Device.Connect()
|
||||
}
|
||||
}
|
||||
|
||||
func (self *NetItem) GetLinkObj() UI.PluginInterface {
|
||||
return nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *NetItem) Draw() {
|
||||
for k,v := range self.Labels {
|
||||
x,_ := v.Coord()
|
||||
_,h := v.Size()
|
||||
self.Labels[k].NewCoord(x, self.PosY+(self.Height - h)/2)
|
||||
self.Labels[k].Draw()
|
||||
}
|
||||
|
||||
if self.IsActive {
|
||||
self.Icons["done"].NewCoord(UI.Width-22, self.PosY)
|
||||
self.Icons["done"].Draw()
|
||||
}
|
||||
for k, v := range self.Labels {
|
||||
x, _ := v.Coord()
|
||||
_, h := v.Size()
|
||||
self.Labels[k].NewCoord(x, self.PosY+(self.Height-h)/2)
|
||||
self.Labels[k].Draw()
|
||||
}
|
||||
|
||||
if self.IsActive {
|
||||
self.Icons["done"].NewCoord(UI.Width-22, self.PosY)
|
||||
self.Icons["done"].Draw()
|
||||
}
|
||||
|
||||
draw.Line(self.Parent.CanvasHWND, &color.Color{169, 169, 169, 255},
|
||||
self.PosX, self.PosY+self.Height-1,
|
||||
self.PosX+self.Width, self.PosY+self.Height-1,
|
||||
1)
|
||||
|
||||
draw.Line(self.Parent.CanvasHWND,&color.Color{169,169,169,255},
|
||||
self.PosX,self.PosY+self.Height-1,
|
||||
self.PosX+self.Width,self.PosY+self.Height-1,
|
||||
1)
|
||||
|
||||
}
|
||||
|
||||
@@ -1,133 +1,129 @@
|
||||
package Bluetooth
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"fmt"
|
||||
//"log"
|
||||
//"os"
|
||||
//"time"
|
||||
"github.com/godbus/dbus/v5"
|
||||
//"github.com/muka/go-bluetooth/api"
|
||||
"github.com/muka/go-bluetooth/hw"
|
||||
//"github.com/muka/go-bluetooth/bluez/profile"
|
||||
"github.com/muka/go-bluetooth/bluez/profile/agent"
|
||||
//"github.com/muka/go-bluetooth/bluez/profile/adapter"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"github.com/godbus/dbus/v5"
|
||||
//"github.com/muka/go-bluetooth/api"
|
||||
"github.com/muka/go-bluetooth/hw"
|
||||
//"github.com/muka/go-bluetooth/bluez/profile"
|
||||
"github.com/muka/go-bluetooth/bluez/profile/agent"
|
||||
//"github.com/muka/go-bluetooth/bluez/profile/adapter"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
/******************************************************************************/
|
||||
type BluetoothPlugin struct {
|
||||
UI.Plugin
|
||||
BluetoothPage *BluetoothPage
|
||||
PairPage *BleAgentPairPage
|
||||
UI.Plugin
|
||||
BluetoothPage *BluetoothPage
|
||||
PairPage *BleAgentPairPage
|
||||
}
|
||||
|
||||
const (
|
||||
adapterID = "hci0"
|
||||
BUS_NAME = "org.bluez"
|
||||
AGENT_INTERFACE = "org.bluez.Agent1"
|
||||
|
||||
adapterID = "hci0"
|
||||
BUS_NAME = "org.bluez"
|
||||
AGENT_INTERFACE = "org.bluez.Agent1"
|
||||
)
|
||||
|
||||
|
||||
func (self *BluetoothPlugin) InitAgent() {
|
||||
|
||||
conn, err := dbus.SystemBus()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ag := agent.NewSimpleAgent()
|
||||
err = agent.ExposeAgent(conn, ag, agent.CapKeyboardDisplay, true)
|
||||
if err != nil {
|
||||
fmt.Println( fmt.Errorf("SimpleAgent: %s", err) )
|
||||
return
|
||||
}
|
||||
conn, err := dbus.SystemBus()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ag := agent.NewSimpleAgent()
|
||||
err = agent.ExposeAgent(conn, ag, agent.CapKeyboardDisplay, true)
|
||||
if err != nil {
|
||||
fmt.Println(fmt.Errorf("SimpleAgent: %s", err))
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *BluetoothPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
|
||||
log.Println("Reset bluetooth device")
|
||||
|
||||
btmgmt := hw.NewBtMgmt(adapterID)
|
||||
btmgmt.SetPowered(true)
|
||||
func (self *BluetoothPlugin) Init(main_screen *UI.MainScreen) {
|
||||
|
||||
self.BluetoothPage = NewBluetoothPage()
|
||||
self.BluetoothPage.SetScreen( main_screen)
|
||||
self.BluetoothPage.SetName("Bluetooth")
|
||||
self.BluetoothPage.Leader = self
|
||||
self.BluetoothPage.Init()
|
||||
|
||||
self.PairPage = NewBleAgentPairPage()
|
||||
self.PairPage.SetScreen( main_screen)
|
||||
self.PairPage.SetName("Bluetooth pair")
|
||||
self.PairPage.Leader = self
|
||||
self.PairPage.Init()
|
||||
|
||||
self.InitAgent()
|
||||
|
||||
/*
|
||||
a, err := adapter.GetAdapter(adapterID)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
log.Println("Reset bluetooth device")
|
||||
|
||||
discovery, cancel, err := api.Discover(a, nil)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
btmgmt := hw.NewBtMgmt(adapterID)
|
||||
btmgmt.SetPowered(true)
|
||||
|
||||
defer cancel()
|
||||
self.BluetoothPage = NewBluetoothPage()
|
||||
self.BluetoothPage.SetScreen(main_screen)
|
||||
self.BluetoothPage.SetName("Bluetooth")
|
||||
self.BluetoothPage.Leader = self
|
||||
self.BluetoothPage.Init()
|
||||
|
||||
wait := make(chan error)
|
||||
self.PairPage = NewBleAgentPairPage()
|
||||
self.PairPage.SetScreen(main_screen)
|
||||
self.PairPage.SetName("Bluetooth pair")
|
||||
self.PairPage.Leader = self
|
||||
self.PairPage.Init()
|
||||
|
||||
go func() {
|
||||
for dev := range discovery {
|
||||
if dev == nil {
|
||||
return
|
||||
}
|
||||
wait <- nil
|
||||
}
|
||||
}()
|
||||
self.InitAgent()
|
||||
|
||||
go func() {
|
||||
sleep := 5
|
||||
time.Sleep(time.Duration(sleep) * time.Second)
|
||||
log.Debugf("Discovery timeout exceeded (%ds)", sleep)
|
||||
wait <- nil
|
||||
}()
|
||||
/*
|
||||
a, err := adapter.GetAdapter(adapterID)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
err = <-wait
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
*/
|
||||
discovery, cancel, err := api.Discover(a, nil)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
defer cancel()
|
||||
|
||||
wait := make(chan error)
|
||||
|
||||
go func() {
|
||||
for dev := range discovery {
|
||||
if dev == nil {
|
||||
return
|
||||
}
|
||||
wait <- nil
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
sleep := 5
|
||||
time.Sleep(time.Duration(sleep) * time.Second)
|
||||
log.Debugf("Discovery timeout exceeded (%ds)", sleep)
|
||||
wait <- nil
|
||||
}()
|
||||
|
||||
err = <-wait
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
*/
|
||||
|
||||
//self.BluetoothPage.RefreshDevices()
|
||||
//self.BluetoothPage.GenNetworkList()
|
||||
|
||||
//self.BluetoothPage.RefreshDevices()
|
||||
//self.BluetoothPage.GenNetworkList()
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
func (self *BluetoothPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.BluetoothPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
func (self *BluetoothPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.BluetoothPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
}
|
||||
|
||||
var APIOBJ BluetoothPlugin
|
||||
|
||||
@@ -1,296 +1,294 @@
|
||||
package Brightness
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
type OnChangeCB_T func(int)
|
||||
|
||||
type SliderIcon struct {
|
||||
UI.IconItem
|
||||
Parent *BSlider
|
||||
|
||||
UI.IconItem
|
||||
Parent *BSlider
|
||||
}
|
||||
|
||||
func NewSliderIcon() *SliderIcon {
|
||||
p := &SliderIcon{}
|
||||
p := &SliderIcon{}
|
||||
p.MyType = UI.ICON_TYPES["EXE"]
|
||||
p.Align = UI.ALIGN["VCenter"]
|
||||
|
||||
return p
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *SliderIcon) Draw() {
|
||||
if self.Parent == nil {
|
||||
fmt.Println("Error: SliderIcon Draw Parent nil")
|
||||
return
|
||||
}
|
||||
parent_x,parent_y := self.Parent.Coord()
|
||||
|
||||
if self.Parent == nil {
|
||||
fmt.Println("Error: SliderIcon Draw Parent nil")
|
||||
return
|
||||
}
|
||||
parent_x, parent_y := self.Parent.Coord()
|
||||
|
||||
if self.Label != nil {
|
||||
// lab_x,lab_y := self.Label.Coord()
|
||||
lab_w,lab_h:= self.Label.Size()
|
||||
|
||||
// lab_x,lab_y := self.Label.Coord()
|
||||
lab_w, lab_h := self.Label.Size()
|
||||
|
||||
if self.Align == UI.ALIGN["VCenter"] {
|
||||
// fmt.Println("IconItem Draw VCenter:",lab_w,lab_h,self.Label.GetText())
|
||||
|
||||
self.Label.NewCoord( self.PosX - lab_w/2 + parent_x, self.PosY + self.Height/2+6+parent_y)
|
||||
|
||||
}else if self.Align == UI.ALIGN["HLeft"] {
|
||||
self.Label.NewCoord( self.PosX + self.Width/2+3+parent_x, self.PosY - lab_h/2 + parent_y)
|
||||
// fmt.Println("IconItem Draw VCenter:",lab_w,lab_h,self.Label.GetText())
|
||||
|
||||
self.Label.NewCoord(self.PosX-lab_w/2+parent_x, self.PosY+self.Height/2+6+parent_y)
|
||||
|
||||
} else if self.Align == UI.ALIGN["HLeft"] {
|
||||
self.Label.NewCoord(self.PosX+self.Width/2+3+parent_x, self.PosY-lab_h/2+parent_y)
|
||||
}
|
||||
|
||||
self.Label.Draw()
|
||||
}
|
||||
|
||||
if self.ImgSurf != nil {
|
||||
surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf,draw.MidRect(self.PosX + parent_x, self.PosY + parent_y,
|
||||
self.Width,self.Height, UI.Width, UI.Height),nil)
|
||||
surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf, draw.MidRect(self.PosX+parent_x, self.PosY+parent_y,
|
||||
self.Width, self.Height, UI.Width, UI.Height), nil)
|
||||
}
|
||||
}
|
||||
|
||||
type SliderMultiIcon struct {
|
||||
UI.MultiIconItem
|
||||
Parent *BSlider
|
||||
UI.MultiIconItem
|
||||
Parent *BSlider
|
||||
}
|
||||
|
||||
func NewSliderMultiIcon() *SliderMultiIcon {
|
||||
p := &SliderMultiIcon{}
|
||||
p := &SliderMultiIcon{}
|
||||
p.MyType = UI.ICON_TYPES["EXE"]
|
||||
p.Align = UI.ALIGN["VCenter"]
|
||||
|
||||
p.IconIndex = 0
|
||||
|
||||
p.IconIndex = 0
|
||||
p.IconWidth = 18
|
||||
p.IconHeight = 18
|
||||
|
||||
return p
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *SliderMultiIcon) Draw() {
|
||||
if self.Parent == nil {
|
||||
fmt.Println("Error: SliderMultiIcon Draw Parent nil")
|
||||
return
|
||||
}
|
||||
parent_x,parent_y := self.Parent.Coord()
|
||||
|
||||
if self.Parent == nil {
|
||||
fmt.Println("Error: SliderMultiIcon Draw Parent nil")
|
||||
return
|
||||
}
|
||||
parent_x, parent_y := self.Parent.Coord()
|
||||
|
||||
if self.Label != nil {
|
||||
// lab_x,lab_y := self.Label.Coord()
|
||||
lab_w,lab_h:= self.Label.Size()
|
||||
// lab_x,lab_y := self.Label.Coord()
|
||||
lab_w, lab_h := self.Label.Size()
|
||||
if self.Align == UI.ALIGN["VCenter"] {
|
||||
self.Label.NewCoord( self.PosX - lab_w/2 + parent_x, self.PosY + self.Height/2+6 + parent_y)
|
||||
}else if self.Align == UI.ALIGN["HLeft"] {
|
||||
self.Label.NewCoord( self.PosX + self.Width/2+3 + parent_x, self.PosY - lab_h/2 + parent_y )
|
||||
self.Label.NewCoord(self.PosX-lab_w/2+parent_x, self.PosY+self.Height/2+6+parent_y)
|
||||
} else if self.Align == UI.ALIGN["HLeft"] {
|
||||
self.Label.NewCoord(self.PosX+self.Width/2+3+parent_x, self.PosY-lab_h/2+parent_y)
|
||||
}
|
||||
|
||||
self.Label.Draw()
|
||||
}
|
||||
|
||||
if self.ImgSurf != nil {
|
||||
|
||||
portion := rect.Rect(0,self.IconIndex*self.IconHeight,self.IconWidth,self.IconHeight)
|
||||
|
||||
|
||||
portion := rect.Rect(0, self.IconIndex*self.IconHeight, self.IconWidth, self.IconHeight)
|
||||
|
||||
surface.Blit(self.Parent.GetCanvasHWND(),
|
||||
self.ImgSurf,draw.MidRect(self.PosX + parent_x, self.PosY + parent_y,
|
||||
self.Width,self.Height, UI.Width, UI.Height),&portion)
|
||||
self.ImgSurf, draw.MidRect(self.PosX+parent_x, self.PosY+parent_y,
|
||||
self.Width, self.Height, UI.Width, UI.Height), &portion)
|
||||
}
|
||||
}
|
||||
|
||||
type BSlider struct {
|
||||
UI.Slider
|
||||
|
||||
BGpng *SliderIcon
|
||||
BGwidth int
|
||||
BGheight int
|
||||
//NeedleSurf
|
||||
Scale *SliderMultiIcon
|
||||
Parent *BrightnessPage
|
||||
|
||||
OnChangeCB OnChangeCB_T
|
||||
|
||||
UI.Slider
|
||||
|
||||
BGpng *SliderIcon
|
||||
BGwidth int
|
||||
BGheight int
|
||||
//NeedleSurf
|
||||
Scale *SliderMultiIcon
|
||||
Parent *BrightnessPage
|
||||
|
||||
OnChangeCB OnChangeCB_T
|
||||
}
|
||||
|
||||
func NewBSlider() *BSlider {
|
||||
p := &BSlider{}
|
||||
p.Range = [2]int{0,255}
|
||||
p.Value = 0
|
||||
|
||||
p.BGwidth = 179
|
||||
p.BGheight = 153
|
||||
|
||||
return p
|
||||
p := &BSlider{}
|
||||
p.Range = [2]int{0, 255}
|
||||
p.Value = 0
|
||||
|
||||
p.BGwidth = 179
|
||||
p.BGheight = 153
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *BSlider) GetCanvasHWND() *sdl.Surface {
|
||||
return self.CanvasHWND
|
||||
return self.CanvasHWND
|
||||
}
|
||||
|
||||
func (self *BSlider) Init() {
|
||||
|
||||
self.Width = self.Parent.Width
|
||||
self.Height = self.Parent.Height
|
||||
|
||||
self.BGpng = NewSliderIcon()
|
||||
self.BGpng.ImgSurf = UI.MyIconPool.GetImgSurf("light")
|
||||
self.BGpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
self.BGpng.Parent = self
|
||||
self.BGpng.Adjust(0,0,self.BGwidth,self.BGheight,0)
|
||||
|
||||
self.Scale = NewSliderMultiIcon()
|
||||
self.Scale.MyType = UI.ICON_TYPES["STAT"]
|
||||
self.Scale.Parent = self
|
||||
self.Scale.ImgSurf = UI.MyIconPool.GetImgSurf("scale")
|
||||
self.Scale.IconWidth = 82
|
||||
self.Scale.IconHeight = 63
|
||||
self.Scale.Adjust(0,0,82,63,0)
|
||||
self.Width = self.Parent.Width
|
||||
self.Height = self.Parent.Height
|
||||
|
||||
self.BGpng = NewSliderIcon()
|
||||
self.BGpng.ImgSurf = UI.MyIconPool.GetImgSurf("light")
|
||||
self.BGpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
self.BGpng.Parent = self
|
||||
self.BGpng.Adjust(0, 0, self.BGwidth, self.BGheight, 0)
|
||||
|
||||
self.Scale = NewSliderMultiIcon()
|
||||
self.Scale.MyType = UI.ICON_TYPES["STAT"]
|
||||
self.Scale.Parent = self
|
||||
self.Scale.ImgSurf = UI.MyIconPool.GetImgSurf("scale")
|
||||
self.Scale.IconWidth = 82
|
||||
self.Scale.IconHeight = 63
|
||||
self.Scale.Adjust(0, 0, 82, 63, 0)
|
||||
|
||||
}
|
||||
|
||||
func (self *BSlider) SetValue( brt int) {
|
||||
self.Value = brt
|
||||
func (self *BSlider) SetValue(brt int) {
|
||||
self.Value = brt
|
||||
}
|
||||
|
||||
func (self *BSlider) Further() {
|
||||
self.Value += 1
|
||||
|
||||
if self.Value > 9 {
|
||||
self.Value = 9
|
||||
}
|
||||
self.Value += 1
|
||||
|
||||
if self.Value > 9 {
|
||||
self.Value = 9
|
||||
}
|
||||
|
||||
if self.OnChangeCB != nil {
|
||||
self.OnChangeCB(self.Value)
|
||||
}
|
||||
|
||||
if self.OnChangeCB != nil {
|
||||
self.OnChangeCB(self.Value)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *BSlider) StepBack() {
|
||||
self.Value -= 1
|
||||
|
||||
if self.Value < 0 {
|
||||
self.Value = 0
|
||||
}
|
||||
|
||||
if self.OnChangeCB != nil {
|
||||
self.OnChangeCB(self.Value)
|
||||
}
|
||||
self.Value -= 1
|
||||
|
||||
if self.Value < 0 {
|
||||
self.Value = 0
|
||||
}
|
||||
|
||||
if self.OnChangeCB != nil {
|
||||
self.OnChangeCB(self.Value)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *BSlider) Draw() {
|
||||
self.BGpng.NewCoord(self.Width/2,self.Height/2+11)
|
||||
self.BGpng.Draw()
|
||||
|
||||
self.Scale.NewCoord(self.Width/2,self.Height/2)
|
||||
self.BGpng.NewCoord(self.Width/2, self.Height/2+11)
|
||||
self.BGpng.Draw()
|
||||
|
||||
self.Scale.NewCoord(self.Width/2, self.Height/2)
|
||||
|
||||
icon_idx := self.Value - 1
|
||||
if icon_idx < 0 {
|
||||
icon_idx = 0
|
||||
}
|
||||
|
||||
self.Scale.IconIndex = icon_idx
|
||||
self.Scale.Draw()
|
||||
|
||||
icon_idx := self.Value-1
|
||||
if icon_idx <0 {
|
||||
icon_idx = 0
|
||||
}
|
||||
|
||||
self.Scale.IconIndex = icon_idx
|
||||
self.Scale.Draw()
|
||||
|
||||
}
|
||||
|
||||
type BrightnessPage struct {
|
||||
UI.Page
|
||||
MySlider *BSlider
|
||||
UI.Page
|
||||
MySlider *BSlider
|
||||
}
|
||||
|
||||
func NewBrightnessPage() *BrightnessPage {
|
||||
p:= &BrightnessPage{}
|
||||
|
||||
p := &BrightnessPage{}
|
||||
|
||||
p.PageIconMargin = 20
|
||||
p.SelectedIconTopOffset = 20
|
||||
p.EasingDur = 10
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.FootMsg = [5]string{"Nav","","","Back","Enter"}
|
||||
|
||||
return p
|
||||
p.FootMsg = [5]string{"Nav", "", "", "Back", "Enter"}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *BrightnessPage) Init() {
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
self.MySlider = NewBSlider()
|
||||
|
||||
self.MySlider.Parent = self
|
||||
|
||||
self.MySlider.SetCanvasHWND(self.CanvasHWND)
|
||||
self.MySlider.OnChangeCB = self.WhenSliderDrag
|
||||
|
||||
self.MySlider.Init()
|
||||
|
||||
brt := self.ReadBackLight()
|
||||
|
||||
self.MySlider.SetValue(brt)
|
||||
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
self.MySlider = NewBSlider()
|
||||
|
||||
self.MySlider.Parent = self
|
||||
|
||||
self.MySlider.SetCanvasHWND(self.CanvasHWND)
|
||||
self.MySlider.OnChangeCB = self.WhenSliderDrag
|
||||
|
||||
self.MySlider.Init()
|
||||
|
||||
brt := self.ReadBackLight()
|
||||
|
||||
self.MySlider.SetValue(brt)
|
||||
|
||||
}
|
||||
|
||||
func (self *BrightnessPage) ReadBackLight() int {
|
||||
|
||||
if UI.FileExists(sysgo.BackLight) == false {
|
||||
return 0
|
||||
}
|
||||
|
||||
lines,err := UI.ReadLines(sysgo.BackLight)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return 0
|
||||
}
|
||||
|
||||
for _,v := range lines {
|
||||
n,e := strconv.Atoi(v)
|
||||
if e == nil {
|
||||
return n
|
||||
}else {
|
||||
fmt.Println(e)
|
||||
return 0
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
return 0
|
||||
|
||||
if UI.FileExists(sysgo.BackLight) == false {
|
||||
return 0
|
||||
}
|
||||
|
||||
lines, err := UI.ReadLines(sysgo.BackLight)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return 0
|
||||
}
|
||||
|
||||
for _, v := range lines {
|
||||
n, e := strconv.Atoi(v)
|
||||
if e == nil {
|
||||
return n
|
||||
} else {
|
||||
fmt.Println(e)
|
||||
return 0
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *BrightnessPage) OnLoadCb() {
|
||||
brt := self.ReadBackLight()
|
||||
|
||||
self.MySlider.SetValue(brt)
|
||||
brt := self.ReadBackLight()
|
||||
|
||||
self.MySlider.SetValue(brt)
|
||||
|
||||
}
|
||||
|
||||
func (self *BrightnessPage) SetBackLight( newbrt int){
|
||||
|
||||
newbrt_str := fmt.Sprintf("%d",newbrt)
|
||||
|
||||
if UI.FileExists(sysgo.BackLight) {
|
||||
err:= ioutil.WriteFile(sysgo.BackLight,[]byte(newbrt_str),0644)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}else{
|
||||
fmt.Println(sysgo.BackLight, " file not existed")
|
||||
}
|
||||
func (self *BrightnessPage) SetBackLight(newbrt int) {
|
||||
|
||||
newbrt_str := fmt.Sprintf("%d", newbrt)
|
||||
|
||||
if UI.FileExists(sysgo.BackLight) {
|
||||
err := ioutil.WriteFile(sysgo.BackLight, []byte(newbrt_str), 0644)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
} else {
|
||||
fmt.Println(sysgo.BackLight, " file not existed")
|
||||
}
|
||||
}
|
||||
|
||||
func (self *BrightnessPage) WhenSliderDrag( val int) {
|
||||
self.SetBackLight(val)
|
||||
func (self *BrightnessPage) WhenSliderDrag(val int) {
|
||||
self.SetBackLight(val)
|
||||
}
|
||||
|
||||
func (self *BrightnessPage) KeyDown(ev *event.Event) {
|
||||
@@ -299,24 +297,23 @@ func (self *BrightnessPage) KeyDown(ev *event.Event) {
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Right"] {
|
||||
self.MySlider.Further()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Left"] {
|
||||
self.MySlider.StepBack()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
if ev.Data["Key"] == UI.CurKeys["Right"] {
|
||||
self.MySlider.Further()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Left"] {
|
||||
self.MySlider.StepBack()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
}
|
||||
|
||||
func (self *BrightnessPage) Draw() {
|
||||
|
||||
self.ClearCanvas()
|
||||
self.MySlider.Draw()
|
||||
self.ClearCanvas()
|
||||
self.MySlider.Draw()
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package Brightness
|
||||
|
||||
/*
|
||||
* sysgo.BackLight
|
||||
* sysgo.BackLight
|
||||
*/
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||
)
|
||||
@@ -19,21 +19,20 @@ import (
|
||||
/******************************************************************************/
|
||||
type BrightnessPlugin struct {
|
||||
UI.Plugin
|
||||
BrightnessPage *BrightnessPage
|
||||
BrightnessPage *BrightnessPage
|
||||
}
|
||||
|
||||
|
||||
func (self *BrightnessPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *BrightnessPlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.BrightnessPage = NewBrightnessPage()
|
||||
self.BrightnessPage.SetScreen( main_screen)
|
||||
self.BrightnessPage.SetScreen(main_screen)
|
||||
self.BrightnessPage.SetName("Brightness")
|
||||
self.BrightnessPage.Init()
|
||||
self.BrightnessPage.Init()
|
||||
}
|
||||
|
||||
func (self *BrightnessPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *BrightnessPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.BrightnessPage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.BrightnessPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
@@ -1,112 +1,109 @@
|
||||
package ButtonsLayout
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os/exec"
|
||||
//"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os/exec"
|
||||
//"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
//"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
//"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
//"github.com/cuu/gogame/time"
|
||||
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
type UpdateConfirmPage struct {
|
||||
UI.ConfirmPage
|
||||
|
||||
RetroArchConf string
|
||||
|
||||
LayoutMode string
|
||||
|
||||
UI.ConfirmPage
|
||||
|
||||
RetroArchConf string
|
||||
|
||||
LayoutMode string
|
||||
}
|
||||
|
||||
func NewUpdateConfirmPage() *UpdateConfirmPage {
|
||||
|
||||
p := &UpdateConfirmPage{}
|
||||
|
||||
p.ListFont = UI.MyLangManager.TrFont("veramono20")
|
||||
|
||||
p.FootMsg = [5]string{"Nav","","","Cancel","Yes"}
|
||||
|
||||
p.ConfirmText = "Apply to RetroArch?"
|
||||
p.RetroArchConf = "/home/cpi/.config/retroarch/retroarch.cfg"
|
||||
p.LayoutMode = "Unknown"
|
||||
|
||||
return p
|
||||
p := &UpdateConfirmPage{}
|
||||
|
||||
p.ListFont = UI.MyLangManager.TrFont("veramono20")
|
||||
|
||||
p.FootMsg = [5]string{"Nav", "", "", "Cancel", "Yes"}
|
||||
|
||||
p.ConfirmText = "Apply to RetroArch?"
|
||||
p.RetroArchConf = "/home/cpi/.config/retroarch/retroarch.cfg"
|
||||
p.LayoutMode = "Unknown"
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *UpdateConfirmPage) ModifyRetroArchConf( keys []string ) string {
|
||||
func (self *UpdateConfirmPage) ModifyRetroArchConf(keys []string) string {
|
||||
|
||||
if UI.FileExists(self.RetroArchConf) {
|
||||
|
||||
confarr,err := UI.ReadLines(self.RetroArchConf)
|
||||
var bka = false
|
||||
var bkb = false
|
||||
var bkx = false
|
||||
var bky = false
|
||||
|
||||
if err == nil {
|
||||
for i,ln := range confarr {
|
||||
parts := strings.Split(ln,"=")
|
||||
if len(parts) < 1 {
|
||||
fmt.Println("retroarch.cfg cannot parse.")
|
||||
return "retroarch.cfg cannot parse."
|
||||
}
|
||||
lnk := strings.Trim(parts[0],"\r\n ")
|
||||
if lnk == "input_player1_a" {
|
||||
confarr[i] = "input_player1_a = \"" + keys[0] + "\"\n"
|
||||
bka=true
|
||||
}
|
||||
if lnk == "input_player1_b" {
|
||||
confarr[i] = "input_player1_b = \"" + keys[1] + "\"\n"
|
||||
bkb = true
|
||||
}
|
||||
if lnk == "input_player1_x" {
|
||||
confarr[i] = "input_player1_x = \"" + keys[2] + "\"\n"
|
||||
bkx = true
|
||||
}
|
||||
|
||||
if lnk == "input_player1_y" {
|
||||
confarr[i] = "input_player1_y = \"" + keys[3] + "\"\n"
|
||||
bky = true
|
||||
}
|
||||
}
|
||||
|
||||
if bka == false || bkb == false || bkx == false || bky == false {
|
||||
fmt.Println("retroarch.cfg validation error.")
|
||||
return "retroarch.cfg validation error."
|
||||
}
|
||||
}
|
||||
|
||||
err = UI.WriteLines(confarr,self.RetroArchConf)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return "retroarch.cfg cannot write."
|
||||
}
|
||||
|
||||
}
|
||||
if UI.FileExists(self.RetroArchConf) {
|
||||
|
||||
fmt.Println( "Completed! Your RA keymap: " + strings.ToUpper(self.LayoutMode) )
|
||||
return "Completed! Your RA keymap: " + strings.ToUpper(self.LayoutMode)
|
||||
confarr, err := UI.ReadLines(self.RetroArchConf)
|
||||
var bka = false
|
||||
var bkb = false
|
||||
var bkx = false
|
||||
var bky = false
|
||||
|
||||
if err == nil {
|
||||
for i, ln := range confarr {
|
||||
parts := strings.Split(ln, "=")
|
||||
if len(parts) < 1 {
|
||||
fmt.Println("retroarch.cfg cannot parse.")
|
||||
return "retroarch.cfg cannot parse."
|
||||
}
|
||||
lnk := strings.Trim(parts[0], "\r\n ")
|
||||
if lnk == "input_player1_a" {
|
||||
confarr[i] = "input_player1_a = \"" + keys[0] + "\"\n"
|
||||
bka = true
|
||||
}
|
||||
if lnk == "input_player1_b" {
|
||||
confarr[i] = "input_player1_b = \"" + keys[1] + "\"\n"
|
||||
bkb = true
|
||||
}
|
||||
if lnk == "input_player1_x" {
|
||||
confarr[i] = "input_player1_x = \"" + keys[2] + "\"\n"
|
||||
bkx = true
|
||||
}
|
||||
|
||||
if lnk == "input_player1_y" {
|
||||
confarr[i] = "input_player1_y = \"" + keys[3] + "\"\n"
|
||||
bky = true
|
||||
}
|
||||
}
|
||||
|
||||
if bka == false || bkb == false || bkx == false || bky == false {
|
||||
fmt.Println("retroarch.cfg validation error.")
|
||||
return "retroarch.cfg validation error."
|
||||
}
|
||||
}
|
||||
|
||||
err = UI.WriteLines(confarr, self.RetroArchConf)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return "retroarch.cfg cannot write."
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fmt.Println("Completed! Your RA keymap: " + strings.ToUpper(self.LayoutMode))
|
||||
return "Completed! Your RA keymap: " + strings.ToUpper(self.LayoutMode)
|
||||
}
|
||||
|
||||
func (self *UpdateConfirmPage) finalizeWithDialog(msg string) {
|
||||
self.Screen.MsgBox.SetText(msg)
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
return
|
||||
self.Screen.MsgBox.SetText(msg)
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
return
|
||||
}
|
||||
|
||||
func (self *UpdateConfirmPage) KeyDown(ev *event.Event) {
|
||||
@@ -116,261 +113,251 @@ func (self *UpdateConfirmPage) KeyDown(ev *event.Event) {
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
|
||||
keymap := []string{"j","k","u","i"}
|
||||
|
||||
if self.LayoutMode == "xbox" {
|
||||
|
||||
keymap = []string{"j","k","u","i"}
|
||||
|
||||
}else if self.LayoutMode == "snes" {
|
||||
|
||||
keymap = []string{ "k","j","i","u" }
|
||||
|
||||
}else {
|
||||
self.finalizeWithDialog("Internal error.")
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println( "mode: ",self.LayoutMode)
|
||||
|
||||
if UI.IsAFile(self.RetroArchConf) == false {
|
||||
self.finalizeWithDialog("retroarch.cfg was not found.")
|
||||
return
|
||||
}
|
||||
|
||||
cpCmd := exec.Command("cp", "-rf", self.RetroArchConf,self.RetroArchConf+".blbak")
|
||||
err := cpCmd.Run()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
self.finalizeWithDialog("Cannot create .blbak")
|
||||
return
|
||||
}
|
||||
|
||||
self.finalizeWithDialog(self.ModifyRetroArchConf(keymap))
|
||||
return
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
|
||||
keymap := []string{"j", "k", "u", "i"}
|
||||
|
||||
if self.LayoutMode == "xbox" {
|
||||
|
||||
keymap = []string{"j", "k", "u", "i"}
|
||||
|
||||
} else if self.LayoutMode == "snes" {
|
||||
|
||||
keymap = []string{"k", "j", "i", "u"}
|
||||
|
||||
} else {
|
||||
self.finalizeWithDialog("Internal error.")
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("mode: ", self.LayoutMode)
|
||||
|
||||
if UI.IsAFile(self.RetroArchConf) == false {
|
||||
self.finalizeWithDialog("retroarch.cfg was not found.")
|
||||
return
|
||||
}
|
||||
|
||||
cpCmd := exec.Command("cp", "-rf", self.RetroArchConf, self.RetroArchConf+".blbak")
|
||||
err := cpCmd.Run()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
self.finalizeWithDialog("Cannot create .blbak")
|
||||
return
|
||||
}
|
||||
|
||||
self.finalizeWithDialog(self.ModifyRetroArchConf(keymap))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (self *UpdateConfirmPage) OnReturnBackCb() {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
func (self *UpdateConfirmPage) Draw() {
|
||||
self.ClearCanvas()
|
||||
self.DrawBG()
|
||||
for _,v := range self.MyList {
|
||||
v.Draw()
|
||||
}
|
||||
|
||||
self.Reset()
|
||||
self.ClearCanvas()
|
||||
self.DrawBG()
|
||||
for _, v := range self.MyList {
|
||||
v.Draw()
|
||||
}
|
||||
|
||||
self.Reset()
|
||||
}
|
||||
|
||||
type ButtonsLayoutPage struct {
|
||||
|
||||
UI.Page
|
||||
ListFontObj *ttf.Font
|
||||
BGwidth int
|
||||
BGheight int
|
||||
|
||||
DrawOnce bool
|
||||
Scrolled int
|
||||
Scroller *UI.ListScroller
|
||||
ConfirmPage *UpdateConfirmPage
|
||||
|
||||
dialog_index int
|
||||
Icons map[string]UI.IconItemInterface
|
||||
|
||||
ConfigFilename string
|
||||
UI.Page
|
||||
ListFontObj *ttf.Font
|
||||
BGwidth int
|
||||
BGheight int
|
||||
|
||||
DrawOnce bool
|
||||
Scrolled int
|
||||
Scroller *UI.ListScroller
|
||||
ConfirmPage *UpdateConfirmPage
|
||||
|
||||
dialog_index int
|
||||
Icons map[string]UI.IconItemInterface
|
||||
|
||||
ConfigFilename string
|
||||
}
|
||||
|
||||
|
||||
func NewButtonsLayoutPage() *ButtonsLayoutPage {
|
||||
p := &ButtonsLayoutPage{}
|
||||
p := &ButtonsLayoutPage{}
|
||||
p.PageIconMargin = 20
|
||||
p.SelectedIconTopOffset = 20
|
||||
p.EasingDur = 10
|
||||
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.FootMsg = [5]string{"Nav","UpdateRetroArch","","Back","Toggle"}
|
||||
p.Icons = make( map[string]UI.IconItemInterface )
|
||||
|
||||
p.BGwidth = UI.Width
|
||||
p.BGheight = UI.Height - 24 -20
|
||||
|
||||
p.ConfigFilename = "sysgo/.buttonslayout"
|
||||
|
||||
return p
|
||||
|
||||
p.FootMsg = [5]string{"Nav", "UpdateRetroArch", "", "Back", "Toggle"}
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
|
||||
p.BGwidth = UI.Width
|
||||
p.BGheight = UI.Height - 24 - 20
|
||||
|
||||
p.ConfigFilename = "sysgo/.buttonslayout"
|
||||
|
||||
return p
|
||||
|
||||
}
|
||||
|
||||
func (self *ButtonsLayoutPage) Init() {
|
||||
|
||||
if self.Screen != nil {
|
||||
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||
self.HWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = surface.Surface(self.Screen.Width,self.Screen.Height)
|
||||
}
|
||||
}
|
||||
|
||||
self.PosX = self.Index*self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
|
||||
DialogBoxs := UI.NewMultiIconItem()
|
||||
DialogBoxs.ImgSurf = UI.MyIconPool.GetImgSurf("buttonslayout")
|
||||
DialogBoxs.MyType = UI.ICON_TYPES["STAT"]
|
||||
DialogBoxs.Parent = self
|
||||
DialogBoxs.IconWidth = 300
|
||||
DialogBoxs.IconHeight = 150
|
||||
DialogBoxs.Adjust(0,0,134,372,0)
|
||||
self.Icons["DialogBoxs"] = DialogBoxs
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
self.Scroller.SetCanvasHWND(self.HWND)
|
||||
|
||||
|
||||
self.ConfirmPage = NewUpdateConfirmPage()
|
||||
self.ConfirmPage.LayoutMode = self.GetButtonsLayoutMode()
|
||||
self.ConfirmPage.Screen = self.Screen
|
||||
self.ConfirmPage.Name = "Overwrite RA conf"
|
||||
self.ConfirmPage.Init()
|
||||
|
||||
if self.Screen != nil {
|
||||
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||
self.HWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = surface.Surface(self.Screen.Width, self.Screen.Height)
|
||||
}
|
||||
}
|
||||
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
DialogBoxs := UI.NewMultiIconItem()
|
||||
DialogBoxs.ImgSurf = UI.MyIconPool.GetImgSurf("buttonslayout")
|
||||
DialogBoxs.MyType = UI.ICON_TYPES["STAT"]
|
||||
DialogBoxs.Parent = self
|
||||
DialogBoxs.IconWidth = 300
|
||||
DialogBoxs.IconHeight = 150
|
||||
DialogBoxs.Adjust(0, 0, 134, 372, 0)
|
||||
self.Icons["DialogBoxs"] = DialogBoxs
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
self.Scroller.SetCanvasHWND(self.HWND)
|
||||
|
||||
self.ConfirmPage = NewUpdateConfirmPage()
|
||||
self.ConfirmPage.LayoutMode = self.GetButtonsLayoutMode()
|
||||
self.ConfirmPage.Screen = self.Screen
|
||||
self.ConfirmPage.Name = "Overwrite RA conf"
|
||||
self.ConfirmPage.Init()
|
||||
|
||||
}
|
||||
|
||||
func (self *ButtonsLayoutPage) ScrollUp() {
|
||||
dis := 10
|
||||
|
||||
if self.PosY < 0 {
|
||||
self.PosY += dis
|
||||
self.Scrolled += dis
|
||||
}
|
||||
dis := 10
|
||||
|
||||
if self.PosY < 0 {
|
||||
self.PosY += dis
|
||||
self.Scrolled += dis
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ButtonsLayoutPage) ScrollDown() {
|
||||
dis := 10
|
||||
|
||||
if UI.Abs(self.Scrolled) < (self.BGheight - self.Height) / 2 + 0 {
|
||||
self.PosY -= dis
|
||||
self.Scrolled -=dis
|
||||
}
|
||||
dis := 10
|
||||
|
||||
if UI.Abs(self.Scrolled) < (self.BGheight-self.Height)/2+0 {
|
||||
self.PosY -= dis
|
||||
self.Scrolled -= dis
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (self *ButtonsLayoutPage) GetButtonsLayoutMode() string {
|
||||
lm := "xbox"
|
||||
|
||||
lm_bytes,err := ioutil.ReadFile(self.ConfigFilename)
|
||||
|
||||
if err == nil {
|
||||
|
||||
for _,v := range []string{"xbox","snes"} {
|
||||
if v == string(lm_bytes) {
|
||||
lm = string(lm_bytes)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
lm := "xbox"
|
||||
|
||||
return lm
|
||||
lm_bytes, err := ioutil.ReadFile(self.ConfigFilename)
|
||||
|
||||
if err == nil {
|
||||
|
||||
for _, v := range []string{"xbox", "snes"} {
|
||||
if v == string(lm_bytes) {
|
||||
lm = string(lm_bytes)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lm
|
||||
}
|
||||
|
||||
func (self *ButtonsLayoutPage) ToggleMode() {
|
||||
|
||||
|
||||
if self.GetButtonsLayoutMode() == "xbox" {
|
||||
d := []byte("snes")
|
||||
err := ioutil.WriteFile(self.ConfigFilename,d,0644)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
self.dialog_index = 1
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
}else {
|
||||
d := []byte("xbox")
|
||||
err := ioutil.WriteFile(self.ConfigFilename,d,0644)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
self.dialog_index = 0
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
}
|
||||
if self.GetButtonsLayoutMode() == "xbox" {
|
||||
d := []byte("snes")
|
||||
err := ioutil.WriteFile(self.ConfigFilename, d, 0644)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
self.dialog_index = 1
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
} else {
|
||||
d := []byte("xbox")
|
||||
err := ioutil.WriteFile(self.ConfigFilename, d, 0644)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
self.dialog_index = 0
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ButtonsLayoutPage) OnLoadCb() {
|
||||
|
||||
self.Scrolled = 0
|
||||
self.PosY = 0
|
||||
self.DrawOnce = false
|
||||
|
||||
|
||||
if self.GetButtonsLayoutMode() == "xbox" {
|
||||
self.dialog_index = 0
|
||||
}else {
|
||||
self.dialog_index = 1
|
||||
}
|
||||
self.Scrolled = 0
|
||||
self.PosY = 0
|
||||
self.DrawOnce = false
|
||||
|
||||
if self.GetButtonsLayoutMode() == "xbox" {
|
||||
self.dialog_index = 0
|
||||
} else {
|
||||
self.dialog_index = 1
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ButtonsLayoutPage) OnReturnBackCb() {
|
||||
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (self *ButtonsLayoutPage) KeyDown(ev *event.Event) {
|
||||
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
self.ToggleMode()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["X"] {
|
||||
self.ConfirmPage.LayoutMode = self.GetButtonsLayoutMode()
|
||||
self.Screen.PushPage(self.ConfirmPage)
|
||||
self.Screen.Draw()
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
self.ToggleMode()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["X"] {
|
||||
self.ConfirmPage.LayoutMode = self.GetButtonsLayoutMode()
|
||||
self.Screen.PushPage(self.ConfirmPage)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *ButtonsLayoutPage) Draw() {
|
||||
|
||||
self.ClearCanvas()
|
||||
|
||||
self.Icons["DialogBoxs"].NewCoord(0,30)
|
||||
|
||||
self.Icons["DialogBoxs"].SetIconIndex(self.dialog_index)
|
||||
self.Icons["DialogBoxs"].DrawTopLeft()
|
||||
|
||||
if self.HWND != nil {
|
||||
surface.Fill(self.HWND, &color.Color{255,255,255,255})
|
||||
rect_ := rect.Rect(self.PosX,self.PosY,self.Width,self.Height)
|
||||
surface.Blit(self.HWND,self.CanvasHWND,&rect_,nil)
|
||||
}
|
||||
self.ClearCanvas()
|
||||
|
||||
self.Icons["DialogBoxs"].NewCoord(0, 30)
|
||||
|
||||
self.Icons["DialogBoxs"].SetIconIndex(self.dialog_index)
|
||||
self.Icons["DialogBoxs"].DrawTopLeft()
|
||||
|
||||
if self.HWND != nil {
|
||||
surface.Fill(self.HWND, &color.Color{255, 255, 255, 255})
|
||||
rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
|
||||
surface.Blit(self.HWND, self.CanvasHWND, &rect_, nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package ButtonsLayout
|
||||
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||
)
|
||||
@@ -16,21 +16,20 @@ import (
|
||||
/******************************************************************************/
|
||||
type ButtonsLayoutPlugin struct {
|
||||
UI.Plugin
|
||||
ButtonsLayoutPage *ButtonsLayoutPage
|
||||
ButtonsLayoutPage *ButtonsLayoutPage
|
||||
}
|
||||
|
||||
|
||||
func (self *ButtonsLayoutPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *ButtonsLayoutPlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.ButtonsLayoutPage = NewButtonsLayoutPage()
|
||||
self.ButtonsLayoutPage.SetScreen( main_screen)
|
||||
self.ButtonsLayoutPage.SetScreen(main_screen)
|
||||
self.ButtonsLayoutPage.SetName("Buttons Layout")
|
||||
self.ButtonsLayoutPage.Init()
|
||||
self.ButtonsLayoutPage.Init()
|
||||
}
|
||||
|
||||
func (self *ButtonsLayoutPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *ButtonsLayoutPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.ButtonsLayoutPage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.ButtonsLayoutPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
@@ -1,424 +1,414 @@
|
||||
package GateWay
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
//"io/ioutil"
|
||||
//"path/filepath"
|
||||
"strings"
|
||||
"strconv"
|
||||
"runtime"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
//"github.com/mitchellh/go-homedir"
|
||||
"fmt"
|
||||
//"io/ioutil"
|
||||
//"path/filepath"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
//"github.com/mitchellh/go-homedir"
|
||||
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/time"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
)
|
||||
|
||||
type ListPageSelector struct {
|
||||
UI.InfoPageSelector
|
||||
UI.InfoPageSelector
|
||||
}
|
||||
|
||||
func NewListPageSelector() *ListPageSelector {
|
||||
|
||||
p := &ListPageSelector{}
|
||||
|
||||
p.Width = UI.Width
|
||||
p.BackgroundColor = &color.Color{131,199,219,255} //SkinManager().GiveColor('Front')
|
||||
|
||||
return p
|
||||
|
||||
p := &ListPageSelector{}
|
||||
|
||||
p.Width = UI.Width
|
||||
p.BackgroundColor = &color.Color{131, 199, 219, 255} //SkinManager().GiveColor('Front')
|
||||
|
||||
return p
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (self *ListPageSelector) Draw() {
|
||||
|
||||
idx := self.Parent.GetPsIndex()
|
||||
mylist := self.Parent.GetMyList()
|
||||
|
||||
if idx < len(mylist) {
|
||||
x,y := mylist[idx].Coord()
|
||||
_,h := mylist[idx].Size()
|
||||
|
||||
self.PosX = x+2
|
||||
self.PosY = y+1
|
||||
self.Height = h-3
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
rect_ := rect.Rect(self.PosX,self.PosY,self.Width-4, self.Height)
|
||||
|
||||
draw.AARoundRect(canvas_,&rect_,self.BackgroundColor,4,0,self.BackgroundColor)
|
||||
}
|
||||
|
||||
idx := self.Parent.GetPsIndex()
|
||||
mylist := self.Parent.GetMyList()
|
||||
|
||||
if idx < len(mylist) {
|
||||
x, y := mylist[idx].Coord()
|
||||
_, h := mylist[idx].Size()
|
||||
|
||||
self.PosX = x + 2
|
||||
self.PosY = y + 1
|
||||
self.Height = h - 3
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
rect_ := rect.Rect(self.PosX, self.PosY, self.Width-4, self.Height)
|
||||
|
||||
draw.AARoundRect(canvas_, &rect_, self.BackgroundColor, 4, 0, self.BackgroundColor)
|
||||
}
|
||||
}
|
||||
|
||||
type PageListItem struct {
|
||||
UI.InfoPageListItem
|
||||
|
||||
Active bool
|
||||
Value string
|
||||
}
|
||||
UI.InfoPageListItem
|
||||
|
||||
Active bool
|
||||
Value string
|
||||
}
|
||||
|
||||
func NewPageListItem() *PageListItem {
|
||||
|
||||
p := &PageListItem{}
|
||||
p.Height = UI.DefaultInfoPageListItemHeight
|
||||
p.ReadOnly = false
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
p.Icons = make( map[string]UI.IconItemInterface)
|
||||
p.Fonts = make(map[string]*ttf.Font)
|
||||
|
||||
return p
|
||||
p := &PageListItem{}
|
||||
p.Height = UI.DefaultInfoPageListItemHeight
|
||||
p.ReadOnly = false
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
p.Fonts = make(map[string]*ttf.Font)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
|
||||
func (self *PageListItem) Draw() {
|
||||
|
||||
x,_ := self.Labels["Text"].Coord()
|
||||
w,h := self.Labels["Text"].Size()
|
||||
|
||||
self.Labels["Text"].NewCoord( x, self.PosY + (self.Height - h)/2 )
|
||||
|
||||
|
||||
if self.Active == true {
|
||||
self.Parent.(*GateWayPage).Icons["done"].NewCoord(self.Parent.(*GateWayPage).Width-30,self.PosY+5)
|
||||
self.Parent.(*GateWayPage).Icons["done"].Draw()
|
||||
}
|
||||
|
||||
self.Labels["Text"].SetBold(self.Active)
|
||||
self.Labels["Text"].Draw()
|
||||
|
||||
|
||||
|
||||
if _, ok := self.Labels["Small"]; ok {
|
||||
x,_ = self.Labels["Small"].Coord()
|
||||
w,h = self.Labels["Small"].Size()
|
||||
|
||||
self.Labels["Small"].NewCoord( self.Width - w - 10 , self.PosY + (self.Height - h)/2 )
|
||||
self.Labels["Small"].Draw()
|
||||
|
||||
}
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
draw.Line(canvas_, &color.Color{169,169,169,255},
|
||||
self.PosX, self.PosY+self.Height -1,
|
||||
self.PosX + self.Width, self.PosY+self.Height -1 ,1)
|
||||
|
||||
|
||||
x, _ := self.Labels["Text"].Coord()
|
||||
w, h := self.Labels["Text"].Size()
|
||||
|
||||
self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2)
|
||||
|
||||
if self.Active == true {
|
||||
self.Parent.(*GateWayPage).Icons["done"].NewCoord(self.Parent.(*GateWayPage).Width-30, self.PosY+5)
|
||||
self.Parent.(*GateWayPage).Icons["done"].Draw()
|
||||
}
|
||||
|
||||
self.Labels["Text"].SetBold(self.Active)
|
||||
self.Labels["Text"].Draw()
|
||||
|
||||
if _, ok := self.Labels["Small"]; ok {
|
||||
x, _ = self.Labels["Small"].Coord()
|
||||
w, h = self.Labels["Small"].Size()
|
||||
|
||||
self.Labels["Small"].NewCoord(self.Width-w-10, self.PosY+(self.Height-h)/2)
|
||||
self.Labels["Small"].Draw()
|
||||
|
||||
}
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
draw.Line(canvas_, &color.Color{169, 169, 169, 255},
|
||||
self.PosX, self.PosY+self.Height-1,
|
||||
self.PosX+self.Width, self.PosY+self.Height-1, 1)
|
||||
|
||||
}
|
||||
|
||||
type GateWayPage struct {
|
||||
UI.Page
|
||||
|
||||
ListFont *ttf.Font
|
||||
|
||||
BGwidth int
|
||||
BGheight int
|
||||
|
||||
DrawOnce bool
|
||||
|
||||
Scroller *UI.ListScroller
|
||||
UI.Page
|
||||
|
||||
Icons map[string]UI.IconItemInterface
|
||||
ListFont *ttf.Font
|
||||
|
||||
BGwidth int
|
||||
BGheight int
|
||||
|
||||
DrawOnce bool
|
||||
|
||||
Scroller *UI.ListScroller
|
||||
|
||||
Icons map[string]UI.IconItemInterface
|
||||
}
|
||||
|
||||
|
||||
func NewGateWayPage() *GateWayPage {
|
||||
p := &GateWayPage{}
|
||||
|
||||
p.ListFont = UI.Fonts["notosanscjk15"]
|
||||
p.FootMsg = [5]string{"Nav","","Clear All","Back","Select"}
|
||||
|
||||
p.BGwidth = UI.Width
|
||||
p.BGheight = UI.Height - 24 - 20
|
||||
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
|
||||
return p
|
||||
p := &GateWayPage{}
|
||||
|
||||
p.ListFont = UI.Fonts["notosanscjk15"]
|
||||
p.FootMsg = [5]string{"Nav", "", "Clear All", "Back", "Select"}
|
||||
|
||||
p.BGwidth = UI.Width
|
||||
p.BGheight = UI.Height - 24 - 20
|
||||
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *GateWayPage) GenList() {
|
||||
|
||||
self.MyList = nil
|
||||
|
||||
start_x := 0
|
||||
start_y := 0
|
||||
last_height := 0
|
||||
|
||||
var drivers = [][2]string{[2]string{"usb0","USB Ethernet"},
|
||||
[2]string{sysgo.WifiDev,"Wi-Fi"}}
|
||||
|
||||
self.MyList = nil
|
||||
|
||||
for _,u := range drivers {
|
||||
li := NewPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + last_height
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFont
|
||||
li.Active = false
|
||||
li.Value = u[0]
|
||||
li.Init(u[1])
|
||||
last_height += li.Height
|
||||
self.MyList = append(self.MyList,li)
|
||||
}
|
||||
start_x := 0
|
||||
start_y := 0
|
||||
last_height := 0
|
||||
|
||||
var drivers = [][2]string{[2]string{"usb0", "USB Ethernet"},
|
||||
[2]string{sysgo.WifiDev, "Wi-Fi"}}
|
||||
|
||||
for _, u := range drivers {
|
||||
li := NewPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + last_height
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFont
|
||||
li.Active = false
|
||||
li.Value = u[0]
|
||||
li.Init(u[1])
|
||||
last_height += li.Height
|
||||
self.MyList = append(self.MyList, li)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *GateWayPage) Init() {
|
||||
|
||||
if self.Screen != nil {
|
||||
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||
self.HWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = surface.Surface( self.Screen.Width,self.Screen.Height )
|
||||
}
|
||||
}
|
||||
|
||||
self.PosX = self.Index*self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
done := UI.NewIconItem()
|
||||
done.ImgSurf = UI.MyIconPool.GetImgSurf("done")
|
||||
done.MyType = UI.ICON_TYPES["STAT"]
|
||||
done.Parent = self
|
||||
|
||||
self.Icons["done"] = done
|
||||
|
||||
ps := NewListPageSelector()
|
||||
ps.Parent = self
|
||||
|
||||
self.Ps = ps
|
||||
self.PsIndex = 0
|
||||
|
||||
self.GenList()
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
self.Scroller.SetCanvasHWND(self.HWND)
|
||||
|
||||
if self.Screen != nil {
|
||||
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||
self.HWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = surface.Surface(self.Screen.Width, self.Screen.Height)
|
||||
}
|
||||
}
|
||||
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
done := UI.NewIconItem()
|
||||
done.ImgSurf = UI.MyIconPool.GetImgSurf("done")
|
||||
done.MyType = UI.ICON_TYPES["STAT"]
|
||||
done.Parent = self
|
||||
|
||||
self.Icons["done"] = done
|
||||
|
||||
ps := NewListPageSelector()
|
||||
ps.Parent = self
|
||||
|
||||
self.Ps = ps
|
||||
self.PsIndex = 0
|
||||
|
||||
self.GenList()
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
self.Scroller.SetCanvasHWND(self.HWND)
|
||||
|
||||
}
|
||||
|
||||
func (self *GateWayPage) Click() {
|
||||
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if self.PsIndex >= len(self.MyList) {
|
||||
self.PsIndex = len(self.MyList) -1
|
||||
}
|
||||
|
||||
cur_li := self.MyList[self.PsIndex].(*PageListItem)
|
||||
if cur_li.Active == true {
|
||||
out := UI.System( "sudo ip route | grep default | cut -d \" \" -f3" )
|
||||
if len(out) > 7 {
|
||||
self.Screen.MsgBox.SetText(strings.Trim(out,"\r\n "))
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if strings.Contains(runtime.GOARCH,"arm") == true {
|
||||
for i,_ := range self.MyList {
|
||||
self.MyList[i].(*PageListItem).Active = false
|
||||
}
|
||||
cur_li.Active = self.ApplyGateWay(cur_li.Value)
|
||||
self.Screen.MsgBox.SetText("Applying")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
time.BlockDelay(1000)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}else {
|
||||
self.Screen.MsgBox.SetText("Do it in GameShell")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if self.PsIndex >= len(self.MyList) {
|
||||
self.PsIndex = len(self.MyList) - 1
|
||||
}
|
||||
|
||||
cur_li := self.MyList[self.PsIndex].(*PageListItem)
|
||||
if cur_li.Active == true {
|
||||
out := UI.System("sudo ip route | grep default | cut -d \" \" -f3")
|
||||
if len(out) > 7 {
|
||||
self.Screen.MsgBox.SetText(strings.Trim(out, "\r\n "))
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if strings.Contains(runtime.GOARCH, "arm") == true {
|
||||
for i, _ := range self.MyList {
|
||||
self.MyList[i].(*PageListItem).Active = false
|
||||
}
|
||||
cur_li.Active = self.ApplyGateWay(cur_li.Value)
|
||||
self.Screen.MsgBox.SetText("Applying")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
time.BlockDelay(1000)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
} else {
|
||||
self.Screen.MsgBox.SetText("Do it in GameShell")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *GateWayPage) ClearAllGateways() {
|
||||
self.Screen.MsgBox.SetText("Cleaning up")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
UI.System("sudo ip route del 0/0")
|
||||
time.BlockDelay(800)
|
||||
|
||||
for i,_ := range self.MyList {
|
||||
self.MyList[i].(*PageListItem).Active = false
|
||||
}
|
||||
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
self.Screen.MsgBox.SetText("Cleaning up")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
UI.System("sudo ip route del 0/0")
|
||||
time.BlockDelay(800)
|
||||
|
||||
for i, _ := range self.MyList {
|
||||
self.MyList[i].(*PageListItem).Active = false
|
||||
}
|
||||
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
}
|
||||
|
||||
func (self *GateWayPage) ApplyGateWay( gateway string ) bool {
|
||||
UI.System("sudo ip route del 0/0")
|
||||
if gateway == "usb0" {
|
||||
out := UI.System("sudo ifconfig usb0 | grep inet | tr -s \" \"| cut -d \" \" -f3")
|
||||
if len(out) > 7 {
|
||||
if strings.Contains(out,"error") == false {
|
||||
out = strings.Trim(out,"\r\n ")
|
||||
parts := strings.Split(out,".")
|
||||
if len(parts) == 4 { // IPv4
|
||||
tmp,err := strconv.Atoi(parts[3])
|
||||
if err == nil {
|
||||
if tmp == 0 {
|
||||
tmp = tmp + 1
|
||||
}else if tmp == 1 {
|
||||
tmp = tmp + 1
|
||||
}else if tmp > 1 {
|
||||
tmp = tmp -1
|
||||
}
|
||||
parts[3] = strconv.Itoa(tmp)
|
||||
ipaddress := strings.Join(parts,".")
|
||||
UI.System( fmt.Sprintf("sudo route add default gw %s",ipaddress) )
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else { // wlan0
|
||||
if self.Screen.IsWifiConnectedNow() == true {
|
||||
UI.System(fmt.Sprintf("sudo dhclient %s",sysgo.WifiDev))
|
||||
return true
|
||||
}else {
|
||||
self.Screen.MsgBox.SetText("Wi-Fi is not connected")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false
|
||||
func (self *GateWayPage) ApplyGateWay(gateway string) bool {
|
||||
UI.System("sudo ip route del 0/0")
|
||||
if gateway == "usb0" {
|
||||
out := UI.System("sudo ifconfig usb0 | grep inet | tr -s \" \"| cut -d \" \" -f3")
|
||||
if len(out) > 7 {
|
||||
if strings.Contains(out, "error") == false {
|
||||
out = strings.Trim(out, "\r\n ")
|
||||
parts := strings.Split(out, ".")
|
||||
if len(parts) == 4 { // IPv4
|
||||
tmp, err := strconv.Atoi(parts[3])
|
||||
if err == nil {
|
||||
if tmp == 0 {
|
||||
tmp = tmp + 1
|
||||
} else if tmp == 1 {
|
||||
tmp = tmp + 1
|
||||
} else if tmp > 1 {
|
||||
tmp = tmp - 1
|
||||
}
|
||||
parts[3] = strconv.Itoa(tmp)
|
||||
ipaddress := strings.Join(parts, ".")
|
||||
UI.System(fmt.Sprintf("sudo route add default gw %s", ipaddress))
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // wlan0
|
||||
if self.Screen.IsWifiConnectedNow() == true {
|
||||
UI.System(fmt.Sprintf("sudo dhclient %s", sysgo.WifiDev))
|
||||
return true
|
||||
} else {
|
||||
self.Screen.MsgBox.SetText("Wi-Fi is not connected")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *GateWayPage) OnLoadCb() {
|
||||
|
||||
self.PosY = 0
|
||||
self.DrawOnce = false
|
||||
|
||||
thedrv := ""
|
||||
if strings.Contains(runtime.GOARCH,"arm") == true {
|
||||
out := UI.System("sudo ip route | grep default")
|
||||
if len(out) > 7 {
|
||||
if strings.Contains(out,"usb0") {
|
||||
thedrv = "usb0"
|
||||
}else if strings.Contains(out,sysgo.WifiDev) {
|
||||
thedrv = sysgo.WifiDev
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for i, _ := range self.MyList {
|
||||
self.MyList[i].(*PageListItem).Active = false
|
||||
}
|
||||
|
||||
if thedrv != "" {
|
||||
for i, v := range self.MyList {
|
||||
if strings.Contains( v.(*PageListItem).Value, thedrv) {
|
||||
self.MyList[i].(*PageListItem).Active = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.PosY = 0
|
||||
self.DrawOnce = false
|
||||
|
||||
thedrv := ""
|
||||
if strings.Contains(runtime.GOARCH, "arm") == true {
|
||||
out := UI.System("sudo ip route | grep default")
|
||||
if len(out) > 7 {
|
||||
if strings.Contains(out, "usb0") {
|
||||
thedrv = "usb0"
|
||||
} else if strings.Contains(out, sysgo.WifiDev) {
|
||||
thedrv = sysgo.WifiDev
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for i, _ := range self.MyList {
|
||||
self.MyList[i].(*PageListItem).Active = false
|
||||
}
|
||||
|
||||
if thedrv != "" {
|
||||
for i, v := range self.MyList {
|
||||
if strings.Contains(v.(*PageListItem).Value, thedrv) {
|
||||
self.MyList[i].(*PageListItem).Active = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *GateWayPage) KeyDown(ev *event.Event ) {
|
||||
|
||||
func (self *GateWayPage) KeyDown(ev *event.Event) {
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
self.Click()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Y"] {
|
||||
self.ClearAllGateways()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Up"] {
|
||||
|
||||
self.ScrollUp()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Down"] {
|
||||
|
||||
self.ScrollDown()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
self.Click()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Y"] {
|
||||
self.ClearAllGateways()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Up"] {
|
||||
|
||||
self.ScrollUp()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Down"] {
|
||||
|
||||
self.ScrollDown()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *GateWayPage) Draw() {
|
||||
|
||||
self.ClearCanvas()
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if len(self.MyList) * UI.DefaultInfoPageListItemHeight > self.Height {
|
||||
|
||||
self.Ps.(*ListPageSelector).Width = self.Width - 11
|
||||
self.Ps.Draw()
|
||||
|
||||
for _,v := range self.MyList {
|
||||
if v.(*PageListItem).PosY > self.Height + self.Height/2 {
|
||||
break
|
||||
}
|
||||
|
||||
if v.(*PageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
|
||||
}
|
||||
|
||||
self.Scroller.UpdateSize( len(self.MyList)*UI.DefaultInfoPageListItemHeight,
|
||||
self.PsIndex*UI.DefaultInfoPageListItemHeight)
|
||||
self.Scroller.Draw()
|
||||
|
||||
}else {
|
||||
self.Ps.(*ListPageSelector).Width = self.Width
|
||||
self.Ps.Draw()
|
||||
for _,v := range self.MyList {
|
||||
if v.(*PageListItem).PosY > self.Height + self.Height/2 {
|
||||
break
|
||||
}
|
||||
|
||||
if v.(*PageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if self.HWND != nil {
|
||||
surface.Fill(self.HWND, &color.Color{255,255,255,255})
|
||||
rect_ := rect.Rect(self.PosX,self.PosY,self.Width,self.Height)
|
||||
surface.Blit(self.HWND,self.CanvasHWND,&rect_,nil)
|
||||
}
|
||||
}
|
||||
|
||||
self.ClearCanvas()
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if len(self.MyList)*UI.DefaultInfoPageListItemHeight > self.Height {
|
||||
|
||||
self.Ps.(*ListPageSelector).Width = self.Width - 11
|
||||
self.Ps.Draw()
|
||||
|
||||
for _, v := range self.MyList {
|
||||
if v.(*PageListItem).PosY > self.Height+self.Height/2 {
|
||||
break
|
||||
}
|
||||
|
||||
if v.(*PageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
|
||||
}
|
||||
|
||||
self.Scroller.UpdateSize(len(self.MyList)*UI.DefaultInfoPageListItemHeight,
|
||||
self.PsIndex*UI.DefaultInfoPageListItemHeight)
|
||||
self.Scroller.Draw()
|
||||
|
||||
} else {
|
||||
self.Ps.(*ListPageSelector).Width = self.Width
|
||||
self.Ps.Draw()
|
||||
for _, v := range self.MyList {
|
||||
if v.(*PageListItem).PosY > self.Height+self.Height/2 {
|
||||
break
|
||||
}
|
||||
|
||||
if v.(*PageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if self.HWND != nil {
|
||||
surface.Fill(self.HWND, &color.Color{255, 255, 255, 255})
|
||||
rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
|
||||
surface.Blit(self.HWND, self.CanvasHWND, &rect_, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package GateWay
|
||||
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||
)
|
||||
@@ -16,21 +16,20 @@ import (
|
||||
/******************************************************************************/
|
||||
type GatewayPlugin struct {
|
||||
UI.Plugin
|
||||
Page1st *GateWayPage
|
||||
Page1st *GateWayPage
|
||||
}
|
||||
|
||||
|
||||
func (self *GatewayPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *GatewayPlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.Page1st = NewGateWayPage()
|
||||
self.Page1st.SetScreen( main_screen)
|
||||
self.Page1st.SetScreen(main_screen)
|
||||
self.Page1st.SetName("Gateway switch")
|
||||
self.Page1st.Init()
|
||||
self.Page1st.Init()
|
||||
}
|
||||
|
||||
func (self *GatewayPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *GatewayPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.Page1st)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.Page1st)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
@@ -1,367 +1,357 @@
|
||||
package Languages
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/time"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
type ListPageSelector struct {
|
||||
UI.InfoPageSelector
|
||||
UI.InfoPageSelector
|
||||
}
|
||||
|
||||
func NewListPageSelector() *ListPageSelector {
|
||||
|
||||
p := &ListPageSelector{}
|
||||
|
||||
p.Width = UI.Width
|
||||
p.BackgroundColor = &color.Color{131,199,219,255} //SkinManager().GiveColor('Front')
|
||||
|
||||
return p
|
||||
|
||||
p := &ListPageSelector{}
|
||||
|
||||
p.Width = UI.Width
|
||||
p.BackgroundColor = &color.Color{131, 199, 219, 255} //SkinManager().GiveColor('Front')
|
||||
|
||||
return p
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (self *ListPageSelector) Draw() {
|
||||
|
||||
idx := self.Parent.GetPsIndex()
|
||||
mylist := self.Parent.GetMyList()
|
||||
|
||||
if idx < len(mylist) {
|
||||
x,y := mylist[idx].Coord()
|
||||
_,h := mylist[idx].Size()
|
||||
|
||||
self.PosX = x+2
|
||||
self.PosY = y+1
|
||||
self.Height = h-3
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
rect_ := rect.Rect(self.PosX,self.PosY,self.Width-4, self.Height)
|
||||
|
||||
draw.AARoundRect(canvas_,&rect_,self.BackgroundColor,4,0,self.BackgroundColor)
|
||||
}
|
||||
|
||||
idx := self.Parent.GetPsIndex()
|
||||
mylist := self.Parent.GetMyList()
|
||||
|
||||
if idx < len(mylist) {
|
||||
x, y := mylist[idx].Coord()
|
||||
_, h := mylist[idx].Size()
|
||||
|
||||
self.PosX = x + 2
|
||||
self.PosY = y + 1
|
||||
self.Height = h - 3
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
rect_ := rect.Rect(self.PosX, self.PosY, self.Width-4, self.Height)
|
||||
|
||||
draw.AARoundRect(canvas_, &rect_, self.BackgroundColor, 4, 0, self.BackgroundColor)
|
||||
}
|
||||
}
|
||||
|
||||
type PageListItem struct {
|
||||
UI.InfoPageListItem
|
||||
|
||||
Active bool
|
||||
Value string
|
||||
}
|
||||
UI.InfoPageListItem
|
||||
|
||||
Active bool
|
||||
Value string
|
||||
}
|
||||
|
||||
func NewPageListItem() *PageListItem {
|
||||
|
||||
p := &PageListItem{}
|
||||
p.Height = UI.DefaultInfoPageListItemHeight
|
||||
p.ReadOnly = false
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
p.Icons = make( map[string]UI.IconItemInterface)
|
||||
p.Fonts = make(map[string]*ttf.Font)
|
||||
|
||||
return p
|
||||
p := &PageListItem{}
|
||||
p.Height = UI.DefaultInfoPageListItemHeight
|
||||
p.ReadOnly = false
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
p.Fonts = make(map[string]*ttf.Font)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
|
||||
func (self *PageListItem) Draw() {
|
||||
|
||||
x,_ := self.Labels["Text"].Coord()
|
||||
w,h := self.Labels["Text"].Size()
|
||||
|
||||
self.Labels["Text"].NewCoord( x, self.PosY + (self.Height - h)/2 )
|
||||
|
||||
|
||||
if self.Active == true {
|
||||
self.Parent.(*LanguagesPage).Icons["done"].NewCoord(self.Parent.(*LanguagesPage).Width-30,self.PosY+5)
|
||||
self.Parent.(*LanguagesPage).Icons["done"].Draw()
|
||||
}
|
||||
|
||||
self.Labels["Text"].SetBold(self.Active)
|
||||
self.Labels["Text"].Draw()
|
||||
|
||||
|
||||
|
||||
if _, ok := self.Labels["Small"]; ok {
|
||||
x,_ = self.Labels["Small"].Coord()
|
||||
w,h = self.Labels["Small"].Size()
|
||||
|
||||
self.Labels["Small"].NewCoord( self.Width - w - 10 , self.PosY + (self.Height - h)/2 )
|
||||
self.Labels["Small"].Draw()
|
||||
|
||||
}
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
draw.Line(canvas_, &color.Color{169,169,169,255},
|
||||
self.PosX, self.PosY+self.Height -1,
|
||||
self.PosX + self.Width, self.PosY+self.Height -1 ,1)
|
||||
|
||||
|
||||
x, _ := self.Labels["Text"].Coord()
|
||||
w, h := self.Labels["Text"].Size()
|
||||
|
||||
self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2)
|
||||
|
||||
if self.Active == true {
|
||||
self.Parent.(*LanguagesPage).Icons["done"].NewCoord(self.Parent.(*LanguagesPage).Width-30, self.PosY+5)
|
||||
self.Parent.(*LanguagesPage).Icons["done"].Draw()
|
||||
}
|
||||
|
||||
self.Labels["Text"].SetBold(self.Active)
|
||||
self.Labels["Text"].Draw()
|
||||
|
||||
if _, ok := self.Labels["Small"]; ok {
|
||||
x, _ = self.Labels["Small"].Coord()
|
||||
w, h = self.Labels["Small"].Size()
|
||||
|
||||
self.Labels["Small"].NewCoord(self.Width-w-10, self.PosY+(self.Height-h)/2)
|
||||
self.Labels["Small"].Draw()
|
||||
|
||||
}
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
draw.Line(canvas_, &color.Color{169, 169, 169, 255},
|
||||
self.PosX, self.PosY+self.Height-1,
|
||||
self.PosX+self.Width, self.PosY+self.Height-1, 1)
|
||||
|
||||
}
|
||||
|
||||
type LanguagesPage struct {
|
||||
UI.Page
|
||||
|
||||
ListFont *ttf.Font
|
||||
|
||||
BGwidth int
|
||||
BGheight int
|
||||
|
||||
DrawOnce bool
|
||||
|
||||
Scroller *UI.ListScroller
|
||||
UI.Page
|
||||
|
||||
Icons map[string]UI.IconItemInterface
|
||||
ListFont *ttf.Font
|
||||
|
||||
BGwidth int
|
||||
BGheight int
|
||||
|
||||
DrawOnce bool
|
||||
|
||||
Scroller *UI.ListScroller
|
||||
|
||||
Icons map[string]UI.IconItemInterface
|
||||
}
|
||||
|
||||
|
||||
func NewLanguagesPage() *LanguagesPage {
|
||||
p := &LanguagesPage{}
|
||||
|
||||
p.ListFont = UI.Fonts["notosanscjk15"]
|
||||
p.FootMsg = [5]string{"Nav","","","Back","Select"}
|
||||
|
||||
p.BGwidth = UI.Width
|
||||
p.BGheight = UI.Height - 24 - 20
|
||||
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
|
||||
return p
|
||||
p := &LanguagesPage{}
|
||||
|
||||
p.ListFont = UI.Fonts["notosanscjk15"]
|
||||
p.FootMsg = [5]string{"Nav", "", "", "Back", "Select"}
|
||||
|
||||
p.BGwidth = UI.Width
|
||||
p.BGheight = UI.Height - 24 - 20
|
||||
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *LanguagesPage) GenList() {
|
||||
|
||||
self.MyList = nil
|
||||
|
||||
start_x := 0
|
||||
start_y := 0
|
||||
last_height := 0
|
||||
|
||||
file_paths,err := filepath.Glob("sysgo/langs/*.ini")//sorted
|
||||
|
||||
if err == nil {
|
||||
for _,u := range file_paths {
|
||||
parts := strings.Split(filepath.Base(u),"_")
|
||||
if len(parts) > 1 {
|
||||
li := NewPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + last_height
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFont
|
||||
li.Active = false
|
||||
li.Value = filepath.Base(u)
|
||||
|
||||
lang_name := parts[1]
|
||||
parts = strings.Split(lang_name,".")
|
||||
lang_name = parts[0]
|
||||
|
||||
li.Init(lang_name)
|
||||
last_height += li.Height
|
||||
self.MyList = append(self.MyList,li)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
self.MyList = nil
|
||||
|
||||
start_x := 0
|
||||
start_y := 0
|
||||
last_height := 0
|
||||
|
||||
file_paths, err := filepath.Glob("sysgo/langs/*.ini") //sorted
|
||||
|
||||
if err == nil {
|
||||
for _, u := range file_paths {
|
||||
parts := strings.Split(filepath.Base(u), "_")
|
||||
if len(parts) > 1 {
|
||||
li := NewPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + last_height
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFont
|
||||
li.Active = false
|
||||
li.Value = filepath.Base(u)
|
||||
|
||||
lang_name := parts[1]
|
||||
parts = strings.Split(lang_name, ".")
|
||||
lang_name = parts[0]
|
||||
|
||||
li.Init(lang_name)
|
||||
last_height += li.Height
|
||||
self.MyList = append(self.MyList, li)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *LanguagesPage) Init() {
|
||||
|
||||
if self.Screen != nil {
|
||||
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||
self.HWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = surface.Surface( self.Screen.Width,self.Screen.Height )
|
||||
}
|
||||
}
|
||||
|
||||
self.PosX = self.Index*self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
done := UI.NewIconItem()
|
||||
done.ImgSurf = UI.MyIconPool.GetImgSurf("done")
|
||||
done.MyType = UI.ICON_TYPES["STAT"]
|
||||
done.Parent = self
|
||||
|
||||
self.Icons["done"] = done
|
||||
|
||||
ps := NewListPageSelector()
|
||||
ps.Parent = self
|
||||
|
||||
self.Ps = ps
|
||||
self.PsIndex = 0
|
||||
|
||||
self.GenList()
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
self.Scroller.SetCanvasHWND(self.HWND)
|
||||
|
||||
if self.Screen != nil {
|
||||
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||
self.HWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = surface.Surface(self.Screen.Width, self.Screen.Height)
|
||||
}
|
||||
}
|
||||
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
done := UI.NewIconItem()
|
||||
done.ImgSurf = UI.MyIconPool.GetImgSurf("done")
|
||||
done.MyType = UI.ICON_TYPES["STAT"]
|
||||
done.Parent = self
|
||||
|
||||
self.Icons["done"] = done
|
||||
|
||||
ps := NewListPageSelector()
|
||||
ps.Parent = self
|
||||
|
||||
self.Ps = ps
|
||||
self.PsIndex = 0
|
||||
|
||||
self.GenList()
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
self.Scroller.SetCanvasHWND(self.HWND)
|
||||
|
||||
}
|
||||
|
||||
func (self *LanguagesPage) Click() {
|
||||
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if self.PsIndex >= len(self.MyList) {
|
||||
self.PsIndex = len(self.MyList) -1
|
||||
}
|
||||
|
||||
cur_li := self.MyList[self.PsIndex]
|
||||
if cur_li.(*PageListItem).Active == true {
|
||||
return
|
||||
}
|
||||
|
||||
for i,_ := range self.MyList {
|
||||
self.MyList[i].(*PageListItem).Active = false
|
||||
}
|
||||
|
||||
cur_li.(*PageListItem).Active = true
|
||||
|
||||
d := []byte(fmt.Sprintf("%s",cur_li.(*PageListItem).Value))
|
||||
err := ioutil.WriteFile("sysgo/.lang", d, 0644)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
self.Screen.MsgBox.SetText("Applying")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
UI.MyLangManager.UpdateLang()
|
||||
|
||||
event.Post(UI.RESTARTUI,"")
|
||||
|
||||
time.BlockDelay(1000)
|
||||
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if self.PsIndex >= len(self.MyList) {
|
||||
self.PsIndex = len(self.MyList) - 1
|
||||
}
|
||||
|
||||
cur_li := self.MyList[self.PsIndex]
|
||||
if cur_li.(*PageListItem).Active == true {
|
||||
return
|
||||
}
|
||||
|
||||
for i, _ := range self.MyList {
|
||||
self.MyList[i].(*PageListItem).Active = false
|
||||
}
|
||||
|
||||
cur_li.(*PageListItem).Active = true
|
||||
|
||||
d := []byte(fmt.Sprintf("%s", cur_li.(*PageListItem).Value))
|
||||
err := ioutil.WriteFile("sysgo/.lang", d, 0644)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
self.Screen.MsgBox.SetText("Applying")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
UI.MyLangManager.UpdateLang()
|
||||
|
||||
event.Post(UI.RESTARTUI, "")
|
||||
|
||||
time.BlockDelay(1000)
|
||||
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
}
|
||||
|
||||
func (self *LanguagesPage) OnLoadCb() {
|
||||
|
||||
self.PosY = 0
|
||||
self.DrawOnce = false
|
||||
|
||||
fname :="sysgo/.lang"
|
||||
thelang := ""
|
||||
|
||||
if UI.FileExists(fname) {
|
||||
config_bytes,err := ioutil.ReadFile(fname)
|
||||
if err == nil {
|
||||
thelang = strings.Trim(string(config_bytes),"\r\n ")
|
||||
if len(thelang) < 3 {
|
||||
thelang = "English"
|
||||
}
|
||||
}
|
||||
|
||||
for i, v := range self.MyList {
|
||||
if strings.Contains( v.(*PageListItem).Value, thelang) {
|
||||
self.MyList[i].(*PageListItem).Active = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.PosY = 0
|
||||
self.DrawOnce = false
|
||||
|
||||
fname := "sysgo/.lang"
|
||||
thelang := ""
|
||||
|
||||
if UI.FileExists(fname) {
|
||||
config_bytes, err := ioutil.ReadFile(fname)
|
||||
if err == nil {
|
||||
thelang = strings.Trim(string(config_bytes), "\r\n ")
|
||||
if len(thelang) < 3 {
|
||||
thelang = "English"
|
||||
}
|
||||
}
|
||||
|
||||
for i, v := range self.MyList {
|
||||
if strings.Contains(v.(*PageListItem).Value, thelang) {
|
||||
self.MyList[i].(*PageListItem).Active = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *LanguagesPage) KeyDown(ev *event.Event ) {
|
||||
|
||||
func (self *LanguagesPage) KeyDown(ev *event.Event) {
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
self.Click()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Up"] {
|
||||
|
||||
self.ScrollUp()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Down"] {
|
||||
|
||||
self.ScrollDown()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
self.Click()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Up"] {
|
||||
|
||||
self.ScrollUp()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Down"] {
|
||||
|
||||
self.ScrollDown()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *LanguagesPage) Draw() {
|
||||
|
||||
self.ClearCanvas()
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if len(self.MyList) * UI.DefaultInfoPageListItemHeight > self.Height {
|
||||
|
||||
self.Ps.(*ListPageSelector).Width = self.Width - 11
|
||||
self.Ps.Draw()
|
||||
|
||||
for _,v := range self.MyList {
|
||||
if v.(*PageListItem).PosY > self.Height + self.Height/2 {
|
||||
break
|
||||
}
|
||||
|
||||
if v.(*PageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
|
||||
}
|
||||
|
||||
self.Scroller.UpdateSize( len(self.MyList)*UI.DefaultInfoPageListItemHeight,
|
||||
self.PsIndex*UI.DefaultInfoPageListItemHeight)
|
||||
self.Scroller.Draw()
|
||||
|
||||
}else {
|
||||
self.Ps.(*ListPageSelector).Width = self.Width
|
||||
self.Ps.Draw()
|
||||
for _,v := range self.MyList {
|
||||
if v.(*PageListItem).PosY > self.Height + self.Height/2 {
|
||||
break
|
||||
}
|
||||
|
||||
if v.(*PageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if self.HWND != nil {
|
||||
surface.Fill(self.HWND, &color.Color{255,255,255,255})
|
||||
rect_ := rect.Rect(self.PosX,self.PosY,self.Width,self.Height)
|
||||
surface.Blit(self.HWND,self.CanvasHWND,&rect_,nil)
|
||||
}
|
||||
}
|
||||
|
||||
self.ClearCanvas()
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if len(self.MyList)*UI.DefaultInfoPageListItemHeight > self.Height {
|
||||
|
||||
self.Ps.(*ListPageSelector).Width = self.Width - 11
|
||||
self.Ps.Draw()
|
||||
|
||||
for _, v := range self.MyList {
|
||||
if v.(*PageListItem).PosY > self.Height+self.Height/2 {
|
||||
break
|
||||
}
|
||||
|
||||
if v.(*PageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
|
||||
}
|
||||
|
||||
self.Scroller.UpdateSize(len(self.MyList)*UI.DefaultInfoPageListItemHeight,
|
||||
self.PsIndex*UI.DefaultInfoPageListItemHeight)
|
||||
self.Scroller.Draw()
|
||||
|
||||
} else {
|
||||
self.Ps.(*ListPageSelector).Width = self.Width
|
||||
self.Ps.Draw()
|
||||
for _, v := range self.MyList {
|
||||
if v.(*PageListItem).PosY > self.Height+self.Height/2 {
|
||||
break
|
||||
}
|
||||
|
||||
if v.(*PageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if self.HWND != nil {
|
||||
surface.Fill(self.HWND, &color.Color{255, 255, 255, 255})
|
||||
rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
|
||||
surface.Blit(self.HWND, self.CanvasHWND, &rect_, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package Languages
|
||||
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||
)
|
||||
@@ -16,21 +16,20 @@ import (
|
||||
/******************************************************************************/
|
||||
type LanguagesPlugin struct {
|
||||
UI.Plugin
|
||||
LanguagesPage *LanguagesPage
|
||||
LanguagesPage *LanguagesPage
|
||||
}
|
||||
|
||||
|
||||
func (self *LanguagesPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *LanguagesPlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.LanguagesPage = NewLanguagesPage()
|
||||
self.LanguagesPage.SetScreen( main_screen)
|
||||
self.LanguagesPage.SetScreen(main_screen)
|
||||
self.LanguagesPage.SetName("Languages")
|
||||
self.LanguagesPage.Init()
|
||||
self.LanguagesPage.Init()
|
||||
}
|
||||
|
||||
func (self *LanguagesPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *LanguagesPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.LanguagesPage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.LanguagesPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
package LauncherPy
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"github.com/cuu/gogame/time"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/cuu/gogame/time"
|
||||
"log"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
)
|
||||
|
||||
/******************************************************************************/
|
||||
type LauncherPyPlugin struct {
|
||||
UI.Plugin
|
||||
}
|
||||
|
||||
func (self *LauncherPyPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *LauncherPyPlugin) Init(main_screen *UI.MainScreen) {
|
||||
|
||||
}
|
||||
|
||||
func (self *LauncherPyPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *LauncherPyPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.MsgBox.SetText("Rebooting to Launcher")
|
||||
main_screen.MsgBox.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
time.BlockDelay(550)
|
||||
usr, _ := user.Current()
|
||||
dir := usr.HomeDir
|
||||
if usr.Username == "root" {
|
||||
dir = "/home/cpi"
|
||||
}
|
||||
main_screen.MsgBox.SetText("Rebooting to Launcher")
|
||||
main_screen.MsgBox.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
time.BlockDelay(550)
|
||||
usr, _ := user.Current()
|
||||
dir := usr.HomeDir
|
||||
if usr.Username == "root" {
|
||||
dir = "/home/cpi"
|
||||
}
|
||||
|
||||
cmd := exec.Command("sed","-i","s/launchergo/launcher/g",dir+"/.bashrc")
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
log.Println("sed failed", err)
|
||||
}else {
|
||||
|
||||
cmd = exec.Command("sudo","reboot")
|
||||
cmd.Run()
|
||||
}
|
||||
cmd := exec.Command("sed", "-i", "s/launchergo/launcher/g", dir+"/.bashrc")
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
log.Println("sed failed", err)
|
||||
} else {
|
||||
|
||||
cmd = exec.Command("sudo", "reboot")
|
||||
cmd.Run()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,368 +1,358 @@
|
||||
package Lima
|
||||
|
||||
import (
|
||||
//"fmt"
|
||||
//"io/ioutil"
|
||||
//"path/filepath"
|
||||
"strings"
|
||||
"runtime"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
//"fmt"
|
||||
//"io/ioutil"
|
||||
//"path/filepath"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/time"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
type ListPageSelector struct {
|
||||
UI.InfoPageSelector
|
||||
UI.InfoPageSelector
|
||||
}
|
||||
|
||||
func NewListPageSelector() *ListPageSelector {
|
||||
|
||||
p := &ListPageSelector{}
|
||||
|
||||
p.Width = UI.Width
|
||||
p.BackgroundColor = &color.Color{131,199,219,255} //SkinManager().GiveColor('Front')
|
||||
|
||||
return p
|
||||
|
||||
p := &ListPageSelector{}
|
||||
|
||||
p.Width = UI.Width
|
||||
p.BackgroundColor = &color.Color{131, 199, 219, 255} //SkinManager().GiveColor('Front')
|
||||
|
||||
return p
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (self *ListPageSelector) Draw() {
|
||||
|
||||
idx := self.Parent.GetPsIndex()
|
||||
mylist := self.Parent.GetMyList()
|
||||
|
||||
if idx < len(mylist) {
|
||||
x,y := mylist[idx].Coord()
|
||||
_,h := mylist[idx].Size()
|
||||
|
||||
self.PosX = x+2
|
||||
self.PosY = y+1
|
||||
self.Height = h-3
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
rect_ := rect.Rect(self.PosX,self.PosY,self.Width-4, self.Height)
|
||||
|
||||
draw.AARoundRect(canvas_,&rect_,self.BackgroundColor,4,0,self.BackgroundColor)
|
||||
}
|
||||
|
||||
idx := self.Parent.GetPsIndex()
|
||||
mylist := self.Parent.GetMyList()
|
||||
|
||||
if idx < len(mylist) {
|
||||
x, y := mylist[idx].Coord()
|
||||
_, h := mylist[idx].Size()
|
||||
|
||||
self.PosX = x + 2
|
||||
self.PosY = y + 1
|
||||
self.Height = h - 3
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
rect_ := rect.Rect(self.PosX, self.PosY, self.Width-4, self.Height)
|
||||
|
||||
draw.AARoundRect(canvas_, &rect_, self.BackgroundColor, 4, 0, self.BackgroundColor)
|
||||
}
|
||||
}
|
||||
|
||||
type PageListItem struct {
|
||||
UI.InfoPageListItem
|
||||
|
||||
Active bool
|
||||
Value string
|
||||
}
|
||||
UI.InfoPageListItem
|
||||
|
||||
Active bool
|
||||
Value string
|
||||
}
|
||||
|
||||
func NewPageListItem() *PageListItem {
|
||||
|
||||
p := &PageListItem{}
|
||||
p.Height = UI.DefaultInfoPageListItemHeight
|
||||
p.ReadOnly = false
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
p.Icons = make( map[string]UI.IconItemInterface)
|
||||
p.Fonts = make(map[string]*ttf.Font)
|
||||
|
||||
return p
|
||||
p := &PageListItem{}
|
||||
p.Height = UI.DefaultInfoPageListItemHeight
|
||||
p.ReadOnly = false
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
p.Fonts = make(map[string]*ttf.Font)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
|
||||
func (self *PageListItem) Draw() {
|
||||
|
||||
x,_ := self.Labels["Text"].Coord()
|
||||
w,h := self.Labels["Text"].Size()
|
||||
|
||||
self.Labels["Text"].NewCoord( x, self.PosY + (self.Height - h)/2 )
|
||||
|
||||
|
||||
if self.Active == true {
|
||||
self.Parent.(*GPUDriverPage).Icons["done"].NewCoord(self.Parent.(*GPUDriverPage).Width-30,self.PosY+5)
|
||||
self.Parent.(*GPUDriverPage).Icons["done"].Draw()
|
||||
}
|
||||
|
||||
self.Labels["Text"].SetBold(self.Active)
|
||||
self.Labels["Text"].Draw()
|
||||
|
||||
|
||||
|
||||
if _, ok := self.Labels["Small"]; ok {
|
||||
x,_ = self.Labels["Small"].Coord()
|
||||
w,h = self.Labels["Small"].Size()
|
||||
|
||||
self.Labels["Small"].NewCoord( self.Width - w - 10 , self.PosY + (self.Height - h)/2 )
|
||||
self.Labels["Small"].Draw()
|
||||
|
||||
}
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
draw.Line(canvas_, &color.Color{169,169,169,255},
|
||||
self.PosX, self.PosY+self.Height -1,
|
||||
self.PosX + self.Width, self.PosY+self.Height -1 ,1)
|
||||
|
||||
|
||||
x, _ := self.Labels["Text"].Coord()
|
||||
w, h := self.Labels["Text"].Size()
|
||||
|
||||
self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2)
|
||||
|
||||
if self.Active == true {
|
||||
self.Parent.(*GPUDriverPage).Icons["done"].NewCoord(self.Parent.(*GPUDriverPage).Width-30, self.PosY+5)
|
||||
self.Parent.(*GPUDriverPage).Icons["done"].Draw()
|
||||
}
|
||||
|
||||
self.Labels["Text"].SetBold(self.Active)
|
||||
self.Labels["Text"].Draw()
|
||||
|
||||
if _, ok := self.Labels["Small"]; ok {
|
||||
x, _ = self.Labels["Small"].Coord()
|
||||
w, h = self.Labels["Small"].Size()
|
||||
|
||||
self.Labels["Small"].NewCoord(self.Width-w-10, self.PosY+(self.Height-h)/2)
|
||||
self.Labels["Small"].Draw()
|
||||
|
||||
}
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
draw.Line(canvas_, &color.Color{169, 169, 169, 255},
|
||||
self.PosX, self.PosY+self.Height-1,
|
||||
self.PosX+self.Width, self.PosY+self.Height-1, 1)
|
||||
|
||||
}
|
||||
|
||||
type GPUDriverPage struct {
|
||||
UI.Page
|
||||
|
||||
ListFont *ttf.Font
|
||||
|
||||
BGwidth int
|
||||
BGheight int
|
||||
|
||||
DrawOnce bool
|
||||
|
||||
Scroller *UI.ListScroller
|
||||
UI.Page
|
||||
|
||||
Icons map[string]UI.IconItemInterface
|
||||
ListFont *ttf.Font
|
||||
|
||||
BGwidth int
|
||||
BGheight int
|
||||
|
||||
DrawOnce bool
|
||||
|
||||
Scroller *UI.ListScroller
|
||||
|
||||
Icons map[string]UI.IconItemInterface
|
||||
}
|
||||
|
||||
|
||||
func NewGPUDriverPage() *GPUDriverPage {
|
||||
p := &GPUDriverPage{}
|
||||
|
||||
p.ListFont = UI.Fonts["notosanscjk12"]
|
||||
p.FootMsg = [5]string{"Nav","","","Back","Select"}
|
||||
|
||||
p.BGwidth = UI.Width
|
||||
p.BGheight = UI.Height - 24 - 20
|
||||
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
|
||||
return p
|
||||
p := &GPUDriverPage{}
|
||||
|
||||
p.ListFont = UI.Fonts["notosanscjk12"]
|
||||
p.FootMsg = [5]string{"Nav", "", "", "Back", "Select"}
|
||||
|
||||
p.BGwidth = UI.Width
|
||||
p.BGheight = UI.Height - 24 - 20
|
||||
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *GPUDriverPage) GenList() {
|
||||
|
||||
self.MyList = nil
|
||||
|
||||
start_x := 0
|
||||
start_y := 0
|
||||
last_height := 0
|
||||
|
||||
var drivers = [][2]string{[2]string{"fbturbo","FBTURBO driver (Software Rendering)"},
|
||||
[2]string{"modesetting","LIMA driver (Experimental Hardware Rendering)"}}
|
||||
|
||||
self.MyList = nil
|
||||
|
||||
for _,u := range drivers {
|
||||
li := NewPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + last_height
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFont
|
||||
li.Active = false
|
||||
li.Value = u[0]
|
||||
li.Init(u[1])
|
||||
last_height += li.Height
|
||||
self.MyList = append(self.MyList,li)
|
||||
}
|
||||
start_x := 0
|
||||
start_y := 0
|
||||
last_height := 0
|
||||
|
||||
var drivers = [][2]string{[2]string{"fbturbo", "FBTURBO driver (Software Rendering)"},
|
||||
[2]string{"modesetting", "LIMA driver (Experimental Hardware Rendering)"}}
|
||||
|
||||
for _, u := range drivers {
|
||||
li := NewPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + last_height
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFont
|
||||
li.Active = false
|
||||
li.Value = u[0]
|
||||
li.Init(u[1])
|
||||
last_height += li.Height
|
||||
self.MyList = append(self.MyList, li)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *GPUDriverPage) Init() {
|
||||
|
||||
if self.Screen != nil {
|
||||
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||
self.HWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = surface.Surface( self.Screen.Width,self.Screen.Height )
|
||||
}
|
||||
}
|
||||
|
||||
self.PosX = self.Index*self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
done := UI.NewIconItem()
|
||||
done.ImgSurf = UI.MyIconPool.GetImgSurf("done")
|
||||
done.MyType = UI.ICON_TYPES["STAT"]
|
||||
done.Parent = self
|
||||
|
||||
self.Icons["done"] = done
|
||||
|
||||
ps := NewListPageSelector()
|
||||
ps.Parent = self
|
||||
|
||||
self.Ps = ps
|
||||
self.PsIndex = 0
|
||||
|
||||
self.GenList()
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
self.Scroller.SetCanvasHWND(self.HWND)
|
||||
|
||||
if self.Screen != nil {
|
||||
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||
self.HWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = surface.Surface(self.Screen.Width, self.Screen.Height)
|
||||
}
|
||||
}
|
||||
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
done := UI.NewIconItem()
|
||||
done.ImgSurf = UI.MyIconPool.GetImgSurf("done")
|
||||
done.MyType = UI.ICON_TYPES["STAT"]
|
||||
done.Parent = self
|
||||
|
||||
self.Icons["done"] = done
|
||||
|
||||
ps := NewListPageSelector()
|
||||
ps.Parent = self
|
||||
|
||||
self.Ps = ps
|
||||
self.PsIndex = 0
|
||||
|
||||
self.GenList()
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
self.Scroller.SetCanvasHWND(self.HWND)
|
||||
|
||||
}
|
||||
|
||||
func (self *GPUDriverPage) Click() {
|
||||
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if self.PsIndex >= len(self.MyList) {
|
||||
self.PsIndex = len(self.MyList) -1
|
||||
}
|
||||
|
||||
cur_li := self.MyList[self.PsIndex].(*PageListItem)
|
||||
if cur_li.Active == true {
|
||||
return
|
||||
}
|
||||
|
||||
if strings.Contains(runtime.GOARCH,"arm") == true {
|
||||
for i,_ := range self.MyList {
|
||||
self.MyList[i].(*PageListItem).Active = false
|
||||
}
|
||||
cur_li.Active = true
|
||||
self.Screen.MsgBox.SetText("Applying")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
if strings.Contains(cur_li.Value,"modesetting") {
|
||||
lockfile,_ := homedir.Expand("~/.lima")
|
||||
UI.System("touch "+lockfile)
|
||||
UI.ArmSystem("sudo mv /usr/lib/xorg/modules/drivers/modesetting_drv.so.lima /usr/lib/xorg/modules/drivers/modesetting_drv.so")
|
||||
UI.ArmSystem("sudo sed -i '/^#.*lima/s/^#//' /etc/ld.so.conf.d/00-arm-linux-gnueabihf.conf")
|
||||
UI.ArmSystem("sudo ldconfig")
|
||||
|
||||
}else {
|
||||
lockfile,_ := homedir.Expand("~/.lima")
|
||||
UI.System("rm "+lockfile)
|
||||
UI.ArmSystem("sudo mv /usr/lib/xorg/modules/drivers/modesetting_drv.so /usr/lib/xorg/modules/drivers/modesetting_drv.so.lima")
|
||||
UI.ArmSystem("sudo sed -i 's/^[^#]*lima/#&/' /etc/ld.so.conf.d/00-arm-linux-gnueabihf.conf")
|
||||
UI.ArmSystem("sudo ldconfig")
|
||||
|
||||
}
|
||||
|
||||
time.BlockDelay(1000)
|
||||
UI.System("sudo reboot")
|
||||
|
||||
}else {
|
||||
self.Screen.MsgBox.SetText("Do it in GameShell")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if self.PsIndex >= len(self.MyList) {
|
||||
self.PsIndex = len(self.MyList) - 1
|
||||
}
|
||||
|
||||
cur_li := self.MyList[self.PsIndex].(*PageListItem)
|
||||
if cur_li.Active == true {
|
||||
return
|
||||
}
|
||||
|
||||
if strings.Contains(runtime.GOARCH, "arm") == true {
|
||||
for i, _ := range self.MyList {
|
||||
self.MyList[i].(*PageListItem).Active = false
|
||||
}
|
||||
cur_li.Active = true
|
||||
self.Screen.MsgBox.SetText("Applying")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
if strings.Contains(cur_li.Value, "modesetting") {
|
||||
lockfile, _ := homedir.Expand("~/.lima")
|
||||
UI.System("touch " + lockfile)
|
||||
UI.ArmSystem("sudo mv /usr/lib/xorg/modules/drivers/modesetting_drv.so.lima /usr/lib/xorg/modules/drivers/modesetting_drv.so")
|
||||
UI.ArmSystem("sudo sed -i '/^#.*lima/s/^#//' /etc/ld.so.conf.d/00-arm-linux-gnueabihf.conf")
|
||||
UI.ArmSystem("sudo ldconfig")
|
||||
|
||||
} else {
|
||||
lockfile, _ := homedir.Expand("~/.lima")
|
||||
UI.System("rm " + lockfile)
|
||||
UI.ArmSystem("sudo mv /usr/lib/xorg/modules/drivers/modesetting_drv.so /usr/lib/xorg/modules/drivers/modesetting_drv.so.lima")
|
||||
UI.ArmSystem("sudo sed -i 's/^[^#]*lima/#&/' /etc/ld.so.conf.d/00-arm-linux-gnueabihf.conf")
|
||||
UI.ArmSystem("sudo ldconfig")
|
||||
|
||||
}
|
||||
|
||||
time.BlockDelay(1000)
|
||||
UI.System("sudo reboot")
|
||||
|
||||
} else {
|
||||
self.Screen.MsgBox.SetText("Do it in GameShell")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *GPUDriverPage) OnLoadCb() {
|
||||
|
||||
self.PosY = 0
|
||||
self.DrawOnce = false
|
||||
|
||||
thedrv := ""
|
||||
if strings.Contains(runtime.GOARCH,"arm") == true {
|
||||
lockfile,_ := homedir.Expand("~/.lima")
|
||||
if UI.FileExists(lockfile) {
|
||||
thedrv = "modesetting"
|
||||
}else {
|
||||
thedrv = "fbturbo"
|
||||
}
|
||||
}
|
||||
|
||||
if thedrv == "" {
|
||||
thedrv = "fbturbo"
|
||||
}
|
||||
|
||||
for i, v := range self.MyList {
|
||||
if strings.Contains( v.(*PageListItem).Value, thedrv) {
|
||||
self.MyList[i].(*PageListItem).Active = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
self.PosY = 0
|
||||
self.DrawOnce = false
|
||||
|
||||
thedrv := ""
|
||||
if strings.Contains(runtime.GOARCH, "arm") == true {
|
||||
lockfile, _ := homedir.Expand("~/.lima")
|
||||
if UI.FileExists(lockfile) {
|
||||
thedrv = "modesetting"
|
||||
} else {
|
||||
thedrv = "fbturbo"
|
||||
}
|
||||
}
|
||||
|
||||
if thedrv == "" {
|
||||
thedrv = "fbturbo"
|
||||
}
|
||||
|
||||
for i, v := range self.MyList {
|
||||
if strings.Contains(v.(*PageListItem).Value, thedrv) {
|
||||
self.MyList[i].(*PageListItem).Active = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *GPUDriverPage) KeyDown(ev *event.Event ) {
|
||||
|
||||
func (self *GPUDriverPage) KeyDown(ev *event.Event) {
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
self.Click()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Up"] {
|
||||
|
||||
self.ScrollUp()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Down"] {
|
||||
|
||||
self.ScrollDown()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
self.Click()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Up"] {
|
||||
|
||||
self.ScrollUp()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Down"] {
|
||||
|
||||
self.ScrollDown()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *GPUDriverPage) Draw() {
|
||||
|
||||
self.ClearCanvas()
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if len(self.MyList) * UI.DefaultInfoPageListItemHeight > self.Height {
|
||||
|
||||
self.Ps.(*ListPageSelector).Width = self.Width - 11
|
||||
self.Ps.Draw()
|
||||
|
||||
for _,v := range self.MyList {
|
||||
if v.(*PageListItem).PosY > self.Height + self.Height/2 {
|
||||
break
|
||||
}
|
||||
|
||||
if v.(*PageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
|
||||
}
|
||||
|
||||
self.Scroller.UpdateSize( len(self.MyList)*UI.DefaultInfoPageListItemHeight,
|
||||
self.PsIndex*UI.DefaultInfoPageListItemHeight)
|
||||
self.Scroller.Draw()
|
||||
|
||||
}else {
|
||||
self.Ps.(*ListPageSelector).Width = self.Width
|
||||
self.Ps.Draw()
|
||||
for _,v := range self.MyList {
|
||||
if v.(*PageListItem).PosY > self.Height + self.Height/2 {
|
||||
break
|
||||
}
|
||||
|
||||
if v.(*PageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if self.HWND != nil {
|
||||
surface.Fill(self.HWND, UI.MySkinManager.GiveColor("White"))
|
||||
rect_ := rect.Rect(self.PosX,self.PosY,self.Width,self.Height)
|
||||
surface.Blit(self.HWND,self.CanvasHWND,&rect_,nil)
|
||||
}
|
||||
}
|
||||
|
||||
self.ClearCanvas()
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if len(self.MyList)*UI.DefaultInfoPageListItemHeight > self.Height {
|
||||
|
||||
self.Ps.(*ListPageSelector).Width = self.Width - 11
|
||||
self.Ps.Draw()
|
||||
|
||||
for _, v := range self.MyList {
|
||||
if v.(*PageListItem).PosY > self.Height+self.Height/2 {
|
||||
break
|
||||
}
|
||||
|
||||
if v.(*PageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
|
||||
}
|
||||
|
||||
self.Scroller.UpdateSize(len(self.MyList)*UI.DefaultInfoPageListItemHeight,
|
||||
self.PsIndex*UI.DefaultInfoPageListItemHeight)
|
||||
self.Scroller.Draw()
|
||||
|
||||
} else {
|
||||
self.Ps.(*ListPageSelector).Width = self.Width
|
||||
self.Ps.Draw()
|
||||
for _, v := range self.MyList {
|
||||
if v.(*PageListItem).PosY > self.Height+self.Height/2 {
|
||||
break
|
||||
}
|
||||
|
||||
if v.(*PageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if self.HWND != nil {
|
||||
surface.Fill(self.HWND, UI.MySkinManager.GiveColor("White"))
|
||||
rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
|
||||
surface.Blit(self.HWND, self.CanvasHWND, &rect_, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package Lima
|
||||
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||
)
|
||||
@@ -16,21 +16,20 @@ import (
|
||||
/******************************************************************************/
|
||||
type LimaPlugin struct {
|
||||
UI.Plugin
|
||||
GPUDriverPage *GPUDriverPage
|
||||
GPUDriverPage *GPUDriverPage
|
||||
}
|
||||
|
||||
|
||||
func (self *LimaPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *LimaPlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.GPUDriverPage = NewGPUDriverPage()
|
||||
self.GPUDriverPage.SetScreen( main_screen)
|
||||
self.GPUDriverPage.SetScreen(main_screen)
|
||||
self.GPUDriverPage.SetName("GPU Driver Switch")
|
||||
self.GPUDriverPage.Init()
|
||||
self.GPUDriverPage.Init()
|
||||
}
|
||||
|
||||
func (self *LimaPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *LimaPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.GPUDriverPage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.GPUDriverPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package PowerOFF
|
||||
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||
)
|
||||
@@ -16,21 +16,20 @@ import (
|
||||
/******************************************************************************/
|
||||
type PowerOFFPlugin struct {
|
||||
UI.Plugin
|
||||
PowerOFFPage *PowerOFFConfirmPage
|
||||
PowerOFFPage *PowerOFFConfirmPage
|
||||
}
|
||||
|
||||
|
||||
func (self *PowerOFFPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *PowerOFFPlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.PowerOFFPage = NewPowerOFFConfirmPage()
|
||||
self.PowerOFFPage.SetScreen( main_screen)
|
||||
self.PowerOFFPage.SetScreen(main_screen)
|
||||
self.PowerOFFPage.SetName("PowerOFF")
|
||||
self.PowerOFFPage.Init()
|
||||
self.PowerOFFPage.Init()
|
||||
}
|
||||
|
||||
func (self *PowerOFFPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *PowerOFFPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.PowerOFFPage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.PowerOFFPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
@@ -1,64 +1,61 @@
|
||||
package PowerOFF
|
||||
|
||||
import (
|
||||
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/cuu/gogame/event"
|
||||
)
|
||||
|
||||
type PowerOFFConfirmPage struct {
|
||||
UI.ConfirmPage
|
||||
|
||||
UI.ConfirmPage
|
||||
}
|
||||
|
||||
func NewPowerOFFConfirmPage() *PowerOFFConfirmPage {
|
||||
|
||||
p := &PowerOFFConfirmPage{}
|
||||
p.ListFont = UI.Fonts["veramono20"]
|
||||
p.ConfirmText = "Awaiting Input"
|
||||
p.FootMsg = [5]string{ "Nav","Reboot","","Cancel","Shutdown" }
|
||||
|
||||
p.ConfirmPage.ConfirmText = p.ConfirmText
|
||||
p.ConfirmPage.FootMsg = p.FootMsg
|
||||
p.ConfirmPage.ListFont = p.ListFont
|
||||
|
||||
return p
|
||||
|
||||
p := &PowerOFFConfirmPage{}
|
||||
p.ListFont = UI.Fonts["veramono20"]
|
||||
p.ConfirmText = "Awaiting Input"
|
||||
p.FootMsg = [5]string{"Nav", "Reboot", "", "Cancel", "Shutdown"}
|
||||
|
||||
p.ConfirmPage.ConfirmText = p.ConfirmText
|
||||
p.ConfirmPage.FootMsg = p.FootMsg
|
||||
p.ConfirmPage.ListFont = p.ListFont
|
||||
|
||||
return p
|
||||
|
||||
}
|
||||
|
||||
func (self *PowerOFFConfirmPage) KeyDown(ev *event.Event) {
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Menu"] || ev.Data["Key"] == UI.CurKeys["A"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
cmdpath := ""
|
||||
|
||||
if UI.CheckBattery() < 20 {
|
||||
cmdpath = "feh --bg-center sysgo/gameshell/wallpaper/gameover.png;"
|
||||
}else {
|
||||
cmdpath = "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
|
||||
}
|
||||
|
||||
cmdpath = cmdpath + "sleep 3;"
|
||||
|
||||
cmdpath = cmdpath + "sudo halt -p"
|
||||
|
||||
event.Post(UI.RUNSYS,cmdpath)
|
||||
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["X"] {
|
||||
cmdpath := "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
|
||||
cmdpath += "sleep 3;"
|
||||
cmdpath += "sudo reboot"
|
||||
|
||||
event.Post(UI.RUNSYS,cmdpath)
|
||||
}
|
||||
if ev.Data["Key"] == UI.CurKeys["Menu"] || ev.Data["Key"] == UI.CurKeys["A"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
cmdpath := ""
|
||||
|
||||
if UI.CheckBattery() < 20 {
|
||||
cmdpath = "feh --bg-center sysgo/gameshell/wallpaper/gameover.png;"
|
||||
} else {
|
||||
cmdpath = "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
|
||||
}
|
||||
|
||||
cmdpath = cmdpath + "sleep 3;"
|
||||
|
||||
cmdpath = cmdpath + "sudo halt -p"
|
||||
|
||||
event.Post(UI.RUNSYS, cmdpath)
|
||||
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["X"] {
|
||||
cmdpath := "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
|
||||
cmdpath += "sleep 3;"
|
||||
cmdpath += "sudo reboot"
|
||||
|
||||
event.Post(UI.RUNSYS, cmdpath)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package PowerOptions
|
||||
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||
)
|
||||
@@ -16,21 +16,20 @@ import (
|
||||
/******************************************************************************/
|
||||
type PowerOptionsPlugin struct {
|
||||
UI.Plugin
|
||||
PowerOptionsPage *PowerOptionsPage
|
||||
PowerOptionsPage *PowerOptionsPage
|
||||
}
|
||||
|
||||
|
||||
func (self *PowerOptionsPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *PowerOptionsPlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.PowerOptionsPage = NewPowerOptionsPage()
|
||||
self.PowerOptionsPage.SetScreen( main_screen)
|
||||
self.PowerOptionsPage.SetScreen(main_screen)
|
||||
self.PowerOptionsPage.SetName("PowerOptions")
|
||||
self.PowerOptionsPage.Init()
|
||||
self.PowerOptionsPage.Init()
|
||||
}
|
||||
|
||||
func (self *PowerOptionsPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *PowerOptionsPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.PowerOptionsPage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.PowerOptionsPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,71 +3,67 @@ package Settings
|
||||
import (
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"path/filepath"
|
||||
// "github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"path/filepath"
|
||||
// "github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
//child packages
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/About"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Sound"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Brightness"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Wifi"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Bluetooth"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Update"
|
||||
|
||||
//child packages
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/About"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Bluetooth"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Brightness"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Sound"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Wifi"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Languages"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Storage"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Languages"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/PowerOFF"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/PowerOptions"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Airplane"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/ButtonsLayout"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/TimeZone"
|
||||
//"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Lima"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/GateWay"
|
||||
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Update"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Airplane"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/ButtonsLayout"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/PowerOFF"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/PowerOptions"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/TimeZone"
|
||||
//"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Lima"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/GateWay"
|
||||
)
|
||||
|
||||
type SettingsPageSelector struct {
|
||||
UI.PageSelector
|
||||
BackgroundColor *color.Color
|
||||
|
||||
}
|
||||
|
||||
func NewSettingsPageSelector() *SettingsPageSelector{
|
||||
func NewSettingsPageSelector() *SettingsPageSelector {
|
||||
s := &SettingsPageSelector{}
|
||||
s.BackgroundColor = &color.Color{131,199,219,255}
|
||||
s.BackgroundColor = &color.Color{131, 199, 219, 255}
|
||||
|
||||
s.Width = UI.Width
|
||||
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func (self *SettingsPageSelector) Draw() {
|
||||
idx := self.Parent.GetPsIndex()
|
||||
mylist := self.Parent.GetMyList()
|
||||
if idx < len( mylist) {
|
||||
_,y_ := mylist[idx].Coord()
|
||||
_,h_ := mylist[idx].Size()
|
||||
|
||||
if idx < len(mylist) {
|
||||
_, y_ := mylist[idx].Coord()
|
||||
_, h_ := mylist[idx].Size()
|
||||
|
||||
x := 2
|
||||
y := y_+1
|
||||
h := h_-3
|
||||
y := y_ + 1
|
||||
h := h_ - 3
|
||||
self.PosX = x
|
||||
self.PosY = y
|
||||
self.Height = h
|
||||
|
||||
rect_ := rect.Rect(x,y,self.Width-4,h)
|
||||
rect_ := rect.Rect(x, y, self.Width-4, h)
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
draw.AARoundRect(canvas_, &rect_,self.BackgroundColor,4,0,self.BackgroundColor)
|
||||
|
||||
draw.AARoundRect(canvas_, &rect_, self.BackgroundColor, 4, 0, self.BackgroundColor)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,109 +71,106 @@ func (self *SettingsPageSelector) Draw() {
|
||||
|
||||
type SettingsPage struct {
|
||||
UI.Page
|
||||
AList map[string]map[string]string
|
||||
ListFontObj *ttf.Font
|
||||
Scrolled int
|
||||
BGwidth int
|
||||
BGheight int
|
||||
DrawOnce bool
|
||||
Scroller *UI.ListScroller
|
||||
Icons map[string]UI.IconItemInterface
|
||||
AList map[string]map[string]string
|
||||
ListFontObj *ttf.Font
|
||||
Scrolled int
|
||||
BGwidth int
|
||||
BGheight int
|
||||
DrawOnce bool
|
||||
Scroller *UI.ListScroller
|
||||
Icons map[string]UI.IconItemInterface
|
||||
|
||||
MyPath string
|
||||
|
||||
}
|
||||
|
||||
func NewSettingsPage() *SettingsPage {
|
||||
p := &SettingsPage{}
|
||||
p.FootMsg = [5]string{"Nav","","","Back","Enter"}
|
||||
p.FootMsg = [5]string{"Nav", "", "", "Back", "Enter"}
|
||||
p.ListFontObj = UI.Fonts["varela15"]
|
||||
|
||||
p.MyPath = "Menu/GameShell/10_Settings"
|
||||
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *SettingsPage) GenList() []*UI.UIPlugin {
|
||||
alist := []*UI.UIPlugin{
|
||||
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "Airplane", "Airplane Mode", &Airplane.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "PowerOptions", "Power Options", &PowerOptions.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "Wifi", "Wi-Fi", &Wifi.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "Bluetooth", "Bluetooth", &Bluetooth.APIOBJ},
|
||||
alist := []*UI.UIPlugin{
|
||||
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "Sound", "Sound Volume" , &Sound.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "Brightness", "BackLight Brightness", &Brightness.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "Storage", "", &Storage.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "TimeZone", "Timezone", &TimeZone.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "Airplane", "Airplane Mode", &Airplane.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "PowerOptions", "Power Options", &PowerOptions.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "Wifi", "Wi-Fi", &Wifi.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "Bluetooth", "Bluetooth", &Bluetooth.APIOBJ},
|
||||
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "Languages", "Languages", &Languages.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "Update", "Update LauncherGo", &Update.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "About", "About", &About.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "PowerOFF", "Power off", &PowerOFF.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "ButtonsLayout", "Buttons Layout", &ButtonsLayout.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "Sound", "Sound Volume", &Sound.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "Brightness", "BackLight Brightness", &Brightness.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "Storage", "", &Storage.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "TimeZone", "Timezone", &TimeZone.APIOBJ},
|
||||
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "Languages", "Languages", &Languages.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "Update", "Update LauncherGo", &Update.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "About", "About", &About.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "PowerOFF", "Power off", &PowerOFF.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "ButtonsLayout", "Buttons Layout", &ButtonsLayout.APIOBJ},
|
||||
// &UI.UIPlugin{UI.PluginPackage,"", "LauncherPy", "Switch to Launcher", &LauncherPy.APIOBJ},
|
||||
//&UI.UIPlugin{UI.PluginPackage,"", "Lima", "GPU Driver Switch", &Lima.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "GateWay", "Network gateway switch", &GateWay.APIOBJ},
|
||||
}
|
||||
|
||||
return alist
|
||||
//&UI.UIPlugin{UI.PluginPackage,"", "Lima", "GPU Driver Switch", &Lima.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage, "", "GateWay", "Network gateway switch", &GateWay.APIOBJ},
|
||||
}
|
||||
|
||||
return alist
|
||||
}
|
||||
|
||||
func (self *SettingsPage) Init() {
|
||||
if self.Screen != nil {
|
||||
|
||||
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
|
||||
|
||||
ps := NewSettingsPageSelector()
|
||||
ps.Parent = self
|
||||
self.Ps = ps
|
||||
self.PsIndex = 0
|
||||
|
||||
|
||||
|
||||
start_x := 0
|
||||
start_y := 0
|
||||
|
||||
alist := self.GenList()
|
||||
|
||||
for i,v := range alist{
|
||||
|
||||
alist := self.GenList()
|
||||
|
||||
for i, v := range alist {
|
||||
li := UI.NewListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + i*li.Height
|
||||
li.Width = UI.Width
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + i*li.Height
|
||||
li.Width = UI.Width
|
||||
|
||||
li.Fonts["normal"] = self.ListFontObj
|
||||
|
||||
if v.LabelText != "" {
|
||||
li.Init(v.LabelText)
|
||||
}else{
|
||||
} else {
|
||||
li.Init(v.FolderName)
|
||||
}
|
||||
|
||||
if v.SoFile!= "" && UI.FileExists( filepath.Join(self.MyPath,v.FolderName,v.SoFile )) {
|
||||
pi,err := UI.LoadPlugin(filepath.Join(self.MyPath,v.FolderName,v.SoFile ))
|
||||
|
||||
if v.SoFile != "" && UI.FileExists(filepath.Join(self.MyPath, v.FolderName, v.SoFile)) {
|
||||
pi, err := UI.LoadPlugin(filepath.Join(self.MyPath, v.FolderName, v.SoFile))
|
||||
UI.Assert(err)
|
||||
li.LinkObj = UI.InitPlugin(pi,self.Screen)
|
||||
self.MyList = append(self.MyList,li)
|
||||
|
||||
}else {
|
||||
if v.EmbInterface != nil {
|
||||
v.EmbInterface.Init(self.Screen)
|
||||
li.LinkObj = v.EmbInterface
|
||||
self.MyList = append(self.MyList,li)
|
||||
}
|
||||
}
|
||||
li.LinkObj = UI.InitPlugin(pi, self.Screen)
|
||||
self.MyList = append(self.MyList, li)
|
||||
|
||||
} else {
|
||||
if v.EmbInterface != nil {
|
||||
v.EmbInterface.Init(self.Screen)
|
||||
li.LinkObj = v.EmbInterface
|
||||
self.MyList = append(self.MyList, li)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
|
||||
}
|
||||
@@ -185,55 +178,54 @@ func (self *SettingsPage) Init() {
|
||||
|
||||
func (self *SettingsPage) ScrollUp() {
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
self.PsIndex -= 1
|
||||
|
||||
if self.PsIndex < 0 {
|
||||
self.PsIndex = 0
|
||||
}
|
||||
cur_li := self.MyList[self.PsIndex]
|
||||
x,y := cur_li.Coord()
|
||||
if y < 0 {
|
||||
for i:=0;i<len(self.MyList);i++ {
|
||||
_,h := self.MyList[i].Size()
|
||||
x,y = self.MyList[i].Coord()
|
||||
self.MyList[i].NewCoord(x, y+h)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
self.PsIndex -= 1
|
||||
|
||||
if self.PsIndex < 0 {
|
||||
self.PsIndex = 0
|
||||
}
|
||||
cur_li := self.MyList[self.PsIndex]
|
||||
x, y := cur_li.Coord()
|
||||
if y < 0 {
|
||||
for i := 0; i < len(self.MyList); i++ {
|
||||
_, h := self.MyList[i].Size()
|
||||
x, y = self.MyList[i].Coord()
|
||||
self.MyList[i].NewCoord(x, y+h)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (self *SettingsPage) ScrollDown() {
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
self.PsIndex += 1
|
||||
if self.PsIndex >= len(self.MyList) {
|
||||
self.PsIndex = len(self.MyList) - 1
|
||||
}
|
||||
|
||||
cur_li := self.MyList[self.PsIndex]
|
||||
x,y := cur_li.Coord()
|
||||
_,h := cur_li.Size()
|
||||
|
||||
if y + h > self.Height {
|
||||
for i:=0;i<len(self.MyList);i++ {
|
||||
_,h = self.MyList[i].Size()
|
||||
x,y = self.MyList[i].Coord()
|
||||
self.MyList[i].NewCoord(x, y - h)
|
||||
}
|
||||
}
|
||||
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
self.PsIndex += 1
|
||||
if self.PsIndex >= len(self.MyList) {
|
||||
self.PsIndex = len(self.MyList) - 1
|
||||
}
|
||||
|
||||
cur_li := self.MyList[self.PsIndex]
|
||||
x, y := cur_li.Coord()
|
||||
_, h := cur_li.Size()
|
||||
|
||||
if y+h > self.Height {
|
||||
for i := 0; i < len(self.MyList); i++ {
|
||||
_, h = self.MyList[i].Size()
|
||||
x, y = self.MyList[i].Coord()
|
||||
self.MyList[i].NewCoord(x, y-h)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *SettingsPage) Click() {
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
cur_li := self.MyList[self.PsIndex]
|
||||
|
||||
lk_obj := cur_li.GetLinkObj()
|
||||
@@ -244,15 +236,14 @@ func (self *SettingsPage) Click() {
|
||||
|
||||
}
|
||||
|
||||
func (self *SettingsPage) KeyDown( ev *event.Event) {
|
||||
|
||||
func (self *SettingsPage) KeyDown(ev *event.Event) {
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Up"] {
|
||||
self.ScrollUp()
|
||||
self.Screen.Draw()
|
||||
@@ -270,55 +261,52 @@ func (self *SettingsPage) KeyDown( ev *event.Event) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (self *SettingsPage) Draw() {
|
||||
self.ClearCanvas()
|
||||
|
||||
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
_,h_ := self.MyList[0].Size()
|
||||
_, h_ := self.MyList[0].Size()
|
||||
|
||||
if len(self.MyList) * h_ > self.Height {
|
||||
_,ph_ := self.Ps.Size()
|
||||
self.Ps.NewSize(self.Width - 11, ph_)
|
||||
if len(self.MyList)*h_ > self.Height {
|
||||
_, ph_ := self.Ps.Size()
|
||||
self.Ps.NewSize(self.Width-11, ph_)
|
||||
self.Ps.Draw()
|
||||
|
||||
for _,v := range self.MyList {
|
||||
for _, v := range self.MyList {
|
||||
v.Draw()
|
||||
}
|
||||
|
||||
self.Scroller.UpdateSize(len(self.MyList)*h_,self.PsIndex*h_)
|
||||
self.Scroller.UpdateSize(len(self.MyList)*h_, self.PsIndex*h_)
|
||||
self.Scroller.Draw()
|
||||
|
||||
}else {
|
||||
_,ph_ := self.Ps.Size()
|
||||
self.Ps.NewSize(self.Width,ph_)
|
||||
|
||||
} else {
|
||||
_, ph_ := self.Ps.Size()
|
||||
self.Ps.NewSize(self.Width, ph_)
|
||||
self.Ps.Draw()
|
||||
for _,v := range self.MyList {
|
||||
for _, v := range self.MyList {
|
||||
v.Draw()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
type SettingsPlugin struct {
|
||||
UI.Plugin
|
||||
Page UI.PageInterface
|
||||
}
|
||||
|
||||
|
||||
func (self *SettingsPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *SettingsPlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.Page = NewSettingsPage()
|
||||
self.Page.SetScreen( main_screen)
|
||||
self.Page.SetScreen(main_screen)
|
||||
self.Page.SetName("Settings")
|
||||
self.Page.Init()
|
||||
}
|
||||
|
||||
func (self *SettingsPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *SettingsPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushPage(self.Page)
|
||||
main_screen.Draw()
|
||||
|
||||
@@ -5,14 +5,14 @@ package Sound
|
||||
* `sudo apt-get install alsa-utils`
|
||||
*/
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||
)
|
||||
@@ -20,21 +20,20 @@ import (
|
||||
/******************************************************************************/
|
||||
type SoundPlugin struct {
|
||||
UI.Plugin
|
||||
SoundPage *SoundPage
|
||||
SoundPage *SoundPage
|
||||
}
|
||||
|
||||
|
||||
func (self *SoundPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *SoundPlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.SoundPage = NewSoundPage()
|
||||
self.SoundPage.SetScreen( main_screen)
|
||||
self.SoundPage.SetScreen(main_screen)
|
||||
self.SoundPage.SetName("Sound Volume")
|
||||
self.SoundPage.Init()
|
||||
self.SoundPage.Init()
|
||||
}
|
||||
|
||||
func (self *SoundPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *SoundPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.SoundPage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.SoundPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
@@ -1,272 +1,268 @@
|
||||
package Sound
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
"github.com/cuu/gogame/event"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/rect"
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
type OnChangeCB_T func(int)
|
||||
|
||||
type SliderIcon struct {
|
||||
UI.IconItem
|
||||
Parent *SoundSlider
|
||||
|
||||
UI.IconItem
|
||||
Parent *SoundSlider
|
||||
}
|
||||
|
||||
func NewSliderIcon() *SliderIcon {
|
||||
p := &SliderIcon{}
|
||||
p := &SliderIcon{}
|
||||
p.MyType = UI.ICON_TYPES["EXE"]
|
||||
p.Align = UI.ALIGN["VCenter"]
|
||||
|
||||
return p
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *SliderIcon) Draw() {
|
||||
if self.Parent == nil {
|
||||
fmt.Println("Error: SliderIcon Draw Parent nil")
|
||||
return
|
||||
}
|
||||
parent_x,parent_y := self.Parent.Coord()
|
||||
|
||||
if self.Parent == nil {
|
||||
fmt.Println("Error: SliderIcon Draw Parent nil")
|
||||
return
|
||||
}
|
||||
parent_x, parent_y := self.Parent.Coord()
|
||||
|
||||
if self.Label != nil {
|
||||
// lab_x,lab_y := self.Label.Coord()
|
||||
lab_w,lab_h:= self.Label.Size()
|
||||
|
||||
// lab_x,lab_y := self.Label.Coord()
|
||||
lab_w, lab_h := self.Label.Size()
|
||||
|
||||
if self.Align == UI.ALIGN["VCenter"] {
|
||||
// fmt.Println("IconItem Draw VCenter:",lab_w,lab_h,self.Label.GetText())
|
||||
|
||||
self.Label.NewCoord( self.PosX - lab_w/2 + parent_x, self.PosY + self.Height/2+6+parent_y)
|
||||
|
||||
}else if self.Align == UI.ALIGN["HLeft"] {
|
||||
self.Label.NewCoord( self.PosX + self.Width/2+3+parent_x, self.PosY - lab_h/2 + parent_y)
|
||||
// fmt.Println("IconItem Draw VCenter:",lab_w,lab_h,self.Label.GetText())
|
||||
|
||||
self.Label.NewCoord(self.PosX-lab_w/2+parent_x, self.PosY+self.Height/2+6+parent_y)
|
||||
|
||||
} else if self.Align == UI.ALIGN["HLeft"] {
|
||||
self.Label.NewCoord(self.PosX+self.Width/2+3+parent_x, self.PosY-lab_h/2+parent_y)
|
||||
}
|
||||
|
||||
self.Label.Draw()
|
||||
}
|
||||
|
||||
if self.ImgSurf != nil {
|
||||
surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf,draw.MidRect(self.PosX + parent_x, self.PosY + parent_y,
|
||||
self.Width,self.Height, UI.Width, UI.Height),nil)
|
||||
surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf, draw.MidRect(self.PosX+parent_x, self.PosY+parent_y,
|
||||
self.Width, self.Height, UI.Width, UI.Height), nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
type SliderMultiIcon struct {
|
||||
UI.MultiIconItem
|
||||
Parent *SoundSlider
|
||||
UI.MultiIconItem
|
||||
Parent *SoundSlider
|
||||
}
|
||||
|
||||
func NewSliderMultiIcon() *SliderMultiIcon {
|
||||
p := &SliderMultiIcon{}
|
||||
p := &SliderMultiIcon{}
|
||||
p.MyType = UI.ICON_TYPES["EXE"]
|
||||
p.Align = UI.ALIGN["VCenter"]
|
||||
|
||||
p.IconIndex = 0
|
||||
|
||||
p.IconIndex = 0
|
||||
p.IconWidth = 18
|
||||
p.IconHeight = 18
|
||||
|
||||
return p
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *SliderMultiIcon) Draw() {
|
||||
if self.Parent == nil {
|
||||
fmt.Println("Error: SliderMultiIcon Draw Parent nil")
|
||||
return
|
||||
}
|
||||
parent_x,parent_y := self.Parent.Coord()
|
||||
|
||||
if self.Parent == nil {
|
||||
fmt.Println("Error: SliderMultiIcon Draw Parent nil")
|
||||
return
|
||||
}
|
||||
parent_x, parent_y := self.Parent.Coord()
|
||||
|
||||
if self.Label != nil {
|
||||
// lab_x,lab_y := self.Label.Coord()
|
||||
lab_w,lab_h:= self.Label.Size()
|
||||
// lab_x,lab_y := self.Label.Coord()
|
||||
lab_w, lab_h := self.Label.Size()
|
||||
if self.Align == UI.ALIGN["VCenter"] {
|
||||
self.Label.NewCoord( self.PosX - lab_w/2 + parent_x, self.PosY + self.Height/2+6 + parent_y)
|
||||
}else if self.Align == UI.ALIGN["HLeft"] {
|
||||
self.Label.NewCoord( self.PosX + self.Width/2+3 + parent_x, self.PosY - lab_h/2 + parent_y )
|
||||
self.Label.NewCoord(self.PosX-lab_w/2+parent_x, self.PosY+self.Height/2+6+parent_y)
|
||||
} else if self.Align == UI.ALIGN["HLeft"] {
|
||||
self.Label.NewCoord(self.PosX+self.Width/2+3+parent_x, self.PosY-lab_h/2+parent_y)
|
||||
}
|
||||
|
||||
self.Label.Draw()
|
||||
}
|
||||
|
||||
if self.ImgSurf != nil {
|
||||
|
||||
portion := rect.Rect(0,self.IconIndex*self.IconHeight,self.IconWidth,self.IconHeight)
|
||||
|
||||
|
||||
portion := rect.Rect(0, self.IconIndex*self.IconHeight, self.IconWidth, self.IconHeight)
|
||||
|
||||
surface.Blit(self.Parent.GetCanvasHWND(),
|
||||
self.ImgSurf,draw.MidRect(self.PosX + parent_x, self.PosY + parent_y,
|
||||
self.Width,self.Height, UI.Width, UI.Height),&portion)
|
||||
self.ImgSurf, draw.MidRect(self.PosX+parent_x, self.PosY+parent_y,
|
||||
self.Width, self.Height, UI.Width, UI.Height), &portion)
|
||||
}
|
||||
}
|
||||
|
||||
type SoundSlider struct {
|
||||
UI.Slider
|
||||
|
||||
BGpng *SliderIcon
|
||||
BGwidth int
|
||||
BGheight int
|
||||
//NeedleSurf
|
||||
Scale *SliderMultiIcon
|
||||
Parent *SoundPage
|
||||
|
||||
OnChangeCB OnChangeCB_T
|
||||
|
||||
snd_segs [][2]int
|
||||
UI.Slider
|
||||
|
||||
BGpng *SliderIcon
|
||||
BGwidth int
|
||||
BGheight int
|
||||
//NeedleSurf
|
||||
Scale *SliderMultiIcon
|
||||
Parent *SoundPage
|
||||
|
||||
OnChangeCB OnChangeCB_T
|
||||
|
||||
snd_segs [][2]int
|
||||
}
|
||||
|
||||
func NewSoundSlider() *SoundSlider {
|
||||
p := &SoundSlider{}
|
||||
p.Range = [2]int{0,255}
|
||||
p.Value = 0
|
||||
|
||||
p.BGwidth = 192
|
||||
p.BGheight = 173
|
||||
|
||||
p.snd_segs = [][2]int{ [2]int{0,20},[2]int{21,40},[2]int{41,50},
|
||||
[2]int{51,60},[2]int{61,70},[2]int{71,85},
|
||||
[2]int{86,90},[2]int{91,95},[2]int{96,100}}
|
||||
|
||||
return p
|
||||
p := &SoundSlider{}
|
||||
p.Range = [2]int{0, 255}
|
||||
p.Value = 0
|
||||
|
||||
p.BGwidth = 192
|
||||
p.BGheight = 173
|
||||
|
||||
p.snd_segs = [][2]int{[2]int{0, 20}, [2]int{21, 40}, [2]int{41, 50},
|
||||
[2]int{51, 60}, [2]int{61, 70}, [2]int{71, 85},
|
||||
[2]int{86, 90}, [2]int{91, 95}, [2]int{96, 100}}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *SoundSlider) GetCanvasHWND() *sdl.Surface {
|
||||
return self.CanvasHWND
|
||||
return self.CanvasHWND
|
||||
}
|
||||
|
||||
func (self *SoundSlider) Init() {
|
||||
self.Width = self.Parent.Width
|
||||
self.Height = self.Parent.Height
|
||||
|
||||
self.BGpng = NewSliderIcon()
|
||||
self.BGpng.ImgSurf = UI.MyIconPool.GetImgSurf("vol")
|
||||
self.BGpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
self.BGpng.Parent = self
|
||||
self.BGpng.Adjust(0,0,self.BGwidth,self.BGheight,0)
|
||||
|
||||
self.Scale = NewSliderMultiIcon()
|
||||
self.Scale.MyType = UI.ICON_TYPES["STAT"]
|
||||
self.Scale.Parent = self
|
||||
self.Scale.ImgSurf = UI.MyIconPool.GetImgSurf("scale")
|
||||
self.Scale.IconWidth = 82
|
||||
self.Scale.IconHeight = 63
|
||||
self.Scale.Adjust(0,0,82,63,0)
|
||||
self.Width = self.Parent.Width
|
||||
self.Height = self.Parent.Height
|
||||
|
||||
self.BGpng = NewSliderIcon()
|
||||
self.BGpng.ImgSurf = UI.MyIconPool.GetImgSurf("vol")
|
||||
self.BGpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
self.BGpng.Parent = self
|
||||
self.BGpng.Adjust(0, 0, self.BGwidth, self.BGheight, 0)
|
||||
|
||||
self.Scale = NewSliderMultiIcon()
|
||||
self.Scale.MyType = UI.ICON_TYPES["STAT"]
|
||||
self.Scale.Parent = self
|
||||
self.Scale.ImgSurf = UI.MyIconPool.GetImgSurf("scale")
|
||||
self.Scale.IconWidth = 82
|
||||
self.Scale.IconHeight = 63
|
||||
self.Scale.Adjust(0, 0, 82, 63, 0)
|
||||
}
|
||||
|
||||
func (self *SoundSlider) SetValue(vol int) { // pct 0 - 100
|
||||
for i,v := range self.snd_segs {
|
||||
if vol >= v[0] && vol <= v[1] {
|
||||
self.Value = i
|
||||
break
|
||||
}
|
||||
}
|
||||
for i, v := range self.snd_segs {
|
||||
if vol >= v[0] && vol <= v[1] {
|
||||
self.Value = i
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SoundSlider) Further() {
|
||||
self.Value += 1
|
||||
|
||||
if self.Value >= len(self.snd_segs) -1 {
|
||||
self.Value = len(self.snd_segs) -1
|
||||
}
|
||||
|
||||
vol := self.snd_segs[self.Value][0] + (self.snd_segs[self.Value][1]-self.snd_segs[self.Value][0])/2
|
||||
|
||||
if self.OnChangeCB != nil {
|
||||
self.OnChangeCB(vol)
|
||||
}
|
||||
self.Value += 1
|
||||
|
||||
if self.Value >= len(self.snd_segs)-1 {
|
||||
self.Value = len(self.snd_segs) - 1
|
||||
}
|
||||
|
||||
vol := self.snd_segs[self.Value][0] + (self.snd_segs[self.Value][1]-self.snd_segs[self.Value][0])/2
|
||||
|
||||
if self.OnChangeCB != nil {
|
||||
self.OnChangeCB(vol)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SoundSlider) StepBack() {
|
||||
self.Value -= 1
|
||||
|
||||
if self.Value < 0 {
|
||||
self.Value = 0
|
||||
}
|
||||
self.Value -= 1
|
||||
|
||||
vol := self.snd_segs[self.Value][0] + (self.snd_segs[self.Value][1]-self.snd_segs[self.Value][0])/2
|
||||
|
||||
if self.OnChangeCB != nil {
|
||||
self.OnChangeCB(vol)
|
||||
}
|
||||
if self.Value < 0 {
|
||||
self.Value = 0
|
||||
}
|
||||
|
||||
vol := self.snd_segs[self.Value][0] + (self.snd_segs[self.Value][1]-self.snd_segs[self.Value][0])/2
|
||||
|
||||
if self.OnChangeCB != nil {
|
||||
self.OnChangeCB(vol)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SoundSlider) Draw() {
|
||||
self.BGpng.NewCoord(self.Width/2,self.Height/2)
|
||||
//fmt.Printf("%x\n",self.BGpng.Parent)
|
||||
self.BGpng.Draw()
|
||||
|
||||
self.Scale.NewCoord(self.Width/2,self.Height/2)
|
||||
|
||||
self.Scale.IconIndex = self.Value
|
||||
|
||||
self.Scale.Draw()
|
||||
self.BGpng.NewCoord(self.Width/2, self.Height/2)
|
||||
//fmt.Printf("%x\n",self.BGpng.Parent)
|
||||
self.BGpng.Draw()
|
||||
|
||||
self.Scale.NewCoord(self.Width/2, self.Height/2)
|
||||
|
||||
self.Scale.IconIndex = self.Value
|
||||
|
||||
self.Scale.Draw()
|
||||
|
||||
}
|
||||
|
||||
|
||||
type SoundPage struct {
|
||||
UI.Page
|
||||
|
||||
MySlider *SoundSlider
|
||||
UI.Page
|
||||
|
||||
MySlider *SoundSlider
|
||||
}
|
||||
|
||||
func NewSoundPage() *SoundPage {
|
||||
p := &SoundPage{}
|
||||
|
||||
p := &SoundPage{}
|
||||
|
||||
p.PageIconMargin = 20
|
||||
p.SelectedIconTopOffset = 20
|
||||
p.EasingDur = 10
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.FootMsg = [5]string{"Nav","","","Back","Enter"}
|
||||
|
||||
return p
|
||||
p.FootMsg = [5]string{"Nav", "", "", "Back", "Enter"}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *SoundPage) Init() {
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
self.MySlider = NewSoundSlider()
|
||||
|
||||
self.MySlider.Parent = self
|
||||
self.MySlider.SetCanvasHWND(self.CanvasHWND)
|
||||
|
||||
self.MySlider.OnChangeCB = self.WhenSliderDrag
|
||||
|
||||
self.MySlider.Init()
|
||||
|
||||
v,err := GetVolume()
|
||||
if err == nil {
|
||||
self.MySlider.SetValue(v)
|
||||
}else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
self.MySlider = NewSoundSlider()
|
||||
|
||||
self.MySlider.Parent = self
|
||||
self.MySlider.SetCanvasHWND(self.CanvasHWND)
|
||||
|
||||
self.MySlider.OnChangeCB = self.WhenSliderDrag
|
||||
|
||||
self.MySlider.Init()
|
||||
|
||||
v, err := GetVolume()
|
||||
if err == nil {
|
||||
self.MySlider.SetValue(v)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SoundPage) OnLoadCb() {
|
||||
v,err := GetVolume()
|
||||
if err == nil {
|
||||
self.MySlider.SetValue(v)
|
||||
}else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
v, err := GetVolume()
|
||||
if err == nil {
|
||||
self.MySlider.SetValue(v)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SoundPage) WhenSliderDrag(val int) { //value 0 - 100
|
||||
if val <0 || val > 100 {
|
||||
return
|
||||
}
|
||||
|
||||
self.Screen.TitleBar.SetSoundVolume(val)
|
||||
|
||||
SetVolume(val)
|
||||
if val < 0 || val > 100 {
|
||||
return
|
||||
}
|
||||
|
||||
self.Screen.TitleBar.SetSoundVolume(val)
|
||||
|
||||
SetVolume(val)
|
||||
}
|
||||
|
||||
func (self *SoundPage) KeyDown(ev *event.Event) {
|
||||
@@ -276,24 +272,22 @@ func (self *SoundPage) KeyDown(ev *event.Event) {
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Right"] {
|
||||
self.MySlider.Further()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Left"] {
|
||||
self.MySlider.StepBack()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
if ev.Data["Key"] == UI.CurKeys["Right"] {
|
||||
self.MySlider.Further()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Left"] {
|
||||
self.MySlider.StepBack()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (self *SoundPage) Draw() {
|
||||
self.ClearCanvas()
|
||||
self.MySlider.Draw()
|
||||
self.ClearCanvas()
|
||||
self.MySlider.Draw()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
//go:build !windows && !darwin
|
||||
// +build !windows,!darwin
|
||||
|
||||
/*
|
||||
* Copied from https://github.com/itchyny/volume-go, MIT License
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
/*
|
||||
* Copied from https://github.com/itchyny/volume-go, MIT License
|
||||
*/
|
||||
|
||||
@@ -1,37 +1,34 @@
|
||||
package Storage
|
||||
|
||||
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
)
|
||||
|
||||
/******************************************************************************/
|
||||
type StoragePlugin struct {
|
||||
UI.Plugin
|
||||
StoragePage *StoragePage
|
||||
StoragePage *StoragePage
|
||||
}
|
||||
|
||||
|
||||
func (self *StoragePlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *StoragePlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.StoragePage = NewStoragePage()
|
||||
self.StoragePage.SetScreen( main_screen)
|
||||
self.StoragePage.SetScreen(main_screen)
|
||||
self.StoragePage.SetName("Storage")
|
||||
self.StoragePage.Init()
|
||||
self.StoragePage.Init()
|
||||
}
|
||||
|
||||
func (self *StoragePlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *StoragePlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.StoragePage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.StoragePage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
@@ -3,12 +3,11 @@ package Storage
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/color"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -19,19 +18,19 @@ const (
|
||||
)
|
||||
|
||||
type StoragePage struct {
|
||||
UI.Page
|
||||
|
||||
BGpng UI.IconItemInterface
|
||||
BGwidth int // 96
|
||||
BGheight int // 73
|
||||
BGlabel UI.LabelInterface
|
||||
FreeLabel UI.LabelInterface
|
||||
|
||||
BGmsg string // "%.1GB of %.1fGB Used"
|
||||
|
||||
DskUsg [2]float64
|
||||
HighColor *color.Color //MySkinManager.GiveColor('High')
|
||||
|
||||
UI.Page
|
||||
|
||||
BGpng UI.IconItemInterface
|
||||
BGwidth int // 96
|
||||
BGheight int // 73
|
||||
BGlabel UI.LabelInterface
|
||||
FreeLabel UI.LabelInterface
|
||||
|
||||
BGmsg string // "%.1GB of %.1fGB Used"
|
||||
|
||||
DskUsg [2]float64
|
||||
HighColor *color.Color //MySkinManager.GiveColor('High')
|
||||
|
||||
}
|
||||
|
||||
type DiskStatus struct {
|
||||
@@ -53,97 +52,95 @@ func DiskUsage(path string) (disk DiskStatus) {
|
||||
}
|
||||
|
||||
func NewStoragePage() *StoragePage {
|
||||
p:= &StoragePage{}
|
||||
|
||||
p := &StoragePage{}
|
||||
|
||||
p.PageIconMargin = 20
|
||||
p.SelectedIconTopOffset = 20
|
||||
p.EasingDur = 10
|
||||
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.FootMsg = [5]string{"Nav","","","Back",""}
|
||||
|
||||
p.HighColor = &color.Color{51, 166, 255,255}
|
||||
|
||||
p.BGwidth = 96
|
||||
p.BGheight = 73
|
||||
|
||||
p.BGmsg = "%.1fGB of %.1fGB Used"
|
||||
return p
|
||||
p.FootMsg = [5]string{"Nav", "", "", "Back", ""}
|
||||
|
||||
p.HighColor = &color.Color{51, 166, 255, 255}
|
||||
|
||||
p.BGwidth = 96
|
||||
p.BGheight = 73
|
||||
|
||||
p.BGmsg = "%.1fGB of %.1fGB Used"
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *StoragePage) DiskUsage() (float64,float64) {
|
||||
disk := DiskUsage("/")
|
||||
|
||||
all := float64(disk.All)/float64(GB)
|
||||
|
||||
free := float64(disk.Free)/float64(GB)
|
||||
|
||||
return free,all
|
||||
func (self *StoragePage) DiskUsage() (float64, float64) {
|
||||
disk := DiskUsage("/")
|
||||
|
||||
all := float64(disk.All) / float64(GB)
|
||||
|
||||
free := float64(disk.Free) / float64(GB)
|
||||
|
||||
return free, all
|
||||
|
||||
}
|
||||
|
||||
func (self *StoragePage) Init() {
|
||||
|
||||
self.DskUsg[0],self.DskUsg[1] = self.DiskUsage()
|
||||
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
bgpng := UI.NewIconItem()
|
||||
bgpng.ImgSurf = UI.MyIconPool.GetImgSurf("icon_sd")
|
||||
bgpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
bgpng.Parent = self
|
||||
|
||||
bgpng.AddLabel( fmt.Sprintf(self.BGmsg,self.DskUsg[1]-self.DskUsg[0],self.DskUsg[1]),UI.Fonts["varela15"])
|
||||
bgpng.Adjust(0,0,self.BGwidth,self.BGheight,0)
|
||||
|
||||
self.BGpng = bgpng
|
||||
self.BGlabel = UI.NewLabel()
|
||||
self.BGlabel.SetCanvasHWND(self.CanvasHWND)
|
||||
|
||||
usage_percent := int((self.DskUsg[0]/self.DskUsg[1])*100.0)
|
||||
|
||||
self.BGlabel.Init(fmt.Sprintf("%d%%",usage_percent ),UI.Fonts["varela25"],nil)
|
||||
self.BGlabel.SetColor(self.HighColor)
|
||||
|
||||
self.FreeLabel = UI.NewLabel()
|
||||
self.FreeLabel.SetCanvasHWND(self.CanvasHWND)
|
||||
self.FreeLabel.Init("Free",UI.Fonts["varela13"],nil)
|
||||
self.FreeLabel.SetColor(self.BGlabel.(*UI.Label).Color)
|
||||
|
||||
self.DskUsg[0], self.DskUsg[1] = self.DiskUsage()
|
||||
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
bgpng := UI.NewIconItem()
|
||||
bgpng.ImgSurf = UI.MyIconPool.GetImgSurf("icon_sd")
|
||||
bgpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
bgpng.Parent = self
|
||||
|
||||
bgpng.AddLabel(fmt.Sprintf(self.BGmsg, self.DskUsg[1]-self.DskUsg[0], self.DskUsg[1]), UI.Fonts["varela15"])
|
||||
bgpng.Adjust(0, 0, self.BGwidth, self.BGheight, 0)
|
||||
|
||||
self.BGpng = bgpng
|
||||
self.BGlabel = UI.NewLabel()
|
||||
self.BGlabel.SetCanvasHWND(self.CanvasHWND)
|
||||
|
||||
usage_percent := int((self.DskUsg[0] / self.DskUsg[1]) * 100.0)
|
||||
|
||||
self.BGlabel.Init(fmt.Sprintf("%d%%", usage_percent), UI.Fonts["varela25"], nil)
|
||||
self.BGlabel.SetColor(self.HighColor)
|
||||
|
||||
self.FreeLabel = UI.NewLabel()
|
||||
self.FreeLabel.SetCanvasHWND(self.CanvasHWND)
|
||||
self.FreeLabel.Init("Free", UI.Fonts["varela13"], nil)
|
||||
self.FreeLabel.SetColor(self.BGlabel.(*UI.Label).Color)
|
||||
|
||||
}
|
||||
|
||||
func (self *StoragePage) Draw() {
|
||||
self.ClearCanvas()
|
||||
|
||||
self.BGpng.NewCoord(self.Width/2,self.Height/2-10)
|
||||
self.BGpng.Draw()
|
||||
|
||||
self.BGlabel.NewCoord(self.Width/2-28,self.Height/2-30)
|
||||
self.BGlabel.Draw()
|
||||
self.ClearCanvas()
|
||||
|
||||
x,_ := self.BGlabel.Coord()
|
||||
self.FreeLabel.NewCoord(x+10 ,self.Height/2)
|
||||
self.FreeLabel.Draw()
|
||||
self.BGpng.NewCoord(self.Width/2, self.Height/2-10)
|
||||
self.BGpng.Draw()
|
||||
|
||||
usage_percent := (self.DskUsg[0]/self.DskUsg[1] )
|
||||
if usage_percent < 0.1 {
|
||||
usage_percent = 0.1
|
||||
}
|
||||
|
||||
rect_ := draw.MidRect(self.Width/2,self.Height-30,170,17, UI.Width,UI.Height)
|
||||
self.BGlabel.NewCoord(self.Width/2-28, self.Height/2-30)
|
||||
self.BGlabel.Draw()
|
||||
|
||||
draw.AARoundRect(self.CanvasHWND,rect_,&color.Color{169,169,169,255},5,0,&color.Color{169,169,169,255})
|
||||
|
||||
rect2_ := draw.MidRect(self.Width/2,self.Height-30,int(170.0*(1.0-usage_percent)),17, UI.Width,UI.Height)
|
||||
|
||||
rect2_.X = rect_.X
|
||||
rect2_.Y = rect_.Y
|
||||
|
||||
|
||||
draw.AARoundRect(self.CanvasHWND,rect2_,&color.Color{131,199,219,255},5,0,&color.Color{131,199,219,255})
|
||||
|
||||
x, _ := self.BGlabel.Coord()
|
||||
self.FreeLabel.NewCoord(x+10, self.Height/2)
|
||||
self.FreeLabel.Draw()
|
||||
|
||||
usage_percent := (self.DskUsg[0] / self.DskUsg[1])
|
||||
if usage_percent < 0.1 {
|
||||
usage_percent = 0.1
|
||||
}
|
||||
|
||||
rect_ := draw.MidRect(self.Width/2, self.Height-30, 170, 17, UI.Width, UI.Height)
|
||||
|
||||
draw.AARoundRect(self.CanvasHWND, rect_, &color.Color{169, 169, 169, 255}, 5, 0, &color.Color{169, 169, 169, 255})
|
||||
|
||||
rect2_ := draw.MidRect(self.Width/2, self.Height-30, int(170.0*(1.0-usage_percent)), 17, UI.Width, UI.Height)
|
||||
|
||||
rect2_.X = rect_.X
|
||||
rect2_.Y = rect_.Y
|
||||
|
||||
draw.AARoundRect(self.CanvasHWND, rect2_, &color.Color{131, 199, 219, 255}, 5, 0, &color.Color{131, 199, 219, 255})
|
||||
|
||||
}
|
||||
|
||||
@@ -1,105 +1,99 @@
|
||||
package TimeZone
|
||||
|
||||
import (
|
||||
//"fmt"
|
||||
//"strings"
|
||||
//"io/ioutil"
|
||||
"path/filepath"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
//"github.com/veandco/go-sdl2/sdl"
|
||||
//"fmt"
|
||||
//"strings"
|
||||
//"io/ioutil"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"path/filepath"
|
||||
|
||||
//"github.com/veandco/go-sdl2/sdl"
|
||||
//"github.com/cuu/gogame/surface"
|
||||
//"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
//"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
)
|
||||
|
||||
var TimeZoneListPageListItemDefaultHeight = 30
|
||||
|
||||
type TimeZoneListPageInterface interface {
|
||||
UI.PageInterface
|
||||
GetMapIcons() map[string]UI.IconItemInterface
|
||||
|
||||
type TimeZoneListPageInterface interface {
|
||||
UI.PageInterface
|
||||
GetMapIcons() map[string]UI.IconItemInterface
|
||||
}
|
||||
|
||||
type TimeZoneListPageListItem struct {
|
||||
UI.HierListItem
|
||||
Parent TimeZoneListPageInterface
|
||||
UI.HierListItem
|
||||
Parent TimeZoneListPageInterface
|
||||
}
|
||||
|
||||
func NewTimeZoneListPageListItem() *TimeZoneListPageListItem {
|
||||
p := &TimeZoneListPageListItem{}
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
p.Icons = make( map[string]UI.IconItemInterface)
|
||||
p.Fonts = make(map[string]*ttf.Font)
|
||||
|
||||
p.MyType = UI.ICON_TYPES["EXE"]
|
||||
p := &TimeZoneListPageListItem{}
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
p.Fonts = make(map[string]*ttf.Font)
|
||||
|
||||
p.MyType = UI.ICON_TYPES["EXE"]
|
||||
p.Height = TimeZoneListPageListItemDefaultHeight
|
||||
p.Width = 0
|
||||
|
||||
|
||||
return p
|
||||
p.Width = 0
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *TimeZoneListPageListItem) Init(text string) {
|
||||
l := UI.NewLabel()
|
||||
l.PosX = 20
|
||||
l := UI.NewLabel()
|
||||
l.PosX = 20
|
||||
|
||||
l.SetCanvasHWND(self.Parent.GetCanvasHWND())
|
||||
|
||||
if self.IsDir() == true || self.IsFile() == true {
|
||||
self.Path = text
|
||||
}
|
||||
|
||||
label_text := filepath.Base(text)
|
||||
|
||||
if self.IsDir() == true {
|
||||
l.Init(label_text, self.Fonts["normal"],nil)
|
||||
}else {
|
||||
l.Init(label_text,self.Fonts["normal"],nil)
|
||||
}
|
||||
|
||||
self.Labels["Text"] = l
|
||||
l.SetCanvasHWND(self.Parent.GetCanvasHWND())
|
||||
|
||||
if self.IsDir() == true || self.IsFile() == true {
|
||||
self.Path = text
|
||||
}
|
||||
|
||||
label_text := filepath.Base(text)
|
||||
|
||||
if self.IsDir() == true {
|
||||
l.Init(label_text, self.Fonts["normal"], nil)
|
||||
} else {
|
||||
l.Init(label_text, self.Fonts["normal"], nil)
|
||||
}
|
||||
|
||||
self.Labels["Text"] = l
|
||||
}
|
||||
|
||||
func (self *TimeZoneListPageListItem) Draw() {
|
||||
x,y := self.Labels["Text"].Coord()
|
||||
_,h := self.Labels["Text"].Size()
|
||||
|
||||
|
||||
if self.Path != "[..]" {
|
||||
self.Labels["Text"].NewCoord(23,y)
|
||||
|
||||
}else {
|
||||
self.Labels["Text"].NewCoord(3,y)
|
||||
}
|
||||
|
||||
x,y = self.Labels["Text"].Coord()
|
||||
self.Labels["Text"].NewCoord(x, self.PosY + (self.Height-h)/2)
|
||||
|
||||
self.Labels["Text"].Draw()
|
||||
|
||||
parent_icons := self.Parent.GetMapIcons()
|
||||
_,h = parent_icons["sys"].Size()
|
||||
|
||||
if self.IsDir() == true && self.Path != "[..]" {
|
||||
parent_icons["sys"].SetIconIndex (0)
|
||||
parent_icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
|
||||
parent_icons["sys"].Draw()
|
||||
}
|
||||
|
||||
if self.IsFile() == true {
|
||||
parent_icons["sys"].SetIconIndex(1)
|
||||
parent_icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
|
||||
parent_icons["sys"].Draw()
|
||||
}
|
||||
|
||||
draw.Line(self.Parent.GetCanvasHWND(),&color.Color{169,169,169,255},
|
||||
self.PosX,self.PosY+self.Height-1,self.PosX+self.Width,self.PosY+self.Height-1,1)
|
||||
x, y := self.Labels["Text"].Coord()
|
||||
_, h := self.Labels["Text"].Size()
|
||||
|
||||
if self.Path != "[..]" {
|
||||
self.Labels["Text"].NewCoord(23, y)
|
||||
|
||||
} else {
|
||||
self.Labels["Text"].NewCoord(3, y)
|
||||
}
|
||||
|
||||
x, y = self.Labels["Text"].Coord()
|
||||
self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2)
|
||||
|
||||
self.Labels["Text"].Draw()
|
||||
|
||||
parent_icons := self.Parent.GetMapIcons()
|
||||
_, h = parent_icons["sys"].Size()
|
||||
|
||||
if self.IsDir() == true && self.Path != "[..]" {
|
||||
parent_icons["sys"].SetIconIndex(0)
|
||||
parent_icons["sys"].NewCoord(self.PosX+12, self.PosY+(self.Height-h)/2+h/2)
|
||||
parent_icons["sys"].Draw()
|
||||
}
|
||||
|
||||
if self.IsFile() == true {
|
||||
parent_icons["sys"].SetIconIndex(1)
|
||||
parent_icons["sys"].NewCoord(self.PosX+12, self.PosY+(self.Height-h)/2+h/2)
|
||||
parent_icons["sys"].Draw()
|
||||
}
|
||||
|
||||
draw.Line(self.Parent.GetCanvasHWND(), &color.Color{169, 169, 169, 255},
|
||||
self.PosX, self.PosY+self.Height-1, self.PosX+self.Width, self.PosY+self.Height-1, 1)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package TimeZone
|
||||
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||
)
|
||||
@@ -16,21 +16,20 @@ import (
|
||||
/******************************************************************************/
|
||||
type TimeZonePlugin struct {
|
||||
UI.Plugin
|
||||
TimeZonePage *TimeZoneListPage
|
||||
TimeZonePage *TimeZoneListPage
|
||||
}
|
||||
|
||||
|
||||
func (self *TimeZonePlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *TimeZonePlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.TimeZonePage = NewTimeZoneListPage()
|
||||
self.TimeZonePage.SetScreen( main_screen)
|
||||
self.TimeZonePage.SetScreen(main_screen)
|
||||
self.TimeZonePage.SetName("Timezone Selection")
|
||||
self.TimeZonePage.Init()
|
||||
self.TimeZonePage.Init()
|
||||
}
|
||||
|
||||
func (self *TimeZonePlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *TimeZonePlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.TimeZonePage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.TimeZonePage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
@@ -1,364 +1,349 @@
|
||||
package TimeZone
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"path/filepath"
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/time"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/time"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
var TimeZonePath = "/usr/share/zoneinfo/posix"
|
||||
|
||||
type ListPageSelector struct {
|
||||
UI.InfoPageSelector
|
||||
UI.InfoPageSelector
|
||||
}
|
||||
|
||||
func NewListPageSelector() *ListPageSelector {
|
||||
|
||||
p := &ListPageSelector{}
|
||||
|
||||
p.Width = UI.Width
|
||||
p.BackgroundColor = &color.Color{131,199,219,255} //SkinManager().GiveColor('Front')
|
||||
|
||||
return p
|
||||
|
||||
p := &ListPageSelector{}
|
||||
|
||||
p.Width = UI.Width
|
||||
p.BackgroundColor = &color.Color{131, 199, 219, 255} //SkinManager().GiveColor('Front')
|
||||
|
||||
return p
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (self *ListPageSelector) Draw() {
|
||||
|
||||
idx := self.Parent.GetPsIndex()
|
||||
mylist := self.Parent.GetMyList()
|
||||
|
||||
if idx < len(mylist) {
|
||||
x,y := mylist[idx].Coord()
|
||||
_,h := mylist[idx].Size()
|
||||
|
||||
self.PosX = x+2
|
||||
self.PosY = y+1
|
||||
self.Height = h-3
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
rect_ := rect.Rect(self.PosX,self.PosY,self.Width-4, self.Height)
|
||||
|
||||
draw.AARoundRect(canvas_,&rect_,self.BackgroundColor,4,0,self.BackgroundColor)
|
||||
}
|
||||
|
||||
idx := self.Parent.GetPsIndex()
|
||||
mylist := self.Parent.GetMyList()
|
||||
|
||||
if idx < len(mylist) {
|
||||
x, y := mylist[idx].Coord()
|
||||
_, h := mylist[idx].Size()
|
||||
|
||||
self.PosX = x + 2
|
||||
self.PosY = y + 1
|
||||
self.Height = h - 3
|
||||
|
||||
canvas_ := self.Parent.GetCanvasHWND()
|
||||
rect_ := rect.Rect(self.PosX, self.PosY, self.Width-4, self.Height)
|
||||
|
||||
draw.AARoundRect(canvas_, &rect_, self.BackgroundColor, 4, 0, self.BackgroundColor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
type TimeZoneListPage struct {
|
||||
UI.Page
|
||||
|
||||
Scroller *UI.ListScroller
|
||||
|
||||
Icons map[string]UI.IconItemInterface
|
||||
UI.Page
|
||||
|
||||
ListFont *ttf.Font
|
||||
MyStack *UI.FolderStack
|
||||
BGpng *UI.IconItem
|
||||
BGwidth int
|
||||
BGheight int
|
||||
|
||||
SwapMyList []UI.ListItemInterface
|
||||
Scroller *UI.ListScroller
|
||||
|
||||
Icons map[string]UI.IconItemInterface
|
||||
|
||||
ListFont *ttf.Font
|
||||
MyStack *UI.FolderStack
|
||||
BGpng *UI.IconItem
|
||||
BGwidth int
|
||||
BGheight int
|
||||
|
||||
SwapMyList []UI.ListItemInterface
|
||||
}
|
||||
|
||||
type ListEle struct {
|
||||
|
||||
Name string
|
||||
FilePath string
|
||||
IsFile bool
|
||||
Name string
|
||||
FilePath string
|
||||
IsFile bool
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
func NewTimeZoneListPage() *TimeZoneListPage {
|
||||
p := &TimeZoneListPage{}
|
||||
|
||||
p.BGwidth = 56
|
||||
p.BGheight = 70
|
||||
|
||||
p.FootMsg = [5]string{ "Nav","","","Back","Select" }
|
||||
|
||||
p.ListFont = UI.Fonts["notosanscjk15"]
|
||||
|
||||
p.MyStack = UI.NewFolderStack()
|
||||
p.MyStack.SetRootPath( TimeZonePath )
|
||||
|
||||
p.Icons = make(map[string]UI.IconItemInterface )
|
||||
return p
|
||||
p := &TimeZoneListPage{}
|
||||
|
||||
p.BGwidth = 56
|
||||
p.BGheight = 70
|
||||
|
||||
p.FootMsg = [5]string{"Nav", "", "", "Back", "Select"}
|
||||
|
||||
p.ListFont = UI.Fonts["notosanscjk15"]
|
||||
|
||||
p.MyStack = UI.NewFolderStack()
|
||||
p.MyStack.SetRootPath(TimeZonePath)
|
||||
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *TimeZoneListPage) GetMapIcons() map[string]UI.IconItemInterface {
|
||||
return self.Icons
|
||||
return self.Icons
|
||||
}
|
||||
|
||||
func (self *TimeZoneListPage) buildDirectoryList(path string) []*ListEle {
|
||||
|
||||
//[*ListEle{},*ListEle{}]
|
||||
var ret []*ListEle
|
||||
|
||||
file_paths,err := filepath.Glob(path+"/*")//sorted
|
||||
if err == nil {
|
||||
for _, u := range file_paths {
|
||||
e := &ListEle{}
|
||||
e.Name = filepath.Base(u)
|
||||
e.FilePath = u
|
||||
if UI.IsAFile(u) {
|
||||
e.IsFile = true
|
||||
}else {
|
||||
e.IsFile = false
|
||||
}
|
||||
|
||||
ret = append(ret,e)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
func (self *TimeZoneListPage) buildDirectoryList(path string) []*ListEle {
|
||||
|
||||
//[*ListEle{},*ListEle{}]
|
||||
var ret []*ListEle
|
||||
|
||||
file_paths, err := filepath.Glob(path + "/*") //sorted
|
||||
if err == nil {
|
||||
for _, u := range file_paths {
|
||||
e := &ListEle{}
|
||||
e.Name = filepath.Base(u)
|
||||
e.FilePath = u
|
||||
if UI.IsAFile(u) {
|
||||
e.IsFile = true
|
||||
} else {
|
||||
e.IsFile = false
|
||||
}
|
||||
|
||||
ret = append(ret, e)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (self *TimeZoneListPage) SyncList(path string) {
|
||||
|
||||
alist := self.buildDirectoryList(path)
|
||||
if len(alist) == 0 {
|
||||
fmt.Println("buildDirectoryList empty")
|
||||
return
|
||||
}
|
||||
|
||||
self.MyList = nil
|
||||
self.SwapMyList = nil
|
||||
|
||||
|
||||
start_x := 0
|
||||
start_y := 0
|
||||
|
||||
hasparent := 0
|
||||
|
||||
if self.MyStack.Length() > 0 {
|
||||
hasparent = 1
|
||||
|
||||
li := NewTimeZoneListPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFont
|
||||
li.MyType = UI.ICON_TYPES["DIR"]
|
||||
li.Init("[..]")
|
||||
|
||||
self.MyList = append(self.MyList,li)
|
||||
|
||||
}
|
||||
|
||||
for i,v := range alist{
|
||||
li := NewTimeZoneListPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + (i+hasparent) *TimeZoneListPageListItemDefaultHeight
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFont
|
||||
li.MyType = UI.ICON_TYPES["FILE"]
|
||||
|
||||
if v.IsFile == false {
|
||||
li.MyType = UI.ICON_TYPES["DIR"]
|
||||
}else{
|
||||
li.MyType = UI.ICON_TYPES["FILE"]
|
||||
}
|
||||
|
||||
li.Init(v.Name)
|
||||
li.Path = v.FilePath
|
||||
|
||||
self.MyList = append(self.MyList,li)
|
||||
}
|
||||
|
||||
|
||||
for _,v := range self.MyList {
|
||||
self.SwapMyList = append(self.SwapMyList,v)
|
||||
}
|
||||
|
||||
alist := self.buildDirectoryList(path)
|
||||
if len(alist) == 0 {
|
||||
fmt.Println("buildDirectoryList empty")
|
||||
return
|
||||
}
|
||||
|
||||
self.MyList = nil
|
||||
self.SwapMyList = nil
|
||||
|
||||
start_x := 0
|
||||
start_y := 0
|
||||
|
||||
hasparent := 0
|
||||
|
||||
if self.MyStack.Length() > 0 {
|
||||
hasparent = 1
|
||||
|
||||
li := NewTimeZoneListPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFont
|
||||
li.MyType = UI.ICON_TYPES["DIR"]
|
||||
li.Init("[..]")
|
||||
|
||||
self.MyList = append(self.MyList, li)
|
||||
|
||||
}
|
||||
|
||||
for i, v := range alist {
|
||||
li := NewTimeZoneListPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + (i+hasparent)*TimeZoneListPageListItemDefaultHeight
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFont
|
||||
li.MyType = UI.ICON_TYPES["FILE"]
|
||||
|
||||
if v.IsFile == false {
|
||||
li.MyType = UI.ICON_TYPES["DIR"]
|
||||
} else {
|
||||
li.MyType = UI.ICON_TYPES["FILE"]
|
||||
}
|
||||
|
||||
li.Init(v.Name)
|
||||
li.Path = v.FilePath
|
||||
|
||||
self.MyList = append(self.MyList, li)
|
||||
}
|
||||
|
||||
for _, v := range self.MyList {
|
||||
self.SwapMyList = append(self.SwapMyList, v)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *TimeZoneListPage) Init() {
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
|
||||
ps := NewListPageSelector()
|
||||
ps.Parent = self
|
||||
|
||||
self.Ps = ps
|
||||
self.PsIndex = 0
|
||||
|
||||
self.SyncList( TimeZonePath )
|
||||
|
||||
icon_for_list := UI.NewMultiIconItem()
|
||||
icon_for_list.ImgSurf = UI.MyIconPool.GetImgSurf("sys")
|
||||
icon_for_list.MyType = UI.ICON_TYPES["STAT"]
|
||||
icon_for_list.Parent = self
|
||||
|
||||
icon_for_list.Adjust(0,0,18,18,0)
|
||||
self.Icons["sys"] = icon_for_list
|
||||
|
||||
bgpng := UI.NewIconItem()
|
||||
bgpng.ImgSurf = UI.MyIconPool.GetImgSurf("empty")
|
||||
bgpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
bgpng.Parent = self
|
||||
bgpng.AddLabel("No timezones found on system!", UI.MyLangManager.TrFont("varela22"))
|
||||
bgpng.SetLabelColor( UI.MySkinManager.GiveColor("Disabled") )
|
||||
bgpng.Adjust(0,0,self.BGwidth,self.BGheight,0)
|
||||
|
||||
self.BGpng = bgpng
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
|
||||
ps := NewListPageSelector()
|
||||
ps.Parent = self
|
||||
|
||||
self.Ps = ps
|
||||
self.PsIndex = 0
|
||||
|
||||
self.SyncList(TimeZonePath)
|
||||
|
||||
icon_for_list := UI.NewMultiIconItem()
|
||||
icon_for_list.ImgSurf = UI.MyIconPool.GetImgSurf("sys")
|
||||
icon_for_list.MyType = UI.ICON_TYPES["STAT"]
|
||||
icon_for_list.Parent = self
|
||||
|
||||
icon_for_list.Adjust(0, 0, 18, 18, 0)
|
||||
self.Icons["sys"] = icon_for_list
|
||||
|
||||
bgpng := UI.NewIconItem()
|
||||
bgpng.ImgSurf = UI.MyIconPool.GetImgSurf("empty")
|
||||
bgpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
bgpng.Parent = self
|
||||
bgpng.AddLabel("No timezones found on system!", UI.MyLangManager.TrFont("varela22"))
|
||||
bgpng.SetLabelColor(UI.MySkinManager.GiveColor("Disabled"))
|
||||
bgpng.Adjust(0, 0, self.BGwidth, self.BGheight, 0)
|
||||
|
||||
self.BGpng = bgpng
|
||||
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (self *TimeZoneListPage) Click() {
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
cur_li := self.MyList[self.PsIndex].(*TimeZoneListPageListItem)
|
||||
|
||||
if cur_li.MyType == UI.ICON_TYPES["DIR"] {
|
||||
if cur_li.Path == "[..]" {
|
||||
self.MyStack.Pop()
|
||||
self.SyncList(self.MyStack.Last())
|
||||
self.PsIndex = 0
|
||||
}else {
|
||||
self.MyStack.Push( self.MyList[self.PsIndex].(*TimeZoneListPageListItem).Path)
|
||||
self.SyncList(self.MyStack.Last())
|
||||
self.PsIndex = 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if cur_li.MyType == UI.ICON_TYPES["FILE"] { //set the current timezone
|
||||
self.Screen.MsgBox.SetText("Applying")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
time.BlockDelay(300)
|
||||
cpCmd := exec.Command("sudo","cp", cur_li.Path,"/etc/localtime")
|
||||
err := cpCmd.Run()
|
||||
if err != nil{
|
||||
fmt.Println(err)
|
||||
}else {
|
||||
|
||||
self.Screen.TitleBar.UpdateTimeLocation()
|
||||
|
||||
}
|
||||
fmt.Println("add ",cur_li.Path)
|
||||
}
|
||||
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
cur_li := self.MyList[self.PsIndex].(*TimeZoneListPageListItem)
|
||||
|
||||
if cur_li.MyType == UI.ICON_TYPES["DIR"] {
|
||||
if cur_li.Path == "[..]" {
|
||||
self.MyStack.Pop()
|
||||
self.SyncList(self.MyStack.Last())
|
||||
self.PsIndex = 0
|
||||
} else {
|
||||
self.MyStack.Push(self.MyList[self.PsIndex].(*TimeZoneListPageListItem).Path)
|
||||
self.SyncList(self.MyStack.Last())
|
||||
self.PsIndex = 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if cur_li.MyType == UI.ICON_TYPES["FILE"] { //set the current timezone
|
||||
self.Screen.MsgBox.SetText("Applying")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
time.BlockDelay(300)
|
||||
cpCmd := exec.Command("sudo", "cp", cur_li.Path, "/etc/localtime")
|
||||
err := cpCmd.Run()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
|
||||
self.Screen.TitleBar.UpdateTimeLocation()
|
||||
|
||||
}
|
||||
fmt.Println("add ", cur_li.Path)
|
||||
}
|
||||
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
|
||||
func (self *TimeZoneListPage) Rescan() {
|
||||
self.SyncList(TimeZonePath)
|
||||
self.PsIndex = 0
|
||||
self.SyncList(TimeZonePath)
|
||||
self.PsIndex = 0
|
||||
}
|
||||
|
||||
func (self *TimeZoneListPage) KeyDown(ev *event.Event) {
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Menu"] || ev.Data["Key"] == UI.CurKeys["A"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Up"] {
|
||||
self.ScrollUp()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Down"] {
|
||||
self.ScrollDown()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Right"] {
|
||||
self.FastScrollDown(5)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Left"] {
|
||||
self.FastScrollUp(5)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Enter"] {
|
||||
self.Click()
|
||||
}
|
||||
if ev.Data["Key"] == UI.CurKeys["Menu"] || ev.Data["Key"] == UI.CurKeys["A"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Up"] {
|
||||
self.ScrollUp()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Down"] {
|
||||
self.ScrollDown()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Right"] {
|
||||
self.FastScrollDown(5)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Left"] {
|
||||
self.FastScrollUp(5)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Enter"] {
|
||||
self.Click()
|
||||
}
|
||||
}
|
||||
|
||||
func (self *TimeZoneListPage) Draw() {
|
||||
self.ClearCanvas()
|
||||
|
||||
if len(self.MyList) == 0 {
|
||||
self.BGpng.NewCoord(self.Width/2,self.Height/2)
|
||||
self.BGpng.Draw()
|
||||
}
|
||||
|
||||
if len(self.MyList) *TimeZoneListPageListItemDefaultHeight > self.Height {
|
||||
|
||||
self.Ps.(*ListPageSelector).Width = self.Width - 11
|
||||
self.Ps.Draw()
|
||||
|
||||
for _,v := range self.MyList {
|
||||
if v.(*TimeZoneListPageListItem).PosY > self.Height + self.Height/2 {
|
||||
break
|
||||
}
|
||||
if v.(*TimeZoneListPageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
}
|
||||
self.Scroller.UpdateSize( len(self.MyList)*TimeZoneListPageListItemDefaultHeight,
|
||||
self.PsIndex*TimeZoneListPageListItemDefaultHeight)
|
||||
self.Scroller.Draw()
|
||||
|
||||
}else {
|
||||
self.Ps.(*ListPageSelector).Width = self.Width
|
||||
self.Ps.Draw()
|
||||
|
||||
for _,v := range self.MyList {
|
||||
if v.(*TimeZoneListPageListItem).PosY > self.Height + self.Height/2 {
|
||||
break
|
||||
}
|
||||
if v.(*TimeZoneListPageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
self.ClearCanvas()
|
||||
|
||||
if len(self.MyList) == 0 {
|
||||
self.BGpng.NewCoord(self.Width/2, self.Height/2)
|
||||
self.BGpng.Draw()
|
||||
}
|
||||
|
||||
if len(self.MyList)*TimeZoneListPageListItemDefaultHeight > self.Height {
|
||||
|
||||
self.Ps.(*ListPageSelector).Width = self.Width - 11
|
||||
self.Ps.Draw()
|
||||
|
||||
for _, v := range self.MyList {
|
||||
if v.(*TimeZoneListPageListItem).PosY > self.Height+self.Height/2 {
|
||||
break
|
||||
}
|
||||
if v.(*TimeZoneListPageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
}
|
||||
self.Scroller.UpdateSize(len(self.MyList)*TimeZoneListPageListItemDefaultHeight,
|
||||
self.PsIndex*TimeZoneListPageListItemDefaultHeight)
|
||||
self.Scroller.Draw()
|
||||
|
||||
} else {
|
||||
self.Ps.(*ListPageSelector).Width = self.Width
|
||||
self.Ps.Draw()
|
||||
|
||||
for _, v := range self.MyList {
|
||||
if v.(*TimeZoneListPageListItem).PosY > self.Height+self.Height/2 {
|
||||
break
|
||||
}
|
||||
if v.(*TimeZoneListPageListItem).PosY < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
v.Draw()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
package Update
|
||||
|
||||
import (
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
/******************************************************************************/
|
||||
type UpdatePlugin struct {
|
||||
UI.Plugin
|
||||
Page UI.PageInterface
|
||||
}
|
||||
|
||||
|
||||
func (self *UpdatePlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *UpdatePlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.Page = NewUpdatePage()
|
||||
self.Page.SetScreen( main_screen)
|
||||
self.Page.SetScreen(main_screen)
|
||||
self.Page.SetName("Update LauncherGo")
|
||||
self.Page.Init()
|
||||
}
|
||||
|
||||
func (self *UpdatePlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *UpdatePlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushPage(self.Page)
|
||||
main_screen.Draw()
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
package Update
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"bytes"
|
||||
"strings"
|
||||
gotime "time"
|
||||
"os/exec"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/cuu/gogame/time"
|
||||
// "github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
//"github.com/cuu/gogame/rect"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"strings"
|
||||
gotime "time"
|
||||
// "github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
//"github.com/cuu/gogame/rect"
|
||||
//"github.com/cuu/gogame/color"
|
||||
// "github.com/cuu/gogame/font"
|
||||
// "github.com/cuu/gogame/font"
|
||||
//"github.com/cuu/gogame/draw"
|
||||
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
var InfoPageListItemDefaultHeight = 30
|
||||
var launchergo_path = "/home/cpi/launchergo"
|
||||
|
||||
type UpdateConfirmPage struct {
|
||||
UI.ConfirmPage
|
||||
|
||||
URL string
|
||||
MD5 string
|
||||
Version string
|
||||
GIT bool
|
||||
UI.ConfirmPage
|
||||
|
||||
URL string
|
||||
MD5 string
|
||||
Version string
|
||||
GIT bool
|
||||
}
|
||||
|
||||
func NewUpdateConfirmPage() *UpdateConfirmPage {
|
||||
p := &UpdateConfirmPage{}
|
||||
|
||||
p.ListFont = UI.Fonts["veramono20"]
|
||||
p.FootMsg = [5]string{"Nav","","","Cancel","Yes"}
|
||||
p.ConfirmText = "Confirm Update?"
|
||||
p := &UpdateConfirmPage{}
|
||||
|
||||
return p
|
||||
p.ListFont = UI.Fonts["veramono20"]
|
||||
p.FootMsg = [5]string{"Nav", "", "", "Cancel", "Yes"}
|
||||
p.ConfirmText = "Confirm Update?"
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *UpdateConfirmPage) KeyDown(ev *event.Event) {
|
||||
@@ -50,210 +50,208 @@ func (self *UpdateConfirmPage) KeyDown(ev *event.Event) {
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
fmt.Println("Update Confirm Page B",self.GIT)
|
||||
if self.GIT == true {
|
||||
//go exec requires FullPath of script filename
|
||||
cmdpath := fmt.Sprintf("%s/update.sh %s",UI.GetExePath(),self.Version)
|
||||
event.Post(UI.RUNSH,cmdpath)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
fmt.Println("Update Confirm Page B", self.GIT)
|
||||
if self.GIT == true {
|
||||
//go exec requires FullPath of script filename
|
||||
cmdpath := fmt.Sprintf("%s/update.sh %s", UI.GetExePath(), self.Version)
|
||||
event.Post(UI.RUNSH, cmdpath)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *UpdateConfirmPage) OnReturnBackCb() {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
func (self *UpdateConfirmPage) Draw() {
|
||||
self.ClearCanvas()
|
||||
self.DrawBG()
|
||||
for _,v := range self.MyList{
|
||||
v.Draw()
|
||||
}
|
||||
self.Reset()
|
||||
self.ClearCanvas()
|
||||
self.DrawBG()
|
||||
for _, v := range self.MyList {
|
||||
v.Draw()
|
||||
}
|
||||
self.Reset()
|
||||
}
|
||||
|
||||
type UpdatePage struct {
|
||||
UI.Page
|
||||
AList map[string]map[string]string
|
||||
ListFontObj *ttf.Font
|
||||
MyList []*UI.InfoPageListItem
|
||||
ConfirmPage *UpdateConfirmPage
|
||||
UI.Page
|
||||
AList map[string]map[string]string
|
||||
ListFontObj *ttf.Font
|
||||
MyList []*UI.InfoPageListItem
|
||||
ConfirmPage *UpdateConfirmPage
|
||||
}
|
||||
|
||||
func NewUpdatePage() *UpdatePage {
|
||||
p := &UpdatePage{}
|
||||
p.FootMsg = [5]string{ "Nav","Check Update","","Back","" }
|
||||
p := &UpdatePage{}
|
||||
p.FootMsg = [5]string{"Nav", "Check Update", "", "Back", ""}
|
||||
p.PageIconMargin = 20
|
||||
p.SelectedIconTopOffset = 20
|
||||
p.EasingDur = 10
|
||||
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
p.ListFontObj = UI.Fonts["varela15"]
|
||||
|
||||
p.AList = make( map[string]map[string]string )
|
||||
|
||||
return p
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
p.ListFontObj = UI.Fonts["varela15"]
|
||||
|
||||
p.AList = make(map[string]map[string]string)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *UpdatePage) GenList() {
|
||||
self.MyList = nil
|
||||
self.MyList = make([]*UI.InfoPageListItem,0)
|
||||
self.MyList = nil
|
||||
self.MyList = make([]*UI.InfoPageListItem, 0)
|
||||
|
||||
start_x := 0
|
||||
start_y := 0
|
||||
i := 0
|
||||
|
||||
for k,_ := range self.AList {
|
||||
li := UI.NewInfoPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + i*InfoPageListItemDefaultHeight
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFontObj
|
||||
li.Fonts["small"] = UI.Fonts["varela12"]
|
||||
|
||||
if self.AList[k]["label"] != "" {
|
||||
li.Init(self.AList[k]["label"])
|
||||
}else {
|
||||
li.Init(self.AList[k]["key"] )
|
||||
}
|
||||
|
||||
li.Flag = self.AList[k]["key"]
|
||||
|
||||
li.SetSmallText( self.AList[k]["value"])
|
||||
|
||||
self.MyList = append(self.MyList,li)
|
||||
|
||||
i+=1
|
||||
}
|
||||
start_x := 0
|
||||
start_y := 0
|
||||
i := 0
|
||||
|
||||
for k, _ := range self.AList {
|
||||
li := UI.NewInfoPageListItem()
|
||||
li.Parent = self
|
||||
li.PosX = start_x
|
||||
li.PosY = start_y + i*InfoPageListItemDefaultHeight
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFontObj
|
||||
li.Fonts["small"] = UI.Fonts["varela12"]
|
||||
|
||||
if self.AList[k]["label"] != "" {
|
||||
li.Init(self.AList[k]["label"])
|
||||
} else {
|
||||
li.Init(self.AList[k]["key"])
|
||||
}
|
||||
|
||||
li.Flag = self.AList[k]["key"]
|
||||
|
||||
li.SetSmallText(self.AList[k]["value"])
|
||||
|
||||
self.MyList = append(self.MyList, li)
|
||||
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
|
||||
func (self *UpdatePage) Init() {
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
self.ConfirmPage = NewUpdateConfirmPage()
|
||||
self.ConfirmPage.Screen = self.Screen
|
||||
self.ConfirmPage.Name = "Update Confirm"
|
||||
self.ConfirmPage.Init()
|
||||
|
||||
it := make(map[string]string)
|
||||
it["key"] = "version"
|
||||
it["label"] = "Version"
|
||||
it["value"] = sysgo.VERSION
|
||||
|
||||
self.AList["version"] = it
|
||||
|
||||
self.GenList()
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
self.ConfirmPage = NewUpdateConfirmPage()
|
||||
self.ConfirmPage.Screen = self.Screen
|
||||
self.ConfirmPage.Name = "Update Confirm"
|
||||
self.ConfirmPage.Init()
|
||||
|
||||
it := make(map[string]string)
|
||||
it["key"] = "version"
|
||||
it["label"] = "Version"
|
||||
it["value"] = sysgo.VERSION
|
||||
|
||||
self.AList["version"] = it
|
||||
|
||||
self.GenList()
|
||||
}
|
||||
|
||||
func (self *UpdatePage) CheckUpdate() bool {
|
||||
self.Screen.MsgBox.SetText("Checking Update")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
self.Screen.MsgBox.SetText("Checking Update")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
type Response struct {
|
||||
GitVersion string `json:"gitversion"`
|
||||
}
|
||||
|
||||
|
||||
timeout := gotime.Duration(8 * gotime.Second)
|
||||
client := http.Client{
|
||||
Timeout: timeout,
|
||||
}
|
||||
type Response struct {
|
||||
GitVersion string `json:"gitversion"`
|
||||
}
|
||||
|
||||
resp, err := client.Get(sysgo.UPDATE_URL)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return false
|
||||
}
|
||||
var ret Response
|
||||
buf := new(bytes.Buffer)
|
||||
timeout := gotime.Duration(8 * gotime.Second)
|
||||
client := http.Client{
|
||||
Timeout: timeout,
|
||||
}
|
||||
|
||||
resp, err := client.Get(sysgo.UPDATE_URL)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return false
|
||||
}
|
||||
var ret Response
|
||||
buf := new(bytes.Buffer)
|
||||
buf.ReadFrom(resp.Body)
|
||||
respByte := buf.Bytes()
|
||||
if err := json.Unmarshal(respByte, &ret); err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Println(err)
|
||||
return false
|
||||
}
|
||||
|
||||
fmt.Println("got git version :", ret.GitVersion)
|
||||
|
||||
launchergo_git_rev_parse := exec.Command("git", "rev-parse", "--short", "HEAD")
|
||||
launchergo_git_rev_parse.Dir = launchergo_path
|
||||
var out bytes.Buffer
|
||||
fmt.Println("got git version :", ret.GitVersion)
|
||||
|
||||
launchergo_git_rev_parse := exec.Command("git", "rev-parse", "--short", "HEAD")
|
||||
launchergo_git_rev_parse.Dir = launchergo_path
|
||||
var out bytes.Buffer
|
||||
launchergo_git_rev_parse.Stdout = &out
|
||||
err = launchergo_git_rev_parse.Run()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return false
|
||||
}
|
||||
|
||||
git_revision_short_hash := strings.Trim(out.String(), "\r\n ")
|
||||
|
||||
if git_revision_short_hash != ret.GitVersion {
|
||||
self.ConfirmPage.Version = ret.GitVersion
|
||||
self.ConfirmPage.GIT = true
|
||||
self.Screen.PushCurPage()
|
||||
self.Screen.SetCurPage(self.ConfirmPage)
|
||||
|
||||
self.Screen.Draw()
|
||||
|
||||
self.ConfirmPage.SnapMsg( fmt.Sprintf("Update to %s?",ret.GitVersion))
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
}else {
|
||||
self.Screen.Draw()
|
||||
self.Screen.MsgBox.SetText("Launchergo is up to date")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
time.BlockDelay(765)
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
|
||||
return true
|
||||
|
||||
err = launchergo_git_rev_parse.Run()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return false
|
||||
}
|
||||
|
||||
git_revision_short_hash := strings.Trim(out.String(), "\r\n ")
|
||||
|
||||
if git_revision_short_hash != ret.GitVersion {
|
||||
self.ConfirmPage.Version = ret.GitVersion
|
||||
self.ConfirmPage.GIT = true
|
||||
self.Screen.PushCurPage()
|
||||
self.Screen.SetCurPage(self.ConfirmPage)
|
||||
|
||||
self.Screen.Draw()
|
||||
|
||||
self.ConfirmPage.SnapMsg(fmt.Sprintf("Update to %s?", ret.GitVersion))
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
} else {
|
||||
self.Screen.Draw()
|
||||
self.Screen.MsgBox.SetText("Launchergo is up to date")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
time.BlockDelay(765)
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
func (self *UpdatePage) KeyDown(ev *event.Event) {
|
||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["X"] {
|
||||
if self.Screen.IsWifiConnectedNow() == true {
|
||||
if self.CheckUpdate() == true {
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}else {
|
||||
self.Screen.Draw()
|
||||
self.Screen.MsgBox.SetText("Check Update Failed")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
}else {
|
||||
self.Screen.Draw()
|
||||
self.Screen.MsgBox.SetText("Please Check your Wi-Fi connection")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
}
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["X"] {
|
||||
if self.Screen.IsWifiConnectedNow() == true {
|
||||
if self.CheckUpdate() == true {
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
} else {
|
||||
self.Screen.Draw()
|
||||
self.Screen.MsgBox.SetText("Check Update Failed")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
} else {
|
||||
self.Screen.Draw()
|
||||
self.Screen.MsgBox.SetText("Please Check your Wi-Fi connection")
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *UpdatePage) Draw() {
|
||||
self.ClearCanvas()
|
||||
for _,v := range self.MyList {
|
||||
v.Draw()
|
||||
}
|
||||
self.ClearCanvas()
|
||||
for _, v := range self.MyList {
|
||||
v.Draw()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,51 +1,50 @@
|
||||
package Wifi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
//"strconv"
|
||||
//"strings"
|
||||
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
|
||||
"fmt"
|
||||
//"strconv"
|
||||
//"strings"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
)
|
||||
|
||||
var NetItemDefaultHeight = 30
|
||||
|
||||
type NetItemMultiIcon struct {
|
||||
UI.MultiIconItem
|
||||
CanvasHWND *sdl.Surface // self._Parent._CanvasHWND
|
||||
CanvasHWND *sdl.Surface // self._Parent._CanvasHWND
|
||||
Parent UI.WidgetInterface //
|
||||
}
|
||||
|
||||
func NewNetItemMultiIcon() *NetItemMultiIcon{
|
||||
p := &NetItemMultiIcon{}
|
||||
p.IconIndex = 0
|
||||
p.IconWidth = 18
|
||||
p.IconHeight = 18
|
||||
|
||||
p.Width = 18
|
||||
p.Height = 18
|
||||
return p
|
||||
func NewNetItemMultiIcon() *NetItemMultiIcon {
|
||||
p := &NetItemMultiIcon{}
|
||||
p.IconIndex = 0
|
||||
p.IconWidth = 18
|
||||
p.IconHeight = 18
|
||||
|
||||
p.Width = 18
|
||||
p.Height = 18
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *NetItemMultiIcon) Draw() {
|
||||
_,h_ := self.Parent.Size()
|
||||
dest_rect := rect.Rect(self.PosX,self.PosY+(h_-self.Height)/2, self.Width,self.Height)
|
||||
area_rect := rect.Rect(0,self.IconIndex*self.IconHeight,self.IconWidth,self.IconHeight)
|
||||
surface.Blit(self.CanvasHWND,self.ImgSurf,&dest_rect,&area_rect)
|
||||
|
||||
_, h_ := self.Parent.Size()
|
||||
dest_rect := rect.Rect(self.PosX, self.PosY+(h_-self.Height)/2, self.Width, self.Height)
|
||||
area_rect := rect.Rect(0, self.IconIndex*self.IconHeight, self.IconWidth, self.IconHeight)
|
||||
surface.Blit(self.CanvasHWND, self.ImgSurf, &dest_rect, &area_rect)
|
||||
|
||||
}
|
||||
|
||||
type NetItemIcon struct {
|
||||
UI.IconItem
|
||||
CanvasHWND *sdl.Surface
|
||||
Parent UI.WidgetInterface
|
||||
Parent UI.WidgetInterface
|
||||
}
|
||||
|
||||
func NewNetItemIcon() *NetItemIcon {
|
||||
@@ -56,202 +55,196 @@ func NewNetItemIcon() *NetItemIcon {
|
||||
}
|
||||
|
||||
func (self *NetItemIcon) Draw() {
|
||||
_,h_ := self.Parent.Size()
|
||||
_, h_ := self.Parent.Size()
|
||||
|
||||
dest_rect := rect.Rect(self.PosX,self.PosY+(h_-self.Height)/2,self.Width,self.Height)
|
||||
dest_rect := rect.Rect(self.PosX, self.PosY+(h_-self.Height)/2, self.Width, self.Height)
|
||||
|
||||
surface.Blit(self.CanvasHWND, self.ImgSurf, &dest_rect, nil)
|
||||
|
||||
surface.Blit(self.CanvasHWND,self.ImgSurf,&dest_rect,nil)
|
||||
|
||||
}
|
||||
|
||||
|
||||
type NetItem struct {
|
||||
UI.Widget
|
||||
|
||||
Bssid string //eg: 50:3A:A0:51:18:3C
|
||||
Essid string //eg: MERCURY_EB88
|
||||
|
||||
ip string
|
||||
Encrypt string // WPA2
|
||||
Channel string //'10'
|
||||
Signal int16 // -67
|
||||
Mode string // Master or AdHoc
|
||||
Parent *WifiList
|
||||
IsActive bool
|
||||
Password string
|
||||
Labels map[string]UI.LabelInterface
|
||||
Icons map[string]UI.IconItemInterface
|
||||
Fonts map[string]*ttf.Font
|
||||
FontObj *ttf.Font
|
||||
|
||||
|
||||
ip string
|
||||
Encrypt string // WPA2
|
||||
Channel string //'10'
|
||||
Signal int16 // -67
|
||||
Mode string // Master or AdHoc
|
||||
Parent *WifiList
|
||||
IsActive bool
|
||||
Password string
|
||||
Labels map[string]UI.LabelInterface
|
||||
Icons map[string]UI.IconItemInterface
|
||||
Fonts map[string]*ttf.Font
|
||||
FontObj *ttf.Font
|
||||
}
|
||||
|
||||
func NewNetItem() *NetItem {
|
||||
p := &NetItem{}
|
||||
|
||||
p.Height = NetItemDefaultHeight
|
||||
|
||||
p.Height = NetItemDefaultHeight
|
||||
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
p.Icons = make( map[string]UI.IconItemInterface)
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
p.Fonts = make(map[string]*ttf.Font)
|
||||
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *NetItem) SetActive( act bool) {
|
||||
func (self *NetItem) SetActive(act bool) {
|
||||
self.IsActive = act
|
||||
}
|
||||
|
||||
func (self *NetItem) UpdateStrenLabel() { // ## sig_str should be 'number',eg:'-70'
|
||||
|
||||
|
||||
if _, ok := self.Labels["stren"]; ok {
|
||||
self.Labels["stren"].SetText( fmt.Sprintf("%d",self.CalcWifiQuality()) )
|
||||
self.Labels["stren"].SetText(fmt.Sprintf("%d", self.CalcWifiQuality()))
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
func (self *NetItem) Init(is_active bool) {
|
||||
|
||||
//strenstr := "quality"
|
||||
//gap := 7
|
||||
|
||||
the_main_screen := self.Parent.GetScreen()
|
||||
|
||||
if is_active {
|
||||
self.SetActive(is_active)
|
||||
}
|
||||
//strenstr := "quality"
|
||||
//gap := 7
|
||||
|
||||
|
||||
essid_label := UI.NewLabel()
|
||||
essid_label.PosX = 36
|
||||
essid_label.CanvasHWND = self.Parent.GetCanvasHWND()
|
||||
the_main_screen := self.Parent.GetScreen()
|
||||
|
||||
essid_ := ""
|
||||
|
||||
if len(self.Essid) > 19 {
|
||||
if is_active {
|
||||
self.SetActive(is_active)
|
||||
}
|
||||
|
||||
essid_label := UI.NewLabel()
|
||||
essid_label.PosX = 36
|
||||
essid_label.CanvasHWND = self.Parent.GetCanvasHWND()
|
||||
|
||||
essid_ := ""
|
||||
|
||||
if len(self.Essid) > 19 {
|
||||
essid_ = self.Essid[:20]
|
||||
}else {
|
||||
} else {
|
||||
essid_ = self.Essid
|
||||
}
|
||||
}
|
||||
|
||||
if len(essid_) == 0 {
|
||||
essid_ = self.Bssid
|
||||
}
|
||||
|
||||
|
||||
if len(essid_) == 0 {
|
||||
essid_ = EMPTY_NETWORK
|
||||
}
|
||||
|
||||
|
||||
//fmt.Println("essid: ",essid_, len(essid_))
|
||||
|
||||
essid_label.Init(essid_, self.FontObj,nil)
|
||||
|
||||
self.Labels["essid"] = essid_label
|
||||
|
||||
stren_label := UI.NewLabel()
|
||||
stren_label.CanvasHWND = self.Parent.GetCanvasHWND()
|
||||
essid_label.Init(essid_, self.FontObj, nil)
|
||||
|
||||
stren_l := fmt.Sprintf("%%%d ",self.CalcWifiQuality())
|
||||
self.Labels["essid"] = essid_label
|
||||
|
||||
stren_label := UI.NewLabel()
|
||||
stren_label.CanvasHWND = self.Parent.GetCanvasHWND()
|
||||
|
||||
stren_l := fmt.Sprintf("%%%d ", self.CalcWifiQuality())
|
||||
if len(stren_l) == 0 {
|
||||
stren_l = "%%0"
|
||||
}
|
||||
stren_label.Init(stren_l, self.FontObj,nil)
|
||||
stren_label.PosX = self.Width - 23 - stren_label.Width-2
|
||||
stren_label.Init(stren_l, self.FontObj, nil)
|
||||
stren_label.PosX = self.Width - 23 - stren_label.Width - 2
|
||||
|
||||
self.Labels["stren"] = stren_label
|
||||
self.Labels["stren"] = stren_label
|
||||
|
||||
lock_icon := NewNetItemIcon()
|
||||
lock_icon.ImgSurf = UI.MyIconPool.GetImgSurf("lock")
|
||||
lock_icon.CanvasHWND = self.Parent.GetCanvasHWND()
|
||||
lock_icon.Parent = self // WidgetInterface
|
||||
self.Icons["lock"] = lock_icon
|
||||
lock_icon := NewNetItemIcon()
|
||||
lock_icon.ImgSurf = UI.MyIconPool.GetImgSurf("lock")
|
||||
lock_icon.CanvasHWND = self.Parent.GetCanvasHWND()
|
||||
lock_icon.Parent = self // WidgetInterface
|
||||
self.Icons["lock"] = lock_icon
|
||||
|
||||
done_icon := NewNetItemIcon()
|
||||
done_icon.ImgSurf = UI.MyIconPool.GetImgSurf("done")
|
||||
done_icon.CanvasHWND = self.Parent.GetCanvasHWND()
|
||||
done_icon.Parent = self
|
||||
done_icon := NewNetItemIcon()
|
||||
done_icon.ImgSurf = UI.MyIconPool.GetImgSurf("done")
|
||||
done_icon.CanvasHWND = self.Parent.GetCanvasHWND()
|
||||
done_icon.Parent = self
|
||||
|
||||
self.Icons["done"] = done_icon
|
||||
self.Icons["done"] = done_icon
|
||||
|
||||
nimt := NewNetItemMultiIcon()
|
||||
nimt.ImgSurf = the_main_screen.TitleBar.Icons["wifistatus"].GetImgSurf()
|
||||
nimt.CanvasHWND = self.Parent.GetCanvasHWND()
|
||||
nimt.Parent = self // WidgetInterface
|
||||
nimt := NewNetItemMultiIcon()
|
||||
nimt.ImgSurf = the_main_screen.TitleBar.Icons["wifistatus"].GetImgSurf()
|
||||
nimt.CanvasHWND = self.Parent.GetCanvasHWND()
|
||||
nimt.Parent = self // WidgetInterface
|
||||
|
||||
self.Icons["wifistatus"] = nimt
|
||||
self.Icons["wifistatus"] = nimt
|
||||
}
|
||||
|
||||
|
||||
func (self *NetItem) Connect() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
func (self *NetItem) CalcWifiQuality() int {
|
||||
|
||||
qua := 0
|
||||
qua = 2 * (int(self.Signal) + 100)
|
||||
|
||||
return qua
|
||||
qua := 0
|
||||
qua = 2 * (int(self.Signal) + 100)
|
||||
|
||||
return qua
|
||||
}
|
||||
|
||||
func (self *NetItem) CalcWifiStrength() int {
|
||||
|
||||
segs := [][]int{ []int{-2,-1}, []int{0,25}, []int{25,50}, []int{50,75},[]int{75,100}}
|
||||
stren_number := self.CalcWifiQuality()
|
||||
ge := 0
|
||||
if stren_number == 0 {
|
||||
return ge
|
||||
}
|
||||
|
||||
for i,v := range segs {
|
||||
if stren_number >= v[0] && stren_number <= v[1] {
|
||||
ge = i
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return ge
|
||||
|
||||
segs := [][]int{[]int{-2, -1}, []int{0, 25}, []int{25, 50}, []int{50, 75}, []int{75, 100}}
|
||||
stren_number := self.CalcWifiQuality()
|
||||
ge := 0
|
||||
if stren_number == 0 {
|
||||
return ge
|
||||
}
|
||||
|
||||
for i, v := range segs {
|
||||
if stren_number >= v[0] && stren_number <= v[1] {
|
||||
ge = i
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return ge
|
||||
|
||||
}
|
||||
|
||||
func (self *NetItem) Draw() {
|
||||
for i,v := range self.Labels {
|
||||
x_,_ := v.Coord()
|
||||
_,h_ := v.Size()
|
||||
self.Labels[i].NewCoord(x_,self.PosY+(self.Height - h_)/2)
|
||||
for i, v := range self.Labels {
|
||||
x_, _ := v.Coord()
|
||||
_, h_ := v.Size()
|
||||
self.Labels[i].NewCoord(x_, self.PosY+(self.Height-h_)/2)
|
||||
self.Labels[i].Draw()
|
||||
}
|
||||
}
|
||||
|
||||
if self.IsActive == true {
|
||||
self.Icons["done"].NewCoord(14,self.PosY)
|
||||
if self.IsActive == true {
|
||||
self.Icons["done"].NewCoord(14, self.PosY)
|
||||
self.Icons["done"].Draw()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if self.Encrypt != "Unsecured" {
|
||||
w_,_ := self.Labels["stren"].Size()
|
||||
self.Icons["lock"].NewCoord(self.Width -23 - w_ -2 - 18, self.PosY)
|
||||
self.Icons["lock"].Draw()
|
||||
}
|
||||
*/
|
||||
//the_main_screen := self.Parent.GetScreen()
|
||||
ge := self.CalcWifiStrength()
|
||||
if ge > 0 {
|
||||
self.Icons["wifistatus"].SetIconIndex(ge)
|
||||
self.Icons["wifistatus"].NewCoord(self.Width-23,self.PosY)
|
||||
/*
|
||||
if self.Encrypt != "Unsecured" {
|
||||
w_,_ := self.Labels["stren"].Size()
|
||||
self.Icons["lock"].NewCoord(self.Width -23 - w_ -2 - 18, self.PosY)
|
||||
self.Icons["lock"].Draw()
|
||||
}
|
||||
*/
|
||||
//the_main_screen := self.Parent.GetScreen()
|
||||
ge := self.CalcWifiStrength()
|
||||
if ge > 0 {
|
||||
self.Icons["wifistatus"].SetIconIndex(ge)
|
||||
self.Icons["wifistatus"].NewCoord(self.Width-23, self.PosY)
|
||||
self.Icons["wifistatus"].Draw()
|
||||
}else {
|
||||
} else {
|
||||
self.Icons["wifistatus"].SetIconIndex(0)
|
||||
self.Icons["wifistatus"].NewCoord(self.Width-23,self.PosY)
|
||||
self.Icons["wifistatus"].NewCoord(self.Width-23, self.PosY)
|
||||
self.Icons["wifistatus"].Draw()
|
||||
}
|
||||
}
|
||||
|
||||
draw.Line(self.Parent.GetCanvasHWND(),
|
||||
&color.Color{169,169,169,255},
|
||||
self.PosX,self.PosY+self.Height-1,
|
||||
self.PosX+self.Width,self.PosY+self.Height-1,
|
||||
draw.Line(self.Parent.GetCanvasHWND(),
|
||||
&color.Color{169, 169, 169, 255},
|
||||
self.PosX, self.PosY+self.Height-1,
|
||||
self.PosX+self.Width, self.PosY+self.Height-1,
|
||||
1)
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,61 +1,59 @@
|
||||
package Wifi
|
||||
|
||||
import (
|
||||
//gotime "time"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
//gotime "time"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||
wifi "github.com/cuu/wpa-connect"
|
||||
|
||||
)
|
||||
|
||||
/******************************************************************************/
|
||||
type WifiPlugin struct {
|
||||
UI.Plugin
|
||||
ScanPage *WifiList
|
||||
PasswordPage *UI.Keyboard
|
||||
ScanPage *WifiList
|
||||
PasswordPage *UI.Keyboard
|
||||
}
|
||||
|
||||
var (
|
||||
GsScanManager = wifi.NewScanManager(sysgo.WifiDev)
|
||||
GsScanManager = wifi.NewScanManager(sysgo.WifiDev)
|
||||
GsConnectManager = wifi.NewConnectManager(sysgo.WifiDev)
|
||||
)
|
||||
|
||||
func (self *WifiPlugin) Init(main_screen *UI.MainScreen) {
|
||||
|
||||
self.PasswordPage = UI.NewKeyboard()
|
||||
self.PasswordPage.Name = "Enter wifi password"
|
||||
self.PasswordPage.Screen = main_screen
|
||||
self.PasswordPage.Init()
|
||||
|
||||
self.ScanPage = NewWifiList()
|
||||
self.ScanPage.Name = "Scan wifi"
|
||||
|
||||
self.ScanPage.Screen = main_screen
|
||||
|
||||
self.PasswordPage.Caller = self.ScanPage
|
||||
|
||||
self.ScanPage.Init()
|
||||
|
||||
func (self *WifiPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
|
||||
self.PasswordPage = UI.NewKeyboard()
|
||||
self.PasswordPage.Name = "Enter wifi password"
|
||||
self.PasswordPage.Screen= main_screen
|
||||
self.PasswordPage.Init()
|
||||
|
||||
self.ScanPage = NewWifiList()
|
||||
self.ScanPage.Name = "Scan wifi"
|
||||
|
||||
self.ScanPage.Screen = main_screen
|
||||
|
||||
self.PasswordPage.Caller = self.ScanPage
|
||||
|
||||
self.ScanPage.Init()
|
||||
|
||||
}
|
||||
|
||||
func (self *WifiPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.ScanPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
func (self *WifiPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.ScanPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
}
|
||||
|
||||
var APIOBJ WifiPlugin
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,14 @@
|
||||
package TinyCloud
|
||||
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||
)
|
||||
@@ -16,21 +16,20 @@ import (
|
||||
/******************************************************************************/
|
||||
type TinyCloudPlugin struct {
|
||||
UI.Plugin
|
||||
MainPage *TinyCloudPage
|
||||
|
||||
MainPage *TinyCloudPage
|
||||
}
|
||||
|
||||
func (self *TinyCloudPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *TinyCloudPlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.MainPage = NewTinyCloudPage()
|
||||
self.MainPage.SetScreen( main_screen)
|
||||
self.MainPage.SetScreen(main_screen)
|
||||
self.MainPage.SetName("Tiny cloud")
|
||||
self.MainPage.Init()
|
||||
self.MainPage.Init()
|
||||
}
|
||||
|
||||
func (self *TinyCloudPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *TinyCloudPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.MainPage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.MainPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
@@ -1,215 +1,209 @@
|
||||
package TinyCloud
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"fmt"
|
||||
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
|
||||
"github.com/cuu/gogame/color"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/color"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
type TinyCloudLabel struct {
|
||||
Key string
|
||||
Lable string
|
||||
Font *ttf.Font
|
||||
Color *color.Color
|
||||
|
||||
Key string
|
||||
Lable string
|
||||
Font *ttf.Font
|
||||
Color *color.Color
|
||||
}
|
||||
|
||||
type TinyCloudPage struct {
|
||||
UI.Page
|
||||
ListFontObj *ttf.Font
|
||||
URLColor *color.Color
|
||||
TextColor *color.Color
|
||||
Labels map[string]UI.LabelInterface
|
||||
Icons map[string]UI.IconItemInterface
|
||||
UI.Page
|
||||
ListFontObj *ttf.Font
|
||||
URLColor *color.Color
|
||||
TextColor *color.Color
|
||||
Labels map[string]UI.LabelInterface
|
||||
Icons map[string]UI.IconItemInterface
|
||||
|
||||
Coords map[string]UI.Coord
|
||||
IP string
|
||||
|
||||
PngSize map[string]UI.Plane
|
||||
Coords map[string]UI.Coord
|
||||
IP string
|
||||
|
||||
PngSize map[string]UI.Plane
|
||||
}
|
||||
|
||||
func NewTinyCloudPage() *TinyCloudPage {
|
||||
p := &TinyCloudPage{}
|
||||
p.PageIconMargin = 20
|
||||
p := &TinyCloudPage{}
|
||||
p.PageIconMargin = 20
|
||||
p.SelectedIconTopOffset = 20
|
||||
p.EasingDur = 10
|
||||
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.FootMsg = [5]string{"Nav.","","","Back",""}
|
||||
|
||||
p.Coords = make(map[string]UI.Coord)
|
||||
p.PngSize = make(map[string]UI.Plane)
|
||||
|
||||
p.URLColor = UI.MySkinManager.GiveColor("URL")
|
||||
p.TextColor = UI.MySkinManager.GiveColor("Text")
|
||||
p.ListFontObj = UI.MyLangManager.TrFont("varela13")
|
||||
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
|
||||
return p
|
||||
p.FootMsg = [5]string{"Nav.", "", "", "Back", ""}
|
||||
|
||||
p.Coords = make(map[string]UI.Coord)
|
||||
p.PngSize = make(map[string]UI.Plane)
|
||||
|
||||
p.URLColor = UI.MySkinManager.GiveColor("URL")
|
||||
p.TextColor = UI.MySkinManager.GiveColor("Text")
|
||||
p.ListFontObj = UI.MyLangManager.TrFont("varela13")
|
||||
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *TinyCloudPage) OnLoadCb() {
|
||||
self.PosY = 0
|
||||
self.PosY = 0
|
||||
}
|
||||
|
||||
func (self *TinyCloudPage) SetCoords() {
|
||||
self.Coords["forID"] = UI.Coord{15,11}
|
||||
|
||||
self.Coords["forKey"] = UI.Coord{71,self.Coords["forID"].Y}
|
||||
|
||||
self.Coords["key_and_pass"] = UI.Coord{36, self.Coords["forID"].Y}
|
||||
|
||||
self.Coords["forssh"] = UI.Coord{self.Coords["forID"].X,36}
|
||||
|
||||
self.Coords["ssh_addr"] = UI.Coord{self.Coords["forID"].X,54}
|
||||
|
||||
self.Coords["forwin"] = UI.Coord{self.Coords["forID"].X,80}
|
||||
|
||||
self.Coords["samba_games"] = UI.Coord{ self.Coords["forID"].X,97}
|
||||
|
||||
self.Coords["samba_music"] = UI.Coord{ self.Coords["samba_games"].X,115}
|
||||
self.Coords["forID"] = UI.Coord{15, 11}
|
||||
|
||||
self.Coords["for_airplay"] = UI.Coord{ self.Coords["forID"].X,140}
|
||||
|
||||
self.Coords["airplay_name"] = UI.Coord{ 68,self.Coords["for_airplay"].Y}
|
||||
self.Coords["forKey"] = UI.Coord{71, self.Coords["forID"].Y}
|
||||
|
||||
self.Coords["for-usb-eth"] = UI.Coord{ self.Coords["forID"].X,163}
|
||||
|
||||
self.Coords["usb-eth-addr"] = UI.Coord{ 112,self.Coords["for-usb-eth"].Y}
|
||||
|
||||
self.Coords["bg"] = UI.Coord{ self.Width/2,self.Height/2 }
|
||||
|
||||
self.Coords["online"] = UI.Coord{ 266, 99 }
|
||||
self.Coords["key_and_pass"] = UI.Coord{36, self.Coords["forID"].Y}
|
||||
|
||||
self.Coords["forssh"] = UI.Coord{self.Coords["forID"].X, 36}
|
||||
|
||||
self.Coords["ssh_addr"] = UI.Coord{self.Coords["forID"].X, 54}
|
||||
|
||||
self.Coords["forwin"] = UI.Coord{self.Coords["forID"].X, 80}
|
||||
|
||||
self.Coords["samba_games"] = UI.Coord{self.Coords["forID"].X, 97}
|
||||
|
||||
self.Coords["samba_music"] = UI.Coord{self.Coords["samba_games"].X, 115}
|
||||
|
||||
self.Coords["for_airplay"] = UI.Coord{self.Coords["forID"].X, 140}
|
||||
|
||||
self.Coords["airplay_name"] = UI.Coord{68, self.Coords["for_airplay"].Y}
|
||||
|
||||
self.Coords["for-usb-eth"] = UI.Coord{self.Coords["forID"].X, 163}
|
||||
|
||||
self.Coords["usb-eth-addr"] = UI.Coord{112, self.Coords["for-usb-eth"].Y}
|
||||
|
||||
self.Coords["bg"] = UI.Coord{self.Width / 2, self.Height / 2}
|
||||
|
||||
self.Coords["online"] = UI.Coord{266, 99}
|
||||
|
||||
}
|
||||
|
||||
func (self *TinyCloudPage) SetLabels() {
|
||||
if self.Screen.IsWifiConnectedNow() {
|
||||
self.IP = self.Screen.GetWirelessIP()
|
||||
fmt.Printf("TinyCould : %s\n",self.IP)
|
||||
}else {
|
||||
self.IP = "xxx.xxx.xxx.xxx"
|
||||
}
|
||||
|
||||
|
||||
labels := []*TinyCloudLabel{
|
||||
&TinyCloudLabel{"forssh","For ssh and scp:",self.ListFontObj,self.TextColor},
|
||||
&TinyCloudLabel{"ssh_addr",fmt.Sprintf("ssh cpi@%s",self.IP), self.ListFontObj,self.URLColor},
|
||||
&TinyCloudLabel{"forwin", "For Windows network:", self.ListFontObj, self.TextColor},
|
||||
&TinyCloudLabel{"samba_games", fmt.Sprintf("\\\\%s\\games", self.IP), self.ListFontObj,self.URLColor},
|
||||
&TinyCloudLabel{"samba_music", fmt.Sprintf("\\\\%s\\music" , self.IP), self.ListFontObj,self.URLColor},
|
||||
&TinyCloudLabel{"forID", "ID:", self.ListFontObj, self.TextColor},
|
||||
&TinyCloudLabel{"forKey", "Key:", self.ListFontObj, self.TextColor},
|
||||
&TinyCloudLabel{"key_and_pass", "cpi", self.ListFontObj, self.URLColor},
|
||||
&TinyCloudLabel{"for_airplay", "Airplay:", self.ListFontObj, self.TextColor},
|
||||
&TinyCloudLabel{"airplay_name","clockworkpi", self.ListFontObj, self.URLColor},
|
||||
&TinyCloudLabel{"for-usb-eth","USB-Ethernet:", self.ListFontObj, self.TextColor},
|
||||
&TinyCloudLabel{"usb-eth-addr","192.168.10.1", self.ListFontObj, self.URLColor},
|
||||
}
|
||||
|
||||
for _,v := range labels {
|
||||
l := UI.NewLabel()
|
||||
l.SetCanvasHWND(self.CanvasHWND)
|
||||
l.Init(v.Lable,v.Font,nil)
|
||||
l.SetColor(v.Color)
|
||||
self.Labels[v.Key] = l
|
||||
}
|
||||
|
||||
self.SetCoords()
|
||||
if self.Screen.IsWifiConnectedNow() {
|
||||
self.IP = self.Screen.GetWirelessIP()
|
||||
fmt.Printf("TinyCould : %s\n", self.IP)
|
||||
} else {
|
||||
self.IP = "xxx.xxx.xxx.xxx"
|
||||
}
|
||||
|
||||
labels := []*TinyCloudLabel{
|
||||
&TinyCloudLabel{"forssh", "For ssh and scp:", self.ListFontObj, self.TextColor},
|
||||
&TinyCloudLabel{"ssh_addr", fmt.Sprintf("ssh cpi@%s", self.IP), self.ListFontObj, self.URLColor},
|
||||
&TinyCloudLabel{"forwin", "For Windows network:", self.ListFontObj, self.TextColor},
|
||||
&TinyCloudLabel{"samba_games", fmt.Sprintf("\\\\%s\\games", self.IP), self.ListFontObj, self.URLColor},
|
||||
&TinyCloudLabel{"samba_music", fmt.Sprintf("\\\\%s\\music", self.IP), self.ListFontObj, self.URLColor},
|
||||
&TinyCloudLabel{"forID", "ID:", self.ListFontObj, self.TextColor},
|
||||
&TinyCloudLabel{"forKey", "Key:", self.ListFontObj, self.TextColor},
|
||||
&TinyCloudLabel{"key_and_pass", "cpi", self.ListFontObj, self.URLColor},
|
||||
&TinyCloudLabel{"for_airplay", "Airplay:", self.ListFontObj, self.TextColor},
|
||||
&TinyCloudLabel{"airplay_name", "clockworkpi", self.ListFontObj, self.URLColor},
|
||||
&TinyCloudLabel{"for-usb-eth", "USB-Ethernet:", self.ListFontObj, self.TextColor},
|
||||
&TinyCloudLabel{"usb-eth-addr", "192.168.10.1", self.ListFontObj, self.URLColor},
|
||||
}
|
||||
|
||||
for _, v := range labels {
|
||||
l := UI.NewLabel()
|
||||
l.SetCanvasHWND(self.CanvasHWND)
|
||||
l.Init(v.Lable, v.Font, nil)
|
||||
l.SetColor(v.Color)
|
||||
self.Labels[v.Key] = l
|
||||
}
|
||||
|
||||
self.SetCoords()
|
||||
|
||||
}
|
||||
|
||||
func (self *TinyCloudPage) Init() {
|
||||
if self.Screen == nil {
|
||||
panic("No Screen")
|
||||
}
|
||||
|
||||
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil{
|
||||
self.HWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = surface.Surface(self.Screen.Width,self.Screen.Height)
|
||||
}
|
||||
|
||||
self.PosX = self.Index*self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
self.PngSize["bg"] = UI.Plane{253,114}
|
||||
self.PngSize["online"] = UI.Plane{75,122}
|
||||
|
||||
bgpng := UI.NewIconItem()
|
||||
bgpng.ImgSurf = UI.MyIconPool.GetImgSurf("needwifi_bg")
|
||||
bgpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
bgpng.Parent = self
|
||||
bgpng.Adjust(0,0,self.PngSize["bg"].W,self.PngSize["bg"].H,0)
|
||||
|
||||
self.Icons["bg"] = bgpng
|
||||
|
||||
onlinepng := UI.NewIconItem()
|
||||
onlinepng.ImgSurf = UI.MyIconPool.GetImgSurf("online")
|
||||
onlinepng.MyType = UI.ICON_TYPES["STAT"]
|
||||
onlinepng.Parent = self
|
||||
onlinepng.Adjust(0,0,self.PngSize["online"].W, self.PngSize["online"].H,0)
|
||||
|
||||
self.Icons["online"] = onlinepng
|
||||
if self.Screen == nil {
|
||||
panic("No Screen")
|
||||
}
|
||||
|
||||
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||
self.HWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = surface.Surface(self.Screen.Width, self.Screen.Height)
|
||||
}
|
||||
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
self.PngSize["bg"] = UI.Plane{253, 114}
|
||||
self.PngSize["online"] = UI.Plane{75, 122}
|
||||
|
||||
bgpng := UI.NewIconItem()
|
||||
bgpng.ImgSurf = UI.MyIconPool.GetImgSurf("needwifi_bg")
|
||||
bgpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
bgpng.Parent = self
|
||||
bgpng.Adjust(0, 0, self.PngSize["bg"].W, self.PngSize["bg"].H, 0)
|
||||
|
||||
self.Icons["bg"] = bgpng
|
||||
|
||||
onlinepng := UI.NewIconItem()
|
||||
onlinepng.ImgSurf = UI.MyIconPool.GetImgSurf("online")
|
||||
onlinepng.MyType = UI.ICON_TYPES["STAT"]
|
||||
onlinepng.Parent = self
|
||||
onlinepng.Adjust(0, 0, self.PngSize["online"].W, self.PngSize["online"].H, 0)
|
||||
|
||||
self.Icons["online"] = onlinepng
|
||||
|
||||
self.SetLabels()
|
||||
|
||||
self.SetLabels()
|
||||
|
||||
}
|
||||
|
||||
func (self *TinyCloudPage) KeyDown( ev *event.Event ) {
|
||||
func (self *TinyCloudPage) KeyDown(ev *event.Event) {
|
||||
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
return
|
||||
return
|
||||
}
|
||||
|
||||
func (self *TinyCloudPage) Draw() {
|
||||
self.ClearCanvas()
|
||||
if self.Screen.IsWifiConnectedNow() {
|
||||
self.Icons["online"].NewCoord(self.Coords["online"].X, self.Coords["online"].Y)
|
||||
self.Icons["online"].Draw()
|
||||
|
||||
|
||||
for k,_ := range self.Labels{
|
||||
if _ ,ok := self.Coords[k]; ok {
|
||||
self.Labels[k].NewCoord( self.Coords[k].X, self.Coords[k].Y)
|
||||
self.Labels[k].Draw()
|
||||
}
|
||||
}
|
||||
|
||||
self.Labels["key_and_pass"].NewCoord( 103,self.Coords["key_and_pass"].Y)
|
||||
self.Labels["key_and_pass"].Draw()
|
||||
}else {
|
||||
self.Icons["bg"].NewCoord(self.Coords["bg"].X, self.Coords["bg"].Y)
|
||||
self.Icons["bg"].Draw()
|
||||
|
||||
self.Labels["for-usb-eth"].NewCoord(self.Coords["for-usb-eth"].X+55, self.Coords["for-usb-eth"].Y)
|
||||
self.Labels["for-usb-eth"].Draw()
|
||||
|
||||
self.Labels["usb-eth-addr"].NewCoord(self.Coords["usb-eth-addr"].X+55, self.Coords["usb-eth-addr"].Y)
|
||||
self.Labels["usb-eth-addr"].Draw()
|
||||
|
||||
self.ClearCanvas()
|
||||
if self.Screen.IsWifiConnectedNow() {
|
||||
self.Icons["online"].NewCoord(self.Coords["online"].X, self.Coords["online"].Y)
|
||||
self.Icons["online"].Draw()
|
||||
|
||||
|
||||
}
|
||||
|
||||
if self.HWND != nil {
|
||||
surface.Fill(self.HWND,UI.MySkinManager.GiveColor("white"))
|
||||
rect_ := rect.Rect(self.PosX,self.PosY,self.Width,self.Height)
|
||||
surface.Blit(self.HWND,self.CanvasHWND,&rect_,nil)
|
||||
}
|
||||
for k, _ := range self.Labels {
|
||||
if _, ok := self.Coords[k]; ok {
|
||||
self.Labels[k].NewCoord(self.Coords[k].X, self.Coords[k].Y)
|
||||
self.Labels[k].Draw()
|
||||
}
|
||||
}
|
||||
|
||||
self.Labels["key_and_pass"].NewCoord(103, self.Coords["key_and_pass"].Y)
|
||||
self.Labels["key_and_pass"].Draw()
|
||||
} else {
|
||||
self.Icons["bg"].NewCoord(self.Coords["bg"].X, self.Coords["bg"].Y)
|
||||
self.Icons["bg"].Draw()
|
||||
|
||||
self.Labels["for-usb-eth"].NewCoord(self.Coords["for-usb-eth"].X+55, self.Coords["for-usb-eth"].Y)
|
||||
self.Labels["for-usb-eth"].Draw()
|
||||
|
||||
self.Labels["usb-eth-addr"].NewCoord(self.Coords["usb-eth-addr"].X+55, self.Coords["usb-eth-addr"].Y)
|
||||
self.Labels["usb-eth-addr"].Draw()
|
||||
|
||||
}
|
||||
|
||||
if self.HWND != nil {
|
||||
surface.Fill(self.HWND, UI.MySkinManager.GiveColor("white"))
|
||||
rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
|
||||
surface.Blit(self.HWND, self.CanvasHWND, &rect_, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package PowerOFF
|
||||
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||
)
|
||||
@@ -16,21 +16,20 @@ import (
|
||||
/******************************************************************************/
|
||||
type PowerOFFPlugin struct {
|
||||
UI.Plugin
|
||||
PowerOFFPage *PowerOFFConfirmPage
|
||||
PowerOFFPage *PowerOFFConfirmPage
|
||||
}
|
||||
|
||||
|
||||
func (self *PowerOFFPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *PowerOFFPlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.PowerOFFPage = NewPowerOFFConfirmPage()
|
||||
self.PowerOFFPage.SetScreen( main_screen)
|
||||
self.PowerOFFPage.SetScreen(main_screen)
|
||||
self.PowerOFFPage.SetName("PowerOFF")
|
||||
self.PowerOFFPage.Init()
|
||||
self.PowerOFFPage.Init()
|
||||
}
|
||||
|
||||
func (self *PowerOFFPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *PowerOFFPlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.PowerOFFPage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.PowerOFFPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
@@ -1,64 +1,61 @@
|
||||
package PowerOFF
|
||||
|
||||
import (
|
||||
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/cuu/gogame/event"
|
||||
)
|
||||
|
||||
type PowerOFFConfirmPage struct {
|
||||
UI.ConfirmPage
|
||||
|
||||
UI.ConfirmPage
|
||||
}
|
||||
|
||||
func NewPowerOFFConfirmPage() *PowerOFFConfirmPage {
|
||||
|
||||
p := &PowerOFFConfirmPage{}
|
||||
p.ListFont = UI.Fonts["veramono20"]
|
||||
p.ConfirmText = "Awaiting Input"
|
||||
p.FootMsg = [5]string{ "Nav","Reboot","","Cancel","Shutdown" }
|
||||
|
||||
p.ConfirmPage.ConfirmText = p.ConfirmText
|
||||
p.ConfirmPage.FootMsg = p.FootMsg
|
||||
p.ConfirmPage.ListFont = p.ListFont
|
||||
|
||||
return p
|
||||
|
||||
p := &PowerOFFConfirmPage{}
|
||||
p.ListFont = UI.Fonts["veramono20"]
|
||||
p.ConfirmText = "Awaiting Input"
|
||||
p.FootMsg = [5]string{"Nav", "Reboot", "", "Cancel", "Shutdown"}
|
||||
|
||||
p.ConfirmPage.ConfirmText = p.ConfirmText
|
||||
p.ConfirmPage.FootMsg = p.FootMsg
|
||||
p.ConfirmPage.ListFont = p.ListFont
|
||||
|
||||
return p
|
||||
|
||||
}
|
||||
|
||||
func (self *PowerOFFConfirmPage) KeyDown(ev *event.Event) {
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Menu"] || ev.Data["Key"] == UI.CurKeys["A"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
cmdpath := ""
|
||||
|
||||
if UI.CheckBattery() < 20 {
|
||||
cmdpath = "feh --bg-center sysgo/gameshell/wallpaper/gameover.png;"
|
||||
}else {
|
||||
cmdpath = "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
|
||||
}
|
||||
|
||||
cmdpath = cmdpath + "sleep 3;"
|
||||
|
||||
cmdpath = cmdpath + "sudo halt -p"
|
||||
|
||||
event.Post(UI.RUNSYS,cmdpath)
|
||||
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["X"] {
|
||||
cmdpath := "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
|
||||
cmdpath += "sleep 3;"
|
||||
cmdpath += "sudo reboot"
|
||||
|
||||
event.Post(UI.RUNSYS,cmdpath)
|
||||
}
|
||||
if ev.Data["Key"] == UI.CurKeys["Menu"] || ev.Data["Key"] == UI.CurKeys["A"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
cmdpath := ""
|
||||
|
||||
if UI.CheckBattery() < 20 {
|
||||
cmdpath = "feh --bg-center sysgo/gameshell/wallpaper/gameover.png;"
|
||||
} else {
|
||||
cmdpath = "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
|
||||
}
|
||||
|
||||
cmdpath = cmdpath + "sleep 3;"
|
||||
|
||||
cmdpath = cmdpath + "sudo halt -p"
|
||||
|
||||
event.Post(UI.RUNSYS, cmdpath)
|
||||
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["X"] {
|
||||
cmdpath := "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
|
||||
cmdpath += "sleep 3;"
|
||||
cmdpath += "sudo reboot"
|
||||
|
||||
event.Post(UI.RUNSYS, cmdpath)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user