public static void Postfix(ref bool __result, FloatMenuOption __instance) { if (!Ad2Mod.settings.useRightClickMenu || !PatchFloatMenu.IsTracked(__instance)) { return; } if (!__result || Event.current.button != 1) { return; } __result = false; var recipe = Ad2.GetRecipeByLabel(__instance.Label); if (recipe == null || !Ad2.IsSrcRecipe(recipe)) { return; } var nlst = Ad2.GetNewRecipesList(recipe); if (nlst == null) { return; } Find.WindowStack.Add(new FloatMenu(RecipeOptionsMaker(nlst))); }
public static List <RecipeDef> Postfix(List <RecipeDef> __result, ref List <RecipeDef> ___allRecipesCached, bool __state) { if (!__state) { return(__result); } var res = new List <RecipeDef>(); foreach (var r in __result) { if (Ad2.IsNewRecipe(r)) { continue; } res.Add(r); var newRList = Ad2.GetNewRecipesList(r); if (newRList == null) { continue; } foreach (var nr in newRList) { res.Add(nr); } } ___allRecipesCached = res; //Log.Message("___allRecipesCached = res"); return(res); }
public static bool Postfix(bool __result, RecipeDef __instance) { if (Ad2Mod.settings.useRightClickMenu) { return(__result); } if (__result == false) { return(false); } var srcRecipe = Ad2.GetSrcRecipe(__instance); if (srcRecipe == null) { return(true); } if (Ad2Mod.settings.limitToX5 && __instance != Ad2.GetNewRecipesList(srcRecipe)[0]) { return(false); } if (__instance.workAmount > 1.5 * Ad2Mod.settings.defaultThreshold * 60) { //Log.Message(__instance.label + " hidden with src workAmount " + __instance.WorkAmountTotal(null)/60); return(false); } return(true); }
public static void Prefix(ref Func <List <FloatMenuOption> > recipeOptionsMaker, BillStack __instance) { inDoListing = true; lastBillStack = __instance; if (!Ad2Mod.settings.useRightClickMenu) { return; } var list = recipeOptionsMaker(); recipeOptionsMaker = delegate { var newList = new List <FloatMenuOption>(); foreach (var opt in list) { var recipe = Ad2.GetRecipeByLabel(opt.Label); if (recipe == null || !Ad2.IsNewRecipe(recipe)) { newList.Add(opt); } } return(newList); }; }
public override void DoSettingsWindowContents(Rect inRect) { var x = inRect.x; var y = inRect.y; var LH = Text.LineHeight; y += LH; Text.Font = GameFont.Medium; Widgets.Label(new Rect(x, y, 200, Text.LineHeight), "Global settings"); y += Text.LineHeight + 2; Text.Font = GameFont.Small; if (defaultThresholdField.DoField(y, "Default target time", ref settings.defaultThreshold)) { Messages.Message("Default target time changed to " + settings.defaultThreshold, MessageTypeDefOf.NeutralEvent); } TooltipHandler.TipRegion(new Rect(x, y, 360, LH), "Has no effect if 'Put recipes in context menu' is checked"); y += LH; var r1 = new Rect(x, y, 360, LH); Widgets.CheckboxLabeled(r1, "Limit to x5 recipes", ref settings.limitToX5); TooltipHandler.TipRegion(r1, "Add only x5 recipes"); y += LH; var r2 = new Rect(x, y, 360, LH); Widgets.CheckboxLabeled(r2, "Put recipes in context menu", ref settings.useRightClickMenu); TooltipHandler.TipRegion(r2, "Put recipes to context menu of source recipe instead of adding after it in the same list."); y += (2 * LH) + 2; if (Current.Game == null) { //lastGame = null; return; } Text.Font = GameFont.Medium; Widgets.Label(new Rect(x, y, 200, Text.LineHeight), "World settings"); y += Text.LineHeight + 2; Text.Font = GameFont.Small; var bills = Ad2.FindRecipesUses(); var s = $"Remove modded recipes from save ({bills.Count} found)"; var w = Text.CalcSize(s).x + 64; if (!Widgets.ButtonText(new Rect(x, y, w, 32), s)) { return; } foreach (var bill in bills) { bill.billStack.Delete(bill); } Messages.Message(bills.Count + " bills removed", MessageTypeDefOf.NeutralEvent); }