Exemplo n.º 1
0
        private void DoDiscordWindow(int windowId)
        {
            GUISkinUtils.RenderWithSkin(SetGUIStyle(), () =>
            {
                using (GUILayout.VerticalScope v = new GUILayout.VerticalScope("Box"))
                {
                    using (GUILayout.HorizontalScope h = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(avatar);
                        GUILayout.Label("<b>" + Request.username + "</b> wants to join your server.");
                    }
                    using (GUILayout.HorizontalScope b = new GUILayout.HorizontalScope())
                    {
                        if (GUILayout.Button("Accept"))
                        {
                            CloseWindow(1);
                        }

                        if (GUILayout.Button("Deny"))
                        {
                            CloseWindow(0);
                        }
                    }
                }
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Call this inside a <see cref="MonoBehaviour.OnGUI"/> method.
        /// </summary>
        public void OnGUI()
        {
            if (!Enabled)
            {
                return;
            }

            GUISkin skin     = GUI.skin;
            string  skinName = GetSkinName();

            switch (SkinCreationOptions)
            {
            case GUISkinCreationOptions.DEFAULT:
                skin = GUISkinUtils.RegisterDerivedOnce("debuggers.default", s =>
                {
                    SetBaseStyle(s);
                    OnSetSkinImpl(s);
                });
                break;

            case GUISkinCreationOptions.UNITYCOPY:
                skin = GUISkinUtils.RegisterDerivedOnce(skinName, OnSetSkinImpl);
                break;

            case GUISkinCreationOptions.DERIVEDCOPY:
                GUISkin baseSkin = GUISkinUtils.RegisterDerivedOnce("debuggers.default", SetBaseStyle);
                skin = GUISkinUtils.RegisterDerivedOnce(skinName, OnSetSkinImpl, baseSkin);
                break;
            }
            GUISkinUtils.RenderWithSkin(skin, () =>
            {
                WindowRect = GUILayout.Window(GUIUtility.GetControlID(FocusType.Keyboard), WindowRect, RenderInternal, $"[DEBUGGER] {DebuggerName}", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
            });
        }
Exemplo n.º 3
0
        private void JoinServerWindow(int windowId)
        {
            Event e = Event.current;

            if (e.isKey)
            {
                switch (e.keyCode)
                {
                case KeyCode.Return:
                    OnJoinButtonClick();
                    break;

                case KeyCode.Escape:
                    OnCancelButtonClick();
                    break;
                }
            }

            GUISkinUtils.RenderWithSkin(GetGUISkin("menus.server.join", 80), () => {
                using (new GUILayout.VerticalScope("Box")) {
                    using (new GUILayout.HorizontalScope()) {
                        GUILayout.Label("Username:"******"usernameInput");
                        usernameInput = GUILayout.TextField(usernameInput, 30);
                    }

                    using (new GUILayout.HorizontalScope()) {
                        GUILayout.Label("Password:"******"passwordInput");
                        passwordInput = GUILayout.TextField(passwordInput, 64);
                    }

                    using (new GUILayout.HorizontalScope()) {
                        GUILayout.Label("Host:");
                        GUI.SetNextControlName("hostnameInput");
                        hostnameInput = GUILayout.TextField(hostnameInput, 120);
                    }

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button("Join"))
                    {
                        OnJoinButtonClick();
                    }

                    if (GUILayout.Button("Cancel"))
                    {
                        OnCancelButtonClick();
                    }

                    GUILayout.EndHorizontal();
                }

                if (shouldFocus)
                {
                    GUI.FocusControl("playerNameField");
                    shouldFocus = false;
                }
            });
        }
Exemplo n.º 4
0
        private void DrawDiscordRequestWindow(int windowID)
        {
            GUISkinUtils.RenderWithSkin(guiSkin, () =>
            {
                using (new GUILayout.VerticalScope("Box"))
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(avatar);
                        GUILayout.Label("<b>" + Request.username + "</b> wants to join your server.");
                    }

                    using (new GUILayout.HorizontalScope())
                    {
                        if (GUILayout.Button("Accept"))
                        {
                            CloseWindow(DiscordRpc.Reply.YES);
                        }

                        if (GUILayout.Button("Deny"))
                        {
                            CloseWindow(DiscordRpc.Reply.NO);
                        }
                    }
                }
            });
        }
Exemplo n.º 5
0
        private void DoAddServerWindow(int windowId)
        {
            Event e = Event.current;

            if (e.isKey)
            {
                switch (e.keyCode)
                {
                case KeyCode.Return:
                    OnAddServerButtonClicked();
                    break;

                case KeyCode.Escape:
                    OnCancelButtonClicked();
                    break;
                }
            }

            GUISkinUtils.RenderWithSkin(GetGUISkin(),
                                        () =>
            {
                using (new GUILayout.VerticalScope("Box"))
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label("Name:");
                        GUI.SetNextControlName("serverNameField");
                        // 120 so users can't go too crazy.
                        serverNameInput = GUILayout.TextField(serverNameInput, 120);
                    }

                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label("Host:");
                        GUI.SetNextControlName("serverHostField");
                        // 120 so users can't go too crazy.
                        serverHostInput = GUILayout.TextField(serverHostInput, 120);
                    }

                    if (GUILayout.Button("Add server"))
                    {
                        OnAddServerButtonClicked();
                    }

                    if (GUILayout.Button("Cancel"))
                    {
                        OnCancelButtonClicked();
                    }
                }
            });

            if (shouldFocus)
            {
                GUI.FocusControl("serverNameField");
                shouldFocus = false;
            }
        }
