Beispiel #1
0
    void UpdateHostLine(int index, uLink.HostData data)
    {
        if (PlayerControlsDrone.Enabled)
        {
            if (!isConnectingToServer || failedToConnectToServer)
            {
                if (uLink.Network.status != uLink.NetworkStatus.Connected && uLink.Network.status != uLink.NetworkStatus.Connecting)
                {
                    if (data.externalIP == PlayerControlsDrone.DesiredIP)
                    {
                        ConnectToServer(data);
                    }
                }
            }
        }

        if (index < 0 || index >= linesGui.Length)
        {
            return;
        }

        //Debug.Log("UpdateServerLine " + index);
        ServerLineGui line = linesGui[index];

        if (line != null)
        {
            if (!line.button.Widget.IsVisible())
            {
                ShowServerLine(index);
            }

            //We have no server name but ip:port is a good identifier and a very usefull information
            line.labelServerName.SetNewText(data.ipAddress + ":" + data.port);

            //IP
            line.labelMapName.SetNewText(data.gameName);
            line.labelMode.SetNewText(data.gameMode);

            //Show ping times only for game server hosts found via the master server, not LAN servers. LAN server ping times might have a bug in uLink.
            if (m_ServerListType == E_ServerListType.Lobby)
            {
                //Prints the ping to the master server, not the actual game server. This is OK as long as the
                //game servers and the master server is hosted in the same datacenter.
                //TODO: remove this GUI column from the list of game servers and put the ping value on top of the screen
                //becuse the ping value will be identiacal for all game servers in the same data center
                line.labelPing.SetNewText(((int)(uLink.MasterServer.ping * 1000)).ToString());
            }
            else
            {
                line.labelPing.Clear();
            }
            line.labelPlayers.SetNewText(data.connectedPlayers.ToString());

            line.hostData = data;
        }
    }
Beispiel #2
0
    void HighlightLine(int index, bool on)
    {
        if (index < 0 || index >= linesGui.Length)
        {
            return;
        }

        ServerLineGui line = linesGui[index];

        if (line.button.Widget.IsVisible())
        {
            line.button.ForceHighlight(on);
        }
    }
Beispiel #3
0
    void ShowServerLine(int index)
    {
        ServerLineGui line = linesGui[index];

        //Debug.Log("Hiding line " + index + " " + line);
        if (line != null)
        {
            line.button.Widget.Show(true, true);
            line.labelMapName.Widget.Show(true, true);
            line.labelMode.Widget.Show(true, true);
            line.labelPing.Widget.Show(true, true);
            line.labelPlayers.Widget.Show(true, true);
            line.labelServerName.Widget.Show(true, true);
        }
    }
Beispiel #4
0
    void UpdateScreenList(uLink.HostData[] hostData)
    {
        int index = 0;

        foreach (uLink.HostData data in hostData)
        {
            if (IsLocalHost(data))
            {
                UpdateHostLine(index, data);
                index++;
            }
        }

        foreach (uLink.HostData data in hostData)
        {
            if (!IsLocalHost(data))
            {
                UpdateHostLine(index, data);
                index++;
            }
        }

        //pokd jeste neni vybrany radek (nebo je mimo zobrazeny rozsah), vyber prvni radek
        if ((mSelectedIndex == -1 || mSelectedIndex >= index) && index > 0)
        {
            //but only when widget is already visible
            int           hg   = 0;
            ServerLineGui line = linesGui[hg];
            if (line.button.Widget.IsVisible())
            {
                SelectServerLine(hg);
            }
        }
        else if (index == 0)
        {
            SelectServerLine(-1);
        }

        //skryj zbytek nevyuzitych radku
        for (int i = index; i < maxLines; i++)
        {
            HideServerLine(i);
        }
    }
