public ConfigDescriptionViewModel(ConfigDescription configDescription) { Name = configDescription.Name; Type = configDescription.Type; GroupName = configDescription.GroupName; Pattern = configDescription.Pattern; Required = configDescription.Required; ReadOnly = configDescription.ReadOnly; Multiple = configDescription.Multiple; MultipleLimit = configDescription.MultipleLimit; Unit = configDescription.Unit; UnitLabel = configDescription.UnitLabel; Context = configDescription.Context; Label = configDescription.Label; Description = configDescription.Description; Options = configDescription.Options?.ToViewModels(); FilterCriteria = configDescription.FilterCriteria?.ToViewModels(); LimitToOptions = configDescription.LimitToOptions; Advanced = configDescription.Advanced; StepSize = configDescription.StepSize; Verifyable = configDescription.Verifyable; Default = configDescription.Default; Minimum = configDescription.Minimum; Maximum = configDescription.Maximum; _configDescription = configDescription; }
public void OnRegister(BaseUnityPlugin plugin) { var adv1 = new ConfigDescription("", null, new ConfigurationManagerAttributes { IsAdvanced = true, Order = 3 }); DebugOn = plugin.Config.Bind("Debug功能", "调试开关", false, adv1); DebugOutDir = plugin.Config.Bind("Debug功能", "调试路径", "export/", adv1); var adv = new ConfigDescription("", null, new ConfigurationManagerAttributes { IsAdvanced = true }); NodeDocKey = plugin.Config.Bind("Debug功能", "Mod文档导出", KeyCode.P, adv); NodeContent = plugin.Config.Bind("Debug功能", "OutputNode内容(原始格式)", "", adv); NodeFileKey = plugin.Config.Bind("Debug功能", "OutputNode输出(Json格式)", KeyCode.O, adv); NodeFilePath = plugin.Config.Bind("Debug功能", "OutputNode输出路径", "OutputNode.json", adv); JsonFormat = plugin.Config.Bind("Debug功能", "导出时使用json格式", true, adv); JsonPritty = plugin.Config.Bind("Debug功能", "导出json是否格式化", true, adv); BattleFileId = plugin.Config.Bind("Debug功能", "战斗文件Id", "", adv); BattleFileKey = plugin.Config.Bind("Debug功能", "战斗文件保存键", KeyCode.B, adv); BattleFilePath = plugin.Config.Bind("Debug功能", "战斗文件保存路径", "battle/{0}.json", adv); BuffFileId = plugin.Config.Bind("Debug功能", "Buff文件Id", "", adv); BuffFileKey = plugin.Config.Bind("Debug功能", "Buff文件保存键", KeyCode.N, adv); BuffFilePath = plugin.Config.Bind("Debug功能", "Buff文件保存路径", "buff/{0}.json", adv); MovieFileType = plugin.Config.Bind("Debug功能", "过场文件类型", MovieType.Cinematic, adv); MovieFileId = plugin.Config.Bind("Debug功能", "过场文件Id", "", adv); MovieFileKey = plugin.Config.Bind("Debug功能", "过场文件保存键", KeyCode.M, adv); MovieFilePath = plugin.Config.Bind("Debug功能", "过场文件保存路径", "movie/{0}.json", adv); SortSchedule = plugin.Config.Bind("Debug功能", "过场是否重新排序", false, adv); SortSchedule.SettingChanged += (o, e) => { ScheduleGraphConverter.WriteSorted = SortSchedule.Value; }; }
public ConfigEntry <T> Bind <T>(string section, string key, T defaultValue, ConfigDescription configDescription = null, bool?serverAuthoritative = null) { ConfigEntry <T> entry = new ConfigEntry <T>(_mod.Config.Bind(section, key, defaultValue, configDescription), serverAuthoritative != null ? (bool)serverAuthoritative : _DefaultBindAuthority); _configEntries[entry.BaseEntry.Definition.ToString()] = entry; return(entry); }
protected ConfigEntry <T> AddConfig <T>(string key, T defaultValue, ConfigDescription configDescription) { ConfigDescription orderedConfigDescription = new ConfigDescription(configDescription.Description, configDescription.AcceptableValues); ConfigEntry <T> entry = PluginEntry.Configuration.Bind(Name, key, defaultValue, orderedConfigDescription); entry.SettingChanged += ReloadHooks; return(entry); }
private void DescriptionCallback(ConfigDescription m) { latestDescription = m; if (descriptionCallback != null) { descriptionCallback(latestDescription); } }
public Model( XmlSchemaSet schemes, Config config, ConfigDescription configDescription ) { this.schemes = schemes; this.config = config; this.configDescription = configDescription; }
public OmegaMod() { Config = base.Config; Logger = base.Logger; var sizeDescription = new ConfigDescription("Shield Growth Rate"); var sizeDefinition = new ConfigDefinition("Shield", "SizePerSecond"); _sizePerSecond = Config.Bind(sizeDefinition, 1f, sizeDescription); }
private static ConfigEntry <bool> BindBool(ConfigFile file, string section, string key, bool defaultVal, string description, string title) { ConfigDefinition def = new ConfigDefinition(section, key); ConfigDescription cd = new ConfigDescription(description); var entry = BindConfig(file, def, cd, defaultVal); VRSettings.Add(new BepinGTFOSettingBool(title, eSettingInputType.BoolToggle, (eCellSettingID)baseVRConfigID, entry, defaultVal)); return(entry); }
protected ConfigEntry <T> AddConfig <T>(string settingShortDescr, T value, ConfigDescription configDescription) { ConfigDescription orderedConfigDescription = new ConfigDescription(configDescription.Description, configDescription.AcceptableValues, new ConfigurationManagerAttributes { Order = --ConfigOrder }); ConfigEntry <T> entry = Config.Bind(Name, settingShortDescr, value, orderedConfigDescription); entry.SettingChanged += ReloadContent; return(entry); }
private static ConfigEntry <string> BindStringDropdown(ConfigFile file, string section, string key, string defaultVal, string description, string title, string[] possibleValues) { AcceptableValueList <string> acceptableValues = new AcceptableValueList <string>(possibleValues); ConfigDefinition def = new ConfigDefinition(section, key); ConfigDescription cd = new ConfigDescription(description, acceptableValues); var entry = BindConfig(file, def, cd, defaultVal); VRSettings.Add(new BepinGTFOSettingString(title, eSettingInputType.StringArrayDropdown, (eCellSettingID)baseVRConfigID, entry, defaultVal, possibleValues)); return(entry); }
private static ConfigEntry <float> BindFloat(ConfigFile file, string section, string key, float defaultVal, float minVal, float maxVal, string description, string title) { AcceptableValueBase a = new AcceptableValueRange <float>(minVal, maxVal); ConfigDefinition def = new ConfigDefinition(section, key); ConfigDescription cd = new ConfigDescription(description, a); var entry = BindConfig(file, def, cd, defaultVal); VRSettings.Add(new BepinGTFOSettingFloat(title, eSettingInputType.FloatSlider, (eCellSettingID)baseVRConfigID, entry, defaultVal, minVal, maxVal)); return(entry); }
ConfigEntry <T> config <T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { ConfigEntry <T> configEntry = Config.Bind(group, name, value, description); SyncedConfigEntry <T> syncedConfigEntry = configSync.AddConfigEntry(configEntry); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return(configEntry); }
public void OnRegister(BaseUnityPlugin plugin) { Plugin = plugin; ExtDrop = plugin.Config.Bind("扩展功能", "战场掉落", false, "特定关卡敌方掉落,游玩剑击江湖请勾选"); var adv = new ConfigDescription("", null, new ConfigurationManagerAttributes { IsAdvanced = true }); DropRateCharacter = Plugin.Config.Bind("扩展功能", "战场掉落率(人物)", 0.02f, adv); DropRateSkillMantra = Plugin.Config.Bind("扩展功能", "战场掉落率(秘籍)", 0.04f, adv); DropRateEquip = Plugin.Config.Bind("扩展功能", "战场掉落率(装备)", 0.05f, adv); }
public static Model Create( XmlSchemaSet schemes, Config config, ConfigDescription configDescription ) { var _this = new Model(); _this.schemes = schemes; _this.config = config; _this.configDescription = configDescription; return(_this); }
public void RepairManagerDefinitionTest() { string configCsvPath = Path.Combine(Utility.TestDirectory, "Configurations.csv"); FabricSettingsMetadata metadata = FabricSettingsMetadata.Create(configCsvPath); ConfigDescription desc = null; metadata.TryGetConfigDescription(StringConstants.SectionName.RepairManager, StringConstants.ParameterName.TargetReplicaSetSize, out desc); Assert.AreEqual(desc.DefaultValue, "0"); Assert.AreEqual(desc.UpgradePolicy, UpgradePolicy.SingleChange); metadata.TryGetConfigDescription(StringConstants.SectionName.RepairManager, StringConstants.ParameterName.MinReplicaSetSize, out desc); Assert.AreEqual(desc.DefaultValue, "0"); Assert.AreEqual(desc.UpgradePolicy, UpgradePolicy.SingleChange); }
internal ConfigEntry(ConfigFile configFile, ConfigDefinition definition, T defaultValue, ConfigDescription configDescription) : base(configFile, definition, typeof(T), defaultValue, configDescription) { configFile.SettingChanged += (sender, args) => { if (args.ChangedSetting == this) { SettingChanged?.Invoke(sender, args); } }; }
ConfigEntry <T> config <T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { configSync = new ConfigSync(Info.Metadata.GUID) { DisplayName = Info.Metadata.Name, CurrentVersion = Info.Metadata.Version.ToString() }; ConfigEntry <T> configEntry = Config.Bind(group, name, value, description); SyncedConfigEntry <T> syncedConfigEntry = configSync.AddConfigEntry(configEntry); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return(configEntry); }
private void DescriptionRecieved(ConfigDescription cd) { def = cd.dflt; max = cd.max; min = cd.min; Dispatcher.BeginInvoke(new Action(() => { SortedList <int, DynamicReconfigureGroup> hierarchy = new SortedList <int, DynamicReconfigureGroup>(); foreach (Group g in cd.groups) { DynamicReconfigureGroup drg = new DynamicReconfigureGroup(g, def, min, max, name, dynamic); hierarchy.Add(drg.id, drg); } GroupHolder.Children.Add(hierarchy[0]); })); }
private void InitUncensorConfigs <T>(string sex, string part, Dictionary <string, T> uncensorDictionary, string[] defaultChoices, int order, out ConfigEntry <string> defaultConf, out ConfigEntry <string> excludeConf) where T : IUncensorData { byte sexValue = (byte)(sex == "Male" ? 0 : 1); if (!RandomExcludedSets.TryGetValue(sexValue, out var sexExcluded)) { sexExcluded = RandomExcludedSets[sexValue] = new Dictionary <string, HashSet <string> >(StringComparer.OrdinalIgnoreCase); } if (!sexExcluded.TryGetValue(part, out var partExcluded)) { partExcluded = sexExcluded[part] = new HashSet <string>(StringComparer.OrdinalIgnoreCase); } var defaultDescAttrs = new ConfigurationManagerAttributes { Order = order }; var defaultDesc = new ConfigDescription($"{part} to use if the character does not have one set. The {(part == "Body" ? "censored" : "mosaic")} {part.ToLower()} will not be selected randomly if there are any alternatives.", new AcceptableValueList <string>(defaultChoices), defaultDescAttrs); defaultConf = Config.Bind("Config", $"Default {sex} {part}", "Random", defaultDesc); var settingsGUI = new SettingsGUI <T>(uncensorDictionary, sexValue, part); SettingsGUIs.Add(settingsGUI); var excludedDescAttrs = new ConfigurationManagerAttributes { HideDefaultButton = true, CustomDrawer = settingsGUI.DrawSettingsGUI, Order = order }; var excludedDesc = new ConfigDescription($"{part} uncensors to exclude from random selection for {sex.ToLower()}s", null, excludedDescAttrs); excludeConf = Config.Bind("Random Excluded", $"{sex} {part}", string.Empty, excludedDesc); //Apply initial config file value now UpdateGuidSet(excludeConf.Value, partExcluded); //Update on change excludeConf.SettingChanged += (s, a) => { if (!(a is SettingChangedEventArgs args) || !(args.ChangedSetting is ConfigEntry <string> conf)) { Logger.LogError("Unexpected error, unable to handle changed settings."); return; } UpdateGuidSet(conf.Value, partExcluded); }; }
PluginEntry() { #if DEBUG Logger.LogWarning("This is an experimental build!"); #endif rng = new Random(); statDefs = new List <DumbStat>(); StatsToAdd = Config.Bind("main", "amount", 5, "How many stats to add to the end screen."); disablePoints = Config.Bind("miscellaneous", "Disable points in the end screen?", false); List <string> stringBuilder = new List <string>(); var types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type tInfo in types) { if (typeof(DumbStat).IsAssignableFrom(tInfo)) { var statAttrs = tInfo.GetCustomAttribute <DumbStatDefAttribute>(); if (statAttrs != null) { var stat = (DumbStat)Activator.CreateInstance(tInfo); statDefs.Add(stat); stringBuilder.Add(stat.Definition.displayToken); } } } ConfigDefinition bl = new ConfigDefinition("main", "blacklist"); ConfigDescription bld = new ConfigDescription("Possible values: " + string.Join(";", stringBuilder)); blackList = Config.Bind <string>(bl, "", bld); var version = Config.Bind <string>("miscellaneous", "config version", VERSION); if (Version.Parse(VERSION).CompareTo(Version.Parse(version.Value)) != 0) { string hold = blackList.Value; blackList = null; Config.Remove(bl); Config.Save(); version.Value = VERSION; blackList = Config.Bind <string>(bl, "", bld); blackList.Value = hold; } BlackList = new List <string>(blackList.Value.Split(';', ',', ' ')); }
private void DescriptionRecieved(ConfigDescription cd) { def = cd.dflt; max = cd.max; min = cd.min; Dispatcher.BeginInvoke(new Action(() => { GroupHolder.Children.Clear(); SortedList<int, DynamicReconfigureGroup> hierarchy = new SortedList<int, DynamicReconfigureGroup>(); foreach (Group g in cd.groups) { DynamicReconfigureGroup drg = new DynamicReconfigureGroup(g, def, min, max, Namespace, dynamic); hierarchy.Add(drg.id, drg); drg.BoolChanged += (a, v) => { if (BoolChanged != null) BoolChanged(a, v); }; drg.IntChanged += (a, v) => { if (IntChanged != null) IntChanged(a, v); }; drg.StringChanged += (a, v) => { if (StringChanged != null) StringChanged(a, v); }; drg.DoubleChanged += (a, v) => { if (BoolChanged != null) DoubleChanged(a, v); }; } GroupHolder.Children.Add(hierarchy[0]); })); }
/// <summary> /// Types of defaultValue and definition.AcceptableValues have to be the same as settingType. /// </summary> internal ConfigEntryBase(ConfigFile configFile, ConfigDefinition definition, Type settingType, object defaultValue, ConfigDescription configDescription) { ConfigFile = configFile ?? throw new ArgumentNullException(nameof(configFile)); Definition = definition ?? throw new ArgumentNullException(nameof(definition)); SettingType = settingType ?? throw new ArgumentNullException(nameof(settingType)); Description = configDescription ?? ConfigDescription.Empty; if (Description.AcceptableValues != null && !SettingType.IsAssignableFrom(Description.AcceptableValues.ValueType)) { throw new ArgumentException("configDescription.AcceptableValues is for a different type than the type of this setting"); } DefaultValue = defaultValue; // Free type check and automatically calls ClampValue in case AcceptableValues were provided BoxedValue = defaultValue; }
private void DescriptionRecieved(ConfigDescription cd) { def = cd.dflt; max = cd.max; min = cd.min; Dispatcher.BeginInvoke(new Action(() => { GroupHolder.Children.Clear(); SortedList <int, DynamicReconfigureGroup> hierarchy = new SortedList <int, DynamicReconfigureGroup>(); foreach (Group g in cd.groups) { DynamicReconfigureGroup drg = new DynamicReconfigureGroup(g, def, min, max, Namespace, dynamic); hierarchy.Add(drg.id, drg); drg.BoolChanged += (a, v) => { if (BoolChanged != null) { BoolChanged(a, v); } }; drg.IntChanged += (a, v) => { if (IntChanged != null) { IntChanged(a, v); } }; drg.StringChanged += (a, v) => { if (StringChanged != null) { StringChanged(a, v); } }; drg.DoubleChanged += (a, v) => { if (BoolChanged != null) { DoubleChanged(a, v); } }; } GroupHolder.Children.Add(hierarchy[0]); })); }
private void Awake() { if (StudioAPI.InsideStudio) { throw new NotImplementedException("Shouldn't load in studio"); } Instance = this; Logger = base.Logger; var windDescr = new ConfigDescription("Drag bottom right corner of the window to change these.", null, new ConfigurationManagerAttributes { IsAdvanced = true }); AddWinRect = Config.Bind("Windows", "Editor window rect", new Rect(10, 10, 500, 350), windDescr); ListWinRect = Config.Bind("Windows", "List window rect", new Rect(510, 10, 700, 350), windDescr); VarWinRect = Config.Bind("Windows", "Inspect window rect", new Rect(1220, 10, 370, 350), windDescr); SolidBackground = Config.Bind("Windows", "Solid window background", true, "Make window background solid for easier reading. If false, windows are transparent."); OpenShortcut = Config.Bind("General", "Open ADV editor", new KeyboardShortcut(KeyCode.Pause, KeyCode.LeftShift)); _hi = Harmony.CreateAndPatchAll(typeof(PreventAdvCrashHooks), GUID); #if DEBUG #if KK if (Manager.Game.Instance?.actScene?.isEventNow == true) { _advEditor.Enabled = true; } #elif KKS if (ActionScene.initialized && ActionScene.instance.isEventNow) { _advEditor.Enabled = true; } #endif #endif }
private void config() { const string sectionName = "may the day treat you well"; ConfigDefinition moveSpeedDef = new ConfigDefinition(sectionName, "Set Move Speed"); ConfigDescription moveSpeedDesc = new ConfigDescription($"Set Beetle Move Speed to this amount (base is {_origBaseMoveSpeed})"); SetMoveSpeed = Config.Bind <float>(moveSpeedDef, 9.5f, moveSpeedDesc); ConfigDefinition attackSpeedDef = new ConfigDefinition(sectionName, "Attack Speed Multiplier"); ConfigDescription attackSpeedDesc = new ConfigDescription("Multiply Beetle Attack Speed by this amount"); MultAttackSpeed = Config.Bind <float>(attackSpeedDef, 2f, attackSpeedDesc); ConfigDefinition levelAttackSpeedDef = new ConfigDefinition(sectionName, "Set Level Attack speed"); ConfigDescription levelAttackSpeedDesc = new ConfigDescription("Set Beetle Attack speed gained per level"); SetLevelAttackSpeed = Config.Bind <float>(levelAttackSpeedDef, 0.1f, levelAttackSpeedDesc); ConfigDefinition damageDef = new ConfigDefinition(sectionName, "Damage Multipier"); ConfigDescription damageDesc = new ConfigDescription("Multiply Beetle Damage by this amount"); MultDamage = Config.Bind <float>(damageDef, 0.8f, damageDesc); }
/// <summary> /// 初始化系统参数配置信息 /// </summary> public void Init() { //所有选项值 List <Options> listOption = ConfigService.GetAllOptions(); ConfigDescription desc = null; //代码现有配置项 foreach (ConfigOption item in AllConfig) { //反射读取配置项ConfigTypeAttribute ConfigAttribute 信息 desc = ConfigDescriptionCache.GetTypeDiscription(item.GetType()); //设置当前配置项的GroupType desc.GroupTypePropertyInfo.SetValue(item, Convert.ChangeType(desc.Group, desc.GroupTypePropertyInfo.PropertyType), null); //每项值信息 List <Options> itemOptions = listOption.Where(e => e.OptionType.Equals(desc.Group, StringComparison.OrdinalIgnoreCase)).ToList(); Options op = null; ConfigAttribute ca = null; foreach (PropertyInfo prop in desc.StaticPropertyInfo) { op = itemOptions.FirstOrDefault(e1 => e1.Key.Equals(prop.Name, StringComparison.OrdinalIgnoreCase)); ca = desc.MemberDict[prop.Name]; if (op == null) { //设置默认值 prop.SetValue(null, Convert.ChangeType(ca.DefaultValue, prop.PropertyType), null); } else { prop.SetValue(null, Convert.ChangeType(op.Value, prop.PropertyType), null); } } } }
private void DescriptionCallback(ConfigDescription m) { latestDescription = m; if (descriptionCallback != null) descriptionCallback(latestDescription); }
public static void SetConfig(string name, ConfigFile config) { var minConfigDescription = new ConfigDescription( "Dungeons will generate with at least this many rooms placed. \n" + "In vanilla Valheim, this value is 3.", new AcceptableValueRange <int>(0, 200)); minimumDungeonSize = config.Bind(name + ".Global", "min_rooms", 15, minConfigDescription); var maxConfigDescription = new ConfigDescription( "Dungeons will attempt to place this many rooms. \n" + "In vanilla Valheim, this value varies based on dungeon type but tends to be 30 or 40." + "Expect fps drops in dungeons if this is over 100.", new AcceptableValueRange <int>(0, 200)); maximumDungeonSize = config.Bind(name + ".Global", "max_rooms", 60, maxConfigDescription); var minCampDescription = new ConfigDescription( "Camps will generate with at least this many components placed. \n", new AcceptableValueRange <int>(0, 80)); minimumCampSize = config.Bind(name + ".Global", "camp_min", 25, minCampDescription); var maxCampDescription = new ConfigDescription( "Camps will attempt to place this many components.", new AcceptableValueRange <int>(0, 80)); maximumCampSize = config.Bind(name + ".Global", "camp_max", 40, maxCampDescription); var mobMinLvlDescription = new ConfigDescription( "Minimum level of dungeon/point of interest mobs. Level 1 (default) means Zero stars.", new AcceptableValueRange <int>(0, 10)); minMobLevel = config.Bind(name + ".Global", "mob_min_lvl", 1, mobMinLvlDescription); var mobMaxLvlDescription = new ConfigDescription( "Maximum level of dungeon/point of interest mobs. Level 3 (default) means 2 Stars.", new AcceptableValueRange <int>(0, 10)); maxMobLevel = config.Bind(name + ".Global", "mob_max_lvl", 3, mobMaxLvlDescription); var mobLevelChanceDescription = new ConfigDescription( "Chance for dungeon/point of interest mobs to spawn higher than the minimum level.", new AcceptableValueRange <int>(0, 100)); mobLevelChance = config.Bind(name + ".Global", "mob_lvl_chance", 15, mobLevelChanceDescription); var mobScaleDescription = new ConfigDescription( "How much bigger are higher level mobs?" + "Percentage, per level", new AcceptableValueRange <int>(0, 500)); mobScale = config.Bind(name + ".Global", "mob_scale", 10, mobScaleDescription); var newWorldDescription = new ConfigDescription( "If you're running this on a world that existed before the mod was installed, change the value to false"); isNewWorld = config.Bind(name + ".Global", "new_world", true, newWorldDescription); isDefaultDifficulty = minMobLevel.Value == 1 && maxMobLevel.Value == 3 && mobLevelChance.Value == 15; }
protected ConfigEntry <T> Bind <T>(string name, T defaultValue, ConfigDescription description) { return(UtilityPackPlugin.Instance.Config.Bind(new ConfigDefinition(this.Name, name), defaultValue, description)); }
public static ConfigEntry <TConf> ConfigEntryBind <TConf>(this IRedirectorHandler handler, string key, TConf defaultValue, ConfigDescription description) { return(handler.Plugin.Config.Bind <TConf>(handler.ConfigSectionName, key, defaultValue, description)); }
public Configure(string name, ConfigDescription type) { this.name = name; this.type = type; }
private static ConfigEntry <T> BindConfig <T>(ConfigFile file, ConfigDefinition definition, ConfigDescription cd, T defaultValue) { baseVRConfigID++; var entry = file.Bind <T>(definition, defaultValue, cd); return(entry); }