Exemplo n.º 6
0
        private void DoServerPasswordWindow(int windowId)
        {
            Event e = Event.current;

            if (e.isKey)
            {
                switch (e.keyCode)
                {
                case KeyCode.Return:
                    OnSubmitPasswordButtonClicked();
                    break;

                case KeyCode.Escape:
                    OnCancelButtonClicked();
                    break;
                }
            }

            GUISkinUtils.RenderWithSkin(GetGUISkin(),
                                        () =>
            {
                using (new GUILayout.VerticalScope("Box"))
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label("Password:"******"serverPasswordField");
                        serverPassword = GUILayout.TextField(serverPassword);
                    }

                    if (GUILayout.Button("Submit Password"))
                    {
                        HidePasswordWindow();
                        OnSubmitPasswordButtonClicked();
                    }

                    if (GUILayout.Button("Cancel"))
                    {
                        HidePasswordWindow();
                        OnCancelClick();
                    }
                }
            });

            if (shouldFocus)
            {
                GUI.FocusControl("serverPasswordField");
                shouldFocus = false;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Call this inside a <see cref="MonoBehaviour.OnGUI"/> method.
        /// </summary>
        public virtual void OnGUI()
        {
            if (!Enabled)
            {
                return;
            }

            GUISkin skin = GetSkin();

            GUISkinUtils.RenderWithSkin(skin, () =>
            {
                WindowRect = GUILayout.Window(GUIUtility.GetControlID(FocusType.Keyboard), WindowRect, RenderInternal, $"[DEBUGGER] {DebuggerName}", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
            });
        }
Exemplo n.º 8
0
        private void DoJoinServerWindow(int windowId)
        {
            Event e = Event.current;

            if (e.isKey)
            {
                switch (e.keyCode)
                {
                case KeyCode.Return:
                    StartCoroutine(JoinServerWait(ServerIp));
                    showingUsername = false;
                    break;

                case KeyCode.Escape:
                    showingUsername = false;
                    break;
                }
            }

            GUISkinUtils.RenderWithSkin(GetGUISkin(), () =>
            {
                using (new GUILayout.VerticalScope("Box"))
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label("Username:"******"usernameField");
                        username = GUILayout.TextField(username);
                    }

                    if (GUILayout.Button("Join"))
                    {
                        StartCoroutine(JoinServerWait(ServerIp));
                        showingUsername = false;
                    }

                    if (GUILayout.Button("Cancel"))
                    {
                        showingUsername = false;
                    }
                }
            });

            if (shouldFocus)
            {
                GUI.FocusControl("usernameField");
                shouldFocus = false;
            }
        }
