private static void RootMenuRev2createElementsPostfix(GuiElement ___subMenuExtra) { ___subMenuExtra.width += 124; ___subMenuExtra.elementList[0].offsetX += 4; ___subMenuExtra.AddButton("Mod Manager", SCREEN_MANAGER.white, 0, 0, 120, 40, new BasicButton.ClickEvent(WTFRootMenu.actionMods), SCREEN_MANAGER.FF16, new Color(196, 250, 255, 210)); ___subMenuExtra.elementList.Move(___subMenuExtra.elementList.Count - 1, 0); }
// we use a postfix patch on RootMenuRev2.createElements to find and resize all parts of the "open game" dialogue to fit the new delete button, after that we clear out the original button container and replace them with our own buttons. private static void Postfix(RootMenuRev2 __instance, ref GuiElement ___popupLoad, ref ScrollCanvas ___scrollLoadCanvas, ref List <GuiElement> ___popupCanvas) { int num3 = 300; Color fontColor = new Color(226, 252, 255, 210); ___popupLoad.width = 450; bool openMP2 = CONFIG.openMP; // a check if we have the multiplayer version of the game is probably redundant at this point, but it will do no harm. if (!openMP2) { foreach (var entry in ___popupLoad.elementList) { if (entry.name == "load scroll") { entry.width = 450; foreach (var entry2 in ___scrollLoadCanvas.elementList) { entry2.width = 436; } } else { entry.elementList.Clear(); entry.width = 450; entry.AddButton("Load", SCREEN_MANAGER.white, 2, 2, num3 / 2 - 2 - 1, 36, new BasicButton.ClickEvent(DeleteWorldSaves.MyRootMenuRev2.loadGame), SCREEN_MANAGER.FF16, fontColor); // calling "DeleteWorldSaves.MyRootMenuRev2.loadGame" instead of RootMenuRev2.loadGame, private delegated methods have to be replaced by our own, not sure if it is posible to call and modify them with reflections, at this point this is the only solution a could think of. entry.AddButton("Close", SCREEN_MANAGER.white, 2, 2, num3 / 2 - 2 - 1, 36, new BasicButton.ClickEvent(__instance.actionCloseLoad), SCREEN_MANAGER.FF16, fontColor); // we can use the original RootMenuRev2.actionCloseLoad method bacause it is public and can be accessed by harmony via instance of "RootMenuRev2" entry.AddButton("Delete", SCREEN_MANAGER.white, 2, 2, num3 / 2 - 2 - 1, 36, new BasicButton.ClickEvent(DeleteWorldSaves.MyRootMenuRev2.deleteSave), SCREEN_MANAGER.FF16, CONFIG.textColorRed); // this is our new delete button with red text } } // adding a confirmation dialogue ___popupCanvas.Add(new Canvas("confirm delete worldsave", SCREEN_MANAGER.white, 600, 600, 0, 0, 300, 80, SortType.vertical, new Color(14, 18, 19, 245))); DeleteWorldSaves.MyRootMenuRev2.popupConfirmDelete = ___popupCanvas.Last <GuiElement>(); DeleteWorldSaves.MyRootMenuRev2.popupConfirmDelete.addLabel("Confirm delete", SCREEN_MANAGER.FF20, 70, 0, 150, 40, CONFIG.textBrightColor); DeleteWorldSaves.MyRootMenuRev2.popupConfirmDelete.AddCanvas("confirm delete worldsave buttons", SCREEN_MANAGER.white, 0, 0, 300, 40, SortType.horizontal); GuiElement guiElement6 = DeleteWorldSaves.MyRootMenuRev2.popupConfirmDelete.elementList.Last <GuiElement>(); guiElement6.AddButton("Confirm", SCREEN_MANAGER.white, 0, 0, 150, 40, new BasicButton.ClickEvent(DeleteWorldSaves.MyRootMenuRev2.actionConfirmDelete), SCREEN_MANAGER.FF16, CONFIG.textColorRed); guiElement6.AddButton("Cancel", SCREEN_MANAGER.white, 0, 0, 150, 40, new BasicButton.ClickEvent(DeleteWorldSaves.MyRootMenuRev2.actionCancelDelete), SCREEN_MANAGER.FF16, CONFIG.textBrightColor); DeleteWorldSaves.MyRootMenuRev2.popupConfirmDelete.isVisible = false; } }