示例#1
0
        private void DrawWindow(int id)
        {
            GUI.BringWindowToFront(id);

            BeginVertical();
            {
                GUI.enabled = State != EState.Deleting;

                if (Button(State == EState.Deleting ? "Deleting..." : "Delete"))
                {
                    ShareMod.PlayButtonSound();

                    MessageBox.Show($"Are you sure you want to delete the world '{World.Title}'?", "u sure bro?", o =>
                    {
                        if (o == 0)
                        {
                            DeleteWorld(World);
                        }
                    }, "Yes", "No");
                }

                FlexibleSpace();

                if (Button("Close"))
                {
                    ShareMod.PlayButtonSound();

                    Close();
                }
            }
            EndVertical();

            GUI.DragWindow();
        }
示例#2
0
        public override void Draw()
        {
            if (!IsInitialized || !Remote.User.IsLoggedIn || !RunMainMenu.Instance.MainMenuCanvas.enabled)
            {
                return;
            }

            //Update world "created at" times every second
            if (Time.time - LastTimeUpdate > 1)
            {
                LastTimeUpdate = Time.time;
                UpdateWorldTimes();
            }

            if (GUI.Button(new Rect(2, 67, 150, 25), "Browse market") || (Visible && Input.GetKeyDown(KeyCode.Escape)))
            {
                ShareMod.PlayButtonSound();

                Visible = !Visible;
                SetMainMenuPlaying(!Visible);
            }

            if (Visible)
            {
                GUI.Window(1237, WorldsWindowRect, o => { }, "");
                WorldsWindowRect = GUI.Window(1235, WorldsWindowRect, DrawWindow, "World market");
                GUI.BringWindowToFront(1235);
            }
        }
示例#3
0
        private void DrawMainButton()
        {
            if (GUI.Button(new Rect(2, 37, 150, 25), "Your account"))
            {
                ShareMod.PlayButtonSound();

                Visible = !Visible;
                SetMainMenuPlaying(!Visible);
            }
        }
示例#4
0
        public void Draw()
        {
            if (!Shown.Contains(this))
            {
                return;
            }

            Vector2 size = new Vector2(300, 100);
            Vector2 pos  = new Vector2(Screen.width / 2 - size.x / 2, Screen.height / 2 - size.y / 2);

            GUI.Window(123123, new Rect(pos, size), Window, this.Title);

            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return && Options.Length == 1)
            {
                this.Result = 0;
                ResultSet?.Invoke(this, null);
            }

            void Window(int id)
            {
                BeginVertical();
                {
                    FlexibleSpace();

                    Label(this.Text, Style, MaxWidth(size.x));

                    FlexibleSpace();

                    BeginHorizontal();
                    {
                        FlexibleSpace();

                        int i = 0;
                        foreach (var item in this.Options)
                        {
                            if (Button(item, Width(90), Height(30)))
                            {
                                ShareMod.PlayButtonSound();

                                this.Result = i;
                                ResultSet?.Invoke(this, null);
                            }

                            i++;
                        }

                        FlexibleSpace();
                    }
                    EndHorizontal();
                }
                EndVertical();
            }
        }
示例#5
0
        public override void Draw()
        {
            if (!(RunMainMenu.Instance.LoadGameCanvas?.enabled ?? false) || !Remote.User.IsLoggedIn)
            {
                return;
            }

            GUI.enabled = LoadGameMenu.Instance.SelectedSaveFile != null && !Uploading;
            if (GUI.Button(new Rect(2, 37, 150, 55), "Upload world"))
            {
                ShareMod.PlayButtonSound();

                UploadWorld(Application.persistentDataPath + "/saves/" + LoadGameMenu.Instance.SelectedSaveFile.FileName);
            }
        }
示例#6
0
        private void DrawWindow(int id)
        {
            BeginVertical();
            {
                if (Button("Change password", Height(30)))
                {
                    ShareMod.PlayButtonSound();

                    State = EState.ChangingPassword;
                    PasswordUI.Show();

                    Hide();
                }

                FlexibleSpace();

                GUI.enabled = State == EState.Idle;
                if (Button("Log out", Height(30)))
                {
                    ShareMod.PlayButtonSound();

                    Logout();
                }
                GUI.enabled = true;

                if (Button("Close"))
                {
                    ShareMod.PlayButtonSound();

                    Hide();
                }
            }
            EndVertical();


            GUI.DragWindow();
        }
