Exemple #1
0
        static bool Prefix()
        {
            FryLabsServerList.UI.Instance.IsModEnabled = Main.enabled;
            FryLabsServerList.UI.Instance.Opened       = true;

            if (ServerList.servers.Count == 0)
            {
                ServerList.Search();
            }

            // Don't run original function if our browser is enabled
            return(!Main.enabled);
        }
        // Called by window in loop?
        private void WindowFunction(int windowId)
        {
            if (Input.GetAxisRaw("Mouse ScrollWheel") != 0)
            {
                UI.scrollPos.y += Input.GetAxisRaw("Mouse ScrollWheel");
            }

            if (!UI.isButtonStyleInitialized)
            {
                UI.button                   = new GUIStyle(GUI.skin.button);
                UI.button.alignment         = TextAnchor.MiddleCenter;
                UI.button.margin            = new RectOffset(0, 0, 0, 0);
                UI.isButtonStyleInitialized = true;
            }

            GUILayout.Label(
                String.Format(
                    "{0} v{1}",
                    FryLabsServerList.Main.mod.Info.DisplayName,
                    FryLabsServerList.Main.mod.Info.Version
                    ),
                UnityModManager.UI.h1
                );
            GUILayout.Space(5);

            UI.scrollPos = GUILayout.BeginScrollView(UI.scrollPos, GUILayout.MinWidth(mWindowSize.x), GUILayout.MaxWidth(mWindowSize.x));
            GUILayout.BeginVertical();

            foreach (ServerData sData in ServerList.servers)
            {
                GUILayout.Space(3);

                GUILayout.BeginHorizontal(GUILayout.MinWidth(mWindowSize.x - 15), GUILayout.MaxWidth(mWindowSize.x - 15));

                GUILayout.Label(sData.Project, UI.textLeft, GUILayout.Width(150), GUILayout.ExpandWidth(false));
                GUILayout.Label(sData.Info, UI.textInfo, GUILayout.MaxWidth(mWindowSize.x - 440));
                GUILayout.Label(sData.Players, UI.textCenter, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(sData.Ping.ToString(), UI.textCenter, GUILayout.Width(25), GUILayout.ExpandWidth(false));

                if (GUILayout.Button("Discord", UI.button, GUILayout.ExpandWidth(false)))
                {
                    ServerList.Discord(sData);
                }

                if (GUILayout.Button("Rules", UI.button, GUILayout.ExpandWidth(false)))
                {
                    ToggleWindow(false);
                    global::ServerInfo.ShowInfo(sData.serverInfo.pastebin);
                }

                if (GUILayout.Button("Connect", UI.button, GUILayout.ExpandWidth(false)))
                {
                    ToggleWindow(false);
                    ServerList.Connect(sData);
                }

                GUILayout.EndHorizontal();

                GUILayout.Space(3);
                GUILayout.Label(GUIContent.none, UI.separator, GUILayout.ExpandWidth(true), GUILayout.Height(1f));
            }

            GUILayout.EndVertical();
            GUILayout.EndScrollView();

            GUILayout.FlexibleSpace();
            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayout.Label(UI.status);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Close", UnityModManager.UI.button, GUILayout.ExpandWidth(false)))
            {
                ToggleWindow(false);
            }
            if (GUILayout.Button("Refresh", UnityModManager.UI.button, GUILayout.ExpandWidth(false)))
            {
                ServerList.Search();
            }
            GUILayout.EndHorizontal();
        }