示例#1
0
        public static void Postfix(LevelGridMenu __instance)
        {
            if (__instance.DisplayType_ == LevelSelectMenuAbstract.DisplayType.GameLobby)
            {
                return;
            }

            LockingSystem.CreateProfile();
            if (__instance.isCampaignMode_)
            {
                foreach (var campaign in Campaigns.Items)
                {
                    if (campaign.Value.Enabled)
                    {
                        __instance.CreateAndAddCampaignLevelSet(campaign.Value.GetLevelSet(campaign.Value.GameMode, false), campaign.Value.Name, true, unlock_mode, campaign.Value.GameMode);
                    }
                }
            }
            else if (__instance.modeID_ == GameModeID.Sprint)
            {
                foreach (var campaign in Campaigns.Items)
                {
                    if (campaign.Value.Enabled && campaign.Value.ShowInArcade)
                    {
                        LevelSet set = campaign.Value.GetLevelSet(GameModeID.Sprint, true);

                        LevelPlaylist playlist = LevelPlaylist.Create(set, $"{Constants.Strings.CampaignEntry_Color}{campaign.Value.Name}[-]");

                        bool unlocked = LockingSystem.IsCampaignComplete(campaign.Value.Id);
                        __instance.CreateAndAddEntry(playlist, LevelGridMenu.PlaylistEntry.Type.Campaign, unlocked, sprint_unlock_mode);
                    }
                }
            }
            __instance.buttonList_.SortAndUpdateVisibleButtons();
        }
