diff --git a/Menu/GameShell/97_MusicPlayer/music_lib_list_page.go b/Menu/GameShell/97_MusicPlayer/music_lib_list_page.go new file mode 100644 index 0000000..0778375 --- /dev/null +++ b/Menu/GameShell/97_MusicPlayer/music_lib_list_page.go @@ -0,0 +1,143 @@ +package MusicPlayer + +import ( + //"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" +) + +type MusicLibListPage struct { + UI.Page + ListFontObj *ttf.Font + URLColor *color.Color + TextColor *color.Color + Labels map[string]UI.LabelInterface + Icons map[string]UI.IconItemInterface + + IP string + + MyList []UI.ListItemInterface + MyStack *MusicLibStack + BGwidth int + BGheight int //70 + Scroller *UI.ListScroller + Scrolled int + + Parent *MusicPlayerPage +} + +func NewMusicLibListPage() *MusicLibListPage { + p := &MusicLibListPage{} + p.PageIconMargin = 20 + p.SelectedIconTopOffset = 20 + p.EasingDur = 10 + + p.Align = UI.ALIGN["SLeft"] + + p.FootMsg = [5]string{"Nav.", "", "Scan","Back","Add to Playlist"} + + + p.URLColor = UI.MySkinManager.GiveColor("URL") + p.TextColor = UI.MySkinManager.GiveColor("Text") + p.ListFontObj = UI.MyLangManager.TrFont("notosanscjk15") + + p.Labels = make(map[string]UI.LabelInterface) + + p.Icons = make(map[string]UI.IconItemInterface) + + p.BGwidth = 56 + p.BGheight = 70 + + + return p +} + +func (self *MusicLibListPage) OnLoadCb() { + self.PosY = 0 +} + +func (self *MusicLibListPage) SetCoords() { + +} + +func (self *MusicLibListPage) 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 + + ps := UI.NewInfoPageSelector() + ps.Width = UI.Width - 12 + ps.PosX = 2 + ps.Parent = self + + self.Ps = ps + self.PsIndex = 0 + + 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 + + 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 + + self.Scroller = UI.NewListScroller() + self.Scroller.Parent = self + self.Scroller.PosX = self.Width - 10 + self.Scroller.PosY = 2 + self.Scroller.Init() + +} + +func (self *MusicLibListPage) KeyDown(ev *event.Event) { + if ev.Data["Key"] == UI.CurKeys["Left"] || ev.Data["Key"] == UI.CurKeys["Menu"] { + self.ReturnToUpLevelPage() + self.Screen.Draw() + self.Screen.SwapAndShow() + } + + return +} + +func (self *MusicLibListPage) Draw() { + self.ClearCanvas() + + if len(self.MyList) == 0 { + self.Icons["bg"].NewCoord(self.Width/2, self.Height/2) + self.Icons["bg"].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) + } + +} diff --git a/Menu/GameShell/97_MusicPlayer/music_lib_stack.go b/Menu/GameShell/97_MusicPlayer/music_lib_stack.go new file mode 100644 index 0000000..32743bd --- /dev/null +++ b/Menu/GameShell/97_MusicPlayer/music_lib_stack.go @@ -0,0 +1,64 @@ +package MusicPlayer + +import ( + "sync" +) + +type element struct { + data interface{} + next *element +} + +type MusicLibStack struct { + lock *sync.Mutex + head *element + Size int +} + +func (stk *MusicLibStack) Push(data interface{}) { + stk.lock.Lock() + + element := new(element) + element.data = data + temp := stk.head + element.next = temp + stk.head = element + stk.Size++ + + stk.lock.Unlock() +} + +func (stk *MusicLibStack) Pop() interface{} { + if stk.head == nil { + return nil + } + stk.lock.Lock() + r := stk.head.data + stk.head = stk.head.next + stk.Size-- + + stk.lock.Unlock() + + return r +} + +func (stk *MusicLibStack) Length() int { + return stk.Size +} + +func (stk *MusicLibStack) Last() string { + idx := stk.Length() -1 + if idx < 0 { + return "/" + } else { + return stk.head.data.(string) + } +} + +func NewMusicLibStack() *MusicLibStack { + stk := new(MusicLibStack) + stk.lock = &sync.Mutex{} + return stk +} + + diff --git a/Menu/GameShell/97_MusicPlayer/music_player_page.go b/Menu/GameShell/97_MusicPlayer/music_player_page.go new file mode 100644 index 0000000..ef31bd1 --- /dev/null +++ b/Menu/GameShell/97_MusicPlayer/music_player_page.go @@ -0,0 +1,156 @@ +package MusicPlayer + +import ( + //"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" +) + +type MusicPlayerPage struct { + UI.Page + ListFontObj *ttf.Font + URLColor *color.Color + TextColor *color.Color + Labels map[string]UI.LabelInterface + Icons map[string]UI.IconItemInterface + + IP string + + MyMusicLibListPage *MusicLibListPage + + MyList []UI.ListItemInterface + MyStack *MusicLibStack + BGwidth int + BGheight int //70 + Scroller *UI.ListScroller + Scrolled int + +} + +func NewMusicPlayerPage() *MusicPlayerPage { + p := &MusicPlayerPage{} + p.PageIconMargin = 20 + p.SelectedIconTopOffset = 20 + p.EasingDur = 10 + + p.Align = UI.ALIGN["SLeft"] + + p.FootMsg = [5]string{"Nav","Remove","RTA","Back","Play/Pause"} + + + p.URLColor = UI.MySkinManager.GiveColor("URL") + p.TextColor = UI.MySkinManager.GiveColor("Text") + p.ListFontObj = UI.MyLangManager.TrFont("notosanscjk15") + + p.Labels = make(map[string]UI.LabelInterface) + + p.Icons = make(map[string]UI.IconItemInterface) + + p.BGwidth = 56 + p.BGheight = 70 + + + return p +} + +func (self *MusicPlayerPage) OnLoadCb() { + self.PosY = 0 +} + +func (self *MusicPlayerPage) SetCoords() { + +} + +func (self *MusicPlayerPage) SetLabels() { + +} + +func (self *MusicPlayerPage) 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 + + ps := UI.NewInfoPageSelector() + ps.Width = UI.Width - 12 + ps.PosX = 2 + ps.Parent = self + + self.Ps = ps + self.PsIndex = 0 + + 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 + + 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 + + self.Scroller = UI.NewListScroller() + self.Scroller.Parent = self + self.Scroller.PosX = self.Width - 10 + self.Scroller.PosY = 2 + self.Scroller.Init() + + self.MyMusicLibListPage = NewMusicLibListPage() + self.MyMusicLibListPage.Screen = self.Screen + self.MyMusicLibListPage.Name = "Music Library" + self.MyMusicLibListPage.Parent = self + self.MyMusicLibListPage.Init() +} + +func (self *MusicPlayerPage) KeyDown(ev *event.Event) { + if ev.Data["Key"] == UI.CurKeys["Right"] { + self.Screen.PushPage(self.MyMusicLibListPage) + self.Screen.Draw() + self.Screen.SwapAndShow() + } + if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] { + self.ReturnToUpLevelPage() + self.Screen.Draw() + self.Screen.SwapAndShow() + } + return +} + +func (self *MusicPlayerPage) Draw() { + self.ClearCanvas() + + if len(self.MyList) == 0 { + self.Icons["bg"].NewCoord(self.Width/2, self.Height/2) + self.Icons["bg"].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) + } +} diff --git a/Menu/GameShell/97_MusicPlayer/plugin.json b/Menu/GameShell/97_MusicPlayer/plugin.json new file mode 100644 index 0000000..68d2517 --- /dev/null +++ b/Menu/GameShell/97_MusicPlayer/plugin.json @@ -0,0 +1,5 @@ +{ +"SO_FILE":"", +"NAME":"Music Player" +} + diff --git a/Menu/GameShell/97_MusicPlayer/plugin_init.go b/Menu/GameShell/97_MusicPlayer/plugin_init.go new file mode 100644 index 0000000..286f5ff --- /dev/null +++ b/Menu/GameShell/97_MusicPlayer/plugin_init.go @@ -0,0 +1,38 @@ +package MusicPlayer + +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/clockworkpi/LauncherGoDev/sysgo/UI" + //"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS" +) + +/******************************************************************************/ +type MusicPlayerPlugin struct { + UI.Plugin + MusicPlayerPage *MusicPlayerPage +} + +func (self *MusicPlayerPlugin) Init(main_screen *UI.MainScreen) { + self.MusicPlayerPage = NewMusicPlayerPage() + self.MusicPlayerPage.SetScreen(main_screen) + self.MusicPlayerPage.SetName("Music Player") + self.MusicPlayerPage.Init() +} + +func (self *MusicPlayerPlugin) Run(main_screen *UI.MainScreen) { + if main_screen != nil { + main_screen.PushCurPage() + main_screen.SetCurPage(self.MusicPlayerPage) + main_screen.Draw() + main_screen.SwapAndShow() + } +} + +var APIOBJ MusicPlayerPlugin diff --git a/mainscreen.go b/mainscreen.go index 3b1c047..b58cbfc 100644 --- a/mainscreen.go +++ b/mainscreen.go @@ -21,6 +21,7 @@ import ( "github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings" "github.com/clockworkpi/LauncherGoDev/Menu/GameShell/21_Warehouse" + "github.com/clockworkpi/LauncherGoDev/Menu/GameShell/97_MusicPlayer" "github.com/clockworkpi/LauncherGoDev/Menu/GameShell/98_TinyCloud" "github.com/clockworkpi/LauncherGoDev/Menu/GameShell/99_PowerOFF" @@ -31,6 +32,7 @@ var ( UIPluginList = []*UI.UIPlugin{ &UI.UIPlugin{1, "", "Menu/GameShell/10_Settings", "Settings", &Settings.APIOBJ}, &UI.UIPlugin{1, "", "Menu/GameShell/21_Warehouse", "Warehouse", &Warehouse.APIOBJ}, + &UI.UIPlugin{1, "", "Menu/GameShell/97_MusicPlayer", "Music Player", &MusicPlayer.APIOBJ}, &UI.UIPlugin{1, "", "Menu/GameShell/98_TinyCloud", "TinyCloud", &TinyCloud.APIOBJ}, &UI.UIPlugin{1, "", "Menu/GameShell/99_PowerOFF", "PowerOFF", &PowerOFF.APIOBJ}, }