Example #1
0
        // Add a player selector
        private static void MultiplayerMenu_ctor(On.Menu.MultiplayerMenu.orig_ctor orig, MultiplayerMenu self, ProcessManager manager)
        {
            orig(self, manager);

            // Place relative to the first join button
            self.pages[0].subObjects.Add(new PlayerSelector(self, self.pages[0], self.playerJoinButtons[0].pos + new Vector2(-1f, -40f)));
        }
        /// <summary>
        ///
        /// </summary>
        private static void MultiplayerMenu_ctor(On.Menu.MultiplayerMenu.orig_ctor orig, Menu.MultiplayerMenu self, ProcessManager manager)
        {
            orig(self, manager);

            foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks)
            {
                string path = Custom.RootFolderDirectory() + CustomWorldMod.resourcePath + keyValues.Value + Path.DirectorySeparatorChar + "Levels";
                if (Directory.Exists(path))
                {
                    CustomWorldMod.Log($"Custom Regions: Loading arena(s) from [{keyValues.Value}]");

                    string[] files = Directory.GetFiles(path);

                    for (int i = 0; i < files.Length; i++)
                    {
                        if (files[i].Substring(files[i].Length - 4, 4) == ".txt" && files[i].Substring(files[i].Length - 13, 13) != "_Settings.txt" && files[i].Substring(files[i].Length - 10, 10) != "_Arena.txt" && !files[i].Contains(CustomWorldMod.customUnlocksFileName))
                        {
                            string[] array = files[i].Substring(0, files[i].Length - 4).Split(new char[]
                            {
                                Path.DirectorySeparatorChar
                            });
                            self.allLevels.Add(array[array.Length - 1]);
                        }
                        for (int j = self.allLevels.Count - 1; j >= 0; j--)
                        {
                            if (!self.multiplayerUnlocks.IsLevelUnlocked(self.allLevels[j]))
                            {
                                self.allLevels.RemoveAt(j);
                            }
                        }
                        self.allLevels.Sort((string A, string B) => self.multiplayerUnlocks.LevelListSortString(A).CompareTo(self.multiplayerUnlocks.LevelListSortString(B)));
                        foreach (string level in self.allLevels)
                        {
                            if (!self.thumbsToBeLoaded.Contains(level))
                            {
                                self.thumbsToBeLoaded.Add(level);
                            }
                        }

                        /*for (int k = 0; k < self.allLevels.Count; k++)
                         * {
                         *  self.thumbsToBeLoaded.Add(self.allLevels[k]);
                         * }*/
                    }
                }
                string debug  = $"Custom Regions: Loaded arenas [";
                string debug2 = $"Custom Regions: Pending thumbnails [";

                foreach (string level in self.allLevels)
                {
                    debug += level + ", ";
                }
                foreach (string thumb in self.thumbsToBeLoaded)
                {
                    debug2 += thumb + ", ";
                }

                CustomWorldMod.Log(debug + "]");
                //CustomWorldMod.CustomWorldLog(debug2 + "]");
                self.ClearGameTypeSpecificButtons();
                self.InitiateGameTypeSpecificButtons();
            }
        }