static CrossPromotion() { var instance = HarmonyInstance.Create(_crosspromotion); if (instance.HasAnyPatches(_crosspromotion)) { return; } instance.Patch( SymbolExtensions.GetMethodInfo(() => MainMenuDrawer.Init()), postfix: new HarmonyMethod(SymbolExtensions.GetMethodInfo(() => MainMenuDrawer_Init_Postfix())) ); instance.Patch( AccessTools.DeclaredMethod(typeof(Page_ModsConfig), nameof(Page_ModsConfig.PostClose)), postfix: new HarmonyMethod(SymbolExtensions.GetMethodInfo(() => Page_ModsConfig_PostClose_Postfix())) ); instance.Patch( AccessTools.DeclaredMethod(typeof(WorkshopItems), "Notify_Subscribed"), postfix: new HarmonyMethod(SymbolExtensions.GetMethodInfo(() => WorkshopItems_Notify_Subscribed_Postfix(new PublishedFileId_t(0)))) ); instance.Patch( AccessTools.DeclaredMethod(typeof(Page_ModsConfig), nameof(Page_ModsConfig.DoWindowContents)), transpiler: new HarmonyMethod(SymbolExtensions.GetMethodInfo(() => Page_ModsConfig_DoWindowContents_Transpiler(null, null))) ); }
public override void Init() { base.Init(); // UIMenuBackgroundManager.background = new UI_BackgroundMain(); //Ö÷²Ëµ¥ MainMenuDrawer.Init(); QuickStarter.CheckQuickStart(); //°æ±¾ÐÅÏ¢ VersionUpdateDialogMaker.CreateVersionUpdateDialogIfNecessary(); //Todo:×¢ÊÍSteam¼ì²â /* * if (!SteamManager.Initialized) * { * Dialog_MessageBox window = new Dialog_MessageBox((string)"SteamClientMissing".Translate(), "Quit".Translate(), delegate * { * Application.Quit(); * }, "Ignore".Translate()); * Find.WindowStack.Add(window); * } */ }
public MainMenuScreen(MyGameWindow gameWindow) : base(gameWindow) { mainMenuDrawer = new MainMenuDrawer(); AddKeyToSingleUserActionMapping(Key.Up, UserAction.GoUpInMenu); AddKeyToSingleUserActionMapping(Key.W, UserAction.GoUpInMenu); AddKeyToSingleUserActionMapping(Key.Down, UserAction.GoDownInMenu); AddKeyToSingleUserActionMapping(Key.S, UserAction.GoDownInMenu); AddKeyToSingleUserActionMapping(Key.Enter, UserAction.SelectCurrentMenuItem); AddKeyToSingleUserActionMapping(Key.Space, UserAction.SelectCurrentMenuItem); AddKeyToSingleUserActionMapping(Key.O, UserAction.DecreaseDifficulty); AddKeyToSingleUserActionMapping(Key.P, UserAction.IncreaseDifficulty); AddSingleUserActionToFunctionMapping(UserAction.GoUpInMenu, GoUpInMenu); AddSingleUserActionToFunctionMapping(UserAction.GoDownInMenu, GoDownInMenu); AddSingleUserActionToFunctionMapping(UserAction.SelectCurrentMenuItem, SelectCurrentMenuItem); AddSingleUserActionToFunctionMapping(UserAction.ImportSong, ImportSong); AddSingleUserActionToFunctionMapping(UserAction.DecreaseDifficulty, DecreaseDifficulty); AddSingleUserActionToFunctionMapping(UserAction.IncreaseDifficulty, IncreaseDifficulty); menuItemXPaddings = new int[numberOfMenuItems]; menuItemXPaddings[0] = 1; for (int i = 1; i < numberOfMenuItems; i++) { menuItemXPaddings[i] = 0; } }
private void DoMainMenu() { if (!WorldRendererUtility.WorldRenderedNow) { UIMenuBackgroundManager.background.BackgroundOnGUI(); if (this.ShouldDoMainMenu) { Current.Game = null; MainMenuDrawer.MainMenuOnGUI(); } } }
public override void Init() { base.Init(); UIMenuBackgroundManager.background = new UI_BackgroundMain(); MainMenuDrawer.Init(); QuickStarter.CheckQuickStart(); VersionUpdateDialogMaker.CreateVersionUpdateDialogIfNecessary(); if (!SteamManager.Initialized) { Dialog_MessageBox window = new Dialog_MessageBox((string)"SteamClientMissing".Translate(), "Quit".Translate(), delegate { Application.Quit(); }, "Ignore".Translate()); Find.WindowStack.Add(window); } }
/* * 0.0 0.5 1.0 * 0.0 +--------------------------------------------------+-----------+ |Version | | Ludeon | +--+-----+-----------------------------------------+-----------+ | | RimWorld Title Tex | | | Texture | | +-------------------------+-------------------------------+-+ | | Credit to Tynan | | | +-+--------------+----------------+ | | | | | | | | Main | Web Links | | | 0.5 | | Option | | | | | Buttons | | | | | | | | | | | | | | | | | | | | +----------+-----+ | | | | Language | | | | | Flag | | | +----------------+----------+ | | | | 1.0 +--------------------------------------------------------------+ */ internal static void _MainMenuOnGUI() { #region Version VersionControl.DrawInfoInCorner(); #endregion #region Compute Base Title Vector var titleBaseVec = MainMenuDrawerExt.TitleSize; if (titleBaseVec.x > (float)Screen.width) { titleBaseVec *= (float)Screen.width / titleBaseVec.x; } var titleFinalVec = titleBaseVec * 0.7f; #endregion #region Compute Main Buttons, Links and Language Rects var currentMainMenuDefs = MainMenuDrawerExt.CurrentMainMenuDefs(MainMenuDrawerExt.AnyWorldFiles, MainMenuDrawerExt.AnyMapFiles); var currentMainMenuButtonCount = currentMainMenuDefs.Count; var currentMainMenuButtonHeight = MainMenuDrawerExt.OptionButtonSpacingFor(currentMainMenuButtonCount); var PaneWidth = MainMenuDrawerExt.GameRectWidth * 2 + MainMenuDrawerExt.OptionListSpacing * 3; var minPaneHeight = MainMenuDrawerExt.LinkOptionsHeight + MainMenuDrawerExt.LanguageOptionSpacing + MainMenuDrawerExt.LanguageOptionHeight; var maxPaneHeight = Screen.height - titleFinalVec.y - MainMenuDrawerExt.TitlePaneSpacing - MainMenuDrawerExt.CreditHeight - MainMenuDrawerExt.CreditTitleSpacing - MainMenuDrawerExt.LudeonEdgeSpacing - MainMenuDrawerExt.LudeonLogoSize.y; var PaneHeight = Mathf.Max(Mathf.Min(currentMainMenuButtonHeight, maxPaneHeight), minPaneHeight) + MainMenuDrawerExt.OptionListSpacing * 2; MainMenuDrawerExt.PaneSize = new Vector2(PaneWidth, PaneHeight); var menuOptionsRect = new Rect( ((float)Screen.width - MainMenuDrawerExt.PaneSize.x) / 2f, ((float)Screen.height - MainMenuDrawerExt.PaneSize.y) / 2f, MainMenuDrawerExt.PaneSize.x, MainMenuDrawerExt.PaneSize.y); menuOptionsRect.y += MainMenuDrawerExt.TitleShift; menuOptionsRect.x = ((float)Screen.width - menuOptionsRect.width - MainMenuDrawerExt.OptionsEdgeSpacing); #endregion #region Compute and Draw RimWorld Title var titleRect = new Rect( ((float)Screen.width - titleFinalVec.x) / 2f, (menuOptionsRect.y - titleFinalVec.y - MainMenuDrawerExt.TitlePaneSpacing), titleFinalVec.x, titleFinalVec.y); titleRect.x = ((float)Screen.width - titleFinalVec.x - MainMenuDrawerExt.TitleShift); GUI.DrawTexture( titleRect, (Texture)MainMenuDrawerExt.TexTitle, ScaleMode.StretchToFill, true); #endregion #region Compute and Draw Credit to Tynan var mainCreditRect = titleRect; mainCreditRect.y += titleRect.height; mainCreditRect.xMax -= 55f; mainCreditRect.height = MainMenuDrawerExt.CreditHeight; mainCreditRect.y += MainMenuDrawerExt.CreditTitleSpacing; var mainCreditText = "MainPageCredit".Translate(); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.UpperRight; if (Screen.width < 990) { var mainCreditBackRect = mainCreditRect; mainCreditBackRect.xMin = mainCreditBackRect.xMax - Text.CalcSize(mainCreditText).x; mainCreditBackRect.xMin -= 4f; mainCreditBackRect.xMax += 4f; GUI.color = new Color(0.2f, 0.2f, 0.2f, 0.5f); GUI.DrawTexture( mainCreditBackRect, (Texture)BaseContent.WhiteTex); GUI.color = Color.white; } Widgets.Label(mainCreditRect, mainCreditText); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; #endregion #region Compute and Draw Ludeon Logo GUI.color = new Color(1f, 1f, 1f, 0.5f); GUI.DrawTexture( new Rect( (float)Screen.width - MainMenuDrawerExt.LudeonLogoSize.x - MainMenuDrawerExt.LudeonEdgeSpacing, MainMenuDrawerExt.LudeonEdgeSpacing, MainMenuDrawerExt.LudeonLogoSize.x, MainMenuDrawerExt.LudeonLogoSize.y), (Texture)MainMenuDrawerExt.TexLudeonLogo, ScaleMode.StretchToFill, true); GUI.color = Color.white; #endregion #region Draw Main Buttons, Links and Language Option menuOptionsRect.y += MainMenuDrawerExt.OptionListSpacing; GUI.BeginGroup(menuOptionsRect); MainMenuDrawer.DoMainMenuButtons( menuOptionsRect, MainMenuDrawerExt.AnyWorldFiles, MainMenuDrawerExt.AnyMapFiles); GUI.EndGroup(); #endregion }
public static bool PreFMainMenuOnGUI() { VersionControl.DrawInfoInCorner(); // Calculate main menu frame float floFramePadding = 25f; float floFrameWidth = (UI.screenWidth - (UI.screenWidth / 1.62f)) / 1.62f; float floFrameHeight = (UI.screenHeight / 1.62f); float floFrameX = UI.screenWidth - (floFrameWidth + floFramePadding); float floFrameY = (UI.screenHeight - floFrameHeight) / 2f; float floAspect = (float)UI.screenWidth / (float)UI.screenHeight; if (floAspect > 2f) { floFrameWidth = floFrameHeight * .765f; floFrameX = UI.screenWidth - (floFrameWidth + floFramePadding); } if (floAspect < 1.25) { floFrameWidth = floFrameHeight * .477f; floFrameX = UI.screenWidth - (floFrameWidth + floFramePadding); } // Shape RimWorld Title. float floTexTitleWidth = floFrameWidth - (floFrameWidth / 1.62f); float floTexTitleHeight = (floTexTitleWidth / TitleSize.x) * TitleSize.y; // Draw Rimworld Title. Rect rectTexTitle = new Rect(floFrameX + (floFrameWidth * .05f), floFrameY, floTexTitleWidth, floTexTitleHeight); GUI.DrawTexture(rectTexTitle, TexTitle, ScaleMode.StretchToFill, true); // Shape Prophecy Title. float floProTitleWidth = floFrameWidth; float floProTitleHeight = (floProTitleWidth / ProTitleSize.x) * ProTitleSize.y; // Draw Prophecy Title. Rect rectProTitle = new Rect(floFrameX, (floFrameY + floTexTitleHeight) - floProTitleHeight * .1f, floProTitleWidth, floProTitleHeight); GUI.DrawTexture(rectProTitle, ProTBin.ProTitle, ScaleMode.StretchToFill, true); // Shape main page credit. if (UI.screenWidth > 1700f) { Text.Font = GameFont.Medium; } else { Text.Font = GameFont.Small; } Text.Anchor = TextAnchor.UpperLeft; string str = "MainPageCredit".Translate(); float floMPCWidth = floFrameWidth; float floMPCHeight = Text.CalcHeight(str, floMPCWidth); // Draw main page credit. Rect rectMPC = new Rect(floFrameX, rectProTitle.y + floProTitleHeight, floMPCWidth, floMPCHeight); Widgets.Label(rectMPC, str); // Revert GUI text size. Text.Font = GameFont.Small; // Shape main menu controls. float floMMCHeight = floFrameHeight - floMPCHeight - floProTitleHeight - floTexTitleHeight; // Draw main menu controls. Rect rectMMC = new Rect(floFrameX, rectMPC.y + (floMPCHeight * 2f), floFrameWidth, floMMCHeight); MainMenuDrawer.DoMainMenuControls(rectMMC, Traverse.CreateWithType("MainMenuDrawer").Field("anyMapFiles").GetValue <bool>()); // Shape Ludeon logo. GUI.color = new Color(1f, 1f, 1f, 0.5f); float ludeonLogoSize = (float)(UI.screenWidth - 8) - LudeonLogoSize.x; float ludeonLogoSize1 = LudeonLogoSize.x; Vector2 ludeonLogoSize2 = LudeonLogoSize; // Draw Ludeon logo. Rect rect4 = new Rect(ludeonLogoSize, 8f, ludeonLogoSize1, ludeonLogoSize2.y); GUI.DrawTexture(rect4, TexLudeonLogo, ScaleMode.StretchToFill, true); // Revert GUI text color GUI.color = Color.white; return(false); }