Beispiel #1
0
        public void GetNewSettings()
        {
            try
            {
                WebClient myClient = new WebClient();
                List <PatcherSettings> webSettingsList =
                    JsonConvert.DeserializeObject <List <PatcherSettings> >(
                        myClient.DownloadString("http://ww1.openmeridian.org/settings.txt"));          //Download the settings from the web, store them in a list.

                foreach (PatcherSettings currentSettings in Servers)                                   //Loop through loaded settings from settings.txt
                {
                    PatcherSettings temp = webSettingsList.First(i => i.Guid == currentSettings.Guid); //Find the server loaded settings that match the local profile by Guid
                    if (temp != null)                                                                  //If null, we have profiles to add from the remote server
                    {
                        if (currentSettings.PatchBaseUrl != temp.PatchBaseUrl ||
                            currentSettings.PatchInfoUrl != temp.PatchInfoUrl ||
                            currentSettings.ServerName != temp.ServerName)    //If different
                        {
                            currentSettings.PatchBaseUrl = temp.PatchBaseUrl; //Update the server-side settings only
                            currentSettings.PatchInfoUrl = temp.PatchInfoUrl;
                            currentSettings.ServerName   = temp.ServerName;
                        }
                        //Todo: add the new profilses from the server
                    }
                }
            }
            catch (Exception e)
            {
                throw new InvalidOperationException("Unable to download settings from server." + e);
            }
        }
        private void btnStartModify_Click(object sender, EventArgs e)
        {
            groupProfileSettings.Enabled = true;
            PatcherSettings ps = _settings.FindByName(ddlServer.SelectedItem.ToString());

            txtClientFolder.Text    = ps.ClientFolder;
            txtPatchBaseURL.Text    = ps.PatchBaseUrl;
            txtPatchInfoURL.Text    = ps.PatchInfoUrl;
            txtServerName.Text      = ps.ServerName;
            cbDefaultServer.Checked = ps.Default;
            _changetype             = ChangeType.ModProfile;
        }
Beispiel #3
0
        //used when adding from form
        public void AddProfile(string clientfolder, string patchbaseurl, string patchinfourl, string servername, bool isdefault)
        {
            PatcherSettings ps = new PatcherSettings();
            ps.ClientFolder = clientfolder;
            ps.PatchBaseUrl = patchbaseurl;
            ps.PatchInfoUrl = patchinfourl;
            ps.ServerName = servername;
            ps.Default = isdefault;

            Servers.Add(ps);
            SaveSettings();
            LoadSettings();
        }
