Beispiel #1
0
    void PlayWindow(int windowID)        // Window 2
    {
        playWindowScrollView = GUILayout.BeginScrollView(playWindowScrollView, false, false, GUILayout.Width(controlWindowRect.width), GUILayout.Height(controlWindowRect.height));

        GUILayout.BeginVertical();

        GUILayout.Space(5);
        GUILayout.BeginHorizontal();
        GUILayout.Space(5);
        if (GUILayout.Button("Host Match", hiddenCenterLargeStyle))
        {
            if (hostSection == true)
            {
                hostSection = false;
            }
            else
            {
                hostSection = true;
            }
        }
        GUILayout.EndHorizontal();

        if (hostSection == true)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Host Match on: ", labelLeftMediumStyle);
            networkManager.activePort = GUILayout.TextField(networkManager.activePort, 5, textFieldStyle);
            if (GUILayout.Button("Host", buttonCenterSmallStyle))
            {
                debugLog.ReceiveMessage("\nInitializing Host");
                if (networkManager.SetupHost())
                {
                    debugLog.ReceiveMessage("\tHosting Enabled Sucessfully");
                }
                else
                {
                    debugLog.ReceiveMessage("\tERROR: Unable to Initialize Hosting");
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }


        GUILayout.Space(40);
        GUILayout.BeginHorizontal();
        GUILayout.Space(5);
        if (GUILayout.Button("Official Servers", hiddenCenterLargeStyle))
        {
            if (officialConnectSection == true)
            {
                officialConnectSection = false;
            }
            else
            {
                officialConnectSection = true;
            }
        }
        GUILayout.EndHorizontal();

        if (officialConnectSection == true)
        {
            foreach (OfficialServer officialServer in serversManager.officialServerList.officialServers)
            {
                if (GUILayout.Button(officialServer.name, buttonLeftMediumStyle))
                {
/*					Connect to Official Server	*/
                    networkManager.AttemptConnection(officialServer.ipaddress, officialServer.port);
                }
            }
        }


        GUILayout.Space(40);
        GUILayout.BeginHorizontal();
        GUILayout.Space(5);
        if (GUILayout.Button("Direct Connection", hiddenCenterLargeStyle))
        {
            if (directConnectSection == true)
            {
                directConnectSection = false;
            }
            else
            {
                directConnectSection = true;
            }
        }
        GUILayout.EndHorizontal();

        if (directConnectSection == true)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Connect to: ", labelLeftMediumStyle);
            directIP   = GUILayout.TextField(RemoveChar(directIP), 22, textFieldStyle, GUILayout.MinWidth(120));
            directPort = GUILayout.TextField(RemoveChar(directPort), 5, textFieldStyle, GUILayout.MinWidth(50));
            directName = GUILayout.TextField(directName, 22, textFieldStyle, GUILayout.MinWidth(105));
            if (GUILayout.Button("Save Server", buttonCenterSmallStyle))
            {
                debugLog.ReceiveMessage("\nSaving Server [" + directIP + ", " + directPort + ", " + directName + "]");
                externalInformation.SaveServer(directIP, directPort, directName);
            }
            if (GUILayout.Button("Connect", buttonCenterSmallStyle))
            {
                networkManager.AttemptConnection(directIP, directPort);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }


        if (serversManager.savedServerList.savedServers != null && serversManager.savedServerList.savedServers.Count > 0)
        {
            GUILayout.Space(40);
            GUILayout.BeginHorizontal();
            GUILayout.Space(5);
            if (GUILayout.Button("Saved Servers", hiddenCenterLargeStyle))
            {
                if (savedServerSection == true)
                {
                    savedServerSection = false;
                }
                else
                {
                    savedServerSection = true;
                }
            }
            GUILayout.EndHorizontal();

            if (savedServerSection == true)
            {
                foreach (SavedServer savedServer in serversManager.savedServerList.savedServers)
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(savedServer.name, buttonLeftMediumStyle))
                    {
/*						Connect to Saved Server	*/
                        networkManager.AttemptConnection(savedServer.ipaddress, savedServer.port);
                    }

                    if (GUILayout.Button("Delete", buttonCenterMediumStyle, GUILayout.Width(100)))
                    {
                        debugLog.ReceiveMessage("\nDeleting Server " + savedServer.name + " (" + savedServer.index + ")");
                        externalInformation.RemoveSavedServer(savedServer.index);
                    }
                    GUILayout.EndHorizontal();
                }
            }
        }

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