Exemplo n.º 9
0
        private void RenderJoinServerDialog(int windowId)
        {
            Event e = Event.current;

            if (e.isKey)
            {
                switch (e.keyCode)
                {
                case KeyCode.Return:
                    StartMultiplayerClient();
                    break;

                case KeyCode.Escape:
                    StopMultiplayerClient();
                    break;
                }
            }

            GUISkinUtils.RenderWithSkin(GetGUISkin("menus.server", 80), () =>
            {
                using (new GUILayout.VerticalScope("Box"))
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label("Username:"******"usernameField");
                        username = GUILayout.TextField(username);
                    }


                    if (GUILayout.Button("Join"))
                    {
                        StartMultiplayerClient();
                    }

                    if (GUILayout.Button("Cancel"))
                    {
                        StopMultiplayerClient();
                    }
                }
            });

            if (shouldFocus)
            {
                GUI.FocusControl("usernameField");
                shouldFocus = false;
            }
        }
Exemplo n.º 10
0
        private void RenderJoinServerDialog(int windowId)
        {
            Event e = Event.current;

            if (e.isKey)
            {
                switch (e.keyCode)
                {
                case KeyCode.Return:
                    multiplayerSession.RequestSessionReservation(new PlayerSettings(RandomColorGenerator.GenerateColor()), new AuthenticationContext(username));
                    break;

                case KeyCode.Escape:
                    StopMultiplayerClient();
                    break;
                }
            }

            GUISkinUtils.RenderWithSkin(GetGUISkin("menus.server", 80), () =>
            {
                using (new GUILayout.VerticalScope("Box"))
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label("Username:"******"usernameField");
                        username = GUILayout.TextField(username);
                    }

                    if (GUILayout.Button("Join"))
                    {
                        multiplayerSession.RequestSessionReservation(new PlayerSettings(RandomColorGenerator.GenerateColor()), new AuthenticationContext(username));
                    }

                    if (GUILayout.Button("Cancel"))
                    {
                        joiningServer = false;
                        StopMultiplayerClient();
                    }
                }
            });

            if (shouldFocus)
            {
                GUI.FocusControl("usernameField");
                shouldFocus = false;
            }
        }
Exemplo n.º 11
0
        private void RenderUnableToJoinDialog(int windowId)
        {
            GUISkinUtils.RenderWithSkin(GetGUISkin("dialogs.server.rejected", 550), () =>
            {
                using (new GUILayout.VerticalScope("Box"))
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(notificationMessage);
                    }

                    if (GUILayout.Button("OK"))
                    {
                        AcknowledgeNotification();
                    }
                }
            });
        }
Exemplo n.º 12
0
        private void RenderUnableToJoinDialog(int windowId)
        {
            Event e = Event.current;

            if (e.isKey)
            {
                switch (e.keyCode)
                {
                case KeyCode.Return:
                    joiningServer         = true;
                    notifyingUnableToJoin = false;
                    break;

                case KeyCode.Escape:
                    joiningServer         = true;
                    notifyingUnableToJoin = false;
                    break;
                }
            }

            GUISkinUtils.RenderWithSkin(GetGUISkin("dialogs.server.rejected", 490), () =>
            {
                using (new GUILayout.VerticalScope("Box"))
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        MultiplayerSessionReservationState reservationState = multiplayerSession.Reservation.ReservationState;
                        string reservationStateDescription = reservationState.Describe();

                        GUILayout.Label(reservationStateDescription);
                    }

                    if (GUILayout.Button("OK"))
                    {
                        notifyingUnableToJoin = false;
                        multiplayerSession.Disconnect();
                        multiplayerSession.Connect(ServerIp);
                    }
                }
            });
        }