示例#2
0
        public bool savePlaylist(LevelPlaylist selectedPlaylist, string name)
        {
            // playlists are attached to game objects
            // when a new level loads, all existing game objects are destroyed so we cannot properly save them
            // instead, we make a new one and copy the old playlist into the new object.
            LevelPlaylist list = LevelPlaylist.Create(true);

            list.CopyFrom(selectedPlaylist);
            list.IsCustom_   = true;
            selectedPlaylist = list;
            switch (name)
            {
            case "current":
            {
                if (canUseCurrentPlaylist)
                {
                    G.Sys.GameManager_.LevelPlaylist_.CopyFrom(selectedPlaylist);
                    G.Sys.GameManager_.LevelPlaylist_.SetIndex(0);
                    GeneralUtilities.updateGameManagerCurrentLevel();
                    StaticTargetedEvent <Events.ServerToClient.SetLevelName.Data> .Broadcast(RPCMode.All, G.Sys.GameManager_.CreateSetLevelNameEventData());

                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case "upcoming":
            {
                if (canUseCurrentPlaylist)
                {
                    var currentPlaylist = G.Sys.GameManager_.LevelPlaylist_;
                    if (currentPlaylist.Count_ > currentPlaylist.Index_ + 1)
                    {
                        currentPlaylist.Playlist_.RemoveRange(currentPlaylist.Index_ + 1, currentPlaylist.Count_ - currentPlaylist.Index_ - 1);
                    }
                    foreach (LevelPlaylist.ModeAndLevelInfo level in selectedPlaylist.Playlist_)
                    {
                        currentPlaylist.Add(level);
                    }
                    currentPlaylist.IsCustom_ = true;
                    GeneralUtilities.updateGameManagerCurrentLevel();
                    StaticTargetedEvent <Events.ServerToClient.SetLevelName.Data> .Broadcast(RPCMode.All, G.Sys.GameManager_.CreateSetLevelNameEventData());

                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case "active":
            {
                return(true);
            }

            default:
            {
                selectedPlaylist.Name_ = name;
                selectedPlaylist.Save();
                return(true);
            }
            }
        }
示例#3
0
        public override void use(ClientPlayerInfo p, string message)
        {
            Match playlistCmdMatch = Regex.Match(message, @"^(\w+) ?(.*)$");

            if (!playlistCmdMatch.Success)
            {
                help(p);
                return;
            }
            MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p));
            string uniquePlayerString = GeneralUtilities.getUniquePlayerString(p);
            string playlistCmd        = playlistCmdMatch.Groups[1].Value.ToLower();
            string playlistCmdData    = playlistCmdMatch.Groups[2].Value;

            switch (playlistCmd)
            {
            default:
                MessageUtilities.sendMessage($"[A00000]Invalid sub-command `{playlistCmd}`[-]");
                help(p);
                break;

            case "list":
            {
                List <string> playlists = getPlaylists(playlistCmdData);
                var           results   = "";
                foreach (string playlist in playlists)
                {
                    results += "\n" + (playlist == "current" ? playlist : Resource.GetFileNameWithoutExtension(playlist));
                }
                if (results == "")
                {
                    results = "None";
                }
                MessageUtilities.sendMessage("[FFFFFF]Playlists: [-]" + results);
                break;
            }

            case "new":
            {
                LevelPlaylist list = LevelPlaylist.Create(true);
                list.Name_ = "New Playlist";
                FilteredPlaylist levels = new FilteredPlaylist(GeneralUtilities.getAllLevelsAndModes());
                GeneralUtilities.addFiltersToPlaylist(levels, p, playlistCmdData, true);
                list.Playlist_.AddRange(levels.Calculate().levelList);
                selectedPlaylists[uniquePlayerString] = list;
                MessageUtilities.sendMessage("[FFFFFF]New playlist with...[-]");
                MessageUtilities.sendMessage(GeneralUtilities.getPlaylistText(levels, GeneralUtilities.IndexMode.Final, levelFormat));
                break;
            }

            case "load":
            {
                int           matchingCount    = 0;
                LevelPlaylist selectedPlaylist = getPlaylistLevels(playlistCmdData, out matchingCount, getActivePlaylist(p));
                if (matchingCount == 0)
                {
                    MessageUtilities.sendMessage("[A00000]Could not find any playlists with that search[-]");
                    break;
                }
                else if (matchingCount == 1)
                {
                    MessageUtilities.sendMessage($"{selectedPlaylist.Name_} is now active");
                }
                else
                {
                    MessageUtilities.sendMessage($"{selectedPlaylist.Name_} is now active, but {matchingCount - 1} others matched too");
                }

                selectedPlaylists[uniquePlayerString] = selectedPlaylist;
                break;
            }

            case "save":
            {
                LevelPlaylist selectedPlaylist;
                if (!selectedPlaylists.TryGetValue(uniquePlayerString, out selectedPlaylist))
                {
                    MessageUtilities.sendMessage("[A00000]You have no active playlist[-]");
                    break;
                }
                if (selectedPlaylist.Playlist_.Count == 0)
                {
                    MessageUtilities.sendMessage("[A00000]Your active playlist is empty[-]");
                    break;
                }
                if (playlistCmdData == "")
                {
                    MessageUtilities.sendMessage($"[A05000]No name given. Using existing name: {selectedPlaylist.Name_}");
                    playlistCmdData = selectedPlaylist.Name_;
                }
                bool result = savePlaylist(selectedPlaylist, playlistCmdData);
                switch (playlistCmdData)
                {
                case "current":
                    if (result)
                    {
                        MessageUtilities.sendMessage("Set current playlist to active playlist.");
                    }
                    else
                    {
                        MessageUtilities.sendMessage("You cannot save to the current playlist right now.");
                    }
                    break;

                case "upcoming":
                    if (result)
                    {
                        MessageUtilities.sendMessage("Set upcoming levels to active playlist.");
                    }
                    else
                    {
                        MessageUtilities.sendMessage("You cannot save to the current playlist right now.");
                    }
                    break;

                case "active":
                    MessageUtilities.sendMessage("No changes made.");
                    break;

                default:
                    selectedPlaylist.Name_ = playlistCmdData;
                    MessageUtilities.sendMessage($"Saved playlist as {playlistCmdData}.");
                    break;
                }
                break;
            }

            case "active":
            {
                LevelPlaylist selectedPlaylist;
                if (!selectedPlaylists.TryGetValue(uniquePlayerString, out selectedPlaylist))
                {
                    MessageUtilities.sendMessage("[A00000]You have no active playlist[-]");
                    break;
                }
                MessageUtilities.sendMessage(selectedPlaylist.Name_);
                break;
            }

            case "del":
            {
                if (playlistCmdData == "")
                {
                    MessageUtilities.sendMessage("[A00000]You must enter a name[-]");
                    break;
                }
                List <string> toDelete;
                var           count = 0;
                if (deleteConfirmation.TryGetValue(uniquePlayerString, out toDelete))
                {
                    if (playlistCmdData.ToLower() == "yes")
                    {
                        foreach (string playlist in toDelete)
                        {
                            FileEx.Delete(playlist);
                            count++;
                        }
                        MessageUtilities.sendMessage($"Deleted {count} playlists.");
                        deleteConfirmation.Remove(uniquePlayerString);
                        break;
                    }
                    else if (playlistCmdData.ToLower() == "no")
                    {
                        deleteConfirmation.Remove(uniquePlayerString);
                        MessageUtilities.sendMessage("Cancelled deletion.");
                        break;
                    }
                }
                var           searchRegex = GeneralUtilities.getSearchRegex(playlistCmdData);
                List <string> playlists   = GeneralUtilities.playlists();
                playlists.RemoveAll((string s) => !Resource.FileExist(s));
                toDelete = new List <string>();
                var results = "";
                foreach (string playlist in playlists)
                {
                    if (Regex.IsMatch(playlist == "current" ? playlist : Resource.GetFileNameWithoutExtension(playlist), searchRegex, RegexOptions.IgnoreCase))
                    {
                        toDelete.Add(playlist);
                        results += "\n" + (playlist == "current" ? playlist : Resource.GetFileNameWithoutExtension(playlist));
                        count++;
                    }
                }
                if (count > 0)
                {
                    deleteConfirmation[uniquePlayerString] = toDelete;
                    MessageUtilities.sendMessage($"[FFFFFF]Use [A05000]!playlist del yes[-] to delete {count} playlists:[-] {results}");
                }
                else
                {
                    MessageUtilities.sendMessage("[A00000]No playlists found[-]");
                }
            }
            break;

            case "show":
            {
                LevelPlaylist selectedPlaylist;
                if (!selectedPlaylists.TryGetValue(uniquePlayerString, out selectedPlaylist))
                {
                    MessageUtilities.sendMessage("[A00000]You have no active playlist[-]");
                    break;
                }
                FilteredPlaylist filterer = new FilteredPlaylist(selectedPlaylist.Playlist_);
                GeneralUtilities.addFiltersToPlaylist(filterer, p, playlistCmdData, false);
                MessageUtilities.sendMessage(GeneralUtilities.getPlaylistText(filterer, GeneralUtilities.IndexMode.Initial, levelFormat));
                break;
            }

            case "filter":
            {
                LevelPlaylist selectedPlaylist;
                if (!selectedPlaylists.TryGetValue(uniquePlayerString, out selectedPlaylist))
                {
                    MessageUtilities.sendMessage("[A00000]You have no active playlist[-]");
                    break;
                }
                FilteredPlaylist filterer = new FilteredPlaylist(selectedPlaylist.Playlist_);
                GeneralUtilities.addFiltersToPlaylist(filterer, p, playlistCmdData, false);
                selectedPlaylist.Playlist_.Clear();
                selectedPlaylist.Playlist_.AddRange(filterer.Calculate().levelList);
                MessageUtilities.sendMessage("[FFFFFF]Filtered:[-]");
                MessageUtilities.sendMessage(GeneralUtilities.getPlaylistText(filterer, GeneralUtilities.IndexMode.Final, levelFormat));
                break;
            }

            case "add":
            {
                LevelPlaylist selectedPlaylist;
                if (!selectedPlaylists.TryGetValue(uniquePlayerString, out selectedPlaylist))
                {
                    MessageUtilities.sendMessage("[A00000]You have no active playlist[-]");
                    break;
                }
                FilteredPlaylist filterer = new FilteredPlaylist(GeneralUtilities.getAllLevelsAndModes());
                GeneralUtilities.addFiltersToPlaylist(filterer, p, playlistCmdData, true);
                selectedPlaylist.Playlist_.AddRange(filterer.Calculate().levelList);
                MessageUtilities.sendMessage("[FFFFFF]Added:[-]");
                MessageUtilities.sendMessage(GeneralUtilities.getPlaylistText(filterer, GeneralUtilities.IndexMode.Final, levelFormat));
                break;
            }

            case "clear":
            {
                LevelPlaylist selectedPlaylist;
                if (!selectedPlaylists.TryGetValue(uniquePlayerString, out selectedPlaylist))
                {
                    MessageUtilities.sendMessage("[A00000]You have no active playlist[-]");
                    break;
                }
                selectedPlaylist.Playlist_.Clear();
                MessageUtilities.sendMessage("[FFFFFF]Cleared[-]");
                break;
            }
            }
            MessageUtilities.popMessageOptions();
        }
示例#4
0
        public LevelPlaylist getPlaylistLevels(string search, out int count, LevelPlaylist activePlaylist)
        {
            var           searchRegex = GeneralUtilities.getSearchRegex(search);
            List <string> playlists   = GeneralUtilities.playlists();

            playlists.RemoveAll((string s) => !Resource.FileExist(s));
            playlists.RemoveAll(playlist => !Regex.IsMatch(Resource.GetFileNameWithoutExtension(playlist), searchRegex, RegexOptions.IgnoreCase));

            if (canUseCurrentPlaylist)
            {
                List <string> miniList = new List <string>();
                miniList.Add("current");
                miniList.Add("upcoming");
                miniList.Add("active");
                miniList.RemoveAll(playlist => !Regex.IsMatch(playlist, searchRegex, RegexOptions.IgnoreCase));
                playlists.AddRange(miniList);
            }
            count = playlists.Count;
            if (playlists.Count == 0)
            {
                return(null);
            }
            var           selectedPlaylist = playlists[0];
            LevelPlaylist playlistComp;

            switch (selectedPlaylist)
            {
            case "current":
            {
                playlistComp = LevelPlaylist.Create(true);
                playlistComp.CopyFrom(G.Sys.GameManager_.LevelPlaylist_);
                playlistComp.Name_ = "current";
                break;
            }

            case "upcoming":
            {
                playlistComp = LevelPlaylist.Create(true);
                var currentList = G.Sys.GameManager_.LevelPlaylist_;
                for (int i = currentList.Index_ + 1; i < currentList.Count_; i++)
                {
                    playlistComp.Playlist_.Add(currentList.Playlist_[i]);
                }
                playlistComp.Name_ = "upcoming";
                break;
            }

            case "active":
            {
                if (activePlaylist == null)
                {
                    return(null);
                }
                playlistComp = LevelPlaylist.Create(true);
                playlistComp.CopyFrom(activePlaylist);
                playlistComp.Name_ = activePlaylist.Name_;
                break;
            }

            default:
            {
                var gameObject = LevelPlaylist.Load(selectedPlaylist);
                playlistComp = gameObject.GetComponent <LevelPlaylist>();
                break;
            }
            }
            return(playlistComp);
        }