Beispiel #4
0
        //used when adding from form
        public void AddProfile(string clientfolder, string patchbaseurl, string patchinfourl, string servername, bool isdefault)
        {
            PatcherSettings ps = new PatcherSettings();

            ps.ClientFolder = clientfolder;
            ps.PatchBaseUrl = patchbaseurl;
            ps.PatchInfoUrl = patchinfourl;
            ps.ServerName   = servername;
            ps.Default      = isdefault;

            Servers.Add(ps);
            SaveSettings();
            LoadSettings();
        }
        //used when adding from form
        public void AddProfile(string clientfolder, string patchbaseurl, string patchinfourl, string servername, bool isdefault)
        {
            var ps = new PatcherSettings
            {
                ClientFolder = clientfolder,
                PatchBaseUrl = patchbaseurl,
                PatchInfoUrl = patchinfourl,
                ServerName   = servername,
                Default      = isdefault
            };

            Servers.Add(ps);
            SaveSettings();
            LoadSettings();
        }
        //used when adding from form
        public void AddProfile(string clientfolder, string patchbaseurl, string patchinfourl, string servername, bool isdefault)
        {
            var ps = new PatcherSettings
            {
                ClientFolder = clientfolder,
                PatchBaseUrl = patchbaseurl,
                PatchInfoUrl = patchinfourl,
                ServerName = servername,
                Default = isdefault
            };

            Servers.Add(ps);
            SaveSettings();
            LoadSettings();
        }
        private void ddlServer_SelectionChangeCommitted(object sender, EventArgs e)
        {
            //lblStatus.Text = ddlServer.SelectedItem.ToString();
            PatcherSettings selected = _settings.FindByName(ddlServer.SelectedItem.ToString());

            if (selected == null)
            {
                return;
            }
            _patcher.CurrentProfile = selected;
            txtLog.Text            += String.Format("Server {0} selected. Client located at: {1}\r\n", selected.ServerName, selected.ClientFolder);
            btnPlay.Enabled         = false;

            if (groupProfileSettings.Enabled != true)
            {
                return;
            }
            groupProfileSettings.Enabled = false;
            txtClientFolder.Text         = "";
            txtPatchBaseURL.Text         = "";
            txtPatchInfoURL.Text         = "";
            txtServerName.Text           = "";
            cbDefaultServer.Checked      = false;
        }
        /// <summary>
        /// Load the type of client patcher we need for scanning the given profile.
        /// </summary>
        private ClientPatcher GetClientPatcher(PatcherSettings ps, ClientPatcher oldPatcher)
        {
            // If a patcher already exists, remove the event handlers.
            if (oldPatcher != null)
            {
                oldPatcher.FileScanned -= Patcher_FileScanned;
                oldPatcher.StartedDownload -= Patcher_StartedDownload;
                oldPatcher.ProgressedDownload -= Patcher_ProgressedDownload;
                oldPatcher.EndedDownload -= Patcher_EndedDownload;
                oldPatcher.FailedDownload -= Patcher_FailedDownload;
                oldPatcher.StartedUnzip -= Patcher_StartedUnzip;
                oldPatcher.ProgressedUnzip -= Patcher_ProgressedUnzip;
                oldPatcher.EndedUnzip -= Patcher_EndedUnzip;
                oldPatcher.FailedDependency -= Patcher_FailedDependency;
            }

            ClientPatcher newPatcher;
            if (ps.ClientType == ClientType.DotNet)
                newPatcher = new OgreClientPatcher(ps);
            else
                newPatcher = new ClassicClientPatcher(ps);

            // Add event handlers.
            newPatcher.FileScanned += Patcher_FileScanned;
            newPatcher.StartedDownload += Patcher_StartedDownload;
            newPatcher.ProgressedDownload += Patcher_ProgressedDownload;
            newPatcher.EndedDownload += Patcher_EndedDownload;
            newPatcher.FailedDownload += Patcher_FailedDownload;
            newPatcher.StartedUnzip += Patcher_StartedUnzip;
            newPatcher.ProgressedUnzip += Patcher_ProgressedUnzip;
            newPatcher.EndedUnzip += Patcher_EndedUnzip;
            newPatcher.FailedDependency += Patcher_FailedDependency;

            return newPatcher;
        }
Beispiel #9
0
 public void AddProfile(PatcherSettings newprofile)
 {
     Servers.Add(newprofile);
     SaveSettings();
     LoadSettings();
 }
 /// <summary>
 /// Display create account text for the current profile.
 /// </summary>
 private void SetCreateAccountText(PatcherSettings ps)
 {
     btnCreateAccount.Text = String.Format("Create Account for {0}", ps.ServerNumber);
 }
 public OgreClientPatcher(PatcherSettings settings)
     : base(settings)
 {
 }
        /// <summary>
        /// Add a profile to the Servers list, used by the add form.
        /// </summary>
        public void AddProfile(string clientfolder, string patchbaseurl, string patchinfourl,
                               string fullinstallurl, string servername, int servernumber,
                               bool isdefault = false, ClientType clientType = ClientType.Classic)
        {
            var ps = new PatcherSettings
            {
                ClientFolder = clientfolder,
                PatchBaseUrl = patchbaseurl,
                PatchInfoUrl = patchinfourl,
                FullInstallUrl = fullinstallurl,
                ServerName = servername,
                ServerNumber = servernumber,
                Default = isdefault,
                ClientType = clientType,
                Enabled = true,
                SaveProfile = true,
                DeleteProfile = false
            };

            if (isdefault)
            {
                foreach (PatcherSettings patcherSettingse in Servers.FindAll(s => s.Default))
                {
                    patcherSettingse.Default = false;
                }
            }
            Servers.Add(ps);
            SaveSettings();
            LoadSettings();
        }
 /// <summary>
 /// Fills out the Options tab data fields when a new profile is selected.
 /// </summary>
 private void SetProfileDataFields(PatcherSettings profile)
 {
     if (profile == null)
     {
         txtClientFolder.Text = "";
         txtPatchBaseURL.Text = "";
         txtPatchInfoURL.Text = "";
         txtFullInstallURL.Text = "";
         txtServerName.Text = "";
         txtServerNumber.Text = "0";
     }
     else
     {
         txtClientFolder.Text = profile.ClientFolder;
         txtPatchBaseURL.Text = profile.PatchBaseUrl;
         txtPatchInfoURL.Text = profile.PatchInfoUrl;
         txtFullInstallURL.Text = profile.FullInstallUrl;
         txtServerName.Text = profile.ServerName;
         txtServerNumber.Text = profile.ServerNumber.ToString();
         cbDefaultServer.Checked = profile.Default;
     }
 }
 public void AddProfile(PatcherSettings newprofile)
 {
     Servers.Add(newprofile);
     SaveSettings();
     LoadSettings();
 }
