internal void RegisterSettings(ModSettingsPack pack) { ShowNewsSetting = pack.GetHandle("modUpdateNews", "HugsLib_setting_showNews_label".Translate(), "HugsLib_setting_showNews_desc".Translate(), true); var allNewsHandle = pack.GetHandle("showAllNews", "HugsLib_setting_allNews_label".Translate(), "HugsLib_setting_allNews_desc".Translate(), false); allNewsHandle.Unsaved = true; allNewsHandle.CustomDrawer = rect => { if (Widgets.ButtonText(rect, "HugsLib_setting_allNews_button".Translate())) { if (!TryShowDialog(true)) { Find.WindowStack.Add(new Dialog_MessageBox("HugsLib_setting_allNews_fail".Translate())); } } return(false); }; IgnoredNewsProvidersSetting = pack.GetHandle <IgnoredNewsIds>("ignoredUpdateNews", null, null); if (IgnoredNewsProvidersSetting.Value == null) { IgnoredNewsProvidersSetting.Value = new IgnoredNewsIds(); IgnoredNewsProvidersSetting.HasUnsavedChanges = false; } IgnoredNewsProvidersSetting.NeverVisible = true; IgnoredNewsProvidersSetting.Value.Handle = IgnoredNewsProvidersSetting; }
/// <summary> /// Initializes the weather data from the given <see cref="ModSettingsPack" /> settings /// and <see cref="WeatherDef" />, creating our settings in the process. /// </summary> /// <param name="settings">The setting pack to use</param> /// <param name="biome">The biome to use</param> /// <param name="weather">The weather to base this off of</param> /// <param name="visibilityFunc">Function which returns if we should display this now</param> public WeatherData(ModSettingsPack settings, BiomeDef biome, WeatherDef weather, SettingHandle.ShouldDisplay visibilityFunc) { this.weather = weather; var curCommonality = biome.baseWeatherCommonalities.FirstOrDefault(wc => wc.weather == weather)?.commonality ?? 0f; // Init our settings... SpacerDrawer.GenerateSpacer(GenText.ToTitleCaseSmart(weather.label), settings, visibilityFunc); commonality = settings.GetHandle($"weather_{biome.defName}_{weather.defName}", " " + "ColdDesertNights_BiomeWeather".Translate(), "ColdDesertNights_BiomeWeather_Desc".Translate(curCommonality), curCommonality, Validators.FloatRangeValidator(0f, float.MaxValue)); allowRepeating = settings.GetHandle($"weather_{biome.defName}_{weather.defName}_repeating", " " + "ColdDesertNights_BiomeWeatherRepeating".Translate(), "ColdDesertNights_BiomeWeatherRepeating_Desc".Translate( (weather.repeatable ? "ColdDesertNights_Checked" : "ColdDesertNights_Unchecked").Translate()), weather.repeatable); allowEarly = settings.GetHandle($"weather_{biome.defName}_{weather.defName}_early", " " + "ColdDesertNights_BiomeWeatherEarly".Translate(), "ColdDesertNights_BiomeWeatherEarly_Desc".Translate( (Favorability.Neutral <= weather.favorability ? "ColdDesertNights_Checked" : "ColdDesertNights_Unchecked").Translate()), Favorability.Neutral <= weather.favorability); // And set our visibility predicates... commonality.VisibilityPredicate = allowRepeating.VisibilityPredicate = allowEarly.VisibilityPredicate = visibilityFunc; }
/// <summary> /// Initialize weather specific settings /// </summary> /// <param name="settings">The settings instance to use</param> /// <param name="biome">The biome we're working with</param> /// <param name="key">The key to use</param> /// <param name="weathers">The weathers to iterate through</param> /// <param name="visibilityFunc">Our base visibility function</param> private void InitWeatherSettings(ModSettingsPack settings, BiomeDef biome, string key, List <WeatherDef> weathers, SettingHandle.ShouldDisplay visibilityFunc) { // Per-biome rain and snowfall multipliers foreach (var weather in weathers) { weatherCommonalities[weather] = new WeatherData(settings, biome, weather, visibilityFunc); } SpacerDrawer.GenerateSpacer("ColdDesertNights_WeatherMiscSettings".Translate(), settings, visibilityFunc); // If we're allowed to bypass the rain limits settingIgnoreRainLimit = settings.GetHandle( $"ignore_rain_limit_{key}", " " + "ColdDesertNights_IgnoreRainLimit".Translate(), "ColdDesertNights_IgnoreRainLimit_Desc".Translate(), false); // Force weather into the given range minWeatherTemperature = settings.GetHandle( $"weather_temp_min_{key}", " " + "ColdDesertNights_WeatherTempMin".Translate(), "ColdDesertNights_WeatherTempMin_Desc".Translate(), -999f); maxWeatherTemperature = settings.GetHandle( $"weather_temp_max_{key}", " " + "ColdDesertNights_WeatherTempMax".Translate(), "ColdDesertNights_WeatherTempMax_Desc".Translate(), 999f); // Set our visibility predicates: settingIgnoreRainLimit.VisibilityPredicate = minWeatherTemperature.VisibilityPredicate = maxWeatherTemperature.VisibilityPredicate = visibilityFunc; }
public Settings(ModSettingsPack settings) { droppodCargoDropPercentage = settings.GetHandle("droppodCargoDropPercentage", "DroppodCargoDropPercentage".Translate(), "DroppodCargoDropPercentageDesc".Translate(), 30, AtLeast()); useGameSpeed = settings.GetHandle <bool>("useGameSpeed", "RA2UseGameSpeed".Translate(), "RA2UseGameSpeedDesc".Translate()); }
//public static SettingHandle<bool> removeDuplicateFactions; public static void Initialize(ModSettingsPack settings) { newFactionSettlementFactor = settings.GetHandle("newFactionSettlementFactor", "SettingSettlementFactor".Translate(), "SettingSettlementFactorDesc".Translate(), 0.7f, AtLeast(() => 0)); minSettlements = settings.GetHandle("minSettlements", "SettingSettlementsMin".Translate(), "SettingSettlementsMinDesc".Translate(), 3, AtLeast(() => 0)); minOfAnyFaction = settings.GetHandle("minOfAnyFaction", "SettingMinOfAnyFaction".Translate(), "SettingMinOfAnyFactionDesc".Translate(), 1, Validators.IntRangeValidator(0, 5)); maxOfAnyFaction = settings.GetHandle("maxOfAnyFaction", "SettingMaxOfAnyFaction".Translate(), "SettingMaxOfAnyFactionDesc".Translate(), 1, Validators.IntRangeValidator(1, 10)); //removeDuplicateFactions = settings.GetHandle("removeDuplicateFactions", "SettingRemoveDuplicates".Translate(), "SettingRemoveDuplicatesDesc".Translate(), false); //removeDuplicateFactions.OnValueChanged += OnChangedRemoveDuplicates; }
private void OnDefLoaded() { Log.Message("[PrepareLanding] GameOptions.OnDefLoaded()."); DisableWorldData = _settingsPack.GetHandle("DisableWorldData", "PLGOPT_DisableWorldDataTitle".Translate(), "PLGOPT_DisableWorldDataDescription".Translate(), false); DisablePreciseWorldGenPercentage = _settingsPack.GetHandle("DisablePreciseWorldGenPercentage", "Disable Precise World Gen. %", "Disable Precise World Generation Percentage on the Create World parameter page.", false); }
internal void PrepareSettingHandles(ModSettingsPack pack, List <string> races) { evaluatedRaces = races; DebugMode = pack.GetHandle("DebugMode", Translator.Translate("PawnkindRaceDiversity_DebugMode_label"), Translator.Translate("PawnkindRaceDiversity_DebugMode_description"), false); OverrideAllHumanPawnkinds = pack.GetHandle("OverrideAllHumanPawnkinds", Translator.Translate("PawnkindRaceDiversity_OverrideAllHumanPawnkinds_label"), Translator.Translate("PawnkindRaceDiversity_OverrideAllHumanPawnkinds_description"), true); OverrideAllAlienPawnkinds = pack.GetHandle("OverrideAllAlienPawnkinds", Translator.Translate("PawnkindRaceDiversity_OverrideAllAlienPawnkinds_label"), Translator.Translate("PawnkindRaceDiversity_OverrideAllAlienPawnkinds_description"), false); OverridePawnsWithInconsistentAges = pack.GetHandle("OverridePawnsWithInconsistentAges", Translator.Translate("PawnkindRaceDiversity_OverridePawnsWithInconsistentAges_label"), Translator.Translate("PawnkindRaceDiversity_OverridePawnsWithInconsistentAges_description"), false); //Excluded factions ConstructOtherAdjustmentHandles(pack, "RaceOverrideExcludedFaction", (from def in factionsWithHumanlikesLoaded select def.defName).ToList(), ref excludedFactions, false, false); //Global weights ConstructRaceAdjustmentHandles(pack, HandleContext.GENERAL); //Per-world weights ConstructRaceAdjustmentHandles(pack, HandleContext.WORLD); //Starting pawn weights ConstructRaceAdjustmentHandles(pack, HandleContext.STARTING); //Local weights ConstructRaceAdjustmentHandles(pack, HandleContext.LOCAL); //Settings category buttons construction //Excluded factions this.SettingsButtonCategoryConstructor(pack, "PawnkindRaceDiversity_FactionExclusionWindowTitle", showSettingsValid, "PawnkindRaceDiversity_FactionExclusionWindowDescription", delegate { Find.WindowStack.Add(new FactionExclusionWindow()); }); //----Weights related---- //Flat weights this.SettingsButtonCategoryConstructor(pack, "PawnkindRaceDiversity_WeightWindowTitle_FlatWeights", showSettingsValid, "PawnkindRaceDiversity_FlatWeights_Category_description", delegate { Find.WindowStack.Add(new WeightSettingsWindow(HandleContext.GENERAL)); }); //Local weights this.SettingsButtonCategoryConstructor(pack, "PawnkindRaceDiversity_WeightWindowTitle_FlatWeightsLocal", showSettingsValid, "PawnkindRaceDiversity_FlatWeightsLocal_Category_description", delegate { Find.WindowStack.Add(new WeightSettingsWindow(HandleContext.LOCAL)); }, delegate { //Invalid if not in a world return(!isInWorld()); }); }
static void Postfix(VerbProperties __instance, ref Thing equipment, ref float __result) { if (equipment == null || equipment.holdingOwner == null || !(equipment.holdingOwner.Owner is Pawn_EquipmentTracker)) { return; } if (equipment == null || equipment.holdingOwner == null || equipment.holdingOwner.Owner == null) { return; } Pawn_EquipmentTracker eqt = (Pawn_EquipmentTracker)equipment.holdingOwner.Owner; Pawn pawn = Traverse.Create(eqt).Field("pawn").GetValue <Pawn>(); if (pawn == null || pawn.stances == null) { return; } if (pawn.stances.curStance is Stance_RunAndGun || pawn.stances.curStance is Stance_RunAndGun_Cooldown) { ModSettingsPack settings = HugsLibController.SettingsManager.GetModSettings("RunAndGun"); int value = settings.GetHandle <int>("accuracyPenalty").Value; float factor = ((float)(100 - value) / 100); __result *= factor; } }
private void OnDefLoaded() { Log.Message("[PrepareLanding] GameOptions.OnDefLoaded()."); DisableWorldData = _settingsPack.GetHandle("DisableWorldData", "PLGOPT_DisableWorldDataTitle".Translate(), "PLGOPT_DisableWorldDataDescription".Translate(), false); }
public void CreateWorkAmountSetting <T>(ref SettingHandle <int> settingHandle, string settingName, Tabs tabIndex, Action <T, float> customAction = null) where T : IWorkAmount { settingHandle = modSettingsPack.GetHandle( settingName, settingName.Translate(), $"{settingName}Desc".Translate(), 100, value => ValueValidator(value, 1, 100)); settingHandle.OnValueChanged = newVal => { ApplySetting(newVal, customAction); }; settingHandle.VisibilityPredicate = () => tabsHandler.Value == tabNames[(int)tabIndex]; }
//Constructs a button in the mod settings that handles custom actions. // Specifically, these are made in order to create special windows. private void SettingsButtonCategoryConstructor(ModSettingsPack pack, string labelID, string buttonLabel, string desc, Action buttonAction, Func <bool> invalidCondition = null) { SettingHandle <bool> handle = pack.GetHandle(labelID, Translator.Translate(labelID), Translator.Translate(desc), false, null, null); handle.Unsaved = true; handle.CustomDrawer = delegate(Rect rect) { bool invalid = false; if (invalidCondition != null) { invalid = invalidCondition(); } if (invalid) { GUI.color = new Color(1f, 0.3f, 0.35f); } bool validButtonRes = Widgets.ButtonText(rect, Translator.Translate(buttonLabel), true, true, true); if (validButtonRes) { if (!invalid) { buttonAction(); } else { SoundDefOf.ClickReject.PlayOneShotOnCamera(null); } } GUI.color = Color.white; return(false); }; }
protected ListSetting(ModSettingsPack settings, string name, string title, string description, string defaultKey, IReadOnlyCollection <T> validValues) { _keyedValues = validValues.ToDictionary(Key, value => value); _sortedValues = validValues.OrderBy(Label).ToList(); _handler = settings.GetHandle(name, title, description, defaultKey, _keyedValues.ContainsKey); _handler.CustomDrawer = DrawDropDown; }
//public static SettingHandle<float> option_debug_scale_X; //public static SettingHandle<float> option_debug_scale_Y; //public static SettingHandle<float> option_debug_offset_X; //public static SettingHandle<float> option_debug_offset_Y; //public static SettingHandle<float> option_debug_loc_X; //public static SettingHandle<float> option_debug_loc_Y; //public static SettingHandle<float> option_debug_loc_Z; //public static SettingHandle<float> option_hair_offset_Y; public BnC_Settings(ModSettingsPack settings) { option_hostile_children_raider = settings.GetHandle <bool>("hostile_children_raider", "HostileChildrenRaider".Translate(), "HostileChildrenRaider_desc".Translate(), true); option_child_max_weapon_mass = settings.GetHandle("child_max_weapon_mas", "ChildMaxWeaponMass".Translate(), "ChildMaxWeaponMass_desc".Translate(), 2, Validators.IntRangeValidator(0, 4)); option_child_max_weapon_mass.SpinnerIncrement = 1; option_accelerated_growth = settings.GetHandle <bool>("accelerated_growth", "AcceleratedGrowth".Translate(), "AcceleratedGrowth_desc".Translate(), true); option_accelerated_growth_end_age = settings.GetHandle("accelerated_growth_end_age", "AcceleratedGrowthEndAge".Translate(), "AcceleratedGrowthEndAge_desc".Translate(), 8, Validators.IntRangeValidator(0, 12)); option_accelerated_growth_end_age.SpinnerIncrement = 1; option_baby_accelerated_factor = settings.GetHandle("baby_accelerated_factor", "BabyAcceleratedFactor".Translate(), "BabyAcceleratedFactor_desc".Translate(), 4, Validators.IntRangeValidator(1, 12)); option_baby_accelerated_factor.SpinnerIncrement = 1; option_toddler_accelerated_factor = settings.GetHandle("toddler_accelerated_factor", "ToddlerAcceleratedFactor".Translate(), "ToddlerAcceleratedFactor_desc".Translate(), 4, Validators.IntRangeValidator(1, 12)); option_toddler_accelerated_factor.SpinnerIncrement = 1; option_child_accelerated_factor = settings.GetHandle("child_accelerated_factor", "ChildAcceleratedFactor".Translate(), "ChildAcceleratedFactor_desc".Translate(), 4, Validators.IntRangeValidator(1, 12)); option_child_accelerated_factor.SpinnerIncrement = 1; //option_texture_scale_X = settings.GetHandle<float>("texture_scale_X", "TextureScaleX".Translate(), "TextureScaleX_desc".Translate(), 1.12f, Validators.FloatRangeValidator(-5f, 5f)); //option_texture_scale_Y = settings.GetHandle<float>("texture_scale_Y", "TextureScaleY".Translate(), "TextureScaleY_desc".Translate(), 1.32f, Validators.FloatRangeValidator(-5f, 5f)); //option_texture_offset_X = settings.GetHandle<float>("texture_offset_X", "TextureOffsetX".Translate(), "TextureOffsetX_desc".Translate(), -0.055f, Validators.FloatRangeValidator(-5f, 5f)); //option_texture_offset_Y = settings.GetHandle<float>("texture_offset_Y", "TextureOffsetY".Translate(), "TextureOffsetY_desc".Translate(), -0.2f, Validators.FloatRangeValidator(-5f, 5f)); //option_texture_offset_westeast_X = settings.GetHandle<float>("texture_offset_westeast_X", "TextureOffsetWesteast_X".Translate(), "TextureOffsetWesteast_X_desc".Translate(), -0.06f, Validators.FloatRangeValidator(-5f, 5f)); //option_debug_scale_X = settings.GetHandle<float>("debug_scale_X", "DebugScaleX".Translate(), "DebugScaleX_desc".Translate(), 1.225f, Validators.FloatRangeValidator(-5f, 5f)); //option_debug_scale_Y = settings.GetHandle<float>("debug_scale_Y", "DebugScaleY".Translate(), "DebugScaleY_desc".Translate(), 1.225f, Validators.FloatRangeValidator(-5f, 5f)); //option_debug_offset_X = settings.GetHandle<float>("debug_offset_X", "DebugOffsetX".Translate(), "DebugOffsetX_desc".Translate(), -0.105f, Validators.FloatRangeValidator(-5f, 5f)); //option_debug_offset_Y = settings.GetHandle<float>("debug_offset_Y", "DebugOffsetY".Translate(), "DebugOffsetY_desc".Translate(), -0.10f, Validators.FloatRangeValidator(-5f, 5f)); ////option_debug_loc_X = settings.GetHandle<float>("debug_loc_X", "DebugLocX".Translate(), "DebugLocX_desc".Translate(), 0f, Validators.FloatRangeValidator(-5f, 5f)); //option_debug_loc_Y = settings.GetHandle<float>("debug_loc_Y", "DebugLocY".Translate(), "DebugLocY_desc".Translate(), 0f, Validators.FloatRangeValidator(-5f, 5f)); //option_debug_loc_Z = settings.GetHandle<float>("debug_loc_Z", "DebugLocZ".Translate(), "DebugLocZ_desc".Translate(), 0f, Validators.FloatRangeValidator(-5f, 5f)); //option_hair_offset_Y = settings.GetHandle<float>("option_hair_offset_Y", "HairOffsetY".Translate(), "HairOffsetY_desc".Translate(), 0.114f, Validators.FloatRangeValidator(-5f, 5f)); }
private void OnDefLoaded() { Log.Message("[PrepareLanding] GameOptions.OnDefLoaded()."); DisableWorldData = _settingsPack.GetHandle("DisableWorldData", "PLGOPT_DisableWorldDataTitle".Translate(), "PLGOPT_DisableWorldDataDescription".Translate(), false); DisablePreciseWorldGenPercentage = _settingsPack.GetHandle("DisablePreciseWorldGenPercentage", "Disable Precise World Gen. %", "Disable Precise World Generation Percentage on the Create World parameter page.", true); PrepareLandingHotKey = _settingsPack.GetHandle("HotKey", "PrepareLanding Hotkey", "Hotkey for Prepare Landing Main Window", KeyCode.P, // this gets overriden by the settings. null, "Hotkey_"); }
internal static void RegisterSettings(ModSettingsPack pack) { optionsHandle = pack.GetHandle <LogPublisherOptions>("logPublisherSettings", null, null); if (optionsHandle.Value == null) { optionsHandle.Value = new LogPublisherOptions(); } optionsHandle.NeverVisible = true; }
/// <summary> /// Generates a randomly named settings spacer /// </summary> /// <param name="label">The label to use</param> /// <param name="settings">The settings handle to use</param> /// <param name="visibilityFunc">The visibility predicate</param> public static void GenerateSpacer(string label, ModSettingsPack settings, SettingHandle.ShouldDisplay visibilityFunc) { var spacer = settings.GetHandle <bool>("s" + spacers++, label, string.Empty); spacer.CustomDrawer = r => Draw(label, r); spacer.Unsaved = true; spacer.VisibilityPredicate = visibilityFunc; }
internal static void RegisterSettings(ModSettingsPack pack) { optionsHandle = pack.GetHandle <LogPublisherOptions>("logPublisherSettings", null, null); if (optionsHandle.Value == null) { optionsHandle.Value = new LogPublisherOptions(); } optionsHandle.VisibilityPredicate = () => false; // invisible, but can be reset by "Reset all settings" }
public override void Initialize(CompProperties props) { base.Initialize(props); Pawn pawn = (Pawn)(parent as Pawn); ModSettingsPack settings = HugsLibController.SettingsManager.GetModSettings("RunAndGun"); bool enableRGForAI = settings.GetHandle <bool>("enableRGForAI").Value; if (!pawn.IsColonist && enableRGForAI) { isEnabled = true; } }
public static void Load(ModSettingsPack settings) { for (int i = 0; i < NumPlans; i++) { _planColorSetting[i] = settings.GetHandle("planColor" + i, "planColor" + i, "planColor" + i, GetDefaultColor(i)); } for (int i = 0; i < NumPlans; i++) { ColorChanged(i); } }
//Construct other list-related handles private void ConstructOtherAdjustmentHandles(ModSettingsPack pack, string handleName, List <string> elements, ref Dictionary <string, SettingHandle <bool> > handleDict, bool defaultValue, bool unsaved) { foreach (string defName in elements) { //Handle configuration string id = handleName + "_" + defName; SettingHandle <bool> handle = pack.GetHandle <bool>(id, defName, null, defaultValue, null); handle.Unsaved = unsaved; handle.NeverVisible = true; //Never visible because it is handled by custom GUI instead handleDict.Add(defName, handle); } }
public Settings(ModSettingsPack settings) { disableGuests = settings.GetHandle("disableGuests", "DisableVisitors".Translate(), "DisableVisitorsDesc".Translate(), false); disableWork = settings.GetHandle("disableWork", "DisableGuestsHelping".Translate(), "DisableGuestsHelpingDesc".Translate(), false); disableArtAndCraft = settings.GetHandle("disableArtAndCraft", "DisableArtAndCraft".Translate(), "DisableArtAndCraftDesc".Translate(), true); disableGifts = settings.GetHandle("disableGifts", "DisableGifts".Translate(), "DisableGiftsDesc".Translate(), false); minGuestWorkSkill = settings.GetHandle("minGuestWorkSkill", "MinGuestWorkSkill".Translate(), "MinGuestWorkSkillDesc".Translate(), 7, WorkSkillLimits()); maxGuestGroupSize = settings.GetHandle("maxGuestGroupSize", "MaxGuestGroupSize".Translate(), "MaxGuestGroupSizeDesc".Translate(), 16, GroupSizeLimits()); disableLimits = settings.GetHandle("disableLimits", "DisableLimits".Translate(), "DisableLimitsDesc".Translate(), false); }
private void MakeSettingsCategoryToggle(ModSettingsPack pack, string labelId, Action buttonAction) { var toolToggle = pack.GetHandle <bool>(labelId, labelId.Translate(), null); toolToggle.Unsaved = true; toolToggle.CustomDrawer = rect => { if (Widgets.ButtonText(rect, "setting_showToggles_btn".Translate())) { buttonAction(); } return(false); }; }
/// <summary> /// Initalizes all of our 'general' tab settings. /// </summary> /// <param name="settings">The settings instance to use</param> /// <param name="biome">The biome we're working with</param> /// <param name="key">The key to use</param> /// <param name="visibilityFunc">Our base visibility function</param> private void InitGeneralSettings(ModSettingsPack settings, BiomeDef biome, string key, SettingHandle.ShouldDisplay visibilityFunc) { settingFunc = settings.GetHandle($"temp_func_{key}", "ColdDesertNights_Function".Translate(GenText.ToTitleCaseSmart(biome.label)), "ColdDesertNights_Function_Desc".Translate(), TemperatureFunctions.Vanilla, null, "ColdDesertNights_Function_Enum_"); settingMultiplier = settings.GetHandle( $"temp_multiplier_{key}", "ColdDesertNights_Multiplier".Translate(GenText.ToTitleCaseSmart(biome.label)), "ColdDesertNights_Multiplier_Desc".Translate(), 14.0f, Validators.FloatRangeValidator(-200, 200)); settingOffset = settings.GetHandle($"temp_offset_{key}", "ColdDesertNights_Offset".Translate(GenText.ToTitleCaseSmart(biome.label)), "ColdDesertNights_Offset_Desc".Translate(), 0.0f, Validators.FloatRangeValidator(-200, 200)); settingSeasonal = settings.GetHandle($"temp_seasonal_{key}", "ColdDesertNights_Seasonal".Translate(GenText.ToTitleCaseSmart(biome.label)), "ColdDesertNights_Seasonal_Desc".Translate(), 56.0f, Validators.FloatRangeValidator(-400, 400)); settingFunc.VisibilityPredicate = settingMultiplier.VisibilityPredicate = settingOffset.VisibilityPredicate = settingSeasonal.VisibilityPredicate = visibilityFunc; // And use them to init our values... UpdateFunction(settingFunc.Value); RecalculateMultiplierAndOffset(); RecalculateSeasonalCurve(settingSeasonal.Value); // Sync them up when they get changed settingFunc.OnValueChanged += UpdateFunction; settingMultiplier.OnValueChanged += _ => RecalculateMultiplierAndOffset(); settingOffset.OnValueChanged += _ => RecalculateMultiplierAndOffset(); settingSeasonal.OnValueChanged += RecalculateSeasonalCurve; }
static bool shouldRunAndGun() { var rndInt = new Random(DateTime.Now.Millisecond).Next(1, 100); ModSettingsPack settings = HugsLibController.SettingsManager.GetModSettings("RunAndGun"); int chance = settings.GetHandle <int>("enableRGForFleeChance").Value; if (rndInt <= chance) { return(true); } else { return(false); } }
/// <summary> /// Initialize condition specific settings /// </summary> /// <param name="settings">The settings instance to use</param> /// <param name="key">The key to use</param> /// <param name="conditions">The conditions to iterate through</param> /// <param name="visibilityFunc">Our base visibility function</param> private void InitConditionSettings(ModSettingsPack settings, string key, List <GameConditionDef> conditions, SettingHandle.ShouldDisplay visibilityFunc) { // Iterate through each of our conditions... foreach (var condition in conditions) { var setting = settings.GetHandle($"condition_{key}_{condition.defName}_offset", "ColdDesertNights_ConditionTemp".Translate(GenText.ToTitleCaseSmart(condition.label)), "ColdDesertNights_ConditionTemp_Desc".Translate(), DefaultConditionTemps.ContainsKey(condition) ? DefaultConditionTemps[condition] : 0f, Validators.FloatRangeValidator(-400, 400)); setting.VisibilityPredicate = visibilityFunc; conditionOffsets[condition] = setting; } }
internal static void RegisterSettings(ModSettingsPack pack) { optionsHandle = pack.GetHandle <LogPublisherOptions>("logPublisherSettings", "HugsLib_setting_logPublisherSettings_label".Translate(), null); optionsHandle.NeverVisible = true; optionsHandle.OnValueChanged = EnsureNonNullHandleValue; EnsureNonNullHandleValue(null); void EnsureNonNullHandleValue(LogPublisherOptions _) { if (optionsHandle.Value != null) { return; } optionsHandle.Value = new LogPublisherOptions(); optionsHandle.HasUnsavedChanges = false; } }
private static ThingFilter UserFuelSettings() { ModSettingsPack pack = HugsLibController.SettingsManager.GetModSettings("JPT_BurnItForFuel"); return(pack.GetHandle <FuelSettingsHandle>("FuelSettings").Value.masterFuelSettings); }
internal void PrepareSettingsHandles(ModSettingsPack pack) { GlobalHotkeysSetting = pack.GetHandle("globalHotkeys", "setting_globalHotkeys_label".Translate(), "setting_globalHotkeys_desc".Translate(), true); ContextOverlaySetting = pack.GetHandle("contextOverlay", "setting_contextOverlay_label".Translate(), "setting_contextOverlay_desc".Translate(), true); ContextWatermarkSetting = pack.GetHandle("contextWatermark", "setting_contextWatermark_label".Translate(), "setting_contextWatermark_desc".Translate(), true); ReplaceIconsSetting = pack.GetHandle("replaceIcons", "setting_replaceIcons_label".Translate(), "setting_replaceIcons_desc".Translate(), false); HaulWorktypeSetting = pack.GetHandle("haulUrgentlyWorktype", "setting_haulUrgentlyWorktype_label".Translate(), "setting_haulUrgentlyWorktype_desc".Translate(), true); FinishOffWorktypeSetting = pack.GetHandle("finishOffWorktype", "setting_finishOffWorktype_label".Translate(), "setting_finishOffWorktype_desc".Translate(), false); ExtendedContextActionSetting = pack.GetHandle("extendedContextActionKey", "setting_extendedContextHotkey_label".Translate(), "setting_extendedContextHotkey_desc".Translate(), true); ReverseDesignatorPickSetting = pack.GetHandle("reverseDesignatorPick", "setting_reverseDesignatorPick_label".Translate(), "setting_reverseDesignatorPick_desc".Translate(), true); FinishOffUnforbidsSetting = pack.GetHandle("finishOffUnforbids", "setting_finishOffUnforbids_label".Translate(), "setting_finishOffUnforbids_desc".Translate(), true); PartyHuntSetting = pack.GetHandle("partyHunt", "setting_partyHunt_label".Translate(), "setting_partyHunt_desc".Translate(), true); StorageSpaceAlertSetting = pack.GetHandle("storageSpaceAlert", "setting_storageSpaceAlert_label".Translate(), "setting_storageSpaceAlert_desc".Translate(), true); SelectionLimitSetting = pack.GetHandle("selectionLimit", "setting_selectionLimit_label".Translate(), "setting_selectionLimit_desc".Translate(), 200, Validators.IntRangeValidator(50, 100000)); SelectionLimitSetting.SpinnerIncrement = 50; // designators MakeSettingsCategoryToggle(pack, "setting_showToolToggles_label", () => expandToolSettings = !expandToolSettings); foreach (var designatorDef in DefDatabase <ThingDesignatorDef> .AllDefs) { var handleName = DesignatorHandleNamePrefix + designatorDef.defName; var handle = pack.GetHandle(handleName, "setting_showTool_label".Translate(designatorDef.label), null, true); handle.VisibilityPredicate = () => expandToolSettings; designatorToggleHandles[handleName] = handle; } // context menus MakeSettingsCategoryToggle(pack, "setting_showProviderToggles_label", () => expandProviderSettings = !expandProviderSettings); SettingHandle.ShouldDisplay menuEntryHandleVisibility = () => expandProviderSettings; foreach (var handle in DesignatorContextMenuController.RegisterMenuEntryHandles(pack)) { handle.VisibilityPredicate = menuEntryHandleVisibility; } // reverse designators MakeSettingsCategoryToggle(pack, "setting_showReverseToggles_label", () => expandReverseToolSettings = !expandReverseToolSettings); foreach (var reverseDef in DefDatabase <ReverseDesignatorDef> .AllDefs) { var handleName = ReverseDesignatorHandleNamePrefix + reverseDef.defName; var handle = pack.GetHandle(handleName, "setting_showTool_label".Translate(reverseDef.designatorDef.label), "setting_reverseDesignator_desc".Translate(), true); handle.VisibilityPredicate = () => expandReverseToolSettings; reverseDesignatorToggleHandles[handleName] = handle; } FinishOffSkillRequirement = pack.GetHandle("finishOffSkill", "setting_finishOffSkill_label".Translate(), "setting_finishOffSkill_desc".Translate(), true); FinishOffSkillRequirement.VisibilityPredicate = () => Prefs.DevMode; StripMineSettings = pack.GetHandle <StripMineGlobalSettings>("stripMineSettings", null, null); if (StripMineSettings.Value == null) { StripMineSettings.Value = new StripMineGlobalSettings(); } // invisible but resettable StripMineSettings.VisibilityPredicate = () => false; RegisterPackHandlesChangedCallback(pack); }
public void InitializeSettings() { modSettingsPack = HugsLibController.Instance.Settings.GetModSettings("WorkRebalancer"); // profiles // SettingHandle <bool> profiles = modSettingsPack.GetHandle( "ProfilesDrawer", "Profiles".Translate(), "Profiles".Translate(), false); profiles.CustomDrawerHeight = 40; profiles.CustomDrawer = rect => { //var lister = new Listing_Standard(); //lister.Begin(rect); //lister.verticalSpacing = 1f; IEnumerable <FloatMenuOption> loadMenu() { foreach (var profName in Profile.GetAllProfiles()) { yield return(new FloatMenuOption(profName, () => { _saveName = Path.GetFileNameWithoutExtension(profName); Prof.Load(profName); })); } } IEnumerable <FloatMenuOption> deleteMenu() { foreach (var profName in Profile.GetAllProfiles()) { yield return(new FloatMenuOption(profName, () => { Profile.Delete(profName); })); } } Rect buttonRect1 = new Rect(rect) { height = 20f, width = rect.width / 3 }, buttonRect2 = new Rect(buttonRect1) { x = buttonRect1.xMax }, buttonRect3 = new Rect(buttonRect2) { x = buttonRect2.xMax }; if (Widgets.ButtonText(buttonRect1, "LoadProfileBtn".Translate())) { Find.WindowStack.Add(new FloatMenu(new List <FloatMenuOption>(loadMenu()))); } if (Widgets.ButtonText(buttonRect2, "DeleteProfileBtn".Translate())) { Find.WindowStack.Add(new FloatMenu(new List <FloatMenuOption>(deleteMenu()))); } if (Widgets.ButtonText(buttonRect3, "ResetBtn".Translate())) { Prof.ResetToDefault(); ApplySettings(); } Rect textRect1 = new Rect(rect) { height = 20f, width = rect.width / 2, y = buttonRect1.yMax }, buttonRect4 = new Rect(textRect1) { x = textRect1.xMax }; _saveName = Widgets.TextField(textRect1, _saveName); if (Widgets.ButtonText(buttonRect4, "SaveProfileBtn".Translate())) { Prof.Save(_saveName); } //if (lister.ButtonText("LoadProfileBtn".Translate())) // Find.WindowStack.Add(new FloatMenu(new List<FloatMenuOption>(loadMenu()))); //if (lister.ButtonText("DeleteProfileBtn".Translate())) // Find.WindowStack.Add(new FloatMenu(new List<FloatMenuOption>(deleteMenu()))); //_saveName = lister.TextEntryLabeled("savename", _saveName); //if (lister.ButtonText("SaveProfileBtn".Translate())) // Prof.Save(_saveName); //lister.End(); return(true); }; CreateCustomSetting(ref Prof.CheckHostileDelay, "CheckHostileDelay", 60, Tabs.none); CreateCustomSetting(ref Prof.RestoreWhenHostileDetected, "RestoreWhenHostileDetected", true, Tabs.none); var marks = modSettingsPack.GetHandle("marks", "marksTitle".Translate(), "", ""); marks.CustomDrawer = rect => { Widgets.Label(rect, "marksDesc".Translate()); return(false); }; marks.CustomDrawerHeight = int.Parse("marksDescHeight".Translate()); tabsHandler = modSettingsPack.GetHandle("tabs", "tabsTitle".Translate(), "", "none"); tabsHandler.CustomDrawer = rect => CustomDrawer_Tabs(rect, tabsHandler, tabNames); tabsHandler.CustomDrawerHeight = (float)Math.Ceiling((double)tabNames.Length / 2) * 20; // generalTab // CreateWorkAmountSetting <ResearchWorkAmount>(ref Prof.PercentOfBaseResearches, "PercentOfBaseResearches", Tabs.generalTab); CreateWorkAmountSetting <TerrainWorkAmount>(ref Prof.PercentOfBaseTerrains, "PercentOfBaseTerrains", Tabs.generalTab); CreateWorkAmountSetting <RecipeWorkAmount>(ref Prof.PercentOfBaseRecipes, "PercentOfBaseRecipes", Tabs.generalTab); CreateWorkAmountSetting <ThingWorkAmount>(ref Prof.PercentOfBaseThingStats, "PercentOfBaseThingStats", Tabs.generalTab, (w, p) => w.SetStats(p)); CreateWorkAmountSetting <ThingWorkAmount>(ref Prof.PercentOfBaseThingFactors, "PercentOfBaseThingFactors", Tabs.generalTab, (w, p) => w.SetFactors(p)); CreateWorkAmountSetting <PlantWorkAmount>(ref Prof.PercentOfBasePlantsWork, "PercentOfBasePlantsWork", Tabs.generalTab); CreateCustomSetting(ref Prof.PercentOfBaseTendPatient, "PercentOfBaseTendPatient", 100, Tabs.generalTab); CreateCustomSetting(ref Prof.PercentOfBaseMineJob, "PercentOfBaseMineJob", 100, Tabs.generalTab); CreateCustomSetting(ref Prof.DeepScannerJob, "DeepScannerJob", 1f, Tabs.generalTab); if (FluffyBreakdownsPatched) { CreateCustomSetting(ref Prof.PercentOfBaseFluffyBreakdowns, "PercentOfBaseFluffyBreakdowns", 100, Tabs.generalTab); } CreateCustomSetting(ref Prof.RepairJobAddX, "RepairJobAddX", 1, Tabs.generalTab); if (HSKCollectJobsPatched) { CreateCustomSetting(ref Prof.PercentOfBaseHSKCollectJobs, "PercentOfBaseHSKCollectJobs", 100, Tabs.generalTab); } if (RAtomicsResearchPatched) { CreateCustomSetting(ref Prof.RAtomicsResearchMultiplier, "RAtomicsResearchMultiplier", 1f, Tabs.generalTab); } if (RFDrillJobPatched) { CreateCustomSetting(ref Prof.RFDrillJobMultiplier, "RFDrillJobMultiplier", 1f, Tabs.generalTab); } if (RFCrudeJobPatched) { CreateCustomSetting(ref Prof.RFCrudeJobMultiplier, "RFCrudeJobMultiplier", 1f, Tabs.generalTab); } if (RFRefineryJobPatched) { CreateCustomSetting(ref Prof.RFRefineryJobMultiplier, "RFRefineryJobMultiplier", 1f, Tabs.generalTab); } if (HSKMineQuarryPatched) { CreateCustomSetting(ref Prof.PercentOfBaseHSKMineQuarry, "PercentOfBaseHSKMineQuarry", 100, Tabs.generalTab); } if (HSKExtractorsPatched) { CreateCustomSetting(ref Prof.PercentOfBaseHSKExtractorsMine, "PercentOfBaseHSKExtractorsMine", 100, Tabs.generalTab); } if (AndroidsPatched) { CreateCustomSetting(ref Prof.AndroidsCraftAddX, "AndroidsCraftAddX", 1, Tabs.generalTab); } // otherTab // HugsLabelWtf("boostXpTitle", Tabs.otherTab); CreateCustomSetting(ref Prof.SkillLearnMultiplier, "SkillLearnMultiplier", 1f, Tabs.otherTab); CreateCustomSetting(ref Prof.SkillLearnAllowMax, "SkillLearnAllowMax", 0, Tabs.otherTab); // fast aging // HugsLabelWtf("humanoidTitle", Tabs.fastAging); CreateCustomSetting(ref Prof.PawnSpeedMultBeforeCutoff, "PawnSpeedMultBeforeCutoff", 1, Tabs.fastAging); CreateCustomSetting(ref Prof.PawnSpeedMultAfterCutoff, "PawnSpeedMultAfterCutoff", 1, Tabs.fastAging); CreateCustomSetting(ref Prof.PawnCutoffAge, "PawnCutoffAge", 16, Tabs.fastAging); HugsLabelWtf("animalsTitle", Tabs.fastAging); CreateCustomSetting(ref Prof.AnimalSpeedMultBeforeCutoff, "AnimalSpeedMultBeforeCutoff", 1, Tabs.fastAging); CreateCustomSetting(ref Prof.AnimalSpeedMultAfterCutoff, "AnimalSpeedMultAfterCutoff", 1, Tabs.fastAging); CreateCustomSetting(ref Prof.AnimalCutoffAge, "AnimalCutoffAge", 1, Tabs.fastAging); // pawnsTab // CreateWorkAmountSetting <PlantGrowDays>(ref Prof.PercentOfBasePlantsGrowDays, "PercentOfBasePlantsGrowDays", Tabs.pawnsTab); CreateCustomSetting(ref Prof.EggHatchSpeedMult, "EggHatchSpeedMult", 1f, Tabs.pawnsTab); CreateCustomSetting(ref Prof.EggLayerSpeedMult, "EggLayerSpeedMult", 1f, Tabs.pawnsTab); if (RjwPregnancyPatched) { CreateCustomSetting(ref Prof.RjwPregnancySpeedMult, "RjwPregnancySpeedMult", 1f, Tabs.pawnsTab); } if (RjwInsectEggPatched) { CreateCustomSetting(ref Prof.RjwInsectEggSpeedMult, "RjwInsectEggSpeedMult", 1, Tabs.pawnsTab); } // fastMoving // CreateCustomSetting(ref Prof.ShowInstantMovingIcon, "ShowInstantMovingIcon", false, Tabs.fastMoving); CreateCustomSetting(ref Prof.InstantMovingSmoother, "InstantMovingSmoother", true, Tabs.fastMoving); CreateCustomSetting(ref Prof.InstantMovingOnlyColonists, "InstantMovingOnlyColonists", true, Tabs.fastMoving); CreateCustomSetting(ref Prof.InstantMovingAutooffOnPause, "InstantMovingAutooffOnPause", false, Tabs.fastMoving); // fastTime // CreateCustomSetting(ref Prof.ShowFastTimeIcon, "ShowFastTimeIcon", false, Tabs.fastTime); CreateCustomSetting(ref Prof.FastTimeMultiplier, "FastTimeMultiplier", 0, Tabs.fastTime); // fastPawnsTicks // // CreateCustomSetting(ref Prof.ShowFastPawnsTicksIcon, "ShowFastPawnsTicksIcon", false, Tabs.fastPawnsTicks); // CreateCustomSetting(ref Prof.FastPawnsTicksMultiplier, "FastPawnsTicksMultiplier", 1, Tabs.fastPawnsTicks); // debug // DebugLog = modSettingsPack.GetHandle( "DebugLog", "DebugLog", "DebugLog", false); //SettingHandle<bool> handleRebalance = modSettingsPack.GetHandle("Rebalance", "RebalanceBtn".Translate(), "RebalanceBtnDesc".Translate(), false); //handleRebalance.CustomDrawer = rect => //{ // if (Widgets.ButtonText(rect, "RebalanceBtn".Translate())) ApplySettings(); // return false; //}; }
internal static void RegisterSettings(ModSettingsPack settings) { handle = settings.GetHandle <QuickstartSettings>("quickstartSettings", null, null); handle.VisibilityPredicate = () => false; // invisible, but can be reset by "Reset all settings" }