Ejemplo n.º 1
0
        void ApplyTabGeneral()
        {
            tServerName.Text = ConfigKey.ServerName.GetString();
            tMOTD.Text       = ConfigKey.MOTD.GetString();

            nMaxPlayers.Value = ConfigKey.MaxPlayers.GetInt();
            CheckMaxPlayersPerWorldValue();
            nMaxPlayersPerWorld.Value = ConfigKey.MaxPlayersPerWorld.GetInt();

            FillRankList(cDefaultRank, "(lowest rank)");
            if (ConfigKey.DefaultRank.IsBlank())
            {
                cDefaultRank.SelectedIndex = 0;
            }
            else
            {
                cDefaultRank.SelectedIndex = RankManager.GetIndex(RankManager.ParseRank(ConfigKey.DefaultRank.GetString()));
            }

            cPublic.SelectedIndex  = ConfigKey.IsPublic.GetBool() ? 0 : 1;
            nPort.Value            = ConfigKey.Port.GetInt();
            nUploadBandwidth.Value = ConfigKey.UploadBandwidth.GetInt();

            xAnnouncements.Checked = (ConfigKey.AnnouncementInterval.GetInt() > 0);
            nAnnouncements.Value   = ConfigKey.AnnouncementInterval.GetInt();

            // UpdaterSettingsWindow
            updaterWindow.BackupBeforeUpdate = ConfigKey.BackupBeforeUpdate.GetBool();
            updaterWindow.RunBeforeUpdate    = ConfigKey.RunBeforeUpdate.GetString();
            updaterWindow.RunAfterUpdate     = ConfigKey.RunAfterUpdate.GetString();
            updaterWindow.UpdaterMode        = ConfigKey.UpdaterMode.GetEnum <UpdaterMode>();
        }
Ejemplo n.º 2
0
 public ConditionPreviousRank(XElement el)
 {
     if (el == null)
     {
         throw new ArgumentNullException("el");
     }
     Rank       = RankManager.ParseRank(el.Attribute("val").Value);
     Comparison = (ComparisonOperation)Enum.Parse(typeof(ComparisonOperation), el.Attribute("op").Value, true);
 }
Ejemplo n.º 3
0
        void ApplyTabWorlds()
        {
            if (rankNameList == null)
            {
                rankNameList = new BindingList <string>();
                rankNameList.Add(WorldListEntry.DefaultRankOption);
                foreach (Rank rank in RankManager.Ranks)
                {
                    rankNameList.Add(rank.ToComboBoxOption());
                }
                dgvcAccess.DataSource = rankNameList;
                dgvcBuild.DataSource  = rankNameList;
                dgvcBackup.DataSource = World.BackupEnum;

                LoadWorldList();
                dgvWorlds.DataSource = worlds;
            }
            else
            {
                //dgvWorlds.DataSource = null;
                rankNameList.Clear();
                rankNameList.Add(WorldListEntry.DefaultRankOption);
                foreach (Rank rank in RankManager.Ranks)
                {
                    rankNameList.Add(rank.ToComboBoxOption());
                }
                foreach (WorldListEntry world in worlds)
                {
                    world.ReparseRanks();
                }
                worlds.ResetBindings();
                //dgvWorlds.DataSource = worlds;
            }

            FillRankList(cDefaultBuildRank, "(lowest rank)");
            if (ConfigKey.DefaultBuildRank.IsBlank())
            {
                cDefaultBuildRank.SelectedIndex = 0;
            }
            else
            {
                cDefaultBuildRank.SelectedIndex = RankManager.GetIndex(RankManager.ParseRank(ConfigKey.DefaultBuildRank.GetString()));
            }

            if (Paths.IsDefaultMapPath(Config.GetString(ConfigKey.MapPath)))
            {
                tMapPath.Text    = Paths.MapPathDefault;
                xMapPath.Checked = false;
            }
            else
            {
                tMapPath.Text    = Config.GetString(ConfigKey.MapPath);
                xMapPath.Checked = true;
            }
        }
