Exemplo n.º 1
0
        /**
         * add a song to the queue
         */
        public void AddQueueSong(QueuedSong qs, bool sendMessage)
        {
            StaticData.QueueList.Add(qs);
            if (StaticData.QueueList.Count == 1)
            {
                StaticData.SongAddedToQueueEvent?.Invoke(qs);
            }

            if (sendMessage)
            {
                SendMessage(qs.RequestedBy + " added \"" + qs.SongName + "\", uploaded by " + qs.AuthName + " to queue!");
            }
        }
Exemplo n.º 2
0
        private void BlacklistSong(QueuedSong song, bool isAdd)
        {
            if (song.Id == null)
            {
                return;
            }
            if (isAdd && _banList.Contains(song.Id) || !isAdd && !_banList.Contains(song.Id))
            {
                SendMessage(isAdd ? "Song already on banlist." : "Song is not on banlist.");
                return;
            }

            if (isAdd)
            {
                _banList.Add(song.Id);
            }
            else
            {
                _banList.Remove(song.Id);
            }

            if (!File.Exists("Plugins\\Config\\song_blacklist.txt"))
            {
                return;
            }

            // add song to blacklist.txt
            if (isAdd)
            {
                // add song id to file
                File.AppendAllText("Plugins\\Config\\song_blacklist.txt", song.Id + Environment.NewLine);
                // send feedback
                SendMessage("Added \"" + song.SongName + "\", uploaded by " + song.AuthName + " to banlist!");

                return;
            }

            // remove song from blacklist.txt (list remaining songs)
            var bannedSongs = "";

            foreach (string banValue in _banList)
            {
                bannedSongs += banValue + Environment.NewLine;
            }

            File.WriteAllText("Plugins\\Config\\song_blacklist.txt", bannedSongs);

            // send feedback
            SendMessage("Removed \"" + song.SongName + "\", uploaded by " + song.AuthName + " from banlist!");
        }
        public void Init(QueuedSong song)
        {
            var cell = GetComponent <StandardLevelListTableCell>();

            foreach (var info in cell.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic))
            {
                info.SetValue(this, info.GetValue(cell));
            }

            Destroy(cell);

            _song = song;

            songName = _song.BeatName;
            author   = _song.AuthName;
            StartCoroutine(TwitchIntegrationUi.LoadSprite(_song.CoverUrl, this));
        }
Exemplo n.º 4
0
        /**
         * load queue from song_queue.txt
         */
        private void LoadQueue()
        {
            // create config directory if not exists
            CreateConfigDirectory();

            // ignore load if file doesn't exists
            if (!File.Exists("Plugins\\Config\\song_queue.txt"))
            {
                return;
            }

            // get json from file
            var    file = new StreamReader("Plugins\\Config\\song_queue.txt");
            var    json = "";
            string line;

            while ((line = file.ReadLine()) != null)
            {
                json += line;
            }

            var node = JSON.Parse(json);

            for (var i = 0; i < node.Count; i++)
            {
                var song = node[i];
                var qs   = new QueuedSong(
                    song["songName"],
                    song["name"],
                    song["authorName"],
                    song["bpm"],
                    song["id"],
                    song["songSubName"],
                    song["downloadUrl"],
                    song["requestedBy"],
                    song["coverUrl"]
                    );
                AddQueueSong(qs, false);
            }

            file.Close();
        }