Browse Source

go fmt ./...

cuu 2 years ago
parent
commit
7382cc40b1
88 changed files with 9745 additions and 10185 deletions
  1. 206 225
      Menu/GameShell/10_Settings/About/about.go
  2. 174 181
      Menu/GameShell/10_Settings/Airplane/airplane_page.go
  3. 14 15
      Menu/GameShell/10_Settings/Airplane/plugin_init.go
  4. 118 119
      Menu/GameShell/10_Settings/Bluetooth/ble_agent_pair_page.go
  5. 565 583
      Menu/GameShell/10_Settings/Bluetooth/bluetooth_page.go
  6. 95 100
      Menu/GameShell/10_Settings/Bluetooth/net_item.go
  7. 105 109
      Menu/GameShell/10_Settings/Bluetooth/plugin_init.go
  8. 208 211
      Menu/GameShell/10_Settings/Brightness/brightness_page.go
  9. 15 16
      Menu/GameShell/10_Settings/Brightness/plugin_init.go
  10. 274 287
      Menu/GameShell/10_Settings/ButtonsLayout/buttons_layout_page.go
  11. 14 15
      Menu/GameShell/10_Settings/ButtonsLayout/plugin_init.go
  12. 349 359
      Menu/GameShell/10_Settings/GateWay/gateway_page.go
  13. 14 15
      Menu/GameShell/10_Settings/GateWay/plugin_init.go
  14. 295 305
      Menu/GameShell/10_Settings/Languages/languages_page.go
  15. 14 15
      Menu/GameShell/10_Settings/Languages/plugin_init.go
  16. 27 27
      Menu/GameShell/10_Settings/LauncherPy/plugin_init.go
  17. 297 307
      Menu/GameShell/10_Settings/Lima/gpu_driver_page.go
  18. 14 15
      Menu/GameShell/10_Settings/Lima/plugin_init.go
  19. 14 15
      Menu/GameShell/10_Settings/PowerOFF/plugin_init.go
  20. 46 49
      Menu/GameShell/10_Settings/PowerOFF/poweroff_confirm_page.go
  21. 14 15
      Menu/GameShell/10_Settings/PowerOptions/plugin_init.go
  22. 504 530
      Menu/GameShell/10_Settings/PowerOptions/power_options_page.go
  23. 149 161
      Menu/GameShell/10_Settings/Settings.go
  24. 14 15
      Menu/GameShell/10_Settings/Sound/plugin_init.go
  25. 186 192
      Menu/GameShell/10_Settings/Sound/sound_page.go
  26. 2 0
      Menu/GameShell/10_Settings/Sound/volume_linux.go
  27. 2 0
      Menu/GameShell/10_Settings/Sound/volume_unix.go
  28. 15 18
      Menu/GameShell/10_Settings/Storage/plugin_init.go
  29. 92 95
      Menu/GameShell/10_Settings/Storage/storage_page.go
  30. 73 79
      Menu/GameShell/10_Settings/TimeZone/list_item.go
  31. 14 15
      Menu/GameShell/10_Settings/TimeZone/plugin_init.go
  32. 293 308
      Menu/GameShell/10_Settings/TimeZone/time_zone_page.go
  33. 6 5
      Menu/GameShell/10_Settings/Update/plugin_init.go
  34. 189 191
      Menu/GameShell/10_Settings/Update/update_page.go
  35. 147 154
      Menu/GameShell/10_Settings/Wifi/net_item.go
  36. 35 37
      Menu/GameShell/10_Settings/Wifi/plugin_init.go
  37. 392 396
      Menu/GameShell/10_Settings/Wifi/wifi.go
  38. 14 15
      Menu/GameShell/98_TinyCloud/plugin_init.go
  39. 164 170
      Menu/GameShell/98_TinyCloud/tiny_cloud_page.go
  40. 14 15
      Menu/GameShell/99_PowerOFF/plugin_init.go
  41. 46 49
      Menu/GameShell/99_PowerOFF/poweroff_confirm_page.go
  42. 408 417
      main.go
  43. 200 201
      mainscreen.go
  44. 102 103
      sysgo/DBUS/dbus.go
  45. 49 59
      sysgo/UI/Emulator/emulator.go
  46. 473 487
      sysgo/UI/Emulator/fav_list_page.go
  47. 88 94
      sysgo/UI/Emulator/list_item.go
  48. 512 524
      sysgo/UI/Emulator/rom_list_page.go
  49. 89 92
      sysgo/UI/Emulator/rom_so_confirm_page.go
  50. 55 60
      sysgo/UI/UI.go
  51. 53 56
      sysgo/UI/above_all_patch.go
  52. 114 121
      sysgo/UI/confirm_page.go
  53. 7 9
      sysgo/UI/constants.go
  54. 131 137
      sysgo/UI/counter_screen.go
  55. 49 53
      sysgo/UI/delete_confirm_page.go
  56. 234 241
      sysgo/UI/download_process_page.go
  57. 5 6
      sysgo/UI/events.go
  58. 32 33
      sysgo/UI/folder_stack.go
  59. 4 5
      sysgo/UI/fonts.go
  60. 76 81
      sysgo/UI/foot_bar.go
  61. 16 20
      sysgo/UI/fullscreen.go
  62. 120 125
      sysgo/UI/hier_list_item.go
  63. 93 101
      sysgo/UI/icon_item.go
  64. 13 15
      sysgo/UI/icon_pool.go
  65. 42 43
      sysgo/UI/info_page_list_item.go
  66. 30 34
      sysgo/UI/info_page_selector.go
  67. 125 133
      sysgo/UI/keyboard.go
  68. 22 25
      sysgo/UI/keys_def.go
  69. 47 50
      sysgo/UI/label.go
  70. 102 106
      sysgo/UI/lang_manager.go
  71. 25 33
      sysgo/UI/list_item.go
  72. 146 154
      sysgo/UI/main_screen.go
  73. 46 48
      sysgo/UI/multi_icon_item.go
  74. 39 42
      sysgo/UI/multilabel.go
  75. 248 265
      sysgo/UI/page.go
  76. 27 29
      sysgo/UI/plugin.go
  77. 32 33
      sysgo/UI/scroller.go
  78. 35 39
      sysgo/UI/skin_manager.go
  79. 33 35
      sysgo/UI/slider.go
  80. 83 87
      sysgo/UI/sound_patch.go
  81. 19 25
      sysgo/UI/text_item.go
  82. 69 71
      sysgo/UI/textarea.go
  83. 249 260
      sysgo/UI/title_bar.go
  84. 17 21
      sysgo/UI/untitled_icon.go
  85. 122 130
      sysgo/UI/util_funcs.go
  86. 37 40
      sysgo/config.go
  87. 3 12
      sysgo/plugins/HelloWorld/helloworld.go
  88. 1 2
      sysgo/wicd/misc/misc.go

+ 206 - 225
Menu/GameShell/10_Settings/About/about.go

@@ -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
-
-
-
-
-
-
-
-

+ 174 - 181
Menu/GameShell/10_Settings/Airplane/airplane_page.go

@@ -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.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
-
-  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)    
+	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
+
+	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)
+	}
 }

+ 14 - 15
Menu/GameShell/10_Settings/Airplane/plugin_init.go

@@ -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()
 	}

+ 118 - 119
Menu/GameShell/10_Settings/Bluetooth/ble_agent_pair_page.go

@@ -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
+ 565 - 583
Menu/GameShell/10_Settings/Bluetooth/bluetooth_page.go


+ 95 - 100
Menu/GameShell/10_Settings/Bluetooth/net_item.go

@@ -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) {
+
+	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
+	}
 
-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.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()
-  }
-
-  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)
-  
+	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)
+
 }

+ 105 - 109
Menu/GameShell/10_Settings/Bluetooth/plugin_init.go

@@ -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/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/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/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)
-
-  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
-  }
-
-  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()
-  
-  
- 
+func (self *BluetoothPlugin) Init(main_screen *UI.MainScreen) {
+
+	log.Println("Reset bluetooth device")
+
+	btmgmt := hw.NewBtMgmt(adapterID)
+	btmgmt.SetPowered(true)
+
+	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
+	  }
+
+	  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()
+
 }
 
-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

+ 208 - 211
Menu/GameShell/10_Settings/Brightness/brightness_page.go

@@ -1,296 +1,294 @@
 package Brightness
 
-import(
-  "fmt"
-  
-  "io/ioutil"
-  "strconv"
-  
-  "github.com/veandco/go-sdl2/sdl"
-
-  "github.com/cuu/gogame/event"
-  "github.com/cuu/gogame/draw"
-  "github.com/cuu/gogame/surface"
-  "github.com/cuu/gogame/rect"
-
-  "github.com/clockworkpi/LauncherGoDev/sysgo"
-  "github.com/clockworkpi/LauncherGoDev/sysgo/UI"
+import (
+	"fmt"
+
+	"io/ioutil"
+	"strconv"
+
+	"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
-  }
-
-  if self.OnChangeCB != nil {
-    self.OnChangeCB(self.Value)
-  }
-  
+	self.Value += 1
+
+	if self.Value > 9 {
+		self.Value = 9
+	}
+
+	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)
-
-  icon_idx := self.Value-1
-  if icon_idx <0 {
-    icon_idx = 0
-  }
-  
-  self.Scale.IconIndex = icon_idx
-  self.Scale.Draw()
-  
+	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()
+
 }
 
 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()
 
 }
-

+ 15 - 16
Menu/GameShell/10_Settings/Brightness/plugin_init.go

@@ -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()
 	}

+ 274 - 287
Menu/GameShell/10_Settings/ButtonsLayout/buttons_layout_page.go

@@ -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 {
-
-  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."
-    }
-  
-  }
-
-  fmt.Println( "Completed! Your RA keymap: " + strings.ToUpper(self.LayoutMode)  )
-  return "Completed! Your RA keymap: " + strings.ToUpper(self.LayoutMode)
+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."
+		}
+
+	}
+
+	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
-      }
-    }
-  }
-
-  return lm
+	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
+			}
+		}
+	}
+
+	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)
+	}
+}

+ 14 - 15
Menu/GameShell/10_Settings/ButtonsLayout/plugin_init.go

@@ -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()
 	}

+ 349 - 359
Menu/GameShell/10_Settings/GateWay/gateway_page.go

@@ -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"
-
-  "github.com/cuu/gogame/draw"
-	"github.com/cuu/gogame/rect"
-	"github.com/cuu/gogame/surface"
+	"fmt"
+	//"io/ioutil"
+	//"path/filepath"
+	"github.com/veandco/go-sdl2/ttf"
+	"runtime"
+	"strconv"
+	"strings"
+	//"github.com/mitchellh/go-homedir"
+
+	"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/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 := &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)  
+	p.Icons = make(map[string]UI.IconItemInterface)
+	p.Fonts = make(map[string]*ttf.Font)
 
-  return p
+	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
-
-  Icons map[string]UI.IconItemInterface
-}
+	UI.Page
+
+	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"}}
-  
-
-  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)
-  }
+	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"}}
+
+	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)
+	}
+}

+ 14 - 15
Menu/GameShell/10_Settings/GateWay/plugin_init.go

@@ -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()
 	}

+ 295 - 305
Menu/GameShell/10_Settings/Languages/languages_page.go

@@ -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/rect"
-	"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/cuu/gogame/surface"
 	"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 := &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)  
+	p.Icons = make(map[string]UI.IconItemInterface)
+	p.Fonts = make(map[string]*ttf.Font)
 
-  return p
+	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
-
-  Icons map[string]UI.IconItemInterface
-}
+	UI.Page
+
+	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)
+	}
+}

+ 14 - 15
Menu/GameShell/10_Settings/Languages/plugin_init.go

@@ -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()
 	}

+ 27 - 27
Menu/GameShell/10_Settings/LauncherPy/plugin_init.go

@@ -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"
-    }
-
-    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()
-    }
+		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()
+		}
 	}
 }
 

+ 297 - 307
Menu/GameShell/10_Settings/Lima/gpu_driver_page.go

@@ -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"
-
-  "github.com/cuu/gogame/draw"
-	"github.com/cuu/gogame/rect"
-	"github.com/cuu/gogame/surface"
+	//"fmt"
+	//"io/ioutil"
+	//"path/filepath"
+	"github.com/mitchellh/go-homedir"
+	"github.com/veandco/go-sdl2/ttf"
+	"runtime"
+	"strings"
+
 	"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/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 := &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)  
+	p.Icons = make(map[string]UI.IconItemInterface)
+	p.Fonts = make(map[string]*ttf.Font)
 
-  return p
+	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
-
-  Icons map[string]UI.IconItemInterface
-}
+	UI.Page
+
+	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)"}}
-  
-
-  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)
-  }
+	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)"}}
+
+	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)
+	}
+}

+ 14 - 15
Menu/GameShell/10_Settings/Lima/plugin_init.go

@@ -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()
 	}

+ 14 - 15
Menu/GameShell/10_Settings/PowerOFF/plugin_init.go

@@ -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()
 	}

+ 46 - 49
Menu/GameShell/10_Settings/PowerOFF/poweroff_confirm_page.go

@@ -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)
+	}
 
 }

+ 14 - 15
Menu/GameShell/10_Settings/PowerOptions/plugin_init.go

@@ -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()
 	}

+ 504 - 530
Menu/GameShell/10_Settings/PowerOptions/power_options_page.go

@@ -1,534 +1,513 @@
 package PowerOptions
 
 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/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/time"
-  
-  "github.com/clockworkpi/LauncherGoDev/sysgo"
 
-  "github.com/clockworkpi/LauncherGoDev/sysgo/UI"
+	"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 := &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)  
+	p.Icons = make(map[string]UI.IconItemInterface)
+	p.Fonts = make(map[string]*ttf.Font)
 
-  return p
+	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.(*PowerOptionsPage).Icons["done"].NewCoord(self.Parent.(*PowerOptionsPage).Width-30,self.PosY+5)
-    self.Parent.(*PowerOptionsPage).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.(*PowerOptionsPage).Icons["done"].NewCoord(self.Parent.(*PowerOptionsPage).Width-30, self.PosY+5)
+		self.Parent.(*PowerOptionsPage).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 InfoPage struct {
-  UI.Page
-  ListFontObj *ttf.Font
-  
-  Time1 int
-  Time2 int
-  Time3 int
-
-  AList map[string]map[string]string
+	UI.Page
+	ListFontObj *ttf.Font
+
+	Time1 int
+	Time2 int
+	Time3 int
+
+	AList map[string]map[string]string
 }
 
 func NewInfoPage() *InfoPage {
-  
-  p := &InfoPage{}
-  
-  p.ListFontObj = UI.MyLangManager.TrFont("varela15")
-  p.FootMsg = [5]string{"Nav","","","Back",""}
-  
-  p.Time1 = 40
-  p.Time2 = 120 // 120 secs
-  p.Time3 = 300 // 5 minutes
-  
-  p.AList = make(map[string]map[string]string)
-  
-  return p
+
+	p := &InfoPage{}
+
+	p.ListFontObj = UI.MyLangManager.TrFont("varela15")
+	p.FootMsg = [5]string{"Nav", "", "", "Back", ""}
+
+	p.Time1 = 40
+	p.Time2 = 120 // 120 secs
+	p.Time3 = 300 // 5 minutes
+
+	p.AList = make(map[string]map[string]string)
+
+	return p
 }
 
+func (self *InfoPage) ConvertSecToMin(secs int) string {
+	sec_str := ""
+	min_str := ""
+
+	if secs > 60 {
+		m := int(secs / 60)
+		s := secs % 60
+
+		if m > 1 {
+			min_str = fmt.Sprintf("%d "+UI.MyLangManager.Tr("minutes")+" ", m)
+		} else {
+			min_str = fmt.Sprintf("%d "+UI.MyLangManager.Tr("minute")+" ", m)
+		}
+
+		if s == 1 {
+			sec_str = fmt.Sprintf("%d "+UI.MyLangManager.Tr("second"), s)
+		} else if s > 1 {
+			sec_str = fmt.Sprintf("%d "+UI.MyLangManager.Tr("seconds"), s)
+		}
+
+	} else if secs <= 60 && secs > 0 {
+		if secs > 1 {
+			sec_str = fmt.Sprintf("%d "+UI.MyLangManager.Tr("seconds"), secs)
+		} else {
+			sec_str = fmt.Sprintf("%d "+UI.MyLangManager.Tr("second"), secs)
+		}
+
+	} else if secs == 0 {
+		sec_str = UI.MyLangManager.Tr("Never")
+	}
 
-func (self *InfoPage) ConvertSecToMin( secs int) string {
-  sec_str := ""
-  min_str := ""
-  
-  if secs > 60 {
-    m := int(secs/60)
-    s := secs % 60
-    
-    if m > 1 {
-      min_str = fmt.Sprintf("%d "+UI.MyLangManager.Tr("minutes")+ " ", m)
-    }else {
-      min_str = fmt.Sprintf("%d "+UI.MyLangManager.Tr("minute")+ " ", m)
-    }
-    
-    if s == 1 {
-      sec_str = fmt.Sprintf("%d "+UI.MyLangManager.Tr("second"), s)
-    }else if s > 1 {
-      sec_str = fmt.Sprintf("%d "+UI.MyLangManager.Tr("seconds"), s)
-    }
-    
-  }else if secs <= 60 && secs > 0 {
-    if secs > 1 {
-      sec_str = fmt.Sprintf("%d "+UI.MyLangManager.Tr("seconds"), secs)
-    }else {
-      sec_str = fmt.Sprintf("%d "+UI.MyLangManager.Tr("second"), secs)
-    }
-    
-  
-  }else if secs == 0 {
-    sec_str = UI.MyLangManager.Tr("Never")
-  }
-  
-  
-  return min_str + sec_str
+	return min_str + sec_str
 
 }
 
 func (self *InfoPage) RefreshList() {
-  
-  self.AList["time1"]["value"] = self.ConvertSecToMin(self.Time1)
-  self.AList["time2"]["value"] = self.ConvertSecToMin(self.Time2)
-  self.AList["time3"]["value"] = self.ConvertSecToMin(self.Time3)
-  
-  i := 0 
-  for _ ,v := range self.AList {
-    self.MyList[i].(*PageListItem).SetSmallText( v["value"] )
-    i+=1
-  }
+
+	self.AList["time1"]["value"] = self.ConvertSecToMin(self.Time1)
+	self.AList["time2"]["value"] = self.ConvertSecToMin(self.Time2)
+	self.AList["time3"]["value"] = self.ConvertSecToMin(self.Time3)
+
+	i := 0
+	for _, v := range self.AList {
+		self.MyList[i].(*PageListItem).SetSmallText(v["value"])
+		i += 1
+	}
 
 }
 
 func (self *InfoPage) GenList() {
 
-  time1 := make(map[string]string)
-  
-  time1["key"] = "time1"
-  
-  if self.Time1 == 0 {
-    time1["value"] = UI.MyLangManager.Tr("Never")
-  }else {
-    time1["value"] = fmt.Sprintf("%d secs",self.Time1)
-  }
-  time1["label"] = "Screen dimming"
-  
-  time2 := make(map[string]string)
-  time2["key"] = "time2"
-  
-  if self.Time2 == 0 {
-    time2["value"] = UI.MyLangManager.Tr("Never")
-  }else {
-    time2["value"] = fmt.Sprintf("%d secs",self.Time2)
-  }
-  
-  time2["label"] = "Screen OFF"
-  
-  time3 := make(map[string]string)
-  time3["key"] = "time3"
-  
-  if self.Time3 == 0 {
-    time3["value"] = UI.MyLangManager.Tr("Never")
-  }else {
-    time3["value"] = fmt.Sprintf("%d secs",self.Time3)
-  }
-  
-  time3["label"] = "Power OFF"
-  
-  
-  self.AList["time1"] = time1
-  self.AList["time2"] = time2
-  self.AList["time3"] = time3  
-  
-  
-  self.MyList = nil
-  
-  start_x := 0 
-  start_y := 0 
-  
-  
-  i:=0
-  for _,v := range self.AList {
-    
-    li := NewPageListItem()
-    li.Parent = self
-    li.PosX = start_x
-    li.PosY = start_y + i*UI.DefaultInfoPageListItemHeight
-    li.Width = UI.Width
-    li.Fonts["normal"] = self.ListFontObj
-    li.Fonts["small"]  = UI.MyLangManager.TrFont("varela12")
-    
-    if v["label"] != "" {
-      li.Init( v["label"])
-    }else {
-      li.Init(v["key"])
-    }
-    
-    li.Flag = v["key"]
-    
-    li.SetSmallText(v["value"])
-    
-    self.MyList = append(self.MyList,li)
-    i+=1
-  }
+	time1 := make(map[string]string)
+
+	time1["key"] = "time1"
+
+	if self.Time1 == 0 {
+		time1["value"] = UI.MyLangManager.Tr("Never")
+	} else {
+		time1["value"] = fmt.Sprintf("%d secs", self.Time1)
+	}
+	time1["label"] = "Screen dimming"
+
+	time2 := make(map[string]string)
+	time2["key"] = "time2"
+
+	if self.Time2 == 0 {
+		time2["value"] = UI.MyLangManager.Tr("Never")
+	} else {
+		time2["value"] = fmt.Sprintf("%d secs", self.Time2)
+	}
+
+	time2["label"] = "Screen OFF"
+
+	time3 := make(map[string]string)
+	time3["key"] = "time3"
+
+	if self.Time3 == 0 {
+		time3["value"] = UI.MyLangManager.Tr("Never")
+	} else {
+		time3["value"] = fmt.Sprintf("%d secs", self.Time3)
+	}
+
+	time3["label"] = "Power OFF"
+
+	self.AList["time1"] = time1
+	self.AList["time2"] = time2
+	self.AList["time3"] = time3
+
+	self.MyList = nil
+
+	start_x := 0
+	start_y := 0
+
+	i := 0
+	for _, v := range self.AList {
+
+		li := NewPageListItem()
+		li.Parent = self
+		li.PosX = start_x
+		li.PosY = start_y + i*UI.DefaultInfoPageListItemHeight
+		li.Width = UI.Width
+		li.Fonts["normal"] = self.ListFontObj
+		li.Fonts["small"] = UI.MyLangManager.TrFont("varela12")
+
+		if v["label"] != "" {
+			li.Init(v["label"])
+		} else {
+			li.Init(v["key"])
+		}
+
+		li.Flag = v["key"]
+
+		li.SetSmallText(v["value"])
+
+		self.MyList = append(self.MyList, li)
+		i += 1
+	}
 }
 
 func (self *InfoPage) Init() {
 
-  if self.Screen != nil {
-    if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
-      self.CanvasHWND = self.Screen.CanvasHWND
-    }
-  }
-  
-  self.PosX = self.Index*self.Screen.Width 
-  self.Width = self.Screen.Width
-  self.Height = self.Screen.Height
-
-  ps := NewListPageSelector()
-  ps.Parent = self
-  self.Ps = ps
-  self.PsIndex = 0
-        
-  self.GenList()
+	if self.Screen != nil {
+		if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
+			self.CanvasHWND = self.Screen.CanvasHWND
+		}
+	}
+
+	self.PosX = self.Index * self.Screen.Width
+	self.Width = self.Screen.Width
+	self.Height = self.Screen.Height
+
+	ps := NewListPageSelector()
+	ps.Parent = self
+	self.Ps = ps
+	self.PsIndex = 0
+
+	self.GenList()
 }
 
 func (self *InfoPage) Click() {
-  
-  if self.PsIndex >= len(self.MyList) {
-    return
-  }
-  
-  cur_li := self.MyList[self.PsIndex]
-  
-  fmt.Println(cur_li.(*PageListItem).Flag )
+
+	if self.PsIndex >= len(self.MyList) {
+		return
+	}
+
+	cur_li := self.MyList[self.PsIndex]
+
+	fmt.Println(cur_li.(*PageListItem).Flag)
 
 }
 
 func (self *InfoPage) OnLoadCb() {
-  
-  self.RefreshList()
-  
-}
 
+	self.RefreshList()
 
-func (self *InfoPage) KeyDown(ev *event.Event) {
+}
 
+func (self *InfoPage) 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()
-    self.Screen.SwapAndShow()
-  }
-  
-  if ev.Data["Key"]  == UI.CurKeys["Down"] {
-  
-    self.ScrollDown()
-    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()
+	}
 }
 
 func (self *InfoPage) Draw() {
-  self.ClearCanvas()
-  self.Ps.Draw()
-  for _,v := range self.MyList{
-    v.Draw()
-  }
+	self.ClearCanvas()
+	self.Ps.Draw()
+	for _, v := range self.MyList {
+		v.Draw()
+	}
 }
 
-
 type PowerOptionsPage struct {
-  UI.Page
-  
-  ListFont *ttf.Font
-  BGwidth int
-  BGheight int
-  
-  AList map[string]map[string]string
-  DrawOnce bool
-  InfoPage *InfoPage
-  Scroller *UI.ListScroller
-  Icons map[string]UI.IconItemInterface
-}
+	UI.Page
 
+	ListFont *ttf.Font
+	BGwidth  int
+	BGheight int
+
+	AList    map[string]map[string]string
+	DrawOnce bool
+	InfoPage *InfoPage
+	Scroller *UI.ListScroller
+	Icons    map[string]UI.IconItemInterface
+}
 
 func NewPowerOptionsPage() *PowerOptionsPage {
-  
-  p := &PowerOptionsPage{}
-  
-  p.BGwidth = UI.Width 
-  p.BGheight = UI.Height - 24 - 20
-  
-  p.AList = make(map[string]map[string]string)
-  p.Icons = make(map[string]UI.IconItemInterface)
-
-  p.ListFont = UI.Fonts["notosanscjk15"]
-  p.FootMsg =  [5]string{"Nav","","Detail","Back","Select"}
-  
-  return p
+
+	p := &PowerOptionsPage{}
+
+	p.BGwidth = UI.Width
+	p.BGheight = UI.Height - 24 - 20
+
+	p.AList = make(map[string]map[string]string)
+	p.Icons = make(map[string]UI.IconItemInterface)
+
+	p.ListFont = UI.Fonts["notosanscjk15"]
+	p.FootMsg = [5]string{"Nav", "", "Detail", "Back", "Select"}
+
+	return p
 }
 
 func (self *PowerOptionsPage) GenList() {
-  
-  self.MyList = nil
-  
-  start_x := 0
-  start_y := 0 
-  
-  last_height :=0
-  
-  supersaving := make(map[string]string)
-  supersaving["key"] = "super"
-  supersaving["label"] = "Power saving"
-  supersaving["value"] = "supersaving"
-
-  powersaving := make(map[string]string)
-  powersaving["key"] = "saving"
-  powersaving["label"] = "Balanced"
-  powersaving["value"] = "powersaving"
-
-  performance := make(map[string]string)
-  performance["key"] = "performance"
-  performance["label"] = "Performance"
-  performance["value"] = "performance"
-
-  server_saving := make(map[string]string)
-  server_saving["key"] = "server"
-  server_saving["label"] = "Server"
-  server_saving["value"] = "server"
-  
-  self.AList["supersaving"] = supersaving
-  self.AList["powersaving"] = powersaving
-  self.AList["server"]      = server_saving
-  self.AList["performance"] = performance
-  
-  
-  for _,u := range [4]string{"supersaving","powersaving","server","performance"} {
-    
-    v := self.AList[u]
-    
-    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 = v["value"]
-    
-    if v["label"] != "" {
-      li.Init(v["label"])
-    }else {
-      li.Init(v["key"])
-    }
-    
-    last_height += li.Height
-    
-    self.MyList = append(self.MyList,li)
-  
-  }
-}
 
+	self.MyList = nil
+
+	start_x := 0
+	start_y := 0
+
+	last_height := 0
+
+	supersaving := make(map[string]string)
+	supersaving["key"] = "super"
+	supersaving["label"] = "Power saving"
+	supersaving["value"] = "supersaving"
+
+	powersaving := make(map[string]string)
+	powersaving["key"] = "saving"
+	powersaving["label"] = "Balanced"
+	powersaving["value"] = "powersaving"
+
+	performance := make(map[string]string)
+	performance["key"] = "performance"
+	performance["label"] = "Performance"
+	performance["value"] = "performance"
+
+	server_saving := make(map[string]string)
+	server_saving["key"] = "server"
+	server_saving["label"] = "Server"
+	server_saving["value"] = "server"
+
+	self.AList["supersaving"] = supersaving
+	self.AList["powersaving"] = powersaving
+	self.AList["server"] = server_saving
+	self.AList["performance"] = performance
+
+	for _, u := range [4]string{"supersaving", "powersaving", "server", "performance"} {
+
+		v := self.AList[u]
+
+		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 = v["value"]
+
+		if v["label"] != "" {
+			li.Init(v["label"])
+		} else {
+			li.Init(v["key"])
+		}
+
+		last_height += li.Height
+
+		self.MyList = append(self.MyList, li)
+
+	}
+}
 
 func (self *PowerOptionsPage) 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)  
-
-  self.InfoPage = NewInfoPage()
-  self.InfoPage.Screen = self.Screen
-  self.InfoPage.Name   = "Power option detail"
-  self.InfoPage.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)
+
+	self.InfoPage = NewInfoPage()
+	self.InfoPage.Screen = self.Screen
+	self.InfoPage.Name = "Power option detail"
+	self.InfoPage.Init()
+
 }
 
 func (self *PowerOptionsPage) Click() {
-  if len(self.MyList) == 0 {
-    return
-  }
-  
-  cur_li := self.MyList[self.PsIndex].(*PageListItem)
-  
-  if cur_li.Active == true {
-    return
-  }
-  
-  for i,_ := range self.MyList {
-    self.MyList[i].(*PageListItem).Active = false
-  }
-  
-  cur_li.Active = true
-  
-  fmt.Println(cur_li.Value)
-  
-  d := []byte(cur_li.Value)
-  err := ioutil.WriteFile("sysgo/.powerlevel", d, 0644)
-  if err != nil {
-    fmt.Println(err)
-  }
-  
-  sysgo.CurPowerLevel = cur_li.Value
-  
-  if sysgo.CurPowerLevel == "supersaving" {
-    UI.System(fmt.Sprintf("sudo iw %s set power_save on >/dev/null",sysgo.WifiDev))
-  }else{
-    UI.System(fmt.Sprintf("sudo iw %s set power_save off >/dev/null",sysgo.WifiDev))
-  }
-  
-  self.Screen.MsgBox.SetText("Applying")
-  self.Screen.MsgBox.Draw()
-  self.Screen.SwapAndShow()  
-  
-  event.Post(UI.POWEROPT,"")
-  
-  time.BlockDelay(1000)
-  
-  self.Screen.Draw()
-  self.Screen.SwapAndShow()  
+	if len(self.MyList) == 0 {
+		return
+	}
+
+	cur_li := self.MyList[self.PsIndex].(*PageListItem)
+
+	if cur_li.Active == true {
+		return
+	}
+
+	for i, _ := range self.MyList {
+		self.MyList[i].(*PageListItem).Active = false
+	}
+
+	cur_li.Active = true
+
+	fmt.Println(cur_li.Value)
+
+	d := []byte(cur_li.Value)
+	err := ioutil.WriteFile("sysgo/.powerlevel", d, 0644)
+	if err != nil {
+		fmt.Println(err)
+	}
+
+	sysgo.CurPowerLevel = cur_li.Value
+
+	if sysgo.CurPowerLevel == "supersaving" {
+		UI.System(fmt.Sprintf("sudo iw %s set power_save on >/dev/null", sysgo.WifiDev))
+	} else {
+		UI.System(fmt.Sprintf("sudo iw %s set power_save off >/dev/null", sysgo.WifiDev))
+	}
+
+	self.Screen.MsgBox.SetText("Applying")
+	self.Screen.MsgBox.Draw()
+	self.Screen.SwapAndShow()
+
+	event.Post(UI.POWEROPT, "")
+
+	time.BlockDelay(1000)
+
+	self.Screen.Draw()
+	self.Screen.SwapAndShow()
 }
 
 func (self *PowerOptionsPage) OnLoadCb() {
-  
-  self.PosY = 0
-  self.DrawOnce = false
-  
-  for i,_ := range self.MyList{
-    if self.MyList[i].(*PageListItem).Value == sysgo.CurPowerLevel {
-      self.MyList[i].(*PageListItem).Active = true
-    }
-  }
+
+	self.PosY = 0
+	self.DrawOnce = false
+
+	for i, _ := range self.MyList {
+		if self.MyList[i].(*PageListItem).Value == sysgo.CurPowerLevel {
+			self.MyList[i].(*PageListItem).Active = true
+		}
+	}
 }
 
 func (self *PowerOptionsPage) KeyDown(ev *event.Event) {
@@ -537,96 +516,91 @@ func (self *PowerOptionsPage) KeyDown(ev *event.Event) {
 		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["Y"] {
-    cur_li := self.MyList[self.PsIndex].(*PageListItem)
-    
-    time1 := sysgo.PowerLevels[cur_li.Value].Dim
-    time2 := sysgo.PowerLevels[cur_li.Value].Close
-    time3 := sysgo.PowerLevels[cur_li.Value].PowerOff
-     
-            
-    self.InfoPage.Time1 = time1
-    self.InfoPage.Time2 = time2
-    self.InfoPage.Time3 = time3
-    
-            
-    self.Screen.PushPage(self.InfoPage)
-    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["Y"] {
+		cur_li := self.MyList[self.PsIndex].(*PageListItem)
+
+		time1 := sysgo.PowerLevels[cur_li.Value].Dim
+		time2 := sysgo.PowerLevels[cur_li.Value].Close
+		time3 := sysgo.PowerLevels[cur_li.Value].PowerOff
+
+		self.InfoPage.Time1 = time1
+		self.InfoPage.Time2 = time2
+		self.InfoPage.Time3 = time3
+
+		self.Screen.PushPage(self.InfoPage)
+		self.Screen.Draw()
+		self.Screen.SwapAndShow()
+	}
 }
 
 func (self *PowerOptionsPage) 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)
+	}
+
+}

+ 149 - 161
Menu/GameShell/10_Settings/Settings.go

@@ -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"
-	"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"
-
-  
 
+	//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/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},
-
-    &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},    
+	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},
+
+		&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()

+ 14 - 15
Menu/GameShell/10_Settings/Sound/plugin_init.go

@@ -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()
 	}

+ 186 - 192
Menu/GameShell/10_Settings/Sound/sound_page.go

@@ -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"
-
-  "github.com/clockworkpi/LauncherGoDev/sysgo/UI"
+import (
+	"fmt"
+	"github.com/cuu/gogame/event"
+	"github.com/veandco/go-sdl2/sdl"
+
+	"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
-  }
-
-  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 < 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()
 }
 
+func (self *SoundPage) Draw() {
+	self.ClearCanvas()
+	self.MySlider.Draw()
+}

+ 2 - 0
Menu/GameShell/10_Settings/Sound/volume_linux.go

@@ -1,4 +1,6 @@
+//go:build !windows && !darwin
 // +build !windows,!darwin
+
 /*
  * Copied from https://github.com/itchyny/volume-go,  MIT License
  */

+ 2 - 0
Menu/GameShell/10_Settings/Sound/volume_unix.go

@@ -1,4 +1,6 @@
+//go:build !windows
 // +build !windows
+
 /*
  * Copied from https://github.com/itchyny/volume-go,  MIT License
  */

+ 15 - 18
Menu/GameShell/10_Settings/Storage/plugin_init.go

@@ -1,37 +1,34 @@
 package Storage
 
-
 import (
-/*
-	"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/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/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()
 	}

+ 92 - 95
Menu/GameShell/10_Settings/Storage/storage_page.go

@@ -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()
-
-  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})
-  
+	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()
+
+	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})
 
 }

+ 73 - 79
Menu/GameShell/10_Settings/TimeZone/list_item.go

@@ -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.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 := 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
 }
 
 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)
+
+}

+ 14 - 15
Menu/GameShell/10_Settings/TimeZone/plugin_init.go

@@ -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()
 	}

+ 293 - 308
Menu/GameShell/10_Settings/TimeZone/time_zone_page.go

@@ -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)
-  } 
 }
 
+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)
+	}
+}
 
 type TimeZoneListPage struct {
-  UI.Page
-  
-  Scroller *UI.ListScroller
-  
-  Icons  map[string]UI.IconItemInterface
-
-  ListFont *ttf.Font
-  MyStack *UI.FolderStack
-  BGpng *UI.IconItem
-  BGwidth int
-  BGheight int
-  
-  SwapMyList []UI.ListItemInterface
+	UI.Page
+
+	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"}
 
-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.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.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.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()
 
-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() 
 }
 
+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()
+}
 
 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()
+		}
+	}
 
+}

+ 6 - 5
Menu/GameShell/10_Settings/Update/plugin_init.go

@@ -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()

+ 189 - 191
Menu/GameShell/10_Settings/Update/update_page.go

@@ -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)
-
-  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
-  }
+	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
+	}
 }
 
 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()
-
-  type Response struct {
-    GitVersion string `json:"gitversion"`
-  }
-  
-  
-  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)
+	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,
+	}
+
+	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()
+	}
 
 }

+ 147 - 154
Menu/GameShell/10_Settings/Wifi/net_item.go

@@ -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,14 +55,13 @@ 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
@@ -71,187 +69,182 @@ type NetItem struct {
 	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)
-  }
-
-  
-  essid_label := UI.NewLabel()
-  essid_label.PosX = 36
-  essid_label.CanvasHWND = self.Parent.GetCanvasHWND()
-
-  essid_  := ""
-	
-  if len(self.Essid) > 19 {
+	//strenstr := "quality"
+	//gap := 7
+
+	the_main_screen := self.Parent.GetScreen()
+
+	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)
+
+	self.Labels["essid"] = essid_label
+
+	stren_label := UI.NewLabel()
+	stren_label.CanvasHWND = self.Parent.GetCanvasHWND()
 
-	stren_l := fmt.Sprintf("%%%d ",self.CalcWifiQuality())
+	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)
-	
+
 }

+ 35 - 37
Menu/GameShell/10_Settings/Wifi/plugin_init.go

@@ -1,61 +1,59 @@
 package Wifi
 
 import (
-  //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"
-*/
+	//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/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
+ 392 - 396
Menu/GameShell/10_Settings/Wifi/wifi.go


+ 14 - 15
Menu/GameShell/98_TinyCloud/plugin_init.go

@@ -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()
 	}

+ 164 - 170
Menu/GameShell/98_TinyCloud/tiny_cloud_page.go

@@ -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/surface"
+	"github.com/veandco/go-sdl2/ttf"
+
 	"github.com/cuu/gogame/color"
-	
-	"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
 
+	"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
-
-  Coords map[string]UI.Coord
-  IP string 
-  
-  PngSize map[string]UI.Plane
+	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
 }
 
 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["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 }
+	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["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
-
-  self.SetLabels()
-    
+	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()
+
 }
 
-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()                
-                
-
-  
-  }
-  
-  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 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()
+
+	}
+
+	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)
+	}
 }

+ 14 - 15
Menu/GameShell/99_PowerOFF/plugin_init.go

@@ -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()
 	}

+ 46 - 49
Menu/GameShell/99_PowerOFF/poweroff_confirm_page.go

@@ -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)
+	}
 
 }

+ 408 - 417
main.go

@@ -1,507 +1,498 @@
 package main
 
 import (
-
-	"os"
 	"fmt"
-  "log"
-  "io/ioutil"
-  "strconv"
-  "strings"
-  "runtime"
-  "path/filepath"
-  "os/exec"
-  "syscall"
-  //"encoding/json"
-	gotime "time"
+	"io/ioutil"
+	"log"
+	"os"
+	"os/exec"
+	"path/filepath"
+	"runtime"
+	"strconv"
+	"strings"
+	"syscall"
+	//"encoding/json"
 	"github.com/veandco/go-sdl2/sdl"
+	gotime "time"
 	//"github.com/go-ini/ini"
 	"github.com/cuu/gogame"
 	"github.com/cuu/gogame/display"
 	"github.com/cuu/gogame/event"
-//	"github.com/cuu/gogame/color"
+	//	"github.com/cuu/gogame/color"
 	"github.com/cuu/gogame/font"
 	//"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"
 )
 
 var (
-  flash_led1_counter  = 0
-  last_brt = -1
-  passout_time_stage = 0
-  led1_proc_file = "/proc/driver/led1"
-  
-  everytime_keydown = gotime.Now()
-  
-  sound_patch *UI.SoundPatch
-  
+	flash_led1_counter = 0
+	last_brt           = -1
+	passout_time_stage = 0
+	led1_proc_file     = "/proc/driver/led1"
+
+	everytime_keydown = gotime.Now()
+
+	sound_patch *UI.SoundPatch
 )
 
 // flash the Led1 on the GS back
 func FlashLed1(main_screen *UI.MainScreen) {
-  
-  for {
-    if UI.FileExists(led1_proc_file) {
-      if main_screen.Closed == false {
-        if flash_led1_counter > 0 {
-          d := []byte(fmt.Sprintf("%d",0))
-          err := ioutil.WriteFile(led1_proc_file, d, 0644) // turn off led1
-          if err != nil {
-            fmt.Println(err)
-          }
-          flash_led1_counter = 0
-        }
-      
-      } else {
-        flash_led1_counter +=1
-        if flash_led1_counter == 3 {
-          d := []byte(fmt.Sprintf("%d",1))
-          err := ioutil.WriteFile(led1_proc_file, d, 0644)
-          if err != nil {
-            fmt.Println(err)
-          }
-        }
-        
-        if flash_led1_counter == 5 {
-          d := []byte(fmt.Sprintf("%d",0))
-          err := ioutil.WriteFile(led1_proc_file, d, 0644)
-          if err != nil {
-            fmt.Println(err)
-          }
-        }
-        
-        if flash_led1_counter == 11 {
-          flash_led1_counter = 1
-        }
-      }
-    }
-    
-    gotime.Sleep(200 * gotime.Millisecond)
-  }
+
+	for {
+		if UI.FileExists(led1_proc_file) {
+			if main_screen.Closed == false {
+				if flash_led1_counter > 0 {
+					d := []byte(fmt.Sprintf("%d", 0))
+					err := ioutil.WriteFile(led1_proc_file, d, 0644) // turn off led1
+					if err != nil {
+						fmt.Println(err)
+					}
+					flash_led1_counter = 0
+				}
+
+			} else {
+				flash_led1_counter += 1
+				if flash_led1_counter == 3 {
+					d := []byte(fmt.Sprintf("%d", 1))
+					err := ioutil.WriteFile(led1_proc_file, d, 0644)
+					if err != nil {
+						fmt.Println(err)
+					}
+				}
+
+				if flash_led1_counter == 5 {
+					d := []byte(fmt.Sprintf("%d", 0))
+					err := ioutil.WriteFile(led1_proc_file, d, 0644)
+					if err != nil {
+						fmt.Println(err)
+					}
+				}
+
+				if flash_led1_counter == 11 {
+					flash_led1_counter = 1
+				}
+			}
+		}
+
+		gotime.Sleep(200 * gotime.Millisecond)
+	}
 }
 
 //happens everytime when KeyDown occurs
 func RestoreLastBackLightBrightness(main_screen *UI.MainScreen) bool {
-  
-  passout_time_stage = 0
-  main_screen.TitleBar.InLowBackLight = -1
-  main_screen.Closed = false
-  
-  if last_brt == -1 {
-    return true
-  }
-  
-  if UI.FileExists(sysgo.BackLight) {
-    lines,err := UI.ReadLines(sysgo.BackLight)
-    if err == nil {
-      brt,err2 := strconv.Atoi(strings.Trim(lines[0],"\r\n "))
-      if err2 == nil {
-        if brt < last_brt {
-          d := []byte(fmt.Sprintf("%d",last_brt))
-          ioutil.WriteFile(sysgo.BackLight,d,0644)
-          last_brt = -1
-        }
-      }
-    }else {
-      fmt.Println(err)
-    }
-    
-  }else {
-    
-  }
-  
-  if UI.FileExists(led1_proc_file) {
-    d := []byte(fmt.Sprintf("%d",0))
-    err := ioutil.WriteFile(led1_proc_file, d, 0644)
-    if err != nil {
-      fmt.Println(err)
-    }
-  }
-
-  //Stop CounterScreen here
-  
-  if main_screen.CounterScreen.Counting == true {
-    main_screen.CounterScreen.StopCounter()
-    main_screen.Draw()
-    main_screen.SwapAndShow()
-    return false
-  }
-  
-  return true
-  
+
+	passout_time_stage = 0
+	main_screen.TitleBar.InLowBackLight = -1
+	main_screen.Closed = false
+
+	if last_brt == -1 {
+		return true
+	}
+
+	if UI.FileExists(sysgo.BackLight) {
+		lines, err := UI.ReadLines(sysgo.BackLight)
+		if err == nil {
+			brt, err2 := strconv.Atoi(strings.Trim(lines[0], "\r\n "))
+			if err2 == nil {
+				if brt < last_brt {
+					d := []byte(fmt.Sprintf("%d", last_brt))
+					ioutil.WriteFile(sysgo.BackLight, d, 0644)
+					last_brt = -1
+				}
+			}
+		} else {
+			fmt.Println(err)
+		}
+
+	} else {
+
+	}
+
+	if UI.FileExists(led1_proc_file) {
+		d := []byte(fmt.Sprintf("%d", 0))
+		err := ioutil.WriteFile(led1_proc_file, d, 0644)
+		if err != nil {
+			fmt.Println(err)
+		}
+	}
+
+	//Stop CounterScreen here
+
+	if main_screen.CounterScreen.Counting == true {
+		main_screen.CounterScreen.StopCounter()
+		main_screen.Draw()
+		main_screen.SwapAndShow()
+		return false
+	}
+
+	return true
+
 }
 
 //power stuff dealer
 func InspectionTeam(main_screen *UI.MainScreen) {
 
-  for {
-    cur_time := gotime.Now()
-    elapsed := cur_time.Sub(everytime_keydown)
-    
-    time1 := sysgo.PowerLevels[sysgo.CurPowerLevel].Dim
-    time2 := sysgo.PowerLevels[sysgo.CurPowerLevel].Close
-    time3 := sysgo.PowerLevels[sysgo.CurPowerLevel].PowerOff
-    
-    if elapsed > gotime.Duration(time1) *gotime.Second && passout_time_stage == 0 {
-      fmt.Println("timeout, dim screen ",elapsed)
-      
-      if main_screen.TitleBar.InLowBackLight >= 0 {
-        everytime_keydown = cur_time
-        continue
-      }
-      
-      if UI.FileExists(sysgo.BackLight) {
-        lines,err := UI.ReadLines(sysgo.BackLight) 
-        
-        if err == nil {
-          brt,err2 := strconv.Atoi(strings.Trim(lines[0],"\r\n "))
-          if err2 == nil {
-            if brt > 0 {
-              if last_brt < 0 {
-                last_brt = brt
-              }
-              d := []byte(fmt.Sprintf("%d",1)) // lowest backlight
-              ioutil.WriteFile(sysgo.BackLight,d,0644)
-            }
-          }
-        }
-      
-      
-        main_screen.TitleBar.InLowBackLight = 0
-        if time2 != 0 {
-          passout_time_stage = 1 // next 
-        }
-      }
-      everytime_keydown = cur_time
-    }else if elapsed > gotime.Duration(time2) *gotime.Second && passout_time_stage == 1 {
-      fmt.Println("timeout, close screen ", elapsed)
-      
-      if main_screen.Closed == true {
-        everytime_keydown = cur_time
-        continue
-      }
-      if UI.FileExists(sysgo.BackLight) {
-        d := []byte(fmt.Sprintf("%d",0))
-        ioutil.WriteFile(sysgo.BackLight,d,0644)
-      }      
-      
-      main_screen.TitleBar.InLowBackLight = 0
-      main_screen.Closed = true
-      if time3 != 0 {
-        passout_time_stage = 2 // next
-      }
-      
-      everytime_keydown = cur_time
-    }else if elapsed > gotime.Duration(time3) * gotime.Second && passout_time_stage  == 2{
-      
-      fmt.Println("Power Off counting down")
-      
-      if UI.FileExists(sysgo.BackLight) { //hdmi does not have BackLight dev node
-        d := []byte(fmt.Sprintf("%d",last_brt))
-        ioutil.WriteFile(sysgo.BackLight,d,0644)
-        
-        main_screen.CounterScreen.Draw()
-        main_screen.CounterScreen.SwapAndShow()
-        main_screen.CounterScreen.StartCounter()        
-        
-      }
-      
-      main_screen.TitleBar.InLowBackLight = 0
-      
-      passout_time_stage = 4
-      
-    }
-    
-    gotime.Sleep(gotime.Duration(UI.DT) * gotime.Millisecond)
-  }
+	for {
+		cur_time := gotime.Now()
+		elapsed := cur_time.Sub(everytime_keydown)
+
+		time1 := sysgo.PowerLevels[sysgo.CurPowerLevel].Dim
+		time2 := sysgo.PowerLevels[sysgo.CurPowerLevel].Close
+		time3 := sysgo.PowerLevels[sysgo.CurPowerLevel].PowerOff
+
+		if elapsed > gotime.Duration(time1)*gotime.Second && passout_time_stage == 0 {
+			fmt.Println("timeout, dim screen ", elapsed)
+
+			if main_screen.TitleBar.InLowBackLight >= 0 {
+				everytime_keydown = cur_time
+				continue
+			}
+
+			if UI.FileExists(sysgo.BackLight) {
+				lines, err := UI.ReadLines(sysgo.BackLight)
+
+				if err == nil {
+					brt, err2 := strconv.Atoi(strings.Trim(lines[0], "\r\n "))
+					if err2 == nil {
+						if brt > 0 {
+							if last_brt < 0 {
+								last_brt = brt
+							}
+							d := []byte(fmt.Sprintf("%d", 1)) // lowest backlight
+							ioutil.WriteFile(sysgo.BackLight, d, 0644)
+						}
+					}
+				}
+
+				main_screen.TitleBar.InLowBackLight = 0
+				if time2 != 0 {
+					passout_time_stage = 1 // next
+				}
+			}
+			everytime_keydown = cur_time
+		} else if elapsed > gotime.Duration(time2)*gotime.Second && passout_time_stage == 1 {
+			fmt.Println("timeout, close screen ", elapsed)
+
+			if main_screen.Closed == true {
+				everytime_keydown = cur_time
+				continue
+			}
+			if UI.FileExists(sysgo.BackLight) {
+				d := []byte(fmt.Sprintf("%d", 0))
+				ioutil.WriteFile(sysgo.BackLight, d, 0644)
+			}
+
+			main_screen.TitleBar.InLowBackLight = 0
+			main_screen.Closed = true
+			if time3 != 0 {
+				passout_time_stage = 2 // next
+			}
+
+			everytime_keydown = cur_time
+		} else if elapsed > gotime.Duration(time3)*gotime.Second && passout_time_stage == 2 {
+
+			fmt.Println("Power Off counting down")
+
+			if UI.FileExists(sysgo.BackLight) { //hdmi does not have BackLight dev node
+				d := []byte(fmt.Sprintf("%d", last_brt))
+				ioutil.WriteFile(sysgo.BackLight, d, 0644)
+
+				main_screen.CounterScreen.Draw()
+				main_screen.CounterScreen.SwapAndShow()
+				main_screen.CounterScreen.StartCounter()
+
+			}
+
+			main_screen.TitleBar.InLowBackLight = 0
+
+			passout_time_stage = 4
+
+		}
+
+		gotime.Sleep(gotime.Duration(UI.DT) * gotime.Millisecond)
+	}
 }
 
-//If not under awesomeWM, AutoRedraw improves the experience of gsnotify 
+//If not under awesomeWM, AutoRedraw improves the experience of gsnotify
 //awesomeWM can hold individual window's content from being polluted without redrawing
 func AutoRedraw(main_screen *UI.MainScreen) {
 
 	for {
-    if main_screen.TitleBar.InLowBackLight < 0 {
-      UI.SwapAndShow()
-    }
-    gotime.Sleep(650 * gotime.Millisecond)
-  }
+		if main_screen.TitleBar.InLowBackLight < 0 {
+			UI.SwapAndShow()
+		}
+		gotime.Sleep(650 * gotime.Millisecond)
+	}
 }
 
-func PreparationInAdv(){
-  
-  if strings.Contains(runtime.GOARCH,"arm") == false {
-    return
-  }
-  
-  if UI.FileExists("sysgo/.powerlevel") == false {
-    UI.System("touch sysgo/.powerlevel")
-    UI.System(fmt.Sprintf("sudo iw %s set power_save off >/dev/null",sysgo.WifiDev))
-    
-  }else{
-    b, err := ioutil.ReadFile("sysgo/.powerlevel")
-    if err != nil {
-        log.Fatal(err)
-    }
-    
-    pwl := strings.Trim(string(b),"\r\n ")
-    
-    if pwl != ""{
-      sysgo.CurPowerLevel = pwl
-      if pwl == "supersaving" {
-        UI.System(fmt.Sprintf("sudo iw %s set power_save on >/dev/null",sysgo.WifiDev))
-      }else{
-        UI.System(fmt.Sprintf("sudo iw %s set power_save off >/dev/null",sysgo.WifiDev))
-      }
-    }else {
-      UI.System(fmt.Sprintf("sudo iw %s set power_save off >/dev/null",sysgo.WifiDev))
-    }
-  }
-  
+func PreparationInAdv() {
+
+	if strings.Contains(runtime.GOARCH, "arm") == false {
+		return
+	}
+
+	if UI.FileExists("sysgo/.powerlevel") == false {
+		UI.System("touch sysgo/.powerlevel")
+		UI.System(fmt.Sprintf("sudo iw %s set power_save off >/dev/null", sysgo.WifiDev))
+
+	} else {
+		b, err := ioutil.ReadFile("sysgo/.powerlevel")
+		if err != nil {
+			log.Fatal(err)
+		}
+
+		pwl := strings.Trim(string(b), "\r\n ")
+
+		if pwl != "" {
+			sysgo.CurPowerLevel = pwl
+			if pwl == "supersaving" {
+				UI.System(fmt.Sprintf("sudo iw %s set power_save on >/dev/null", sysgo.WifiDev))
+			} else {
+				UI.System(fmt.Sprintf("sudo iw %s set power_save off >/dev/null", sysgo.WifiDev))
+			}
+		} else {
+			UI.System(fmt.Sprintf("sudo iw %s set power_save off >/dev/null", sysgo.WifiDev))
+		}
+	}
+
 }
 
 func release_self_fds() {
-  fds_flags := []string{"pipe","socket:",".ttf"}
-  file_paths,err := filepath.Glob("/proc/self/fd/*")
-  if err != nil {
-    fmt.Println("release_self_fds error",err)
-    return
-  }
-  
-  ret := make(map[string]string)
-  path := ""
-  for _,v := range file_paths {
-    path,err = os.Readlink(v)
-    if err == nil {
-      ret[v] = path
-    }
-  }
-  
-  for k,v := range ret {
-    for _,f := range fds_flags {
-      if strings.Contains(v,f) {
-        id,_ :=  strconv.Atoi(filepath.Base(k))
-        //fmt.Println("closing ",id)
-        err = syscall.Close(id)
-        if err != nil {
-          fmt.Println("syscall.CLose err ",err)
-        }
-      }
-    }
-  }
+	fds_flags := []string{"pipe", "socket:", ".ttf"}
+	file_paths, err := filepath.Glob("/proc/self/fd/*")
+	if err != nil {
+		fmt.Println("release_self_fds error", err)
+		return
+	}
+
+	ret := make(map[string]string)
+	path := ""
+	for _, v := range file_paths {
+		path, err = os.Readlink(v)
+		if err == nil {
+			ret[v] = path
+		}
+	}
+
+	for k, v := range ret {
+		for _, f := range fds_flags {
+			if strings.Contains(v, f) {
+				id, _ := strconv.Atoi(filepath.Base(k))
+				//fmt.Println("closing ",id)
+				err = syscall.Close(id)
+				if err != nil {
+					fmt.Println("syscall.CLose err ", err)
+				}
+			}
+		}
+	}
 }
 
-func run() int {	
+func run() int {
 	display.Init()
 	font.Init()
-	screen := display.SetMode(int32(UI.Width),int32(UI.Height),0,32)
+	screen := display.SetMode(int32(UI.Width), int32(UI.Height), 0, 32)
 
 	UI.Init()
-  
-  PreparationInAdv()
-  
+
+	PreparationInAdv()
+
 	main_screen := UI.NewMainScreen()
 	main_screen.HWND = screen
 	main_screen.Init()
-		
+
 	title_bar := UI.NewTitleBar()
 	foot_bar := UI.NewFootBar()
 
 	title_bar.Init(main_screen)
 	foot_bar.Init(main_screen)
-	
+
 	main_screen.TitleBar = title_bar
-	main_screen.FootBar  = foot_bar
+	main_screen.FootBar = foot_bar
+
+	ReadTheDirIntoPages(main_screen, "Menu", 0, nil)
+	ReadTheDirIntoPages(main_screen, "/home/cpi/apps/Menu", 1, main_screen.Pages[len(main_screen.Pages)-1])
+	ReunionPagesIcons(main_screen)
 
-	ReadTheDirIntoPages(main_screen,"Menu",0,nil)
-  ReadTheDirIntoPages(main_screen,"/home/cpi/apps/Menu",1,main_screen.Pages[len(main_screen.Pages)-1])
-  ReunionPagesIcons(main_screen)
-  
 	main_screen.FartherPages()
-  
-  sound_patch = UI.NewSoundPatch()
-  sound_patch.Parent = main_screen
-  sound_patch.Init()
-  
+
+	sound_patch = UI.NewSoundPatch()
+	sound_patch.Parent = main_screen
+	sound_patch.Init()
+
 	main_screen.Draw()
 	main_screen.SwapAndShow()
 
 	UI.SwapAndShow()
-	
+
 	//fmt.Println(main_screen)
-  event.AllocEvents(5)
-  event.AddCustomEvent(UI.RUNEVT)
-  event.AddCustomEvent(UI.RUNSH)
-  event.AddCustomEvent(UI.RUNSYS)
-  event.AddCustomEvent(UI.RESTARTUI)
-  event.AddCustomEvent(UI.POWEROPT)
-
-  go FlashLed1(main_screen)
-  go InspectionTeam(main_screen)
-  go main_screen.TitleBar.RoundRobinCheck()
-  //go AutoRedraw(main_screen)
-  
+	event.AllocEvents(5)
+	event.AddCustomEvent(UI.RUNEVT)
+	event.AddCustomEvent(UI.RUNSH)
+	event.AddCustomEvent(UI.RUNSYS)
+	event.AddCustomEvent(UI.RESTARTUI)
+	event.AddCustomEvent(UI.POWEROPT)
+
+	go FlashLed1(main_screen)
+	go InspectionTeam(main_screen)
+	go main_screen.TitleBar.RoundRobinCheck()
+	//go AutoRedraw(main_screen)
+
 	running := true
 	for running {
-		ev := event.Poll()
+		ev := event.Wait()
 		if ev.Type == event.QUIT {
 			running = false
 			break
 		}
 		if ev.Type == event.USEREVENT {
 
-      
-			fmt.Println("UserEvent: ",ev.Data["Msg"])
-      
-      switch ev.Code {
-        case UI.RUNEVT:
-          main_screen.OnExitCb()      
-          gogame.Quit()          
-          
-          fmt.Println("RUNEVT")
-          
-          endpos := len(ev.Data["Msg"])
-          space_break_pos := endpos
-          for i:=0;i<endpos;i++ {
-            if i > 6 && string(ev.Data["Msg"][i]) == "/" && string(ev.Data["Msg"][i-1]) == " " {
-              space_break_pos = i-1
-              break
-            }
-          }
-          
-          exec_app_cmd := "cd " + filepath.Dir( ev.Data["Msg"][:space_break_pos] )+";"
-          exec_app_cmd += ev.Data["Msg"]
-          exec_app_cmd +="; sync & cd "+UI.GetExePath()+"; "+os.Args[0]+";"
-          fmt.Println(exec_app_cmd)
-          release_self_fds()
-          cmd := exec.Command("/bin/sh","-c",exec_app_cmd)
-          err := cmd.Start()
-          if err != nil {
-            fmt.Println(err)
-          }
-          err = cmd.Process.Release()
-          if err != nil {
-            fmt.Println(err)
-          }
-          os.Exit(0)
-          
-        case UI.RUNSYS:
-          main_screen.OnExitCb()      
-          gogame.Quit()   
-          release_self_fds()         
-          exec_app_cmd := ev.Data["Msg"]
-          cmd := exec.Command("/bin/sh","-c",exec_app_cmd)
-          err := cmd.Start()
-          if err != nil {
-            fmt.Println(err)
-          }
-          err = cmd.Process.Release()
-          if err != nil {
-            fmt.Println(err)
-          }
-          os.Exit(0)
-
-        case UI.RUNSH:
-          main_screen.OnExitCb()      
-          gogame.Quit()          
-          
-          fmt.Println("RUNSH")
-          exec_app_cmd := ev.Data["Msg"]+";"
-          fmt.Println(exec_app_cmd)
-          release_self_fds()
-          cmd := exec.Command("/bin/sh","-c",exec_app_cmd)
-          err := cmd.Start()
-          if err != nil {
-            fmt.Println(err)
-          }
-          err = cmd.Process.Release()
-          if err != nil {
-            fmt.Println(err)
-          }
-          os.Exit(0)          
-        
-        case UI.RESTARTUI:
-          main_screen.OnExitCb()      
-          gogame.Quit()
-          exec_app_cmd :=" sync & cd "+UI.GetExePath()+"; "+os.Args[0]+";"
-          fmt.Println(exec_app_cmd)
-          release_self_fds()
-          cmd := exec.Command("/bin/sh","-c",exec_app_cmd)
-          err := cmd.Start()
-          if err != nil {
-            fmt.Println(err)
-          }
-          err = cmd.Process.Release()
-          if err != nil {
-            fmt.Println(err)
-          }
-          os.Exit(0)
-          
-        case UI.POWEROPT:
-          everytime_keydown = gotime.Now()
-
-      }
-      
-      
+			fmt.Println("UserEvent: ", ev.Data["Msg"])
+
+			switch ev.Code {
+			case UI.RUNEVT:
+				main_screen.OnExitCb()
+				gogame.Quit()
+
+				fmt.Println("RUNEVT")
+
+				endpos := len(ev.Data["Msg"])
+				space_break_pos := endpos
+				for i := 0; i < endpos; i++ {
+					if i > 6 && string(ev.Data["Msg"][i]) == "/" && string(ev.Data["Msg"][i-1]) == " " {
+						space_break_pos = i - 1
+						break
+					}
+				}
+
+				exec_app_cmd := "cd " + filepath.Dir(ev.Data["Msg"][:space_break_pos]) + ";"
+				exec_app_cmd += ev.Data["Msg"]
+				exec_app_cmd += "; sync & cd " + UI.GetExePath() + "; " + os.Args[0] + ";"
+				fmt.Println(exec_app_cmd)
+				release_self_fds()
+				cmd := exec.Command("/bin/sh", "-c", exec_app_cmd)
+				err := cmd.Start()
+				if err != nil {
+					fmt.Println(err)
+				}
+				err = cmd.Process.Release()
+				if err != nil {
+					fmt.Println(err)
+				}
+				os.Exit(0)
+
+			case UI.RUNSYS:
+				main_screen.OnExitCb()
+				gogame.Quit()
+				release_self_fds()
+				exec_app_cmd := ev.Data["Msg"]
+				cmd := exec.Command("/bin/sh", "-c", exec_app_cmd)
+				err := cmd.Start()
+				if err != nil {
+					fmt.Println(err)
+				}
+				err = cmd.Process.Release()
+				if err != nil {
+					fmt.Println(err)
+				}
+				os.Exit(0)
+
+			case UI.RUNSH:
+				main_screen.OnExitCb()
+				gogame.Quit()
+
+				fmt.Println("RUNSH")
+				exec_app_cmd := ev.Data["Msg"] + ";"
+				fmt.Println(exec_app_cmd)
+				release_self_fds()
+				cmd := exec.Command("/bin/sh", "-c", exec_app_cmd)
+				err := cmd.Start()
+				if err != nil {
+					fmt.Println(err)
+				}
+				err = cmd.Process.Release()
+				if err != nil {
+					fmt.Println(err)
+				}
+				os.Exit(0)
+
+			case UI.RESTARTUI:
+				main_screen.OnExitCb()
+				gogame.Quit()
+				exec_app_cmd := " sync & cd " + UI.GetExePath() + "; " + os.Args[0] + ";"
+				fmt.Println(exec_app_cmd)
+				release_self_fds()
+				cmd := exec.Command("/bin/sh", "-c", exec_app_cmd)
+				err := cmd.Start()
+				if err != nil {
+					fmt.Println(err)
+				}
+				err = cmd.Process.Release()
+				if err != nil {
+					fmt.Println(err)
+				}
+				os.Exit(0)
+
+			case UI.POWEROPT:
+				everytime_keydown = gotime.Now()
+
+			}
+
 		}
 		if ev.Type == event.KEYDOWN {
-      everytime_keydown = gotime.Now()
-      if RestoreLastBackLightBrightness(main_screen) == false {
-        continue
-      }
-      
-      
+			everytime_keydown = gotime.Now()
+			if RestoreLastBackLightBrightness(main_screen) == false {
+				continue
+			}
+
 			if ev.Data["Key"] == "Q" {
 				main_screen.OnExitCb()
 				return 0
 			}
-      
-      
-      if ev.Data["Key"] == "Keypad +" {
-        if main_screen.CurPage().GetName() != "Sound volume" {
-          main_screen.Draw()
-          sound_patch.VolumeUp()
-          sound_patch.Draw()
-          main_screen.SwapAndShow()
-        }
-        continue
-      }
-      
-      if ev.Data["Key"] == "Keypad -" {
-        if main_screen.CurPage().GetName() != "Sound volume" {
-          main_screen.Draw()
-          sound_patch.VolumeDown()
-          sound_patch.Draw()
-          main_screen.SwapAndShow()       
-        
-        }
-        continue
-      }
-                  
+
+			if ev.Data["Key"] == "Keypad +" {
+				if main_screen.CurPage().GetName() != "Sound volume" {
+					main_screen.Draw()
+					sound_patch.VolumeUp()
+					sound_patch.Draw()
+					main_screen.SwapAndShow()
+				}
+				continue
+			}
+
+			if ev.Data["Key"] == "Keypad -" {
+				if main_screen.CurPage().GetName() != "Sound volume" {
+					main_screen.Draw()
+					sound_patch.VolumeDown()
+					sound_patch.Draw()
+					main_screen.SwapAndShow()
+
+				}
+				continue
+			}
+
 			main_screen.KeyDown(ev)
 			main_screen.LastKeyDown = everytime_keydown
 		}
-    
-    gotime.Sleep(50*gotime.Millisecond)
+
+		gotime.Sleep(50 * gotime.Millisecond)
 	}
 
 	return 0
 }
 
 func main() {
-	
+
 	var exitcode int
 	defer sdl.Quit()
 
-  //runtime.GOMAXPROCS(1)
-  
-	os.Setenv("SDL_VIDEO_CENTERED","1")
-	
+	//runtime.GOMAXPROCS(1)
+
+	os.Setenv("SDL_VIDEO_CENTERED", "1")
+
 	exitcode = run()
 
 	os.Exit(exitcode)

+ 200 - 201
mainscreen.go

@@ -1,154 +1,153 @@
 package main
 
-import (	
-  //"os"
+import (
+	//"os"
 	"fmt"
-  "log"
-  "io/ioutil"
-//  "strconv"
-  "strings"
-//  "runtime"
-  "path/filepath"
-  //os/exec"
-  "encoding/json"
-  "sort"
-  
-  "github.com/go-ini/ini"
-
-  "github.com/yookoala/realpath"
-
-  "github.com/clockworkpi/LauncherGoDev/sysgo/UI"
-  "github.com/clockworkpi/LauncherGoDev/sysgo/UI/Emulator"
-  "github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings"
-  "github.com/clockworkpi/LauncherGoDev/Menu/GameShell/98_TinyCloud"
-  "github.com/clockworkpi/LauncherGoDev/Menu/GameShell/99_PowerOFF"
+	"io/ioutil"
+	"log"
+	//  "strconv"
+	"strings"
+	//  "runtime"
+	"path/filepath"
+	//os/exec"
+	"encoding/json"
+	"sort"
+
+	"github.com/go-ini/ini"
+
+	"github.com/yookoala/realpath"
+
+	"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings"
+	"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/98_TinyCloud"
+	"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/99_PowerOFF"
+	"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
+	"github.com/clockworkpi/LauncherGoDev/sysgo/UI/Emulator"
 )
 
 var (
-  UIPluginList = []*UI.UIPlugin {
-    &UI.UIPlugin{1,"", "Menu/GameShell/10_Settings",     "Settings",  &Settings.APIOBJ},
-    &UI.UIPlugin{1,"", "Menu/GameShell/98_TinyCloud",    "TinyCloud", &TinyCloud.APIOBJ},
-    &UI.UIPlugin{1,"", "Menu/GameShell/99_PowerOFF",     "PowerOFF",  &PowerOFF.APIOBJ},
-  }
+	UIPluginList = []*UI.UIPlugin{
+		&UI.UIPlugin{1, "", "Menu/GameShell/10_Settings", "Settings", &Settings.APIOBJ},
+		&UI.UIPlugin{1, "", "Menu/GameShell/98_TinyCloud", "TinyCloud", &TinyCloud.APIOBJ},
+		&UI.UIPlugin{1, "", "Menu/GameShell/99_PowerOFF", "PowerOFF", &PowerOFF.APIOBJ},
+	}
 )
 
 func ReunionPagesIcons(self *UI.MainScreen) {
-    type Tup struct {
-      FileName string
-      OrigIdx  int
-    }
-    
-    var tmp []Tup
-    
-    for i,p := range self.Pages {
-      p_icons := p.GetIcons()
-      for i,x := range p_icons {
-        var t Tup
-        if x.GetFileName() != ""{
-          if strings.Contains(x.GetFileName(),"_") == false {
-            t = Tup{"98_"+x.GetFileName(),i}
-          }else {
-            t = Tup{x.GetFileName(),i}
-          }
-        }else{
-          t = Tup{"",i}
-        }
-        
-        tmp = append(tmp,t)
-      }
-      
-      sort.Slice(tmp, func(i, j int) bool { return tmp[i].FileName < tmp[j].FileName })
-      //fmt.Println(tmp)
-      
-      var retro_games_idx []int
-      retro_games_dir := "20_Retro Games"
-      for _,x := range tmp {
-        if strings.HasPrefix(x.FileName, retro_games_dir) {
-          retro_games_idx = append(retro_games_idx,x.OrigIdx)
-        }
-      }
-      
-      if len(retro_games_idx) > 1 {
-        p_icons_0_link_page := p_icons[retro_games_idx[0]].GetLinkPage().(*UI.Page)
-        for i:=1;i<len(retro_games_idx);i++ {
-          icons_other_page := p_icons[retro_games_idx[i]].GetLinkPage().GetIcons()
-          p_icons_0_link_page.Icons = append(p_icons_0_link_page.Icons, icons_other_page...)
-        }
-        
-        var tmpswap []Tup
-        onlyone := false
-        for _,x := range tmp {
-          if strings.HasPrefix(x.FileName,retro_games_dir) == false{
-            tmpswap = append(tmpswap,x)
-          }
-          
-          if strings.HasPrefix(x.FileName,retro_games_dir) == true && onlyone == false {
-            tmpswap = append(tmpswap,x)
-            onlyone = true
-          }
-        }
-        
-        tmp = tmpswap
-      }
-      
-      var new_icons []UI.IconItemInterface
-      for _,x := range tmp {
-        new_icons = append(new_icons, p_icons[x.OrigIdx])
-      }
-      self.Pages[i].(*UI.Page).Icons = new_icons
-    }
+	type Tup struct {
+		FileName string
+		OrigIdx  int
+	}
 
-}
+	var tmp []Tup
+
+	for i, p := range self.Pages {
+		p_icons := p.GetIcons()
+		for i, x := range p_icons {
+			var t Tup
+			if x.GetFileName() != "" {
+				if strings.Contains(x.GetFileName(), "_") == false {
+					t = Tup{"98_" + x.GetFileName(), i}
+				} else {
+					t = Tup{x.GetFileName(), i}
+				}
+			} else {
+				t = Tup{"", i}
+			}
+
+			tmp = append(tmp, t)
+		}
+
+		sort.Slice(tmp, func(i, j int) bool { return tmp[i].FileName < tmp[j].FileName })
+		//fmt.Println(tmp)
+
+		var retro_games_idx []int
+		retro_games_dir := "20_Retro Games"
+		for _, x := range tmp {
+			if strings.HasPrefix(x.FileName, retro_games_dir) {
+				retro_games_idx = append(retro_games_idx, x.OrigIdx)
+			}
+		}
+
+		if len(retro_games_idx) > 1 {
+			p_icons_0_link_page := p_icons[retro_games_idx[0]].GetLinkPage().(*UI.Page)
+			for i := 1; i < len(retro_games_idx); i++ {
+				icons_other_page := p_icons[retro_games_idx[i]].GetLinkPage().GetIcons()
+				p_icons_0_link_page.Icons = append(p_icons_0_link_page.Icons, icons_other_page...)
+			}
 
+			var tmpswap []Tup
+			onlyone := false
+			for _, x := range tmp {
+				if strings.HasPrefix(x.FileName, retro_games_dir) == false {
+					tmpswap = append(tmpswap, x)
+				}
+
+				if strings.HasPrefix(x.FileName, retro_games_dir) == true && onlyone == false {
+					tmpswap = append(tmpswap, x)
+					onlyone = true
+				}
+			}
+
+			tmp = tmpswap
+		}
+
+		var new_icons []UI.IconItemInterface
+		for _, x := range tmp {
+			new_icons = append(new_icons, p_icons[x.OrigIdx])
+		}
+		self.Pages[i].(*UI.Page).Icons = new_icons
+	}
+
+}
 
 func ReadTheDirIntoPages(self *UI.MainScreen, _dir string, pglevel int, cur_page UI.PageInterface) {
-	
+
 	if UI.FileExists(_dir) == false && UI.IsDirectory(_dir) == false {
 		return
 	}
 
-	files,err := ioutil.ReadDir(_dir)
+	files, err := ioutil.ReadDir(_dir)
 	if err != nil {
 		log.Fatal(err)
 		return
 	}
 
-	for _,f := range files { // already sorted
-		if UI.IsDirectory( _dir +"/"+f.Name()) && strings.HasPrefix( f.Name(), ".") == false {
+	for _, f := range files { // already sorted
+		if UI.IsDirectory(_dir+"/"+f.Name()) && strings.HasPrefix(f.Name(), ".") == false {
 			if pglevel == 0 {
 				page := UI.NewPage()
 				page.Name = self.ExtraName(f.Name())
 				self.Pages = append(self.Pages, page)
-				ReadTheDirIntoPages(self,_dir+"/"+f.Name(),pglevel+1, self.Pages[ len(self.Pages) - 1] )
-			}else{ // on cur_page now
-				i2:= self.ExtraName(f.Name())
+				ReadTheDirIntoPages(self, _dir+"/"+f.Name(), pglevel+1, self.Pages[len(self.Pages)-1])
+			} else { // on cur_page now
+				i2 := self.ExtraName(f.Name())
 				iconitem := UI.NewIconItem()
-        iconitem.FileName = f.Name()
-				iconitem.AddLabel(i2,self.IconFont)
-        if UI.FileExists(filepath.Join(_dir,f.Name(),i2+".png")) { //eg: 20_Prog/Prog.png , cut 20_ 
-          iconitem.ImageName = filepath.Join(_dir,f.Name(),i2+".png")
-          
-        }else if UI.FileExists( UI.SkinMap(_dir+"/"+i2+".png")) {
-					iconitem.ImageName = UI.SkinMap(_dir+"/"+i2+".png")
-				}else {
+				iconitem.FileName = f.Name()
+				iconitem.AddLabel(i2, self.IconFont)
+				if UI.FileExists(filepath.Join(_dir, f.Name(), i2+".png")) { //eg: 20_Prog/Prog.png , cut 20_
+					iconitem.ImageName = filepath.Join(_dir, f.Name(), i2+".png")
+
+				} else if UI.FileExists(UI.SkinMap(_dir + "/" + i2 + ".png")) {
+					iconitem.ImageName = UI.SkinMap(_dir + "/" + i2 + ".png")
+				} else {
 					//fmt.Println(  UI.SkinMap(_dir+"/"+i2+".png") )
 					untitled := UI.NewUntitledIcon()
 					untitled.Init()
 					if len(i2) > 1 {
-						untitled.SetWords(string(i2[0]),string(i2[1]))
-					}else if len(i2) == 1 {
-						untitled.SetWords(string(i2[0]),string(i2[0]))
-					}else {
-						untitled.SetWords("G","s")
+						untitled.SetWords(string(i2[0]), string(i2[1]))
+					} else if len(i2) == 1 {
+						untitled.SetWords(string(i2[0]), string(i2[0]))
+					} else {
+						untitled.SetWords("G", "s")
 					}
 					iconitem.ImgSurf = untitled.Surface()
 					iconitem.ImageName = ""
 				}
 
-				if self.IsPluginPackage(_dir+"/"+f.Name()) {
+				if self.IsPluginPackage(_dir + "/" + f.Name()) {
 					p_c := UI.PluginConfig{}
-          
-					dat, err := ioutil.ReadFile(_dir+"/"+f.Name()+"/" +UI.Plugin_flag)
+
+					dat, err := ioutil.ReadFile(_dir + "/" + f.Name() + "/" + UI.Plugin_flag)
 					UI.ShowErr(err)
 
 					err = json.Unmarshal(dat, &p_c)
@@ -156,114 +155,114 @@ func ReadTheDirIntoPages(self *UI.MainScreen, _dir string, pglevel int, cur_page
 						if p_c.NAME == "" {
 							p_c.NAME = f.Name()
 						}
-            
-            so_file := filepath.Join(_dir,f.Name(),p_c.SO_FILE)
-            if UI.FileExists(so_file) && UI.IsAFile(so_file) {
-              pi,err := UI.LoadPlugin(_dir+"/"+f.Name()+"/"+p_c.SO_FILE)
-              UI.Assert(err)
-              iconitem.CmdInvoke = UI.InitPlugin(pi,self)
-              if iconitem.CmdInvoke != nil {
-							
-                iconitem.MyType = UI.ICON_TYPES["FUNC"]
-                iconitem.CmdPath = f.Name()
-                cur_page.AppendIcon(iconitem)
-              }
-            } else {
-              for _,v := range UIPluginList {
-                if v.LabelText == p_c.NAME {
-                  v.EmbInterface.Init(self)
-                  iconitem.CmdInvoke = v.EmbInterface
-                  if iconitem.CmdInvoke != nil {
-                    iconitem.MyType = UI.ICON_TYPES["FUNC"]
-                    iconitem.CmdPath = f.Name()
-                    cur_page.AppendIcon(iconitem)
-                  }                 
-                }
-              }
-            }
-          }
-					//Init it 
-				}else if self.IsEmulatorPackage(_dir+"/"+f.Name()) {
-          a_c := Emulator.ActionConfig{}
-          a_c.FILETYPE="file"
-          a_c.TITLE = "Game"
-          cfg, err := ini.Load(_dir+"/"+f.Name()+"/" +UI.Emulator_flag)
+
+						so_file := filepath.Join(_dir, f.Name(), p_c.SO_FILE)
+						if UI.FileExists(so_file) && UI.IsAFile(so_file) {
+							pi, err := UI.LoadPlugin(_dir + "/" + f.Name() + "/" + p_c.SO_FILE)
+							UI.Assert(err)
+							iconitem.CmdInvoke = UI.InitPlugin(pi, self)
+							if iconitem.CmdInvoke != nil {
+
+								iconitem.MyType = UI.ICON_TYPES["FUNC"]
+								iconitem.CmdPath = f.Name()
+								cur_page.AppendIcon(iconitem)
+							}
+						} else {
+							for _, v := range UIPluginList {
+								if v.LabelText == p_c.NAME {
+									v.EmbInterface.Init(self)
+									iconitem.CmdInvoke = v.EmbInterface
+									if iconitem.CmdInvoke != nil {
+										iconitem.MyType = UI.ICON_TYPES["FUNC"]
+										iconitem.CmdPath = f.Name()
+										cur_page.AppendIcon(iconitem)
+									}
+								}
+							}
+						}
+					}
+					//Init it
+				} else if self.IsEmulatorPackage(_dir + "/" + f.Name()) {
+					a_c := Emulator.ActionConfig{}
+					a_c.FILETYPE = "file"
+					a_c.TITLE = "Game"
+					cfg, err := ini.Load(_dir + "/" + f.Name() + "/" + UI.Emulator_flag)
 					UI.ShowErr(err)
 
 					err = cfg.MapTo(&a_c)
-          
+
 					if err == nil {
-            //fmt.Println(a_c)
-            if UI.FileExists(filepath.Join(_dir,f.Name(),"retroarch-local.cfg")) {
-              a_c.RETRO_CONFIG = UI.CmdClean( filepath.Join(_dir,f.Name(),"retroarch-local.cfg") )
-              fmt.Println("a local retroarch cfg: ",a_c.RETRO_CONFIG)
-            }
-            
-            em := Emulator.NewMyEmulator()
-            em.EmulatorConfig = &a_c
-            em.Init(self)
-            
-            iconitem.CmdInvoke = em
-            if iconitem.CmdInvoke != nil {
-              iconitem.MyType = UI.ICON_TYPES["Emulator"]
-              iconitem.CmdPath = f.Name()
-              cur_page.AppendIcon(iconitem)
-            }
-          }else {
-            fmt.Println("ReadTheDirIntoPages EmulatorConfig ",err)
-          }
-        
-        }else if self.IsExecPackage(_dir+"/"+f.Name()) {
-          iconitem.MyType = UI.ICON_TYPES["EXE"]
-          rel_path,err := realpath.Realpath( filepath.Join(_dir,f.Name(),i2+".sh"))
-          if err != nil {
-            rel_path,_ = filepath.Abs(filepath.Join(_dir,f.Name(),i2+".sh"))
-          }
-          iconitem.CmdPath = rel_path
-          UI.MakeExecutable( iconitem.CmdPath )
-          cur_page.AppendIcon(iconitem)
-        }else {
+						//fmt.Println(a_c)
+						if UI.FileExists(filepath.Join(_dir, f.Name(), "retroarch-local.cfg")) {
+							a_c.RETRO_CONFIG = UI.CmdClean(filepath.Join(_dir, f.Name(), "retroarch-local.cfg"))
+							fmt.Println("a local retroarch cfg: ", a_c.RETRO_CONFIG)
+						}
+
+						em := Emulator.NewMyEmulator()
+						em.EmulatorConfig = &a_c
+						em.Init(self)
+
+						iconitem.CmdInvoke = em
+						if iconitem.CmdInvoke != nil {
+							iconitem.MyType = UI.ICON_TYPES["Emulator"]
+							iconitem.CmdPath = f.Name()
+							cur_page.AppendIcon(iconitem)
+						}
+					} else {
+						fmt.Println("ReadTheDirIntoPages EmulatorConfig ", err)
+					}
+
+				} else if self.IsExecPackage(_dir + "/" + f.Name()) {
+					iconitem.MyType = UI.ICON_TYPES["EXE"]
+					rel_path, err := realpath.Realpath(filepath.Join(_dir, f.Name(), i2+".sh"))
+					if err != nil {
+						rel_path, _ = filepath.Abs(filepath.Join(_dir, f.Name(), i2+".sh"))
+					}
+					iconitem.CmdPath = rel_path
+					UI.MakeExecutable(iconitem.CmdPath)
+					cur_page.AppendIcon(iconitem)
+				} else {
 					iconitem.MyType = UI.ICON_TYPES["DIR"]
 					linkpage := UI.NewPage()
-					linkpage.Name = i2					
+					linkpage.Name = i2
 					iconitem.LinkPage = linkpage
 					cur_page.AppendIcon(iconitem)
-					ReadTheDirIntoPages(self,_dir+"/"+f.Name(),pglevel+1, iconitem.LinkPage)
+					ReadTheDirIntoPages(self, _dir+"/"+f.Name(), pglevel+1, iconitem.LinkPage)
 				}
-				
+
 			}
-		} else if UI.IsAFile(_dir+"/"+f.Name()) && strings.HasPrefix( f.Name(), ".") == false && (pglevel > 0) {
-			if strings.HasSuffix(strings.ToLower(f.Name()),UI.IconExt) {
+		} else if UI.IsAFile(_dir+"/"+f.Name()) && strings.HasPrefix(f.Name(), ".") == false && (pglevel > 0) {
+			if strings.HasSuffix(strings.ToLower(f.Name()), UI.IconExt) {
 				i2 := self.ExtraName(f.Name())
 				iconitem := UI.NewIconItem()
-        rel_path,err := realpath.Realpath( _dir+"/"+f.Name() )
-        if err != nil {
-          rel_path,_ = filepath.Abs(_dir+"/"+f.Name())
-        }
-        
+				rel_path, err := realpath.Realpath(_dir + "/" + f.Name())
+				if err != nil {
+					rel_path, _ = filepath.Abs(_dir + "/" + f.Name())
+				}
+
 				iconitem.CmdPath = rel_path
-        iconitem.FileName = f.Name()
-        
-				UI.MakeExecutable( iconitem.CmdPath )
+				iconitem.FileName = f.Name()
+
+				UI.MakeExecutable(iconitem.CmdPath)
 				iconitem.MyType = UI.ICON_TYPES["EXE"]
-				if UI.FileExists( UI.SkinMap( _dir+"/"+ UI.ReplaceSuffix(i2,"png"))) {
-					iconitem.ImageName = UI.SkinMap( _dir+"/"+ UI.ReplaceSuffix(i2,"png"))
-				}else {
-					
-					untitled:= UI.NewUntitledIcon()
+				if UI.FileExists(UI.SkinMap(_dir + "/" + UI.ReplaceSuffix(i2, "png"))) {
+					iconitem.ImageName = UI.SkinMap(_dir + "/" + UI.ReplaceSuffix(i2, "png"))
+				} else {
+
+					untitled := UI.NewUntitledIcon()
 					untitled.Init()
 					if len(i2) > 1 {
-						untitled.SetWords(string(i2[0]),string(i2[1]))
-					}else if len(i2) == 1 {
-						untitled.SetWords(string(i2[0]),string(i2[0]))
-					}else {
-						untitled.SetWords("G","s")
+						untitled.SetWords(string(i2[0]), string(i2[1]))
+					} else if len(i2) == 1 {
+						untitled.SetWords(string(i2[0]), string(i2[0]))
+					} else {
+						untitled.SetWords("G", "s")
 					}
 					iconitem.ImgSurf = untitled.Surface()
 					iconitem.ImageName = ""
 				}
 
-				iconitem.AddLabel(strings.Split(i2,".")[0], self.IconFont)
+				iconitem.AddLabel(strings.Split(i2, ".")[0], self.IconFont)
 				iconitem.LinkPage = nil
 				cur_page.AppendIcon(iconitem)
 			}

+ 102 - 103
sysgo/DBUS/dbus.go

@@ -2,27 +2,27 @@ package DBUS
 
 import (
 	"fmt"
-  "strings"
+	"strings"
 	//"strconv"
 	"github.com/godbus/dbus"
 )
 
 type DbusInterface struct {
-	Dest string
-	Path dbus.ObjectPath
-	Iface string
-	Obj *dbus.Object
-  SigFuncs  map[string]interface{}
+	Dest     string
+	Path     dbus.ObjectPath
+	Iface    string
+	Obj      *dbus.Object
+	SigFuncs map[string]interface{}
 }
 
-func NewDbusInterface(conn *dbus.Conn,dest string, path dbus.ObjectPath ,iface string) *DbusInterface {
-  m := &DbusInterface{}
-	o := conn.Object(dest,path)
+func NewDbusInterface(conn *dbus.Conn, dest string, path dbus.ObjectPath, iface string) *DbusInterface {
+	m := &DbusInterface{}
+	o := conn.Object(dest, path)
 
 	m.Obj = o.(*dbus.Object)
 	m.Dest = dest
 	m.Path = path
-  
+
 	m.SigFuncs = make(map[string]interface{})
 
 	if len(iface) > 2 {
@@ -31,53 +31,52 @@ func NewDbusInterface(conn *dbus.Conn,dest string, path dbus.ObjectPath ,iface s
 	return m
 }
 
-func (self *DbusInterface) Method(name string, args...interface{} ) *dbus.Call {
+func (self *DbusInterface) Method(name string, args ...interface{}) *dbus.Call {
 	var method string
 	if self.Iface != "" {
-		method = fmt.Sprintf("%s.%s.%s", self.Dest, self.Iface,name)
-	}else {
-		method = fmt.Sprintf("%s.%s", self.Dest,name)
+		method = fmt.Sprintf("%s.%s.%s", self.Dest, self.Iface, name)
+	} else {
+		method = fmt.Sprintf("%s.%s", self.Dest, name)
 	}
 
 	if args != nil {
-		return self.Obj.Call( method , 0,args...)
-	}else {
-		return self.Obj.Call( method, 0)
+		return self.Obj.Call(method, 0, args...)
+	} else {
+		return self.Obj.Call(method, 0)
 	}
 }
 
-func (self *DbusInterface) Get( thecall *dbus.Call, retvalues ...interface{}) error {
+func (self *DbusInterface) Get(thecall *dbus.Call, retvalues ...interface{}) error {
 	if len(thecall.Body) == 0 {
 		return nil
 	}
-	err:=  thecall.Store(retvalues...)
-  
+	err := thecall.Store(retvalues...)
+
 	if err != nil {
-		panic(fmt.Sprintf("Failed: %s,%s",err,thecall.Method))
+		panic(fmt.Sprintf("Failed: %s,%s", err, thecall.Method))
 	}
-  
-  return err
+
+	return err
 }
 
 func (self *DbusInterface) EnableSignal(signame string) {
-  iface := self.Dest
-  if self.Iface != "" {
-    iface = iface+ "."+self.Iface
-  }
-  self.Obj.AddMatchSignal(iface,signame)
+	iface := self.Dest
+	if self.Iface != "" {
+		iface = iface + "." + self.Iface
+	}
+	self.Obj.AddMatchSignal(iface, signame)
 }
 
+func (self *DbusInterface) HandleSignal(sig *dbus.Signal) {
 
-func (self *DbusInterface) HandleSignal( sig *dbus.Signal) {
-	
 	iface := self.Dest
 	if self.Iface != "" {
-		iface = iface+ "."+self.Iface
+		iface = iface + "." + self.Iface
 	}
 
-	if strings.HasPrefix(sig.Name,iface) {
-		func_name := strings.Replace( sig.Name, iface, "",-1)[1:]
-		for k,v := range self.SigFuncs {
+	if strings.HasPrefix(sig.Name, iface) {
+		func_name := strings.Replace(sig.Name, iface, "", -1)[1:]
+		for k, v := range self.SigFuncs {
 			if k == func_name {
 				v.(func([]interface{}))(sig.Body)
 				break
@@ -89,13 +88,13 @@ func (self *DbusInterface) HandleSignal( sig *dbus.Signal) {
 
 type DBusInterface interface {
 	WifiStrength() int
-	IsWifiConnectedNow() bool 	
+	IsWifiConnectedNow() bool
 }
 
 type DBus struct {
-	Conn *dbus.Conn
+	Conn   *dbus.Conn
 	Daemon *DbusInterface
-  Wifi    *DbusInterface
+	Wifi   *DbusInterface
 }
 
 func NewDBus() *DBus {
@@ -104,130 +103,130 @@ func NewDBus() *DBus {
 }
 
 func (self *DBus) Init() {
-  //conn_option := dbus.WithSignalHandler(self)
-  
+	//conn_option := dbus.WithSignalHandler(self)
+
 	conn, err := dbus.SystemBus()
-  //conn,err := dbus.SystemBusPrivate(conn_option)
-  
-  if err != nil {
-    panic(fmt.Sprintf("Failed to connect to system bus:", err))
-  }
+	//conn,err := dbus.SystemBusPrivate(conn_option)
+
+	if err != nil {
+		panic(fmt.Sprintf("Failed to connect to system bus:", err))
+	}
 
 	self.Conn = conn
 
-	self.Daemon = NewDbusInterface(conn, "org.wicd.daemon","/org/wicd/daemon" ,"",)
-	self.Wifi   = NewDbusInterface(conn, "org.wicd.daemon","/org/wicd/daemon/wireless","wireless")
+	self.Daemon = NewDbusInterface(conn, "org.wicd.daemon", "/org/wicd/daemon", "")
+	self.Wifi = NewDbusInterface(conn, "org.wicd.daemon", "/org/wicd/daemon/wireless", "wireless")
 }
 
 func (self *DBus) WifiStrength() int {
 	var fast bool
 	var iwconfig string
-  var sig_display_type int
+	var sig_display_type int
 	var strength int
 
-	self.Daemon.Get( self.Daemon.Method("NeedsExternalCalls"), &fast)
+	self.Daemon.Get(self.Daemon.Method("NeedsExternalCalls"), &fast)
 
 	if fast == false {
-			self.Wifi.Get( self.Wifi.Method("GetIwconfig"), &iwconfig  )
-	}else{
+		self.Wifi.Get(self.Wifi.Method("GetIwconfig"), &iwconfig)
+	} else {
 		iwconfig = ""
 	}
-	self.Daemon.Get( self.Daemon.Method("GetSignalDisplayType"), &sig_display_type )
-	
+	self.Daemon.Get(self.Daemon.Method("GetSignalDisplayType"), &sig_display_type)
+
 	if sig_display_type == 0 {
-		self.Wifi.Get( self.Wifi.Method("GetCurrentSignalStrength",iwconfig), &strength)
-	} else{
-		self.Wifi.Get( self.Wifi.Method("GetCurrentDBMStrength",iwconfig), &strength)
+		self.Wifi.Get(self.Wifi.Method("GetCurrentSignalStrength", iwconfig), &strength)
+	} else {
+		self.Wifi.Get(self.Wifi.Method("GetCurrentDBMStrength", iwconfig), &strength)
 	}
 
-	return strength	
+	return strength
 }
 
-func (self *DBus) check_for_wireless(iwconfig string, wireless_ip string)  bool {
-  var network string
-  var sig_display_type int
+func (self *DBus) check_for_wireless(iwconfig string, wireless_ip string) bool {
+	var network string
+	var sig_display_type int
 	var strength int
 	if wireless_ip == "" {
 		return false
 	}
 
-	self.Wifi.Get( self.Wifi.Method("GetCurrentNetwork",iwconfig), &network)
-	self.Daemon.Get( self.Daemon.Method("GetSignalDisplayType"), &sig_display_type )
-	
+	self.Wifi.Get(self.Wifi.Method("GetCurrentNetwork", iwconfig), &network)
+	self.Daemon.Get(self.Daemon.Method("GetSignalDisplayType"), &sig_display_type)
+
 	if sig_display_type == 0 {
-		self.Wifi.Get( self.Wifi.Method("GetCurrentSignalStrength",iwconfig), &strength)
-	}else {
-		self.Wifi.Get( self.Wifi.Method("GetCurrentDBMStrength",iwconfig), &strength)
+		self.Wifi.Get(self.Wifi.Method("GetCurrentSignalStrength", iwconfig), &strength)
+	} else {
+		self.Wifi.Get(self.Wifi.Method("GetCurrentDBMStrength", iwconfig), &strength)
 	}
 
 	if strength == 0 {
 		return false
 	}
 	strength_str := ""
-	self.Daemon.Get( self.Daemon.Method("FormatSignalForPrinting",strength), &strength_str)
+	self.Daemon.Get(self.Daemon.Method("FormatSignalForPrinting", strength), &strength_str)
 
 	return true
 }
 
 func (self *DBus) GetWifiIP() string {
-  var wireless_ip string
-  if self.Wifi != nil {
-    self.Wifi.Get( self.Wifi.Method("GetWirelessIP", ""), &wireless_ip)
-  }
-  return wireless_ip
-  
+	var wireless_ip string
+	if self.Wifi != nil {
+		self.Wifi.Get(self.Wifi.Method("GetWirelessIP", ""), &wireless_ip)
+	}
+	return wireless_ip
+
 }
 
 func (self *DBus) IsWifiConnectedNow() bool {
-  var fast bool
-  var iwconfig string
-  var wireless_connecting bool
+	var fast bool
+	var iwconfig string
+	var wireless_connecting bool
 	var wireless_ip string
 
-	self.Wifi.Get( self.Wifi.Method("CheckIfWirelessConnecting"), &wireless_connecting  )
-	self.Daemon.Get( self.Daemon.Method("NeedsExternalCalls"), &fast)
+	self.Wifi.Get(self.Wifi.Method("CheckIfWirelessConnecting"), &wireless_connecting)
+	self.Daemon.Get(self.Daemon.Method("NeedsExternalCalls"), &fast)
 	if wireless_connecting == true {
 		return false
-	}else {
+	} else {
 		if fast == false {
-			self.Wifi.Get( self.Wifi.Method("GetIwconfig"), &iwconfig  )
-		}else {
+			self.Wifi.Get(self.Wifi.Method("GetIwconfig"), &iwconfig)
+		} else {
 			iwconfig = ""
 		}
 
-		self.Wifi.Get( self.Wifi.Method("GetWirelessIP", iwconfig), &wireless_ip)
-		
-		if self.check_for_wireless(iwconfig,wireless_ip) == true {
+		self.Wifi.Get(self.Wifi.Method("GetWirelessIP", iwconfig), &wireless_ip)
+
+		if self.check_for_wireless(iwconfig, wireless_ip) == true {
 			return true
-		}else {
+		} else {
 			return false
 		}
-		
-	}	
+
+	}
 }
 
 func (self *DBus) ListenSignal() {
 	c := make(chan *dbus.Signal, 10)
 	self.Conn.Signal(c)
-  
-  for v := range c {
-    //fmt.Printf("%+v %#v\n",v,v)
-    //fmt.Printf("body len:%d \n\n",len(v.Body)) 
-    
-    self.Wifi.HandleSignal(v)
-    self.Daemon.HandleSignal(v)
-    
-  }  
+
+	for v := range c {
+		//fmt.Printf("%+v %#v\n",v,v)
+		//fmt.Printf("body len:%d \n\n",len(v.Body))
+
+		self.Wifi.HandleSignal(v)
+		self.Daemon.HandleSignal(v)
+
+	}
 }
 
-var DBusHandler *DBus //global 
+var DBusHandler *DBus //global
 
 func init() {
-  if DBusHandler == nil {
-    DBusHandler = NewDBus()
-    DBusHandler.Init()
-  
-    go DBusHandler.ListenSignal()
-  }
-  
+	if DBusHandler == nil {
+		DBusHandler = NewDBus()
+		DBusHandler.Init()
+
+		go DBusHandler.ListenSignal()
+	}
+
 }

+ 49 - 59
sysgo/UI/Emulator/emulator.go

@@ -1,87 +1,77 @@
 package Emulator
 
 import (
-
-  "github.com/clockworkpi/LauncherGoDev/sysgo/UI"
+	"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
 )
 
 type ActionConfig struct {
-	ROM string `ini:"ROM"`
-	ROM_SO string `ini:"ROM_SO"`
-	EXT []string   `ini:"EXT,omitempty"`
-	EXCLUDE []string `ini:"EXCLUDE,omitempty"`
-	FILETYPE string  `ini:"FILETYPE"`   // defalut is file
-	LAUNCHER string  `ini:"LAUNCHER"`
-	TITLE   string   `ini:"TITLE"` // defaut is Game
-	SO_URL string    `ini:"SO_URL"`
-	RETRO_CONFIG string `ini:"RETRO_CONFIG"`
+	ROM          string   `ini:"ROM"`
+	ROM_SO       string   `ini:"ROM_SO"`
+	EXT          []string `ini:"EXT,omitempty"`
+	EXCLUDE      []string `ini:"EXCLUDE,omitempty"`
+	FILETYPE     string   `ini:"FILETYPE"` // defalut is file
+	LAUNCHER     string   `ini:"LAUNCHER"`
+	TITLE        string   `ini:"TITLE"` // defaut is Game
+	SO_URL       string   `ini:"SO_URL"`
+	RETRO_CONFIG string   `ini:"RETRO_CONFIG"`
 }
 
-
 var (
-  FavGID = 31415
-  FavGname = "cpifav"
-  
+	FavGID   = 31415
+	FavGname = "cpifav"
 )
 
-
 type MyEmulator struct { // as leader of RomListPage and FavListPage, it's a PluginInterface
-  Name string
-  RomPage *RomListPage
-  FavPage *FavListPage
-  DeleteConfirmPage *UI.DeleteConfirmPage
-  EmulatorConfig *ActionConfig
-  
-  SpeedMax int
-  SpeedTimeInter int
-  
+	Name              string
+	RomPage           *RomListPage
+	FavPage           *FavListPage
+	DeleteConfirmPage *UI.DeleteConfirmPage
+	EmulatorConfig    *ActionConfig
+
+	SpeedMax       int
+	SpeedTimeInter int
 }
 
-func NewMyEmulator() *MyEmulator{
-  p := &MyEmulator{}
-  
-  p.SpeedMax = 5
-  p.SpeedTimeInter = 300
-  
-  return p
+func NewMyEmulator() *MyEmulator {
+	p := &MyEmulator{}
+
+	p.SpeedMax = 5
+	p.SpeedTimeInter = 300
+
+	return p
 }
 
 func (self *MyEmulator) GetName() string {
-  return "MyEmulator"
+	return "MyEmulator"
 }
 
-func (self *MyEmulator) Init(main_screen  *UI.MainScreen) {
-  self.DeleteConfirmPage = UI.NewDeleteConfirmPage()
-  self.DeleteConfirmPage.Screen = main_screen
-  self.DeleteConfirmPage.Name  = "Delete Confirm"
-  self.DeleteConfirmPage.Init()
+func (self *MyEmulator) Init(main_screen *UI.MainScreen) {
+	self.DeleteConfirmPage = UI.NewDeleteConfirmPage()
+	self.DeleteConfirmPage.Screen = main_screen
+	self.DeleteConfirmPage.Name = "Delete Confirm"
+	self.DeleteConfirmPage.Init()
+
+	self.RomPage = NewRomListPage()
+	self.RomPage.Screen = main_screen
+	self.RomPage.Name = self.EmulatorConfig.TITLE
+	self.RomPage.EmulatorConfig = self.EmulatorConfig
+	self.RomPage.Leader = self
+	self.RomPage.Init()
+
+	self.FavPage = NewFavListPage()
+	self.FavPage.Screen = main_screen
+	self.FavPage.Name = "FavouriteGames"
+	self.FavPage.EmulatorConfig = self.EmulatorConfig
+	self.FavPage.Leader = self
+	self.FavPage.Init()
 
-  self.RomPage = NewRomListPage()
-  self.RomPage.Screen = main_screen
-  self.RomPage.Name  = self.EmulatorConfig.TITLE
-  self.RomPage.EmulatorConfig = self.EmulatorConfig
-  self.RomPage.Leader = self
-  self.RomPage.Init()
-  
-  self.FavPage = NewFavListPage()
-  self.FavPage.Screen = main_screen
-  self.FavPage.Name = "FavouriteGames"
-  self.FavPage.EmulatorConfig = self.EmulatorConfig
-  self.FavPage.Leader = self
-  self.FavPage.Init()
-  
-  
-  
 }
 
 func (self *MyEmulator) Run(main_screen *UI.MainScreen) {
 	if main_screen != nil {
-    main_screen.PushCurPage()
-    main_screen.SetCurPage(self.RomPage)
+		main_screen.PushCurPage()
+		main_screen.SetCurPage(self.RomPage)
 		main_screen.Draw()
 		main_screen.SwapAndShow()
 	}
 }
-
-
-

+ 473 - 487
sysgo/UI/Emulator/fav_list_page.go

@@ -1,550 +1,536 @@
 package Emulator
 
 import (
-  "fmt"
-  "os"
-  "strings"
-  "path/filepath"
-  "errors"
-  gotime "time"
-  "github.com/veandco/go-sdl2/ttf"
-  
-  "github.com/cuu/gogame/event"
-
-  "github.com/cuu/gogame/color"
+	"errors"
+	"fmt"
+	"github.com/veandco/go-sdl2/ttf"
+	"os"
+	"path/filepath"
+	"strings"
+	gotime "time"
+
+	"github.com/cuu/gogame/event"
+
+	"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
+	"github.com/cuu/gogame/color"
 	"github.com/cuu/gogame/time"
-  "github.com/clockworkpi/LauncherGoDev/sysgo/UI"
-
 )
 
 type FavListPage struct {
-  UI.Page
-  Icons  map[string]UI.IconItemInterface
-  ListFont *ttf.Font
-  MyStack *UI.FolderStack
-  EmulatorConfig *ActionConfig
-  
-  RomSoConfirmDownloadPage *RomSoConfirmPage
-  
-  MyList []UI.ListItemInterface
-  BGwidth int
-  BGheight int //70
-  Scroller *UI.ListScroller
-  Scrolled int 
-  Leader *MyEmulator
-  
+	UI.Page
+	Icons          map[string]UI.IconItemInterface
+	ListFont       *ttf.Font
+	MyStack        *UI.FolderStack
+	EmulatorConfig *ActionConfig
+
+	RomSoConfirmDownloadPage *RomSoConfirmPage
+
+	MyList   []UI.ListItemInterface
+	BGwidth  int
+	BGheight int //70
+	Scroller *UI.ListScroller
+	Scrolled int
+	Leader   *MyEmulator
 }
 
 func NewFavListPage() *FavListPage {
-  p := &FavListPage{}
-  p.PageIconMargin = 20
+	p := &FavListPage{}
+	p.PageIconMargin = 20
 	p.SelectedIconTopOffset = 20
 	p.EasingDur = 10
 
 	p.Align = UI.ALIGN["SLeft"]
-	
-	p.FootMsg = [5]string{ "Nav","Scan","Remove","","Run" }
-  
-  p.Icons=make(map[string]UI.IconItemInterface)
-  p.ListFont =  UI.Fonts["notosanscjk15"]
-  
-  p.MyStack = UI.NewFolderStack()
-  
-  p.BGwidth = 75
-  p.BGheight = 73
-  
-  p.ScrollStep = 1
-
-  return p
+
+	p.FootMsg = [5]string{"Nav", "Scan", "Remove", "", "Run"}
+
+	p.Icons = make(map[string]UI.IconItemInterface)
+	p.ListFont = UI.Fonts["notosanscjk15"]
+
+	p.MyStack = UI.NewFolderStack()
+
+	p.BGwidth = 75
+	p.BGheight = 73
+
+	p.ScrollStep = 1
+
+	return p
 }
 
 func (self *FavListPage) GetMyList() []UI.ListItemInterface {
-  return self.MyList
+	return self.MyList
 }
 
 func (self *FavListPage) GetMapIcons() map[string]UI.IconItemInterface {
-  return self.Icons
+	return self.Icons
 }
 
 func (self *FavListPage) GetEmulatorConfig() *ActionConfig {
-  return self.EmulatorConfig
+	return self.EmulatorConfig
 }
 
-func (self *FavListPage) GeneratePathList(path string) ([]map[string]string,error) {
-  if UI.IsDirectory(path) == false {
-    return nil,errors.New("Path is not a folder")
-  }
-  dirmap := make(map[string]string)
-  var ret []map[string]string
-  
-  file_paths,err := filepath.Glob(path+"/*")//sorted
-  if err != nil {
-    fmt.Println(err)
-    return ret,err
-  }
-  
-  for _,v := range file_paths {
-    if UI.IsDirectory(v) && self.EmulatorConfig.FILETYPE == "dir" { // like DOSBOX
-      gameshell_bat := self.EmulatorConfig.EXT[0]
-      if UI.GetGid(v) != FavGID { //only favs
-        continue
-      }
-      
-      if UI.FileExists( filepath.Join(v,gameshell_bat))  == true {
-        dirmap["gamedir"] = v
-        ret = append(ret,dirmap)
-      }
-    }
-    
-    if UI.IsAFile(v) && self.EmulatorConfig.FILETYPE == "file" {
-      if UI.GetGid(v) != FavGID { //only favs
-        continue
-      }
-      
-      bname := filepath.Base(v)
-      if len(bname) > 1 {        
-        pieces := strings.Split(bname,".")
-        if len(pieces) > 1 {
-          pieces_ext := strings.ToLower( pieces[len(pieces)-1])
-          for _,u := range self.EmulatorConfig.EXT {
-            if pieces_ext == u {
-              dirmap["file"] = v
-              ret = append(ret,dirmap)
-              break
-            }
-          }
-        }
-      }
-    }
-  }
-  
-  return ret,nil
-  
+func (self *FavListPage) GeneratePathList(path string) ([]map[string]string, error) {
+	if UI.IsDirectory(path) == false {
+		return nil, errors.New("Path is not a folder")
+	}
+	dirmap := make(map[string]string)
+	var ret []map[string]string
+
+	file_paths, err := filepath.Glob(path + "/*") //sorted
+	if err != nil {
+		fmt.Println(err)
+		return ret, err
+	}
+
+	for _, v := range file_paths {
+		if UI.IsDirectory(v) && self.EmulatorConfig.FILETYPE == "dir" { // like DOSBOX
+			gameshell_bat := self.EmulatorConfig.EXT[0]
+			if UI.GetGid(v) != FavGID { //only favs
+				continue
+			}
+
+			if UI.FileExists(filepath.Join(v, gameshell_bat)) == true {
+				dirmap["gamedir"] = v
+				ret = append(ret, dirmap)
+			}
+		}
+
+		if UI.IsAFile(v) && self.EmulatorConfig.FILETYPE == "file" {
+			if UI.GetGid(v) != FavGID { //only favs
+				continue
+			}
+
+			bname := filepath.Base(v)
+			if len(bname) > 1 {
+				pieces := strings.Split(bname, ".")
+				if len(pieces) > 1 {
+					pieces_ext := strings.ToLower(pieces[len(pieces)-1])
+					for _, u := range self.EmulatorConfig.EXT {
+						if pieces_ext == u {
+							dirmap["file"] = v
+							ret = append(ret, dirmap)
+							break
+						}
+					}
+				}
+			}
+		}
+	}
+
+	return ret, nil
+
 }
 
-func (self *FavListPage) SyncList( path string ) {
-  
-  alist,err := self.GeneratePathList(path) 
-
-  if err != nil {
-    fmt.Println(err)
-    return
-  }
-  
-  self.MyList = nil 
-  
-  start_x := 0 
-  start_y := 0
-  
-  hasparent := 0 
-  
-  if self.MyStack.Length() > 0 {
-    hasparent = 1
-    
-    li := NewEmulatorListItem()
-    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 := NewEmulatorListItem()
-    li.Parent = self
-    li.PosX   = start_x
-    li.PosY   = start_y + (i+hasparent)*li.Height
-    li.Fonts["normal"] = self.ListFont
-    li.MyType = UI.ICON_TYPES["FILE"]
-    
-    init_val := "NoName"
-    
-    if val, ok := v["directory"]; ok {
-      li.MyType = UI.ICON_TYPES["DIR"]
-      init_val = val
-    }
-    
-    if val, ok := v["file"]; ok {
-      init_val = val
-    }
-    
-    if val, ok := v["gamedir"]; ok {
-      init_val = val
-    }
-    
-    li.Init(init_val)
-    
-    self.MyList = append(self.MyList,li)
-  }
+func (self *FavListPage) SyncList(path string) {
+
+	alist, err := self.GeneratePathList(path)
+
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	self.MyList = nil
+
+	start_x := 0
+	start_y := 0
+
+	hasparent := 0
+
+	if self.MyStack.Length() > 0 {
+		hasparent = 1
+
+		li := NewEmulatorListItem()
+		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 := NewEmulatorListItem()
+		li.Parent = self
+		li.PosX = start_x
+		li.PosY = start_y + (i+hasparent)*li.Height
+		li.Fonts["normal"] = self.ListFont
+		li.MyType = UI.ICON_TYPES["FILE"]
+
+		init_val := "NoName"
+
+		if val, ok := v["directory"]; ok {
+			li.MyType = UI.ICON_TYPES["DIR"]
+			init_val = val
+		}
+
+		if val, ok := v["file"]; ok {
+			init_val = val
+		}
+
+		if val, ok := v["gamedir"]; ok {
+			init_val = val
+		}
+
+		li.Init(init_val)
+
+		self.MyList = append(self.MyList, li)
+	}
 }
 
 func (self *FavListPage) Init() {
-  self.PosX = self.Index *self.Screen.Width
-  self.Width = self.Screen.Width
-  self.Height = self.Screen.Height
-  
-  self.CanvasHWND = self.Screen.CanvasHWND
-  
-  ps := UI.NewInfoPageSelector()
-  ps.Width  = UI.Width - 12
-  ps.PosX = 2
-  ps.Parent = self
-  
-  self.Ps = ps
-  self.PsIndex = 0
-  
-  self.MyStack.SetRootPath(self.EmulatorConfig.ROM)
-
-  self.SyncList( self.EmulatorConfig.ROM )
-    
-  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("star")
-  bgpng.MyType = UI.ICON_TYPES["STAT"]
-  bgpng.Parent = self
-  bgpng.AddLabel("my favourites games",UI.Fonts["varela22"])
-  bgpng.SetLabelColor(&color.Color{204,204,204,255}  )
-  bgpng.Adjust(0,0,self.BGwidth,self.BGheight,0)
-
-  self.Icons["bg"] = bgpng
-  
-  self.Scroller = UI.NewListScroller()
-  self.Scroller.Parent = self
-  self.Scroller.PosX = self.Width - 10
-  self.Scroller.PosY = 2
-  self.Scroller.Init()
-  
-  rom_so_confirm_page := NewRomSoConfirmPage()
-  rom_so_confirm_page.Screen = self.Screen
-  rom_so_confirm_page.Name = "Download Confirm"
-  rom_so_confirm_page.Parent = self
-  rom_so_confirm_page.Init()
-
-  self.RomSoConfirmDownloadPage = rom_so_confirm_page 
-}
+	self.PosX = self.Index * self.Screen.Width
+	self.Width = self.Screen.Width
+	self.Height = self.Screen.Height
 
+	self.CanvasHWND = self.Screen.CanvasHWND
 
-func (self *FavListPage) 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()
-  _,h := cur_li.Size()
-  
-  if y < 0 {
-    for i,_ := range self.MyList{
-      x,y = self.MyList[i].Coord()
-      _, h = self.MyList[i].Size()
-      self.MyList[i].NewCoord(x, y + h)
-    }
-    
-    self.Scrolled +=1
-  }
+	ps := UI.NewInfoPageSelector()
+	ps.Width = UI.Width - 12
+	ps.PosX = 2
+	ps.Parent = self
+
+	self.Ps = ps
+	self.PsIndex = 0
+
+	self.MyStack.SetRootPath(self.EmulatorConfig.ROM)
+
+	self.SyncList(self.EmulatorConfig.ROM)
+
+	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("star")
+	bgpng.MyType = UI.ICON_TYPES["STAT"]
+	bgpng.Parent = self
+	bgpng.AddLabel("my favourites games", UI.Fonts["varela22"])
+	bgpng.SetLabelColor(&color.Color{204, 204, 204, 255})
+	bgpng.Adjust(0, 0, self.BGwidth, self.BGheight, 0)
+
+	self.Icons["bg"] = bgpng
+
+	self.Scroller = UI.NewListScroller()
+	self.Scroller.Parent = self
+	self.Scroller.PosX = self.Width - 10
+	self.Scroller.PosY = 2
+	self.Scroller.Init()
+
+	rom_so_confirm_page := NewRomSoConfirmPage()
+	rom_so_confirm_page.Screen = self.Screen
+	rom_so_confirm_page.Name = "Download Confirm"
+	rom_so_confirm_page.Parent = self
+	rom_so_confirm_page.Init()
+
+	self.RomSoConfirmDownloadPage = rom_so_confirm_page
 }
 
+func (self *FavListPage) ScrollUp() {
+	if len(self.MyList) == 0 {
+		return
+	}
+
+	self.PsIndex -= 1
+
+	if self.PsIndex < 0 {
+		self.PsIndex = 0
+	}
 
-func (self *FavListPage) 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,_ := range self.MyList{
-      x,y = self.MyList[i].Coord()
-      _, h = self.MyList[i].Size()
-      self.MyList[i].NewCoord(x,y-h)
-    }
-    self.Scrolled -=1    
-  }
+	cur_li := self.MyList[self.PsIndex]
+	x, y := cur_li.Coord()
+	_, h := cur_li.Size()
 
+	if y < 0 {
+		for i, _ := range self.MyList {
+			x, y = self.MyList[i].Coord()
+			_, h = self.MyList[i].Size()
+			self.MyList[i].NewCoord(x, y+h)
+		}
+
+		self.Scrolled += 1
+	}
 }
 
-func (self *FavListPage) SyncScroll() {
+func (self *FavListPage) 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, _ := range self.MyList {
+			x, y = self.MyList[i].Coord()
+			_, h = self.MyList[i].Size()
+			self.MyList[i].NewCoord(x, y-h)
+		}
+		self.Scrolled -= 1
+	}
 
-  if self.Scrolled == 0 {
-    return
-  }
-  
-  if self.PsIndex < len(self.MyList) {
-    cur_li := self.MyList[self.PsIndex]
-    x,y := cur_li.Coord()
-    _,h := cur_li.Size()
-    
-    if self.Scrolled > 0 {
-      if y < 0 {
-        for i,_ := range self.MyList{
-          x,y = self.MyList[i].Coord()
-          _,h = self.MyList[i].Size()
-          
-          self.MyList[i].NewCoord(x, y + self.Scrolled*h)
-        }
-      }
-    }else if self.Scrolled < 0 {
-      if y  + h > self.Height {
-        for i,_ := range self.MyList {
-          x,y = self.MyList[i].Coord()
-          _,h = self.MyList[i].Size()
-          self.MyList[i].NewCoord(x,y +  self.Scrolled*h)
-        }
-      }
-    }
-  
-  }
 }
 
+func (self *FavListPage) SyncScroll() {
+
+	if self.Scrolled == 0 {
+		return
+	}
+
+	if self.PsIndex < len(self.MyList) {
+		cur_li := self.MyList[self.PsIndex]
+		x, y := cur_li.Coord()
+		_, h := cur_li.Size()
+
+		if self.Scrolled > 0 {
+			if y < 0 {
+				for i, _ := range self.MyList {
+					x, y = self.MyList[i].Coord()
+					_, h = self.MyList[i].Size()
+
+					self.MyList[i].NewCoord(x, y+self.Scrolled*h)
+				}
+			}
+		} else if self.Scrolled < 0 {
+			if y+h > self.Height {
+				for i, _ := range self.MyList {
+					x, y = self.MyList[i].Coord()
+					_, h = self.MyList[i].Size()
+					self.MyList[i].NewCoord(x, y+self.Scrolled*h)
+				}
+			}
+		}
+
+	}
+}
 
 func (self *FavListPage) Click() {
 
-  if len(self.MyList) == 0 {
-    return
-  }
-  
-  
-  if self.PsIndex > len(self.MyList) - 1 {
-    return
-  }
-  
-  
-  cur_li := self.MyList[self.PsIndex]
-  
-  if cur_li.(*EmulatorListItem).MyType == UI.ICON_TYPES["DIR"] {
-    if cur_li.(*EmulatorListItem).Path ==  "[..]" {
-      self.MyStack.Pop()
-      self.SyncList(self.MyStack.Last())
-      self.PsIndex = 0
-    }else{
-      self.MyStack.Push(self.MyList[self.PsIndex].(*EmulatorListItem).Path)
-      self.SyncList(self.MyStack.Last())
-      self.PsIndex = 0
-    }
-  }
-  
-  if cur_li.(*EmulatorListItem).MyType == UI.ICON_TYPES["FILE"] {
-    self.Screen.MsgBox.SetText("Launching")
-    self.Screen.MsgBox.Draw()
-    self.Screen.SwapAndShow()
-    
-    path := ""
-    if self.EmulatorConfig.FILETYPE == "dir" {
-      path = filepath.Join(cur_li.(*EmulatorListItem).Path,self.EmulatorConfig.EXT[0])
-    }else{
-      path  = cur_li.(*EmulatorListItem).Path
-    }
-    
-    fmt.Println("Run ",path)
-    
-    escaped_path := UI.CmdClean(path)
-    
-    if self.EmulatorConfig.FILETYPE == "dir" {
-      escaped_path = UI.CmdClean(path)
-    }
-    
-    custom_config := ""
-    
-    if self.EmulatorConfig.RETRO_CONFIG != "" && len(self.EmulatorConfig.RETRO_CONFIG) > 5 {
-      custom_config = " -c " + self.EmulatorConfig.RETRO_CONFIG
-    }
-    
-    partsofpath := []string{self.EmulatorConfig.LAUNCHER,self.EmulatorConfig.ROM_SO,custom_config,escaped_path}
-    
-    cmdpath := strings.Join( partsofpath," ")
-    
-    if self.EmulatorConfig.ROM_SO =="" { //empty means No needs for rom so 
-      event.Post(UI.RUNEVT,cmdpath)
-    }else{
-      
-      if UI.FileExists( strings.Split(self.EmulatorConfig.ROM_SO," ")[0] ) == true {
-        event.Post(UI.RUNEVT,cmdpath)
-      } else {
-        self.Screen.PushCurPage()
-        self.Screen.SetCurPage( self.RomSoConfirmDownloadPage)
-        self.Screen.Draw()
-        self.Screen.SwapAndShow()
-      }
-    }
-    
-    return
-    
-  }
-  
-  self.Screen.Draw()
-  self.Screen.SwapAndShow() 
+	if len(self.MyList) == 0 {
+		return
+	}
+
+	if self.PsIndex > len(self.MyList)-1 {
+		return
+	}
+
+	cur_li := self.MyList[self.PsIndex]
+
+	if cur_li.(*EmulatorListItem).MyType == UI.ICON_TYPES["DIR"] {
+		if cur_li.(*EmulatorListItem).Path == "[..]" {
+			self.MyStack.Pop()
+			self.SyncList(self.MyStack.Last())
+			self.PsIndex = 0
+		} else {
+			self.MyStack.Push(self.MyList[self.PsIndex].(*EmulatorListItem).Path)
+			self.SyncList(self.MyStack.Last())
+			self.PsIndex = 0
+		}
+	}
+
+	if cur_li.(*EmulatorListItem).MyType == UI.ICON_TYPES["FILE"] {
+		self.Screen.MsgBox.SetText("Launching")
+		self.Screen.MsgBox.Draw()
+		self.Screen.SwapAndShow()
+
+		path := ""
+		if self.EmulatorConfig.FILETYPE == "dir" {
+			path = filepath.Join(cur_li.(*EmulatorListItem).Path, self.EmulatorConfig.EXT[0])
+		} else {
+			path = cur_li.(*EmulatorListItem).Path
+		}
+
+		fmt.Println("Run ", path)
+
+		escaped_path := UI.CmdClean(path)
+
+		if self.EmulatorConfig.FILETYPE == "dir" {
+			escaped_path = UI.CmdClean(path)
+		}
+
+		custom_config := ""
+
+		if self.EmulatorConfig.RETRO_CONFIG != "" && len(self.EmulatorConfig.RETRO_CONFIG) > 5 {
+			custom_config = " -c " + self.EmulatorConfig.RETRO_CONFIG
+		}
+
+		partsofpath := []string{self.EmulatorConfig.LAUNCHER, self.EmulatorConfig.ROM_SO, custom_config, escaped_path}
+
+		cmdpath := strings.Join(partsofpath, " ")
+
+		if self.EmulatorConfig.ROM_SO == "" { //empty means No needs for rom so
+			event.Post(UI.RUNEVT, cmdpath)
+		} else {
+
+			if UI.FileExists(strings.Split(self.EmulatorConfig.ROM_SO, " ")[0]) == true {
+				event.Post(UI.RUNEVT, cmdpath)
+			} else {
+				self.Screen.PushCurPage()
+				self.Screen.SetCurPage(self.RomSoConfirmDownloadPage)
+				self.Screen.Draw()
+				self.Screen.SwapAndShow()
+			}
+		}
+
+		return
+
+	}
+
+	self.Screen.Draw()
+	self.Screen.SwapAndShow()
 }
 
 func (self *FavListPage) ReScan() {
-  //fmt.Println("FavListPage ReScan ",self.EmulatorConfig.ROM)
-  if self.MyStack.Length() == 0 {
-    self.SyncList(self.EmulatorConfig.ROM)
-  }else{
-    self.SyncList(self.MyStack.Last())
-  }
-  
-  
-  idx := self.PsIndex
-  
-  if idx > len(self.MyList) - 1 {
-    idx = len(self.MyList)
-    if idx > 0 {
-      idx -= 1
-    }else if idx == 0 {
-      //nothing in MyList
-    }
-  }
-  
-  self.PsIndex = idx //sync PsIndex
-  
-  self.SyncScroll()
+	//fmt.Println("FavListPage ReScan ",self.EmulatorConfig.ROM)
+	if self.MyStack.Length() == 0 {
+		self.SyncList(self.EmulatorConfig.ROM)
+	} else {
+		self.SyncList(self.MyStack.Last())
+	}
+
+	idx := self.PsIndex
+
+	if idx > len(self.MyList)-1 {
+		idx = len(self.MyList)
+		if idx > 0 {
+			idx -= 1
+		} else if idx == 0 {
+			//nothing in MyList
+		}
+	}
+
+	self.PsIndex = idx //sync PsIndex
+
+	self.SyncScroll()
 }
 
-
 func (self *FavListPage) OnReturnBackCb() {
-  self.ReScan()
-  self.Screen.Draw()
-  self.Screen.SwapAndShow()
+	self.ReScan()
+	self.Screen.Draw()
+	self.Screen.SwapAndShow()
 }
 
 func (self *FavListPage) OnLoadCb() {
-  self.ReScan()
-  self.Screen.Draw()
-  self.Screen.SwapAndShow()
+	self.ReScan()
+	self.Screen.Draw()
+	self.Screen.SwapAndShow()
 }
 
-func (self *FavListPage) SpeedScroll(thekey string ) {
-  if self.Screen.LastKey == thekey {
-    self.ScrollStep += 1
-    if self.ScrollStep >= self.Leader.SpeedMax {
-      self.ScrollStep = self.Leader.SpeedMax
-    }
-  } else {
-    self.ScrollStep = 1
-  }
-  cur_time := gotime.Now()
-            
-  if cur_time.Sub(self.Screen.LastKeyDown) > gotime.Duration(self.Leader.SpeedTimeInter)*gotime.Millisecond {
-    self.ScrollStep = 1
-  }
+func (self *FavListPage) SpeedScroll(thekey string) {
+	if self.Screen.LastKey == thekey {
+		self.ScrollStep += 1
+		if self.ScrollStep >= self.Leader.SpeedMax {
+			self.ScrollStep = self.Leader.SpeedMax
+		}
+	} else {
+		self.ScrollStep = 1
+	}
+	cur_time := gotime.Now()
+
+	if cur_time.Sub(self.Screen.LastKeyDown) > gotime.Duration(self.Leader.SpeedTimeInter)*gotime.Millisecond {
+		self.ScrollStep = 1
+	}
 }
 
 func (self *FavListPage) KeyDown(ev *event.Event) {
 
-  if ev.Data["Key"] == UI.CurKeys["Menu"] || ev.Data["Key"] == UI.CurKeys["Left"] {
-    self.ReturnToUpLevelPage()
-    self.Screen.Draw()
-    self.Screen.SwapAndShow()
-  }
-    
-  if ev.Data["Key"] == UI.CurKeys["Up"]{
-    self.SpeedScroll(ev.Data["Key"])
-    self.ScrollUp()
-    self.Screen.Draw()
-    self.Screen.SwapAndShow()
-  }
-  
-  if ev.Data["Key"] == UI.CurKeys["Down"] {
-    self.SpeedScroll(ev.Data["Key"])
-    self.ScrollDown()
-    self.Screen.Draw()
-    self.Screen.SwapAndShow()
-  }
-  
-  if ev.Data["Key"] == UI.CurKeys["Enter"] {
-    self.Click()
-  }
-    
-  if ev.Data["Key"] == UI.CurKeys["X"] { //Scan current
-    self.ReScan()
-    self.Screen.Draw()
-    self.Screen.SwapAndShow()        
-  }
-  
-  if ev.Data["Key"] == UI.CurKeys["Y"] {// del
-    if len(self.MyList) == 0 {
-      return
-    }
-    
-    cur_li := self.MyList[self.PsIndex] 
-    if cur_li.(*EmulatorListItem).IsFile() {
-      uid := UI.GetUid(cur_li.(*EmulatorListItem).Path)
-      os.Chown(cur_li.(*EmulatorListItem).Path,uid ,uid)
-      self.Screen.MsgBox.SetText("Deleting")
-      self.Screen.MsgBox.Draw()
-      self.Screen.SwapAndShow()
-      time.BlockDelay(600)
-      self.ReScan()
-      self.Screen.Draw()
-      self.Screen.SwapAndShow()
-    }
-  }
+	if ev.Data["Key"] == UI.CurKeys["Menu"] || ev.Data["Key"] == UI.CurKeys["Left"] {
+		self.ReturnToUpLevelPage()
+		self.Screen.Draw()
+		self.Screen.SwapAndShow()
+	}
+
+	if ev.Data["Key"] == UI.CurKeys["Up"] {
+		self.SpeedScroll(ev.Data["Key"])
+		self.ScrollUp()
+		self.Screen.Draw()
+		self.Screen.SwapAndShow()
+	}
+
+	if ev.Data["Key"] == UI.CurKeys["Down"] {
+		self.SpeedScroll(ev.Data["Key"])
+		self.ScrollDown()
+		self.Screen.Draw()
+		self.Screen.SwapAndShow()
+	}
+
+	if ev.Data["Key"] == UI.CurKeys["Enter"] {
+		self.Click()
+	}
+
+	if ev.Data["Key"] == UI.CurKeys["X"] { //Scan current
+		self.ReScan()
+		self.Screen.Draw()
+		self.Screen.SwapAndShow()
+	}
+
+	if ev.Data["Key"] == UI.CurKeys["Y"] { // del
+		if len(self.MyList) == 0 {
+			return
+		}
+
+		cur_li := self.MyList[self.PsIndex]
+		if cur_li.(*EmulatorListItem).IsFile() {
+			uid := UI.GetUid(cur_li.(*EmulatorListItem).Path)
+			os.Chown(cur_li.(*EmulatorListItem).Path, uid, uid)
+			self.Screen.MsgBox.SetText("Deleting")
+			self.Screen.MsgBox.Draw()
+			self.Screen.SwapAndShow()
+			time.BlockDelay(600)
+			self.ReScan()
+			self.Screen.Draw()
+			self.Screen.SwapAndShow()
+		}
+	}
 }
 
 func (self *FavListPage) Draw() {
-  self.ClearCanvas()
-  
-  if len(self.MyList) == 0 {
-    self.Icons["bg"].NewCoord(self.Width/2,self.Height/2)
-    self.Icons["bg"].Draw()
-  }else{
-    _,h := self.Ps.Size()
-    if len(self.MyList) * UI.HierListItemDefaultHeight > self.Height {
-      
-      self.Ps.NewSize(self.Width - 10, h)
-      self.Ps.Draw()
-      
-      
-      for _,v := range self.MyList {
-        _, y := v.Coord()
-        if y > self.Height + self.Height/2 {
-          break
-        }
-        
-        if y < 0 {
-          continue
-        }
-        
-        v.Draw()
-      }
-      
-      self.Scroller.UpdateSize( len(self.MyList)*UI.HierListItemDefaultHeight, 
-                              self.PsIndex*UI.HierListItemDefaultHeight)
-      self.Scroller.Draw()
-      
-      
-      
-    }else {
-      self.Ps.NewSize(self.Width,h)
-      self.Ps.Draw()
-      for _,v := range self.MyList {
-        v.Draw()
-      }
-    }
-  }
+	self.ClearCanvas()
+
+	if len(self.MyList) == 0 {
+		self.Icons["bg"].NewCoord(self.Width/2, self.Height/2)
+		self.Icons["bg"].Draw()
+	} else {
+		_, h := self.Ps.Size()
+		if len(self.MyList)*UI.HierListItemDefaultHeight > self.Height {
+
+			self.Ps.NewSize(self.Width-10, h)
+			self.Ps.Draw()
+
+			for _, v := range self.MyList {
+				_, y := v.Coord()
+				if y > self.Height+self.Height/2 {
+					break
+				}
+
+				if y < 0 {
+					continue
+				}
+
+				v.Draw()
+			}
+
+			self.Scroller.UpdateSize(len(self.MyList)*UI.HierListItemDefaultHeight,
+				self.PsIndex*UI.HierListItemDefaultHeight)
+			self.Scroller.Draw()
+
+		} else {
+			self.Ps.NewSize(self.Width, h)
+			self.Ps.Draw()
+			for _, v := range self.MyList {
+				v.Draw()
+			}
+		}
+	}
 }
-
-

+ 88 - 94
sysgo/UI/Emulator/list_item.go

@@ -1,118 +1,112 @@
 package Emulator
 
 import (
-  "fmt"
-  "strings"
-  "io/ioutil"
-  "path/filepath"
-  "github.com/veandco/go-sdl2/ttf"
-  
-  //"github.com/veandco/go-sdl2/sdl"
+	"fmt"
+	"github.com/veandco/go-sdl2/ttf"
+	"io/ioutil"
+	"path/filepath"
+	"strings"
+
+	//"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"
-
 )
 
-type EmulatorPageInterface interface {  
-  UI.PageInterface
-  GetMapIcons() map[string]UI.IconItemInterface
-  GetEmulatorConfig() *ActionConfig
+type EmulatorPageInterface interface {
+	UI.PageInterface
+	GetMapIcons() map[string]UI.IconItemInterface
+	GetEmulatorConfig() *ActionConfig
 }
 
-
 type EmulatorListItem struct {
-  UI.HierListItem
-  Parent EmulatorPageInterface
+	UI.HierListItem
+	Parent EmulatorPageInterface
 }
 
 func NewEmulatorListItem() *EmulatorListItem {
-  p := &EmulatorListItem{}
-  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 := &EmulatorListItem{}
+	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 = 32
-	p.Width  = 0
- 
-  
-  return p
+	p.Width = 0
+
+	return p
 }
 
 func (self *EmulatorListItem) Init(text string) {
-  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)
-  ext:= filepath.Ext(text)
-  if ext != "" {
-    alias_file := strings.Replace(text,ext,"",-1) + ".alias"
-    
-    if UI.FileExists(alias_file) == true {
-      b, err := ioutil.ReadFile(alias_file) 
-      if err != nil {
-        fmt.Print(err)
-      }else {
-        label_text = string(b)
-      }
-    }
-    
-  }
-  
-  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 := 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)
+	ext := filepath.Ext(text)
+	if ext != "" {
+		alias_file := strings.Replace(text, ext, "", -1) + ".alias"
+
+		if UI.FileExists(alias_file) == true {
+			b, err := ioutil.ReadFile(alias_file)
+			if err != nil {
+				fmt.Print(err)
+			} else {
+				label_text = string(b)
+			}
+		}
+
+	}
+
+	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 *EmulatorListItem) 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)
+
+}

+ 512 - 524
sysgo/UI/Emulator/rom_list_page.go

@@ -1,585 +1,573 @@
 package Emulator
 
 import (
-  "fmt"
-  "os"
-  "strings"
-  //"regexp"
-  "path/filepath"
-  "os/exec"
-  "errors"
-  gotime "time"
-  "github.com/veandco/go-sdl2/ttf"
-  "github.com/cuu/gogame/time"
-  "github.com/cuu/gogame/color"
+	"fmt"
+	"os"
+	"strings"
+	//"regexp"
+	"errors"
+	"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
+	"github.com/cuu/gogame/color"
 	"github.com/cuu/gogame/event"
-  "github.com/clockworkpi/LauncherGoDev/sysgo/UI"
-
+	"github.com/cuu/gogame/time"
+	"github.com/veandco/go-sdl2/ttf"
+	"os/exec"
+	"path/filepath"
+	gotime "time"
 )
 
 type RomListPage struct {
-  UI.Page
-  Icons  map[string]UI.IconItemInterface
-  ListFont *ttf.Font
-  MyStack *UI.FolderStack
-  EmulatorConfig *ActionConfig
-  
-  RomSoConfirmDownloadPage *RomSoConfirmPage
-  
-  MyList []UI.ListItemInterface
-  BGwidth int
-  BGheight int //70
-  Scroller *UI.ListScroller
-  Scrolled int 
-  
-  Leader *MyEmulator
-  
+	UI.Page
+	Icons          map[string]UI.IconItemInterface
+	ListFont       *ttf.Font
+	MyStack        *UI.FolderStack
+	EmulatorConfig *ActionConfig
+
+	RomSoConfirmDownloadPage *RomSoConfirmPage
+
+	MyList   []UI.ListItemInterface
+	BGwidth  int
+	BGheight int //70
+	Scroller *UI.ListScroller
+	Scrolled int
+
+	Leader *MyEmulator
 }
 
 func NewRomListPage() *RomListPage {
-  p := &RomListPage{}
-  p.PageIconMargin = 20
+	p := &RomListPage{}
+	p.PageIconMargin = 20
 	p.SelectedIconTopOffset = 20
 	p.EasingDur = 10
 
 	p.Align = UI.ALIGN["SLeft"]
-	
-	p.FootMsg = [5]string{ "Nav","Scan","Del","AddFav","Run" }
-  
-  p.Icons=make(map[string]UI.IconItemInterface)
-  p.ListFont =  UI.Fonts["notosanscjk15"]
-  
-  p.MyStack = UI.NewFolderStack()
-  
-  p.BGwidth = 56
-  p.BGheight = 70
-  
-  p.ScrollStep = 1
-  return p
+
+	p.FootMsg = [5]string{"Nav", "Scan", "Del", "AddFav", "Run"}
+
+	p.Icons = make(map[string]UI.IconItemInterface)
+	p.ListFont = UI.Fonts["notosanscjk15"]
+
+	p.MyStack = UI.NewFolderStack()
+
+	p.BGwidth = 56
+	p.BGheight = 70
+
+	p.ScrollStep = 1
+	return p
 }
 
 func (self *RomListPage) GetMyList() []UI.ListItemInterface {
-  return self.MyList
+	return self.MyList
 }
 
 func (self *RomListPage) GetMapIcons() map[string]UI.IconItemInterface {
-  return self.Icons
+	return self.Icons
 }
 
 func (self *RomListPage) GetEmulatorConfig() *ActionConfig {
-  return self.EmulatorConfig
+	return self.EmulatorConfig
 }
 
+func (self *RomListPage) GeneratePathList(path string) ([]map[string]string, error) {
+	if UI.IsDirectory(path) == false {
+		return nil, errors.New("Path is not a folder")
+	}
+
+	var ret []map[string]string
+
+	file_paths, err := filepath.Glob(path + "/*") //sorted
+	if err != nil {
+		fmt.Println(err)
+		return ret, err
+	}
+
+	for _, v := range file_paths {
+		dirmap := make(map[string]string)
+		if UI.IsDirectory(v) && self.EmulatorConfig.FILETYPE == "dir" { // like DOSBOX
+			gameshell_bat := self.EmulatorConfig.EXT[0]
+			if UI.GetGid(v) == FavGID { // skip fav roms
+				continue
+			}
+
+			if UI.FileExists(filepath.Join(v, gameshell_bat)) == true {
+				dirmap["gamedir"] = v
+				ret = append(ret, dirmap)
+			}
+		}
+
+		if UI.IsAFile(v) && self.EmulatorConfig.FILETYPE == "file" {
+			if UI.GetGid(v) == FavGID {
+				continue
+			}
+
+			bname := filepath.Base(v)
+
+			if len(bname) > 1 {
+				is_excluded := false
+				for _, exclude_ext := range self.EmulatorConfig.EXCLUDE {
+					exclude_ext2 := strings.Trim(exclude_ext, "\r\n ")
+					if len(exclude_ext2) > 1 && strings.HasSuffix(bname, exclude_ext2) {
+						is_excluded = true
+						break
+					}
+				}
+
+				if is_excluded == false {
+					pieces := strings.Split(bname, ".")
+
+					if len(pieces) > 1 {
+						pieces_ext := strings.ToLower(pieces[len(pieces)-1])
+						for _, u := range self.EmulatorConfig.EXT {
+							if pieces_ext == u {
+								dirmap["file"] = v
+								ret = append(ret, dirmap)
+								break
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+
+	return ret, nil
 
-func (self *RomListPage) GeneratePathList(path string) ([]map[string]string,error) {
-  if UI.IsDirectory(path) == false {
-    return nil,errors.New("Path is not a folder")
-  }
-  
-  var ret []map[string]string
-  
-  file_paths,err := filepath.Glob(path+"/*")//sorted
-  if err != nil {
-    fmt.Println(err)
-    return ret,err
-  }
- 
-  for _,v := range file_paths {
-    dirmap := make(map[string]string)
-    if UI.IsDirectory(v) && self.EmulatorConfig.FILETYPE == "dir" { // like DOSBOX
-      gameshell_bat := self.EmulatorConfig.EXT[0]
-      if UI.GetGid(v) == FavGID { // skip fav roms
-        continue
-      }
-      
-      if UI.FileExists( filepath.Join(v,gameshell_bat))  == true {
-        dirmap["gamedir"] = v
-        ret = append(ret,dirmap)
-      }
-    }
-    
-    if UI.IsAFile(v) && self.EmulatorConfig.FILETYPE == "file" {
-      if UI.GetGid(v) == FavGID {
-        continue
-      }
-      
-      bname := filepath.Base(v)
-
-      if len(bname) > 1 {
-        is_excluded := false
-        for _,exclude_ext := range self.EmulatorConfig.EXCLUDE {
-          exclude_ext2 := strings.Trim(exclude_ext,"\r\n ")
-          if len(exclude_ext2) > 1 && strings.HasSuffix(bname,exclude_ext2) {
-            is_excluded= true
-            break
-          }
-        }
-        
-        if is_excluded == false {
-          pieces := strings.Split(bname,".")
-
-          if len(pieces) > 1 {
-            pieces_ext := strings.ToLower( pieces[len(pieces)-1])
-            for _,u := range self.EmulatorConfig.EXT {
-              if pieces_ext == u {
-                dirmap["file"] = v
-                ret = append(ret,dirmap)
-                break
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  
-  return ret,nil
-  
 }
 
-func (self *RomListPage) SyncList( path string ) {
-  
-  alist,err := self.GeneratePathList(path) 
-  
-  if err != nil {
-    fmt.Println(err)
-    return
-  }
-  
-  self.MyList = nil 
-  
-  start_x := 0 
-  start_y := 0
-  
-  hasparent := 0 
-  
-  if self.MyStack.Length() > 0 {
-    hasparent = 1
-    
-    li := NewEmulatorListItem()
-    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 := NewEmulatorListItem()
-    li.Parent = self
-    li.PosX   = start_x
-    li.PosY   = start_y + (i+hasparent)*li.Height
-    li.Width  = UI.Width
-    li.Fonts["normal"] = self.ListFont
-    li.MyType = UI.ICON_TYPES["FILE"]
-    
-    init_val := "NoName"
-    
-    if val, ok := v["directory"]; ok {
-      li.MyType = UI.ICON_TYPES["DIR"]
-      init_val = val
-    }
-    
-    if val, ok := v["file"]; ok {
-      init_val = val
-    }
-    
-    if val, ok := v["gamedir"]; ok {
-      init_val = val
-    }
-    
-    li.Init(init_val)
-    self.MyList = append(self.MyList,li)
-  }
+func (self *RomListPage) SyncList(path string) {
+
+	alist, err := self.GeneratePathList(path)
+
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	self.MyList = nil
+
+	start_x := 0
+	start_y := 0
+
+	hasparent := 0
+
+	if self.MyStack.Length() > 0 {
+		hasparent = 1
+
+		li := NewEmulatorListItem()
+		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 := NewEmulatorListItem()
+		li.Parent = self
+		li.PosX = start_x
+		li.PosY = start_y + (i+hasparent)*li.Height
+		li.Width = UI.Width
+		li.Fonts["normal"] = self.ListFont
+		li.MyType = UI.ICON_TYPES["FILE"]
+
+		init_val := "NoName"
+
+		if val, ok := v["directory"]; ok {
+			li.MyType = UI.ICON_TYPES["DIR"]
+			init_val = val
+		}
+
+		if val, ok := v["file"]; ok {
+			init_val = val
+		}
+
+		if val, ok := v["gamedir"]; ok {
+			init_val = val
+		}
+
+		li.Init(init_val)
+		self.MyList = append(self.MyList, li)
+	}
 }
 
 func (self *RomListPage) Init() {
-  self.PosX = self.Index *self.Screen.Width
-  self.Width = self.Screen.Width
-  self.Height = self.Screen.Height
-  
-  self.CanvasHWND = self.Screen.CanvasHWND
-  
-  ps := UI.NewInfoPageSelector()
-  ps.Width  = UI.Width - 12
-  ps.PosX = 2
-  ps.Parent = self
-  
-  self.Ps = ps
-  self.PsIndex = 0
-  
-  self.MyStack.SetRootPath(self.EmulatorConfig.ROM)
-  
-  self.SyncList( self.EmulatorConfig.ROM )
-  
-  err := os.MkdirAll( self.EmulatorConfig.ROM+"/.Trash", 0700)
-  if err != nil {
-    panic(err)
-  }
-  
-  err = os.MkdirAll( self.EmulatorConfig.ROM+"/.Fav", 0700)
-  if err != nil {
-    panic(err)
-  }
-    
-  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("Please upload data over Wi-Fi",UI.Fonts["varela22"])
-  bgpng.SetLabelColor(&color.Color{204,204,204,255}  )
-  bgpng.Adjust(0,0,self.BGwidth,self.BGheight,0)
-
-  self.Icons["bg"] = bgpng
-  
-  self.Scroller = UI.NewListScroller()
-  self.Scroller.Parent = self
-  self.Scroller.PosX = self.Width - 10
-  self.Scroller.PosY = 2
-  self.Scroller.Init()
-  
-  rom_so_confirm_page := NewRomSoConfirmPage()
-  rom_so_confirm_page.Screen = self.Screen
-  rom_so_confirm_page.Name = "Download Confirm"
-  rom_so_confirm_page.Parent = self
-  rom_so_confirm_page.Init()
-
-  self.RomSoConfirmDownloadPage = rom_so_confirm_page 
-}
+	self.PosX = self.Index * self.Screen.Width
+	self.Width = self.Screen.Width
+	self.Height = self.Screen.Height
+
+	self.CanvasHWND = self.Screen.CanvasHWND
 
+	ps := UI.NewInfoPageSelector()
+	ps.Width = UI.Width - 12
+	ps.PosX = 2
+	ps.Parent = self
+
+	self.Ps = ps
+	self.PsIndex = 0
+
+	self.MyStack.SetRootPath(self.EmulatorConfig.ROM)
+
+	self.SyncList(self.EmulatorConfig.ROM)
+
+	err := os.MkdirAll(self.EmulatorConfig.ROM+"/.Trash", 0700)
+	if err != nil {
+		panic(err)
+	}
+
+	err = os.MkdirAll(self.EmulatorConfig.ROM+"/.Fav", 0700)
+	if err != nil {
+		panic(err)
+	}
+
+	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("Please upload data over Wi-Fi", UI.Fonts["varela22"])
+	bgpng.SetLabelColor(&color.Color{204, 204, 204, 255})
+	bgpng.Adjust(0, 0, self.BGwidth, self.BGheight, 0)
+
+	self.Icons["bg"] = bgpng
+
+	self.Scroller = UI.NewListScroller()
+	self.Scroller.Parent = self
+	self.Scroller.PosX = self.Width - 10
+	self.Scroller.PosY = 2
+	self.Scroller.Init()
+
+	rom_so_confirm_page := NewRomSoConfirmPage()
+	rom_so_confirm_page.Screen = self.Screen
+	rom_so_confirm_page.Name = "Download Confirm"
+	rom_so_confirm_page.Parent = self
+	rom_so_confirm_page.Init()
+
+	self.RomSoConfirmDownloadPage = rom_so_confirm_page
+}
 
 func (self *RomListPage) ScrollUp() {
-  if len(self.MyList) == 0 {
-    return
-  }
-  tmp := self.PsIndex
-  self.PsIndex -=self.ScrollStep
-  dy := 0 
-  
-  if self.PsIndex < 0 {
-    self.PsIndex = len(self.MyList) - 1
-  }
-  
-  dy = tmp - self.PsIndex
-  
-  cur_li := self.MyList[self.PsIndex]
-  x,y := cur_li.Coord()
-  _,h := cur_li.Size()
-  {
-    for i,_ := range self.MyList{
-      x,y = self.MyList[i].Coord()
-      _, h = self.MyList[i].Size()
-      self.MyList[i].NewCoord(x,y + h*dy)
-    }
-    
-    self.Scrolled +=dy
-  }
+	if len(self.MyList) == 0 {
+		return
+	}
+	tmp := self.PsIndex
+	self.PsIndex -= self.ScrollStep
+	dy := 0
+
+	if self.PsIndex < 0 {
+		self.PsIndex = len(self.MyList) - 1
+	}
+
+	dy = tmp - self.PsIndex
+
+	cur_li := self.MyList[self.PsIndex]
+	x, y := cur_li.Coord()
+	_, h := cur_li.Size()
+	{
+		for i, _ := range self.MyList {
+			x, y = self.MyList[i].Coord()
+			_, h = self.MyList[i].Size()
+			self.MyList[i].NewCoord(x, y+h*dy)
+		}
+
+		self.Scrolled += dy
+	}
 }
 
+func (self *RomListPage) ScrollDown() {
+	if len(self.MyList) == 0 {
+		return
+	}
+	tmp := self.PsIndex
+	self.PsIndex += self.ScrollStep
+
+	if self.PsIndex >= len(self.MyList) {
+		self.PsIndex = 0
+	}
 
-func (self *RomListPage) ScrollDown(){
-  if len(self.MyList) == 0 {
-    return
-  }
-  tmp := self.PsIndex
-  self.PsIndex +=self.ScrollStep
-  
-  if self.PsIndex >= len(self.MyList) {
-    self.PsIndex = 0
-  }
-  
-  dy := self.PsIndex - tmp
-  
-  cur_li := self.MyList[self.PsIndex]
-  x,y := cur_li.Coord()
-  _,h := cur_li.Size()
-  
-  { 
-    for i,_ := range self.MyList{
-      x,y = self.MyList[i].Coord()
-      _, h = self.MyList[i].Size()
-      self.MyList[i].NewCoord(x,y - h*dy)
-    }
-    self.Scrolled -=dy
-  }
+	dy := self.PsIndex - tmp
+
+	cur_li := self.MyList[self.PsIndex]
+	x, y := cur_li.Coord()
+	_, h := cur_li.Size()
+
+	{
+		for i, _ := range self.MyList {
+			x, y = self.MyList[i].Coord()
+			_, h = self.MyList[i].Size()
+			self.MyList[i].NewCoord(x, y-h*dy)
+		}
+		self.Scrolled -= dy
+	}
 
 }
 
 func (self *RomListPage) SyncScroll() {
 
-  if self.Scrolled == 0 {
-    return
-  }
-  
-  if self.PsIndex < len(self.MyList) {
-    cur_li := self.MyList[self.PsIndex]
-    x, y := cur_li.Coord()
-    _, h := cur_li.Size()
-    
-    if self.Scrolled > 0 {
-      if y < 0 {
-        for i,_ := range self.MyList{
-           x,y = self.MyList[i].Coord()
-          _, h = self.MyList[i].Size()
-          self.MyList[i].NewCoord(x, y +  self.Scrolled*h)
-        }
-      }
-    }else if self.Scrolled < 0 {
-      if y + h > self.Height{
-        for i,_ := range self.MyList{
-          x,y = self.MyList[i].Coord()
-          _, h = self.MyList[i].Size()
-          self.MyList[i].NewCoord(x, y +  self.Scrolled*h)
-        }
-      }
-    }
-  
-  }
+	if self.Scrolled == 0 {
+		return
+	}
+
+	if self.PsIndex < len(self.MyList) {
+		cur_li := self.MyList[self.PsIndex]
+		x, y := cur_li.Coord()
+		_, h := cur_li.Size()
+
+		if self.Scrolled > 0 {
+			if y < 0 {
+				for i, _ := range self.MyList {
+					x, y = self.MyList[i].Coord()
+					_, h = self.MyList[i].Size()
+					self.MyList[i].NewCoord(x, y+self.Scrolled*h)
+				}
+			}
+		} else if self.Scrolled < 0 {
+			if y+h > self.Height {
+				for i, _ := range self.MyList {
+					x, y = self.MyList[i].Coord()
+					_, h = self.MyList[i].Size()
+					self.MyList[i].NewCoord(x, y+self.Scrolled*h)
+				}
+			}
+		}
+
+	}
 }
 
-
 func (self *RomListPage) Click() {
-  if len(self.MyList) == 0 {
-    return
-  }
-  
-  
-  if self.PsIndex > len(self.MyList) - 1 {
-    return
-  }
-  
-  
-  cur_li := self.MyList[self.PsIndex]
-  
-  if cur_li.(*EmulatorListItem).MyType == UI.ICON_TYPES["DIR"] {
-    if cur_li.(*EmulatorListItem).Path == "[..]"{
-      self.MyStack.Pop()
-      self.SyncList(self.MyStack.Last())
-      self.PsIndex = 0
-    }else{
-      self.MyStack.Push(self.MyList[self.PsIndex].(*EmulatorListItem).Path)
-      self.SyncList(self.MyStack.Last())
-      self.PsIndex = 0
-    }
-  }
-  
-  if cur_li.(*EmulatorListItem).MyType == UI.ICON_TYPES["FILE"] {
-    self.Screen.MsgBox.SetText("Launching")
-    self.Screen.MsgBox.Draw()
-    self.Screen.SwapAndShow()
-    
-    path := ""
-    if self.EmulatorConfig.FILETYPE == "dir" {
-      path = filepath.Join(cur_li.(*EmulatorListItem).Path,self.EmulatorConfig.EXT[0])
-    }else{
-      path  = cur_li.(*EmulatorListItem).Path
-    }
-    
-    fmt.Println("Run ",path)
-    
-    escaped_path := UI.CmdClean(path)
-    
-    if self.EmulatorConfig.FILETYPE == "dir" {
-      escaped_path = UI.CmdClean(path)
-    }
-    
-    custom_config := ""
-    
-    if self.EmulatorConfig.RETRO_CONFIG != "" && len(self.EmulatorConfig.RETRO_CONFIG) > 5 {
-      custom_config = " -c " + self.EmulatorConfig.RETRO_CONFIG
-    }
-    
-    partsofpath := []string{self.EmulatorConfig.LAUNCHER,self.EmulatorConfig.ROM_SO,custom_config,escaped_path}
-    
-    cmdpath := strings.Join( partsofpath," ")
-    
-    if self.EmulatorConfig.ROM_SO =="" { //empty means No needs for rom so 
-      event.Post(UI.RUNEVT,cmdpath)
-    }else{
-      
-      if UI.FileExists( strings.Split(self.EmulatorConfig.ROM_SO," ")[0] ) == true {
-        event.Post(UI.RUNEVT,cmdpath)
-      } else {
-        self.Screen.PushCurPage()
-        self.Screen.SetCurPage( self.RomSoConfirmDownloadPage)
-        self.Screen.Draw()
-        self.Screen.SwapAndShow()
-      }
-    }
-    
-    return
-    
-  }
-  
-  self.Screen.Draw()
-  self.Screen.SwapAndShow() 
+	if len(self.MyList) == 0 {
+		return
+	}
+
+	if self.PsIndex > len(self.MyList)-1 {
+		return
+	}
+
+	cur_li := self.MyList[self.PsIndex]
+
+	if cur_li.(*EmulatorListItem).MyType == UI.ICON_TYPES["DIR"] {
+		if cur_li.(*EmulatorListItem).Path == "[..]" {
+			self.MyStack.Pop()
+			self.SyncList(self.MyStack.Last())
+			self.PsIndex = 0
+		} else {
+			self.MyStack.Push(self.MyList[self.PsIndex].(*EmulatorListItem).Path)
+			self.SyncList(self.MyStack.Last())
+			self.PsIndex = 0
+		}
+	}
+
+	if cur_li.(*EmulatorListItem).MyType == UI.ICON_TYPES["FILE"] {
+		self.Screen.MsgBox.SetText("Launching")
+		self.Screen.MsgBox.Draw()
+		self.Screen.SwapAndShow()
+
+		path := ""
+		if self.EmulatorConfig.FILETYPE == "dir" {
+			path = filepath.Join(cur_li.(*EmulatorListItem).Path, self.EmulatorConfig.EXT[0])
+		} else {
+			path = cur_li.(*EmulatorListItem).Path
+		}
+
+		fmt.Println("Run ", path)
+
+		escaped_path := UI.CmdClean(path)
+
+		if self.EmulatorConfig.FILETYPE == "dir" {
+			escaped_path = UI.CmdClean(path)
+		}
+
+		custom_config := ""
+
+		if self.EmulatorConfig.RETRO_CONFIG != "" && len(self.EmulatorConfig.RETRO_CONFIG) > 5 {
+			custom_config = " -c " + self.EmulatorConfig.RETRO_CONFIG
+		}
+
+		partsofpath := []string{self.EmulatorConfig.LAUNCHER, self.EmulatorConfig.ROM_SO, custom_config, escaped_path}
+
+		cmdpath := strings.Join(partsofpath, " ")
+
+		if self.EmulatorConfig.ROM_SO == "" { //empty means No needs for rom so
+			event.Post(UI.RUNEVT, cmdpath)
+		} else {
+
+			if UI.FileExists(strings.Split(self.EmulatorConfig.ROM_SO, " ")[0]) == true {
+				event.Post(UI.RUNEVT, cmdpath)
+			} else {
+				self.Screen.PushCurPage()
+				self.Screen.SetCurPage(self.RomSoConfirmDownloadPage)
+				self.Screen.Draw()
+				self.Screen.SwapAndShow()
+			}
+		}
+
+		return
+
+	}
+
+	self.Screen.Draw()
+	self.Screen.SwapAndShow()
 }
 
 func (self *RomListPage) ReScan() {
-  //fmt.Println("RomListPage ReScan ",self.EmulatorConfig.ROM)
-  if self.MyStack.Length() == 0 {
-    self.SyncList(self.EmulatorConfig.ROM)
-  }else{
-    self.SyncList(self.MyStack.Last())
-  }
-  
-  self.PsIndex = 0 //sync PsIndex
-  self.Scrolled = 0
-  
-  self.SyncScroll()
-}
+	//fmt.Println("RomListPage ReScan ",self.EmulatorConfig.ROM)
+	if self.MyStack.Length() == 0 {
+		self.SyncList(self.EmulatorConfig.ROM)
+	} else {
+		self.SyncList(self.MyStack.Last())
+	}
 
+	self.PsIndex = 0 //sync PsIndex
+	self.Scrolled = 0
 
-func (self *RomListPage) OnReturnBackCb() {
-  self.ReScan()
-  self.Screen.Draw()
-  self.Screen.SwapAndShow()
+	self.SyncScroll()
 }
 
+func (self *RomListPage) OnReturnBackCb() {
+	self.ReScan()
+	self.Screen.Draw()
+	self.Screen.SwapAndShow()
+}
 
-func (self *RomListPage) SpeedScroll(thekey string ) {
-  if self.Screen.LastKey == thekey {
-    self.ScrollStep += 1
-    if self.ScrollStep >= self.Leader.SpeedMax {
-      self.ScrollStep = self.Leader.SpeedMax
-    }
-  } else {
-    self.ScrollStep = 1
-  }
-  cur_time := gotime.Now()
-            
-  if cur_time.Sub(self.Screen.LastKeyDown) > gotime.Duration(self.Leader.SpeedTimeInter)*gotime.Millisecond {
-    self.ScrollStep = 1
-  }
+func (self *RomListPage) SpeedScroll(thekey string) {
+	if self.Screen.LastKey == thekey {
+		self.ScrollStep += 1
+		if self.ScrollStep >= self.Leader.SpeedMax {
+			self.ScrollStep = self.Leader.SpeedMax
+		}
+	} else {
+		self.ScrollStep = 1
+	}
+	cur_time := gotime.Now()
+
+	if cur_time.Sub(self.Screen.LastKeyDown) > gotime.Duration(self.Leader.SpeedTimeInter)*gotime.Millisecond {
+		self.ScrollStep = 1
+	}
 }
 
 func (self *RomListPage) KeyDown(ev *event.Event) {
 
-  if ev.Data["Key"] == UI.CurKeys["Menu"]{
-    self.ReturnToUpLevelPage()
-    self.Screen.Draw()
-    self.Screen.SwapAndShow()
-  }
-  
-  if ev.Data["Key"] == UI.CurKeys["Right"]{
-    self.Screen.PushCurPage()
-    self.Screen.SetCurPage(self.Leader.FavPage)
-    self.Screen.Draw()
-    self.Screen.SwapAndShow()
-  }
-  
-  if ev.Data["Key"] == UI.CurKeys["Up"]{
-    self.SpeedScroll(ev.Data["Key"])
-    self.ScrollUp()
-    self.Screen.Draw()
-    self.Screen.SwapAndShow()
-  }
-  
-  if ev.Data["Key"] == UI.CurKeys["Down"] {
-    self.SpeedScroll(ev.Data["Key"])
-    self.ScrollDown()
-    self.Screen.Draw()
-    self.Screen.SwapAndShow()
-  }
-  
-  if ev.Data["Key"] == UI.CurKeys["Enter"] {
-    self.Click()
-  }
-  
-  if ev.Data["Key"] == UI.CurKeys["A"] {
-    if len(self.MyList) == 0{
-      return
-    }
-    
-    cur_li := self.MyList[self.PsIndex]
-    
-    if cur_li.(*EmulatorListItem).IsFile() {
-      cmd := exec.Command("chgrp", FavGname, UI.CmdClean(cur_li.(*EmulatorListItem).Path))
-      err := cmd.Run()
-      if err != nil {
-        fmt.Println(err)
-      }
-      
-      self.Screen.MsgBox.SetText("Add to favourite list")
-      self.Screen.MsgBox.Draw()
-      self.Screen.SwapAndShow()
-      time.BlockDelay(600)
-      self.ReScan()
-      self.Screen.Draw()
-      self.Screen.SwapAndShow()
-    
-    }
-  }
-  
-  if ev.Data["Key"] == UI.CurKeys["X"] { //Scan current
-    self.ReScan()
-    self.Screen.Draw()
-    self.Screen.SwapAndShow()        
-  }
-  
-  if ev.Data["Key"] == UI.CurKeys["Y"] {// del
-    if len(self.MyList) == 0 {
-      return
-    }
-    
-    cur_li := self.MyList[self.PsIndex] 
-    if cur_li.(*EmulatorListItem).IsFile() {
-      self.Leader.DeleteConfirmPage.SetFileName(cur_li.(*EmulatorListItem).Path)
-      self.Leader.DeleteConfirmPage.SetTrashDir(filepath.Join(self.EmulatorConfig.ROM,"/.Trash") )
-      
-      self.Screen.PushCurPage()
-      self.Screen.SetCurPage(self.Leader.DeleteConfirmPage)
-      self.Screen.Draw()
-      self.Screen.SwapAndShow()
-      
-    }
-  }
+	if ev.Data["Key"] == UI.CurKeys["Menu"] {
+		self.ReturnToUpLevelPage()
+		self.Screen.Draw()
+		self.Screen.SwapAndShow()
+	}
+
+	if ev.Data["Key"] == UI.CurKeys["Right"] {
+		self.Screen.PushCurPage()
+		self.Screen.SetCurPage(self.Leader.FavPage)
+		self.Screen.Draw()
+		self.Screen.SwapAndShow()
+	}
+
+	if ev.Data["Key"] == UI.CurKeys["Up"] {
+		self.SpeedScroll(ev.Data["Key"])
+		self.ScrollUp()
+		self.Screen.Draw()
+		self.Screen.SwapAndShow()
+	}
+
+	if ev.Data["Key"] == UI.CurKeys["Down"] {
+		self.SpeedScroll(ev.Data["Key"])
+		self.ScrollDown()
+		self.Screen.Draw()
+		self.Screen.SwapAndShow()
+	}
+
+	if ev.Data["Key"] == UI.CurKeys["Enter"] {
+		self.Click()
+	}
+
+	if ev.Data["Key"] == UI.CurKeys["A"] {
+		if len(self.MyList) == 0 {
+			return
+		}
+
+		cur_li := self.MyList[self.PsIndex]
+
+		if cur_li.(*EmulatorListItem).IsFile() {
+			cmd := exec.Command("chgrp", FavGname, UI.CmdClean(cur_li.(*EmulatorListItem).Path))
+			err := cmd.Run()
+			if err != nil {
+				fmt.Println(err)
+			}
+
+			self.Screen.MsgBox.SetText("Add to favourite list")
+			self.Screen.MsgBox.Draw()
+			self.Screen.SwapAndShow()
+			time.BlockDelay(600)
+			self.ReScan()
+			self.Screen.Draw()
+			self.Screen.SwapAndShow()
+
+		}
+	}
+
+	if ev.Data["Key"] == UI.CurKeys["X"] { //Scan current
+		self.ReScan()
+		self.Screen.Draw()
+		self.Screen.SwapAndShow()
+	}
+
+	if ev.Data["Key"] == UI.CurKeys["Y"] { // del
+		if len(self.MyList) == 0 {
+			return
+		}
+
+		cur_li := self.MyList[self.PsIndex]
+		if cur_li.(*EmulatorListItem).IsFile() {
+			self.Leader.DeleteConfirmPage.SetFileName(cur_li.(*EmulatorListItem).Path)
+			self.Leader.DeleteConfirmPage.SetTrashDir(filepath.Join(self.EmulatorConfig.ROM, "/.Trash"))
+
+			self.Screen.PushCurPage()
+			self.Screen.SetCurPage(self.Leader.DeleteConfirmPage)
+			self.Screen.Draw()
+			self.Screen.SwapAndShow()
+
+		}
+	}
 }
 
 func (self *RomListPage) Draw() {
-  self.ClearCanvas()
-  
-  if len(self.MyList) == 0 {
-    self.Icons["bg"].NewCoord(self.Width/2,self.Height/2)
-    self.Icons["bg"].Draw()
-  }else{
-    _,h := self.Ps.Size()
-    if len(self.MyList) * UI.HierListItemDefaultHeight > self.Height {
-
-      self.Ps.NewSize(self.Width - 10,h)
-      self.Ps.Draw()
-      for _,v := range self.MyList {
-        _,y := v.Coord()
-        if y > (self.Height + self.Height/2) {
-          break
-        }
-        v.Draw()
-      }
-      
-      self.Scroller.UpdateSize( len(self.MyList)*UI.HierListItemDefaultHeight, 
-                              self.PsIndex*UI.HierListItemDefaultHeight)
-      self.Scroller.Draw()
-      
-    }else {
-      self.Ps.NewSize(self.Width,h)
-      self.Ps.Draw()
-      for _,v := range self.MyList {
-        v.Draw()
-      }
-    }
-  }
+	self.ClearCanvas()
+
+	if len(self.MyList) == 0 {
+		self.Icons["bg"].NewCoord(self.Width/2, self.Height/2)
+		self.Icons["bg"].Draw()
+	} else {
+		_, h := self.Ps.Size()
+		if len(self.MyList)*UI.HierListItemDefaultHeight > self.Height {
+
+			self.Ps.NewSize(self.Width-10, h)
+			self.Ps.Draw()
+			for _, v := range self.MyList {
+				_, y := v.Coord()
+				if y > (self.Height + self.Height/2) {
+					break
+				}
+				v.Draw()
+			}
+
+			self.Scroller.UpdateSize(len(self.MyList)*UI.HierListItemDefaultHeight,
+				self.PsIndex*UI.HierListItemDefaultHeight)
+			self.Scroller.Draw()
+
+		} else {
+			self.Ps.NewSize(self.Width, h)
+			self.Ps.Draw()
+			for _, v := range self.MyList {
+				v.Draw()
+			}
+		}
+	}
 }
-
-

+ 89 - 92
sysgo/UI/Emulator/rom_so_confirm_page.go

@@ -1,122 +1,119 @@
 package Emulator
 
 import (
-  "fmt"
-  //"strconv"
-  "strings"
-  
-  "path/filepath"
-  
-	"github.com/cuu/gogame/event"
-  "github.com/clockworkpi/LauncherGoDev/sysgo"
-  "github.com/clockworkpi/LauncherGoDev/sysgo/UI"
+	"fmt"
+	//"strconv"
+	"strings"
+
+	"path/filepath"
 
+	"github.com/clockworkpi/LauncherGoDev/sysgo"
+	"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
+	"github.com/cuu/gogame/event"
 )
 
 type RomSoConfirmPage struct {
-  UI.ConfirmPage
-  Parent EmulatorPageInterface
-  DownloadPage *UI.DownloadProcessPage
-  
+	UI.ConfirmPage
+	Parent       EmulatorPageInterface
+	DownloadPage *UI.DownloadProcessPage
 }
 
 func NewRomSoConfirmPage() *RomSoConfirmPage {
-  p := &RomSoConfirmPage{}
-  p.PageIconMargin = 20
+	p := &RomSoConfirmPage{}
+	p.PageIconMargin = 20
 	p.SelectedIconTopOffset = 20
 	p.EasingDur = 10
 	p.Align = UI.ALIGN["SLeft"]
-  
-  p.ListFont = UI.Fonts["veramono18"]
-  p.FootMsg = [5]string{"Nav","","","Cancel","Yes"}
-  p.ConfirmText ="Do you want to setup this game engine automatically?"
-  
-  return p
-  
+
+	p.ListFont = UI.Fonts["veramono18"]
+	p.FootMsg = [5]string{"Nav", "", "", "Cancel", "Yes"}
+	p.ConfirmText = "Do you want to setup this game engine automatically?"
+
+	return p
+
 }
 
 func (self *RomSoConfirmPage) Init() {
-  self.PosX = self.Index * self.Screen.Width
-  self.Width = self.Screen.Width
-  self.Height = self.Screen.Height
-
-  self.CanvasHWND = self.Screen.CanvasHWND
-  
-  li := UI.NewMultiLabel()
-  li.SetCanvasHWND(self.CanvasHWND)
-  li.Width = 160
-  li.Init(self.ConfirmText,self.ListFont,nil)
-  
-  li.PosX = (self.Width - li.Width)/2
-  li.PosY = (self.Height - li.Height)/2
-
-  self.BGPosX = li.PosX-20
-  self.BGPosY = li.PosY-20
-  self.BGWidth = li.Width+40
-  self.BGHeight = li.Height+40  
-  
-  self.MyList = append(self.MyList ,li )
-  
+	self.PosX = self.Index * self.Screen.Width
+	self.Width = self.Screen.Width
+	self.Height = self.Screen.Height
+
+	self.CanvasHWND = self.Screen.CanvasHWND
+
+	li := UI.NewMultiLabel()
+	li.SetCanvasHWND(self.CanvasHWND)
+	li.Width = 160
+	li.Init(self.ConfirmText, self.ListFont, nil)
+
+	li.PosX = (self.Width - li.Width) / 2
+	li.PosY = (self.Height - li.Height) / 2
+
+	self.BGPosX = li.PosX - 20
+	self.BGPosY = li.PosY - 20
+	self.BGWidth = li.Width + 40
+	self.BGHeight = li.Height + 40
+
+	self.MyList = append(self.MyList, li)
+
 }
 
 func (self *RomSoConfirmPage) SnapMsg(msg string) {
-  self.MyList[0].SetText(msg)
-  self.Screen.Draw()
-  self.Screen.SwapAndShow()
-  self.MyList[0].SetText(self.ConfirmText)
+	self.MyList[0].SetText(msg)
+	self.Screen.Draw()
+	self.Screen.SwapAndShow()
+	self.MyList[0].SetText(self.ConfirmText)
 }
 
 func (self *RomSoConfirmPage) OnReturnBackCb() {
-  self.ReturnToUpLevelPage()
-  self.Screen.Draw()
-  self.Screen.SwapAndShow()
+	self.ReturnToUpLevelPage()
+	self.Screen.Draw()
+	self.Screen.SwapAndShow()
 }
 
 func (self *RomSoConfirmPage) 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"] {
-    bat := UI.CheckBattery()
-    if bat < 5 && bat >= 0 {
-      self.SnapMsg("Battery must over 5%")
-    }else { // -1 or something else,
-      if self.DownloadPage == nil {
-        self.DownloadPage = UI.NewDownloadProcessPage()
-        self.DownloadPage.Screen = self.Screen
-        self.DownloadPage.Name   = "Downloading"
-        self.DownloadPage.Init()
-      }
-      
-      self.Screen.PushPage(self.DownloadPage)
-      self.Screen.Draw()
-      self.Screen.SwapAndShow()
-      ec := self.Parent.GetEmulatorConfig()
-      if sysgo.CurKeySet == "PC" {
-        
-        so_url := ec.SO_URL
-        so_url = strings.Replace(so_url,"armhf","x86_64",-1)
-        fmt.Println(so_url)
-        self.DownloadPage.StartDownload(so_url,filepath.Dir(ec.ROM_SO))
-        
-      }else{
-        so_url := ec.SO_URL
-        go self.DownloadPage.StartDownload(so_url,filepath.Dir(ec.ROM_SO))
-      }
-    }
-  }
+
+	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"] {
+		bat := UI.CheckBattery()
+		if bat < 5 && bat >= 0 {
+			self.SnapMsg("Battery must over 5%")
+		} else { // -1 or something else,
+			if self.DownloadPage == nil {
+				self.DownloadPage = UI.NewDownloadProcessPage()
+				self.DownloadPage.Screen = self.Screen
+				self.DownloadPage.Name = "Downloading"
+				self.DownloadPage.Init()
+			}
+
+			self.Screen.PushPage(self.DownloadPage)
+			self.Screen.Draw()
+			self.Screen.SwapAndShow()
+			ec := self.Parent.GetEmulatorConfig()
+			if sysgo.CurKeySet == "PC" {
+
+				so_url := ec.SO_URL
+				so_url = strings.Replace(so_url, "armhf", "x86_64", -1)
+				fmt.Println(so_url)
+				self.DownloadPage.StartDownload(so_url, filepath.Dir(ec.ROM_SO))
+
+			} else {
+				so_url := ec.SO_URL
+				go self.DownloadPage.StartDownload(so_url, filepath.Dir(ec.ROM_SO))
+			}
+		}
+	}
 }
 
 func (self *RomSoConfirmPage) Draw() {
-  self.ClearCanvas()
-  self.DrawBG()
-  for _,v := range self.MyList{
-    v.Draw()
-  }  
-    
+	self.ClearCanvas()
+	self.DrawBG()
+	for _, v := range self.MyList {
+		v.Draw()
+	}
 
 }

+ 55 - 60
sysgo/UI/UI.go

@@ -1,54 +1,52 @@
 package UI
 
 import (
-
 	"fmt"
-	
+
 	"github.com/veandco/go-sdl2/ttf"
-	
-	"github.com/cuu/gogame/font"	
+
 	"github.com/clockworkpi/LauncherGoDev/sysgo"
+	"github.com/cuu/gogame/font"
 )
 
 type WidgetInterface interface {
-	Size() (int,int)
-	NewSize(w,h int)
-	Coord()(int,int)
-	NewCoord(x,y int)
+	Size() (int, int)
+	NewSize(w, h int)
+	Coord() (int, int)
+	NewCoord(x, y int)
 }
 
 type Coord struct {
-  X int 
-  Y int
+	X int
+	Y int
 }
 
 type Plane struct {
-  W int 
-  H int
-
+	W int
+	H int
 }
 
 type Widget struct {
-	PosX int
-	PosY int
-	Width int
+	PosX   int
+	PosY   int
+	Width  int
 	Height int
 }
 
-func (self *Widget) Size() (int,int) {
-	return self.Width,self.Height
+func (self *Widget) Size() (int, int) {
+	return self.Width, self.Height
 }
 
-func (self *Widget) NewSize(w,h int) {
+func (self *Widget) NewSize(w, h int) {
 	self.Width = w
 	self.Height = h
 }
 
-func (self *Widget) Coord() (int,int) {
-	return self.PosX,self.PosY
+func (self *Widget) Coord() (int, int) {
+	return self.PosX, self.PosY
 }
 
-func (self *Widget) NewCoord(x,y int) {
+func (self *Widget) NewCoord(x, y int) {
 	self.PosX = x
 	self.PosY = y
 }
@@ -57,58 +55,55 @@ func (self *Widget) NewCoord(x,y int) {
 func Init() {
 	font.Init()
 
-	skinpath :=  sysgo.SKIN+"/truetype"
+	skinpath := sysgo.SKIN + "/truetype"
 
 	Fonts = make(map[string]*ttf.Font)
 
 	fonts_path := make(map[string]string)
 
+	fonts_path["varela"] = fmt.Sprintf("%s/VarelaRound-Regular.ttf", skinpath)
+	fonts_path["veramono"] = fmt.Sprintf("%s/VeraMono.ttf", skinpath)
+	fonts_path["noto"] = fmt.Sprintf("%s/NotoSansMono-Regular.ttf", skinpath)
+	fonts_path["notocjk"] = fmt.Sprintf("%s/NotoSansCJK-Regular.ttf", skinpath)
 
-	fonts_path["varela"] = fmt.Sprintf("%s/VarelaRound-Regular.ttf",skinpath)
-	fonts_path["veramono"] = fmt.Sprintf("%s/VeraMono.ttf",skinpath)
-	fonts_path["noto"]     = fmt.Sprintf("%s/NotoSansMono-Regular.ttf", skinpath)
-	fonts_path["notocjk"]  = fmt.Sprintf("%s/NotoSansCJK-Regular.ttf" ,skinpath)
-
-	for i:=10;i<41;i++ {
-		keyname := fmt.Sprintf("varela%d",i)
-		Fonts[ keyname ] = font.Font(fonts_path["varela"],i)
+	for i := 10; i < 41; i++ {
+		keyname := fmt.Sprintf("varela%d", i)
+		Fonts[keyname] = font.Font(fonts_path["varela"], i)
 	}
-  
-  Fonts["varela120"] = font.Font(fonts_path["varela"],120)
-  
-	for i:=10;i<26;i++ {
+
+	Fonts["varela120"] = font.Font(fonts_path["varela"], 120)
+
+	for i := 10; i < 26; i++ {
 		keyname := fmt.Sprintf("veramono%d", i)
-		Fonts[keyname] = font.Font(fonts_path["veramono"],i)
+		Fonts[keyname] = font.Font(fonts_path["veramono"], i)
 	}
 
-	for i:= 10;i<28;i++ {
+	for i := 10; i < 28; i++ {
 		keyname := fmt.Sprintf("notosansmono%d", i)
 		Fonts[keyname] = font.Font(fonts_path["noto"], i)
 	}
 
-	for i:=10;i<28;i++ {
-		keyname := fmt.Sprintf("notosanscjk%d",i)
-		Fonts[keyname] = font.Font(fonts_path["notocjk"],i)
+	for i := 10; i < 28; i++ {
+		keyname := fmt.Sprintf("notosanscjk%d", i)
+		Fonts[keyname] = font.Font(fonts_path["notocjk"], i)
 	}
-  
-  //
-  keys_def_init()
-  
-  //// global variables Init
-  if MyIconPool == nil {
-    MyIconPool = NewIconPool()
-    MyIconPool.Init()
-  }
-  if MyLangManager == nil {
-  
-    MyLangManager = NewLangManager()
-    MyLangManager.Init()
-    
-  }
-  if MySkinManager == nil {
-    MySkinManager = NewSkinManager()
-    MySkinManager.Init()
-  }  
-}
 
+	//
+	keys_def_init()
+
+	//// global variables Init
+	if MyIconPool == nil {
+		MyIconPool = NewIconPool()
+		MyIconPool.Init()
+	}
+	if MyLangManager == nil {
+
+		MyLangManager = NewLangManager()
+		MyLangManager.Init()
 
+	}
+	if MySkinManager == nil {
+		MySkinManager = NewSkinManager()
+		MySkinManager.Init()
+	}
+}

+ 53 - 56
sysgo/UI/above_all_patch.go

@@ -1,76 +1,73 @@
 package UI
 
-import(
+import (
 	"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/color"
+	"github.com/cuu/gogame/rect"
 )
 
 type AboveAllPatch struct {
+	Widget
+
+	Text string
+
+	FontObj *ttf.Font
+
+	Color    *color.Color
+	ValColor *color.Color
+
+	CanvasHWND *sdl.Surface
 
-  Widget
-  
-  Text string
-  
-  FontObj *ttf.Font
-  
-  Color *color.Color
-  ValColor *color.Color
-  
-  CanvasHWND *sdl.Surface
-  
-  Icons map[string]IconItemInterface
-  
-  Value int 
+	Icons map[string]IconItemInterface
+
+	Value int
 }
 
 func NewAboveAllPatch() *AboveAllPatch {
-  
-  p := &AboveAllPatch{}
-  p.PosX = Width /2
-  p.PosY = Height /2
-  p.Width = 50
-  p.Height = 120
-  
-  p.FontObj = Fonts["veramono20"]
-  p.Color   = MySkinManager.GiveColor("Text")
-  p.ValColor = MySkinManager.GiveColor("URL")
-  
-  p.Icons = make( map[string]IconItemInterface )
-  
-  p.Value = 0
-
-  return p
+
+	p := &AboveAllPatch{}
+	p.PosX = Width / 2
+	p.PosY = Height / 2
+	p.Width = 50
+	p.Height = 120
+
+	p.FontObj = Fonts["veramono20"]
+	p.Color = MySkinManager.GiveColor("Text")
+	p.ValColor = MySkinManager.GiveColor("URL")
+
+	p.Icons = make(map[string]IconItemInterface)
+
+	p.Value = 0
+
+	return p
 }
 
-func (self *AboveAllPatch) SetCanvasHWND( _canvashwnd *sdl.Surface) {
-  
-  self.CanvasHWND = _canvashwnd
+func (self *AboveAllPatch) SetCanvasHWND(_canvashwnd *sdl.Surface) {
+
+	self.CanvasHWND = _canvashwnd
 
 }
 
 func (self *AboveAllPatch) Draw() {
-  start_rect := draw.MidRect(self.PosX,self.PosY,self.Width,self.Height,Width,Height)
-  draw.AARoundRect(self.CanvasHWND,start_rect,self.Color,3,0,self.Color)
-  
-  if self.Value  > 10 {
-    vol_height := int(float64(self.Height) * (float64(self.Value)/100.0))
-    dheight    := self.Height - vol_height
-    
-    vol_rect   := rect.Rect(self.PosX - self.Width/2,self.PosY - self.Height/2+dheight,self.Width,vol_height)
-    
-    draw.AARoundRect(self.CanvasHWND,&vol_rect,self.ValColor,3,0,self.ValColor)
-    
-  }else {
-      vol_height := 10
-      dheight    := self.Height - vol_height
-      vol_rect   := rect.Rect(self.PosX - self.Width/2,self.PosY - self.Height/2+dheight,self.Width,vol_height)
-      
-      draw.AARoundRect(self.CanvasHWND,&vol_rect,self.ValColor,3,0,self.ValColor)
-  }
-}
+	start_rect := draw.MidRect(self.PosX, self.PosY, self.Width, self.Height, Width, Height)
+	draw.AARoundRect(self.CanvasHWND, start_rect, self.Color, 3, 0, self.Color)
 
+	if self.Value > 10 {
+		vol_height := int(float64(self.Height) * (float64(self.Value) / 100.0))
+		dheight := self.Height - vol_height
 
+		vol_rect := rect.Rect(self.PosX-self.Width/2, self.PosY-self.Height/2+dheight, self.Width, vol_height)
+
+		draw.AARoundRect(self.CanvasHWND, &vol_rect, self.ValColor, 3, 0, self.ValColor)
+
+	} else {
+		vol_height := 10
+		dheight := self.Height - vol_height
+		vol_rect := rect.Rect(self.PosX-self.Width/2, self.PosY-self.Height/2+dheight, self.Width, vol_height)
+
+		draw.AARoundRect(self.CanvasHWND, &vol_rect, self.ValColor, 3, 0, self.ValColor)
+	}
+}

+ 114 - 121
sysgo/UI/confirm_page.go

@@ -3,167 +3,160 @@ package UI
 import (
 	//"fmt"
 	"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/surface"
 	"github.com/cuu/gogame/color"
-//	"github.com/cuu/gogame/font"
+	"github.com/cuu/gogame/event"
+	"github.com/cuu/gogame/rect"
+	//	"github.com/cuu/gogame/font"
 	"github.com/cuu/gogame/draw"
-	
 )
 
 type ListPageSelector struct {
-  PageSelector
-  BackgroundColor *color.Color
-  Parent *ConfirmPage
+	PageSelector
+	BackgroundColor *color.Color
+	Parent          *ConfirmPage
 }
 
 func NewListPageSelector() *ListPageSelector {
-  p := &ListPageSelector{}
-  p.Width = Width
-  p.BackgroundColor = &color.Color{131,199,219,255}
-  return p
+	p := &ListPageSelector{}
+	p.Width = Width
+	p.BackgroundColor = &color.Color{131, 199, 219, 255}
+	return p
 }
 
 func (self *ListPageSelector) Draw() {
-  idx := self.Parent.GetPsIndex()
-  mylist := self.Parent.MyList
-  if idx > (len(mylist) -1) {
-    idx = len(mylist)
-    if idx > 0 {
-      idx -= 1
-    }else if idx == 0 {
-      return
-    }
-  }
-  
-  x,y  := mylist[idx].Coord()
-  _,h  := mylist[idx].Size()
-  
-  self.PosX = x
-  self.PosY = y
-  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.MyList
+	if idx > (len(mylist) - 1) {
+		idx = len(mylist)
+		if idx > 0 {
+			idx -= 1
+		} else if idx == 0 {
+			return
+		}
+	}
+
+	x, y := mylist[idx].Coord()
+	_, h := mylist[idx].Size()
+
+	self.PosX = x
+	self.PosY = y
+	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 ConfirmPage struct {
-  Page
-  ListFont  *ttf.Font
-  FileName string
-  TrashDir string
-  ConfirmText string
-  BGPosX    int
-  BGPosY    int
-  BGWidth   int
-  BGHeight  int
-  Icons map[string]IconItemInterface
-  
-  MyList []LabelInterface
-  
+	Page
+	ListFont    *ttf.Font
+	FileName    string
+	TrashDir    string
+	ConfirmText string
+	BGPosX      int
+	BGPosY      int
+	BGWidth     int
+	BGHeight    int
+	Icons       map[string]IconItemInterface
+
+	MyList []LabelInterface
 }
 
+func NewConfirmPage() *ConfirmPage {
+	p := &ConfirmPage{}
+	p.ListFont = Fonts["veramono20"]
+	p.FootMsg = [5]string{"Nav", "", "", "Cancel", "Yes"}
+	p.ConfirmText = "Confirm?"
 
-func NewConfirmPage() *ConfirmPage  {
-  p := &ConfirmPage{}
-  p.ListFont = Fonts["veramono20"]
-  p.FootMsg = [5]string{"Nav","","","Cancel","Yes"}
-  p.ConfirmText ="Confirm?"
-  
-  return p
+	return p
 }
 
-
 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].NewCoord( (self.Width - w)/2, (self.Height - h)/2) 
-  
-  x,y = self.MyList[0].Coord()
-  
-  self.BGPosX = x - 10
-  self.BGPosY = y - 10
-  
-  self.BGWidth =  w + 20
-  self.BGHeight = h + 20  
+	self.MyList[0].SetText(self.ConfirmText)
+	x, y := self.MyList[0].Coord()
+	w, h := self.MyList[0].Size()
+
+	self.MyList[0].NewCoord((self.Width-w)/2, (self.Height-h)/2)
+
+	x, y = self.MyList[0].Coord()
+
+	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)
-  x,y := self.MyList[0].Coord()
-  w,h := self.MyList[0].Size()
-   
-  self.MyList[0].NewCoord( (self.Width - w )/2, (self.Height - h)/2 )
-  
-  x, y = self.MyList[0].Coord()
-  
-  self.BGPosX = x - 10
-  self.BGPosY = y - 10
-  
-  self.BGWidth = w + 20
-  self.BGHeight = h +20
-  
+	self.MyList[0].SetText(msg)
+	x, y := self.MyList[0].Coord()
+	w, h := self.MyList[0].Size()
+
+	self.MyList[0].NewCoord((self.Width-w)/2, (self.Height-h)/2)
+
+	x, y = self.MyList[0].Coord()
+
+	self.BGPosX = x - 10
+	self.BGPosY = y - 10
+
+	self.BGWidth = w + 20
+	self.BGHeight = h + 20
+
 }
 
 func (self *ConfirmPage) Init() {
-  if self.Screen != nil {
-  
-    self.PosX = self.Index * self.Screen.Width
+	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 := NewListPageSelector()
-    ps.Parent = self
-    self.Ps = ps
-    self.PsIndex = 0
-    
-    li := NewLabel()
-    li.SetCanvasHWND(self.CanvasHWND)
-    li.Init(self.ConfirmText,self.ListFont,nil)
-    
-    li.PosX = (self.Width - li.Width)/2
-    li.PosY = (self.Height - li.Height)/2
-    
-    self.BGPosX = li.PosX - 10
-    self.BGPosY = li.PosY - 10
-    self.BGWidth = li.Width + 20
-    self.BGHeight = li.Height + 20
-    
-    self.MyList = append(self.MyList,li)
-    
-  }
+
+		ps := NewListPageSelector()
+		ps.Parent = self
+		self.Ps = ps
+		self.PsIndex = 0
+
+		li := NewLabel()
+		li.SetCanvasHWND(self.CanvasHWND)
+		li.Init(self.ConfirmText, self.ListFont, nil)
+
+		li.PosX = (self.Width - li.Width) / 2
+		li.PosY = (self.Height - li.Height) / 2
+
+		self.BGPosX = li.PosX - 10
+		self.BGPosY = li.PosY - 10
+		self.BGWidth = li.Width + 20
+		self.BGHeight = li.Height + 20
+
+		self.MyList = append(self.MyList, li)
+
+	}
 }
 
+func (self *ConfirmPage) KeyDown(ev *event.Event) {
 
-func (self *ConfirmPage) KeyDown( ev *event.Event ) {
- 
 	if ev.Data["Key"] == CurKeys["A"] || ev.Data["Key"] == CurKeys["Menu"] {
 		self.ReturnToUpLevelPage()
 		self.Screen.Draw()
 		self.Screen.SwapAndShow()
-	}  
+	}
 }
 
 func (self *ConfirmPage) DrawBG() {
-  rect_ := rect.Rect(self.BGPosX,self.BGPosY,self.BGWidth,self.BGHeight)
-  
-  draw.Rect(self.CanvasHWND,&color.Color{255,255,255,255}, &rect_, 0) // SkinManager().GiveColor('White')
-  draw.Rect(self.CanvasHWND,&color.Color{83,83,83,255}, &rect_, 1)//SkinManager().GiveColor('Text')
-}
+	rect_ := rect.Rect(self.BGPosX, self.BGPosY, self.BGWidth, self.BGHeight)
 
+	draw.Rect(self.CanvasHWND, &color.Color{255, 255, 255, 255}, &rect_, 0) // SkinManager().GiveColor('White')
+	draw.Rect(self.CanvasHWND, &color.Color{83, 83, 83, 255}, &rect_, 1)    //SkinManager().GiveColor('Text')
+}
 
 func (self *ConfirmPage) Draw() {
-  self.DrawBG()
-  for _,v := range self.MyList{
-    v.Draw()
-  }  
-  self.Reset()
+	self.DrawBG()
+	for _, v := range self.MyList {
+		v.Draw()
+	}
+	self.Reset()
 }

+ 7 - 9
sysgo/UI/constants.go

@@ -1,18 +1,16 @@
-
 package UI
 
 var (
-	Width = 320
-	Height = 240
-	IconWidth = 80
+	Width      = 320
+	Height     = 240
+	IconWidth  = 80
 	IconHeight = 80
-	IconExt   = ".sh"
+	IconExt    = ".sh"
 
-	ICON_TYPES = map[string]int{"Emulator":7,"FILE":6,"STAT":5,"NAV":4,"LETTER":3,"FUNC":2,"DIR":1,"EXE":0,"None":-1 }
-	ALIGN      = map[string]int{ "HLeft":0,"HCenter":1,"HRight":2,"VMiddle":3,"SLeft":4,"VCenter":5,"SCenter":6}
+	ICON_TYPES = map[string]int{"Emulator": 7, "FILE": 6, "STAT": 5, "NAV": 4, "LETTER": 3, "FUNC": 2, "DIR": 1, "EXE": 0, "None": -1}
+	ALIGN      = map[string]int{"HLeft": 0, "HCenter": 1, "HRight": 2, "VMiddle": 3, "SLeft": 4, "VCenter": 5, "SCenter": 6}
 
-	DT   = 50
-	
+	DT = 50
 )
 
 var (

+ 131 - 137
sysgo/UI/counter_screen.go

@@ -1,168 +1,162 @@
 package UI
 
 import (
-  "fmt"
-  gotime "time"
-  "github.com/veandco/go-sdl2/ttf"
+	"fmt"
+	"github.com/veandco/go-sdl2/ttf"
+	gotime "time"
 
-  "github.com/cuu/gogame/color"
-  "github.com/cuu/gogame/event"
-  "github.com/cuu/gogame/surface"
-
-  "github.com/clockworkpi/LauncherGoDev/sysgo"
+	"github.com/cuu/gogame/color"
+	"github.com/cuu/gogame/event"
+	"github.com/cuu/gogame/surface"
 
+	"github.com/clockworkpi/LauncherGoDev/sysgo"
 )
+
 type CounterScreen struct {
-  FullScreen
-  
-
-  CounterFont  *ttf.Font
-  TextFont1    *ttf.Font
-  TextFont2    *ttf.Font
-  
-  TopLabel    LabelInterface
-  BottomLabel  LabelInterface
-  NumberLabel  LabelInterface
-  BGColor     *color.Color
-  FGColor     *color.Color
-  
-  Counting    bool
-  
-  Number      int // 10
-  
-  inter_counter int //
-  
-  TheTicker *gotime.Ticker
-  TickerStoped chan bool
-  
+	FullScreen
+
+	CounterFont *ttf.Font
+	TextFont1   *ttf.Font
+	TextFont2   *ttf.Font
+
+	TopLabel    LabelInterface
+	BottomLabel LabelInterface
+	NumberLabel LabelInterface
+	BGColor     *color.Color
+	FGColor     *color.Color
+
+	Counting bool
+
+	Number int // 10
+
+	inter_counter int //
+
+	TheTicker    *gotime.Ticker
+	TickerStoped chan bool
 }
 
 func NewCounterScreen() *CounterScreen {
-  p := &CounterScreen{}
-  p.Width = Width
-  p.Height = Height
-  
-  p.Number = 10
-  p.CounterFont = Fonts["varela120"]
-  p.TextFont1 = Fonts["varela15"]
-  p.TextFont2 = Fonts["varela12"]
-  
-  p.BGColor = &color.Color{0,0,0,255}
-  p.FGColor = &color.Color{255,255,255,255}
-  
-  return p
+	p := &CounterScreen{}
+	p.Width = Width
+	p.Height = Height
+
+	p.Number = 10
+	p.CounterFont = Fonts["varela120"]
+	p.TextFont1 = Fonts["varela15"]
+	p.TextFont2 = Fonts["varela12"]
+
+	p.BGColor = &color.Color{0, 0, 0, 255}
+	p.FGColor = &color.Color{255, 255, 255, 255}
+
+	return p
 }
 
-func (self *CounterScreen ) Interval() {
+func (self *CounterScreen) Interval() {
 
- for {
+	for {
 		select {
 		case <-self.TheTicker.C:
-      self.inter_counter += 1
-      
-      if self.Number == 0 {
-        self.Counting = false
-        self.TheTicker.Stop()
-        fmt.Println("do the real shutdown")
-        
-        if sysgo.CurKeySet != "PC" {
-          cmdpath := "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
-          cmdpath = cmdpath + "sleep 3;"
-          cmdpath = cmdpath + "sudo halt -p"
-          event.Post(RUNEVT,cmdpath)
-          
-        }
-        
-        break
-      }
-      
-      if self.inter_counter >= 2 {
-        self.Number -= 1
-        if self.Number < 0 {
-          self.Number = 0
-        }
-        
-        fmt.Println("sub Number ", self.Number)
-        self.inter_counter = 0
-        
-        self.Draw()
-        self.SwapAndShow()
-      
-      }
-    case <- self.TickerStoped:
-      break
-    }
-  }
+			self.inter_counter += 1
 
-}
+			if self.Number == 0 {
+				self.Counting = false
+				self.TheTicker.Stop()
+				fmt.Println("do the real shutdown")
 
+				if sysgo.CurKeySet != "PC" {
+					cmdpath := "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
+					cmdpath = cmdpath + "sleep 3;"
+					cmdpath = cmdpath + "sudo halt -p"
+					event.Post(RUNEVT, cmdpath)
 
-func (self *CounterScreen) StartCounter() {
-  if self.Counting == true {
-    return
-  }
-  
-  self.Number = 10
-  self.inter_counter = 0
-  
-  self.Counting = true
-  
-  self.TheTicker = gotime.NewTicker(500 * gotime.Millisecond)
-  
-  go self.Interval()
+				}
+
+				break
+			}
+
+			if self.inter_counter >= 2 {
+				self.Number -= 1
+				if self.Number < 0 {
+					self.Number = 0
+				}
+
+				fmt.Println("sub Number ", self.Number)
+				self.inter_counter = 0
+
+				self.Draw()
+				self.SwapAndShow()
+
+			}
+		case <-self.TickerStoped:
+			break
+		}
+	}
 
 }
 
+func (self *CounterScreen) StartCounter() {
+	if self.Counting == true {
+		return
+	}
+
+	self.Number = 10
+	self.inter_counter = 0
+
+	self.Counting = true
+
+	self.TheTicker = gotime.NewTicker(500 * gotime.Millisecond)
+
+	go self.Interval()
+
+}
 
 func (self *CounterScreen) StopCounter() {
-  if self.Counting == false {
-    return
-  }
-  
-  self.Counting = false
-  self.Number = 0
-  self.inter_counter = 0
-  
-  self.TheTicker.Stop()
-  self.TickerStoped <- true
-  
+	if self.Counting == false {
+		return
+	}
+
+	self.Counting = false
+	self.Number = 0
+	self.inter_counter = 0
+
+	self.TheTicker.Stop()
+	self.TickerStoped <- true
+
 }
 
 func (self *CounterScreen) Init() {
-  
-  self.CanvasHWND = surface.Surface(self.Width,self.Height)
-  
-  self.TopLabel = NewLabel()
-  self.TopLabel.SetCanvasHWND( self.CanvasHWND)
-  self.TopLabel.Init("System shutdown in", self.TextFont1,self.FGColor)
-  
-  self.BottomLabel = NewLabel()
-  self.BottomLabel.SetCanvasHWND(self.CanvasHWND)
-  self.BottomLabel.Init("Press any key to stop countdown",self.TextFont2,self.FGColor)
-  
-  
-  self.NumberLabel  = NewLabel()
-  self.NumberLabel.SetCanvasHWND(self.CanvasHWND)
-  number_str := fmt.Sprintf("%d",self.Number)
-  self.NumberLabel.Init(number_str,self.CounterFont,self.FGColor)
-  
-  self.TickerStoped = make(chan bool,1)
-  
+
+	self.CanvasHWND = surface.Surface(self.Width, self.Height)
+
+	self.TopLabel = NewLabel()
+	self.TopLabel.SetCanvasHWND(self.CanvasHWND)
+	self.TopLabel.Init("System shutdown in", self.TextFont1, self.FGColor)
+
+	self.BottomLabel = NewLabel()
+	self.BottomLabel.SetCanvasHWND(self.CanvasHWND)
+	self.BottomLabel.Init("Press any key to stop countdown", self.TextFont2, self.FGColor)
+
+	self.NumberLabel = NewLabel()
+	self.NumberLabel.SetCanvasHWND(self.CanvasHWND)
+	number_str := fmt.Sprintf("%d", self.Number)
+	self.NumberLabel.Init(number_str, self.CounterFont, self.FGColor)
+
+	self.TickerStoped = make(chan bool, 1)
+
 }
 
 func (self *CounterScreen) Draw() {
-  surface.Fill(self.CanvasHWND, self.BGColor)
-  
-  self.TopLabel.NewCoord(Width/2,15)
-  self.TopLabel.DrawCenter(false)
-  
-  self.BottomLabel.NewCoord(Width/2, Height-15)
-  self.BottomLabel.DrawCenter(false)
-
-  self.NumberLabel.NewCoord(Width/2,Height/2)
-  number_str := fmt.Sprintf("%d",self.Number)
-  self.NumberLabel.SetText(number_str)
-  self.NumberLabel.DrawCenter(false)  
+	surface.Fill(self.CanvasHWND, self.BGColor)
 
-}
+	self.TopLabel.NewCoord(Width/2, 15)
+	self.TopLabel.DrawCenter(false)
+
+	self.BottomLabel.NewCoord(Width/2, Height-15)
+	self.BottomLabel.DrawCenter(false)
 
+	self.NumberLabel.NewCoord(Width/2, Height/2)
+	number_str := fmt.Sprintf("%d", self.Number)
+	self.NumberLabel.SetText(number_str)
+	self.NumberLabel.DrawCenter(false)
+
+}

+ 49 - 53
sysgo/UI/delete_confirm_page.go

@@ -1,77 +1,73 @@
 package UI
 
-import(
-  "fmt"
-  "os"
-  "path/filepath"
-  "strings"
-  
-  "github.com/cuu/gogame/event"
-  "github.com/cuu/gogame/time"
+import (
+	"fmt"
+	"os"
+	"path/filepath"
+	"strings"
+
+	"github.com/cuu/gogame/event"
+	"github.com/cuu/gogame/time"
 )
 
 type DeleteConfirmPage struct {
-  ConfirmPage
-
+	ConfirmPage
 }
 
-
 func NewDeleteConfirmPage() *DeleteConfirmPage {
-  p := &DeleteConfirmPage{}
-  p.ListFont = Fonts["veramono20"]
-  p.FootMsg = [5]string{"Nav","","","Cancel","Yes"}
-  p.ConfirmText ="Confirm Delete ?"
-  
-  
-  return p
-}
+	p := &DeleteConfirmPage{}
+	p.ListFont = Fonts["veramono20"]
+	p.FootMsg = [5]string{"Nav", "", "", "Cancel", "Yes"}
+	p.ConfirmText = "Confirm Delete ?"
 
+	return p
+}
 
 func (self *DeleteConfirmPage) SetTrashDir(d string) {
-  self.TrashDir = d
-  if IsDirectory(self.TrashDir)== false {
-    panic("DeleteConfirmPage SetTrashDir errors")
-  }
+	self.TrashDir = d
+	if IsDirectory(self.TrashDir) == false {
+		panic("DeleteConfirmPage SetTrashDir errors")
+	}
 }
 
 func (self *DeleteConfirmPage) SetFileName(fn string) {
-  self.FileName = fn
+	self.FileName = fn
 }
 
 func (self *DeleteConfirmPage) KeyDown(ev *event.Event) {
 
- 	if ev.Data["Key"] == CurKeys["A"] || ev.Data["Key"] == CurKeys["Menu"] {
+	if ev.Data["Key"] == CurKeys["A"] || ev.Data["Key"] == CurKeys["Menu"] {
 		self.ReturnToUpLevelPage()
 		self.Screen.Draw()
 		self.Screen.SwapAndShow()
 	}
 
-  if ev.Data["Key"] == CurKeys["B"] {
-    err := os.Remove(filepath.Join(self.TrashDir, filepath.Base(self.FileName)))
-    if err != nil {
-      fmt.Println("DeleteConfirmPage os.Remove errors :",err)
-    }
-    
-    err = os.Rename(filepath.Base(self.FileName), filepath.Join(self.TrashDir, filepath.Base(self.FileName)))
-    if err != nil {
-      if strings.Contains(err.Error(),"exists" ) {
-        self.Screen.MsgBox.SetText("Already Existed")
-      } else {
-        self.Screen.MsgBox.SetText("Error")
-      }
-      self.Screen.MsgBox.Draw()
-      self.Screen.SwapAndShow()
-    } else {
-      self.SnapMsg("Deleting")
-      self.Screen.Draw()
-      self.Screen.SwapAndShow()
-      self.Reset()
-      time.BlockDelay(300)
-      self.ReturnToUpLevelPage()
-      self.Screen.Draw()
-      self.Screen.SwapAndShow()
-    }
-    
-    fmt.Println(self.FileName)
-  }
+	if ev.Data["Key"] == CurKeys["B"] {
+		err := os.Remove(filepath.Join(self.TrashDir, filepath.Base(self.FileName)))
+		if err != nil {
+			fmt.Println("DeleteConfirmPage os.Remove errors :", err)
+		}
+
+		err = os.Rename(filepath.Base(self.FileName), filepath.Join(self.TrashDir, filepath.Base(self.FileName)))
+		if err != nil {
+			if strings.Contains(err.Error(), "exists") {
+				self.Screen.MsgBox.SetText("Already Existed")
+			} else {
+				self.Screen.MsgBox.SetText("Error")
+			}
+			self.Screen.MsgBox.Draw()
+			self.Screen.SwapAndShow()
+		} else {
+			self.SnapMsg("Deleting")
+			self.Screen.Draw()
+			self.Screen.SwapAndShow()
+			self.Reset()
+			time.BlockDelay(300)
+			self.ReturnToUpLevelPage()
+			self.Screen.Draw()
+			self.Screen.SwapAndShow()
+		}
+
+		fmt.Println(self.FileName)
+	}
 }

+ 234 - 241
sysgo/UI/download_process_page.go

@@ -1,291 +1,284 @@
 package UI
 
 import (
-  "fmt"
-  "os"
-  "strings"
-  "path/filepath"
-  "os/exec"
-  
-  gotime "time"
-  "net/url"
-  
-  "github.com/cuu/grab"
-  "github.com/cuu/gogame/color"
-  "github.com/cuu/gogame/event"
-  "github.com/cuu/gogame/draw"
+	"fmt"
+	"os"
+	"os/exec"
+	"path/filepath"
+	"strings"
 
+	"net/url"
+	gotime "time"
+
+	"github.com/cuu/gogame/color"
+	"github.com/cuu/gogame/draw"
+	"github.com/cuu/gogame/event"
+	"github.com/cuu/grab"
 )
 
 type DownloadProcessPage struct {
-  Page
-    
-  URL string
-  DST_DIR string
-  Value   int
-  PngSize map[string][2]int
-  Doing bool
-  
-  FileNameLabel LabelInterface
-  SizeLabel     LabelInterface
-  
-  Icons  map[string]IconItemInterface
-
-  URLColor  *color.Color
-  TextColor  *color.Color
-  TheTicker *gotime.Ticker
-  
-  Downloader *grab.Client
-  resp *grab.Response
-  req *grab.Request
-  
-}
+	Page
+
+	URL     string
+	DST_DIR string
+	Value   int
+	PngSize map[string][2]int
+	Doing   bool
+
+	FileNameLabel LabelInterface
+	SizeLabel     LabelInterface
+
+	Icons map[string]IconItemInterface
 
+	URLColor  *color.Color
+	TextColor *color.Color
+	TheTicker *gotime.Ticker
+
+	Downloader *grab.Client
+	resp       *grab.Response
+	req        *grab.Request
+}
 
 func NewDownloadProcessPage() *DownloadProcessPage {
-  
-  p := &DownloadProcessPage{}
-  
-  p.FootMsg = [5]string{"Nav","","","Back",""}
-  
-  p.URLColor = &color.Color{51, 166, 255,255 } // URL
-  p.TextColor = &color.Color{83,83,83,255 } // Text
-  
-  p.PngSize = make(map[string][2]int,0)
-  
-  p.Icons=make(map[string]IconItemInterface)
-  
-  return p
+
+	p := &DownloadProcessPage{}
+
+	p.FootMsg = [5]string{"Nav", "", "", "Back", ""}
+
+	p.URLColor = &color.Color{51, 166, 255, 255} // URL
+	p.TextColor = &color.Color{83, 83, 83, 255}  // Text
+
+	p.PngSize = make(map[string][2]int, 0)
+
+	p.Icons = make(map[string]IconItemInterface)
+
+	return p
 }
 
 func (self *DownloadProcessPage) Init() {
-  self.PosX = self.Index * self.Screen.Width
-  self.Width  = self.Screen.Width
-  self.Height = self.Screen.Height
-  
-  self.CanvasHWND = self.Screen.CanvasHWND
-  self.PngSize["bg"] = [2]int{48,79}
-  self.PngSize["needwifi_bg"] = [2]int{253,132}
-  
-  bgpng := NewIconItem()
-  bgpng.ImgSurf = MyIconPool.GetImgSurf("rom_download")
-  bgpng.MyType = ICON_TYPES["STAT"]
-  bgpng.Parent = self
-  bgpng.Adjust(0,0,self.PngSize["bg"][0],self.PngSize["bg"][1],0)
-  self.Icons["bg"] = bgpng
-  
-  needwifi_bg := NewIconItem()
-  needwifi_bg.ImgSurf = MyIconPool.GetImgSurf("needwifi_bg")
-  needwifi_bg.MyType = ICON_TYPES["STAT"]
-  needwifi_bg.Parent = self
-  needwifi_bg.Adjust(0,0,self.PngSize["needwifi_bg"][0],self.PngSize["needwifi_bg"][1],0)
-  
-  self.Icons["needwifi_bg"] = needwifi_bg
-
-  self.FileNameLabel = NewLabel()
-  self.FileNameLabel.SetCanvasHWND(self.CanvasHWND)
-  self.FileNameLabel.Init("", Fonts["varela12"],nil)
-  
-  self.SizeLabel = NewLabel()
-  self.SizeLabel.SetCanvasHWND(self.CanvasHWND)
-  self.SizeLabel.Init("0/0Kb",Fonts["varela12"],nil)
-  self.SizeLabel.SetColor( self.URLColor )
-  
-  self.Downloader = grab.NewClient()
-  
+	self.PosX = self.Index * self.Screen.Width
+	self.Width = self.Screen.Width
+	self.Height = self.Screen.Height
+
+	self.CanvasHWND = self.Screen.CanvasHWND
+	self.PngSize["bg"] = [2]int{48, 79}
+	self.PngSize["needwifi_bg"] = [2]int{253, 132}
+
+	bgpng := NewIconItem()
+	bgpng.ImgSurf = MyIconPool.GetImgSurf("rom_download")
+	bgpng.MyType = ICON_TYPES["STAT"]
+	bgpng.Parent = self
+	bgpng.Adjust(0, 0, self.PngSize["bg"][0], self.PngSize["bg"][1], 0)
+	self.Icons["bg"] = bgpng
+
+	needwifi_bg := NewIconItem()
+	needwifi_bg.ImgSurf = MyIconPool.GetImgSurf("needwifi_bg")
+	needwifi_bg.MyType = ICON_TYPES["STAT"]
+	needwifi_bg.Parent = self
+	needwifi_bg.Adjust(0, 0, self.PngSize["needwifi_bg"][0], self.PngSize["needwifi_bg"][1], 0)
+
+	self.Icons["needwifi_bg"] = needwifi_bg
+
+	self.FileNameLabel = NewLabel()
+	self.FileNameLabel.SetCanvasHWND(self.CanvasHWND)
+	self.FileNameLabel.Init("", Fonts["varela12"], nil)
+
+	self.SizeLabel = NewLabel()
+	self.SizeLabel.SetCanvasHWND(self.CanvasHWND)
+	self.SizeLabel.Init("0/0Kb", Fonts["varela12"], nil)
+	self.SizeLabel.SetColor(self.URLColor)
+
+	self.Downloader = grab.NewClient()
+
 }
 
 func (self *DownloadProcessPage) OnExitCb() {
-  
-  //Stop Ticker and the Grab
-  if self.TheTicker != nil {
-    self.TheTicker.Stop()
-  }
-  
+
+	//Stop Ticker and the Grab
+	if self.TheTicker != nil {
+		self.TheTicker.Stop()
+	}
+
 }
 
 // should be in a gorotine
-func (self *DownloadProcessPage) UpdateProcessInterval() {  
-  
-  if self.Doing == true {
-    return
-  }
-  self.Doing = true
-  for {
-      
-      gotime.Sleep(150 * gotime.Millisecond)
-      
-      fmt.Printf("  transferred %v / %v bytes (%.2f%%)\n",
+func (self *DownloadProcessPage) UpdateProcessInterval() {
+
+	if self.Doing == true {
+		return
+	}
+	self.Doing = true
+	for {
+
+		gotime.Sleep(150 * gotime.Millisecond)
+
+		fmt.Printf("  transferred %v / %v bytes (%.2f%%)\n",
 			self.resp.BytesComplete(),
 			self.resp.Size,
 			100*self.resp.Progress())
-      
-      self.Value = int(100.0*self.resp.Progress())
-      total := float64(self.resp.Size)/1000.0/1000.0
-      downloaded := float64(self.resp.BytesComplete())/1000.0/1000.0
-    
-      lb_str := fmt.Sprintf("%.2f/%.2fMb",downloaded,total)
-      self.SizeLabel.SetText(lb_str)
-    
-      self.FileNameLabel.SetText(filepath.Base(self.resp.Filename))
-      
-      
-      self.Screen.Draw()
-      self.Screen.SwapAndShow()
-  
-      if self.resp.Progress() >= 1.0  {
-        // download is complete
-        fmt.Println("download is complete ",self.Value)
-        self.Value = 0 
-        self.Doing=false
-        break
-      }
-      
-      if self.Doing == false {
-        break
-      }
-  }
-  
-  self.Doing=false
-  
+
+		self.Value = int(100.0 * self.resp.Progress())
+		total := float64(self.resp.Size) / 1000.0 / 1000.0
+		downloaded := float64(self.resp.BytesComplete()) / 1000.0 / 1000.0
+
+		lb_str := fmt.Sprintf("%.2f/%.2fMb", downloaded, total)
+		self.SizeLabel.SetText(lb_str)
+
+		self.FileNameLabel.SetText(filepath.Base(self.resp.Filename))
+
+		self.Screen.Draw()
+		self.Screen.SwapAndShow()
+
+		if self.resp.Progress() >= 1.0 {
+			// download is complete
+			fmt.Println("download is complete ", self.Value)
+			self.Value = 0
+			self.Doing = false
+			break
+		}
+
+		if self.Doing == false {
+			break
+		}
+	}
+
+	self.Doing = false
+
 	if err := self.resp.Err(); err != nil {
-    self.DownloadErr()
+		self.DownloadErr()
 		fmt.Fprintf(os.Stderr, "Download failed: %v\n", err)
-    
-    cmd := exec.Command("rm","-rf",self.resp.Filename)
-    cmd.Dir= self.DST_DIR
-    cmd.Run()
+
+		cmd := exec.Command("rm", "-rf", self.resp.Filename)
+		cmd.Dir = self.DST_DIR
+		cmd.Run()
 	}
 
-  fmt.Printf("Download saved to %s/%v \n",self.DST_DIR, self.resp.Filename)
-  
-  filename := filepath.Base(self.resp.Filename)
-  
-  if strings.HasSuffix(filename,".zip") {
-    cmd := exec.Command("unzip",filename)
-    cmd.Dir = self.DST_DIR
-    cmd.Run()
-  }else if strings.HasSuffix(filename,".zsync") {
-    cmd := exec.Command("rm","-rf",filename)
-    cmd.Dir = self.DST_DIR
-    cmd.Run()
-  }else if strings.HasSuffix(filename,".tar.gz") {
-    cmd := exec.Command("tar", "xf", filename)
-    cmd.Dir= self.DST_DIR
-    cmd.Run()
-  }
-  
-  cmd := exec.Command("rm","-rf",filename)
-  cmd.Dir = self.DST_DIR
-  cmd.Run()
-  
-  self.DoneAndReturnUpLevel()
-  
+	fmt.Printf("Download saved to %s/%v \n", self.DST_DIR, self.resp.Filename)
+
+	filename := filepath.Base(self.resp.Filename)
+
+	if strings.HasSuffix(filename, ".zip") {
+		cmd := exec.Command("unzip", filename)
+		cmd.Dir = self.DST_DIR
+		cmd.Run()
+	} else if strings.HasSuffix(filename, ".zsync") {
+		cmd := exec.Command("rm", "-rf", filename)
+		cmd.Dir = self.DST_DIR
+		cmd.Run()
+	} else if strings.HasSuffix(filename, ".tar.gz") {
+		cmd := exec.Command("tar", "xf", filename)
+		cmd.Dir = self.DST_DIR
+		cmd.Run()
+	}
+
+	cmd := exec.Command("rm", "-rf", filename)
+	cmd.Dir = self.DST_DIR
+	cmd.Run()
+
+	self.DoneAndReturnUpLevel()
+
 }
 
-func (self *DownloadProcessPage) DownloadErr()  {
-  self.Screen.MsgBox.SetText("Download Failed")
-  self.Screen.MsgBox.Draw()
-  self.Screen.SwapAndShow()  
+func (self *DownloadProcessPage) DownloadErr() {
+	self.Screen.MsgBox.SetText("Download Failed")
+	self.Screen.MsgBox.Draw()
+	self.Screen.SwapAndShow()
 }
 
 func (self *DownloadProcessPage) DoneAndReturnUpLevel() {
-  self.ReturnToUpLevelPage()
-  self.Screen.Draw()
-  self.Screen.SwapAndShow()
+	self.ReturnToUpLevelPage()
+	self.Screen.Draw()
+	self.Screen.SwapAndShow()
 }
 
+func (self *DownloadProcessPage) StartDownload(_url, dst_dir string) {
+
+	if self.Screen.IsWifiConnectedNow() == false {
+		return
+	}
 
+	_, err := url.ParseRequestURI(_url)
+	if err == nil && IsDirectory(dst_dir) {
+		self.URL = _url
+		self.DST_DIR = dst_dir
+	} else {
 
-func (self *DownloadProcessPage) StartDownload(_url,dst_dir string) {
-  
-  if self.Screen.IsWifiConnectedNow() == false {
-    return
-  }
-  
-  _, err := url.ParseRequestURI(_url)
-  if err == nil && IsDirectory(dst_dir) {
-    self.URL = _url
-    self.DST_DIR = dst_dir
-  }else{
-  
-    self.Screen.MsgBox.SetText("Invaid")
-    self.Screen.MsgBox.Draw()
-    self.Screen.SwapAndShow() 
-    fmt.Println("DownloadProcessPage StartDownload Invalid ",err)
-    return
-  }
-  
-  if self.Doing == false {
-    self.req, _ = grab.NewRequest(self.DST_DIR, _url)
-    fmt.Printf("Downloading %v...\n", self.req.URL())
-    self.resp = self.Downloader.Do(self.req)
-    fmt.Printf("  %v\n", self.resp.HTTPResponse.Status)
-    self.UpdateProcessInterval()
-  }
+		self.Screen.MsgBox.SetText("Invaid")
+		self.Screen.MsgBox.Draw()
+		self.Screen.SwapAndShow()
+		fmt.Println("DownloadProcessPage StartDownload Invalid ", err)
+		return
+	}
+
+	if self.Doing == false {
+		self.req, _ = grab.NewRequest(self.DST_DIR, _url)
+		fmt.Printf("Downloading %v...\n", self.req.URL())
+		self.resp = self.Downloader.Do(self.req)
+		fmt.Printf("  %v\n", self.resp.HTTPResponse.Status)
+		self.UpdateProcessInterval()
+	}
 }
 
 func (self *DownloadProcessPage) StopDownload() {
 
-  self.Doing=false  
+	self.Doing = false
 }
-func (self *DownloadProcessPage) KeyDown( ev *event.Event) {
+func (self *DownloadProcessPage) KeyDown(ev *event.Event) {
+
+	if ev.Data["Key"] == CurKeys["A"] || ev.Data["Key"] == CurKeys["Menu"] {
+		self.StopDownload()
 
- 	if ev.Data["Key"] == CurKeys["A"] || ev.Data["Key"] == CurKeys["Menu"] {
-    self.StopDownload()
-    
 		self.ReturnToUpLevelPage()
 		self.Screen.Draw()
 		self.Screen.SwapAndShow()
-	}  
+	}
 
 }
 
 func (self *DownloadProcessPage) Draw() {
 
-  self.ClearCanvas()
-  
-  if self.Screen.IsWifiConnectedNow() == false {
-    self.Icons["needwifi_bg"].NewCoord(self.Width/2,self.Height/2)
-    self.Icons["needwifi_bg"].Draw()
-    return
-    
-  }
-  
-  self.Icons["bg"].NewCoord(self.Width/2,self.Height/2-20)
-  self.Icons["bg"].Draw()
-  
-  percent := self.Value
-  if percent < 10 {
-    percent = 10
-  }
-  
-  rect_ := draw.MidRect(self.Width/2,self.Height/2+33,170,17, Width,Height)
-  
-  draw.AARoundRect(self.CanvasHWND,rect_,
-                  &color.Color{228,228,228,255},5,0,&color.Color{228,228,228,255})
-  
-  
-  rect2_ := draw.MidRect( self.Width/2,self.Height/2+33,int(170.0*(float64(percent)/100.0)),17, Width,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})
-  
-  w,h := self.FileNameLabel.Size()
-  
-  rect3_ := draw.MidRect(self.Width/2,self.Height/2+53,w, h,Width,Height)
-
-  w, h = self.SizeLabel.Size()
-  
-  rect4_ := draw.MidRect(self.Width/2,self.Height/2+70,w, h,Width,Height)
-  
-  self.FileNameLabel.NewCoord(int(rect3_.X),int(rect3_.Y))
-  self.FileNameLabel.Draw()
-  
-  self.SizeLabel.NewCoord(int(rect4_.X),int(rect4_.Y))
-  self.SizeLabel.Draw()
-  
+	self.ClearCanvas()
+
+	if self.Screen.IsWifiConnectedNow() == false {
+		self.Icons["needwifi_bg"].NewCoord(self.Width/2, self.Height/2)
+		self.Icons["needwifi_bg"].Draw()
+		return
+
+	}
+
+	self.Icons["bg"].NewCoord(self.Width/2, self.Height/2-20)
+	self.Icons["bg"].Draw()
+
+	percent := self.Value
+	if percent < 10 {
+		percent = 10
+	}
+
+	rect_ := draw.MidRect(self.Width/2, self.Height/2+33, 170, 17, Width, Height)
+
+	draw.AARoundRect(self.CanvasHWND, rect_,
+		&color.Color{228, 228, 228, 255}, 5, 0, &color.Color{228, 228, 228, 255})
+
+	rect2_ := draw.MidRect(self.Width/2, self.Height/2+33, int(170.0*(float64(percent)/100.0)), 17, Width, 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})
+
+	w, h := self.FileNameLabel.Size()
+
+	rect3_ := draw.MidRect(self.Width/2, self.Height/2+53, w, h, Width, Height)
+
+	w, h = self.SizeLabel.Size()
+
+	rect4_ := draw.MidRect(self.Width/2, self.Height/2+70, w, h, Width, Height)
+
+	self.FileNameLabel.NewCoord(int(rect3_.X), int(rect3_.Y))
+	self.FileNameLabel.Draw()
+
+	self.SizeLabel.NewCoord(int(rect4_.X), int(rect4_.Y))
+	self.SizeLabel.Draw()
+
 }

+ 5 - 6
sysgo/UI/events.go

@@ -1,10 +1,9 @@
 package UI
 
-
 const (
-    RUNEVT=1
-    RESTARTUI=2
-    RUNSH=3
-    RUNSYS=4
-    POWEROPT=5
+	RUNEVT    = 1
+	RESTARTUI = 2
+	RUNSH     = 3
+	RUNSYS    = 4
+	POWEROPT  = 5
 )

+ 32 - 33
sysgo/UI/folder_stack.go

@@ -1,46 +1,45 @@
 package UI
 
 import (
-  "sync"
-
+	"sync"
 )
 
 type FolderStack struct {
-    lock *sync.Mutex
-    head *element
-    Size int
-    RootPath string
+	lock     *sync.Mutex
+	head     *element
+	Size     int
+	RootPath string
 }
 
 func (stk *FolderStack) Push(data interface{}) {
-    stk.lock.Lock()
+	stk.lock.Lock()
 
-    element := new(element)
-    element.data = data
-    temp := stk.head
-    element.next = temp
-    stk.head = element
-    stk.Size++
+	element := new(element)
+	element.data = data
+	temp := stk.head
+	element.next = temp
+	stk.head = element
+	stk.Size++
 
-    stk.lock.Unlock()
+	stk.lock.Unlock()
 }
 
 func (stk *FolderStack) Pop() interface{} {
-    if stk.head == nil {
-        return nil
-    }
-    stk.lock.Lock()
-    r := stk.head.data
-    stk.head = stk.head.next
-    stk.Size--
+	if stk.head == nil {
+		return nil
+	}
+	stk.lock.Lock()
+	r := stk.head.data
+	stk.head = stk.head.next
+	stk.Size--
 
-    stk.lock.Unlock()
+	stk.lock.Unlock()
 
-    return r
+	return r
 }
 
 func (stk *FolderStack) SetRootPath(path string) {
-  stk.RootPath = path
+	stk.RootPath = path
 }
 
 func (stk *FolderStack) Length() int {
@@ -48,16 +47,16 @@ func (stk *FolderStack) Length() int {
 }
 
 func (stk *FolderStack) Last() string {
-  idx := stk.Length() -1
-  if idx < 0 {
-    return stk.RootPath
-  }else {
-    return stk.head.data.(string)
-  }
+	idx := stk.Length() - 1
+	if idx < 0 {
+		return stk.RootPath
+	} else {
+		return stk.head.data.(string)
+	}
 }
 
 func NewFolderStack() *FolderStack {
-    stk := new(FolderStack)
-    stk.lock = &sync.Mutex{}
-    return stk
+	stk := new(FolderStack)
+	stk.lock = &sync.Mutex{}
+	return stk
 }

+ 4 - 5
sysgo/UI/fonts.go

@@ -1,8 +1,7 @@
 package UI
-import(
-    "github.com/veandco/go-sdl2/ttf"
-)
-var Fonts map[string]*ttf.Font
-
 
+import (
+	"github.com/veandco/go-sdl2/ttf"
+)
 
+var Fonts map[string]*ttf.Font

+ 76 - 81
sysgo/UI/foot_bar.go

@@ -2,24 +2,23 @@ package UI
 
 import (
 	"fmt"
-//	"io/ioutil"
+	//	"io/ioutil"
 	"log"
-	
+
 	"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/draw"
-	"github.com/cuu/gogame/image"
 	"github.com/cuu/gogame/font"
-	
+	"github.com/cuu/gogame/image"
+	"github.com/cuu/gogame/rect"
+	"github.com/cuu/gogame/surface"
 )
 
 var FootBar_BarHeight = 20
 
 type FootBarIconItem struct {
-	MultiIconItem 
+	MultiIconItem
 	Parent *FootBar
 }
 
@@ -29,11 +28,11 @@ func NewFootBarIconItem() *FootBarIconItem {
 	m.IconWidth = 18
 	m.IconHeight = 18
 	m.Align = ALIGN["VCenter"]
-	
+
 	return m
 }
 
-func (self *FootBarIconItem) Adjust(x,y,w,h,at int) {
+func (self *FootBarIconItem) Adjust(x, y, w, h, at int) {
 	self.PosX = x
 	self.PosY = y
 	self.Width = w
@@ -45,54 +44,52 @@ func (self *FootBarIconItem) Adjust(x,y,w,h,at int) {
 	}
 
 	self.CreateImgSurf()
-//	self.AdjustLinkPage()
-	
+	//	self.AdjustLinkPage()
+
 }
 
 func (self *FootBarIconItem) TotalWidth() int {
-	lab_w,_ := self.Label.Size()
+	lab_w, _ := self.Label.Size()
 	return self.Width + lab_w
 }
 
 func (self *FootBarIconItem) Draw() {
-	
+
 	if self.Label != nil {
-		lab_w,lab_h:= self.Label.Size()
+		lab_w, lab_h := self.Label.Size()
 		if self.Align == ALIGN["VCenter"] {
-			self.Label.NewCoord( self.PosX - lab_w/2, self.PosY+ self.Height/2+12)
+			self.Label.NewCoord(self.PosX-lab_w/2, self.PosY+self.Height/2+12)
 		} else if self.Align == ALIGN["HLeft"] {
-			self.Label.NewCoord( self.PosX + self.Width/2+3, self.PosY - lab_h/2)
+			self.Label.NewCoord(self.PosX+self.Width/2+3, self.PosY-lab_h/2)
 		}
 		self.Label.Draw()
 	}
 
 	if self.ImgSurf != nil {
 		portion := rect.Rect(0, self.IconIndex*self.IconHeight, self.IconWidth, self.IconHeight)
-		surface.Blit(self.Parent.CanvasHWND, self.ImgSurf, draw.MidRect(self.PosX,self.PosY, self.Width,self.Height, Width,Height),&portion)
-	}else {
+		surface.Blit(self.Parent.CanvasHWND, self.ImgSurf, draw.MidRect(self.PosX, self.PosY, self.Width, self.Height, Width, Height), &portion)
+	} else {
 		fmt.Println("self.ImgSurf is nil ")
 	}
-	
+
 }
 
 type FootBar struct {
-  Widget
-	BarHeight int
+	Widget
+	BarHeight   int
 	BorderWidth int
-	CanvasHWND *sdl.Surface
-	HWND       *sdl.Surface
-	Icons   map[string]IconItemInterface
-	IconWidth int
-	IconHeight int
-	LabelFont *ttf.Font
-	State   string
+	CanvasHWND  *sdl.Surface
+	HWND        *sdl.Surface
+	Icons       map[string]IconItemInterface
+	IconWidth   int
+	IconHeight  int
+	LabelFont   *ttf.Font
+	State       string
 	SkinManager *SkinManager
-	
+
 	icon_base_path string
-	
 }
 
-
 func NewFootBar() *FootBar {
 	f := &FootBar{}
 	f.Width = Width
@@ -103,63 +100,62 @@ func NewFootBar() *FootBar {
 
 	f.IconWidth = 18
 	f.IconHeight = 18
-	
+
 	f.LabelFont = Fonts["veramono10"]
 	f.State = "normal"
 	f.icon_base_path = SkinMap("sysgo/gameshell/footbar_icons/")
 
 	f.Icons = make(map[string]IconItemInterface)
-	
+
 	return f
 }
 
-func (self *FootBar) ReadFootBarIcons( icondir string) {
+func (self *FootBar) ReadFootBarIcons(icondir string) {
 	if FileExists(icondir) == false && IsDirectory(icondir) == false {
 		return
 	}
-	keynames := [5]string{"nav","x","y","a","b"}
+	keynames := [5]string{"nav", "x", "y", "a", "b"}
 
-	share_surf := image.Load(self.icon_base_path+"footbar.png")
+	share_surf := image.Load(self.icon_base_path + "footbar.png")
 
-	for i,v := range keynames { // share_surf contains same number of image pieces of keynames
+	for i, v := range keynames { // share_surf contains same number of image pieces of keynames
 		it := NewFootBarIconItem()
 		it.MyType = ICON_TYPES["NAV"]
 		it.Parent = self
 		it.ImgSurf = share_surf
 		it.Align = ALIGN["HLeft"] // (X)Text
 		it.IconWidth = self.IconWidth
-		it.IconHeight =self.IconHeight
+		it.IconHeight = self.IconHeight
 		it.AddLabel("game", self.LabelFont)
-		it.Adjust( self.IconWidth/2+i*self.IconWidth, self.IconHeight/2+2, self.IconWidth,self.IconHeight,0)
+		it.Adjust(self.IconWidth/2+i*self.IconWidth, self.IconHeight/2+2, self.IconWidth, self.IconHeight, 0)
 		it.IconIndex = i
-    if val, ok := self.Icons[v]; ok {
-      if val.(*FootBarIconItem).ImgSurf != nil {
-          val.(*FootBarIconItem).ImgSurf.Free()
-      }
-    }
+		if val, ok := self.Icons[v]; ok {
+			if val.(*FootBarIconItem).ImgSurf != nil {
+				val.(*FootBarIconItem).ImgSurf.Free()
+			}
+		}
 		self.Icons[v] = it
 	}
 }
 
-
 func (self *FootBar) Init(main_screen *MainScreen) {
-	self.CanvasHWND = surface.Surface(self.Width,self.Height)
+	self.CanvasHWND = surface.Surface(self.Width, self.Height)
 	self.HWND = main_screen.HWND
 	self.SkinManager = main_screen.SkinManager
 
 	self.ReadFootBarIcons(self.icon_base_path)
-	
+
 	round_corners := NewFootBarIconItem()
 	round_corners.IconWidth = 10
 	round_corners.IconHeight = 10
-	
+
 	round_corners.MyType = ICON_TYPES["STAT"]
 	round_corners.Parent = self
 	round_corners.ImgSurf = MyIconPool.GetImgSurf("roundcorners")
-	round_corners.Adjust(0,0,10,10,0)
-	
+	round_corners.Adjust(0, 0, 10, 10, 0)
+
 	self.Icons["round_corners"] = round_corners
-	
+
 }
 
 func (self *FootBar) ResetNavText() {
@@ -170,88 +166,87 @@ func (self *FootBar) ResetNavText() {
 
 func (self *FootBar) UpdateNavText(texts string) {
 	self.State = "tips"
-	
-//	my_text := font.Render(self.LabelFont, texts, true,self.SkinManager.GiveColor("Text"),nil)
+
+	//	my_text := font.Render(self.LabelFont, texts, true,self.SkinManager.GiveColor("Text"),nil)
 
 	left_width := self.Width - 18
 
 	final_piece := ""
 
-	for i,_ := range texts {
+	for i, _ := range texts {
 		text_ := texts[:i+1]
-		my_text := font.Render(self.LabelFont, text_, true, self.SkinManager.GiveColor("Text"),nil)
-		final_piece  = text_
+		my_text := font.Render(self.LabelFont, text_, true, self.SkinManager.GiveColor("Text"), nil)
+		final_piece = text_
 		if int(my_text.W) >= left_width {
-      my_text.Free()
+			my_text.Free()
 			break
 		}
-    my_text.Free()
+		my_text.Free()
 	}
-	
+
 	fmt.Printf("finalpiece %s\n", final_piece)
 
 	self.Icons["nav"].SetLabelText(final_piece)
 	self.Draw()
-	
+
 }
 
-func (self *FootBar) SetLabelTexts( texts [5]string) {
-	keynames := [5]string{"nav","x","y","a","b"}
+func (self *FootBar) SetLabelTexts(texts [5]string) {
+	keynames := [5]string{"nav", "x", "y", "a", "b"}
 	if len(texts) < 5 {
 		log.Fatal("SetLabelTexts texts length error")
 		return
 	}
 
-	for idx,x := range keynames {
+	for idx, x := range keynames {
 		self.Icons[x].SetLabelText(texts[idx])
 	}
-	
+
 }
 
 func (self *FootBar) ClearCanvas() {
-	surface.Fill( self.CanvasHWND,  self.SkinManager.GiveColor("White"))
+	surface.Fill(self.CanvasHWND, self.SkinManager.GiveColor("White"))
 
-	self.Icons["round_corners"].NewCoord(5,self.Height-5)
+	self.Icons["round_corners"].NewCoord(5, self.Height-5)
 	self.Icons["round_corners"].SetIconIndex(2)
 	self.Icons["round_corners"].Draw()
 
-
-	self.Icons["round_corners"].NewCoord(self.Width - 5,self.Height - 5)
+	self.Icons["round_corners"].NewCoord(self.Width-5, self.Height-5)
 	self.Icons["round_corners"].SetIconIndex(3)
 
 	self.Icons["round_corners"].Draw()
-	
+
 }
 
 func (self *FootBar) Draw() {
 	self.ClearCanvas()
-	
+
 	self.Icons["nav"].NewCoord(self.IconWidth/2+3, self.IconHeight/2+2)
 	self.Icons["nav"].Draw()
 
 	if self.State == "normal" {
 		_w := 0
 
-		for i,x := range []string{"b","a","y","x"} {
+		for i, x := range []string{"b", "a", "y", "x"} {
 			if self.Icons[x].GetLabelText() != "" {
-				if i== 0 {
+				if i == 0 {
 					_w += self.Icons[x].TotalWidth()
-				}else {
-					_w += self.Icons[x].TotalWidth()+5
+				} else {
+					_w += self.Icons[x].TotalWidth() + 5
 				}
 
 				start_x := self.Width - _w
-				start_y := self.IconHeight/2+2
+				start_y := self.IconHeight/2 + 2
 				self.Icons[x].NewCoord(start_x, start_y)
 				self.Icons[x].Draw()
 			}
 		}
 	}
-	
-	draw.Line(self.CanvasHWND, self.SkinManager.GiveColor("Line"),0,0,Width,0,self.BorderWidth)
-	
+
+	draw.Line(self.CanvasHWND, self.SkinManager.GiveColor("Line"), 0, 0, Width, 0, self.BorderWidth)
+
 	if self.HWND != nil {
-		rect_ := rect.Rect(self.PosX, Height - self.Height, Width, self.BarHeight)
-		surface.Blit(self.HWND,self.CanvasHWND, &rect_,nil)
+		rect_ := rect.Rect(self.PosX, Height-self.Height, Width, self.BarHeight)
+		surface.Blit(self.HWND, self.CanvasHWND, &rect_, nil)
 	}
 }

+ 16 - 20
sysgo/UI/fullscreen.go

@@ -1,40 +1,36 @@
 package UI
 
 import (
+	"github.com/cuu/gogame/surface"
+	"github.com/veandco/go-sdl2/sdl"
 
-  "github.com/veandco/go-sdl2/sdl"
-  "github.com/cuu/gogame/surface"
-
-  "github.com/cuu/gogame/rect"
-
+	"github.com/cuu/gogame/rect"
 )
 
 type FullScreen struct {
-  Widget
-  CanvasHWND *sdl.Surface
-  HWND       *sdl.Surface
-  
+	Widget
+	CanvasHWND *sdl.Surface
+	HWND       *sdl.Surface
 }
 
 func NewFullScreen() *FullScreen {
-  p := &FullScreen{}
-  p.Width = Width
-  p.Height = Height
-  
-  return p
+	p := &FullScreen{}
+	p.Width = Width
+	p.Height = Height
+
+	return p
 
 }
 
 func (self *FullScreen) SwapAndShow() {
-  if self.HWND !=nil {
-    rect_ := rect.Rect(self.PosX,self.PosY,self.Width,self.Height)
-    surface.Blit(self.HWND,self.CanvasHWND,&rect_,nil)
-    SwapAndShow()
-  }
+	if self.HWND != nil {
+		rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
+		surface.Blit(self.HWND, self.CanvasHWND, &rect_, nil)
+		SwapAndShow()
+	}
 
 }
 
 func (self *FullScreen) Draw() {
 
-
 }

+ 120 - 125
sysgo/UI/hier_list_item.go

@@ -1,161 +1,156 @@
 package UI
 
-import(
-  "fmt"
-  "path/filepath"
-  "strings"
-  "io/ioutil"
-  
-  "github.com/veandco/go-sdl2/ttf"
-  
-  "github.com/cuu/gogame/rect"
-
-  "github.com/cuu/gogame/surface"
-	"github.com/cuu/gogame/draw"
-	"github.com/cuu/gogame/color"
+import (
+	"fmt"
+	"io/ioutil"
+	"path/filepath"
+	"strings"
+
+	"github.com/veandco/go-sdl2/ttf"
+
+	"github.com/cuu/gogame/rect"
 
+	"github.com/cuu/gogame/color"
+	"github.com/cuu/gogame/draw"
+	"github.com/cuu/gogame/surface"
 )
 
 type ListItemIcon struct {
-  IconItem
-
+	IconItem
 }
 
 func NewListItemIcon() *ListItemIcon {
-  p := &ListItemIcon{}
-  p.MyType = ICON_TYPES["EXE"]
+	p := &ListItemIcon{}
+	p.MyType = ICON_TYPES["EXE"]
 
 	p.Align = ALIGN["VCenter"]
-  
-  p.Width = 18
-  p.Height = 18
-  
-  return p
+
+	p.Width = 18
+	p.Height = 18
+
+	return p
 }
 
 func (self *ListItemIcon) Draw() {
-  _,h := self.Parent.Size()
-  
-  rect_ := rect.Rect(self.PosX,self.PosY+(h-self.Height)/2,self.Width,self.Height)
-  
-  surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf,&rect_,nil)
+	_, h := self.Parent.Size()
+
+	rect_ := rect.Rect(self.PosX, self.PosY+(h-self.Height)/2, self.Width, self.Height)
+
+	surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf, &rect_, nil)
 }
 
-/// [..] [.] 
+/// [..] [.]
 type HierListItem struct {
-  ListItem
-  MyType int
-  Path  string
-  Active bool
-  Playing bool
+	ListItem
+	MyType  int
+	Path    string
+	Active  bool
+	Playing bool
 }
 
 var HierListItemDefaultHeight = 32
 
 func NewHierListItem() *HierListItem {
-  p := &HierListItem{}
-  p.Labels = make(map[string]LabelInterface)
-	p.Icons  = make( map[string]IconItemInterface)
-	p.Fonts  = make(map[string]*ttf.Font)
-  
-  p.MyType = ICON_TYPES["EXE"]
+	p := &HierListItem{}
+	p.Labels = make(map[string]LabelInterface)
+	p.Icons = make(map[string]IconItemInterface)
+	p.Fonts = make(map[string]*ttf.Font)
+
+	p.MyType = ICON_TYPES["EXE"]
 	p.Height = HierListItemDefaultHeight
-	p.Width  = 0
-  
-  return p
+	p.Width = 0
+
+	return p
 }
 
 func (self *HierListItem) IsFile() bool {
-  if self.MyType == ICON_TYPES["FILE"] {
-    return true
-  }
-  
-  return false
-}
+	if self.MyType == ICON_TYPES["FILE"] {
+		return true
+	}
 
+	return false
+}
 
 func (self *HierListItem) IsDir() bool {
-  if self.MyType == ICON_TYPES["DIR"] {
-    return true
-  }
-  
-  return false
-}
+	if self.MyType == ICON_TYPES["DIR"] {
+		return true
+	}
 
+	return false
+}
 
 func (self *HierListItem) Init(text string) {
-  l := NewLabel()
-  l.PosX = 20
-  if self.Parent == nil {
-    fmt.Println("Parent nil")
-    return
-  }
-  l.SetCanvasHWND(self.Parent.GetCanvasHWND())
-  
-  if self.IsDir() == true || self.IsFile() == true {
-    self.Path = text
-  }
-  
-  label_text := filepath.Base(text)
-  ext:= filepath.Ext(text)
-  if ext != "" {
-    alias_file := strings.Replace(text,ext,"",-1) + ".alias"
-    
-    if FileExists(alias_file) == true {
-      b, err := ioutil.ReadFile(alias_file) 
-      if err != nil {
-        fmt.Print(err)
-      }else {
-        label_text = string(b)
-      }
-    }
-    
-  }
-  
-  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 := NewLabel()
+	l.PosX = 20
+	if self.Parent == nil {
+		fmt.Println("Parent nil")
+		return
+	}
+	l.SetCanvasHWND(self.Parent.GetCanvasHWND())
+
+	if self.IsDir() == true || self.IsFile() == true {
+		self.Path = text
+	}
+
+	label_text := filepath.Base(text)
+	ext := filepath.Ext(text)
+	if ext != "" {
+		alias_file := strings.Replace(text, ext, "", -1) + ".alias"
+
+		if FileExists(alias_file) == true {
+			b, err := ioutil.ReadFile(alias_file)
+			if err != nil {
+				fmt.Print(err)
+			} else {
+				label_text = string(b)
+			}
+		}
+
+	}
+
+	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 *HierListItem) 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()
-  
-  
-  /*
-  w,h := self.Parent.Icons["sys"].Size()
-  
-  if self.IsDir() == true && self.Path != "[..]" {
-    self.Parent.Icons["sys"].IconIndex = 0
-    self.Parent.Icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
-    self.Parent.Icons["sys"].Draw()
-  }
-  
-  if self.IsFile() == true {
-    self.Parent.Icons["sys"].IconIndex = 1
-    self.Parent.Icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
-    self.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()
+
+	/*
+	  w,h := self.Parent.Icons["sys"].Size()
+
+	  if self.IsDir() == true && self.Path != "[..]" {
+	    self.Parent.Icons["sys"].IconIndex = 0
+	    self.Parent.Icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
+	    self.Parent.Icons["sys"].Draw()
+	  }
+
+	  if self.IsFile() == true {
+	    self.Parent.Icons["sys"].IconIndex = 1
+	    self.Parent.Icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
+	    self.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)
+
 }

+ 93 - 101
sysgo/UI/icon_item.go

@@ -2,48 +2,47 @@ package UI
 
 import (
 	"fmt"
-	
+
 	"github.com/veandco/go-sdl2/sdl"
 	"github.com/veandco/go-sdl2/ttf"
 
-	"github.com/cuu/gogame/surface"
-	"github.com/cuu/gogame/draw"
 	"github.com/cuu/gogame/color"
+	"github.com/cuu/gogame/draw"
 	"github.com/cuu/gogame/image"
+	"github.com/cuu/gogame/rect"
+	"github.com/cuu/gogame/surface"
 	"github.com/cuu/gogame/transform"
 	"github.com/cuu/gogame/utils"
-  "github.com/cuu/gogame/rect"
-
 )
 
 type IconItemInterface interface {
-	Init(x,y,w,h,at int)
-	Adjust(x,y,w,h,at int)
+	Init(x, y, w, h, at int)
+	Adjust(x, y, w, h, at int)
 	GetCmdPath() string
-	SetCmdPath( path string)
-	
-	SetMyType( thetype int )
+	SetCmdPath(path string)
+
+	SetMyType(thetype int)
 	GetMyType() int
 
 	GetIconIndex() int
 	SetIconIndex(idx int)
-	
+
 	GetIndex() int
 	SetIndex(i int)
-	
-	SetParent( p interface{} )
-	
+
+	SetParent(p interface{})
+
 	SetLabelColor(col *color.Color)
 	SetLabelText(text string)
 	GetLabelText() string
-	
-	Coord() (int,int)
-	NewCoord(x,y int)
-	Size() (int,int)
-	NewSize(w,h int)
+
+	Coord() (int, int)
+	NewCoord(x, y int)
+	Size() (int, int)
+	NewSize(w, h int)
 
 	TotalWidth() int
-	
+
 	AddLabel(text string, fontobj *ttf.Font)
 	GetLinkPage() PageInterface
 	AdjustLinkPage()
@@ -51,46 +50,43 @@ type IconItemInterface interface {
 	SetImgSurf(newsurf *sdl.Surface)
 	CreateImgSurf()
 	ChangeImgSurfColor(col *color.Color)
-	
+
 	Clear()
 
 	GetCmdInvoke() PluginInterface
 
 	GetFileName() string
 	Draw()
-  DrawTopLeft() 
-  
+	DrawTopLeft()
 }
 
 type IconItem struct {
 	Widget
-	ImageName string
-	ImgSurf *sdl.Surface
-	Parent  PageInterface
-	Index   int
-	IconIndex int
-	MyType int
-	CmdPath  string
-	CmdInvoke PluginInterface
-	LinkPage PageInterface
-	Label  LabelInterface
-	Align  int
+	ImageName     string
+	ImgSurf       *sdl.Surface
+	Parent        PageInterface
+	Index         int
+	IconIndex     int
+	MyType        int
+	CmdPath       string
+	CmdInvoke     PluginInterface
+	LinkPage      PageInterface
+	Label         LabelInterface
+	Align         int
 	AnimationTime int
-  FileName string
+	FileName      string
 }
 
-
 func NewIconItem() *IconItem {
 	i := &IconItem{}
 	i.MyType = ICON_TYPES["EXE"]
 
 	i.Align = ALIGN["VCenter"]
-		
+
 	return i
 }
 
-
-func (self *IconItem) Init(x,y,w,h,at int) {
+func (self *IconItem) Init(x, y, w, h, at int) {
 	self.PosX = x
 	self.PosY = y
 	self.Width = w
@@ -98,7 +94,7 @@ func (self *IconItem) Init(x,y,w,h,at int) {
 	self.AnimationTime = at
 }
 
-func (self *IconItem) Adjust(x,y,w,h,at int) {
+func (self *IconItem) Adjust(x, y, w, h, at int) {
 	self.PosX = x
 	self.PosY = y
 	self.Width = w
@@ -111,19 +107,18 @@ func (self *IconItem) Adjust(x,y,w,h,at int) {
 
 	self.CreateImgSurf()
 	self.AdjustLinkPage()
-	
-}
 
+}
 
 func (self *IconItem) GetCmdPath() string {
 	return self.CmdPath
 }
 
-func (self *IconItem) SetCmdPath( path string) {
+func (self *IconItem) SetCmdPath(path string) {
 	self.CmdPath = path
 }
 
-func (self *IconItem) SetMyType( thetype int ) {
+func (self *IconItem) SetMyType(thetype int) {
 	self.MyType = thetype
 }
 
@@ -135,7 +130,7 @@ func (self *IconItem) GetIconIndex() int {
 	return self.IconIndex
 }
 
-func (self *IconItem) SetIconIndex( idx int) {
+func (self *IconItem) SetIconIndex(idx int) {
 	self.IconIndex = idx
 }
 
@@ -147,7 +142,7 @@ func (self *IconItem) SetIndex(i int) {
 	self.Index = i
 }
 
-func (self *IconItem) SetParent(p interface{} ) {
+func (self *IconItem) SetParent(p interface{}) {
 	self.Parent = p.(PageInterface)
 }
 
@@ -163,11 +158,11 @@ func (self *IconItem) SetLabelText(text string) {
 	self.Label.SetText(text)
 }
 
-func (self *IconItem) Coord() (int,int) {
-	return self.PosX,self.PosY
+func (self *IconItem) Coord() (int, int) {
+	return self.PosX, self.PosY
 }
 
-func (self *IconItem) NewCoord(x,y int) {
+func (self *IconItem) NewCoord(x, y int) {
 	self.PosX = x
 	self.PosY = y
 }
@@ -176,18 +171,18 @@ func (self *IconItem) TotalWidth() int {
 	return 0
 }
 
-func (self *IconItem) Size() (int,int) {
-	return self.Width,self.Height
+func (self *IconItem) Size() (int, int) {
+	return self.Width, self.Height
 }
 
 func (self *IconItem) AddLabel(text string, fontobj *ttf.Font) {
 	if self.Label == nil {
-		l:= NewLabel()
+		l := NewLabel()
 		self.Label = l
 	}
-	
-	self.Label.Init(text,fontobj,nil)
-	
+
+	self.Label.Init(text, fontobj, nil)
+
 }
 
 func (self *IconItem) GetLinkPage() PageInterface {
@@ -200,21 +195,20 @@ func (self *IconItem) AdjustLinkPage() {
 		self.LinkPage.SetAlign(ALIGN["SLeft"])
 		self.LinkPage.UpdateIconNumbers()
 		self.LinkPage.SetScreen(self.Parent.GetScreen())
-		self.LinkPage.SetCanvasHWND( (self.Parent.GetScreen()).CanvasHWND )
-		self.LinkPage.SetFootMsg([5]string{ "Nav.","","","Back","Enter" } )
+		self.LinkPage.SetCanvasHWND((self.Parent.GetScreen()).CanvasHWND)
+		self.LinkPage.SetFootMsg([5]string{"Nav.", "", "", "Back", "Enter"})
 		if self.LinkPage.GetAlign() == ALIGN["HLeft"] {
 			self.LinkPage.AdjustHLeftAlign()
-		}else if self.LinkPage.GetAlign() == ALIGN["SLeft"] {
+		} else if self.LinkPage.GetAlign() == ALIGN["SLeft"] {
 			self.LinkPage.AdjustSAutoLeftAlign()
 			if self.LinkPage.GetIconNumbers() > 1 {
 				self.LinkPage.SetPsIndex(1)
-				self.LinkPage.SetIconIndex ( 1 ) 
+				self.LinkPage.SetIconIndex(1)
 			}
 		}
 	}
 }
 
-
 func (self *IconItem) GetImgSurf() *sdl.Surface {
 	return self.ImgSurf
 }
@@ -223,22 +217,21 @@ func (self *IconItem) SetImgSurf(newsurf *sdl.Surface) {
 	self.ImgSurf = newsurf
 }
 
-
 func (self *IconItem) CreateImgSurf() {
 	if self.ImgSurf == nil && self.ImageName != "" {
 		self.ImgSurf = image.Load(self.ImageName)
-		if int(self.ImgSurf.W)  > IconWidth  || int(self.ImgSurf.H) > IconHeight {
-			self.ImgSurf = transform.Scale(self.ImgSurf,IconWidth,IconHeight)
+		if int(self.ImgSurf.W) > IconWidth || int(self.ImgSurf.H) > IconHeight {
+			self.ImgSurf = transform.Scale(self.ImgSurf, IconWidth, IconHeight)
 		}
 	}
 }
 
 func (self *IconItem) ChangeImgSurfColor(col *color.Color) {
-	utils.ColorSurface(self.ImgSurf,col)
+	utils.ColorSurface(self.ImgSurf, col)
 }
 
 func (self *IconItem) Clear() {
-	
+
 }
 
 func (self *IconItem) GetCmdInvoke() PluginInterface {
@@ -246,65 +239,64 @@ func (self *IconItem) GetCmdInvoke() PluginInterface {
 }
 
 func (self *IconItem) GetFileName() string {
-  return self.FileName
+	return self.FileName
 }
 
 func (self *IconItem) DrawTopLeft() {
-  if self.Parent == nil {
-    fmt.Println("Error: IconItem Draw Parent nil")
-    return
-  }
-	parent_x,parent_y := self.Parent.Coord()
-	
+	if self.Parent == nil {
+		fmt.Println("Error: IconItem 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 == 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 == 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 == 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 {
-    rect_ := rect.Rect( self.PosX+parent_x,self.PosY+parent_y, self.Width,self.Height ) // DIFF
-		surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf,&rect_,nil)
+		rect_ := rect.Rect(self.PosX+parent_x, self.PosY+parent_y, self.Width, self.Height) // DIFF
+		surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf, &rect_, nil)
 	}
 
 }
 
 func (self *IconItem) Draw() {
-  if self.Parent == nil {
-    fmt.Println("Error: IconItem Draw Parent nil")
-    return
-  }
-	parent_x,parent_y := self.Parent.Coord()
-	
+	if self.Parent == nil {
+		fmt.Println("Error: IconItem 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 == 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 == 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 == 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, Width, Height),nil)
+		surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf, draw.MidRect(self.PosX+parent_x, self.PosY+parent_y,
+			self.Width, self.Height, Width, Height), nil)
 	}
 }
-

+ 13 - 15
sysgo/UI/icon_pool.go

@@ -5,41 +5,39 @@ import (
 	"io/ioutil"
 	"log"
 	"strings"
-	
+
 	"github.com/veandco/go-sdl2/sdl"
-	
+
 	"github.com/cuu/gogame/image"
-	
 )
 
 type IconPool struct {
-	GameShellIconPath  string
-	Icons map[string]*sdl.Surface	
+	GameShellIconPath string
+	Icons             map[string]*sdl.Surface
 }
 
 func NewIconPool() *IconPool {
 	i := &IconPool{}
 	i.GameShellIconPath = SkinMap("sysgo/gameshell/icons/")
-	i.Icons = make( map[string]*sdl.Surface )
+	i.Icons = make(map[string]*sdl.Surface)
 	return i
 }
 
-
 func (self *IconPool) Init() {
-	files,err := ioutil.ReadDir(self.GameShellIconPath)
+	files, err := ioutil.ReadDir(self.GameShellIconPath)
 	if err != nil {
 		log.Fatal(err)
 		return
 	}
 
-	for _,f := range files {
+	for _, f := range files {
 		if f.IsDir() {
 			//pass
-		}else {
-			if strings.HasSuffix(f.Name(),".png") == true {
-				keyname := strings.Split(f.Name(),".")
+		} else {
+			if strings.HasSuffix(f.Name(), ".png") == true {
+				keyname := strings.Split(f.Name(), ".")
 				if len(keyname) > 1 {
-					self.Icons[ keyname[0] ] = image.Load( self.GameShellIconPath+ "/"+f.Name() )
+					self.Icons[keyname[0]] = image.Load(self.GameShellIconPath + "/" + f.Name())
 				}
 			}
 		}
@@ -47,7 +45,7 @@ func (self *IconPool) Init() {
 }
 
 func (self *IconPool) GetImgSurf(keyname string) *sdl.Surface {
-	if _,ok := self.Icons[keyname]; ok {
+	if _, ok := self.Icons[keyname]; ok {
 		return self.Icons[keyname]
 	} else {
 		fmt.Println("IconPool GetImgSurf ", keyname, "  failed")
@@ -56,5 +54,5 @@ func (self *IconPool) GetImgSurf(keyname string) *sdl.Surface {
 }
 
 var MyIconPool *IconPool
-// = NewIconPool()
 
+// = NewIconPool()

+ 42 - 43
sysgo/UI/info_page_list_item.go

@@ -2,73 +2,72 @@ package UI
 
 import (
 	"github.com/veandco/go-sdl2/ttf"
-	
-	"github.com/cuu/gogame/draw"
+
 	"github.com/cuu/gogame/color"
-	
+	"github.com/cuu/gogame/draw"
 )
+
 var DefaultInfoPageListItemHeight = 30
 
 type InfoPageListItem struct {
-  ListItem
-  Flag string 
-  ReadOnly bool
+	ListItem
+	Flag     string
+	ReadOnly bool
 }
 
 func NewInfoPageListItem() *InfoPageListItem {
-  p := &InfoPageListItem{}
-  p.Height = DefaultInfoPageListItemHeight
-  p.ReadOnly = false
+	p := &InfoPageListItem{}
+	p.Height = DefaultInfoPageListItemHeight
+	p.ReadOnly = false
 	p.Labels = make(map[string]LabelInterface)
-	p.Icons  = make( map[string]IconItemInterface)
-	p.Fonts  = make(map[string]*ttf.Font)
-  
-  return p
+	p.Icons = make(map[string]IconItemInterface)
+	p.Fonts = make(map[string]*ttf.Font)
+
+	return p
 }
 
 func (self *InfoPageListItem) SetSmallText(text string) {
 	l := NewLabel()
 	l.PosX = 40
 	l.SetCanvasHWND(self.Parent.GetCanvasHWND())
-	l.Init(text,self.Fonts["small"],nil)
+	l.Init(text, self.Fonts["small"], nil)
 	self.Labels["Small"] = l
 }
 
-func (self *InfoPageListItem) Init(text string ) {
+func (self *InfoPageListItem) Init(text string) {
 	l := 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) Draw() {
-  if self.ReadOnly == true {
-    self.Labels["Text"].SetColor(&color.Color{130,130,130,255}  ) //SkinManager().GiveColor("ReadOnlyText")
-  }else {
-    self.Labels["Text"].SetColor(&color.Color{83,83,83,255} ) // SkinManager().GiveColor("Text")
-  }
-  
-  x,_ := self.Labels["Text"].Coord()
-  w,h := self.Labels["Text"].Size()
-  
-  self.Labels["Text"].NewCoord( x + self.PosX, self.PosY + (self.Height - h)/2 )
-  
-  self.Labels["Text"].Draw()
-  
-  self.Labels["Text"].NewCoord(x, self.PosY + (self.Height - h)/2 )
-  
-  if _, ok := self.Labels["Small"]; ok {
-    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 )
-    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)
+	if self.ReadOnly == true {
+		self.Labels["Text"].SetColor(&color.Color{130, 130, 130, 255}) //SkinManager().GiveColor("ReadOnlyText")
+	} else {
+		self.Labels["Text"].SetColor(&color.Color{83, 83, 83, 255}) // SkinManager().GiveColor("Text")
+	}
 
-}
+	x, _ := self.Labels["Text"].Coord()
+	w, h := self.Labels["Text"].Size()
+
+	self.Labels["Text"].NewCoord(x+self.PosX, self.PosY+(self.Height-h)/2)
 
+	self.Labels["Text"].Draw()
+
+	self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2)
+
+	if _, ok := self.Labels["Small"]; ok {
+		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)
+		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)
+
+}

+ 30 - 34
sysgo/UI/info_page_selector.go

@@ -1,53 +1,49 @@
 package UI
 
 import (
-  //"fmt"
-//	"github.com/veandco/go-sdl2/ttf"
+	//"fmt"
+	//	"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/surface"
+	//	"github.com/cuu/gogame/event"
 	"github.com/cuu/gogame/color"
 	"github.com/cuu/gogame/draw"
-	
+	"github.com/cuu/gogame/rect"
 )
 
 type InfoPageSelector struct {
-  PageSelector
-  BackgroundColor *color.Color
+	PageSelector
+	BackgroundColor *color.Color
 }
 
 func NewInfoPageSelector() *InfoPageSelector {
-  p := &InfoPageSelector{}
-  
-  p.Width = Width
-  p.BackgroundColor = &color.Color{131,199,219,255} //SkinManager().GiveColor('Front')
-  
-  return p
-  
+	p := &InfoPageSelector{}
+
+	p.Width = Width
+	p.BackgroundColor = &color.Color{131, 199, 219, 255} //SkinManager().GiveColor('Front')
+
+	return p
+
 }
 
 func (self *InfoPageSelector) AnimateDraw(x2, y2 int) {
-  //pass
+	//pass
 }
 
 func (self *InfoPageSelector) Draw() {
-  idx := self.Parent.GetPsIndex()
-  mylist := self.Parent.GetMyList()
- 
-  if idx < len(mylist) {
-    _,y := mylist[idx].Coord()
-    _,h := mylist[idx].Size()
-    
-    
-    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) {
+		_, y := mylist[idx].Coord()
+		_, h := mylist[idx].Size()
+
+		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)
+	}
+}

+ 125 - 133
sysgo/UI/keyboard.go

@@ -1,19 +1,18 @@
 package UI
 
 import (
-  "fmt"
+	"fmt"
 	"strings"
-  
-  "github.com/cuu/gogame/font"
-	"github.com/cuu/gogame/draw"
-	"github.com/cuu/gogame/surface"
+
 	"github.com/cuu/gogame/color"
+	"github.com/cuu/gogame/draw"
 	"github.com/cuu/gogame/event"
-
+	"github.com/cuu/gogame/font"
+	"github.com/cuu/gogame/surface"
 
 	"github.com/clockworkpi/LauncherGoDev/sysgo/easings"
-
 )
+
 //sysgo/UI/keyboard_keys.layout
 type KeyboardIcon struct {
 	TextItem // IconItem->TextItem->KeyboardIcon
@@ -22,8 +21,8 @@ type KeyboardIcon struct {
 func NewKeyboardIcon() *KeyboardIcon {
 	p := &KeyboardIcon{}
 
-	p.Color = &color.Color{83,83,83,255}//SkinManager().GiveColor('Text')
-	
+	p.Color = &color.Color{83, 83, 83, 255} //SkinManager().GiveColor('Text')
+
 	p.MyType = ICON_TYPES["NAV"]
 
 	return p
@@ -31,20 +30,18 @@ func NewKeyboardIcon() *KeyboardIcon {
 
 func (self *KeyboardIcon) Draw() {
 
-	rect_ := draw.MidRect(self.PosX,self.PosY,self.Width,self.Height,Width,Height)
-	
-	surface.Blit(self.Parent.GetCanvasHWND(),self.ImgSurf,rect_,nil)
-	
-}
+	rect_ := draw.MidRect(self.PosX, self.PosY, self.Width, self.Height, Width, Height)
+
+	surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf, rect_, nil)
 
+}
 
 type KeyboardSelector struct {
 	PageSelector
 	Parent *Keyboard
 }
 
-
-func NewKeyboardSelector() * KeyboardSelector {
+func NewKeyboardSelector() *KeyboardSelector {
 	p := &KeyboardSelector{}
 
 	return p
@@ -53,19 +50,19 @@ func NewKeyboardSelector() * KeyboardSelector {
 func (self *KeyboardSelector) Draw() {
 	sec_idx := self.Parent.SectionIndex
 	row_idx := self.Parent.RowIndex
-	idx     := self.Parent.PsIndex
+	idx := self.Parent.PsIndex
 
-	x, y    := self.Parent.SecsKeys[sec_idx][row_idx][idx].Coord()
-	w, h    := self.Parent.SecsKeys[sec_idx][row_idx][idx].Size()
+	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+6,h+1,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
 	}
-	
-	color_ := &color.Color{126,206,244,255}
-	draw.AARoundRect(self.Parent.CanvasHWND,rect_,color_,3,0,color_)
+
+	color_ := &color.Color{126, 206, 244, 255}
+	draw.AARoundRect(self.Parent.CanvasHWND, rect_, color_, 3, 0, color_)
 
 }
 
@@ -73,12 +70,12 @@ type Keyboard struct {
 	Page
 
 	Secs map[int][][]string
-	
+
 	SecsKeys map[int][][]TextItemInterface
-	
+
 	SectionNumbers int
-	SectionIndex int
-	Icons  map[string]IconItemInterface
+	SectionIndex   int
+	Icons          map[string]IconItemInterface
 
 	KeyboardLayoutFile string ///sysgo/UI/keyboard_keys.layout
 
@@ -99,36 +96,34 @@ func NewKeyboard() *Keyboard {
 	p.SelectedIconTopOffset = 20
 
 	p.Align = ALIGN["SLeft"]
-  
+
 	p.EasingDur = 10
-	
+
 	p.SectionNumbers = 3
 	p.SectionIndex = 1
 
-	p.Icons =  make( map[string]IconItemInterface )
+	p.Icons = make(map[string]IconItemInterface)
 
 	p.LeftOrRight = 1
 
 	p.RowIndex = 0
-	
-	p.FootMsg = [5]string{"Nav.","ABC","Done","Backspace","Enter"}
+
+	p.FootMsg = [5]string{"Nav.", "ABC", "Done", "Backspace", "Enter"}
 
 	p.Secs = make(map[int][][]string)
 	p.SecsKeys = make(map[int][][]TextItemInterface)
-	
+
 	p.KeyboardLayoutFile = "sysgo/UI/keyboard_keys.layout"
 
-	
 	return p
-	
+
 }
 
-func (self *Keyboard) ReadLayoutFile( fname string) {
+func (self *Keyboard) ReadLayoutFile(fname string) {
 
-	
 	LayoutIndex := 0
 
-	content ,err := ReadLines(fname)
+	content, err := ReadLines(fname)
 
 	Assert(err)
 
@@ -159,20 +154,18 @@ func (self *Keyboard) ReadLayoutFile( fname string) {
 		} else { //empty []
 			LayoutIndex += 1
 		}
-	}	
+	}
 }
 
-
 func (self *Keyboard) SetPassword(pwd string) {
-	pwd_seq_list := strings.SplitAfter(pwd,"")
+	pwd_seq_list := strings.SplitAfter(pwd, "")
 
 	self.Textarea.ResetMyWords()
-	for _,v := range pwd_seq_list {
+	for _, v := range pwd_seq_list {
 		self.Textarea.AppendText(v)
 	}
 }
 
-
 func (self *Keyboard) Init() {
 	self.CanvasHWND = self.Screen.CanvasHWND
 	self.ReadLayoutFile(self.KeyboardLayoutFile) //assign to self.Secs
@@ -187,26 +180,26 @@ func (self *Keyboard) Init() {
 
 	word_margin := 15
 
-	secs_zero := strings.Join(self.Secs[0][0],"")
-	fw,_:= font.Size(fontobj,secs_zero)
+	secs_zero := strings.Join(self.Secs[0][0], "")
+	fw, _ := font.Size(fontobj, secs_zero)
 
-	start_x := (self.Width - fw - len(self.Secs[0][0])*word_margin)/2+word_margin/2
+	start_x := (self.Width-fw-len(self.Secs[0][0])*word_margin)/2 + word_margin/2
 	start_y := 0
 
-//	cnt := 0
+	//	cnt := 0
 
-	for i:=0; i < self.SectionNumbers; i++ {
+	for i := 0; i < self.SectionNumbers; i++ {
 		self.SecsKeys[i] = [][]TextItemInterface{}
-		for j:=0; j < len(self.Secs[i]); j++ {
-			self.SecsKeys[i] = append(self.SecsKeys[i],[]TextItemInterface{})
-			secs_ij := strings.Join(self.Secs[i][j],"")
-			fw,_ := font.Size(fontobj,secs_ij)
-			start_x = (self.Width-fw- len(self.Secs[i][j])*word_margin)/2+word_margin/2
+		for j := 0; j < len(self.Secs[i]); j++ {
+			self.SecsKeys[i] = append(self.SecsKeys[i], []TextItemInterface{})
+			secs_ij := strings.Join(self.Secs[i][j], "")
+			fw, _ := font.Size(fontobj, secs_ij)
+			start_x = (self.Width-fw-len(self.Secs[i][j])*word_margin)/2 + word_margin/2
 			start_x = start_x + i*self.Width
 
-			start_y = 84 + j * (word_margin+14)
+			start_y = 84 + j*(word_margin+14)
 
-			for _,val := range self.Secs[i][j] {
+			for _, val := range self.Secs[i][j] {
 				ti := NewTextItem()
 				ti.FontObj = fontobj
 				ti.Parent = self
@@ -216,23 +209,23 @@ func (self *Keyboard) Init() {
 					it.ImgSurf = MyIconPool.GetImgSurf(val)
 					it.Parent = self
 					it.Str = val
-					it.Init(start_x+surface.GetWidth(it.ImgSurf)/2,start_y,surface.GetWidth(it.ImgSurf),surface.GetHeight(it.ImgSurf),0)
-					self.SecsKeys[i][j] = append(self.SecsKeys[i][j],it)
+					it.Init(start_x+surface.GetWidth(it.ImgSurf)/2, start_y, surface.GetWidth(it.ImgSurf), surface.GetHeight(it.ImgSurf), 0)
+					self.SecsKeys[i][j] = append(self.SecsKeys[i][j], it)
 					self.IconNumbers += 1
-					start_x = start_x + surface.GetWidth(it.ImgSurf)+word_margin
-				}else {
+					start_x = start_x + surface.GetWidth(it.ImgSurf) + word_margin
+				} else {
 
-					if val ==  "_S" {
+					if val == "_S" {
 						val = "Space"
 						ti.FontObj = Fonts["veramono15"]
 						ti.Bold = true
 					}
 
-					cur_alpha_w,cur_alpha_h := font.Size(ti.FontObj,val)
-					ti.Init(start_x + cur_alpha_w/2,start_y,cur_alpha_w,cur_alpha_h,0)
+					cur_alpha_w, cur_alpha_h := font.Size(ti.FontObj, val)
+					ti.Init(start_x+cur_alpha_w/2, start_y, cur_alpha_w, cur_alpha_h, 0)
 					ti.Str = val
-					start_x = start_x + cur_alpha_w+word_margin // prepare for next alphabet
-					self.SecsKeys[i][j] = append(self.SecsKeys[i][j],ti)
+					start_x = start_x + cur_alpha_w + word_margin // prepare for next alphabet
+					self.SecsKeys[i][j] = append(self.SecsKeys[i][j], ti)
 				}
 			}
 		}
@@ -253,9 +246,9 @@ func (self *Keyboard) Init() {
 	ps := NewKeyboardSelector()
 
 	ps.Parent = self
-	ps.Init(start_x,start_y,25,25,128)
-  ps.OnShow = true
-  
+	ps.Init(start_x, start_y, 25, 25, 128)
+	ps.OnShow = true
+
 	self.Ps = ps
 	self.PsIndex = 0
 
@@ -264,13 +257,13 @@ func (self *Keyboard) Init() {
 func (self *Keyboard) SelectUpChar() {
 	sec_idx := self.SectionIndex
 
-	self.RowIndex -=1
+	self.RowIndex -= 1
 	if self.RowIndex < 0 {
-		self.RowIndex = len(self.SecsKeys[sec_idx])-1
+		self.RowIndex = len(self.SecsKeys[sec_idx]) - 1
 	}
 
 	if self.PsIndex >= len(self.SecsKeys[sec_idx][self.RowIndex]) {
-		self.PsIndex = len(self.SecsKeys[sec_idx][self.RowIndex])-1
+		self.PsIndex = len(self.SecsKeys[sec_idx][self.RowIndex]) - 1
 	}
 
 	self.ClearCanvas()
@@ -287,8 +280,8 @@ func (self *Keyboard) SelectDownChar() {
 		self.RowIndex = 0
 	}
 
-	if self.PsIndex >=len(self.SecsKeys[sec_idx][self.RowIndex]) {
-		self.PsIndex = len(self.SecsKeys[sec_idx][self.RowIndex])-1
+	if self.PsIndex >= len(self.SecsKeys[sec_idx][self.RowIndex]) {
+		self.PsIndex = len(self.SecsKeys[sec_idx][self.RowIndex]) - 1
 	}
 
 	self.ClearCanvas()
@@ -300,34 +293,34 @@ func (self *Keyboard) SelectNextChar() {
 
 	sec_idx := self.SectionIndex
 	row_idx := self.RowIndex
-	self.PsIndex+=1
-	
+	self.PsIndex += 1
+
 	if self.PsIndex >= len(self.SecsKeys[sec_idx][row_idx]) {
 		self.PsIndex = 0
-		self.RowIndex+=1
-	
+		self.RowIndex += 1
+
 		if self.RowIndex >= len(self.SecsKeys[sec_idx]) {
 			self.RowIndex = 0
 		}
 
 	}
-	
+
 	self.ClearCanvas()
 	self.Draw()
 	self.Screen.SwapAndShow()
-	
+
 }
 
 func (self *Keyboard) SelectPrevChar() {
 
-	sec_idx := self.SectionIndex    
-	self.PsIndex-=1
+	sec_idx := self.SectionIndex
+	self.PsIndex -= 1
 	if self.PsIndex < 0 {
-		self.RowIndex-=1
-		if self.RowIndex <=0 {
-			self.RowIndex = len(self.SecsKeys[sec_idx])-1
+		self.RowIndex -= 1
+		if self.RowIndex <= 0 {
+			self.RowIndex = len(self.SecsKeys[sec_idx]) - 1
 		}
-		self.PsIndex = len(self.SecsKeys[sec_idx][self.RowIndex]) -1
+		self.PsIndex = len(self.SecsKeys[sec_idx][self.RowIndex]) - 1
 	}
 
 	self.ClearCanvas()
@@ -336,20 +329,20 @@ func (self *Keyboard) SelectPrevChar() {
 }
 
 func (self *Keyboard) ClickOnChar() {
-	sec_idx := self.SectionIndex        
+	sec_idx := self.SectionIndex
 	alphabet := self.SecsKeys[sec_idx][self.RowIndex][self.PsIndex].GetStr()
-  
-	if alphabet == "Space"{
+
+	if alphabet == "Space" {
 		alphabet = " "
 	}
 
 	if alphabet == "_L" || alphabet == "_R" {
 		if alphabet == "_L" {
 			self.Textarea.SubTextIndex()
-		}else if alphabet == "_R"{
+		} else if alphabet == "_R" {
 			self.Textarea.AddTextIndex()
 		}
-	}else {
+	} else {
 		self.Textarea.AppendText(alphabet)
 	}
 
@@ -360,23 +353,23 @@ func (self *Keyboard) ClickOnChar() {
 func (self *Keyboard) KeyboardShift() {
 	distance := self.Width //320
 	current_time := float32(0.0)
-	start_posx   := float32(0.0)
+	start_posx := float32(0.0)
 	current_posx := start_posx
-	final_posx   := float32(distance)
-//	posx_init    := start
-	dur          := self.EasingDur
-	last_posx    := float32(0.0)
+	final_posx := float32(distance)
+	//	posx_init    := start
+	dur := self.EasingDur
+	last_posx := float32(0.0)
 
 	var all_last_posx []int
 
-	for i:=0;i<distance*dur;i++ {
-		current_posx = float32(easings.SineIn(float32(current_time), float32(start_posx), float32(final_posx-start_posx),float32(dur)))
+	for i := 0; i < distance*dur; i++ {
+		current_posx = float32(easings.SineIn(float32(current_time), float32(start_posx), float32(final_posx-start_posx), float32(dur)))
 		if current_posx >= final_posx {
 			current_posx = final_posx
 		}
 		dx := current_posx - last_posx
-		all_last_posx = append(all_last_posx,int(dx))
-		current_time+=1.0
+		all_last_posx = append(all_last_posx, int(dx))
+		current_time += 1.0
 		last_posx = current_posx
 		if current_posx >= final_posx {
 			break
@@ -384,19 +377,19 @@ func (self *Keyboard) KeyboardShift() {
 	}
 
 	c := 0
-	for _,v := range all_last_posx {
-		c+=v
+	for _, v := range all_last_posx {
+		c += v
 	}
-	if c < int(final_posx - start_posx) {
-		all_last_posx = append(all_last_posx, int( int(final_posx) - c ))
+	if c < int(final_posx-start_posx) {
+		all_last_posx = append(all_last_posx, int(int(final_posx)-c))
 	}
 
-	for _,v := range all_last_posx {
-		for j:=0;j<self.SectionNumbers;j++ {
-			for _,u := range self.SecsKeys[j] {
-				for _,x := range u {
-          x_,y_ := x.Coord()
-          x.NewCoord(x_+self.LeftOrRight*v,y_)
+	for _, v := range all_last_posx {
+		for j := 0; j < self.SectionNumbers; j++ {
+			for _, u := range self.SecsKeys[j] {
+				for _, x := range u {
+					x_, y_ := x.Coord()
+					x.NewCoord(x_+self.LeftOrRight*v, y_)
 				}
 			}
 		}
@@ -415,8 +408,7 @@ func (self *Keyboard) ShiftKeyboardPage() {
 	self.Screen.SwapAndShow()
 }
 
-
-func (self *Keyboard) KeyDown( ev *event.Event) {
+func (self *Keyboard) KeyDown(ev *event.Event) {
 	if ev.Data["Key"] == CurKeys["Up"] {
 		self.SelectUpChar()
 		return
@@ -441,36 +433,36 @@ func (self *Keyboard) KeyDown( ev *event.Event) {
 		self.ClickOnChar()
 		return
 	}
-  
-  if ev.Data["Key"] == CurKeys["X"] {
-    if self.SectionIndex <= 0 {
-      self.LeftOrRight = -1
-    }
-    
-    if self.SectionIndex >= (self.SectionNumbers - 1) {
-      self.LeftOrRight = 1
-    }
-    
-    self.ShiftKeyboardPage()
-    
-  }
+
+	if ev.Data["Key"] == CurKeys["X"] {
+		if self.SectionIndex <= 0 {
+			self.LeftOrRight = -1
+		}
+
+		if self.SectionIndex >= (self.SectionNumbers - 1) {
+			self.LeftOrRight = 1
+		}
+
+		self.ShiftKeyboardPage()
+
+	}
 
 	if ev.Data["Key"] == CurKeys["Menu"] {
 		self.ReturnToUpLevelPage()
 		self.Screen.Draw()
 		self.Screen.SwapAndShow()
-    
+
 	}
 
 	if ev.Data["Key"] == CurKeys["Y"] { // done
-		fmt.Println(strings.Join(self.Textarea.MyWords,""))
+		fmt.Println(strings.Join(self.Textarea.MyWords, ""))
 		self.ReturnToUpLevelPage()
 		self.Screen.SwapAndShow()
-    if self.Caller != nil {
-      self.Caller.OnKbdReturnBackCb()
-    }
+		if self.Caller != nil {
+			self.Caller.OnKbdReturnBackCb()
+		}
 		//Uplevel/Parent page invoke OnReturnBackCb,eg: ConfigWireless
-		
+
 	}
 
 	if ev.Data["Key"] == CurKeys["A"] {
@@ -480,7 +472,7 @@ func (self *Keyboard) KeyDown( ev *event.Event) {
 	}
 
 	if ev.Data["Key"] == CurKeys["LK1"] {
-		if self.SectionIndex < self.SectionNumbers -1 {
+		if self.SectionIndex < self.SectionNumbers-1 {
 			self.LeftOrRight = -1
 			self.ShiftKeyboardPage()
 		}
@@ -499,9 +491,9 @@ func (self *Keyboard) Draw() {
 	self.ClearCanvas()
 	self.Ps.Draw()
 
-	for i:=0; i < self.SectionNumbers; i++ {
-		for _,j := range self.SecsKeys[i] {
-			for _,u := range j {
+	for i := 0; i < self.SectionNumbers; i++ {
+		for _, j := range self.SecsKeys[i] {
+			for _, u := range j {
 				u.Draw()
 			}
 		}

+ 22 - 25
sysgo/UI/keys_def.go

@@ -4,12 +4,10 @@ import (
 	"github.com/clockworkpi/LauncherGoDev/sysgo"
 )
 
-
 var CurKeys map[string]string
 
 var GameShell map[string]string
-var PC        map[string]string
-
+var PC map[string]string
 
 func DefinePC() {
 	PC["Up"] = "Up"
@@ -17,19 +15,19 @@ func DefinePC() {
 	PC["Left"] = "Left"
 	PC["Right"] = "Right"
 	PC["Menu"] = "Escape"
-	PC["X"]    = "X"
-	PC["Y"]    = "Y"
-	PC["A"]    = "A"
-	PC["B"]    = "B"
+	PC["X"] = "X"
+	PC["Y"] = "Y"
+	PC["A"] = "A"
+	PC["B"] = "B"
 
-	PC["Vol-"]  = "Space"
-	PC["Vol+"]  = "Return"
+	PC["Vol-"] = "Space"
+	PC["Vol+"] = "Return"
 	PC["Space"] = "Space"
 	PC["Enter"] = "Return"
 	PC["Start"] = "S"
 
-	PC["LK1"]  = "H"
-	PC["LK5"]  = "L"
+	PC["LK1"] = "H"
+	PC["LK5"] = "L"
 }
 
 func DefineGameShell() {
@@ -38,33 +36,32 @@ func DefineGameShell() {
 	GameShell["Left"] = "Left"
 	GameShell["Right"] = "Right"
 	GameShell["Menu"] = "Escape"
-	GameShell["X"]    = "U"
-	GameShell["Y"]    = "I"
-	GameShell["A"]    = "J"
-	GameShell["B"]    = "K"
+	GameShell["X"] = "U"
+	GameShell["Y"] = "I"
+	GameShell["A"] = "J"
+	GameShell["B"] = "K"
 
-	GameShell["Vol-"]  = "Space"
-	GameShell["Vol+"]  = "Return"
+	GameShell["Vol-"] = "Space"
+	GameShell["Vol+"] = "Return"
 	GameShell["Space"] = "Space"
 	GameShell["Enter"] = "K"
 	GameShell["Start"] = "Return"
 
-	GameShell["LK1"]  = "H"
-	GameShell["LK5"]  = "L"
-	
-}
+	GameShell["LK1"] = "H"
+	GameShell["LK5"] = "L"
 
+}
 
-func keys_def_init(){
+func keys_def_init() {
 	GameShell = make(map[string]string)
-	PC        = make(map[string]string)
+	PC = make(map[string]string)
 
 	DefineGameShell()
 	DefinePC()
-	
+
 	if sysgo.CurKeySet == "GameShell" {
 		CurKeys = GameShell
-	}else {
+	} else {
 		CurKeys = PC
 	}
 }

+ 47 - 50
sysgo/UI/label.go

@@ -1,83 +1,81 @@
 package UI
 
 import (
-  //"fmt"
+	//"fmt"
 	"github.com/veandco/go-sdl2/sdl"
 	"github.com/veandco/go-sdl2/ttf"
-	
-	"github.com/cuu/gogame/surface"
-	"github.com/cuu/gogame/rect"
+
 	"github.com/cuu/gogame/color"
+	"github.com/cuu/gogame/draw"
 	"github.com/cuu/gogame/font"
- 	"github.com/cuu/gogame/draw"
- 
+	"github.com/cuu/gogame/rect"
+	"github.com/cuu/gogame/surface"
 )
 
 type LabelInterface interface {
-	Init( text string, font_obj *ttf.Font,col *color.Color )
-	SetCanvasHWND( canvas *sdl.Surface)
-	Coord() (int,int)
-	Size() (int,int)
-	NewCoord(x,y int)
-	NewSize(w,h int)
-	SetColor(col *color.Color )
+	Init(text string, font_obj *ttf.Font, col *color.Color)
+	SetCanvasHWND(canvas *sdl.Surface)
+	Coord() (int, int)
+	Size() (int, int)
+	NewCoord(x, y int)
+	NewSize(w, h int)
+	SetColor(col *color.Color)
 	GetText() string
 	SetText(text string)
 	Draw()
-  DrawCenter(bold bool)
-  SetBold(b bool)
+	DrawCenter(bold bool)
+	SetBold(b bool)
 }
 
 type Label struct {
 	Widget
-	Text string
-	FontObj *ttf.Font
-	Color  *color.Color
+	Text       string
+	FontObj    *ttf.Font
+	Color      *color.Color
 	CanvasHWND *sdl.Surface
-  Bold bool
-//	TextSurf *sdl.Surface
+	Bold       bool
+	//	TextSurf *sdl.Surface
 }
 
 func NewLabel() *Label {
 	l := &Label{}
-	l.Color = &color.Color{83,83,83,255}
-  l.Bold = false
+	l.Color = &color.Color{83, 83, 83, 255}
+	l.Bold = false
 	return l
 }
 
-func (self *Label) Init(text string, font_obj *ttf.Font,col *color.Color ) {
+func (self *Label) Init(text string, font_obj *ttf.Font, col *color.Color) {
 	if col != nil {
 		self.Color = col
 	}
-		
 
 	self.Text = text
 
 	self.FontObj = font_obj
 
-	self.Width,self.Height = font.Size(self.FontObj, self.Text)
-	
+	self.Width, self.Height = font.Size(self.FontObj, self.Text)
+
 }
 
-func (self *Label) SetCanvasHWND( canvas *sdl.Surface) {
+func (self *Label) SetCanvasHWND(canvas *sdl.Surface) {
 	self.CanvasHWND = canvas
 }
 
-func (self *Label) Coord() (int,int) {
-	return self.PosX,self.PosY
+func (self *Label) Coord() (int, int) {
+	return self.PosX, self.PosY
 }
 
-func (self *Label) Size() (int,int) {
-	return self.Width,self.Height
+func (self *Label) Size() (int, int) {
+	return self.Width, self.Height
 }
 
-func (self *Label) NewCoord(x,y int) {
+func (self *Label) NewCoord(x, y int) {
 	self.PosX = x
 	self.PosY = y
-	
+
 }
 
-func (self *Label) SetColor(col *color.Color){
+func (self *Label) SetColor(col *color.Color) {
 	if col != nil {
 		self.Color = col
 	}
@@ -87,35 +85,34 @@ func (self *Label) GetText() string {
 	return self.Text
 }
 
-
 func (self *Label) SetText(text string) {
 	self.Text = text
-	self.Width,self.Height = font.Size(self.FontObj, self.Text)
+	self.Width, self.Height = font.Size(self.FontObj, self.Text)
 }
 
 func (self *Label) SetBold(b bool) {
-  self.Bold = b 
+	self.Bold = b
 }
 
 func (self *Label) DrawCenter(bold bool) { // default bold is false
-  font.SetBold(self.FontObj,bold) 
-  my_text := font.Render(self.FontObj,self.Text, true, self.Color, nil)
-  
-  rect_ := draw.MidRect(self.PosX,self.PosY,self.Width,self.Height,Width,Height)
-  
-  surface.Blit(self.CanvasHWND,my_text,rect_,nil)
-  my_text.Free()
+	font.SetBold(self.FontObj, bold)
+	my_text := font.Render(self.FontObj, self.Text, true, self.Color, nil)
+
+	rect_ := draw.MidRect(self.PosX, self.PosY, self.Width, self.Height, Width, Height)
+
+	surface.Blit(self.CanvasHWND, my_text, rect_, nil)
+	my_text.Free()
 }
 
 func (self *Label) Draw() {
-	font.SetBold(self.FontObj,self.Bold) // avoing same font tangling set_bold to others
-  if len(self.Text) == 0 {
+	font.SetBold(self.FontObj, self.Bold) // avoing same font tangling set_bold to others
+	if len(self.Text) == 0 {
 		return
 	}
-	my_text := font.Render(self.FontObj,self.Text, true, self.Color, nil)
+	my_text := font.Render(self.FontObj, self.Text, true, self.Color, nil)
+
+	rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
 
-	rect_ := rect.Rect(self.PosX,self.PosY,self.Width,self.Height)
-	
-	surface.Blit(self.CanvasHWND,my_text,&rect_,nil)
+	surface.Blit(self.CanvasHWND, my_text, &rect_, nil)
 	my_text.Free()
 }

+ 102 - 106
sysgo/UI/lang_manager.go

@@ -1,27 +1,24 @@
 package UI
 
 import (
-  "fmt"
-  "strings"
-  "io/ioutil"
-  "path/filepath"
-  "github.com/veandco/go-sdl2/ttf"
+	"fmt"
 	"github.com/go-ini/ini"
-  
+	"github.com/veandco/go-sdl2/ttf"
+	"io/ioutil"
+	"path/filepath"
+	"strings"
 )
 
-
 func sliceToInt(s []int) int {
-    res := 0
-    op := 1
-    for i := len(s) - 1; i >= 0; i-- {
-        res += s[i] * op
-        op *= 10
-    }
-    return res
+	res := 0
+	op := 1
+	for i := len(s) - 1; i >= 0; i-- {
+		res += s[i] * op
+		op *= 10
+	}
+	return res
 }
 
-
 func ParseNum(s string) []int {
 	nLen := 0
 	for i := 0; i < len(s); i++ {
@@ -39,134 +36,133 @@ func ParseNum(s string) []int {
 }
 
 func GetNumberFromString(s string) int {
-  is := ParseNum(s)
-  
-  return sliceToInt(is)
+	is := ParseNum(s)
+
+	return sliceToInt(is)
 
 }
 
 type LangManager struct {
-  
-  Langs map[string]string
-  ConfigFilename string
-  
-  CJKMode bool
+	Langs          map[string]string
+	ConfigFilename string
+
+	CJKMode bool
 }
 
 func NewLangManager() *LangManager {
-  p := &LangManager{}
-  
-  p.ConfigFilename = "00_English.ini"
-  p.CJKMode = false
-  
-  return p
+	p := &LangManager{}
+
+	p.ConfigFilename = "00_English.ini"
+	p.CJKMode = false
+
+	return p
 }
 
 func (self *LangManager) Init() {
-  if self.Langs == nil {
-    self.SetLangs()
-  }
+	if self.Langs == nil {
+		self.SetLangs()
+	}
 }
 
 func (self *LangManager) UpdateLang() {
-  
-  self.Langs  = nil
-  self.SetLangs()
+
+	self.Langs = nil
+	self.SetLangs()
 
 }
 
 func (self *LangManager) IsCJKMode() bool {
-  var latins = [1]string{"English"}
-  
-  self.CJKMode= false
-  
-  for _,v := range latins {
-    if strings.HasPrefix(self.ConfigFilename,v) {
-      self.CJKMode = false
-      break
-    }
-  }
-  
-  return self.CJKMode
+	var latins = [1]string{"English"}
+
+	self.CJKMode = false
+
+	for _, v := range latins {
+		if strings.HasPrefix(self.ConfigFilename, v) {
+			self.CJKMode = false
+			break
+		}
+	}
+
+	return self.CJKMode
 }
 
 func (self *LangManager) SetLangs() {
-  
-  self.Langs = make(map[string]string)
-  fname := "sysgo/.lang"
-  
-  load_opts := ini.LoadOptions{
-		IgnoreInlineComment:true,
+
+	self.Langs = make(map[string]string)
+	fname := "sysgo/.lang"
+
+	load_opts := ini.LoadOptions{
+		IgnoreInlineComment: true,
 	}
-  
-  if FileExists(fname) {
-    config_bytes,err := ioutil.ReadFile(fname)
-    if err == nil {
-      self.ConfigFilename = strings.Trim(string(config_bytes),"\r\n ")
-      if len(self.ConfigFilename) < 3 {
-        self.ConfigFilename = "00_English.ini"
-      }
-    }
-  }else {
-    System("touch " + fname)
-  }
-  
-  config_file_relative_path := filepath.Join("sysgo","langs",self.ConfigFilename)
-  
-  if FileExists(config_file_relative_path) == false {
-    return
-  }
-  
-  //no matter what ,we must have 00_English.ini
+
+	if FileExists(fname) {
+		config_bytes, err := ioutil.ReadFile(fname)
+		if err == nil {
+			self.ConfigFilename = strings.Trim(string(config_bytes), "\r\n ")
+			if len(self.ConfigFilename) < 3 {
+				self.ConfigFilename = "00_English.ini"
+			}
+		}
+	} else {
+		System("touch " + fname)
+	}
+
+	config_file_relative_path := filepath.Join("sysgo", "langs", self.ConfigFilename)
+
+	if FileExists(config_file_relative_path) == false {
+		return
+	}
+
+	//no matter what ,we must have 00_English.ini
 	cfg, err := ini.LoadSources(load_opts, config_file_relative_path)
 	if err != nil {
 		fmt.Printf("Fail to read file: %v\n", err)
 		return
 	}
-  
+
 	section := cfg.Section("Langs")
 	if section != nil {
 		opts := section.KeyStrings()
-    for _,v := range opts {
-      self.Langs[v] = section.Key(v).String()
+		for _, v := range opts {
+			self.Langs[v] = section.Key(v).String()
 		}
 	}
-  
+
 }
 
 func (self *LangManager) Tr(english_key_str string) string {
-  
-  if self.Langs == nil  {
-    return english_key_str
-  }
-  
-  if len(self.Langs) == 0 {
-    return english_key_str
-  }
-
-  if v,ok := self.Langs[english_key_str]; ok {
-  
-    return v
-  }
-  return english_key_str
+
+	if self.Langs == nil {
+		return english_key_str
+	}
+
+	if len(self.Langs) == 0 {
+		return english_key_str
+	}
+
+	if v, ok := self.Langs[english_key_str]; ok {
+
+		return v
+	}
+	return english_key_str
 }
 
 func (self *LangManager) TrFont(orig_font_str string) *ttf.Font {
-  
-  font_size_number := GetNumberFromString(orig_font_str)
-  if font_size_number > 120 {
-    panic("font string format error")
-  }
-  
-  if strings.Contains(self.ConfigFilename,"English.ini") {
-    return Fonts[orig_font_str]
-  }else {
-    if font_size_number > 28 {
-      panic("cjk font size over 28")
-    }
-  }
-
-  return Fonts[  fmt.Sprintf("notosanscjk%d",font_size_number) ]
+
+	font_size_number := GetNumberFromString(orig_font_str)
+	if font_size_number > 120 {
+		panic("font string format error")
+	}
+
+	if strings.Contains(self.ConfigFilename, "English.ini") {
+		return Fonts[orig_font_str]
+	} else {
+		if font_size_number > 28 {
+			panic("cjk font size over 28")
+		}
+	}
+
+	return Fonts[fmt.Sprintf("notosanscjk%d", font_size_number)]
 
 }
 

+ 25 - 33
sysgo/UI/list_item.go

@@ -2,24 +2,21 @@ package UI
 
 import (
 	"github.com/veandco/go-sdl2/ttf"
-	
-	"github.com/cuu/gogame/draw"
+
 	"github.com/cuu/gogame/color"
-	
+	"github.com/cuu/gogame/draw"
 )
 
 type ListItemInterface interface {
-
 	Init(text string)
-	
-	Size() (int,int)
-	NewSize(w,h int)
-	Coord() (int,int)
-	NewCoord(x,y int)
+
+	Size() (int, int)
+	NewSize(w, h int)
+	Coord() (int, int)
+	NewCoord(x, y int)
 
 	GetLinkObj() PluginInterface
 	Draw()
-	
 }
 
 type ListItem struct {
@@ -29,57 +26,52 @@ type ListItem struct {
 	Fonts  map[string]*ttf.Font
 
 	LinkObj PluginInterface
-	
+
 	Parent PageInterface
 }
 
 func NewListItem() *ListItem {
 	i := &ListItem{}
 	i.Labels = make(map[string]LabelInterface)
-	i.Icons  = make( map[string]IconItemInterface)
-	i.Fonts  = make(map[string]*ttf.Font)
+	i.Icons = make(map[string]IconItemInterface)
+	i.Fonts = make(map[string]*ttf.Font)
 
 	i.Height = 30
-	i.Width  = 0
-	
+	i.Width = 0
+
 	return i
 }
 
-
 func (self *ListItem) Init(text string) {
 	l := NewLabel()
 	l.PosX = 16
 	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 *ListItem) Coord() (int,int) {
-	return self.PosX,self.PosY
 }
 
-func (self *ListItem) Size() (int,int) {
-	return self.Width,self.Height
+func (self *ListItem) Coord() (int, int) {
+	return self.PosX, self.PosY
 }
 
+func (self *ListItem) Size() (int, int) {
+	return self.Width, self.Height
+}
 
 func (self *ListItem) GetLinkObj() PluginInterface {
 	return self.LinkObj
 }
 
 func (self *ListItem) Draw() {
-	x_,_ := self.Labels["Text"].Coord()
-	_,h_ := self.Labels["Text"].Size()
-	
-	self.Labels["Text"].NewCoord(x_, self.PosY+(self.Height - h_)/2)
+	x_, _ := self.Labels["Text"].Coord()
+	_, h_ := self.Labels["Text"].Size()
+
+	self.Labels["Text"].NewCoord(x_, self.PosY+(self.Height-h_)/2)
 	self.Labels["Text"].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)
+	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)
 
-	
 }

+ 146 - 154
sysgo/UI/main_screen.go

@@ -3,68 +3,68 @@ package UI
 import (
 	"fmt"
 	"io/ioutil"
-	"strings"
 	"log"
+	"strings"
 	//"encoding/json"
-	"path/filepath"
-  gotime "time"
 	"github.com/veandco/go-sdl2/sdl"
 	"github.com/veandco/go-sdl2/ttf"
+	"path/filepath"
+	gotime "time"
 
+	"github.com/cuu/gogame/color"
 	"github.com/cuu/gogame/display"
-	"github.com/cuu/gogame/surface"
 	"github.com/cuu/gogame/draw"
-	"github.com/cuu/gogame/color"
-	"github.com/cuu/gogame/rect"
 	"github.com/cuu/gogame/font"
+	"github.com/cuu/gogame/rect"
+	"github.com/cuu/gogame/surface"
 	"github.com/cuu/gogame/time"
-	
+
 	"github.com/cuu/gogame/event"
-  
+
 	"github.com/clockworkpi/LauncherGoDev/sysgo"
 )
+
 //eg: MainScreen
 type ScreenInterface interface {
-  AppendPage( pg PageInterface ) 
-  ClearCanvas()
-  CurPage() PageInterface 
-  Draw()
-  ExtraName(name string) string
-  FartherPages()
-  Init()
-  IsEmulatorPackage(dirname string ) bool 
-  IsExecPackage(dirname string ) bool 
-  IsPluginPackage(dirname string ) bool
-  KeyDown(ev *event.Event)
-  OnExitCb()
-  PushCurPage() 
-  PushPage( pg PageInterface) 
-  RunEXE( cmdpath string)
-  SetCurPage( pg PageInterface)
-  SwapAndShow()
+	AppendPage(pg PageInterface)
+	ClearCanvas()
+	CurPage() PageInterface
+	Draw()
+	ExtraName(name string) string
+	FartherPages()
+	Init()
+	IsEmulatorPackage(dirname string) bool
+	IsExecPackage(dirname string) bool
+	IsPluginPackage(dirname string) bool
+	KeyDown(ev *event.Event)
+	OnExitCb()
+	PushCurPage()
+	PushPage(pg PageInterface)
+	RunEXE(cmdpath string)
+	SetCurPage(pg PageInterface)
+	SwapAndShow()
 	IsWifiConnectedNow()
 }
 
 type PluginConfig struct {
-	NAME string    `json:"NAME"`  // plugin name,default could be the same as Plugin Folder's name
+	NAME    string `json:"NAME"` // plugin name,default could be the same as Plugin Folder's name
 	SO_FILE string `json:"SO_FILE"`
-	
 }
 
 type MessageBox struct {
 	Label
 	Parent *MainScreen
-	HWND *sdl.Surface
+	HWND   *sdl.Surface
 }
 
 func NewMessageBox() *MessageBox {
 	m := &MessageBox{}
-	m.Color = &color.Color{83,83,83,255}
-	
+	m.Color = &color.Color{83, 83, 83, 255}
+
 	return m
 }
 
-func (self *MessageBox) Init( text string, font_obj *ttf.Font, col *color.Color) {
+func (self *MessageBox) Init(text string, font_obj *ttf.Font, col *color.Color) {
 	if col != nil {
 		self.Color = col
 	}
@@ -76,21 +76,21 @@ func (self *MessageBox) Init( text string, font_obj *ttf.Font, col *color.Color)
 	self.Height = 0
 
 	self.CanvasHWND = surface.Surface(self.Parent.Width, self.Parent.Height)
-	self.HWND       = self.Parent.CanvasHWND
-	
+	self.HWND = self.Parent.CanvasHWND
+
 }
 
-func (self *MessageBox) SetText( text string) {
+func (self *MessageBox) SetText(text string) {
 	self.Text = text
 }
 
 func (self *MessageBox) Draw() {
 	self.Width = 0
 	self.Height = 0
-	surface.Fill(self.CanvasHWND, &color.Color{255,255,255,255} )
+	surface.Fill(self.CanvasHWND, &color.Color{255, 255, 255, 255})
 
-	words := strings.Split(self.Text," ")
-	space,_ := font.Size(self.FontObj," ")
+	words := strings.Split(self.Text, " ")
+	space, _ := font.Size(self.FontObj, " ")
 
 	max_width := self.Parent.Width - 40
 	x := 0
@@ -99,8 +99,8 @@ func (self *MessageBox) Draw() {
 	row_total_width := 0
 	lines := 0
 
-	for _,word := range words {
-		word_surface := font.Render( self.FontObj, word, true, self.Color,nil)
+	for _, word := range words {
+		word_surface := font.Render(self.FontObj, word, true, self.Color, nil)
 		word_width := int(word_surface.W)
 		word_height := int(word_surface.H)
 		row_total_width += word_width
@@ -108,27 +108,27 @@ func (self *MessageBox) Draw() {
 			lines += word_height
 		}
 
-		if (row_total_width + space ) >= max_width {
+		if (row_total_width + space) >= max_width {
 			x = 0
 			y += word_height
 			row_total_width = word_width
-			lines+=word_height
+			lines += word_height
 		}
 
-		dest_rect := rect.Rect(x,y, word_width,word_height)
-		surface.Blit(self.CanvasHWND, word_surface, &dest_rect,nil)
-    word_surface.Free()
+		dest_rect := rect.Rect(x, y, word_width, word_height)
+		surface.Blit(self.CanvasHWND, word_surface, &dest_rect, nil)
+		word_surface.Free()
 		if len(words) == 1 {
-			x+=word_width
+			x += word_width
 		} else {
-			x += word_width+space
+			x += word_width + space
 		}
-		
+
 		if x > self.Width {
 			self.Width = x
 		}
 
-		if lines >= self.Parent.Height - 40 {
+		if lines >= self.Parent.Height-40 {
 			break
 		}
 	}
@@ -137,31 +137,30 @@ func (self *MessageBox) Draw() {
 
 	padding := 5
 	x = (self.Parent.Width - self.Width) / 2
-	y = (self.Parent.Height - self.Height) /2
+	y = (self.Parent.Height - self.Height) / 2
+
+	rect_ := rect.Rect(x-padding, y-padding, self.Width+padding*2, self.Height+padding*2)
 
-	rect_ := rect.Rect(x-padding,y-padding, self.Width+padding*2, self.Height+padding*2)
-	
 	if self.HWND != nil {
-		
-		draw.Rect(self.HWND , &color.Color{255,255,255,255},&rect_,0)
-		
-		rect__ := draw.MidRect(self.Parent.Width/2, self.Parent.Height/2,self.Width,self.Height,Width,Height)
-		
-		dest_rect := rect.Rect(0,0,self.Width,self.Height)
-		
+
+		draw.Rect(self.HWND, &color.Color{255, 255, 255, 255}, &rect_, 0)
+
+		rect__ := draw.MidRect(self.Parent.Width/2, self.Parent.Height/2, self.Width, self.Height, Width, Height)
+
+		dest_rect := rect.Rect(0, 0, self.Width, self.Height)
+
 		surface.Blit(self.HWND, self.CanvasHWND, rect__, &dest_rect)
-		
-		draw.Rect(self.HWND , &color.Color{0,0,0,255},&rect_,1)
-		
+
+		draw.Rect(self.HWND, &color.Color{0, 0, 0, 255}, &rect_, 1)
+
 	}
 
-	
 }
 
 type MainScreen struct {
-  Widget
-	Pages []PageInterface
-	PageMax int
+	Widget
+	Pages     []PageInterface
+	PageMax   int
 	PageIndex int
 
 	MyPageStack *PageStack
@@ -174,71 +173,68 @@ type MainScreen struct {
 	MsgBoxFont  *ttf.Font
 	IconFont    *ttf.Font
 	SkinManager *SkinManager
-	
-  CounterScreen *CounterScreen
-  Closed      bool
-  
-  UIPluginList []*UIPlugin
-  
-  LastKey string
-  LastKeyDown gotime.Time
-}
 
+	CounterScreen *CounterScreen
+	Closed        bool
+
+	UIPluginList []*UIPlugin
+
+	LastKey     string
+	LastKeyDown gotime.Time
+}
 
 func NewMainScreen() *MainScreen {
 	m := &MainScreen{}
-  
-	m.PosY = TitleBar_BarHeight+1
+
+	m.PosY = TitleBar_BarHeight + 1
 	m.Width = Width
 	m.Height = Height - FootBar_BarHeight - TitleBar_BarHeight - 1
 	m.MyPageStack = NewPageStack()
-	
+
 	m.MsgBoxFont = Fonts["veramono20"]
-	m.IconFont   = Fonts["varela15"]
-  m.Closed = false
+	m.IconFont = Fonts["varela15"]
+	m.Closed = false
 	return m
 }
 
 func (self *MainScreen) Init() {
-	self.CanvasHWND = surface.Surface(self.Width,self.Height)
-	
-	self.MsgBox     = NewMessageBox()
+	self.CanvasHWND = surface.Surface(self.Width, self.Height)
+
+	self.MsgBox = NewMessageBox()
 	self.MsgBox.Parent = self
-	self.MsgBox.Init(" ", self.MsgBoxFont, &color.Color{83,83,83,255})
+	self.MsgBox.Init(" ", self.MsgBoxFont, &color.Color{83, 83, 83, 255})
 
 	self.SkinManager = NewSkinManager()
 	self.SkinManager.Init()
 
-  self.CounterScreen = NewCounterScreen()
-  self.CounterScreen.HWND = self.HWND
-  self.CounterScreen.Init()
-  
-  //self.GenList() // load predefined plugin list,ready to be injected ,or ,as a .so for dynamic loading
-  
+	self.CounterScreen = NewCounterScreen()
+	self.CounterScreen.HWND = self.HWND
+	self.CounterScreen.Init()
+
+	//self.GenList() // load predefined plugin list,ready to be injected ,or ,as a .so for dynamic loading
+
 }
 
 func (self *MainScreen) FartherPages() { // right after ReadTheDirIntoPages
 	self.PageMax = len(self.Pages)
 
-	for i:=0;i< self.PageMax; i++ {
+	for i := 0; i < self.PageMax; i++ {
 		self.Pages[i].SetIndex(i)
 		self.Pages[i].SetCanvasHWND(self.CanvasHWND)
 		self.Pages[i].UpdateIconNumbers() // IconNumbers always == len(Pages[i].Icons)
 		self.Pages[i].SetScreen(self)
 		self.Pages[i].Adjust()
-		
+
 		if self.Pages[i].GetIconNumbers() > 1 {
 			self.Pages[i].SetPsIndex(1)
-			self.Pages[i].SetIconIndex( 1 )
+			self.Pages[i].SetIconIndex(1)
 		}
 	}
 
-	self.CurrentPage = self.Pages[ self.PageIndex ]
+	self.CurrentPage = self.Pages[self.PageIndex]
 	self.CurrentPage.SetOnShow(true)
 }
 
-
-
 func (self *MainScreen) CurPage() PageInterface {
 	return self.CurrentPage
 }
@@ -247,28 +243,28 @@ func (self *MainScreen) PushCurPage() {
 	self.MyPageStack.Push(self.CurrentPage)
 }
 
-func (self *MainScreen) SetCurPage( pg PageInterface) {
+func (self *MainScreen) SetCurPage(pg PageInterface) {
 	self.CurrentPage = pg
 	pg.OnLoadCb()
 }
 
-func (self *MainScreen) PushPage( pg PageInterface) {
+func (self *MainScreen) PushPage(pg PageInterface) {
 	self.PushCurPage()
 	self.SetCurPage(pg)
 }
 
-func (self *MainScreen) AppendPage( pg PageInterface ) {
-	self.Pages = append(self.Pages,pg)
+func (self *MainScreen) AppendPage(pg PageInterface) {
+	self.Pages = append(self.Pages, pg)
 }
 
 func (self *MainScreen) ClearCanvas() {
-	surface.Fill(self.CanvasHWND, &color.Color{255,255,255,255} ) 
+	surface.Fill(self.CanvasHWND, &color.Color{255, 255, 255, 255})
 }
 
 func (self *MainScreen) SwapAndShow() {
 	if self.HWND != nil {
-		rect_ := rect.Rect( self.PosX,self.PosY,self.Width,self.Height)
-		surface.Blit(self.HWND,self.CanvasHWND,&rect_, nil)
+		rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
+		surface.Blit(self.HWND, self.CanvasHWND, &rect_, nil)
 	}
 
 	display.Flip()
@@ -276,50 +272,49 @@ func (self *MainScreen) SwapAndShow() {
 
 func (self *MainScreen) ExtraName(name string) string {
 
-	parts := strings.Split(name,"_")
-	if len(parts) >  1 {
+	parts := strings.Split(name, "_")
+	if len(parts) > 1 {
 		return parts[1]
-	}else if len(parts) == 1 {
+	} else if len(parts) == 1 {
 		return parts[0]
-	}else {
+	} else {
 		return name
-	}	
+	}
 }
 
-
 //ExecPackage is all-in-one folder ,Name.sh,Name.png,etc
-func (self *MainScreen) IsExecPackage(dirname string ) bool {
-	files,err := ioutil.ReadDir(dirname)
+func (self *MainScreen) IsExecPackage(dirname string) bool {
+	files, err := ioutil.ReadDir(dirname)
 	if err != nil {
 		log.Fatal(err)
 		return false
 	}
-  
-  bname := filepath.Base(dirname)
-  bname = self.ExtraName(bname)
-  
-  for _,v := range files {
-    if v.Name() == bname+".sh" {
-      return true
-    }
-  }
-  
-  return false
+
+	bname := filepath.Base(dirname)
+	bname = self.ExtraName(bname)
+
+	for _, v := range files {
+		if v.Name() == bname+".sh" {
+			return true
+		}
+	}
+
+	return false
 }
 
-func (self *MainScreen) IsPluginPackage(dirname string ) bool {
+func (self *MainScreen) IsPluginPackage(dirname string) bool {
 	ret := false
-	files,err := ioutil.ReadDir(dirname)
+	files, err := ioutil.ReadDir(dirname)
 	if err != nil {
 		log.Fatal(err)
 		return false
 	}
 
-	for _,f := range files {
+	for _, f := range files {
 		if f.IsDir() {
 			//pass
-		}else {
-			if strings.HasSuffix(f.Name(),Plugin_flag) == true {
+		} else {
+			if strings.HasSuffix(f.Name(), Plugin_flag) == true {
 				ret = true
 				break
 			}
@@ -329,33 +324,33 @@ func (self *MainScreen) IsPluginPackage(dirname string ) bool {
 	return ret
 }
 
-func (self *MainScreen) IsEmulatorPackage(dirname string ) bool {
+func (self *MainScreen) IsEmulatorPackage(dirname string) bool {
 	ret := false
-	files,err := ioutil.ReadDir(dirname)
+	files, err := ioutil.ReadDir(dirname)
 	if err != nil {
 		log.Fatal(err)
 		return false
 	}
 
-	for _,f := range files {
+	for _, f := range files {
 		if f.IsDir() {
 			//pass
-		}else {
-			if strings.HasSuffix(f.Name(),Emulator_flag) == true {
+		} else {
+			if strings.HasSuffix(f.Name(), Emulator_flag) == true {
 				ret = true
 				break
 			}
 		}
 	}
 
-	return ret	
+	return ret
 }
 
 func (self *MainScreen) IsWifiConnectedNow() bool {
-	
-  cli := fmt.Sprintf( "ip -4 addr show %s | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}'",sysgo.WifiDev)
-  out := System(cli)
-	if len(out)<6 {
+
+	cli := fmt.Sprintf("ip -4 addr show %s | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}'", sysgo.WifiDev)
+	out := System(cli)
+	if len(out) < 6 {
 		return false
 	}
 	return true
@@ -363,25 +358,23 @@ func (self *MainScreen) IsWifiConnectedNow() bool {
 
 func (self *MainScreen) GetWirelessIP() string {
 
-  cli := fmt.Sprintf( "ip -4 addr show %s | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}'",sysgo.WifiDev)
-  out := SystemTrim(cli)
+	cli := fmt.Sprintf("ip -4 addr show %s | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}'", sysgo.WifiDev)
+	out := SystemTrim(cli)
 
-	
-  return out	
+	return out
 }
 
-func (self *MainScreen) RunEXE( cmdpath string) {
+func (self *MainScreen) RunEXE(cmdpath string) {
 	self.DrawRun()
 	self.SwapAndShow()
 
-	
 	time.BlockDelay(1000)
 
-	cmdpath = strings.Trim(cmdpath," ")
+	cmdpath = strings.Trim(cmdpath, " ")
 	cmdpath = CmdClean(cmdpath)
-	
-	event.Post(RUNEVT,cmdpath)
-	
+
+	event.Post(RUNEVT, cmdpath)
+
 }
 
 func (self *MainScreen) OnExitCb() {
@@ -399,13 +392,12 @@ func (self *MainScreen) KeyDown(ev *event.Event) {
 	if ev.Data["Key"] == "Space" {
 		self.Draw()
 		self.SwapAndShow()
-	} 
+	}
 
 	self.CurrentPage.KeyDown(ev)
-  self.LastKey = ev.Data["Key"]
-  
-}
+	self.LastKey = ev.Data["Key"]
 
+}
 
 func (self *MainScreen) DrawRun() {
 	self.MsgBox.SetText("Launching....")
@@ -416,14 +408,14 @@ func (self *MainScreen) Draw() {
 	if self.CurrentPage != nil {
 		self.CurrentPage.Draw()
 	}
-	
+
 	if self.TitleBar != nil {
-    //every plugin_init should not do any Draw actions since CurrentPage might be nil at that time
-		self.TitleBar.Draw( self.CurrentPage.GetName())
+		//every plugin_init should not do any Draw actions since CurrentPage might be nil at that time
+		self.TitleBar.Draw(self.CurrentPage.GetName())
 	}
 
 	if self.FootBar != nil {
-		self.FootBar.SetLabelTexts( self.CurrentPage.GetFootMsg())
+		self.FootBar.SetLabelTexts(self.CurrentPage.GetFootMsg())
 		self.FootBar.Draw()
 	}
 }

+ 46 - 48
sysgo/UI/multi_icon_item.go

@@ -1,20 +1,18 @@
 package UI
 
 import (
-  "fmt"
-	"github.com/cuu/gogame/surface"
-	"github.com/cuu/gogame/image"
+	"fmt"
 	"github.com/cuu/gogame/draw"
+	"github.com/cuu/gogame/image"
 	"github.com/cuu/gogame/rect"
+	"github.com/cuu/gogame/surface"
 )
 
-
 type MultiIconItem struct {
 	IconItem
-	
-	IconWidth int
+
+	IconWidth  int
 	IconHeight int
-	
 }
 
 func NewMultiIconItem() *MultiIconItem {
@@ -22,67 +20,67 @@ func NewMultiIconItem() *MultiIconItem {
 	m.IconIndex = 0
 	m.IconWidth = 18
 	m.IconHeight = 18
-	return m 
+	return m
 }
 
-func (self * MultiIconItem) CreateImgSurf() {
+func (self *MultiIconItem) CreateImgSurf() {
 	if self.ImgSurf == nil && self.ImageName != "" {
 		self.ImgSurf = image.Load(self.ImageName)
 	}
 }
 
 func (self *MultiIconItem) DrawTopLeft() {
-  if self.Parent == nil {
-    fmt.Println("Error: MultiIconItem Draw Parent nil")
-    return
-  }
-  
-  parent_x,parent_y := self.Parent.Coord()
-  
-  if self.Label != nil {
-    lab_w,lab_h:= self.Label.Size()
-    if self.Align == ALIGN["VCenter"] {
-      
-      self.Label.NewCoord( self.PosX - lab_w/2 + parent_x, self.PosY + self.Height/2+6 + parent_y)
-    }else if self.Align == 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)
-    rect_ := rect.Rect( self.PosX+parent_x,self.PosY+parent_y, self.Width,self.Height ) // DIFF
-		surface.Blit(self.Parent.GetCanvasHWND(),self.ImgSurf,&rect_,&portion)
-  }
+	if self.Parent == nil {
+		fmt.Println("Error: MultiIconItem Draw Parent nil")
+		return
+	}
+
+	parent_x, parent_y := self.Parent.Coord()
+
+	if self.Label != nil {
+		lab_w, lab_h := self.Label.Size()
+		if self.Align == ALIGN["VCenter"] {
+
+			self.Label.NewCoord(self.PosX-lab_w/2+parent_x, self.PosY+self.Height/2+6+parent_y)
+		} else if self.Align == 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)
+		rect_ := rect.Rect(self.PosX+parent_x, self.PosY+parent_y, self.Width, self.Height) // DIFF
+		surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf, &rect_, &portion)
+	}
 
 }
 
 func (self *MultiIconItem) Draw() {
-  if self.Parent == nil {
-    fmt.Println("Error: MultiIconItem Draw Parent nil")
-    return
-  }  
-	parent_x,parent_y := self.Parent.Coord()
-	
+	if self.Parent == nil {
+		fmt.Println("Error: MultiIconItem 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 == ALIGN["VCenter"] {
-			self.Label.NewCoord( self.PosX - lab_w/2 + parent_x,        self.PosY + self.Height/2+6 + parent_y)
-		}else if self.Align == 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 == 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, Width, Height),&portion)
+			self.ImgSurf, draw.MidRect(self.PosX+parent_x, self.PosY+parent_y,
+				self.Width, self.Height, Width, Height), &portion)
 	}
 }

+ 39 - 42
sysgo/UI/multilabel.go

@@ -2,14 +2,14 @@ package UI
 
 import (
 	"strings"
-	
+
 	"github.com/veandco/go-sdl2/sdl"
 	"github.com/veandco/go-sdl2/ttf"
-	
-	"github.com/cuu/gogame/surface"
-	"github.com/cuu/gogame/rect"
+
 	"github.com/cuu/gogame/color"
 	"github.com/cuu/gogame/font"
+	"github.com/cuu/gogame/rect"
+	"github.com/cuu/gogame/surface"
 )
 
 //MultiLabel is also a LabelInterface
@@ -20,24 +20,24 @@ type MultiLabel struct {
 	Color      *color.Color
 	CanvasHWND *sdl.Surface
 	//TextSurf *sdl.Surface
-	MaxWidth   int
-  Bold       bool
+	MaxWidth int
+	Bold     bool
 }
 
-func NewMultiLabel() *MultiLabel{
+func NewMultiLabel() *MultiLabel {
 	l := &MultiLabel{}
-	l.Color = &color.Color{83,83,83,255}
+	l.Color = &color.Color{83, 83, 83, 255}
 	l.Width = 135
 	l.Height = 100
-  l.Bold = false
+	l.Bold = false
 	return l
 }
 
-func (self *MultiLabel) Init(text string, font_obj *ttf.Font,col *color.Color) {
+func (self *MultiLabel) Init(text string, font_obj *ttf.Font, col *color.Color) {
 	if col != nil {
 		self.Color = col
 	}
-	
+
 	self.Text = text
 	self.FontObj = font_obj
 
@@ -46,12 +46,11 @@ func (self *MultiLabel) Init(text string, font_obj *ttf.Font,col *color.Color) {
 	}
 }
 
-func (self *MultiLabel) SetCanvasHWND( canvas *sdl.Surface) {
+func (self *MultiLabel) SetCanvasHWND(canvas *sdl.Surface) {
 	self.CanvasHWND = canvas
 }
 
-
-func (self *MultiLabel) SetColor(col *color.Color){
+func (self *MultiLabel) SetColor(col *color.Color) {
 	if col != nil {
 		self.Color = col
 	}
@@ -61,14 +60,13 @@ func (self *MultiLabel) GetText() string {
 	return self.Text
 }
 
-
 func (self *MultiLabel) SetText(text string) {
 	self.Text = text
-	
+
 }
 
 func (self *MultiLabel) SetBold(b bool) {
-  self.Bold = b
+	self.Bold = b
 
 }
 
@@ -77,22 +75,22 @@ func (self *MultiLabel) DrawCenter(bold bool) {
 }
 
 func (self *MultiLabel) Draw() {
-	font.SetBold(self.FontObj,self.Bold) // avoing same font tangling set_bold to others
-	self.blit_text(self.CanvasHWND, self.Text,self.PosX,self.PosY,self.FontObj)	
+	font.SetBold(self.FontObj, self.Bold) // avoing same font tangling set_bold to others
+	self.blit_text(self.CanvasHWND, self.Text, self.PosX, self.PosY, self.FontObj)
 }
 
 // difference to Label
-func (self *MultiLabel) blit_text(surf *sdl.Surface,text string, pos_x,pos_y int, fnt *ttf.Font) {
+func (self *MultiLabel) blit_text(surf *sdl.Surface, text string, pos_x, pos_y int, fnt *ttf.Font) {
 	words := make([][]string, 0)
-	temp := strings.Split(text,"\n")
-	for _,v := range temp {
-		t := strings.Split(v," ")
-		words = append(words,t)
+	temp := strings.Split(text, "\n")
+	for _, v := range temp {
+		t := strings.Split(v, " ")
+		words = append(words, t)
 	}
 
-	space,_   := font.Size(fnt," ")
+	space, _ := font.Size(fnt, " ")
 	max_width := self.Width
-	x,y       := pos_x,pos_y
+	x, y := pos_x, pos_y
 
 	row_total_width := 0
 	lines := 0
@@ -101,33 +99,33 @@ func (self *MultiLabel) blit_text(surf *sdl.Surface,text string, pos_x,pos_y int
 	if len(words) > 4 {
 		tmp = words[:4]
 	}
-	
-	for _,line := range tmp {
+
+	for _, line := range tmp {
 		word_height := 0
 		tmp2 := line
 		if len(line) > 12 {
 			tmp2 = line[:12]
 		}
-		
-		for _,word := range tmp2 {
-			word_surface := font.Render(fnt,word,true,self.Color,nil)
-			word_width   := surface.GetWidth(word_surface)
-			word_height   = surface.GetHeight(word_surface)
+
+		for _, word := range tmp2 {
+			word_surface := font.Render(fnt, word, true, self.Color, nil)
+			word_width := surface.GetWidth(word_surface)
+			word_height = surface.GetHeight(word_surface)
 			row_total_width += word_width
 			if row_total_width+space >= max_width {
 				x = pos_x
-				y = y+word_height
+				y = y + word_height
 				row_total_width = word_width
 				if lines == 0 {
 					lines = lines + word_height
-				}else {
+				} else {
 					lines = lines + word_height
-				}	
+				}
 			}
-			rect_ := rect.Rect(x,y,self.Width,self.Height)
-			surface.Blit(surf,word_surface,&rect_,nil)
-      word_surface.Free()
-			x += (word_width+space)	
+			rect_ := rect.Rect(x, y, self.Width, self.Height)
+			surface.Blit(surf, word_surface, &rect_, nil)
+			word_surface.Free()
+			x += (word_width + space)
 		}
 		x = pos_x
 		y += word_height
@@ -135,6 +133,5 @@ func (self *MultiLabel) blit_text(surf *sdl.Surface,text string, pos_x,pos_y int
 	}
 
 	self.Height = lines
-	
-}
 
+}

File diff suppressed because it is too large
+ 248 - 265
sysgo/UI/page.go


+ 27 - 29
sysgo/UI/plugin.go

@@ -21,69 +21,67 @@ func (self *Plugin) GetName() string {
 	return self.Name
 }
 
-func (self *Plugin) Init( screen *MainScreen) {
-	
+func (self *Plugin) Init(screen *MainScreen) {
+
 }
 
+func (self *Plugin) Run(screen *MainScreen) {
 
-func (self *Plugin) Run( screen *MainScreen) {
-	
 }
 
-
 func NewPluginPool() map[string]PluginInterface {
-	pp :=make( map[string]PluginInterface )
+	pp := make(map[string]PluginInterface)
 	return pp
 }
 
-func PluginPoolRegister( pi PluginInterface ) bool {
+func PluginPoolRegister(pi PluginInterface) bool {
 	name := pi.GetName()
-	
-	if _,ok := PluginPool[name]; ok {
+
+	if _, ok := PluginPool[name]; ok {
 		return false
 	}
-	
+
 	PluginPool[name] = pi
 	return true
-	
+
 }
 
-func LoadPlugin( pname string) (*goplugin.Plugin,error) {
+func LoadPlugin(pname string) (*goplugin.Plugin, error) {
 	return goplugin.Open(pname)
 }
 
 func InitPlugin(p *goplugin.Plugin, main_screen *MainScreen) PluginInterface {
-	symAPI,err := p.Lookup("APIOBJ")
+	symAPI, err := p.Lookup("APIOBJ")
 
-	if err!= nil {
-		log.Fatal( "init plugin failed")
+	if err != nil {
+		log.Fatal("init plugin failed")
 		return nil
 	}
 
 	var pi PluginInterface
-	pi,ok := symAPI.(PluginInterface)
+	pi, ok := symAPI.(PluginInterface)
 	if !ok {
 		log.Fatal("unexpected type from module symbol")
 		return nil
 	}
 
 	//PluginPoolRegister(pi)
-	
+
 	pi.Init(main_screen)
 
 	return pi
 }
 
 func RunPlugin(p *goplugin.Plugin, main_screen *MainScreen) {
-	symAPI,err := p.Lookup("APIOBJ")
+	symAPI, err := p.Lookup("APIOBJ")
 
-	if err!= nil {
-		log.Fatal( "init plugin failed")
+	if err != nil {
+		log.Fatal("init plugin failed")
 		return
 	}
 
 	var pi PluginInterface
-	pi,ok := symAPI.(PluginInterface)
+	pi, ok := symAPI.(PluginInterface)
 	if !ok {
 		log.Fatal("unexpected type from module symbol")
 		return
@@ -92,14 +90,14 @@ func RunPlugin(p *goplugin.Plugin, main_screen *MainScreen) {
 }
 
 const (
-  PluginPackage = iota
-  PluginSo
+	PluginPackage = iota
+	PluginSo
 )
 
-type UIPlugin struct{ //Loadable and injectable
-  Type int // 0 == loadable package, 1  == .so 
-  SoFile string
-  FolderName string
-  LabelText  string
-  EmbInterface  PluginInterface
+type UIPlugin struct { //Loadable and injectable
+	Type         int // 0 == loadable package, 1  == .so
+	SoFile       string
+	FolderName   string
+	LabelText    string
+	EmbInterface PluginInterface
 }

+ 32 - 33
sysgo/UI/scroller.go

@@ -2,36 +2,35 @@ package UI
 
 import (
 	"fmt"
-	
+
 	"github.com/veandco/go-sdl2/sdl"
-//	"github.com/veandco/go-sdl2/ttf"
-	
-//	"github.com/cuu/gogame/surface"
-//	"github.com/cuu/gogame/rect"
+	//	"github.com/veandco/go-sdl2/ttf"
+
+	//	"github.com/cuu/gogame/surface"
+	//	"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"
 )
 
-type ListScroller struct{
+type ListScroller struct {
 	Widget
 	MinHeight int
-	Parent PageInterface
-	Color  *color.Color
-	
-	StartX int
-	StartY int
-	EndX   int
-	EndY   int
-	Value  int
+	Parent    PageInterface
+	Color     *color.Color
+
+	StartX     int
+	StartY     int
+	EndX       int
+	EndY       int
+	Value      int
 	CanvasHWND *sdl.Surface
 }
 
-
 func NewListScroller() *ListScroller {
 	l := &ListScroller{}
 	l.Width = 7
-	l.Color = &color.Color{131,199,219,255} // SkinManager().GiveColor('Front')
+	l.Color = &color.Color{131, 199, 219, 255} // SkinManager().GiveColor('Front')
 	return l
 }
 
@@ -41,52 +40,52 @@ func (self *ListScroller) Init() {
 	self.SetCanvasHWND(cav_)
 }
 
-func (self *ListScroller) SetCanvasHWND( canvas *sdl.Surface) {
+func (self *ListScroller) SetCanvasHWND(canvas *sdl.Surface) {
 	self.CanvasHWND = canvas
 }
 
-func (self *ListScroller) AnimateDraw(x2,y2 int) {
-	
+func (self *ListScroller) AnimateDraw(x2, y2 int) {
+
 }
 
 func (self *ListScroller) UpdateSize(bigheight, dirtyheight int) {
-	_,h_ := self.Parent.Size()
-	
-	bodyheight := float64(h_)/float64(bigheight)
+	_, h_ := self.Parent.Size()
+
+	bodyheight := float64(h_) / float64(bigheight)
 	if bodyheight > 1.0 {
 		bodyheight = 1.0
 	}
 
 	margin := 4
 
-	self.Height = int( bodyheight * float64(h_) - float64(margin) )
+	self.Height = int(bodyheight*float64(h_) - float64(margin))
 
 	if self.Height < self.MinHeight {
 		self.Height = self.MinHeight
 	}
 
-	self.StartX = self.Width/2
+	self.StartX = self.Width / 2
 	self.StartY = margin/2 + self.Height/2
 
-	self.EndX = self.Width/2
+	self.EndX = self.Width / 2
 	self.EndY = h_ - margin/2 - self.Height/2
 
-	process  := float64(dirtyheight) / float64(bigheight)
+	process := float64(dirtyheight) / float64(bigheight)
 
-	value := process * float64(self.EndY - self.StartY)
+	value := process * float64(self.EndY-self.StartY)
 
 	self.Value = int(value)
-	
+
 }
 
 func (self *ListScroller) Draw() {
-	w_,h_ := self.Parent.Size()
+	w_, h_ := self.Parent.Size()
 
-	start_rect := draw.MidRect(self.PosX+self.StartX,self.StartY+self.Value,self.Width,self.Height,w_,h_)
+	start_rect := draw.MidRect(self.PosX+self.StartX, self.StartY+self.Value, self.Width, self.Height, w_, h_)
 
 	if self.Width < 1 {
 		fmt.Println("ListScroller width error")
-	}else {
-		draw.AARoundRect(self.CanvasHWND,start_rect,self.Color,3,0,self.Color)
+	} else {
+		draw.AARoundRect(self.CanvasHWND, start_rect, self.Color, 3, 0, self.Color)
 	}
 }

+ 35 - 39
sysgo/UI/skin_manager.go

@@ -1,23 +1,21 @@
 package UI
 
-
 import (
 	"fmt"
-	
+
 	"log"
-	"strings"
 	"strconv"
-	
+	"strings"
+
 	"github.com/go-ini/ini"
-	
+
 	"github.com/cuu/gogame/color"
-	
+
 	"github.com/clockworkpi/LauncherGoDev/sysgo"
 )
 
 type SkinManager struct {
 	Colors map[string]*color.Color
-	
 }
 
 func NewSkinManager() *SkinManager {
@@ -26,61 +24,60 @@ func NewSkinManager() *SkinManager {
 	return s
 }
 
-
 func (self *SkinManager) ConvertToRGB(hexstr string) *color.Color {
 	if len(hexstr) < 7 || string(hexstr[0]) != "#" { // # 00 00 00
 		log.Fatalf("ConvertToRGB hex string format error %s", hexstr)
 		//fmt.Printf("ConvertToRGB hex string format error %s", hexstr)
 		return nil
 	}
-	
-	h := strings.TrimLeft(hexstr,"#")
-
-	r,_ := strconv.ParseInt(h[0:2], 16,0)
-	g,_ := strconv.ParseInt(h[2:4], 16,0)
-	b,_ := strconv.ParseInt(h[4:6], 16,0)
-	
-	col := &color.Color{ uint32(r),uint32(g),uint32(b),255 }
+
+	h := strings.TrimLeft(hexstr, "#")
+
+	r, _ := strconv.ParseInt(h[0:2], 16, 0)
+	g, _ := strconv.ParseInt(h[2:4], 16, 0)
+	b, _ := strconv.ParseInt(h[4:6], 16, 0)
+
+	col := &color.Color{uint32(r), uint32(g), uint32(b), 255}
 	return col
 }
 
-func (self *SkinManager) ChangeSkin( skin_name string ) {
-	
+func (self *SkinManager) ChangeSkin(skin_name string) {
+
 }
 
 func (self *SkinManager) Init() {
 	self.Colors = make(map[string]*color.Color)
 
-	self.Colors["High"] = &color.Color{51,166,255,255}
-	self.Colors["Text"] = &color.Color{83,83,83,255}
-  self.Colors["ReadOnlyText"] = &color.Color{130,130,130,255}
-	self.Colors["Front"] =  &color.Color{131,199,219,255}
-	self.Colors["URL"]   = &color.Color{51,166,255,255}
-	self.Colors["Line"]  =  &color.Color{169,169,169,255}
-	self.Colors["TitleBg"] = &color.Color{228,228,228,255}
-	self.Colors["Active"]  =  &color.Color{175,90,0,255}
-  self.Colors["Disabled"]  =  &color.Color{204,204,204,255}
+	self.Colors["High"] = &color.Color{51, 166, 255, 255}
+	self.Colors["Text"] = &color.Color{83, 83, 83, 255}
+	self.Colors["ReadOnlyText"] = &color.Color{130, 130, 130, 255}
+	self.Colors["Front"] = &color.Color{131, 199, 219, 255}
+	self.Colors["URL"] = &color.Color{51, 166, 255, 255}
+	self.Colors["Line"] = &color.Color{169, 169, 169, 255}
+	self.Colors["TitleBg"] = &color.Color{228, 228, 228, 255}
+	self.Colors["Active"] = &color.Color{175, 90, 0, 255}
+	self.Colors["Disabled"] = &color.Color{204, 204, 204, 255}
 
-	self.Colors["White"]  = &color.Color{255,255,255,255}
-  self.Colors["Black"]  = &color.Color{0,0,0,255}
+	self.Colors["White"] = &color.Color{255, 255, 255, 255}
+	self.Colors["Black"] = &color.Color{0, 0, 0, 255}
 
-	fname := sysgo.SKIN+"/config.ini"
+	fname := sysgo.SKIN + "/config.ini"
 
 	load_opts := ini.LoadOptions{
-		IgnoreInlineComment:true,
+		IgnoreInlineComment: true,
 	}
-	cfg, err := ini.LoadSources(load_opts, fname )
+	cfg, err := ini.LoadSources(load_opts, fname)
 	if err != nil {
 		fmt.Printf("Fail to read file: %v\n", err)
 		return
 	}
-	
+
 	section := cfg.Section("Colors")
 	if section != nil {
 		colour_opts := section.KeyStrings()
-		for _,v := range colour_opts {
+		for _, v := range colour_opts {
 			if _, ok := self.Colors[v]; ok { // has this Color key
-				parsed_color := self.ConvertToRGB( section.Key(v).String() )
+				parsed_color := self.ConvertToRGB(section.Key(v).String())
 				if parsed_color != nil {
 					self.Colors[v] = parsed_color
 				}
@@ -89,13 +86,12 @@ func (self *SkinManager) Init() {
 	}
 }
 
-
 func (self *SkinManager) GiveColor(name string) *color.Color {
 
-	if val,ok := self.Colors[name]; ok {
+	if val, ok := self.Colors[name]; ok {
 		return val
-	}else {
-		return &color.Color{255,0,0,255}
+	} else {
+		return &color.Color{255, 0, 0, 255}
 	}
 }
 

+ 33 - 35
sysgo/UI/slider.go

@@ -2,67 +2,65 @@ package UI
 
 import (
 	//"fmt"
-  //"math"
+	//"math"
 	//"sync"
-	
+
 	"github.com/veandco/go-sdl2/sdl"
 
 	//"github.com/cuu/gogame/surface"
 	//"github.com/cuu/gogame/draw"
-  //"github.com/cuu/gogame/rect"
-  //"github.com/cuu/gogame/font"
+	//"github.com/cuu/gogame/rect"
+	//"github.com/cuu/gogame/font"
 	"github.com/cuu/gogame/event"
-
 	//"github.com/cuu/gogame/transform"
 	//"github.com/clockworkpi/LauncherGoDev/sysgo/easings"
-	
 )
 
 type SliderInterface interface {
-  WidgetInterface
-  
-  Init()
-  SetValue()
-  SetRange(m1,m2 int)
-  SetCanvasHWND( canvas *sdl.Surface)
-  KeyDown(ev *event.Event)
-  Draw()
+	WidgetInterface
+
+	Init()
+	SetValue()
+	SetRange(m1, m2 int)
+	SetCanvasHWND(canvas *sdl.Surface)
+	KeyDown(ev *event.Event)
+	Draw()
 }
 
 type Slider struct {
-  Widget
-  
-  Value int
-  
-  CanvasHWND *sdl.Surface
-  
-  Range [2]int
+	Widget
+
+	Value int
+
+	CanvasHWND *sdl.Surface
+
+	Range [2]int
 }
 
 func NewSlider() *Slider {
-  p := &Slider{}
-  p.Range = [2]int{0,255}
-  p.Value = 0
-  return p
+	p := &Slider{}
+	p.Range = [2]int{0, 255}
+	p.Value = 0
+	return p
 }
 
 func (self *Slider) Init() {
-  self.Value = 0
+	self.Value = 0
 }
 
 func (self *Slider) SetValue(v int) {
-  self.Value = v
+	self.Value = v
 }
 
-func (self *Slider) SetRange(m1 ,m2 int) {
-  if m1 >= m2 {
-    return
-  }
-  self.Range[0] = m1
-  self.Range[1] = m2
+func (self *Slider) SetRange(m1, m2 int) {
+	if m1 >= m2 {
+		return
+	}
+	self.Range[0] = m1
+	self.Range[1] = m2
 }
 
-func (self *Slider)	SetCanvasHWND( canvas *sdl.Surface) {
+func (self *Slider) SetCanvasHWND(canvas *sdl.Surface) {
 	self.CanvasHWND = canvas
 }
 
@@ -70,5 +68,5 @@ func (self *Slider) KeyDown(ev *event.Event) {
 }
 
 func (self *Slider) Draw() {
-  
+
 }

+ 83 - 87
sysgo/UI/sound_patch.go

@@ -1,124 +1,120 @@
 package UI
 
 import (
-  "log"
-  
-	"github.com/itchyny/volume-go"
-	"github.com/cuu/gogame/draw"
-  "github.com/cuu/gogame/rect"
-  //"github.com/cuu/gogame/color"
+	"log"
 
+	"github.com/cuu/gogame/draw"
+	"github.com/cuu/gogame/rect"
+	"github.com/itchyny/volume-go"
+	//"github.com/cuu/gogame/color"
 )
 
 type SoundPatch struct {
-  AboveAllPatch
-  
-  snd_segs [][2]int
-  Needle int
-  Parent *MainScreen
+	AboveAllPatch
+
+	snd_segs [][2]int
+	Needle   int
+	Parent   *MainScreen
 }
 
 func NewSoundPatch() *SoundPatch {
-  p := &SoundPatch{}
-  p.PosX = Width /2
-  p.PosY = Height /2
-  p.Width = 50
-  p.Height = 120
-  
-  p.FontObj = Fonts["veramono20"]
-  p.Color   = MySkinManager.GiveColor("Text")
-  p.ValColor = MySkinManager.GiveColor("URL")
-  
-  p.Icons = make( map[string]IconItemInterface )
-  
-  p.Value = 0
-   
-  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 := &SoundPatch{}
+	p.PosX = Width / 2
+	p.PosY = Height / 2
+	p.Width = 50
+	p.Height = 120
+
+	p.FontObj = Fonts["veramono20"]
+	p.Color = MySkinManager.GiveColor("Text")
+	p.ValColor = MySkinManager.GiveColor("URL")
+
+	p.Icons = make(map[string]IconItemInterface)
+
+	p.Value = 0
 
+	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 *SoundPatch) Init() {
-  self.SetCanvasHWND(self.Parent.CanvasHWND)
+	self.SetCanvasHWND(self.Parent.CanvasHWND)
 }
 
 func (self *SoundPatch) VolumeUp() int {
-  
-  vol, err := volume.GetVolume()
-  if err != nil {
-    log.Printf("SoundPatch VolumeUp get volume failed: %+v", err)
+
+	vol, err := volume.GetVolume()
+	if err != nil {
+		log.Printf("SoundPatch VolumeUp get volume failed: %+v", err)
 		vol = 0
-  }
-  
-	for i,v := range self.snd_segs {
+	}
+
+	for i, v := range self.snd_segs {
 		if vol >= v[0] && vol <= v[1] {
 			self.Needle = i
 			break
 		}
 	}
-  
-  self.Needle += 1
-  
-  if self.Needle > len(self.snd_segs) -1 {
-    self.Needle = len(self.snd_segs) -1
-  }
-  
-  val := self.snd_segs[self.Needle][0] +  (self.snd_segs[self.Needle][1] - self.snd_segs[self.Needle][0])/2
-    
-  volume.SetVolume(val)
-  
-  self.Value = self.snd_segs[self.Needle][1]
-  
-  self.Parent.TitleBar.SetSoundVolume(val)
-  
-  return self.Value
+
+	self.Needle += 1
+
+	if self.Needle > len(self.snd_segs)-1 {
+		self.Needle = len(self.snd_segs) - 1
+	}
+
+	val := self.snd_segs[self.Needle][0] + (self.snd_segs[self.Needle][1]-self.snd_segs[self.Needle][0])/2
+
+	volume.SetVolume(val)
+
+	self.Value = self.snd_segs[self.Needle][1]
+
+	self.Parent.TitleBar.SetSoundVolume(val)
+
+	return self.Value
 }
 
 func (self *SoundPatch) VolumeDown() int {
-  vol, err := volume.GetVolume()
-  if err != nil {
-    log.Printf("SoundPatch VolumeDown get volume failed: %+v\n", err)
+	vol, err := volume.GetVolume()
+	if err != nil {
+		log.Printf("SoundPatch VolumeDown get volume failed: %+v\n", err)
 		vol = 0
-  }
-  
-	for i,v := range self.snd_segs {
+	}
+
+	for i, v := range self.snd_segs {
 		if vol >= v[0] && vol <= v[1] {
 			self.Needle = i
 			break
 		}
 	}
-  
-  self.Needle -= 1
-  
-  if self.Needle < 0 {
-    self.Needle = 0
-  }
-  
-  val := self.snd_segs[self.Needle][0]
-  
-  if val < 0 {
-    val = 0
-  }
-  
-  volume.SetVolume(val)
-  
-  self.Value = val
-  
-  self.Parent.TitleBar.SetSoundVolume(val)
-  
-  return self.Value
+
+	self.Needle -= 1
+
+	if self.Needle < 0 {
+		self.Needle = 0
+	}
+
+	val := self.snd_segs[self.Needle][0]
+
+	if val < 0 {
+		val = 0
+	}
+
+	volume.SetVolume(val)
+
+	self.Value = val
+
+	self.Parent.TitleBar.SetSoundVolume(val)
+
+	return self.Value
 
 }
 
 func (self *SoundPatch) Draw() {
 
-  for i:=0;i< (self.Needle+1);i++ {
-    vol_rect := rect.Rect(80+i*20, self.Height/2+20,10, 40)
-    draw.AARoundRect(self.CanvasHWND,&vol_rect,MySkinManager.GiveColor("Front"),3,0,MySkinManager.GiveColor("Front"))
-  }
+	for i := 0; i < (self.Needle + 1); i++ {
+		vol_rect := rect.Rect(80+i*20, self.Height/2+20, 10, 40)
+		draw.AARoundRect(self.CanvasHWND, &vol_rect, MySkinManager.GiveColor("Front"), 3, 0, MySkinManager.GiveColor("Front"))
+	}
 }
-

+ 19 - 25
sysgo/UI/text_item.go

@@ -1,44 +1,39 @@
 package UI
 
 import (
-	
 	"github.com/veandco/go-sdl2/ttf"
-	
-	"github.com/cuu/gogame/surface"
+
 	"github.com/cuu/gogame/color"
-	"github.com/cuu/gogame/font"
 	"github.com/cuu/gogame/draw"
-	
+	"github.com/cuu/gogame/font"
+	"github.com/cuu/gogame/surface"
 )
 
-type TextItemInterface interface{
-  
-  IconItemInterface
-  
+type TextItemInterface interface {
+	IconItemInterface
+
 	GetBold() bool
 	SetBold(bold bool)
 	GetStr() string
-
 }
 
-
 type TextItem struct {
 	IconItem
-	Str string
-	Color *color.Color
+	Str     string
+	Color   *color.Color
 	FontObj *ttf.Font
-	Bold bool
+	Bold    bool
 }
 
 func NewTextItem() *TextItem {
 	p := &TextItem{}
-  
+
 	p.Align = ALIGN["VCenter"]
-    
-	p.Color = &color.Color{83,83,83,255}
+
+	p.Color = &color.Color{83, 83, 83, 255}
 	p.MyType = ICON_TYPES["LETTER"]
-	p.Bold  = false
-	
+	p.Bold = false
+
 	return p
 }
 
@@ -55,20 +50,19 @@ func (self *TextItem) GetStr() string {
 }
 
 func (self *TextItem) Draw() {
-	font.SetBold(self.FontObj,self.Bold)
+	font.SetBold(self.FontObj, self.Bold)
 
-	my_text := font.Render(self.FontObj,self.Str,true,self.Color,nil)
+	my_text := font.Render(self.FontObj, self.Str, true, self.Color, nil)
 
 	if surface.GetWidth(my_text) != self.Width {
 		self.Width = surface.GetWidth(my_text)
 	}
-	
+
 	if surface.GetHeight(my_text) != self.Height {
 		self.Height = surface.GetHeight(my_text)
 	}
 
-
-	rect_ := draw.MidRect(self.PosX,self.PosY,self.Width,self.Height,Width,Height)
-	surface.Blit(self.Parent.GetCanvasHWND(),my_text,rect_,nil)
+	rect_ := draw.MidRect(self.PosX, self.PosY, self.Width, self.Height, Width, Height)
+	surface.Blit(self.Parent.GetCanvasHWND(), my_text, rect_, nil)
 	my_text.Free()
 }

+ 69 - 71
sysgo/UI/textarea.go

@@ -3,29 +3,29 @@ package UI
 import (
 	"fmt"
 	"strings"
-	
+
 	"github.com/veandco/go-sdl2/sdl"
 	"github.com/veandco/go-sdl2/ttf"
 
-	"github.com/cuu/gogame/surface"
 	"github.com/cuu/gogame/color"
 	"github.com/cuu/gogame/draw"
 	"github.com/cuu/gogame/font"
 	"github.com/cuu/gogame/rect"
+	"github.com/cuu/gogame/surface"
 )
 
 type Textarea struct {
 	Widget
 	BackgroundColor *color.Color
-	CanvasHWND *sdl.Surface
-	MyWords []string
-	BlitWords []string
-	FontObj *ttf.Font
-	LineNumber int
-	TextLimit int
-	TextFull bool
-	TextIndex int
-	BlitIndex int
+	CanvasHWND      *sdl.Surface
+	MyWords         []string
+	BlitWords       []string
+	FontObj         *ttf.Font
+	LineNumber      int
+	TextLimit       int
+	TextFull        bool
+	TextIndex       int
+	BlitIndex       int
 }
 
 func NewTextarea() *Textarea {
@@ -34,11 +34,11 @@ func NewTextarea() *Textarea {
 	p.TextLimit = 63
 	p.TextFull = false
 
-	p.MyWords = make([]string,0)
-	p.BlitWords = make([]string,0)
+	p.MyWords = make([]string, 0)
+	p.BlitWords = make([]string, 0)
+
+	p.BackgroundColor = &color.Color{228, 228, 228, 255}
 
-	p.BackgroundColor = &color.Color{228,228,228,255}
-	
 	return p
 }
 
@@ -58,7 +58,7 @@ func (self *Textarea) AddTextIndex() {
 	self.TextIndex += 1
 	if self.TextIndex > len(self.MyWords) {
 		self.TextIndex = len(self.MyWords)
-	}	
+	}
 }
 
 func (self *Textarea) ResetMyWords() {
@@ -70,84 +70,82 @@ func (self *Textarea) RemoveFromLastText() []string {
 	if len(self.MyWords) > 0 {
 		self.SubTextIndex()
 		if self.TextIndex < len(self.MyWords) {
-			self.MyWords = append(self.MyWords[:self.TextIndex],self.MyWords[(self.TextIndex+1):]...)
+			self.MyWords = append(self.MyWords[:self.TextIndex], self.MyWords[(self.TextIndex+1):]...)
 		}
 	}
 
 	return self.MyWords
 }
 
-
-func (self *Textarea) AppendText( alphabet string) {
+func (self *Textarea) AppendText(alphabet string) {
 	self.AppendAndBlitText(alphabet)
 }
 
 func (self *Textarea) AppendAndBlitText(alphabet string) {
 	if self.TextFull == false {
-		
+
 		if self.TextIndex <= len(self.MyWords) {
 			self.MyWords = append(self.MyWords[:self.TextIndex],
-				append([]string{alphabet},self.MyWords[self.TextIndex:]...)...)
-			
+				append([]string{alphabet}, self.MyWords[self.TextIndex:]...)...)
+
 			self.BlitText()
 			self.AddTextIndex()
 		}
-		
-	}else {
-		fmt.Printf("is Full %s\n",strings.Join(self.MyWords,""))
+
+	} else {
+		fmt.Printf("is Full %s\n", strings.Join(self.MyWords, ""))
 	}
-	
+
 }
 
 func (self *Textarea) BuildBlitText() {
-	blit_rows := make([][]string,0)
-  blit_rows = append(blit_rows,[]string{})
-  
-	w         := 0
-//	xmargin   := 5
-	endmargin :=15
+	blit_rows := make([][]string, 0)
+	blit_rows = append(blit_rows, []string{})
+
+	w := 0
+	//	xmargin   := 5
+	endmargin := 15
 	linenumber := 0
 	cursor_row := 0
 
-	
-	for i,v :=  range self.MyWords {
-		t := font.Render(self.FontObj,v,true,&color.Color{8,135,174,255},nil)
+	for i, v := range self.MyWords {
+		t := font.Render(self.FontObj, v, true, &color.Color{8, 135, 174, 255}, nil)
 		t_width := surface.GetWidth(t)
-		w+=t_width
+		w += t_width
 
-		blit_rows[linenumber] = append(blit_rows[linenumber],v)
+		blit_rows[linenumber] = append(blit_rows[linenumber], v)
 
-		if i == self.TextIndex - 1 {
+		if i == self.TextIndex-1 {
 			cursor_row = linenumber
 		}
 
-		if w + t_width >= self.Width - endmargin {
+		if w+t_width >= self.Width-endmargin {
 			w = 0
 			linenumber += 1
-			blit_rows = append(blit_rows,[]string{})
+			blit_rows = append(blit_rows, []string{})
 		}
-    t.Free()
+		t.Free()
 	}
 
 	if len(blit_rows) == 1 {
 		self.BlitWords = blit_rows[0]
 		self.BlitIndex = self.TextIndex
-	}else if len(blit_rows) == 2 || cursor_row < 2 {
+	} else if len(blit_rows) == 2 || cursor_row < 2 {
 		self.BlitWords = append(blit_rows[0], blit_rows[1]...)
 		self.BlitIndex = self.TextIndex
-		
-	}else {
+
+	} else {
 		self.BlitWords = append(blit_rows[cursor_row-1], blit_rows[cursor_row]...)
 		self.BlitIndex = self.TextIndex
 
-		for i,v := range blit_rows {
-			if i == cursor_row - 1 {
+		for i, v := range blit_rows {
+			if i == cursor_row-1 {
 				break
 			}
 			self.BlitIndex -= len(v)
 		}
 	}
-	
+
 }
 
 func (self *Textarea) BlitText() {
@@ -165,23 +163,23 @@ func (self *Textarea) BlitText() {
 
 	if len(self.MyWords) > self.TextLimit {
 		self.TextFull = true
-	}else {
+	} else {
 		self.TextFull = false
 	}
 
-	for _,v := range self.BlitWords {
-		t := font.Render(self.FontObj,v,true,&color.Color{8,135,174,255},nil)
+	for _, v := range self.BlitWords {
+		t := font.Render(self.FontObj, v, true, &color.Color{8, 135, 174, 255}, nil)
 		w += surface.GetWidth(t)
 
-		if w >= self.Width - endmargin && linenumber == 0 {
+		if w >= self.Width-endmargin && linenumber == 0 {
 			linenumber += 1
 			x = self.PosX + xmargin
-			y = self.PosY + surface.GetHeight(t) * linenumber
+			y = self.PosY + surface.GetHeight(t)*linenumber
 			w = 0
 		}
 
-		rect_ := rect.Rect(x,y,0,0)
-		surface.Blit(self.CanvasHWND,t,&rect_,nil)
+		rect_ := rect.Rect(x, y, 0, 0)
+		surface.Blit(self.CanvasHWND, t, &rect_, nil)
 		x += surface.GetWidth(t)
 		t.Free()
 	}
@@ -191,42 +189,42 @@ func (self *Textarea) Cursor() {
 	w := 0
 	xmargin := 5
 	endmargin := 15
-	x := self.PosX+xmargin
+	x := self.PosX + xmargin
 	y := self.PosY
 	linenumber := 0
 
-	for _,v := range self.BlitWords[:self.BlitIndex] {
-		t := font.Render(self.FontObj,v,true,&color.Color{8,135,174,255},nil)
+	for _, v := range self.BlitWords[:self.BlitIndex] {
+		t := font.Render(self.FontObj, v, true, &color.Color{8, 135, 174, 255}, nil)
 		w += surface.GetWidth(t)
 
-		if w >= self.Width - endmargin && linenumber == 0 {
+		if w >= self.Width-endmargin && linenumber == 0 {
 			x = self.PosX + xmargin
 			y = self.PosY + surface.GetHeight(t)
 			w = 0
-			linenumber +=1
+			linenumber += 1
 		}
 
-		if w >= self.Width - endmargin*3 && linenumber > 0 {
+		if w >= self.Width-endmargin*3 && linenumber > 0 {
 			x += surface.GetWidth(t)
 			break
 		}
 		x += surface.GetWidth(t)
-    t.Free()
+		t.Free()
 	}
 
-	c_t := font.Render(self.FontObj,"_",true,&color.Color{0,0,0,255},nil)
-	rect_ := rect.Rect(x+1,y-2,0,0)
-	surface.Blit(self.CanvasHWND,c_t,&rect_,nil)
-  c_t.Free()
+	c_t := font.Render(self.FontObj, "_", true, &color.Color{0, 0, 0, 255}, nil)
+	rect_ := rect.Rect(x+1, y-2, 0, 0)
+	surface.Blit(self.CanvasHWND, c_t, &rect_, nil)
+	c_t.Free()
 }
 
 func (self *Textarea) Draw() {
-	
-	rect_:= rect.Rect(self.PosX,self.PosY,self.Width,self.Height)
-	
-  draw.AARoundRect(self.CanvasHWND,&rect_,self.BackgroundColor,4,0,self.BackgroundColor)
-	
+
+	rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
+
+	draw.AARoundRect(self.CanvasHWND, &rect_, self.BackgroundColor, 4, 0, self.BackgroundColor)
+
 	self.BlitText()
 	self.Cursor()
-	
+
 }

+ 249 - 260
sysgo/UI/title_bar.go

@@ -1,33 +1,30 @@
 package UI
 
 import (
+	"bufio"
 	"fmt"
-	"os"
+	"io/ioutil"
 	"log"
+	"os"
+	"os/exec"
 	"strconv"
-	"bufio"
 	"strings"
-    "os/exec"
-    "io/ioutil"
 	gotime "time"
-	
+
 	"github.com/veandco/go-sdl2/sdl"
 	"github.com/veandco/go-sdl2/ttf"
-	
-	"github.com/cuu/gogame/surface"
-	"github.com/cuu/gogame/rect"
-	"github.com/cuu/gogame/font"
+
 	"github.com/cuu/gogame/draw"
+	"github.com/cuu/gogame/font"
+	"github.com/cuu/gogame/rect"
+	"github.com/cuu/gogame/surface"
 	"github.com/itchyny/volume-go"
-	
+
 	"github.com/vjeantet/jodaTime"
-	
-	"github.com/clockworkpi/LauncherGoDev/sysgo"
 
-	
+	"github.com/clockworkpi/LauncherGoDev/sysgo"
 )
 
-
 var TitleBar_BarHeight = 24
 
 type TitleBarIconItem struct {
@@ -45,7 +42,7 @@ func NewTitleBarIconItem() *TitleBarIconItem {
 
 }
 
-func (self *TitleBarIconItem) Adjust(x,y,w,h,at int) {
+func (self *TitleBarIconItem) Adjust(x, y, w, h, at int) {
 	self.PosX = x
 	self.PosY = y
 	self.Width = w
@@ -57,62 +54,60 @@ func (self *TitleBarIconItem) Adjust(x,y,w,h,at int) {
 	}
 
 	self.CreateImgSurf()
-//	self.AdjustLinkPage()
-	
+	//	self.AdjustLinkPage()
+
 }
 
 func (self *TitleBarIconItem) Draw() {
-	parent_x,parent_y := self.Parent.PosX,self.Parent.PosY
-	
+	parent_x, parent_y := self.Parent.PosX, self.Parent.PosY
+
 	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 == ALIGN["VCenter"] {
-			self.Label.NewCoord( self.PosX - lab_w/2 + parent_x, self.PosY + self.Height/2+6 + parent_y)
-		}else if self.Align == 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 == 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.CanvasHWND,
-			self.ImgSurf,draw.MidRect(self.PosX + parent_x, self.PosY + parent_y,
-			self.Width,self.Height, Width, Height),&portion)
+			self.ImgSurf, draw.MidRect(self.PosX+parent_x, self.PosY+parent_y,
+				self.Width, self.Height, Width, Height), &portion)
 	}
 }
 
-
 type TitleBar struct {
-  Widget
-  BarHeight int
-  LOffset int
-  ROffset int
-  Icons map[string]IconItemInterface
-  IconWidth int
-  IconHeight int 
-  BorderWidth int
-  CanvasHWND *sdl.Surface
-  HWND       *sdl.Surface
-  Title string
-  
-  InLowBackLight int
-  InAirPlaneMode bool
-  
-  SkinManager *SkinManager //set by MainScreen
-	
-  icon_base_path string /// SkinMap("gameshell/titlebar_icons/")
-  
-  MyTimeLocation *gotime.Location
-  
-  TitleFont *ttf.Font
-  TimeFont  *ttf.Font
-}
+	Widget
+	BarHeight   int
+	LOffset     int
+	ROffset     int
+	Icons       map[string]IconItemInterface
+	IconWidth   int
+	IconHeight  int
+	BorderWidth int
+	CanvasHWND  *sdl.Surface
+	HWND        *sdl.Surface
+	Title       string
+
+	InLowBackLight int
+	InAirPlaneMode bool
+
+	SkinManager *SkinManager //set by MainScreen
 
+	icon_base_path string /// SkinMap("gameshell/titlebar_icons/")
+
+	MyTimeLocation *gotime.Location
+
+	TitleFont *ttf.Font
+	TimeFont  *ttf.Font
+}
 
 func NewTitleBar() *TitleBar {
 	t := &TitleBar{}
@@ -129,58 +124,58 @@ func NewTitleBar() *TitleBar {
 
 	t.LOffset = 3
 	t.ROffset = 3
-	
+
 	t.Icons = make(map[string]IconItemInterface)
-	
-	t.icon_base_path  = SkinMap("sysgo/gameshell/titlebar_icons/")
+
+	t.icon_base_path = SkinMap("sysgo/gameshell/titlebar_icons/")
 
 	t.TitleFont = Fonts["varela16"]
-	t.TimeFont  = Fonts["varela12"]
-  
-  t.InLowBackLight = -1
+	t.TimeFont = Fonts["varela12"]
+
+	t.InLowBackLight = -1
 	return t
-	
+
 }
 
 func (self *TitleBar) RoundRobinCheck() {
 	for {
-    
-    if self.InLowBackLight < 0 {
-      self.CheckBatteryStat()
-      self.CheckBluetooth()
-      self.UpdateWifiStrength()
-      SwapAndShow()
-      
-    }else if self.InLowBackLight >= 0 {
-      self.InLowBackLight +=1
-      
-      if self.InLowBackLight > 10 {
-        self.CheckBatteryStat()
-        self.CheckBluetooth()
-        self.UpdateWifiStrength()
-        
-        self.InLowBackLight = 0 // reset
-      }
-          
-    }
-
-    gotime.Sleep(3000 * gotime.Millisecond)
-    
-  }
+
+		if self.InLowBackLight < 0 {
+			self.CheckBatteryStat()
+			self.CheckBluetooth()
+			self.UpdateWifiStrength()
+			SwapAndShow()
+
+		} else if self.InLowBackLight >= 0 {
+			self.InLowBackLight += 1
+
+			if self.InLowBackLight > 10 {
+				self.CheckBatteryStat()
+				self.CheckBluetooth()
+				self.UpdateWifiStrength()
+
+				self.InLowBackLight = 0 // reset
+			}
+
+		}
+
+		gotime.Sleep(3000 * gotime.Millisecond)
+
+	}
 }
 
 func (self *TitleBar) IsWifiConnectedNow() bool {
-  cli := fmt.Sprintf( "ip -4 addr show %s | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}'",sysgo.WifiDev)
-  out := System(cli)
-  if(len(out) > 7) {
-    if strings.Contains(out,"not") {
-      return false
-    }else {
-      return true
-    }
-  }
-  
-  return false
+	cli := fmt.Sprintf("ip -4 addr show %s | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}'", sysgo.WifiDev)
+	out := System(cli)
+	if len(out) > 7 {
+		if strings.Contains(out, "not") {
+			return false
+		} else {
+			return true
+		}
+	}
+
+	return false
 
 }
 
@@ -189,51 +184,51 @@ func (self *TitleBar) UpdateWifiStrength() {
 }
 
 func (t *TitleBar) GetWifiStrength() int {
-    qua := 0
-    cli := fmt.Sprintf("iwconfig %s | grep Signal | /usr/bin/awk '{print $4}' | /usr/bin/cut -d'=' -f2",sysgo.WifiDev)
-    out := System(cli)
-    if(len(out) > 2) {
-      if strings.Contains(out,"No") == false {
-				out = strings.TrimSuffix(out, "\n")
-        stren,err := strconv.ParseInt(out, 10, 0)
-        if err == nil {
-          qua = 2 * (int(stren) + 100)
-        }else {
-					fmt.Println(err)
-				}
-      }
-    }
-
-	segs := [][]int{ []int{-2,-1}, []int{0,25}, []int{25,50}, []int{50,75},[]int{75,100}}
-	stren_number :=  qua
+	qua := 0
+	cli := fmt.Sprintf("iwconfig %s | grep Signal | /usr/bin/awk '{print $4}' | /usr/bin/cut -d'=' -f2", sysgo.WifiDev)
+	out := System(cli)
+	if len(out) > 2 {
+		if strings.Contains(out, "No") == false {
+			out = strings.TrimSuffix(out, "\n")
+			stren, err := strconv.ParseInt(out, 10, 0)
+			if err == nil {
+				qua = 2 * (int(stren) + 100)
+			} else {
+				fmt.Println(err)
+			}
+		}
+	}
+
+	segs := [][]int{[]int{-2, -1}, []int{0, 25}, []int{25, 50}, []int{50, 75}, []int{75, 100}}
+	stren_number := qua
 	ge := 0
 	if stren_number == 0 {
 		return ge
 	}
-	
-	for i,v := range segs {
+
+	for i, v := range segs {
 		if stren_number >= v[0] && stren_number <= v[1] {
 			ge = i
 			break
 		}
 	}
 
-	return ge	
+	return ge
 }
 
 func (self *TitleBar) SyncSoundVolume() {
-	
-  vol, err := volume.GetVolume()
-  if err != nil {
-    log.Printf("TitleBar SyncSoundVolume get volume failed: %+v\n", err)
+
+	vol, err := volume.GetVolume()
+	if err != nil {
+		log.Printf("TitleBar SyncSoundVolume get volume failed: %+v\n", err)
 		vol = 0
-  }
-  fmt.Printf("TitleBar SyncSoundVolume current volume: %d\n", vol)
+	}
+	fmt.Printf("TitleBar SyncSoundVolume current volume: %d\n", vol)
 
-	snd_segs := [][]int{ []int{0,10}, []int{10,30}, []int{30,70},[]int{70,100} }
+	snd_segs := [][]int{[]int{0, 10}, []int{10, 30}, []int{30, 70}, []int{70, 100}}
 	ge := 0
 
-	for i,v := range snd_segs {
+	for i, v := range snd_segs {
 		if vol >= v[0] && vol <= v[1] {
 			ge = i
 			break
@@ -242,16 +237,16 @@ func (self *TitleBar) SyncSoundVolume() {
 
 	self.Icons["soundvolume"].SetIconIndex(ge)
 	self.Icons["sound"] = self.Icons["soundvolume"]
-	// 
+	//
 }
 
 // for outside widget to update sound icon
 func (self *TitleBar) SetSoundVolume(vol int) {
-  
-	snd_segs := [][]int{ []int{0,10}, []int{10,30}, []int{30,70},[]int{70,100} }
+
+	snd_segs := [][]int{[]int{0, 10}, []int{10, 30}, []int{30, 70}, []int{70, 100}}
 	ge := 0
 
-	for i,v := range snd_segs {
+	for i, v := range snd_segs {
 		if vol >= v[0] && vol <= v[1] {
 			ge = i
 			break
@@ -259,19 +254,19 @@ func (self *TitleBar) SetSoundVolume(vol int) {
 	}
 
 	self.Icons["soundvolume"].SetIconIndex(ge)
-	self.Icons["sound"] = self.Icons["soundvolume"]  
+	self.Icons["sound"] = self.Icons["soundvolume"]
 
 }
 
 func (self *TitleBar) CheckBatteryStat() {
-	bat_segs:= [][]int{[]int{0,6},[]int{7,15},[]int{16,20},[]int{21,30},[]int{31,50},[]int{51,60},[]int{61,80},[]int{81,90},[]int{91,100}}
-	
-  if FileExists(sysgo.Battery) == false {
-    self.Icons["battery"] = self.Icons["battery_unknown"]
-    return
-  }
-  
-	file, err := os.Open( sysgo.Battery )
+	bat_segs := [][]int{[]int{0, 6}, []int{7, 15}, []int{16, 20}, []int{21, 30}, []int{31, 50}, []int{51, 60}, []int{61, 80}, []int{81, 90}, []int{91, 100}}
+
+	if FileExists(sysgo.Battery) == false {
+		self.Icons["battery"] = self.Icons["battery_unknown"]
+		return
+	}
+
+	file, err := os.Open(sysgo.Battery)
 	if err != nil {
 		fmt.Println("Could not open file ", sysgo.Battery)
 		self.Icons["battery"] = self.Icons["battery_unknown"]
@@ -281,30 +276,30 @@ func (self *TitleBar) CheckBatteryStat() {
 	defer file.Close()
 
 	bat_uevent := make(map[string]string)
-	
-  scanner := bufio.NewScanner(file)
-	scanner.Split(bufio.ScanLines) 
+
+	scanner := bufio.NewScanner(file)
+	scanner.Split(bufio.ScanLines)
 
 	for scanner.Scan() {
 		line := scanner.Text()
-		line = strings.Trim(line," ")
-		pis := strings.Split(line,"=")
+		line = strings.Trim(line, " ")
+		pis := strings.Split(line, "=")
 		if len(pis) > 1 {
-			bat_uevent[ pis[0] ] = pis[1]
+			bat_uevent[pis[0]] = pis[1]
 		}
 	}
 
 	cur_cap := 0
-	
+
 	if val, ok := bat_uevent["POWER_SUPPLY_CAPACITY"]; ok {
-		cur_cap,_ = strconv.Atoi(val)
-	}else {
+		cur_cap, _ = strconv.Atoi(val)
+	} else {
 		cur_cap = 0
 	}
 
 	cap_ge := 0
 
-	for i,v := range bat_segs {
+	for i, v := range bat_segs {
 		if cur_cap >= v[0] && cur_cap <= v[1] {
 			cap_ge = i
 			break
@@ -315,78 +310,78 @@ func (self *TitleBar) CheckBatteryStat() {
 		if val == "Charging" {
 			self.Icons["battery_charging"].SetIconIndex(cap_ge)
 			self.Icons["battery"] = self.Icons["battery_charging"]
-		}else {
+		} else {
 			self.Icons["battery_discharging"].SetIconIndex(cap_ge)
-			self.Icons["battery"] = self.Icons["battery_discharging"]	
+			self.Icons["battery"] = self.Icons["battery_discharging"]
 		}
 	}
-	
+
 }
 
-func (self *TitleBar) SetBatteryStat( bat int) {
-  
+func (self *TitleBar) SetBatteryStat(bat int) {
+
 }
 
 func (self *TitleBar) CheckBluetooth() {
 
-  out := System("hcitool dev | grep hci0 |cut -f3")
-  
-  if len(out) < 17 {
-    fmt.Println("Titlebar CheckBluetooth: no bluetooth",out)
-    self.Icons["bluetooth"].SetIconIndex(2)
-    return
-  }else {
-    out  = System("sudo rfkill list | grep hci0 -A 2 | grep yes")
-    if len(out) > 10 {
-      self.Icons["bluetooth"].SetIconIndex(1)
-      return
-    }
-  }
-  
-  self.Icons["bluetooth"].SetIconIndex(0)
-  
+	out := System("hcitool dev | grep hci0 |cut -f3")
+
+	if len(out) < 17 {
+		fmt.Println("Titlebar CheckBluetooth: no bluetooth", out)
+		self.Icons["bluetooth"].SetIconIndex(2)
+		return
+	} else {
+		out = System("sudo rfkill list | grep hci0 -A 2 | grep yes")
+		if len(out) > 10 {
+			self.Icons["bluetooth"].SetIconIndex(1)
+			return
+		}
+	}
+
+	self.Icons["bluetooth"].SetIconIndex(0)
+
 }
 
 func (self *TitleBar) Init(main_screen *MainScreen) {
 
 	start_x := 0
 
-	self.CanvasHWND = surface.Surface(self.Width,self.Height)
+	self.CanvasHWND = surface.Surface(self.Width, self.Height)
 	self.HWND = main_screen.HWND
 	self.SkinManager = main_screen.SkinManager
-	
+
 	icon_wifi_status := NewTitleBarIconItem()
 
 	icon_wifi_status.MyType = ICON_TYPES["STAT"]
-	icon_wifi_status.ImageName = self.icon_base_path+"wifi.png"
+	icon_wifi_status.ImageName = self.icon_base_path + "wifi.png"
 	icon_wifi_status.Parent = self
 
-	icon_wifi_status.Adjust(start_x+self.IconWidth+5,self.IconHeight/2+(self.BarHeight-self.IconHeight)/2,self.IconWidth,self.IconHeight,0)
+	icon_wifi_status.Adjust(start_x+self.IconWidth+5, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2, self.IconWidth, self.IconHeight, 0)
 
 	self.Icons["wifistatus"] = icon_wifi_status
 
 	battery_charging := NewTitleBarIconItem()
 	battery_charging.MyType = ICON_TYPES["STAT"]
 	battery_charging.Parent = self
-	battery_charging.ImageName = self.icon_base_path+"withcharging.png"
-	battery_charging.Adjust(start_x+self.IconWidth+self.IconWidth+8,self.IconHeight/2+(self.BarHeight-self.IconHeight)/2,self.IconWidth,self.IconHeight,0)
+	battery_charging.ImageName = self.icon_base_path + "withcharging.png"
+	battery_charging.Adjust(start_x+self.IconWidth+self.IconWidth+8, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2, self.IconWidth, self.IconHeight, 0)
 
 	self.Icons["battery_charging"] = battery_charging
 
 	battery_discharging := NewTitleBarIconItem()
 	battery_discharging.MyType = ICON_TYPES["STAT"]
 	battery_discharging.Parent = self
-	battery_discharging.ImageName = self.icon_base_path+"without_charging.png"
-	battery_discharging.Adjust(start_x+self.IconWidth+self.IconWidth+8,self.IconHeight/2+(self.BarHeight-self.IconHeight)/2,self.IconWidth,self.IconHeight,0)
+	battery_discharging.ImageName = self.icon_base_path + "without_charging.png"
+	battery_discharging.Adjust(start_x+self.IconWidth+self.IconWidth+8, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2, self.IconWidth, self.IconHeight, 0)
 
 	self.Icons["battery_discharging"] = battery_discharging
 
-	battery_unknown  := NewTitleBarIconItem()
+	battery_unknown := NewTitleBarIconItem()
 	battery_unknown.MyType = ICON_TYPES["STAT"]
 	battery_unknown.Parent = self
-	battery_unknown.ImageName = self.icon_base_path+"battery_unknown.png"
-	battery_unknown.Adjust(start_x+self.IconWidth+self.IconWidth+8,self.IconHeight/2+(self.BarHeight-self.IconHeight)/2,self.IconWidth,self.IconHeight,0)
-	
+	battery_unknown.ImageName = self.icon_base_path + "battery_unknown.png"
+	battery_unknown.Adjust(start_x+self.IconWidth+self.IconWidth+8, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2, self.IconWidth, self.IconHeight, 0)
+
 	self.Icons["battery_unknown"] = battery_unknown
 
 	self.CheckBatteryStat()
@@ -394,117 +389,114 @@ func (self *TitleBar) Init(main_screen *MainScreen) {
 	sound_volume := NewTitleBarIconItem()
 	sound_volume.MyType = ICON_TYPES["STAT"]
 	sound_volume.Parent = self
-	sound_volume.ImageName = self.icon_base_path+"soundvolume.png"
-	sound_volume.Adjust(start_x+self.IconWidth+self.IconWidth+8,self.IconHeight/2+(self.BarHeight-self.IconHeight)/2,self.IconWidth,self.IconHeight,0)
+	sound_volume.ImageName = self.icon_base_path + "soundvolume.png"
+	sound_volume.Adjust(start_x+self.IconWidth+self.IconWidth+8, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2, self.IconWidth, self.IconHeight, 0)
 
 	self.Icons["soundvolume"] = sound_volume
 
 	self.SyncSoundVolume()
 
-  bluetooth   := NewTitleBarIconItem()  
-  bluetooth.MyType = ICON_TYPES["STAT"]
-  bluetooth.Parent = self
-  bluetooth.ImageName = self.icon_base_path+"bluetooth.png"
-  bluetooth.Adjust(start_x+self.IconWidth+self.IconWidth+8,self.IconHeight/2+(self.BarHeight-self.IconHeight)/2,self.IconWidth,self.IconHeight,0)  
-        
-  self.Icons["bluetooth"] = bluetooth
-  self.CheckBluetooth()
+	bluetooth := NewTitleBarIconItem()
+	bluetooth.MyType = ICON_TYPES["STAT"]
+	bluetooth.Parent = self
+	bluetooth.ImageName = self.icon_base_path + "bluetooth.png"
+	bluetooth.Adjust(start_x+self.IconWidth+self.IconWidth+8, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2, self.IconWidth, self.IconHeight, 0)
 
+	self.Icons["bluetooth"] = bluetooth
+	self.CheckBluetooth()
 
 	round_corners := NewTitleBarIconItem()
 	round_corners.IconWidth = 10
 	round_corners.IconHeight = 10
-	
+
 	round_corners.MyType = ICON_TYPES["STAT"]
 	round_corners.Parent = self
 	round_corners.ImgSurf = MyIconPool.GetImgSurf("roundcorners")
-	round_corners.Adjust(0,0,10,10,0)
-	
+	round_corners.Adjust(0, 0, 10, 10, 0)
+
 	self.Icons["round_corners"] = round_corners
 
 	if self.IsWifiConnectedNow() {
 		print("wifi is connected")
-	}else {
-  
-    cmd := "sudo rfkill list | grep yes | cut -d \" \" -f3" //make sure sudo rfkill needs no password
-    out, err := exec.Command("bash", "-c", cmd).Output()
-    if err != nil {
-      fmt.Printf("Failed to execute command: %s\n", cmd)
-    }else {
-      outs := strings.Split(string(out),"\n")
-      if len(outs) > 0 && outs[0] == "yes" {
-        self.InAirPlaneMode = true
-      }else{
-        self.InAirPlaneMode = false
-      }
-    }
-
-  }
-  
-  self.UpdateTimeLocation()
-  
+	} else {
+
+		cmd := "sudo rfkill list | grep yes | cut -d \" \" -f3" //make sure sudo rfkill needs no password
+		out, err := exec.Command("bash", "-c", cmd).Output()
+		if err != nil {
+			fmt.Printf("Failed to execute command: %s\n", cmd)
+		} else {
+			outs := strings.Split(string(out), "\n")
+			if len(outs) > 0 && outs[0] == "yes" {
+				self.InAirPlaneMode = true
+			} else {
+				self.InAirPlaneMode = false
+			}
+		}
+
+	}
+
+	self.UpdateTimeLocation()
+
 }
 
 func (self *TitleBar) ClearCanvas() {
 	surface.Fill(self.CanvasHWND, self.SkinManager.GiveColor("TitleBg"))
 
-	self.Icons["round_corners"].NewCoord(5,5)
+	self.Icons["round_corners"].NewCoord(5, 5)
 	self.Icons["round_corners"].SetIconIndex(0)
 	self.Icons["round_corners"].Draw()
 
 	self.Icons["round_corners"].NewCoord(self.Width-5, 5)
 	self.Icons["round_corners"].SetIconIndex(1)
 	self.Icons["round_corners"].Draw()
-	
+
 }
 
+func (self *TitleBar) UpdateTimeLocation() {
+
+	d, err := ioutil.ReadFile("/etc/localtime")
+	if err != nil {
+		return
+	}
 
-func (self *TitleBar) UpdateTimeLocation()  {
-  
-  d,err := ioutil.ReadFile("/etc/localtime")
-  if err != nil {
-    return
-  }
-  
-  self.MyTimeLocation,err = gotime.LoadLocationFromTZData("local", d)
-  if err != nil {
-    fmt.Println(err)
-    self.MyTimeLocation = nil
-  }
+	self.MyTimeLocation, err = gotime.LoadLocationFromTZData("local", d)
+	if err != nil {
+		fmt.Println(err)
+		self.MyTimeLocation = nil
+	}
 }
 
 func (self *TitleBar) GetLocalTime() gotime.Time {
-  if self.MyTimeLocation == nil {
-    return gotime.Now()
-  }else {  
-    return gotime.Now().In(self.MyTimeLocation)
-  }
+	if self.MyTimeLocation == nil {
+		return gotime.Now()
+	} else {
+		return gotime.Now().In(self.MyTimeLocation)
+	}
 }
 
-
 func (self *TitleBar) Draw(title string) {
 	self.ClearCanvas()
 	self.Title = title
 
 	cur_time := jodaTime.Format("HH:mm", self.GetLocalTime())
-	
-	time_text_w,  time_text_h  := font.Size(self.TimeFont, cur_time)
+
+	time_text_w, time_text_h := font.Size(self.TimeFont, cur_time)
 	title_text_w, title_text_h := font.Size(self.TitleFont, self.Title)
 
-	title_text_surf := font.Render(self.TitleFont, self.Title, true, self.SkinManager.GiveColor("Text"),nil)
-	
-	surface.Blit(self.CanvasHWND,title_text_surf, draw.MidRect(title_text_w/2+self.LOffset,title_text_h/2+(self.BarHeight-title_text_h)/2,title_text_w,title_text_h,Width,Height),nil)
-  title_text_surf.Free()
+	title_text_surf := font.Render(self.TitleFont, self.Title, true, self.SkinManager.GiveColor("Text"), nil)
+
+	surface.Blit(self.CanvasHWND, title_text_surf, draw.MidRect(title_text_w/2+self.LOffset, title_text_h/2+(self.BarHeight-title_text_h)/2, title_text_w, title_text_h, Width, Height), nil)
+	title_text_surf.Free()
+
+	time_text_surf := font.Render(self.TimeFont, cur_time, true, self.SkinManager.GiveColor("Text"), nil)
+	surface.Blit(self.CanvasHWND, time_text_surf, draw.MidRect(Width-time_text_w/2-self.ROffset, time_text_h/2+(self.BarHeight-time_text_h)/2, time_text_w, time_text_h, Width, Height), nil)
+
+	time_text_surf.Free()
 
-	time_text_surf := font.Render(self.TimeFont, cur_time,true,self.SkinManager.GiveColor("Text"),nil)
-	surface.Blit(self.CanvasHWND, time_text_surf, draw.MidRect(Width-time_text_w/2-self.ROffset, time_text_h/2+(self.BarHeight-time_text_h)/2, time_text_w,time_text_h,Width,Height),nil)
-  
-  time_text_surf.Free()
-  
 	start_x := Width - time_text_w - self.ROffset - self.IconWidth*3 // close to the time_text
-  
-  self.Icons["bluetooth"].NewCoord(start_x - self.IconWidth,self.IconHeight/2+(self.BarHeight-self.IconHeight)/2)
-	self.Icons["sound"].NewCoord( start_x, self.IconHeight/2+ (self.BarHeight-self.IconHeight)/2)
+
+	self.Icons["bluetooth"].NewCoord(start_x-self.IconWidth, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2)
+	self.Icons["sound"].NewCoord(start_x, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2)
 	self.Icons["battery"].NewCoord(start_x+self.IconWidth+self.IconWidth+8, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2)
 
 	if self.IsWifiConnectedNow() == true {
@@ -512,34 +504,31 @@ func (self *TitleBar) Draw(title string) {
 		//fmt.Println("wifi ge: ",ge)
 		if ge > 0 {
 			self.Icons["wifistatus"].SetIconIndex(ge)
-			self.Icons["wifistatus"].NewCoord(start_x+self.IconWidth+5, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2 )
+			self.Icons["wifistatus"].NewCoord(start_x+self.IconWidth+5, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2)
 			self.Icons["wifistatus"].Draw()
-		}else {
+		} else {
 			self.Icons["wifistatus"].SetIconIndex(0)
-			self.Icons["wifistatus"].NewCoord(start_x+self.IconWidth+5, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2 )
+			self.Icons["wifistatus"].NewCoord(start_x+self.IconWidth+5, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2)
 			self.Icons["wifistatus"].Draw()
 		}
-	}else {
-		
+	} else {
+
 		self.Icons["wifistatus"].SetIconIndex(0)
-		
+
 		self.Icons["wifistatus"].NewCoord(start_x+self.IconWidth+5, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2)
-		
+
 		self.Icons["wifistatus"].Draw()
 	}
 
 	self.Icons["sound"].Draw()
 	self.Icons["battery"].Draw()
-  
-  self.Icons["bluetooth"].Draw()
-	
-	draw.Line(self.CanvasHWND,self.SkinManager.GiveColor("Line"), 0,self.BarHeight,self.Width,self.BarHeight, self.BorderWidth)
+
+	self.Icons["bluetooth"].Draw()
+
+	draw.Line(self.CanvasHWND, self.SkinManager.GiveColor("Line"), 0, self.BarHeight, self.Width, self.BarHeight, self.BorderWidth)
 
 	if self.HWND != nil {
-		rect_ := rect.Rect(self.PosX,self.PosY, self.Width,self.Height)
+		rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
 		surface.Blit(self.HWND, self.CanvasHWND, &rect_, nil)
 	}
 }
-
-	
-	

+ 17 - 21
sysgo/UI/untitled_icon.go

@@ -2,37 +2,36 @@ package UI
 
 import (
 	"strings"
-	
+
 	"github.com/veandco/go-sdl2/sdl"
 	"github.com/veandco/go-sdl2/ttf"
 
-	"github.com/cuu/gogame/surface"
-	"github.com/cuu/gogame/draw"	
 	"github.com/cuu/gogame/color"
-	"github.com/cuu/gogame/image"
+	"github.com/cuu/gogame/draw"
 	"github.com/cuu/gogame/font"
+	"github.com/cuu/gogame/image"
+	"github.com/cuu/gogame/surface"
 )
 
-
 type UntitledIcon struct {
 	Widget
-	Words []string
-	FontObj *ttf.Font
-	BG *sdl.Surface
-	Color *color.Color
+	Words    []string
+	FontObj  *ttf.Font
+	BG       *sdl.Surface
+	Color    *color.Color
 	BlankPng string
-	Text *sdl.Surface
+	Text     *sdl.Surface
 }
 
 func NewUntitledIcon() *UntitledIcon {
 	u := &UntitledIcon{}
 	u.Width = 80
 	u.Height = 80
-	u.Words = []string{"G","s"}
+	u.Words = []string{"G", "s"}
 
 	u.FontObj = Fonts["varela40"]
 
-	u.Color = &color.Color{83,83,83,255}
+	u.Color = &color.Color{83, 83, 83, 255}
 
 	u.BlankPng = SkinMap("sysgo/gameshell/blank.png")
 	return u
@@ -42,15 +41,15 @@ func (self *UntitledIcon) Init() {
 	self.BG = image.Load(self.BlankPng)
 }
 
-func (self *UntitledIcon) SetWords( TwoWords ...string) {
+func (self *UntitledIcon) SetWords(TwoWords ...string) {
 	if len(TwoWords) == 1 {
 		self.Words[0] = strings.ToUpper(TwoWords[0])
 	}
 	if len(TwoWords) == 2 {
-		self.Words[0] = strings.ToUpper( TwoWords[0])
-		self.Words[1] = strings.ToLower( TwoWords[1] )
+		self.Words[0] = strings.ToUpper(TwoWords[0])
+		self.Words[1] = strings.ToLower(TwoWords[1])
 
-		self.Text = font.Render(self.FontObj, strings.Join(self.Words,""),true,self.Color, nil)
+		self.Text = font.Render(self.FontObj, strings.Join(self.Words, ""), true, self.Color, nil)
 	}
 }
 
@@ -58,8 +57,8 @@ func (self *UntitledIcon) Draw() {
 	if self.BG != nil {
 		w_ := self.Text.W
 		h_ := self.Text.H
-		
-		surface.Blit(self.BG,self.Text,draw.MidRect(self.Width/2, self.Height/2, int(w_),int(h_), self.Width, self.Height),nil)
+
+		surface.Blit(self.BG, self.Text, draw.MidRect(self.Width/2, self.Height/2, int(w_), int(h_), self.Width, self.Height), nil)
 	}
 }
 
@@ -67,6 +66,3 @@ func (self *UntitledIcon) Surface() *sdl.Surface {
 	self.Draw()
 	return self.BG
 }
-
-
-		

+ 122 - 130
sysgo/UI/util_funcs.go

@@ -1,19 +1,19 @@
 package UI
 
 import (
-	"os"
+	"bufio"
+	"bytes"
+	"fmt"
+	"io"
 	"log"
+	"os"
+	"os/exec"
 	"path/filepath"
-	"strings"
-	"fmt"
-	"bufio"
-  "bytes"
-  "io"
+	"runtime"
 	"strconv"
-  "syscall"
-  "os/exec"
-  "runtime"
-  
+	"strings"
+	"syscall"
+
 	"github.com/cuu/gogame/display"
 
 	"github.com/clockworkpi/LauncherGoDev/sysgo"
@@ -27,14 +27,14 @@ func ShowErr(e error) {
 
 func Assert(e error) {
 	if e != nil {
-		log.Fatal("Assert: " , e)
+		log.Fatal("Assert: ", e)
 	}
 }
 
 func CheckAndPanic(e error) {
-    if e != nil {
-        panic(e)
-    }
+	if e != nil {
+		panic(e)
+	}
 }
 
 func Abs(n int) int {
@@ -42,42 +42,41 @@ func Abs(n int) int {
 	return (n ^ y) - y
 }
 
-
 func SkinMap(orig_file_or_dir string) string {
 	DefaultSkin := "skin/default/"
 	ret := ""
-  
+
 	if strings.HasPrefix(orig_file_or_dir, "/home/cpi/apps/Menu") {
-		ret = strings.Replace(orig_file_or_dir,"/home/cpi/apps/Menu/", sysgo.SKIN+"/Menu/GameShell/",-1)
-    if FileExists(ret) == false {
-      ret = DefaultSkin+orig_file_or_dir
-    }
-	}else { // there is no need to add insert "sysgo" in the middle
-		ret = sysgo.SKIN+orig_file_or_dir
+		ret = strings.Replace(orig_file_or_dir, "/home/cpi/apps/Menu/", sysgo.SKIN+"/Menu/GameShell/", -1)
 		if FileExists(ret) == false {
-			ret = DefaultSkin+orig_file_or_dir
+			ret = DefaultSkin + orig_file_or_dir
+		}
+	} else { // there is no need to add insert "sysgo" in the middle
+		ret = sysgo.SKIN + orig_file_or_dir
+		if FileExists(ret) == false {
+			ret = DefaultSkin + orig_file_or_dir
 		}
 	}
 
 	if FileExists(ret) {
 		return ret
-	}else { // if not existed both in default or custom skin ,return where it is
+	} else { // if not existed both in default or custom skin ,return where it is
 		return orig_file_or_dir
 	}
 }
 
 func CmdClean(cmdpath string) string {
 	spchars := "\\`$();|{}&'\"*?<>[]!^~-#\n\r "
-	for _,v:= range spchars {
-		cmdpath = strings.Replace(cmdpath,string(v),"\\"+string(v),-1)
+	for _, v := range spchars {
+		cmdpath = strings.Replace(cmdpath, string(v), "\\"+string(v), -1)
 	}
 	return cmdpath
 }
 
 func FileExists(name string) bool {
-	if _, err := os.Stat(name ); err == nil {
+	if _, err := os.Stat(name); err == nil {
 		return true
-	}else {
+	} else {
 		return false
 	}
 }
@@ -86,22 +85,20 @@ func IsDirectory(path string) bool {
 	fileInfo, err := os.Stat(path)
 	if err != nil {
 		return false
-	}else {
-    return fileInfo.IsDir()
+	} else {
+		return fileInfo.IsDir()
 	}
 }
 
-
 func IsAFile(path string) bool {
 	fileInfo, err := os.Stat(path)
 	if err != nil {
 		return false
-	}else {
-    return fileInfo.Mode().IsRegular()
+	} else {
+		return fileInfo.Mode().IsRegular()
 	}
 }
 
-
 func MakeExecutable(path string) {
 	fileInfo, err := os.Stat(path)
 	if err != nil {
@@ -109,8 +106,8 @@ func MakeExecutable(path string) {
 		return
 	}
 	mode := fileInfo.Mode()
-	mode |= (mode & 0444) >> 2 
-	os.Chmod(path,mode)
+	mode |= (mode & 0444) >> 2
+	os.Chmod(path, mode)
 }
 
 func GetExePath() string {
@@ -118,73 +115,72 @@ func GetExePath() string {
 	if err != nil {
 		log.Fatal(err)
 	}
-  return dir
-  
+	return dir
+
 }
 
 func ReplaceSuffix(orig_file_str string, new_ext string) string {
 	orig_ext := filepath.Ext(orig_file_str)
-	if orig_ext!= "" {
-		las_pos := strings.LastIndex(orig_file_str,".")
-		return  orig_file_str[0:las_pos]+"."+new_ext
+	if orig_ext != "" {
+		las_pos := strings.LastIndex(orig_file_str, ".")
+		return orig_file_str[0:las_pos] + "." + new_ext
 	}
-	return orig_file_str // failed just return back where it came 
+	return orig_file_str // failed just return back where it came
 }
 
 func SwapAndShow() {
 	display.Flip()
 }
 
-func ReadLines(path string)(lines [] string,err error){
+func ReadLines(path string) (lines []string, err error) {
 	var (
-		file *os.File
-		part [] byte
+		file   *os.File
+		part   []byte
 		prefix bool
 	)
-	
+
 	if file, err = os.Open(path); err != nil {
 		return
 	}
-	
+
 	reader := bufio.NewReader(file)
-	buffer := bytes.NewBuffer(make([]byte,0))
-	
+	buffer := bytes.NewBuffer(make([]byte, 0))
+
 	for {
-		if part, prefix, err = reader.ReadLine();err != nil {
+		if part, prefix, err = reader.ReadLine(); err != nil {
 			break
 		}
 		buffer.Write(part)
 		if !prefix {
-			lines = append(lines,buffer.String())
+			lines = append(lines, buffer.String())
 			buffer.Reset()
 		}
 	}
-	
+
 	if err == io.EOF {
 		err = nil
 	}
 	return
 }
 
-func WriteLines(lines [] string,path string)(err error){
-    var file *os.File
-    
-    if file,err = os.Create(path); err != nil{
-         return
-    }
-    
-    defer file.Close()
-    
-    for _,elem := range lines {
-       _,err := file.WriteString(strings.TrimSpace(elem)+"\n")
-       if err != nil {
-           fmt.Println(err)
-           break
-       }
-    }
-    return
-}
+func WriteLines(lines []string, path string) (err error) {
+	var file *os.File
+
+	if file, err = os.Create(path); err != nil {
+		return
+	}
 
+	defer file.Close()
+
+	for _, elem := range lines {
+		_, err := file.WriteString(strings.TrimSpace(elem) + "\n")
+		if err != nil {
+			fmt.Println(err)
+			break
+		}
+	}
+	return
+}
 
 func GetGid(path string) int {
 	s, err := os.Stat(path)
@@ -200,7 +196,6 @@ func GetGid(path string) int {
 	return int(sys_interface.(*syscall.Stat_t).Gid)
 }
 
-
 func GetUid(path string) int {
 	s, err := os.Stat(path)
 	if err != nil {
@@ -215,76 +210,73 @@ func GetUid(path string) int {
 	return int(sys_interface.(*syscall.Stat_t).Uid)
 }
 
-func  CheckBattery() int {
-  if FileExists(sysgo.Battery) == false {
-    return -1
-  }
-  
-  batinfos,err := ReadLines(sysgo.Battery)
-  if err == nil {
-    for _,v := range batinfos {
-      if strings.HasPrefix(v,"POWER_SUPPLY_CAPACITY") {
-        parts := strings.Split(v,"=")
-        if len(parts) > 1 {
-          cur_cap,err := strconv.Atoi(parts[1])
-          if err == nil {
-            return cur_cap
-          }else {
-            return 0 
-          }
-        }
-      }
-    }
-  }else{
-    fmt.Println(err)
-  }
-  
-  return 0
-}
-
+func CheckBattery() int {
+	if FileExists(sysgo.Battery) == false {
+		return -1
+	}
 
+	batinfos, err := ReadLines(sysgo.Battery)
+	if err == nil {
+		for _, v := range batinfos {
+			if strings.HasPrefix(v, "POWER_SUPPLY_CAPACITY") {
+				parts := strings.Split(v, "=")
+				if len(parts) > 1 {
+					cur_cap, err := strconv.Atoi(parts[1])
+					if err == nil {
+						return cur_cap
+					} else {
+						return 0
+					}
+				}
+			}
+		}
+	} else {
+		fmt.Println(err)
+	}
 
+	return 0
+}
 
 func System(cmd string) string {
-  ret := ""
-  out,err := exec.Command("bash","-c",cmd).Output()
-  if err != nil {
-    if _, ok := err.(*exec.ExitError); ok {
-      //exit code !=0 ,but it can be ignored
-    }else{
-      fmt.Println(err)
-    }
-  }else {
-    ret = string(out)
-  }
-
-  return ret
+	ret := ""
+	out, err := exec.Command("bash", "-c", cmd).Output()
+	if err != nil {
+		if _, ok := err.(*exec.ExitError); ok {
+			//exit code !=0 ,but it can be ignored
+		} else {
+			fmt.Println(err)
+		}
+	} else {
+		ret = string(out)
+	}
+
+	return ret
 }
 
 func ArmSystem(cmd string) string {
 
-  if strings.Contains(runtime.GOARCH,"arm") == true {
-    return System(cmd)
-  }else {
-    return ""
-  }
-  
+	if strings.Contains(runtime.GOARCH, "arm") == true {
+		return System(cmd)
+	} else {
+		return ""
+	}
+
 }
 
 func SystemTrim(cmd string) string {
-  ret := ""
-  out,err := exec.Command("bash","-c",cmd).Output()
-  if err != nil {
-    if _, ok := err.(*exec.ExitError); ok {
-      //exit code !=0 ,but it can be ignored
-    }else{
-      fmt.Println(err)
-    }
-  }else {
-    ret = string(out)
-  }
-
-  return strings.Trim(ret,"\r\n")
+	ret := ""
+	out, err := exec.Command("bash", "-c", cmd).Output()
+	if err != nil {
+		if _, ok := err.(*exec.ExitError); ok {
+			//exit code !=0 ,but it can be ignored
+		} else {
+			fmt.Println(err)
+		}
+	} else {
+		ret = string(out)
+	}
+
+	return strings.Trim(ret, "\r\n")
 }
 
 func cmdEnv() []string {

+ 37 - 40
sysgo/config.go

@@ -2,62 +2,59 @@ package sysgo
 
 import (
 	"fmt"
-	"os"
 	"github.com/go-ini/ini"
-	
+	"os"
 )
 
 type PowerLevel struct {
-  Dim int
-  Close  int
-  PowerOff int
+	Dim      int
+	Close    int
+	PowerOff int
 }
 
 var PowerLevels map[string]*PowerLevel
 
 var (
-  //CurKeySet = "PC" // PC or GameShell
-  CurKeySet = "GameShell"
-  DontLeave = false
-  BackLight = "/proc/driver/backlight"
-  Battery   = "/sys/class/power_supply/axp20x-battery/uevent"
-  MPD_socket = "/tmp/mpd.socket"
+	//CurKeySet = "PC" // PC or GameShell
+	CurKeySet  = "GameShell"
+	DontLeave  = false
+	BackLight  = "/proc/driver/backlight"
+	Battery    = "/sys/class/power_supply/axp20x-battery/uevent"
+	MPD_socket = "/tmp/mpd.socket"
 
-  UPDATE_URL="https://raw.githubusercontent.com/clockworkpi/CPI/master/launchergo_ver.json"
+	UPDATE_URL = "https://raw.githubusercontent.com/clockworkpi/CPI/master/launchergo_ver.json"
 
-  VERSION="0.22"
+	VERSION = "0.22"
 
-  SKIN="skin/default/" // !!!need the last slash!!!
-  
-  //load from dot files   
-  CurPowerLevel= "performance"
-  Lang        = "English"
-  WifiDev     = "wlan0"
-	
-)
+	SKIN = "skin/default/" // !!!need the last slash!!!
 
+	//load from dot files
+	CurPowerLevel = "performance"
+	Lang          = "English"
+	WifiDev       = "wlan0"
+)
 
 func init() {
-  if PowerLevels == nil {
-    PowerLevels = make(map[string]*PowerLevel)
-    PowerLevels["supersaving"] = &PowerLevel{10, 30,  120}
-    PowerLevels["powersaving"] = &PowerLevel{40, 120, 300}
-    PowerLevels["server"]      = &PowerLevel{40, 120, 0  }
-    PowerLevels["performance"] = &PowerLevel{40, 0,   0  }
-  }
+	if PowerLevels == nil {
+		PowerLevels = make(map[string]*PowerLevel)
+		PowerLevels["supersaving"] = &PowerLevel{10, 30, 120}
+		PowerLevels["powersaving"] = &PowerLevel{40, 120, 300}
+		PowerLevels["server"] = &PowerLevel{40, 120, 0}
+		PowerLevels["performance"] = &PowerLevel{40, 0, 0}
+	}
 
 	//sudo LauncherGoDev=1 ./launchergo # for develop code on PC
 	dev_mode := os.Getenv("LauncherGoDev")
-	
+
 	if len(dev_mode) < 1 {
 		return
 	}
-	
-	if _, err := os.Stat("app-local.ini" ); err == nil {
+
+	if _, err := os.Stat("app-local.ini"); err == nil {
 		load_opts := ini.LoadOptions{
-			IgnoreInlineComment:true,
+			IgnoreInlineComment: true,
 		}
-		cfg, err := ini.LoadSources(load_opts, "app-local.ini" )
+		cfg, err := ini.LoadSources(load_opts, "app-local.ini")
 		if err != nil {
 			fmt.Printf("Fail to read file: %v\n", err)
 			return
@@ -65,17 +62,17 @@ func init() {
 		section := cfg.Section("GameShell")
 		if section != nil {
 			gs_opts := section.KeyStrings()
-			for i,v := range gs_opts {
-				fmt.Println(i,v, section.Key(v).String())
-				switch v{
-					case "WifiDev":
+			for i, v := range gs_opts {
+				fmt.Println(i, v, section.Key(v).String())
+				switch v {
+				case "WifiDev":
 					WifiDev = section.Key(v).String()
-					case "CurKeySet":
+				case "CurKeySet":
 					CurKeySet = section.Key(v).String()
-					
+
 				}
 			}
 		}
 	}
-	
+
 }

+ 3 - 12
sysgo/plugins/HelloWorld/helloworld.go

@@ -8,25 +8,16 @@ type HelloWorldPage struct {
 	UI.Page
 }
 
-
-
-
 type HelloWorldPlugin struct {
 	UI.Plugin
 }
 
+func (self *HelloWorldPlugin) Init(main_screen *UI.MainScreen) {
 
-func (self *HelloWorldPlugin) Init( main_screen *UI.MainScreen ) {
-	
 }
 
-func (self *HelloWorldPlugin) Run( main_screen *UI.MainScreen ) {
-	
+func (self *HelloWorldPlugin) Run(main_screen *UI.MainScreen) {
+
 }
 
 var APIOBJ HelloWorldPlugin
-
-
-
-
-

+ 1 - 2
sysgo/wicd/misc/misc.go

@@ -125,11 +125,10 @@ func LoadEncryptionMethods(wired bool) []*CurType {
 	for _, v := range enctypes {
 
 		c := parse_enc_templat(v)
-    c.Type = v
+		c.Type = v
 		encryptionTypes = append(encryptionTypes, c)
 	}
 
 	return encryptionTypes
 
 }
-

Some files were not shown because too many files changed in this diff