x


GUI Layout problem

var data : HostData[] = MasterServer.PollHostList();
    // Go through all the hosts in the host list
    for (var element in data)
    {
        GUILayout.BeginHorizontal();    
        GUILayout.Space(20);
        var name = element.gameName + " " + element.connectedPlayers + " / " + element.playerLimit;
        GUILayout.Label(name);  
        GUILayout.Space(5);
        var hostInfo;
        hostInfo = "[";
        for (var host in element.ip)
            hostInfo = hostInfo + host + ":" + element.port + " ";
        hostInfo = hostInfo + "]";
        GUILayout.Label(hostInfo);  
        GUILayout.Space(5);
        GUILayout.Label(element.comment);
        GUILayout.Space(5);
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Connect"))
        {
            connectStatus="Connecting";
            // Set NAT functionality based on the host information
            Network.useNat=!Network.HavePublicAddress;
            if (Network.useNat)
                print("Using Nat punchthrough to connect to host");
            else
                print("Connecting directly to host");
            Network.Connect(element.ip, element.port);          
        }
        GUILayout.EndHorizontal();  
    }


GUI.Label(Rect(25,220,300,300),connectStatus);
if (GUI.Button (Rect (25,200,100,20), "Refresh List")) {
connectStatus="Refreshing";
//MasterServer.ClearHostList();
MasterServer.RequestHostList("StealthReduxCoop");

The problem with this code is that it shows only one server at a time, even if 2 or more servers are hosted. In the image below , 2 servers were hosted , Scout's server was hosted second. When the other server shut down and rehosted while scout's server was still running , it showed the other server.

http://img266.imageshack.us/img266/6794/gaemz.jpg

more ▼

asked Sep 12 '10 at 12:53 PM

YeOldeSnake 1 gravatar image

YeOldeSnake 1
205 11 12 19

The GUI code you've posted looks fine; if it is not drawing what you expect then the issue is with the data not being updated. I don't have much experience with the MasterServer, but my guess would be the commented out ClearHostList line.

Sep 12 '10 at 02:32 PM Molix
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Nevermind , it kind of fixed itself -.-

more ▼

answered Sep 12 '10 at 02:52 PM

YeOldeSnake 1 gravatar image

YeOldeSnake 1
205 11 12 19

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3686
x48
x3

asked: Sep 12 '10 at 12:53 PM

Seen: 869 times

Last Updated: Sep 12 '10 at 01:04 PM