Beispiel #5
0
    void UpdateLobby()
    {
        //uLink.HostData[] hostData = uLink.MasterServer.PollHostList(hostFilter, masterServerRefreshHostListIntervalSec);
        // UpdateScreenList(lobbyHostData);

        if (LobbyClient.IsConnected)
        {
            int index = 0;

            List <LobbyClient.Server> Servers = LobbyClient.GetServers();

            foreach (LobbyClient.Server Server in Servers)
            {
                UpdateHostLine(index, Server);
                index++;
            }

            //pokd jeste neni vybrany radek (nebo je mimo zobrazeny rozsah), vyber prvni radek
            if ((mSelectedIndex == -1 || mSelectedIndex >= index) && index > 0)
            {
                //but only when widget is already visible
                int hg = 0;

                ServerLineGui line = linesGui[hg];

                if (line.button.Widget.IsVisible())
                {
                    SelectServerLine(hg);
                }
            }
            else if (index == 0)
            {
                SelectServerLine(-1);
            }

            //skryj zbytek nevyuzitych radku
            for (int i = index; i < maxLines; i++)
            {
                HideServerLine(i);
            }
        }
    }
Beispiel #6
0
    void UpdateHostLine(int index, LobbyClient.Server Server)
    {
        if (index < 0 || index >= linesGui.Length)
        {
            return;
        }

        //Debug.Log("UpdateServerLine " + index);
        ServerLineGui line = linesGui[index];

        if (line != null)
        {
            if (!line.button.Widget.IsVisible())
            {
                ShowServerLine(index);
            }

            //Game Name
            line.labelServerName.SetNewText(Server.Name);


            line.labelMapName.SetNewText(Server.IPName);

            line.labelPing.Clear();
            //Show ping times only for game server hosts found via the master server, not LAN servers. LAN server ping times might have a bug in uLink.

            /*if (m_ServerListType == E_ServerListType.Lobby)
             * {
             *      //Prints the ping to the master server, not the actual game server. This is OK as long as the
             *      //game servers and the master server is hosted in the same datacenter.
             *      //TODO: remove this GUI column from the list of game servers and put the ping value on top of the screen
             *      //becuse the ping value will be identiacal for all game servers in the same data center
             *      //line.labelPing.SetNewText(((int)(uLink.MasterServer.ping * 1000)).ToString());
             * }*/
            line.labelPlayers.Clear();
            //line.labelPlayers.SetNewText(data.connectedPlayers.ToString());

            line.hostData = null;
            line.EndPoint = Server.EndPoint;
        }
    }
Beispiel #7
0
    void InitServerList()
    {
        //server line
        for (int i = 0; i < maxLines; i++)
        {
            string btnName = s_ServerLinePrefix + i;

            linesGui[i]        = new ServerLineGui();
            linesGui[i].button = GuiBaseUtils.RegisterButtonDelegate(m_ScreenLayout, btnName, selectDelegates[i], null);

            //Debug.Log("Register " +i + " " + btnName + " " + linesGui[i].button);

            //gui for server list lines
            GUIBase_Label[] labels = linesGui[i].button.Widget.GetComponentsInChildren <GUIBase_Label>();
            foreach (GUIBase_Label l in labels)
            {
                if (l.name == "Mapname_Label")
                {
                    linesGui[i].labelMapName = l;
                }
                if (l.name == "Mode_Label")
                {
                    linesGui[i].labelMode = l;
                }
                else if (l.name == "Ping_Label")
                {
                    linesGui[i].labelPing = l;
                }
                else if (l.name == "Players_Label")
                {
                    linesGui[i].labelPlayers = l;
                }
                else if (l.name == "Servermame_Label")
                {
                    linesGui[i].labelServerName = l;
                }

                l.Clear();
            }
        }
    }
Beispiel #8
0
    // #################################################################################################################
    // ###  Delegates  #################################################################################################

    void OnConnect(GUIBase_Widget inWidget)
    {
        if (mSelectedIndex == -1)
        {
            return;
        }

        //Debug.Log("Going to connect server on line " + mSelectedIndex);

        //UpadatePlayerProfile();
        ServerLineGui line = linesGui[mSelectedIndex];

        switch (m_ServerListType)
        {
        case E_ServerListType.Lan:
        {
            if (line.hostData != null)
            {
                ConnectToServer(line.hostData);
            }
        }
        break;

        case E_ServerListType.Lobby:
        {
            if (line.hostData != null)
            {
                ConnectToServer(line.hostData);
            }
            else
            {
                if (null != line.EndPoint)
                {
                    ConnectToServer(line.EndPoint);
                }
            }
        }
        break;
        }
    }