Exemple #1
0
 private static void ConvertBasic(Models._16Models.ServerProfile profile, ServerProfile newProfile, int i, int y, string label)
 {
     newProfile.BasicCfg = new FASTER.Models.BasicCfg();
     UpdateStatus(ref i, y, label);
     ulong.TryParse(profile.MaxBandwidth, out ulong maxBandwidth);
     newProfile.BasicCfg.MaxBandwidth = maxBandwidth;
     UpdateStatus(ref i, y, label);
     ushort.TryParse(profile.MaxCustomFileSize, out ushort maxCustomFileSize);
     newProfile.BasicCfg.MaxCustomFileSize = maxCustomFileSize;
     UpdateStatus(ref i, y, label);
     ushort.TryParse(profile.MaxMessagesSend, out ushort maxMsgSend);
     newProfile.BasicCfg.MaxMsgSend = maxMsgSend;
     UpdateStatus(ref i, y, label);
     ushort.TryParse(profile.MaxPacketSize, out ushort maxPacketSize);
     newProfile.BasicCfg.MaxPacketSize = maxPacketSize;
     UpdateStatus(ref i, y, label);
     ushort.TryParse(profile.MaxSizeGuaranteed, out ushort maxSizeGuaranteed);
     newProfile.BasicCfg.MaxSizeGuaranteed = maxSizeGuaranteed;
     UpdateStatus(ref i, y, label);
     ushort.TryParse(profile.MaxSizeNonguaranteed, out ushort maxSizeNonGuaranteed);
     newProfile.BasicCfg.MaxSizeNonGuaranteed = maxSizeNonGuaranteed;
     UpdateStatus(ref i, y, label);
     ulong.TryParse(profile.MinBandwidth, out ulong minBandwidth);
     newProfile.BasicCfg.MinBandwidth = minBandwidth;
     UpdateStatus(ref i, y, label);
     newProfile.BasicCfg.MinErrorToSend = double.Parse(profile.MinErrorToSend.Replace(',', '.'), NumberStyles.Any, CultureInfo.InvariantCulture);
     UpdateStatus(ref i, y, label);
     newProfile.BasicCfg.MinErrorToSendNear = double.Parse(profile.MinErrorToSendNear.Replace(',', '.'), NumberStyles.Any, CultureInfo.InvariantCulture);
     UpdateStatus(ref i, y, label);
 }
Exemple #2
0
        public static void AddServerProfile(ServerProfile newProfile)
        {
            var duplicate       = false;
            var currentProfiles = GetServerProfiles();

            if (currentProfiles.ServerProfiles.Count > 0)
            {
                foreach (var _ in currentProfiles.ServerProfiles
                         .Where(profile => profile.DisplayName == newProfile.DisplayName))
                {
                    duplicate = true;
                }
            }

            if (!duplicate)
            {
                currentProfiles.ServerProfiles.Add(newProfile);
                Properties.Settings.Default.Servers = currentProfiles;
                ServerProfile profile = Properties.Settings.Default.Servers.ServerProfiles.Find(findProfile => findProfile.SafeName == newProfile.SafeName);
                profile.ServerName = newProfile.ServerName;
                profile.Executable = Properties.Settings.Default.serverPath + @"\arma3server_x64.exe";
            }
            else
            {
                MainWindow.Instance.DisplayMessage("Profile Already Exists");
            }

            Properties.Settings.Default.Save();
            MainWindow.Instance.LoadServerProfiles();
        }
Exemple #3
0
        public static void AddServerProfile(string name, string safeName)
        {
            var duplicate       = false;
            var currentProfiles = GetServerProfiles();

            if (currentProfiles.ServerProfiles.Count > 0)
            {
                foreach (var profile in currentProfiles.ServerProfiles)
                {
                    if (profile.DisplayName == name)
                    {
                        duplicate = true;
                    }
                }
            }

            if (!duplicate)
            {
                currentProfiles.ServerProfiles.Add(new ServerProfile(name, safeName));
                Properties.Settings.Default.Servers = currentProfiles;
                ServerProfile profile = Properties.Settings.Default.Servers.ServerProfiles.Find(newProfile => newProfile.SafeName == safeName);
                profile.ServerName = name;
                profile.Executable = Properties.Settings.Default.serverPath + @"\arma3server_x64.exe";
            }
            else
            {
                MainWindow.Instance.IMessageDialog.IsOpen   = true;
                MainWindow.Instance.IMessageDialogText.Text = "Profile Already Exists";
            }

            Properties.Settings.Default.Save();
            MainWindow.Instance.LoadServerProfiles();
        }
