public override void onGui()
        {
            if (Input.GetKey(KeyCode.Space))
            {
                return;
            }

            if (window != null)
            {
                RenderWindow();
                return;
            }

            ResourceList  instance       = ResourceList.getInstance();
            TitleTextures title          = instance.Title;
            Texture2D     gameTitle      = title.GameTitle;
            Vector2       menuButtonSize = GuiRenderer.getMenuButtonSize(FontSize.Huge);
            Vector2       titleLocation  = Singleton <TitleScene> .getInstance().getTitleLocation();

            Vector2 menuLocation = Singleton <TitleScene> .getInstance().getMenuLocation();

            float buttonLeftOffset = (float)Screen.width * 0.75f + (((float)Screen.width * 0.25f) - menuButtonSize.x) / 2;
            float num  = (float)(Screen.height * gameTitle.height) / 1080f;
            float num2 = num * (float)gameTitle.width / (float)gameTitle.height;

            GUI.color = new Color(1f, 1f, 1f, this.mAlpha);
            GUI.DrawTexture(new Rect(titleLocation.x - num2 * 0.5f, titleLocation.y, num2, num), gameTitle);
            GUI.color = Color.white;
            Texture2D backgroundRight = title.BackgroundRight;
            float     num3            = (float)(Screen.height * backgroundRight.height) / 1080f;
            float     num4            = num3 * (float)backgroundRight.width / (float)backgroundRight.height;

            GUI.DrawTexture(new Rect((float)Screen.width - num4 + this.mRightOffset, ((float)Screen.height - num3) * 0.75f, num4, num3), backgroundRight);
            float num5 = menuLocation.y;
            float num6 = menuButtonSize.y * 1.3f;

            serverTarget = GUI.TextField(new Rect(buttonLeftOffset + mRightOffset, num5, menuButtonSize.x, menuButtonSize.y), serverTarget,
                                         21, createTextFieldStyle((int)menuButtonSize.x, (int)menuButtonSize.y));
            num5    += num6;
            username = GUI.TextField(new Rect(buttonLeftOffset + mRightOffset, num5, menuButtonSize.x, menuButtonSize.y), username,
                                     21, createTextFieldStyle((int)menuButtonSize.x, (int)menuButtonSize.y));
            num5    += num6;
            password = GUI.TextField(new Rect(buttonLeftOffset + mRightOffset, num5, menuButtonSize.x, menuButtonSize.y), password,
                                     21, createTextFieldStyle((int)menuButtonSize.x, (int)menuButtonSize.y));

            num5 += num6 * 2;
            if (mGuiRenderer.renderTitleButton(new Rect(buttonLeftOffset + mRightOffset, num5, menuButtonSize.x, menuButtonSize.y), "Connect", FontSize.Huge, true))
            {
                DisableMultiplayer();
                ConnectServer();
            }
            num5 += num6;
            if (mGuiRenderer.renderTitleButton(new Rect(buttonLeftOffset + mRightOffset, num5, menuButtonSize.x, menuButtonSize.y), StringList.get("back"), FontSize.Huge, true))
            {
                DisableMultiplayer();
                GameManager.getInstance().setGameStateTitle();
            }
        }
        private void PrintLine(string text, int lineNumber)
        {
            Vector2  textLocation = new Vector2(50, 80);
            GUIStyle labelStyle   = Renderer.getLabelStyle(FontSize.Huge, FontStyle.Bold, TextAnchor.LowerLeft, FontType.Title);

            labelStyle.normal.textColor = Color.blue;

            GUI.Label(new Rect(textLocation.x, textLocation.y + (GuiRenderer.getMenuButtonSize(FontSize.Huge).y) * lineNumber, Screen.width, GuiRenderer.getMenuButtonSize(FontSize.Huge).y - 30), text, labelStyle);

            labelStyle.normal.textColor = Color.white;
        }
        public static void Postfix(global::Planetbase.GameStateTitle __instance)
        {
            //Render the background image
            var backgroundImage = ResourceList.getInstance().Title.BackgroundRight;
            var textureHeight   = Screen.height * backgroundImage.height / 1080f;
            var textureWidth    = textureHeight * backgroundImage.width / backgroundImage.height;

            GUI.DrawTexture(
                new Rect(
                    textureWidth - __instance.mRightOffset,
                    (float)((Screen.height - (double)textureHeight) * 0.75),
                    -textureWidth,
                    textureHeight
                    ),
                backgroundImage
                );

            //Render the buttons
            var menuLocation = Singleton <global::Planetbase.TitleScene> .getInstance().getMenuLocation();

            var menuButtonSize = GuiRenderer.getMenuButtonSize(FontSize.Huge);

            menuLocation.x -= menuButtonSize.x;
            menuLocation.x += __instance.mRightOffset;

            var modY = menuLocation.y;
            var num1 = menuButtonSize.y * 1.3f;

            foreach (var button in RegisteredTitleButtons)
            {
                if (__instance.mGuiRenderer.renderTitleButton(
                        new Rect(
                            Screen.width - menuLocation.x - menuButtonSize.x,
                            modY,
                            menuButtonSize.x,
                            menuButtonSize.y
                            ),
                        button.Name,
                        FontSize.Huge)
                    )
                {
                    button.HandleAction(__instance);
                }

                modY += num1;
            }
        }
        public override void onGui()
        {
            if (Input.GetKey(KeyCode.Space))
            {
                return;
            }

            PrintLine("Loaded Mods:", 0);
            for (var i = 0; i < ModLoader.ModList.Count; i++)
            {
                PrintLine(ModLoader.ModList[i].ModName, i + 1);
            }

            if (Renderer.renderBackButton(
                    new Vector2(
                        Screen.width - GuiRenderer.getMenuButtonSize(FontSize.Huge).x,
                        Screen.height - GuiRenderer.getMenuButtonSize(FontSize.Huge).y
                        )
                    ))
            {
                GameManager.getInstance().setGameStateTitle();
            }
        }
