private Mode(string menuName, ModeSettings settings) : this() { this.menu = new Menu(menuName) { new MenuKeyBool("key", settings.Keys), new MenuList("champSpells", settings.ChampionSpells), new MenuBool("champAuto", settings.ChampionAuto), new MenuList("minions", settings.Minions), new Menu("objects") { new MenuBool("wards", settings.Wards), new MenuBool("clones", settings.Pets), new MenuBool("pets", settings.Pets), new MenuBool("barrel", settings.Pets) }, new MenuBool("flee", settings.Flee), new MenuBool("explosives", settings.Explosives) }; foreach (var item in this.menu.GetDescendants().OfType <MenuValue>()) { item.IsChampSpecific = true; } this.menu.Get <MenuValue>("key").IsChampSpecific = false; }
public void OnModeUpdate(ModeData modeData, ModeSettings modeSettings) { text.text = modeData.modeName; foreach (Transform child in valueHolder.transform) { Destroy(child.gameObject); } foreach (Value value in modeSettings.values) { ValueEntry valueEntry = Instantiate(this.valueEntry) as ValueEntry; valueEntry.SetValue(value); valueEntry.transform.SetParent(valueHolder.transform); } }
bool LobbyModes(Ruleset ruleset) { // Match general if (Match(Kw("General"))) { ruleset.Modes.All = new WorkshopValuePair(); // Init settings dictionary. Match("{"); // Start general settings section. GroupSettings(ruleset.Modes.All, ModeSettingCollection.AllModeSettings.First(modeSettings => modeSettings.ModeName == "All").ToArray()); // Match settings. Match("}"); // End general settings section. return(true); } // Disabled bool disabled = Match(Kw("disabled")); foreach (var mode in ModeSettingCollection.AllModeSettings) { // Match the mode name. if (Match(Kw(mode.ModeName), false)) { ModeSettings relatedModeSettings = ruleset.Modes.SettingsFromModeCollection(mode); // Get the related mode settings from the matched mode. Match("{"); // Start specific mode settings section. // Match the value pairs. GroupSettings(relatedModeSettings.Settings, mode.ToArray(), () => { bool matchingEnabledMaps; // Determines if the map group is matching enabled or disabled maps. // Match enabled maps if (Match(Kw("enabled maps"))) { matchingEnabledMaps = true; } // Match disabled maps else if (Match(Kw("disabled maps"))) { matchingEnabledMaps = false; } // End else { return(false); } Match("{"); // Start map section. List <string> maps = new List <string>(); // Matched maps. // Match map names. bool matched = true; while (matched) { matched = false; // Only match maps related to the current mode. foreach (var map in LobbyMap.AllMaps.Where(m => m.GameModes.Any(mapMode => mapMode.ToLower() == mode.ModeName.ToLower())).OrderByDescending(map => map.GetWorkshopName().Length)) { // Match the map. if (Match(Kw(map.GetWorkshopName()), false)) { // Add the map. maps.Add(map.Name); // Indicate that a map was matched in this iteration. matched = true; break; } } } Match("}"); // End map section. // Add the maps to the mode's settings. if (matchingEnabledMaps) { relatedModeSettings.EnabledMaps = maps.ToArray(); } else { relatedModeSettings.DisabledMaps = maps.ToArray(); } return(true); }); Match("}"); // End specific mode settings section. if (disabled) { relatedModeSettings.Settings.Add("Enabled", !disabled); } return(true); } } return(false); }