/// <summary> /// End initialization /// </summary> protected override void OnBeforeInitialModuleScreenSetAsRoot() { var builder = BaseSettingsBuilder.Create("Testing_Global_v4", "MCMv4 Testing Fluent Settings") ! .SetFormat("xml") .SetFolderName(string.Empty) .SetSubFolder(string.Empty) .CreateGroup("Testing 1", groupBuilder => groupBuilder .AddBool("prop_1", "Check Box", new ProxyRef <bool>(() => _boolValue, o => _boolValue = o), boolBuilder => boolBuilder .SetHintText("Test") .SetRequireRestart(false))) .CreateGroup("Testing 2", groupBuilder => groupBuilder .AddInteger("prop_2", "Integer", 0, 10, new ProxyRef <int>(() => _intValue, o => _intValue = o), integerBuilder => integerBuilder .SetHintText("Testing")) .AddFloatingInteger("prop_3", "Floating Integer", 0, 10, new ProxyRef <float>(() => _floatValue, o => _floatValue = o), floatingBuilder => floatingBuilder .SetRequireRestart(true) .SetHintText("Test"))) .CreateGroup("Testing 3", groupBuilder => groupBuilder .AddText("prop_4", "Test", new ProxyRef <string>(() => _stringValue, o => _stringValue = o), null)) .CreateGroup("Testing 4", groupBuilder => groupBuilder .AddButton("prop_5", "Test2", new StorageRef((Action)(() => { })), "Test", null)) .CreatePreset("Test", presetBuilder => presetBuilder .SetPropertyValue("prop_1", true) .SetPropertyValue("prop_2", 2) .SetPropertyValue("prop_3", 1.5F) .SetPropertyValue("prop_4", "HueHueHue")); var globalSettings = builder.BuildAsGlobal(); globalSettings.Register(); //globalSettings.Unregister(); //var perSaveSettings = builder.BuildAsPerSave(); //perSaveSettings.Register(); //perSaveSettings.Unregister(); var path = Path.Combine(Utilities.GetBasePath(), "Modules", "Bannerlord.MBOptionScreen.Tests", "ExternalSettingsTest.xml"); if (!File.Exists(path)) { throw new Exception("Settings does not exist in '/Modules' folder"); } using var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); var externalSettings = ExternalGlobalSettings.CreateFromXmlStream(fs, AssignRefDelegate); externalSettings?.Register(); }
public void InitializeSettings() { bool shouldRegister = false; ModuleInfo KLBShackles = ModuleHelper.GetModules().FirstOrDefault(searchInfo => { return(searchInfo.Id == "KLBShackles"); }); if (KLBShackles != null) { shouldRegister = true; } if (!shouldRegister) { return; } ISettingsBuilder builder = BaseSettingsBuilder.Create("CESettingsIntegrations", "Captivity Events Integrations"); if (builder != null) { builder.SetFormat("json2").SetFolderName("Global").SetSubFolder("zCaptivityEvents"); builder.CreateGroup("Integrations", groupBuilder => { if (KLBShackles != null) { groupBuilder.AddBool("KLBShackles", "KLBShackles (Slave Gear)", new ProxyRef <bool>(() => ActivateKLBShackles, o => ActivateKLBShackles = o), boolBuilder => boolBuilder.SetHintText("Enables equipment of slave gear on player-as-captive.").SetRequireRestart(false)); } }); if (_settings != null) { _settings.Unregister(); } _settings = builder.BuildAsGlobal(); _settings.Register(); } }
public void InitializeSettings(List <CECustomModule> moduleCustoms, List <CEEvent> callableEvents) { ISettingsBuilder builder = BaseSettingsBuilder.Create("CaptivityEventsCustomEvents", "Captivity Events Optional Events"); EventToggle = new Dictionary <string, bool>(); EventSettings = new Dictionary <string, CESettingsEvent>(); int eventModuleId = 0; int eventId = 0; if (builder != null) { builder.SetFormat("json2").SetFolderName("Global").SetSubFolder("zCaptivityEvents"); foreach (CECustomModule module in moduleCustoms) { eventModuleId += 1; eventId = 0; foreach (CEEvent currentEvent in module.CEEvents) { eventId += 1; if (!EventToggle.ContainsKey(currentEvent.Name) && callableEvents.Exists((item) => item.Name == currentEvent.Name)) { string folderName = null; if (currentEvent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Captive)) { folderName = module.CEModuleName + "/{=CESETTINGS0098}Captive"; } else if (currentEvent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Captor)) { folderName = module.CEModuleName + "/{=CESETTINGS0099}Captor"; } else if (currentEvent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Random)) { folderName = module.CEModuleName + "/{=CESETTINGS0088}Random"; } if (folderName == null) { continue; } if (currentEvent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Prostitution)) { folderName += "/{=CESETTINGS1034}Prostitution Events"; } else if (currentEvent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Slavery)) { folderName += "/{=CESETTINGS1042}Slavery Events"; } else if (currentEvent.MultipleRestrictedListOfFlags.Contains(RestrictedListOfFlags.Common)) { folderName += "/{=CESETTINGS1028}Common Events"; } else { folderName += "/{=CESETTINGS1122}Other Events"; } folderName += "/" + currentEvent.Name; builder.CreateGroup(folderName, groupBuilder => { EventToggle.Add(currentEvent.Name, true); EventSettings.Add(currentEvent.Name, new CESettingsEvent()); string hintText = currentEvent.Text.Length <= 300 ? currentEvent.Text : (currentEvent.Text.Substring(0, 300) + "..."); groupBuilder.AddToggle(currentEvent.Name + "_" + eventModuleId + "_" + eventId + "_toggle", "{=CESETTINGS1123}Event", new ProxyRef <bool>(() => EventToggle[currentEvent.Name], o => EventToggle[currentEvent.Name] = o), boolBuilder => boolBuilder.SetHintText(hintText).SetRequireRestart(false).SetOrder(0)); groupBuilder.AddText(currentEvent.Name + "_" + eventModuleId + "_" + eventId + "_weight", "{=CESETTINGS1124}Custom Event Frequency", new ProxyRef <string>(() => EventSettings[currentEvent.Name].WeightedChanceOfOccuring, o => EventSettings[currentEvent.Name].WeightedChanceOfOccuring = o), stringBuilder => stringBuilder.SetHintText("{=CESETTINGS1126}Default is " + currentEvent.WeightedChanceOfOccuring).SetRequireRestart(false).SetOrder(1)); groupBuilder.AddText(currentEvent.Name + "_" + eventModuleId + "_" + eventId + "_image", "{=CESETTINGS1125}Custom Event Image", new ProxyRef <string>(() => EventSettings[currentEvent.Name].BackgroundName, o => EventSettings[currentEvent.Name].BackgroundName = o), stringBuilder => stringBuilder.SetHintText("{=CESETTINGS1126}Default is " + (currentEvent.Backgrounds != null ? currentEvent.Backgrounds.ToString() : currentEvent.BackgroundName)).SetRequireRestart(false).SetOrder(2)); }); } } } if (_settings != null) { _settings.Unregister(); } _settings = builder.BuildAsGlobal(); _settings.Register(); } }