From 515763d9543a622c397f4d21a6b0671bca30e860 Mon Sep 17 00:00:00 2001 From: cuu Date: Sun, 25 Nov 2018 02:21:29 +0800 Subject: [PATCH] ... --- Menu/GameShell/10_Settings/Wifi/net_item.go | 3 +- Menu/GameShell/10_Settings/Wifi/wifi.go | 92 ++++++++++++- sysgo/UI/confirm_page.go | 40 +++--- sysgo/UI/info_page_list_item.go | 4 +- sysgo/UI/info_page_selector.go | 4 +- sysgo/UI/keyboard.go | 28 ++-- sysgo/UI/main_screen.go | 2 +- sysgo/UI/text_item.go | 5 +- sysgo/wicd/misc/misc.go | 136 ++++++++++++++++++++ 9 files changed, 275 insertions(+), 39 deletions(-) create mode 100644 sysgo/wicd/misc/misc.go diff --git a/Menu/GameShell/10_Settings/Wifi/net_item.go b/Menu/GameShell/10_Settings/Wifi/net_item.go index 146d5df..c806b34 100644 --- a/Menu/GameShell/10_Settings/Wifi/net_item.go +++ b/Menu/GameShell/10_Settings/Wifi/net_item.go @@ -10,6 +10,7 @@ import ( "github.com/cuu/LauncherGo/sysgo/UI" ) +var NetItemDefaultHeight = 30 type NetItemMultiIcon struct { UI.MultiIconItem @@ -97,7 +98,7 @@ func NewNetItem() *NetItem { p.bitrate = "auto" p.dhcphostname = "GameShell" - p.Height = 30 + p.Height = NetItemDefaultHeight p.Labels = make(map[string]UI.LabelInterface) p.Icons = make( map[string]UI.IconItemInterface) diff --git a/Menu/GameShell/10_Settings/Wifi/wifi.go b/Menu/GameShell/10_Settings/Wifi/wifi.go index 0858a7a..8fbfc59 100644 --- a/Menu/GameShell/10_Settings/Wifi/wifi.go +++ b/Menu/GameShell/10_Settings/Wifi/wifi.go @@ -9,6 +9,9 @@ import ( "github.com/cuu/gogame/time" "github.com/cuu/LauncherGo/sysgo/UI" "github.com/cuu/LauncherGo/sysgo/DBUS" + + "github.com/cuu/LaucherGo/sysgo/wicd/misc" + ) type WifiDisconnectConfirmPage struct { @@ -384,9 +387,14 @@ type WifiList struct{ BlockCb BlockCbFunc LastStatusMsg string + EncMethods []*misc.CurType + Scroller *UI.ListScroller ListFontObj *ttf.Font InfoPage *WifiInfoPage + + MyList []*NetItem + } func NewWifiList() *WifiList { @@ -395,11 +403,91 @@ func NewWifiList() *WifiList { return p } +func (self *WifiList) ShowBox(msg string ) { + self.MsgBox.Text = msg + self.ShowingMessageBox = true + self.Screen.Draw() + self.MsgBox.Draw() + self.Screen.SwapAndShow() + +} + +func (self *WifiList) HideBox() { + self.Draw() + self.ShowingMessageBox = false + self.Screen.SwapAndShow() +} + func (self *WifiList) Init() { + self.PosX = self.Index * self.Screen.Width + self.Width = self.Screen.Width + self.Height = self.Screen.Height + + self.CanvasHWND = self.Screen.CanvasHWND + + ps := NewWifiListSelector() + ps.Parent = self + ps.Width = UI.Width - 12 + + self.Ps = ps + self.PsIndex = 0 + + msgbox := NewWifiListMessageBox() + msgbox.CanvasHWND = self.CanvasHWND + msgbox.Init(" ",UI.Fonts["veramono12"]) + msgbox.Parent = self + + self.MsgBox = msgbox + + self.EncMethods = misc.LoadEncryptionMethods() //# load predefined templates from /etc/wicd/... + /* + { + 'fields': [], + 'name': 'WPA 1/2 (Passphrase)', + 'optional': [], + 'protected': [ + ['apsk', 'Preshared_Key'], + ], + 'required': [ + ['apsk', 'Preshared_Key'], + ], + 'type': 'wpa-psk', + }, + */ + + self.UpdateNetList(true,true) // self.UpdateNetList(force_check=True,firstrun=True) + + self.Scroller = UI.NewListScroller() + self.Scroller.Parent = self + self.Scroller.PosX = 2 + self.Scroller.PosY = 2 + self.Scroller.Init() + + self.InfoPage = NewWifiInfoPage() + self.InfoPage.Screen = self.Screen + self.InfoPage.Name = "Wifi info" + + self.InfoPage.Init() + +} + +func (self *WifiList) Draw() { + self.ClearCanvas() + + if len(self.MyList) == 0 { + return + } + + self.Ps.Draw() + + for _,v := range self.MyList { + v.Draw() + } + + self.Scroller.UpdateSize( len(self.MyList)*NetItemDefaultHeight, self.PsIndex*NetItemDefaultHeight) + self.Scroller.Draw() } - - diff --git a/sysgo/UI/confirm_page.go b/sysgo/UI/confirm_page.go index 56cc7ce..8663d40 100644 --- a/sysgo/UI/confirm_page.go +++ b/sysgo/UI/confirm_page.go @@ -16,6 +16,7 @@ import ( type ListPageSelector struct { PageSelector BackgroundColor *color.Color + Parent *ConfirmPage } func NewListPageSelector() *ListPageSelector { @@ -27,7 +28,7 @@ func NewListPageSelector() *ListPageSelector { func (self *ListPageSelector) Draw() { idx := self.Parent.GetPsIndex() - mylist := self.Parent.GetMyList() + mylist := self.Parent.MyList if idx > (len(mylist) -1) { idx = len(mylist) if idx > 0 { @@ -78,33 +79,36 @@ func NewConfirmPage() *ConfirmPage { } -func (self *ConfirmPage) GetMyList() []LabelInterface { - return self.MyList -} - func (self *ConfirmPage) Reset() { self.MyList[0].SetText(self.ConfirmText) + x,y := self.MyList[0].Coord() + w,h := self.MyList[0].Size() - self.MyList[0].PosX = (self.Width - self.MyList[0].Width)/2 - self.MyList[0].PosY = (self.Width - self.MyList[0].Height)/2 + self.MyList[0].NewCoord( (self.Width - w)/2, (self.Width - h)/2) - self.BGPosX = self.MyList[0].PosX - 10 - self.BGPosY = self.MyList[0].PosY - 10 + x,y = self.MyList[0].Coord() - self.BGWidth = self.MyList[0].Width + 20 - self.BGHeight = self.MyList[0].Height +20 + self.BGPosX = x - 10 + self.BGPosY = y - 10 + + self.BGWidth = w + 20 + self.BGHeight = h + 20 } func (self *ConfirmPage) SnapMsg(msg string) { self.MyList[0].SetText(msg) - self.MyList[0].PosX = (self.Width - self.MyList[0].Width)/2 - self.MyList[0].PosY = (self.Width - self.MyList[0].Height)/2 + x,y := self.MyList[0].Coord() + w,h := self.MyList[0].Size() + + self.MyList[0].NewCoord( (self.Width - w )/2, (self.Width - h)/2 ) - self.BGPosX = self.MyList[0].PosX - 10 - self.BGPosY = self.MyList[0].PosY - 10 + x, y = self.MyList[0].Coord() - self.BGWidth = self.MyList[0].Width + 20 - self.BGHeight = self.MyList[0].Height +20 + self.BGPosX = x - 10 + self.BGPosY = y - 10 + + self.BGWidth = w + 20 + self.BGHeight = h +20 } @@ -123,7 +127,7 @@ func (self *ConfirmPage) Init() { li := NewLabel() li.SetCanvasHWND(self.CanvasHWND) - li.Init(self.ConfirmText,self.ListFont) + li.Init(self.ConfirmText,self.ListFont,nil) li.PosX = (self.Width - li.Width)/2 li.PosY = (self.Height - li.Height)/2 diff --git a/sysgo/UI/info_page_list_item.go b/sysgo/UI/info_page_list_item.go index 9c9386c..30ea3ac 100644 --- a/sysgo/UI/info_page_list_item.go +++ b/sysgo/UI/info_page_list_item.go @@ -48,7 +48,7 @@ func (self *InfoPageListItem) Draw() { self.Labels["Text"].SetColor(&color.Color{83,83,83,255} ) // SkinManager().GiveColor("Text") } - x,y := self.Labels["Text"].Coord() + x,_ := self.Labels["Text"].Coord() w,h := self.Labels["Text"].Size() self.Labels["Text"].NewCoord( x + self.PosX, self.PosY + (self.Height - h)/2 ) @@ -58,7 +58,7 @@ func (self *InfoPageListItem) Draw() { self.Labels["Text"].NewCoord(x, self.PosY + (self.Height - h)/2 ) if _, ok := self.Labels["Small"]; ok { - x,y = self.Labels["Small"].Coord() + x,_ = self.Labels["Small"].Coord() w,h = self.Labels["Small"].Size() self.Labels["Small"].NewCoord( self.Width - w + 5 , self.PosY + (self.Height - h)/2 ) diff --git a/sysgo/UI/info_page_selector.go b/sysgo/UI/info_page_selector.go index 93ee4dd..e6ec11f 100644 --- a/sysgo/UI/info_page_selector.go +++ b/sysgo/UI/info_page_selector.go @@ -35,8 +35,8 @@ func (self *InfoPageSelector) Draw() { mylist := self.Parent.GetMyList() if idx < len(mylist) { - x,y := mylist[idx].Coord() - w,h := mylist[idx].Size() + _,y := mylist[idx].Coord() + _,h := mylist[idx].Size() self.PosY = y+1 self.Height = h-3 diff --git a/sysgo/UI/keyboard.go b/sysgo/UI/keyboard.go index ca3d561..b2fc3ea 100644 --- a/sysgo/UI/keyboard.go +++ b/sysgo/UI/keyboard.go @@ -1,7 +1,10 @@ package UI import ( - + "fmt" + "strings" + + "github.com/cuu/gogame/font" "github.com/cuu/gogame/draw" "github.com/cuu/gogame/surface" "github.com/cuu/gogame/color" @@ -52,12 +55,10 @@ func (self *KeyboardSelector) Draw() { row_idx := self.Parent.RowIndex idx := self.Parent.PsIndex - x := self.Parent.SecsKeys[sec_idx][row_idx][idx].PosX - y := self.Parent.SecsKeys[sec_idx][row_idx][idx].PosY - w := self.Parent.SecsKeys[sec_idx][row_idx][idx].Width+6 - h := self.Parent.SecsKeys[sec_idx][row_idx][idx].Height+1 + x, y := self.Parent.SecsKeys[sec_idx][row_idx][idx].Coord() + w, h := self.Parent.SecsKeys[sec_idx][row_idx][idx].Size() - rect_ := draw.MidRect(x,y,w,h,self.Parent.Width,self.Parent.Height) + rect_ := draw.MidRect(x,y,w+6,h+1,self.Parent.Width,self.Parent.Height) if rect_.W <= 0 || rect_.H <= 0 { return @@ -200,7 +201,7 @@ func (self *Keyboard) Init() { start_y = 84 * j * (word_margin+14) - for idx,val := range self.Secs[i][j] { + for _,val := range self.Secs[i][j] { ti := NewTextItem() ti.FontObj = fontobj ti.Parent = self @@ -248,9 +249,10 @@ func (self *Keyboard) Init() { ps.Parent = self ps.Init(start_x,start_y,25,25,128) + ps.OnShow = true + self.Ps = ps self.PsIndex = 0 - self.Ps.OnShow = true } @@ -295,7 +297,7 @@ func (self *Keyboard) SelectNextChar() { row_idx := self.RowIndex self.PsIndex+=1 - if self._PsIndex >= len(self.SecsKeys[sec_idx][row_idx]) { + if self.PsIndex >= len(self.SecsKeys[sec_idx][row_idx]) { self.PsIndex = 0 self.RowIndex+=1 @@ -330,7 +332,8 @@ func (self *Keyboard) SelectPrevChar() { func (self *Keyboard) ClickOnChar() { sec_idx := self.SectionIndex - alphabet := self.SecsKeys[sec_idx][self.RowIndex][self.PsIndex].Str + alphabet := self.SecsKeys[sec_idx][self.RowIndex][self.PsIndex].GetStr() + if alphabet == "Space"{ alphabet = " " } @@ -387,7 +390,8 @@ func (self *Keyboard) KeyboardShift() { for j:=0;j