示例#7
0
        public override void Draw()
        {
            if (Remote.User.IsLoggedIn || !RunMainMenu.Instance.MainMenuCanvas.enabled)
            {
                return;
            }

            string text = Remote.User.IsLoggedIn ? "Log out" : "Log in to ShareMod";

            GUI.enabled = State != EState.LoggingIn;
            bool b = GUI.Button(new Rect(2, 37, 150, 25), text);

            GUI.enabled = true;

            if (b)
            {
                ShareMod.PlayButtonSound();

                if (!Remote.User.IsLoggedIn)
                {
                    if (State != EState.LoggingIn)
                    {
                        Visible = !Visible;
                        SetMainMenuPlaying(!Visible);

                        if (Visible)
                        {
                            ShallFocusUsername = true;
                        }
                    }
                }
            }

            if (Visible && Input.GetKeyDown(KeyCode.Escape))
            {
                Hide();
            }

            if (Visible)
            {
                LoginWindowRect = LoginWindowRect.CenterInScreen();
                GUI.Window(1234, LoginWindowRect, new GUI.WindowFunction(MyWindow), "ShareMod");
            }

            void MyWindow(int id)
            {
                BeginVertical();
                {
                    GUI.enabled = State != EState.LoggingIn && State != EState.Registering;

                    BeginHorizontal();
                    {
                        GUILayout.Label("Username:"******"txtUsername");
                        Username = TextField(Username, 40, MaxWidth(LoginWindowRect.width / 2));
                    }
                    EndHorizontal();

                    BeginHorizontal();
                    {
                        GUILayout.Label("Password:"******"txtPassword");
                        Password = PasswordField(Password, '*', 40, MaxWidth(LoginWindowRect.width / 2));
                    }
                    EndHorizontal();

                    GUI.enabled = true;

                    if (ShallFocusUsername)
                    {
                        ShallFocusUsername = false;

                        GUI.FocusControl("txtUsername");
                    }


                    if (State == EState.LoggingIn)
                    {
                        GUILayout.Label("Logging in...", new GUIStyle
                        {
                            normal = new GUIStyleState
                            {
                                textColor = new Color(0, 200, 0)
                            }
                        });
                    }
                    else if (State == EState.Registering)
                    {
                        GUILayout.Label("Registering...", new GUIStyle
                        {
                            normal = new GUIStyleState
                            {
                                textColor = new Color(0, 200, 0)
                            }
                        });
                    }
                    else
                    {
                        bool login = false;

                        if (Button("Login", MaxWidth(LoginWindowRect.width)))
                        {
                            ShareMod.PlayButtonSound();
                            login = true;
                        }
                        else if (Button("Register", MaxWidth(LoginWindowRect.width)))
                        {
                            ShareMod.PlayButtonSound();

                            Register(Username, Password);

                            Username = "";
                            Password = "";
                        }

                        string focused = GUI.GetNameOfFocusedControl();
                        if (Event.current.isKey && Event.current.keyCode == KeyCode.Return && (focused == "txtUsername" || focused == "txtPassword"))
                        {
                            login = true;
                        }

                        if (login)
                        {
                            Login(Username, Password);

                            Password = "";
                        }
                    }
                }
                EndVertical();

                GUI.DragWindow();
            }
        }
示例#8
0
        private void DrawWindow(int id)
        {
            BeginVertical();
            {
                GUI.enabled = State == EState.Idle;

                BeginHorizontal();
                {
                    Label("Password:"******"txtPassword");
                    Password = PasswordField(Password, '*', 40, MaxWidth(WindowRect.width / 2));
                }
                EndHorizontal();

                if (FocusPassword)
                {
                    FocusPassword = false;

                    GUI.FocusControl("txtPassword");
                }

                BeginHorizontal();
                {
                    Label("Confirm:");
                    GUI.SetNextControlName("txtConfirm");
                    Confirm = PasswordField(Confirm, '*', 40, MaxWidth(WindowRect.width / 2));
                }
                EndHorizontal();

                string focused = GUI.GetNameOfFocusedControl();

                if (Button("Submit") ||
                    Event.current.isKey && Event.current.keyCode == KeyCode.Return && focused == "txtConfirm")
                {
                    ShareMod.PlayButtonSound();

                    if (!Password.Equals(Confirm))
                    {
                        MessageBox.Show("The passwords must match!", "Error");
                    }
                    else
                    {
                        Submit();
                    }
                }

                if (Button("Cancel"))
                {
                    ShareMod.PlayButtonSound();

                    Password = "";
                    Confirm  = "";

                    Done?.Invoke(this, EventArgs.Empty);
                    Hide();
                }

                GUI.enabled = true;
            }
            EndVertical();
        }