Exemple #4
0
        public static bool RenameServerProfile(string oldName, string newName)
        {
            try
            {
                var currentProfiles = Properties.Settings.Default.Servers.ServerProfiles;

                ServerProfile currentProfile = currentProfiles.Find(profile => profile.DisplayName == oldName);

                currentProfile.DisplayName = newName;
                currentProfile.SafeName    = Functions.SafeName(newName);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"ServerConfig - An exception occurred:\n{ex.Message}", "Error");
                return(false);
            }
        }
        private void MenuItemClone_Click(object sender, RoutedEventArgs e)
        {
            if (IServerProfilesMenu.SelectedIndex == -1)
            {
                return;
            }
            var temp = Properties.Settings.Default.Servers.ServerProfiles.FirstOrDefault(s => s.SafeName == ((ListBoxItem)IServerProfilesMenu.SelectedItem).Name);

            if (temp == null)
            {
                Instance.IMessageDialog.IsOpen   = true;
                Instance.IMessageDialogText.Text = "Could not find the selected profile.";
                return;
            }
            Models.ServerProfile serverProfile = temp.CloneObjectSerializable();
            serverProfile.DisplayName += " 2";
            serverProfile.SafeName     = "_" + Functions.SafeName(serverProfile.DisplayName);
            ServerCollection.AddServerProfile(serverProfile);
        }
Exemple #6
0
        private static ServerProfile ConvertProfile(Models._16Models.ServerProfile profile)
        {
            int    i;
            int    y;
            string label;

            Console.WriteLine($"\t ┌─Converting profile {profile.DisplayName}...");
            i     = 0;
            y     = 8;
            label = "Setting base values";
            var newProfile = new ServerProfile();

            ConvertBaseValues(profile, i, y, label, newProfile);
            Console.Write("\r\t │ Setting base values\n");

            i     = 0;
            y     = 23;
            label = "Setting Arma3Profile";
            Console.Write("\t └─Setting Arma3Profile");
            ConvertArmaProfile(profile, newProfile, i, y, label);
            Console.Write("\r\t │ Setting Arma3Profile\n");

            i     = 0;
            y     = 10;
            label = "Setting Basic.cfg";
            Console.Write("\t └─Setting Basic.cfg");
            ConvertBasic(profile, newProfile, i, y, label);
            Console.Write("\r\t │ Setting Basic.cfg\n");


            i     = 0;
            y     = 25;
            label = "Setting Server.cfg";
            Console.Write("\t └─Setting Server.cfg");
            ConvertServer(profile, newProfile, i, y, label);
            Console.Write("\r\t │ Setting Server.cfg\n");

            Console.Write($"\t └─Done converting {profile.DisplayName} to {newProfile.Id}\n");
            return(newProfile);
        }
Exemple #7
0
 private static void ConvertBasic(Models._16Models.ServerProfile profile, ServerProfile newProfile, int i, int y, string label)
 {
     newProfile.BasicCfg = new FASTER.Models.BasicCfg();
     UpdateStatus(ref i, y, label);
     newProfile.BasicCfg.MaxBandwidth = ulong.Parse(profile.MaxBandwidth);
     UpdateStatus(ref i, y, label);
     newProfile.BasicCfg.MaxCustomFileSize = ushort.Parse(profile.MaxCustomFileSize);
     UpdateStatus(ref i, y, label);
     newProfile.BasicCfg.MaxMsgSend = ushort.Parse(profile.MaxMessagesSend);
     UpdateStatus(ref i, y, label);
     newProfile.BasicCfg.MaxPacketSize = ushort.Parse(profile.MaxPacketSize);
     UpdateStatus(ref i, y, label);
     newProfile.BasicCfg.MaxSizeGuaranteed = ushort.Parse(profile.MaxSizeGuaranteed);
     UpdateStatus(ref i, y, label);
     newProfile.BasicCfg.MaxSizeNonGuaranteed = ushort.Parse(profile.MaxSizeNonguaranteed);
     UpdateStatus(ref i, y, label);
     newProfile.BasicCfg.MinBandwidth = ulong.Parse(profile.MinBandwidth);
     UpdateStatus(ref i, y, label);
     newProfile.BasicCfg.MinErrorToSend = double.Parse(profile.MinErrorToSend);
     UpdateStatus(ref i, y, label);
     newProfile.BasicCfg.MinErrorToSendNear = double.Parse(profile.MinErrorToSendNear);
     UpdateStatus(ref i, y, label);
 }
Exemple #8
0
 private static void ConvertBaseValues(Models._16Models.ServerProfile profile, int i, int y, string label, ServerProfile newProfile)
 {
     UpdateStatus(ref i, y, label);
     newProfile.EnableHyperThreading = bool.Parse(profile.EnableHyperThreading);
     UpdateStatus(ref i, y, label);
     newProfile.Executable = profile.Executable;
     UpdateStatus(ref i, y, label);
     newProfile.HeadlessNumber = int.Parse(profile.NoOfHeadlessClients);
     UpdateStatus(ref i, y, label);
     newProfile.Id = $"_{Guid.NewGuid():N}";
     UpdateStatus(ref i, y, label);
     newProfile.Name = profile.DisplayName;
     UpdateStatus(ref i, y, label);
     newProfile.Port = int.Parse(profile.Port);
     UpdateStatus(ref i, y, label);
     newProfile.RankingChecked = bool.Parse(profile.RankingEnabled);
     UpdateStatus(ref i, y, label);
 }
