mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 07:58:51 +01:00
bug fix,music player fix
This commit is contained in:
parent
e59d572610
commit
057bcc86f1
@ -66,16 +66,21 @@ func NewMusicLibListPage() *MusicLibListPage {
|
||||
return p
|
||||
}
|
||||
|
||||
|
||||
func (self *MusicLibListPage) OnLoadCb() {
|
||||
self.PosY = 0
|
||||
self.SyncList("/")
|
||||
// self.PosY = 0
|
||||
if self.MyList == nil || len(self.MyList) == 0 {
|
||||
self.MyStack.Clear()
|
||||
self.SyncList("/")
|
||||
}
|
||||
}
|
||||
|
||||
func (self *MusicLibListPage) SetCoords() {
|
||||
|
||||
}
|
||||
|
||||
func (self *MusicLibListPage) SyncList(path string) {
|
||||
fmt.Println("SyncList: ",path)
|
||||
fmt.Println(self.MyStack)
|
||||
conn := self.Parent.MpdClient
|
||||
|
||||
self.MyList = nil
|
||||
@ -98,6 +103,7 @@ func (self *MusicLibListPage) SyncList(path string) {
|
||||
li.PosY = start_y
|
||||
li.Width = UI.Width
|
||||
li.Fonts["normal"] = self.ListFontObj
|
||||
li.Path = "[..]"
|
||||
li.Init("[..]")
|
||||
li.MyType = UI.ICON_TYPES["DIR"]
|
||||
self.MyList = append(self.MyList, li)
|
||||
@ -235,7 +241,7 @@ func (self *MusicLibListPage) Click() {
|
||||
|
||||
func (self *MusicLibListPage) KeyDown(ev *event.Event) {
|
||||
|
||||
if UI.IsKeyMenuOrB(ev.Data["Key"]) || ev.Data["Key"] == UI.CurKeys["Left"] {
|
||||
if UI.IsKeyMenuOrA(ev.Data["Key"]) || ev.Data["Key"] == UI.CurKeys["Left"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
@ -255,10 +261,14 @@ func (self *MusicLibListPage) KeyDown(ev *event.Event) {
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if UI.IsKeyStartOrA(ev.Data["Key"]) {
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
self.Click()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Y"] {
|
||||
self.Screen.ShowMsg("Scan...",300)
|
||||
self.OnLoadCb()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -274,6 +284,13 @@ func (self *MusicLibListPage) Draw() {
|
||||
self.Ps.Draw()
|
||||
|
||||
for _, v := range self.MyList {
|
||||
v.(*MusicLibListPageListItem).Active = false
|
||||
|
||||
if self.Parent.InPlayList( v.(*MusicLibListPageListItem).Path) {
|
||||
v.(*MusicLibListPageListItem).Active = true
|
||||
fmt.Println("in PlayList: ",v.(*MusicLibListPageListItem).Path)
|
||||
}
|
||||
|
||||
if v.(*MusicLibListPageListItem).PosY > self.Height+self.Height/2 {
|
||||
break
|
||||
}
|
||||
@ -292,6 +309,13 @@ func (self *MusicLibListPage) Draw() {
|
||||
self.Ps.(*ListPageSelector).Width = self.Width
|
||||
self.Ps.Draw()
|
||||
for _, v := range self.MyList {
|
||||
v.(*MusicLibListPageListItem).Active = false
|
||||
|
||||
if self.Parent.InPlayList( v.(*MusicLibListPageListItem).Path) {
|
||||
v.(*MusicLibListPageListItem).Active = true
|
||||
fmt.Println("in PlayList: ",v.(*MusicLibListPageListItem).Path)
|
||||
}
|
||||
|
||||
if v.(*MusicLibListPageListItem).PosY > self.Height+self.Height/2 {
|
||||
break
|
||||
}
|
||||
|
||||
@ -48,10 +48,27 @@ func (self *MusicLibListPageListItem) Draw() {
|
||||
|
||||
self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2)
|
||||
|
||||
if self.MyType == UI.ICON_TYPES["DIR"] && self.Path != "[..]" {
|
||||
sys_icon := self.Parent.(*MusicLibListPage).Icons["sys"]
|
||||
sys_icon.SetIconIndex(0)
|
||||
_,h := sys_icon.Size()
|
||||
sys_icon.NewCoord(self.Width - 12,self.PosY+ (self.Height - h)/2+h/2)
|
||||
sys_icon.Draw()
|
||||
}
|
||||
|
||||
if self.MyType == UI.ICON_TYPES["FILE"] {
|
||||
sys_icon := self.Parent.(*MusicLibListPage).Icons["sys"]
|
||||
sys_icon.SetIconIndex(1)
|
||||
_,h := sys_icon.Size()
|
||||
sys_icon.NewCoord(self.Width-12,self.PosY+ (self.Height - h)/2+h/2)
|
||||
sys_icon.Draw()
|
||||
}
|
||||
/*
|
||||
if self.Active == true {
|
||||
self.Parent.(*MusicLibListPage).Icons["sys"].NewCoord(self.Parent.(*MusicLibListPage).Width-30, self.PosY+5)
|
||||
self.Parent.(*MusicLibListPage).Icons["sys"].Draw()
|
||||
}
|
||||
*/
|
||||
|
||||
self.Labels["Text"].SetBold(self.Active)
|
||||
self.Labels["Text"].Draw()
|
||||
|
||||
@ -51,7 +51,7 @@ func NewMusicPlayerPage() *MusicPlayerPage {
|
||||
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.FootMsg = [5]string{"Nav","Remove","RTA","Back","Play/Pause"}
|
||||
p.FootMsg = [5]string{"Nav","Remove","","Back","Play/Pause"}
|
||||
|
||||
|
||||
p.URLColor = UI.MySkinManager.GiveColor("URL")
|
||||
@ -185,6 +185,22 @@ func (self *MusicPlayerPage) SyncPlaying() {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *MusicPlayerPage) InPlayList(path string) bool {
|
||||
if self.MyList == nil || len(self.MyList) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
for _,v := range self.MyList {
|
||||
///fmt.Println(v.(*MusicPlayPageListItem).Path, path)
|
||||
|
||||
if v.(*MusicPlayPageListItem).Path == path {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *MusicPlayerPage) Init() {
|
||||
if self.Screen == nil {
|
||||
panic("No Screen")
|
||||
@ -234,7 +250,7 @@ func (self *MusicPlayerPage) Init() {
|
||||
|
||||
self.MyMusicLibListPage = NewMusicLibListPage()
|
||||
self.MyMusicLibListPage.Screen = self.Screen
|
||||
self.MyMusicLibListPage.Name = "Music Library"
|
||||
self.MyMusicLibListPage.Name = "Music library"
|
||||
self.MyMusicLibListPage.Parent = self
|
||||
self.MyMusicLibListPage.Init()
|
||||
|
||||
@ -267,7 +283,12 @@ func (self *MusicPlayerPage) KeyDown(ev *event.Event) {
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["X"] {
|
||||
self.MpdClient.Delete(self.PsIndex,-1)
|
||||
self.SyncList()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ type MusicPlayerPlugin struct {
|
||||
func (self *MusicPlayerPlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.MusicPlayerPage = NewMusicPlayerPage()
|
||||
self.MusicPlayerPage.SetScreen(main_screen)
|
||||
self.MusicPlayerPage.SetName("Music Player")
|
||||
self.MusicPlayerPage.SetName("Music player")
|
||||
self.MpdClient = nil
|
||||
self.MusicPlayerPage.MpdClient = self.MpdClient
|
||||
self.MusicPlayerPage.Init()
|
||||
|
||||
@ -54,7 +54,11 @@ func (stk *FolderStack) Last() string {
|
||||
return stk.head.data.(string)
|
||||
}
|
||||
}
|
||||
|
||||
func (stk *FolderStack) Clear() {
|
||||
for stk.Length() > 0 {
|
||||
stk.Pop()
|
||||
}
|
||||
}
|
||||
func NewFolderStack() *FolderStack {
|
||||
stk := new(FolderStack)
|
||||
stk.lock = &sync.Mutex{}
|
||||
|
||||
@ -70,6 +70,15 @@ func IsKeyStartOrA(key string) bool {
|
||||
return key == CurKeys["Start"] || key == CurKeys["A"]
|
||||
}
|
||||
|
||||
func IsKeyStartOrB(key string) bool {
|
||||
return key == CurKeys["Start"] || key == CurKeys["B"]
|
||||
}
|
||||
|
||||
func IsKeyMenuOrB(key string) bool {
|
||||
return key == CurKeys["Menu"] || key == CurKeys["B"]
|
||||
}
|
||||
|
||||
func IsKeyMenuOrA(key string) bool {
|
||||
return key == CurKeys["Menu"] || key == CurKeys["A"]
|
||||
}
|
||||
|
||||
|
||||
@ -411,7 +411,18 @@ func (self *MainScreen) KeyDown(ev *event.Event) {
|
||||
self.LastKey = ev.Data["Key"]
|
||||
|
||||
}
|
||||
func (self *MainScreen) ShowMsg(content string, blocktime int) {
|
||||
self.MsgBox.SetText(content)
|
||||
self.MsgBox.Draw()
|
||||
self.SwapAndShow()
|
||||
|
||||
if blocktime > 0 {
|
||||
time.BlockDelay(blocktime)
|
||||
self.CurrentPage.Draw()
|
||||
self.SwapAndShow()
|
||||
}
|
||||
|
||||
}
|
||||
func (self *MainScreen) DrawRun() {
|
||||
self.MsgBox.SetText("Launching....")
|
||||
self.MsgBox.Draw()
|
||||
|
||||
@ -132,7 +132,7 @@ func NewTitleBar() *TitleBar {
|
||||
|
||||
t.icon_base_path = SkinMap("sysgo/gameshell/titlebar_icons/")
|
||||
|
||||
t.TitleFont = Fonts["varela16"]
|
||||
t.TitleFont = Fonts["notosanscjk15"]
|
||||
t.TimeFont = Fonts["varela12"]
|
||||
|
||||
t.InLowBackLight = -1
|
||||
@ -293,15 +293,15 @@ func (self *TitleBar) SetSoundVolume(vol int) {
|
||||
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}}
|
||||
|
||||
self.Icons["battery"] = self.Icons["battery_unknown"]
|
||||
|
||||
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"]
|
||||
return
|
||||
}
|
||||
|
||||
@ -529,12 +529,10 @@ func (self *TitleBar) Draw(title string) {
|
||||
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()
|
||||
|
||||
start_x := Width - time_text_w - self.ROffset - self.IconWidth*3 // close to the time_text
|
||||
|
||||
@ -574,4 +572,7 @@ func (self *TitleBar) Draw(title string) {
|
||||
rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
|
||||
surface.Blit(self.HWND, self.CanvasHWND, &rect_, nil)
|
||||
}
|
||||
|
||||
title_text_surf.Free()
|
||||
time_text_surf.Free()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user