Esempio n. 5
0
        static bool Prefix(GameStateTitle __instance)
        {
            if (Input.GetKey(KeyCode.Space))
            {
                return(false);
            }

            Type instanceType = __instance.GetType();

            FieldInfo  mGuiRendererInfo   = Reflection.GetPrivateFieldOrThrow(instanceType, "mGuiRenderer", true);
            FieldInfo  mAlphaInfo         = Reflection.GetPrivateFieldOrThrow(instanceType, "mAlpha", true);
            FieldInfo  mRightOffsetInfo   = Reflection.GetPrivateFieldOrThrow(instanceType, "mRightOffset", true);
            FieldInfo  mConfirmWindowInfo = Reflection.GetPrivateFieldOrThrow(instanceType, "mConfirmWindow", true);
            FieldInfo  mAnySavegamesInfo  = Reflection.GetPrivateFieldOrThrow(instanceType, "mAnySavegames", true);
            MethodInfo canAlreadyPlayInfo = Reflection.GetPrivateMethodOrThrow(instanceType, "canAlreadyPlay", true);
            MethodInfo renderTutorialRequestWindowInfo = Reflection.GetPrivateMethodOrThrow(instanceType, "renderTutorialRequestWindow", true);

            GuiRenderer mGuiRenderer = (GuiRenderer)Reflection.GetInstanceFieldValue(__instance, mGuiRendererInfo);

            if (mGuiRenderer == null)
            {
                mGuiRenderer = new GuiRenderer();
                Reflection.SetInstanceFieldValue(__instance, mGuiRendererInfo, mGuiRenderer);
            }
            ResourceList  instance       = ResourceList.getInstance();
            TitleTextures title          = instance.Title;
            Texture2D     gameTitle      = title.GameTitle;
            Vector2       menuButtonSize = GuiRenderer.getMenuButtonSize(FontSize.Huge);
            Vector2       titleLocation  = Singleton <TitleScene> .getInstance().getTitleLocation();

            Vector2 menuLocation = Singleton <TitleScene> .getInstance().getMenuLocation();

            float num  = (float)(Screen.height * gameTitle.height) / 1080f;
            float num2 = num * (float)gameTitle.width / (float)gameTitle.height;

            GUI.color = new Color(1f, 1f, 1f, (float)Reflection.GetInstanceFieldValue(__instance, mAlphaInfo));
            GUI.DrawTexture(new Rect(titleLocation.x - num2 * 0.5f, titleLocation.y, num2, num), gameTitle);
            GUI.color = Color.white;
            Texture2D backgroundRight = title.BackgroundRight;
            float     num3            = (float)(Screen.height * backgroundRight.height) / 1080f;
            float     num4            = num3 * (float)backgroundRight.width / (float)backgroundRight.height;

            GUI.DrawTexture(new Rect((float)Screen.width - num4 + (float)Reflection.GetInstanceFieldValue(__instance, mRightOffsetInfo), ((float)Screen.height - num3) * 0.75f, num4, num3), backgroundRight);
            float num5 = menuLocation.y * 0.95f;
            float num6 = menuButtonSize.y * 1.2f;

            menuLocation.x -= menuButtonSize.x;
            menuLocation.x += (float)Reflection.GetInstanceFieldValue(__instance, mRightOffsetInfo);
            if (mGuiRenderer.renderTitleButton(new Rect(menuLocation.x, num5, menuButtonSize.x, menuButtonSize.y), StringList.get("new_game"), FontSize.Huge, true))
            {
                if ((bool)Reflection.InvokeInstanceMethod(__instance, canAlreadyPlayInfo))
                {
                    GameManager.getInstance().setGameStateLocationSelection();
                }
                else
                {
                    Reflection.InvokeInstanceMethod(__instance, renderTutorialRequestWindowInfo, new GuiDefinitions.Callback(__instance.onWindowCancelNewGame));
                }
            }
            GUI.enabled = (bool)Reflection.GetInstanceFieldValue(__instance, mAnySavegamesInfo);
            num5       += num6;
            if (mGuiRenderer.renderTitleButton(new Rect(menuLocation.x, num5, menuButtonSize.x, menuButtonSize.y), StringList.get("continue_game"), FontSize.Huge, true))
            {
                GameManager.getInstance().setGameStateGameContinue();
            }
            num5 += num6;
            if (mGuiRenderer.renderTitleButton(new Rect(menuLocation.x, num5, menuButtonSize.x, menuButtonSize.y), StringList.get("load_game"), FontSize.Huge, true))
            {
                GameManager.getInstance().setGameStateLoadGame();
            }
            num5       += num6;
            GUI.enabled = true;
            if (mGuiRenderer.renderTitleButton(new Rect(menuLocation.x, num5, menuButtonSize.x, menuButtonSize.y), "Multiplayer", FontSize.Huge, true))
            {
                GameManager.getInstance().setNewState(new GameStateMultiplayer(GameManager.getInstance().getGameState()));
            }
            num5 += num6;
            if (mGuiRenderer.renderTitleButton(new Rect(menuLocation.x, num5, menuButtonSize.x, menuButtonSize.y), StringList.get("tutorial"), FontSize.Huge, true))
            {
                GameManager.getInstance().setGameStateGameNew(1, 0, true, null);
            }
            num5 += num6;
            if (mGuiRenderer.renderTitleButton(new Rect(menuLocation.x, num5, menuButtonSize.x, menuButtonSize.y), StringList.get("challenges"), FontSize.Huge, true))
            {
                if ((bool)Reflection.InvokeInstanceMethod(__instance, canAlreadyPlayInfo))
                {
                    GameManager.getInstance().setGameStateChallengeSelection();
                }
                else
                {
                    Reflection.InvokeInstanceMethod(__instance, renderTutorialRequestWindowInfo, new GuiDefinitions.Callback(__instance.onWindowCancelChallenges));
                }
            }
            num5 += num6;
            if (mGuiRenderer.renderTitleButton(new Rect(menuLocation.x, num5, menuButtonSize.x, menuButtonSize.y), StringList.get("settings"), FontSize.Huge, true))
            {
                GameManager.getInstance().setGameStateSettings();
            }
            num5 += num6;
            if (mGuiRenderer.renderTitleButton(new Rect(menuLocation.x, num5, menuButtonSize.x, menuButtonSize.y), StringList.get("quit"), FontSize.Huge, true))
            {
                Application.Quit();
            }
            if ((GuiConfirmWindow)Reflection.GetInstanceFieldValue(__instance, mConfirmWindowInfo) != null)
            {
                mGuiRenderer.renderWindow((GuiConfirmWindow)Reflection.GetInstanceFieldValue(__instance, mConfirmWindowInfo), null);
            }
            int     num7   = 3;
            float   num8   = menuButtonSize.y * 0.75f;
            float   num9   = menuButtonSize.y * 0.25f;
            Vector2 vector = new Vector2(((float)Screen.width - (float)num7 * num8 - (float)(num7 - 1) * num9) * 0.5f, (float)Screen.height - num8 - num9 + (float)Reflection.GetInstanceFieldValue(__instance, mRightOffsetInfo) * 0.5f);
            Rect    rect   = new Rect(vector.x, vector.y, num8, num8);

            if (mGuiRenderer.renderButton(rect, new GUIContent(null, instance.Icons.Credits, StringList.get("credits")), null))
            {
                GameManager.getInstance().setGameStateCredits();
            }
            rect.x += num8 + num9;
            if (mGuiRenderer.renderButton(rect, new GUIContent(null, instance.Icons.SwitchPlanet, StringList.get("switch_planet")), null))
            {
                Singleton <TitleScene> .getInstance().switchPlanet();
            }
            rect.x += num8 + num9;
            if (mGuiRenderer.renderButton(rect, new GUIContent(null, instance.Icons.Achievements, StringList.get("achievements")), null))
            {
                GameManager.getInstance().setGameStateAchievements();
            }
            rect.x += num8 + num9;
            return(false);
        }