示例#9
0
        private void DrawWorldEntry(WorldItem world)
        {
            string authorName = world.Author.Username;

            BeginHorizontal(world.World == Selected ? EntryHoverStyle : EntryStyle, Height(68));
            {
                Box("", Width(60), Height(60));

                BeginVertical();
                {
                    Label($"<b><size=16>{world.World.Title}</size></b>");

                    Label("by " + authorName, WorldInfoStyle);
                    Label($"{world.World.Downloads} downloads", WorldInfoStyle);
                }
                EndVertical();

                string btnText =
                    world.State == WorldState.Downloading ? "Downloading..." :
                    world.State == WorldState.Existing ? "Play" : "Download";

                GUI.enabled = world.State != WorldState.Downloading;
                FlexibleSpace();
                BeginVertical();
                {
                    FlexibleSpace();

                    BeginHorizontal();
                    {
                        FlexibleSpace();

                        //--Manage button--
                        if (world.Author.ID == Remote.User.CurrentUser.ID && Button("Manage", Height(30)))
                        {
                            ShareMod.PlayButtonSound();

                            if (!Managing.Any(o => o.World.ID == world.World.ID))
                            {
                                ShowManageWorld(world.World);
                            }
                        }
                        //------------

                        //--Download button--
                        if (Button(btnText, Height(30), Width(95)))
                        {
                            ShareMod.PlayButtonSound();
                            Selected = world.World;

                            if (world.State == WorldState.Existing)
                            {
                                Hide();
                                LoadWorld(world.World);
                            }
                            else
                            {
                                DownloadWorld(world);
                            }
                        }
                        //------------
                    }
                    EndHorizontal();

                    Space(5);

                    GUI.enabled = false;

                    string time = world.TimeString;

                    Label(time, WorldIDStyle);
                    FlexibleSpace();

                    GUI.enabled = true;
                }
                EndVertical();
            }
            EndHorizontal();

            Rect horRect = GUILayoutUtility.GetLastRect();

            if (Event.current.isMouse && horRect.Contains(Event.current.mousePosition) && Event.current.button == 0)
            {
                Selected = world.World;
            }
        }
示例#10
0
        private void DrawPageControls(bool enabled = true)
        {
            bool downloading = WorldStates.Values.Any(o => o.State == WorldState.Downloading);

            if (downloading)
            {
                enabled = false;
            }

            FlexibleSpace();

            BeginVertical();
            {
                FlexibleSpace();

                GUI.enabled = !downloading;
                if (Button("Refresh", Height(30), Width(95)))
                {
                    ShareMod.PlayButtonSound();

                    Refresh(clearCache: true);
                }
                GUI.enabled = true;

                FlexibleSpace();
            }
            EndVertical();

            Space(8);

            BeginVertical();
            {
                FlexibleSpace();

                GUI.enabled = downloading ? false : !enabled ? false : (LastResponse?.Page ?? 0) != 0;
                if (Button("Previous page", Height(30), Width(95)))
                {
                    ShareMod.PlayButtonSound();

                    CurrentPage--;
                    Refresh();
                }

                FlexibleSpace();
            }
            EndVertical();

            BeginVertical();
            {
                FlexibleSpace();

                GUI.enabled = downloading ? false : !enabled ? false : (!LastResponse?.LastPage ?? false);
                if (Button("Next page", Height(30), Width(95)))
                {
                    ShareMod.PlayButtonSound();

                    CurrentPage++;
                    Refresh();
                }
                GUI.enabled = enabled;

                FlexibleSpace();
            }
            EndVertical();
        }