diff --git a/Menu/GameShell/97_MusicPlayer/music_lib_list_page.go b/Menu/GameShell/97_MusicPlayer/music_lib_list_page.go index 8672e97..587248b 100644 --- a/Menu/GameShell/97_MusicPlayer/music_lib_list_page.go +++ b/Menu/GameShell/97_MusicPlayer/music_lib_list_page.go @@ -221,9 +221,13 @@ func (self *MusicLibListPage) Click() { } if cur_li.MyType == UI.ICON_TYPES["FILE"] { - //addfile(cur_li.Path) - //PlayListPage.SyncList() - //print("add" , cur_li._Path) + conn := self.Parent.MpdClient + conn.Add(cur_li.Path) + self.Parent.SyncList() + //addfile(cur_li.Path) + //PlayListPage.SyncList() + //print("add" , cur_li._Path) + } self.Screen.Draw() diff --git a/Menu/GameShell/97_MusicPlayer/music_player_page.go b/Menu/GameShell/97_MusicPlayer/music_player_page.go index d3be9a2..1cf2470 100644 --- a/Menu/GameShell/97_MusicPlayer/music_player_page.go +++ b/Menu/GameShell/97_MusicPlayer/music_player_page.go @@ -93,6 +93,59 @@ func (self *MusicPlayerPage) SetLabels() { } +func (self *MusicPlayerPage) SyncList() { + conn := self.MpdClient + start_x := 0 + start_y := 0 + + if conn == nil { + return + } + + self.MyList = nil + + play_list,_ := conn.PlaylistInfo(-1,-1) + + for i,v := range play_list { + li := NewMusicPlayPageListItem() + li.Parent = self + li.PosX = start_x + li.PosY = start_y + UI.DefaultInfoPageListItemHeight * i + li.Width = UI.Width + li.Fonts["normal"] = self.ListFontObj + + if val,ok:=v["Title"]; ok { + li.Init(val) + + if val2,ok2 := v["file"]; ok2 { + li.Path = val2 + } + }else { + if val2,ok2 := v["file"]; ok2 { + li.Init(filepath.Base(val2)) + li.Path = val2 + }else{ + li.Init("NoName") + } + } + + li.Labels["Text"].PosX = 7 + self.MyList = append(self.MyList, li) + } + + self.SyncPlaying() +} + +func (self *MusicPlayerPage) SyncPlaying() { + conn := self.MpdClient + + for i,_ := range self.MyList { + self.MyList[i].(*MusicPlayPageListItem).Active = false + self.MyList[i].(*MusicPlayPageListItem).PlayingProcess = 0 + } + +} + func (self *MusicPlayerPage) Init() { if self.Screen == nil { panic("No Screen") diff --git a/Menu/GameShell/97_MusicPlayer/music_player_page_list_item.go b/Menu/GameShell/97_MusicPlayer/music_player_page_list_item.go index 5a6b3f5..7a6b8e4 100644 --- a/Menu/GameShell/97_MusicPlayer/music_player_page_list_item.go +++ b/Menu/GameShell/97_MusicPlayer/music_player_page_list_item.go @@ -27,6 +27,8 @@ type MusicPlayPageListItem struct { Value string MyType int Path string + + PlayingProcess int } func NewMusicPlayPageListItem() *MusicPlayPageListItem { @@ -47,15 +49,30 @@ func (self *MusicPlayPageListItem) Draw() { w, h := self.Labels["Text"].Size() self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2) + - if self.Active == true { - self.Parent.(*MusicPlayerPage).Icons["sys"].NewCoord(self.Parent.(*MusicPlayerPage).Width-30, self.PosY+5) - self.Parent.(*MusicPlayerPage).Icons["sys"].Draw() - } + if self.MyType == UI.ICON_TYPES["DIR"] && self.Path != "[..]" { + sys_icon := self.Parent.(*MusicPlayerPage).Icons["sys"] + sys_icon.IconIndex = 0. + sys_icon.NewCoord(self.PosX+12,self.PosY + ( self.Height - sys_icon.Height)/2 + sys_icon.Height /2) + sys_icon.Draw() + } + if self.MyType == UI.ICON_TYPES["FILE"] { + sys_icon := self.Parent.(*MusicPlayerPage).Icons["sys"] + sys_icon.IconIndex = 1 + sys_icon.NewCoord(self.PosX+12,self.PosY + ( self.Height - sys_icon.Height)/2 + sys_icon.Height /2) + sys_icon.Draw() + } + + self.Labels["Text"].Active = self.Active + + self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2) + 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() @@ -64,10 +81,16 @@ func (self *MusicPlayPageListItem) Draw() { self.Labels["Small"].Draw() } - - canvas_ := self.Parent.GetCanvasHWND() - draw.Line(canvas_, &color.Color{169, 169, 169, 255}, + */ + canvas_ := self.Parent.GetCanvasHWND() + draw.Line(canvas_, UI.MySkinManager.GiveColor("Line"), self.PosX, self.PosY+self.Height-1, self.PosX+self.Width, self.PosY+self.Height-1, 1) + if self.PlayingProcess > 0 { + seek_posx := int(self.Width * self.PlayingProcess/100.0) + draw.Line(canvas_, UI.MySkinManager.GiveColor("Active"), + self.PosX, self.PosY+self.Height-2, + self.PosX+seek_posx, self.PosY+self.Height-2, 2) + } }