예제 #1
0
        public static void MainMenuOnGUI()
        {
            VersionControl.DrawInfoInCorner();
            Rect rect = new Rect((float)(Screen.width / 2) - MainMenuDrawer.PaneSize.x / 2f, (float)(Screen.height / 2) - MainMenuDrawer.PaneSize.y / 2f, MainMenuDrawer.PaneSize.x, MainMenuDrawer.PaneSize.y);

            rect.y += 50f;
            rect.x  = (float)Screen.width - rect.width - 30f;
            Vector2 a = MainMenuDrawer.TitleSize;

            if (a.x > (float)Screen.width)
            {
                a *= (float)Screen.width / a.x;
            }
            a *= 0.7f;
            Rect rect2 = new Rect((float)(Screen.width / 2) - a.x / 2f, rect.y - a.y - 10f, a.x, a.y);

            rect2.x = (float)Screen.width - a.x - 50f;
            GUI.DrawTexture(rect2, MainMenuDrawer.TexTitle, ScaleMode.StretchToFill, true);
            Rect rect3 = rect2;

            rect3.y     += rect2.height;
            rect3.xMax  -= 55f;
            rect3.height = 30f;
            rect3.y     += 3f;
            string text = "MainPageCredit".Translate();

            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.UpperRight;
            if (Screen.width < 990)
            {
                Rect position = rect3;
                position.xMin  = position.xMax - Text.CalcSize(text).x;
                position.xMin -= 4f;
                position.xMax += 4f;
                GUI.color      = new Color(0.2f, 0.2f, 0.2f, 0.5f);
                GUI.DrawTexture(position, BaseContent.WhiteTex);
                GUI.color = Color.white;
            }
            Widgets.Label(rect3, text);
            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Small;
            GUI.color   = new Color(1f, 1f, 1f, 0.5f);
            Rect position2 = new Rect((float)(Screen.width - 8) - MainMenuDrawer.LudeonLogoSize.x, 8f, MainMenuDrawer.LudeonLogoSize.x, MainMenuDrawer.LudeonLogoSize.y);

            GUI.DrawTexture(position2, MainMenuDrawer.TexLudeonLogo, ScaleMode.StretchToFill, true);
            GUI.color = Color.white;
            Rect rect4 = rect.ContractedBy(17f);

            GUI.BeginGroup(rect4);
            MainMenuDrawer.DoMainMenuButtons(rect4, MainMenuDrawer.anyWorldFiles, MainMenuDrawer.anyMapFiles, null);
            GUI.EndGroup();
        }
예제 #2
0
        /*
         * 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 override void ExtraOnGUI()
 {
     base.ExtraOnGUI();
     VersionControl.DrawInfoInCorner();
 }
예제 #4
0
        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);
        }