Beispiel #15
0
 public ClientPatcher(PatcherSettings settings)
 {
     LocalFiles     = new List <ManagedFile>();
     MyWebClient    = new WebClient();
     CurrentProfile = settings;
 }
 /// <summary>
 /// Update a local profile data fields from a web profile.
 /// Does not update path or Guid.
 /// </summary>
 private void UpdateProfile(PatcherSettings localProfile, PatcherSettings webProfile)
 {
     localProfile.ClientType = webProfile.ClientType;
     localProfile.PatchBaseUrl = webProfile.PatchBaseUrl;
     localProfile.PatchInfoUrl = webProfile.PatchInfoUrl;
     localProfile.ServerName = webProfile.ServerName;
     localProfile.ServerNumber = webProfile.ServerNumber;
     localProfile.FullInstallUrl = webProfile.FullInstallUrl;
     localProfile.AccountCreationUrl = webProfile.AccountCreationUrl;
     localProfile.Enabled = webProfile.Enabled;
     localProfile.SaveProfile = webProfile.SaveProfile;
     localProfile.DeleteProfile = webProfile.DeleteProfile;
 }
 /// <summary>
 /// Add a profile to the Servers list.
 /// </summary>
 public void AddProfile(PatcherSettings newprofile)
 {
     if (newprofile.Default)
     {
         foreach (PatcherSettings patcherSettingse in Servers.FindAll(s => s.Default))
         {
             patcherSettingse.Default = false;
         }
     }
     Servers.Add(newprofile);
     SaveSettings();
     LoadSettings();
 }
Beispiel #18
0
 public ClientPatcher(PatcherSettings settings)
 {
     downloadFiles = new List<ManagedFile>();
     MyWebClient = new WebClient();
     CurrentProfile = settings;
 }
 public ClassicClientPatcher(PatcherSettings settings)
     : base(settings)
 {
 }
 public ClientPatcher(PatcherSettings settings)
 {
     _downloadFileFailed = false;
     downloadFiles = new List<ManagedFile>();
     MyWebClient = new WebClient();
     MyWebClient.Headers.Add("user-agent", UserAgentString);
     CurrentProfile = settings;
 }
        /// <summary>
        /// Selected a new profile.
        /// </summary>
        private void SetPatcherProfile(PatcherSettings profile)
        {
            // Don't set to null profile.
            if (profile == null)
                return;

            // In case we clicked out from Add Profile.
            if (_changetype == ChangeType.AddProfile)
            {
                _changetype = ChangeType.None;
                groupProfileSettings.Enabled = false;
            }

            if (_patcher.CurrentProfile.ClientType != profile.ClientType)
                _patcher = GetClientPatcher(profile, _patcher);
            else
                _patcher.CurrentProfile = profile;

            txtLog.Text += String.Format("Server {0} selected. Client located at: {1}\r\n",
                            profile.ServerName, profile.ClientFolder);
            btnPlay.Enabled = false;

            // Set create account text.
            SetCreateAccountText(_patcher.CurrentProfile);
            _creatingAccount = false;

            //if (groupProfileSettings.Enabled != true) return;
            //groupProfileSettings.Enabled = false;
            // Set the Options tab data fields to the current selection.
            SetProfileDataFields(profile);
        }