Exemple #9
0
 private static void ConvertArmaProfile(Models._16Models.ServerProfile profile, ServerProfile newProfile, int i, int y, string label)
 {
     newProfile.ArmaProfile = new Arma3Profile();
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.AutoReport = profile.AutoReporting == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.CameraShake = profile.CameraShake == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.Commands = profile.Commands;
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.DetectedMines = profile.DetectedMines;
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.EnemyTags = profile.EnemyNameTags;
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.FriendlyTags = profile.FriendlyNameTags;
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.GroupIndicators = profile.GroupIndicators;
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.MapContentEnemy = profile.MapContentEnemy == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.MapContentFriendly = profile.MapContentFriendly == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.MapContentMines = profile.MapContentMines == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.MultipleSaves = profile.MultipleSaves == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.PrecisionAi = double.Parse(profile.AiAccuracy.Replace(',', '.'), NumberStyles.Any, CultureInfo.InvariantCulture);
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.ReducedDamage = profile.ReducedDamage == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.ScoreTable = profile.ScoreTable == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.SkillAi    = double.Parse(profile.AiSkill.Replace(',', '.'), NumberStyles.Any, CultureInfo.InvariantCulture);
     newProfile.ArmaProfile.StaminaBar = profile.StaminaBar == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.StanceIndicator = profile.StanceIndicator;
     newProfile.ArmaProfile.TacticalPing    = profile.TacticalPing == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.ThirdPersonView = profile.ThirdPerson == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.VisionAid = profile.VisualAids == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.VonID = profile.VonId == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.Waypoints = profile.Waypoints;
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.WeaponCrosshair = profile.Crosshair == "true"
         ? "Enabled"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ArmaProfile.WeaponInfo = profile.WeaponInfo;
     UpdateStatus(ref i, y, label);
 }
Exemple #10
0
 private static void ConvertServer(Models._16Models.ServerProfile profile, ServerProfile newProfile, int i, int y, string label)
 {
     newProfile.ServerCfg = new FASTER.Models.ServerCfg();
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.AllowedFilePatching = profile.AllowFilePatching == "0"
         ? "No Clients"
         : "All Clients";
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.AutoInit = bool.Parse(profile.AutoInit);
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.BattlEye = bool.Parse(profile.BattleEye);
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.CommandLineParameters = profile.ExtraParams;
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.Difficulty = profile.DifficultyPreset;
     UpdateStatus(ref i, y, label);
     int.TryParse(profile.DisconnectTimeout, out int disconnectTimeout);
     newProfile.ServerCfg.DisconnectTimeout = disconnectTimeout;
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.DoubleIdDetected = profile.DoubleIdDetected;
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.HeadlessClientEnabled = bool.Parse(profile.HeadlessClientEnabled);
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.Hostname = profile.ServerName;
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.Loopback = bool.Parse(profile.Loopback);
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.MaxMem = uint.Parse(string.IsNullOrEmpty(profile.MaxMem)
                                                  ? "1024"
                                                  : profile.MaxMem);
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.MaxPacketLoss = int.Parse(string.IsNullOrEmpty(profile.MaxPacketLoss)
                                                        ? "50"
                                                        : profile.MaxPacketLoss);
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.MaxPing = int.Parse(string.IsNullOrEmpty(profile.MaxPing)
                                                  ? "200"
                                                  : profile.MaxPing);
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.MaxPlayers = int.Parse(string.IsNullOrEmpty(profile.MaxPlayers)
                                                     ? "10"
                                                     : profile.MaxPlayers);
     UpdateStatus(ref i, y, label);
     int.TryParse(profile.MotdDelay, out int motdDelay);
     newProfile.ServerCfg.MotdInterval = motdDelay;
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.Password = profile.Password;
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.PasswordAdmin = profile.AdminPassword;
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.Upnp = bool.Parse(profile.Upnp);
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.OnDifferentData = profile.OnDifferentData;
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.OnHackedData = profile.OnHackedData;
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.OnUnsignedData = profile.OnUnsignedData;
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.OnUserConnected = profile.OnUserDisconnected;
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.VerifySignatures = profile.VerifySignatures == "true"
         ? "Activated"
         : "Disabled";
     UpdateStatus(ref i, y, label);
     newProfile.ServerCfg.VotingEnabled = bool.Parse(profile.VotingEnabled);
     UpdateStatus(ref i, y, label);
 }