Browse Source

just showed up the screen,like python's launcher

cuu 5 years ago
parent
commit
85b9423b0d

BIN
main


BIN
skin/default/Menu/GameShell/20_Retro Games/MAME.png


BIN
skin/default/Menu/GameShell/20_Retro Games/MGBA.png


BIN
skin/default/Menu/GameShell/20_Retro Games/NESTOPIA.png


BIN
skin/default/Menu/GameShell/CaveStory.png


BIN
skin/default/Menu/GameShell/Music Player.png


BIN
skin/default/Menu/GameShell/PowerOFF.png


BIN
skin/default/Menu/GameShell/Retro Games.png


BIN
skin/default/Menu/GameShell/RetroArch.png


BIN
skin/default/Menu/GameShell/Settings.png


BIN
skin/default/Menu/GameShell/Sleep.png


BIN
skin/default/Menu/GameShell/TinyCloud.png


BIN
skin/default/Menu/GameShell/freeDM.png


+ 30 - 3
sysgo/UI/foot_bar.go

@@ -19,15 +19,36 @@ import (
 var FootBar_BarHeight = 20
 
 type FootBarIconItem struct {
-	MultiIconItem
+	MultiIconItem 
 	Parent *FootBar
 }
 
 func NewFootBarIconItem() *FootBarIconItem {
 	m := &FootBarIconItem{}
+	m.IconIndex = 0
+	m.IconWidth = 18
+	m.IconHeight = 18
+	m.Align = ALIGN["VCenter"]
+	
 	return m
 }
 
+func (self *FootBarIconItem) Adjust(x,y,w,h,at int) {
+	self.PosX = x
+	self.PosY = y
+	self.Width = w
+	self.Height = h
+	self.AnimationTime = at
+
+	if self.Label != nil {
+		self.Label.SetCanvasHWND(self.Parent.CanvasHWND)
+	}
+
+	self.CreateImgSurf()
+//	self.AdjustLinkPage()
+	
+}
+
 func (self *FootBarIconItem) TotalWidth() int {
 	lab_w,_ := self.Label.Size()
 	return self.Width + lab_w
@@ -48,7 +69,8 @@ func (self *FootBarIconItem) 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 {
+		fmt.Println("self.ImgSurf is nil ")
 	}
 	
 }
@@ -88,7 +110,7 @@ func NewFootBar() *FootBar {
 	
 	f.LabelFont = Fonts["veramono10"]
 	f.State = "normal"
-	f.icon_base_path = SkinMap("gameshell/footbar_icons/")
+	f.icon_base_path = SkinMap("sysgo/gameshell/footbar_icons/")
 
 	f.Icons = make(map[string]IconItemInterface)
 	
@@ -109,6 +131,8 @@ func (self *FootBar) ReadFootBarIcons( icondir string) {
 		it.Parent = self
 		it.ImgSurf = share_surf
 		it.Align = ALIGN["HLeft"] // (X)Text
+		it.IconWidth = self.IconWidth
+		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.IconIndex = i
@@ -122,6 +146,8 @@ func (self *FootBar) Init(main_screen *MainScreen) {
 	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
@@ -196,6 +222,7 @@ func (self *FootBar) ClearCanvas() {
 
 func (self *FootBar) Draw() {
 	self.ClearCanvas()
+	
 	self.Icons["nav"].NewCoord(self.IconWidth/2+3, self.IconHeight/2+2)
 	self.Icons["nav"].Draw()
 

+ 9 - 4
sysgo/UI/icon_item.go

@@ -1,6 +1,7 @@
 package UI
 
 import (
+	"fmt"
 	
 	"github.com/veandco/go-sdl2/sdl"
 	"github.com/veandco/go-sdl2/ttf"
@@ -185,9 +186,10 @@ func (self *IconItem) AddLabel(text string, fontobj *ttf.Font) {
 	if self.Label == nil {
 		l:= NewLabel()
 		self.Label = l
-	}else {
-		self.Label.Init(text,fontobj,nil)
-	}	
+	}
+	
+	self.Label.Init(text,fontobj,nil)
+	
 }
 
 func (self *IconItem) GetLinkPage() PageInterface {
@@ -254,7 +256,10 @@ func (self *IconItem) Draw() {
 		lab_w,lab_h:= self.Label.Size()
 		
 		if self.Align == ALIGN["VCenter"] {
-			self.Label.NewCoord( self.PosX - lab_w/2 + parent_x, self.PosY + lab_h/2+6+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)
 		}

+ 3 - 1
sysgo/UI/icon_pool.go

@@ -1,6 +1,7 @@
 package UI
 
 import (
+	"fmt"
 	"io/ioutil"
 	"log"
 	"strings"
@@ -18,7 +19,7 @@ type IconPool struct {
 
 func NewIconPool() *IconPool {
 	i := &IconPool{}
-	i.GameShellIconPath = SkinMap("gameshell/icons/")
+	i.GameShellIconPath = SkinMap("sysgo/gameshell/icons/")
 	i.Icons = make( map[string]*sdl.Surface )
 	return i
 }
@@ -49,6 +50,7 @@ func (self *IconPool) GetImgSurf(keyname string) *sdl.Surface {
 	if _,ok := self.Icons[keyname]; ok {
 		return self.Icons[keyname]
 	} else {
+		fmt.Println("IconPool GetImgSurf ", keyname, "  failed")
 		return nil
 	}
 }

+ 4 - 3
sysgo/UI/main_screen.go

@@ -321,6 +321,7 @@ func (self *MainScreen) ReadTheDirIntoPages(_dir string, pglevel int, cur_page P
 				if FileExists( SkinMap(_dir+"/"+i2+".png")) {
 					iconitem.ImageName = SkinMap(_dir+"/"+i2+".png")
 				}else {
+					fmt.Println(  SkinMap(_dir+"/"+i2+".png") )
 					untitled := NewUntitledIcon()
 					untitled.Init()
 					if len(i2) > 1 {
@@ -359,6 +360,7 @@ func (self *MainScreen) ReadTheDirIntoPages(_dir string, pglevel int, cur_page P
 				if FileExists( SkinMap( _dir+"/"+ ReplaceSuffix(i2,"png"))) {
 					iconitem.ImageName = SkinMap( _dir+"/"+ ReplaceSuffix(i2,"png"))
 				}else {
+					
 					untitled:= NewUntitledIcon()
 					untitled.Init()
 					if len(i2) > 1 {
@@ -431,8 +433,7 @@ func (self *MainScreen) Draw() {
 	}
 
 	if self.FootBar != nil {
-		fmt.Println( len(self.CurrentPage.GetFootMsg()))
-//		self.FootBar.SetLabelTexts( self.CurrentPage.GetFootMsg())
-//		self.FootBar.Draw()
+		self.FootBar.SetLabelTexts( self.CurrentPage.GetFootMsg())
+		self.FootBar.Draw()
 	}
 }

+ 1 - 1
sysgo/UI/multi_icon_item.go

@@ -24,7 +24,7 @@ func NewMultiIconItem() *MultiIconItem {
 	return m 
 }
 
-func (self * MultiIconItem) CreateImageSurf() {
+func (self * MultiIconItem) CreateImgSurf() {
 	if self.ImgSurf == nil && self.ImageName != "" {
 		self.ImgSurf = image.Load(self.ImageName)
 	}

+ 3 - 0
sysgo/UI/page.go

@@ -91,6 +91,8 @@ type PageSelector struct {
 
 func NewPageSelector() *PageSelector {
 	p := &PageSelector{}
+	p.OnShow = true
+	
 	return p
 }
 
@@ -736,6 +738,7 @@ func (self *Page) ResetPageSelector() {
 
 func (self *Page) DrawPageSelector() {
 	if self.Ps.GetOnShow() == true {
+		fmt.Println("DrawPageSelector")
 		self.Ps.Draw()
 	}
 }

+ 25 - 3
sysgo/UI/title_bar.go

@@ -16,7 +16,6 @@ import (
 	"github.com/cuu/gogame/rect"
 	"github.com/cuu/gogame/font"
 	"github.com/cuu/gogame/draw"
-	
 	"github.com/itchyny/volume-go"
 	
 	"github.com/vjeantet/jodaTime"
@@ -38,11 +37,30 @@ type TitleBarIconItem struct {
 
 func NewTitleBarIconItem() *TitleBarIconItem {
 	m := &TitleBarIconItem{}
-
+	m.IconIndex = 0
+	m.IconWidth = 18
+	m.IconHeight = 18
+	m.Align = ALIGN["VCenter"]
 	return m
 
 }
 
+func (self *TitleBarIconItem) Adjust(x,y,w,h,at int) {
+	self.PosX = x
+	self.PosY = y
+	self.Width = w
+	self.Height = h
+	self.AnimationTime = at
+
+	if self.Label != nil {
+		self.Label.SetCanvasHWND(self.Parent.CanvasHWND)
+	}
+
+	self.CreateImgSurf()
+//	self.AdjustLinkPage()
+	
+}
+
 func (self *TitleBarIconItem) Draw() {
 	parent_x,parent_y := self.Parent.PosX,self.Parent.PosY
 	
@@ -114,7 +132,7 @@ func NewTitleBar() *TitleBar {
 	
 	t.Icons = make(map[string]IconItemInterface)
 	
-	t.icon_base_path  = SkinMap("gameshell/titlebar_icons/")
+	t.icon_base_path  = SkinMap("sysgo/gameshell/titlebar_icons/")
 
 	t.TitleFont = Fonts["varela12"]
 	t.TimeFont  = Fonts["varela16"]
@@ -344,6 +362,7 @@ func (self *TitleBar) Draw(title string) {
 
 	if self.DBusManager.IsWifiConnectedNow() == true {
 		ge := self.GetWifiStrength( self.DBusManager.WifiStrength() )
+		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 )
@@ -353,8 +372,11 @@ func (self *TitleBar) Draw(title string) {
 			self.Icons["wifistatus"].Draw()
 		}
 	}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()
 	}
 

+ 2 - 2
sysgo/UI/util_funcs.go

@@ -21,9 +21,9 @@ func SkinMap(orig_file_or_dir string) string {
 			ret = strings.Replace(orig_file_or_dir,"..", skin_dir_prefix + DefaultSkin,-1)
 		}
 	}else {
-		ret = skin_dir_prefix+sysgo.SKIN+"/sysgo/"+orig_file_or_dir
+		ret = skin_dir_prefix+sysgo.SKIN+"/"+orig_file_or_dir
 		if FileExists(ret) == false {
-			ret = skin_dir_prefix+DefaultSkin+"/sysgo/"+orig_file_or_dir
+			ret = skin_dir_prefix+DefaultSkin+"/"+orig_file_or_dir
 		}
 	}