Ejemplo n.º 4
0
        void ApplyTabSecurity()
        {
            ApplyEnum(cVerifyNames, ConfigKey.VerifyNames, NameVerificationMode.Balanced);

            nMaxConnectionsPerIP.Value   = ConfigKey.MaxConnectionsPerIP.GetInt();
            xMaxConnectionsPerIP.Checked = (nMaxConnectionsPerIP.Value > 0);
            xAllowUnverifiedLAN.Checked  = ConfigKey.AllowUnverifiedLAN.GetBool();

            nAntispamMessageCount.Value = ConfigKey.AntispamMessageCount.GetInt();
            nAntispamInterval.Value     = ConfigKey.AntispamInterval.GetInt();
            nSpamMute.Value             = ConfigKey.AntispamMuteDuration.GetInt();

            xAntispamKicks.Checked     = (ConfigKey.AntispamMaxWarnings.GetInt() > 0);
            nAntispamMaxWarnings.Value = ConfigKey.AntispamMaxWarnings.GetInt();
            if (!xAntispamKicks.Checked)
            {
                nAntispamMaxWarnings.Enabled = false;
            }

            xRequireKickReason.Checked         = ConfigKey.RequireKickReason.GetBool();
            xRequireBanReason.Checked          = ConfigKey.RequireBanReason.GetBool();
            xRequireRankChangeReason.Checked   = ConfigKey.RequireRankChangeReason.GetBool();
            xAnnounceKickAndBanReasons.Checked = ConfigKey.AnnounceKickAndBanReasons.GetBool();
            xAnnounceRankChanges.Checked       = ConfigKey.AnnounceRankChanges.GetBool();
            xAnnounceRankChangeReasons.Checked = ConfigKey.AnnounceRankChangeReasons.GetBool();
            xAnnounceRankChangeReasons.Enabled = xAnnounceRankChanges.Checked;

            FillRankList(cPatrolledRank, "(lowest rank)");
            if (ConfigKey.PatrolledRank.IsBlank())
            {
                cPatrolledRank.SelectedIndex = 0;
            }
            else
            {
                cPatrolledRank.SelectedIndex = RankManager.GetIndex(RankManager.ParseRank(ConfigKey.PatrolledRank.GetString()));
            }

            xPaidPlayersOnly.Checked = ConfigKey.PaidPlayersOnly.GetBool();
        }
Ejemplo n.º 5
0
        public Criterion(XElement el)
        {
            if (el == null)
            {
                throw new ArgumentNullException("el");
            }
            Type = (CriterionType)Enum.Parse(typeof(CriterionType), el.Attribute("type").Value, true);

            FromRank = RankManager.ParseRank(el.Attribute("fromRank").Value);
            if (FromRank == null)
            {
                throw new FormatException("Could not parse \"fromRank\"");
            }

            ToRank = RankManager.ParseRank(el.Attribute("toRank").Value);
            if (ToRank == null)
            {
                throw new FormatException("Could not parse \"toRank\"");
            }

            if (el.Elements().Count() == 1)
            {
                Condition = Condition.Parse(el.Elements().First());
            }
            else if (el.Elements().Count() > 1)
            {
                ConditionAND cand = new ConditionAND();
                foreach (XElement cond in el.Elements())
                {
                    cand.Add(Condition.Parse(cond));
                }
                Condition = cand;
            }
            else
            {
                throw new FormatException("At least one condition required.");
            }
        }
Ejemplo n.º 6
0
        public WorldListEntry(XElement el)
        {
            XAttribute temp;

            if ((temp = el.Attribute("name")) == null)
            {
                throw new FormatException("WorldListEntity: Cannot parse XML: Unnamed worlds are not allowed.");
            }
            if (!World.IsValidName(temp.Value))
            {
                throw new FormatException("WorldListEntity: Cannot parse XML: Invalid world name skipped \"" + temp.Value + "\".");
            }
            name = temp.Value;

            if ((temp = el.Attribute("hidden")) != null && !String.IsNullOrEmpty(temp.Value))
            {
                bool hidden;
                if (Boolean.TryParse(temp.Value, out hidden))
                {
                    Hidden = hidden;
                }
                else
                {
                    throw new FormatException("WorldListEntity: Cannot parse XML: Invalid value for \"hidden\" attribute.");
                }
            }
            else
            {
                Hidden = false;
            }

            if ((temp = el.Attribute("backup")) != null && !String.IsNullOrEmpty(temp.Value))        // TODO: Make per-world backup settings actually work
            {
                if (Array.IndexOf(World.BackupEnum, temp.Value) != -1)
                {
                    Backup = temp.Value;
                }
                else
                {
                    throw new FormatException("WorldListEntity: Cannot parse XML: Invalid value for \"backup\" attribute.");
                }
            }
            else
            {
                Backup = World.BackupEnum[5];
            }

            if (el.Element("accessSecurity") != null)
            {
                accessSecurity = new SecurityController(el.Element("accessSecurity"));
            }
            else if ((temp = el.Attribute("access")) != null && !String.IsNullOrEmpty(temp.Value))
            {
                accessSecurity.MinRank = RankManager.ParseRank(temp.Value);
            }

            if (el.Element("buildSecurity") != null)
            {
                buildSecurity = new SecurityController(el.Element("buildSecurity"));
            }
            else if ((temp = el.Attribute("build")) != null && !String.IsNullOrEmpty(temp.Value))
            {
                buildSecurity.MinRank = RankManager.ParseRank(temp.Value);
            }
        }
Ejemplo n.º 7
0
 public void ReparseRanks()
 {
     accessSecurity.MinRank = RankManager.ParseRank(accessRankString);
     buildSecurity.MinRank  = RankManager.ParseRank(buildRankString);
 }