public UIModEntry(ModSetting modSetting) : base(modSetting.mod.DisplayName, 1f, false) { this.modSetting = modSetting; Width.Set(0, 1f); _defaultBackground = BackgroundColor; _defaultBorder = BorderColor; OnMouseOver += boxOnMouseOver; OnClick += boxOnClick; OnMouseUp += boxOnMouseUpOut; OnMouseOut += boxOnMouseUpOut; }
public void CreateSettings(string skillSettingName, Skill prefab, Vector3 effects, Vector3 vitalCosts, Vector3 otherCosts) { _toggle = _mod.CreateSetting(skillSettingName + nameof(_toggle), false); _effects = _mod.CreateSetting(skillSettingName + nameof(_effects), effects); _vitalCosts = _mod.CreateSetting(skillSettingName + nameof(_vitalCosts), vitalCosts); _otherCosts = _mod.CreateSetting(skillSettingName + nameof(_otherCosts), otherCosts); _effects.AddEvent(() => TryApplyEffectsToPrefab(prefab)); _vitalCosts.AddEvent(() => TryApplyVitalCostsToPrefab(prefab)); _otherCosts.AddEvent(() => TryApplyOtherCostsToPrefab(prefab)); }
public ModInfo(string xmlPath) { var xElement = XElement.Load(xmlPath); Name = (string)xElement.Element("name"); IniName = (string)xElement.Element("ininame"); Namespace = (string)xElement.Element("namespace"); Classname = (string)xElement.Element("classname"); Invoke = (string)xElement.Element("invoke"); if (Namespace != null && Classname != null && Invoke != null) { TypeName = string.Format("{0}.{1}", Namespace, Classname); MethodPath = string.Format("{0}.{1}.{2}", Namespace, Classname, Invoke); } settings = new List <ModSetting>(); foreach (var item in xElement.Element("settings").Elements()) { var setting = new ModSetting(); setting.Type = (string)item.Element("type"); setting.Text = (string)item.Element("text"); setting.Setting = (string)item.Element("setting"); setting.Int = (bool?)item.Element("int"); setting.Min = (float?)item.Element("min"); setting.Max = (float?)item.Element("max"); settings.Add(setting); } presets = new List <PresetInfo>(); var presetElement = xElement.Element("presets"); if (presetElement != null) { foreach (var item in presetElement.Elements()) { var preset = new PresetInfo(); preset.Name = (string)item.Element("name"); preset.PresetSettings = new List <PresetInfo.PresetSetting>(); foreach (var item2 in item.Element("values").Elements()) { var presetSetting = new PresetInfo.PresetSetting(); presetSetting.Setting = (string)item2.Element("setting"); presetSetting.Value = (string)item2.Element("value"); preset.PresetSettings.Add(presetSetting); } presets.Add(preset); } } }
void ModSettingPanel_Inputed(IFocusable sender, InputEventArgs args) { if (args.InputInfo.IsPressed(ButtonType.Cross)) { FocusManager.RemoveFocus(); sound.Play(PPDSetting.DefaultSounds[2], -1000); } else if (args.InputInfo.IsPressed(ButtonType.Circle)) { var window = new PPDModSettingUI.ModSettingWindow(); var helper = new WindowInteropHelper(window) { Owner = gameHost.WindowHandle }; ModSetting setting = modInfo.Settings[currentIndex]; var model = new PPDModSettingUI.ModSettingModel(setting, setting.GetStringValue(modInfo.ModSettingManager[setting.Key]), Utility.Language); window.DataContext = model; var result = window.ShowDialog(); if (result == true) { if (setting.Validate(model.NewValue, out object val)) { modInfo.ModSettingManager[setting.Key] = val; modInfo.SaveSetting(); CurrentComponent.CurrentValue = setting.GetStringValue(val); } } } else if (args.InputInfo.IsPressed(ButtonType.Down)) { CurrentComponent.IsSelected = false; currentIndex++; if (currentIndex >= settingListSprite.ChildrenCount) { currentIndex = settingListSprite.ChildrenCount - 1; } CurrentComponent.IsSelected = true; sound.Play(PPDSetting.DefaultSounds[0], -1000); } else if (args.InputInfo.IsPressed(ButtonType.Up)) { CurrentComponent.IsSelected = false; currentIndex--; if (currentIndex < 0) { currentIndex = 0; } CurrentComponent.IsSelected = true; sound.Play(PPDSetting.DefaultSounds[0], -1000); } }
public ModSettingModel(ModSetting modSetting, string currentValue, LanguageReader language) { this.language = language; this.modSetting = modSetting; Name = modSetting.Name; Description = modSetting.Description; NewValue = currentValue; AvailableValues = modSetting.AvailableValues; if (AvailableValues != null) { UpdateSelectedIndexByNewValue(); } if (modSetting is Int32ModSetting) { var int32ModSetting = (Int32ModSetting)modSetting; var otherValues = GetOtherValues(int32ModSetting); if (!String.IsNullOrEmpty(otherValues)) { OtherValues = otherValues; } } else if (modSetting is FloatModSetting) { var floatModSetting = (FloatModSetting)modSetting; var otherValues = GetOtherValues(floatModSetting); if (!String.IsNullOrEmpty(otherValues)) { OtherValues = otherValues; } } else if (modSetting is DoubleModSetting) { var doubleModSetting = (DoubleModSetting)modSetting; var otherValues = GetOtherValues(doubleModSetting); if (!String.IsNullOrEmpty(otherValues)) { OtherValues = otherValues; } } else if (modSetting is StringModSetting) { var stringModSetting = (StringModSetting)modSetting; if (!stringModSetting.IsMaxLengthClassMaxLength) { OtherValues = String.Format("{0}:{1}}", language["MaxLength"], stringModSetting.MaxLength); } } DefaultValue = modSetting.GetStringValue(modSetting.Default); }
public void FormatSettings(ModSetting <bool> toggle = null) { if (toggle != null) { _toggle.Format(_skillName, toggle); } else { _toggle.Format(_skillName); } _mod.Indent++; { // Effects description string text = ""; if (_effectX.IsNotEmpty()) { text += $"X - {_effectX}\n"; } if (_effectY.IsNotEmpty()) { text += $"Y - {_effectY}\n"; } if (_effectZ.IsNotEmpty()) { text += $"Z - {_effectZ}\n"; } text = text.TrimEnd('\n'); // Format if (text.IsNotEmpty()) { _effects.Format("Effects", _toggle); _effects.Description = text; } _vitalCosts.Format("Costs (vitals)", _toggle); _vitalCosts.Description = "X - Health\n" + "Y - Stamina\n" + "Z - Mana"; _otherCosts.Format("Costs (other)", _toggle); _otherCosts.Description = "X - Durability\n" + "Y - Durability %\n" + "Z - Cooldown"; _mod.Indent--; } }
public ModSettingComponent(PPDDevice device, PPDFramework.Resource.ResourceManager resourceManager, ModSetting modSetting, string currentValue) : base(device) { this.AddChild(nameText = new TextureString(device, modSetting.Name, 24, 500, PPDColors.White) { AllowScroll = false }); this.AddChild(infoText = new TextureString(device, GetInfoText(modSetting), 12, PPDColors.White)); infoText.Update(); infoText.Position = new Vector2(690 - infoText.Width, 30); this.AddChild(descriptionText = new TextureString(device, modSetting.Description, 18, 660, int.MaxValue, true, PPDColors.White) { Position = new Vector2(15, 40) }); this.AddChild(valueText = new TextureString(device, currentValue, 24, 400, PPDColors.White)); valueText.Update(); valueText.Position = new Vector2(690 - valueText.Width, 0); }
private String GetInfoText(ModSetting modSetting) { return(String.Format("{0}:{1}", Utility.Language["DefaultValue"], modSetting.GetStringValue(modSetting.Default))); }