mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2026-03-19 02:12:46 +01:00
bug fix,music player fix
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user