public int AddDisk(SongItem DiskItem) { uint SongId = (uint)DiskItem.songID; if (SongId == 0) { return(-1); } SongData SongData = SongManager.GetSong(SongId); if (SongData == null) { return(-1); } if (mLoadedDisks.ContainsKey(DiskItem.itemID)) { return(-1); } mLoadedDisks.Add(DiskItem.itemID, DiskItem); int NewPlaylistId = mPlaylist.Count; lock (mPlaylist) { mPlaylist.Add(NewPlaylistId, new SongInstance(DiskItem, SongData)); } return(NewPlaylistId); }
private static void AddToPlaylist(GameClient Session, ClientMessage Message) { Room Instance = Session.GetHabbo().CurrentRoom; if (Instance == null || !Instance.CheckRights(Session, true) || !Instance.GotMusicController() || Instance.GetRoomMusicController().PlaylistSize >= Instance.GetRoomMusicController().PlaylistCapacity) { return; } UserItem DiskUserItem = Session.GetHabbo().GetInventoryComponent().GetItem(Message.PopWiredUInt()); if (DiskUserItem == null || DiskUserItem.GetBaseItem().InteractionType != InteractionType.musicdisc) { return; } SongItem item = new SongItem(DiskUserItem); int NewOrder = Instance.GetRoomMusicController().AddDisk(item); if (NewOrder < 0) { return; } Session.GetHabbo().GetInventoryComponent().RemoveItem(item.itemID, true); Session.SendMessage(JukeboxComposer.Compose(Instance.GetRoomMusicController().PlaylistCapacity, Instance.GetRoomMusicController().Playlist.Values.ToList())); }
private static void RemoveFromPlaylist(GameClient Session, ClientMessage Message) { Room Instance = Session.GetHabbo().CurrentRoom; if (Instance == null || !Instance.GotMusicController() || !Instance.CheckRights(Session, true)) { return; } SongItem TakenItem = Instance.GetRoomMusicController().RemoveDisk(Message.PopWiredInt32()); // playlist will skip to the next item automatically if it has to if (TakenItem == null) { return; } Session.GetHabbo().GetInventoryComponent().AddNewItem(TakenItem.itemID, TakenItem.baseItem.ItemId, TakenItem.songID.ToString(), true, true); Session.SendMessage(JukeboxComposer.Compose(Session)); Session.SendMessage(JukeboxComposer.Compose(Instance.GetRoomMusicController().PlaylistCapacity, Instance.GetRoomMusicController().Playlist.Values.ToList())); }
public SongInstance(SongItem Item, SongData SongData) { mDiskItem = Item; mSongData = SongData; }
public int AddDisk(SongItem DiskItem) { uint SongId = (uint)DiskItem.songID; if (SongId == 0) { return -1; } SongData SongData = SongManager.GetSong(SongId); if (SongData == null) { return -1; } if (mLoadedDisks.ContainsKey(DiskItem.itemID)) return -1; mLoadedDisks.Add(DiskItem.itemID, DiskItem); int NewPlaylistId = mPlaylist.Count; lock (mPlaylist) { mPlaylist.Add(NewPlaylistId, new SongInstance(DiskItem, SongData)); } return NewPlaylistId; }
internal void LoadMusic() { DataTable dTable; using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT items_rooms_songs.songid,items.* FROM items_rooms_songs LEFT JOIN items ON items.item_id = items_rooms_songs.itemid WHERE items_rooms_songs.roomid = " + this.RoomId); dTable = dbClient.getTable(); } int songID; uint itemID; int baseID; foreach (DataRow dRow in dTable.Rows) { songID = (int)dRow[0]; itemID = Convert.ToUInt32(dRow[1]); baseID = Convert.ToInt32(dRow[2]); SongItem item = new SongItem(itemID, songID, baseID); GetRoomMusicController().AddDisk(item); } }