/// <summary>
    /// Uses property data to setup the controller view
    /// </summary>
    /// <param name="propertyData"></param>
    public virtual void Setup(LobbyPropertyData propertyData)
    {
        Lobby = Lobby ?? GetComponentInParent <LobbyUi>();

        RawData    = propertyData;
        Label.text = propertyData.Label;

        Dropdown.ClearOptions();

        Dropdown.AddOptions(propertyData.Options);
    }
Exemple #2
0
        public void AddControl(LobbyPropertyData propertyData)
        {
            var defaultValue = "";

            if (propertyData.Options != null && propertyData.Options.Count > 0)
            {
                defaultValue = propertyData.Options.First();
            }

            SetProperty(propertyData.PropertyKey, defaultValue);
            Controls.Add(propertyData);
        }
Exemple #3
0
        public static LobbyBuilder CreateLobbyBuilder(StringReader reader)
        {
            var config = reader.ReadToEnd();

            return((plugin, properties, creator) =>
            {
                Lobby result = null;

                var xmlReader = new XmlParser(config);

                var teams = new List <LobbyTeam>();
                xmlReader.SearchEach("Team", () =>
                {
                    teams.Add(new LobbyTeam(xmlReader["Name"])
                    {
                        MinPlayers = Convert.ToInt32(xmlReader["MinPlayers"]),
                        MaxPlayers = Convert.ToInt32(xmlReader["MaxPlayers"])
                    });
                });

                xmlReader = new XmlParser(config);
                xmlReader.Search("Lobby", () =>
                {
                    result = new Lobby(plugin.GenerateLobbyId(), teams, plugin)
                    {
                        DisplayName = xmlReader["DisplayName"],
                        Autostart = Convert.ToBoolean(xmlReader["Autostart"]),
                        AllowJoiningWhenGameIsLive = Convert.ToBoolean(xmlReader["AllowJoiningWhenGameIsLive"]),
                        AllowPlayersChangeLobbyProperties =
                            Convert.ToBoolean(xmlReader["AllowPlayersChangeLobbyProperties"]),
                        KeepAliveWithZeroPlayers = Convert.ToBoolean(xmlReader["KeepAliveWithZeroPlayers"]),
                        EnableGameMasters = Convert.ToBoolean(xmlReader["EnableGameMasters"]),
                        EnableManualStart = Convert.ToBoolean(xmlReader["EnableManualStart"]),
                        EnableReadySystem = Convert.ToBoolean(xmlReader["EnableReadySystem"]),
                        EnableTeamSwitching = Convert.ToBoolean(xmlReader["EnableTeamSwitching"]),
                        PlayAgainEnabled = Convert.ToBoolean(xmlReader["PlayAgainEnabled"]),
                        StartGameWhenAllReady = Convert.ToBoolean(xmlReader["StartGameWhenAllReady"]),
                        Name = properties.ExtractLobbyName()
                    };
                });

                xmlReader = new XmlParser(config);
                xmlReader.SearchEach("Control", () =>
                {
                    var defaultValue = "";
                    var control = new LobbyPropertyData
                    {
                        PropertyKey = xmlReader["Key"],
                        Label = xmlReader["Label"],
                        Options = new List <string>()
                    };
                    xmlReader.SearchEach("Controloption", () =>
                    {
                        var value = xmlReader["Value"];
                        if (xmlReader["IsDefault"] != null)
                        {
                            defaultValue = value;
                        }
                        control.Options.Add(value);
                    });
                    result.AddControl(control, defaultValue);
                });


                if (result.Autostart)
                {
                    result.StartAutomation();
                }

                return result;
            });
        }
Exemple #4
0
 public void AddControl(LobbyPropertyData propertyData, string defaultValue)
 {
     SetProperty(propertyData.PropertyKey, defaultValue);
     Controls.Add(propertyData);
 }