Пример #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (Settings.Instance.RealmLists.ContainsKey(c_txtNewConfigName.Text) == true)
     {
         Utility.MessageBoxShow("Realm Config with this name already exist! Please change it to a unique name!");
     }
     else if (c_txtNewConfigName.Text == "Configuration Name" || c_txtNewConfigName.Text == "")
     {
         Utility.MessageBoxShow("Realm Config name was not valid. Please enter a name that will be used when choosing realm in the dropdown box in the Launcher!");
     }
     else if (c_txtNewRealmName.Text == "Exact Realm Name" || c_txtNewRealmName.Text == "")
     {
         Utility.MessageBoxShow("Realm Name was not valid. Please enter the correct name of the realm you want to connect to when using this realm configuration in the Launcher!");
     }
     else if (c_txtNewRealmListURL.Text == "Realmlist URL" || c_txtNewRealmListURL.Text == "")
     {
         Utility.MessageBoxShow("Realmlist URL was not valid. Please enter the correct realmlist URL of the realm you want to connect to when using this realm configuration in the Launcher!");
     }
     else
     {
         Settings.Instance.RealmLists.Add(c_txtNewRealmName.Text, new RealmInfo {
             RealmName = c_txtNewRealmName.Text, RealmList = c_txtNewRealmListURL.Text, WowVersion = (WowVersionEnum)Enum.Parse(typeof(WowVersionEnum), (string)c_cbxWowVersion.SelectedItem)
         });
         c_lstRealmConfigurations.Items.Add(c_txtNewRealmName.Text);
         c_lstRealmConfigurations.SelectedIndex = c_lstRealmConfigurations.Items.Count - 1;
         ResetNewRealmConfigInputs();
     }
 }
 private void c_btnChangeUserID_Click(object sender, EventArgs e)
 {
     if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == false)
     {
         SetupUserID.ShowSetupUserID();
         c_txtUserID.Text = Settings.UserID;
         if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == true)
         {
             c_cbContributeRealmPlayers.Enabled = true;
             c_cbContributeRealmPlayers.Checked = Settings.Instance.ContributeRealmPlayers;
             c_cbContributeRaidStats.Enabled    = true;
             c_cbContributeRaidStats.Checked    = Settings.Instance.ContributeRaidStats;
             c_cbxWait5Seconds.Enabled          = true;
             c_cbxWait5Seconds.Checked          = Settings.Instance.Wait5SecondsAfterUpload;
         }
     }
     else
     {
         var result = Utility.MessageBoxShow("Are you sure you want to change your UserID? A UserID is unique and should only be used by 1 person. There are very few reasons to ever change this UserID. Do you have a valid reason and are sure you want to change the UserID?", "Are you sure?", MessageBoxButtons.YesNo);
         if (result == System.Windows.Forms.DialogResult.Yes)
         {
             SetupUserID.ShowSetupUserID();
             c_txtUserID.Text = Settings.UserID;
         }
     }
 }
 private void c_btnTBCWowDirectoryBrowse_Click(object sender, EventArgs e)
 {
     VF.FolderSelectDialog folderSelectDialog = new VF.FolderSelectDialog();
     folderSelectDialog.Title            = "Please find the WoW The Burning Crusade Directory for me";
     folderSelectDialog.InitialDirectory = Settings.GetWowDirectory(WowVersionEnum.TBC);
     if (folderSelectDialog.ShowDialog() == true)
     {
         c_txtTBCWowDirectory.Text = folderSelectDialog.FileName;
         if (c_txtTBCWowDirectory.Text.EndsWith("\\") == false && c_txtTBCWowDirectory.Text.EndsWith("/") == false)
         {
             c_txtTBCWowDirectory.Text += "\\";
         }
         if (WowUtility.IsValidWowDirectory(c_txtTBCWowDirectory.Text) == false)
         {
             c_txtTBCWowDirectory.ForeColor = Color.Red;
             Utility.MessageBoxShow(c_txtTBCWowDirectory.Text + " is not a valid WoW The Burning Crusade Directory. \r\nPlease choose the correct directory where WoW TBC is installed.");
         }
         else
         {
             if (WowUtility.IsWowDirectoryTBC(c_txtTBCWowDirectory.Text) == true)
             {
                 c_txtTBCWowDirectory.ForeColor = Color.Black;
             }
             else
             {
                 c_txtTBCWowDirectory.ForeColor = Color.Red;
                 Utility.MessageBoxShow(c_txtTBCWowDirectory.Text + " is not a valid WoW The Burning Crusade Directory. \r\nPlease choose the correct directory where WoW TBC is installed.");
             }
         }
     }
 }
Пример #4
0
 private void c_btnCancel_Click(object sender, EventArgs e)
 {
     if (Utility.MessageBoxShow("If Wow Directory is not known the Launcher will not work. Are you sure you want to Cancel and close the application?", "", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
     {
         Close();
     }
 }
        private void c_btnCreate_Click(object sender, EventArgs e)
        {
            if (c_txtDescription.Text.Length < 20)
            {
                Utility.MessageBoxShow("Description must be atleast 20 characters long");
                return;
            }
            var addonName      = c_txtAddonFolder.Text.Split(new char[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries).Last();
            int addonNameIndex = c_txtAddonFolder.Text.LastIndexOf(addonName);

            string         addonRootFolder = c_txtAddonFolder.Text.Substring(0, addonNameIndex);
            SaveFileDialog saveFileDialog  = new SaveFileDialog();

            saveFileDialog.DefaultExt       = "zip";
            saveFileDialog.Filter           = "Zip files (*.zip)|*.zip|All files (*.*)|*.*";
            saveFileDialog.InitialDirectory = addonRootFolder;
            saveFileDialog.AddExtension     = true;
            saveFileDialog.FileName         = addonName + "Package_" + c_txtVersion.Text + ".zip";
            var dialogResult = saveFileDialog.ShowDialog();

            if (dialogResult == System.Windows.Forms.DialogResult.OK)
            {
                string addonPackageFilename = saveFileDialog.FileName;
                string descFile             = "\r\n#Version=" + c_txtVersion.Text;
                descFile += "\r\n#Description=" + c_txtDescription.Text.Replace("\r\n#", "\n#");
                descFile += "\r\n#UpdateSubmitter=" + Settings.UserID.Split('.').First();
                descFile += "\r\n#UpdateImportance=|DefaultImportance=" + (string)c_cbUpdateImportance.SelectedItem + "|";

                Utility.AssertFilePath(addonPackageFilename);

                ZipFile zipFile;
                if (System.IO.File.Exists(addonPackageFilename) == true)
                {
                    throw new Exception("The AddonPackage file already exists!");
                }

                zipFile = ZipFile.Create(addonPackageFilename);

                zipFile.BeginUpdate();

                zipFile.AddDirectoryFilesRecursive(addonRootFolder, c_txtAddonFolder.Text);

                //ZipEntry descEntry = new ZipEntry(addonName + "/VF_WowLauncher_AddonDescription.txt");
                //descEntry.DateTime = DateTime.Now;

                System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
                System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(memoryStream);
                streamWriter.Write(descFile);
                streamWriter.Flush();

                CustomStaticDataSource entryDataSource = new CustomStaticDataSource();
                entryDataSource.SetStream(memoryStream);

                zipFile.Add(entryDataSource, addonName + "/VF_WowLauncher_AddonDescription.txt");
                zipFile.CommitUpdate();
                zipFile.Close();
                Close();
            }
        }
 private void c_cbxEnableTBC_CheckedChanged(object sender, EventArgs e)
 {
     c_txtTBCWowDirectory.Enabled       = c_cbxEnableTBC.Checked;
     c_btnTBCWowDirectoryBrowse.Enabled = c_cbxEnableTBC.Checked;
     if (Settings.HaveTBC == false && c_cbxEnableTBC.Checked == true)
     {
         Utility.MessageBoxShow("Please note that this Launcher is originally made for WoW Classic and that some features may not work 100% for WoW TBC. \r\nPlease report any bugs and errors found on the forum at forum.realmplayers.com");
     }
 }
 private void c_cbxRunNotAdmin_CheckedChanged(object sender, EventArgs e)
 {
     if (Settings.Instance.RunWoWNotAdmin == false && c_cbxRunNotAdmin.Checked == true)
     {
         if (Utility.MessageBoxShow("Please note that this feature is only recommended if you have previously experienced issues running wow as admin\r\nAre you sure you want to use this feature?", "Are you sure?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
         {
             c_cbxRunNotAdmin.Checked = false;
         }
     }
 }
 private void c_cbContributeRealmPlayers_CheckedChanged(object sender, EventArgs e)
 {
     if (Settings.Instance.ContributeRealmPlayers == true && c_cbContributeRealmPlayers.Checked == false)
     {
         if (Utility.MessageBoxShow("Please note that without people contributing to RealmPlayers the Armory will not be able to stay up to date and the quality of the service will worsen.\r\nThe addon and uploading is very lightweight and should not affect your gameplay.\r\n\r\nAre you sure you do not want to contribute?", "Are you sure you do not want to contribute?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
         {
             c_cbContributeRealmPlayers.Checked = true;
         }
     }
 }
Пример #9
0
        private void c_btnReinstallAddon_Click(object sender, EventArgs e)
        {
            string addonName = (string)c_lbAddons.SelectedItem;

            if (Utility.MessageBoxShow("Reinstalling an addon means all the previous WTF/savedvariables data will be removed. Are you sure you want to reinstall the addon \"" + addonName + "\"?", "Are you sure?", MessageBoxButtons.YesNoCancel) == System.Windows.Forms.DialogResult.Yes)
            {
                string backupFile = InstalledAddons.BackupAddon(addonName, WowVersionEnum.Vanilla, AddonBackupMode.BackupWTF);
                InstalledAddons.ReinstallAddon(addonName, WowVersionEnum.Vanilla);
                Utility.MessageBoxShow("Addon \"" + addonName + "\" was successfully reinstalled!\r\n\r\nA backup zip file of the old WTF files was saved incase you regret the decision:\r\n" + StaticValues.LauncherWorkDirectory + "\\" + backupFile);
            }
        }
Пример #10
0
 private void c_btnSave_Click(object sender, EventArgs e)
 {
     if (c_ddlConfigProfiles.Text.Contains(' ') || c_ddlConfigProfiles.Text == "" || Utility.IsValidFilename(c_ddlConfigProfiles.Text) == false)
     {
         Utility.MessageBoxShow("\"" + c_ddlConfigProfiles.Text + "\" is not a valid profile name!");
         return;
     }
     ConfigProfiles.SaveConfigWTF(m_ConfigWTF, c_ddlConfigProfiles.Text);
     m_SavedProfile = true;
     Close();
 }
Пример #11
0
 private void c_btnSkip_Click(object sender, EventArgs e)
 {
     if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == false)
     {
         var dialogResult = Utility.MessageBoxShow("Skipping this step means contributions to realmplayers and raidstats wont work. However you can always setup UserID later in the menu File->Settings.\r\n\r\nAre you sure you want to skip configuring UserID?", "Skip configuring UserID?", MessageBoxButtons.YesNo);
         if (dialogResult == System.Windows.Forms.DialogResult.No)
         {
             return;
         }
     }
     Close();
 }
Пример #12
0
 private void c_btnSaveAllChanges_Click(object sender, EventArgs e)
 {
     if (m_AddonStatusChanges.Count > 0)
     {
         foreach (var addonChanges in m_AddonStatusChanges)
         {
             m_AddonsWTF.SetAddonStatus(addonChanges.Item1, addonChanges.Item2);
         }
         m_AddonsWTF.SaveAll();
         Utility.MessageBoxShow("Successfully saved " + m_AddonStatusChanges.Count + " changes to the Enabled/Disabled settings for various addons");
     }
     Close();
 }
        private void CreateAddonPackageForm_Load(object sender, EventArgs e)
        {
            Utility.SetPositionToMouse(this);

            c_cbUpdateImportance.Items.AddRange(Enum.GetNames(typeof(ServerComm.UpdateImportance)));
            c_cbUpdateImportance.SelectedItem = ServerComm.UpdateImportance.Good.ToString();

            //this.TopMost = true;
            if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == false)
            {
                Utility.MessageBoxShow("You must have a valid UserID to be able to create AddonPackages");
                Close();
            }
        }
Пример #14
0
        private void c_btnEnableAllAddons_Click(object sender, EventArgs e)
        {
            if (c_clbAddons.Items.Count >= 1)
            {
                if (Utility.MessageBoxShow("Are you sure you want to enable all addons for the character " + (string)c_lbCharacters.SelectedItem + "? This action can not be reversed. All previous settings will be forgotten.", "Enable all addons?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    string characterDir = Settings.GetWowDirectory(WowVersionEnum.Vanilla) + "WTF\\Account\\" + (string)c_lbAccounts.SelectedItem
                                          + "\\" + StaticValues.RealmNameConverter.First((_Value) => _Value.Value == (string)c_ddlRealm.SelectedItem).Key
                                          + "\\" + (string)c_lbCharacters.SelectedItem + "\\";

                    m_AddonsConfig.EnableAllAddons();

                    m_AddonsConfig.SaveConfigFile(characterDir + "AddOns.txt");
                }
            }
        }
Пример #15
0
        private void c_btnResetRealmLists_Click(object sender, EventArgs e)
        {
            var    defaultRealmLists = Settings.CreateDefaultRealmLists();
            string realmsListStr     = "";

            foreach (var realm in defaultRealmLists)
            {
                realmsListStr += realm.Key + ", ";
            }
            if (Utility.MessageBoxShow("This will reset all realmlists to default configuration. Which means the following realms will be available:\r\n"
                                       + realmsListStr + "\r\n\r\nAre you sure you want to reset?", "Are you sure you want to reset?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                Settings.Instance.RealmLists = defaultRealmLists;
                InitializeWindow();
            }
        }
Пример #16
0
        private void c_btnUninstallAddon_Click(object sender, EventArgs e)
        {
            string addonName = (string)c_lbAddons.SelectedItem;

            c_btnUninstallAddon.Enabled = false;
            if (c_lbNeededFor.Items.Count == 0)
            {
                if (Utility.MessageBoxShow("Are you sure you want to uninstall the addon \"" + addonName + "\"?", "Are you sure?", MessageBoxButtons.YesNoCancel) == System.Windows.Forms.DialogResult.Yes)
                {
                    string backupFile = InstalledAddons.BackupAddon(addonName, WowVersionEnum.Vanilla);
                    if (InstalledAddons.UninstallAddon(addonName, WowVersionEnum.Vanilla) == true)
                    {
                        Utility.MessageBoxShow("Addon \"" + addonName + "\" was successfully uninstalled!\r\n\r\nA backup zip file of the addon and WTF files was saved incase you regret the decision here:\r\n" + StaticValues.LauncherWorkDirectory + "\\" + backupFile);
                        c_lbAddons.SelectedIndex = 0;
                        c_lbAddons.Items.Remove(addonName);
                    }
                    else
                    {
                        Utility.MessageBoxShow("Addon \"" + addonName + "\" could not be uninstalled. Try again later. If you get this error all the times contact Dilatazu for more info.");
                    }
                }
            }
            else
            {
                string neededForStr = "";
                foreach (string item in c_lbNeededFor.Items)
                {
                    neededForStr = neededForStr + item + "\r\n";
                }
                if (Utility.MessageBoxShow("\"" + addonName + "\" is needed for multiple addons. Removing this addon means that the following addons will stop work:\r\n" + neededForStr + "\r\nAre you sure you want to uninstall the addon?", "Are you sure?", MessageBoxButtons.YesNoCancel) == System.Windows.Forms.DialogResult.Yes)
                {
                    string backupFile = InstalledAddons.BackupAddon(addonName, WowVersionEnum.Vanilla);
                    if (InstalledAddons.UninstallAddon(addonName, WowVersionEnum.Vanilla) == true)
                    {
                        Utility.MessageBoxShow("Addon \"" + addonName + "\" was successfully uninstalled!\r\n\r\nA backup zip file of the addon and WTF files was saved incase you regret the decision:\r\n" + StaticValues.LauncherWorkDirectory + "\\" + backupFile);
                        c_lbAddons.SelectedIndex = 0;
                        c_lbAddons.Items.Remove(addonName);
                    }
                    else
                    {
                        Utility.MessageBoxShow("Addon \"" + addonName + "\" could not be uninstalled. Try again later. If you get this error all the times contact Dilatazu for more info.");
                    }
                }
            }
            c_btnUninstallAddon.Enabled = true;
        }
Пример #17
0
 private void c_btnBrowse_Click(object sender, EventArgs e)
 {
     VF.FolderSelectDialog folderSelectDialog = new VF.FolderSelectDialog();
     folderSelectDialog.Title            = "Please find the WoW Classic(or TBC) Directory for me";
     folderSelectDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
     if (folderSelectDialog.ShowDialog() == true)
     {
         c_txtWowDirectory.Text = folderSelectDialog.FileName;
         if (WowUtility.IsValidWowDirectory(c_txtWowDirectory.Text) == false)
         {
             c_txtWowDirectory.ForeColor = Color.Red;
             Utility.MessageBoxShow(c_txtWowDirectory.Text + " is not a valid Wow Directory. \r\nPlease choose the correct directory where Wow is installed.");
         }
         else
         {
             c_txtWowDirectory.ForeColor = Color.Black;
         }
     }
 }
Пример #18
0
        internal static List <string> InstallAddonPackage(string _AddonZipFilePackage, WowVersionEnum _WowVersion, Action <float> _InstallProgress = null, bool _ClearWTFSettings = false)
        {
            List <string> addonsInPackage = GetAddonsInAddonPackage(_AddonZipFilePackage);

            _InstallProgress(0.2f);
            string backupFile = BackupAddons(addonsInPackage, _WowVersion);

            _InstallProgress(0.4f);
            for (int i = 0; i < addonsInPackage.Count; ++i)
            {
                string addon = addonsInPackage[i];
                if (_ClearWTFSettings == true)
                {
                    var savedVariableFiles = WowUtility.GetPerCharacterSavedVariableFilePaths(addon, _WowVersion);
                    savedVariableFiles.AddRange(WowUtility.GetSavedVariableFilePaths(addon, _WowVersion));
                    foreach (string savedVariableFile in savedVariableFiles)
                    {
                        Utility.DeleteFile(savedVariableFile);
                    }
                }
                if (System.IO.Directory.Exists(Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + addon))
                {
                    Utility.DeleteDirectory(Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + addon);
                }
                _InstallProgress(0.4f + ((float)(i + 1) / (float)addonsInPackage.Count) * 0.4f);
            }

            _InstallProgress(0.8f);
            try
            {
                FastZip fastZip = new FastZip();
                fastZip.ExtractZip(_AddonZipFilePackage, Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\", null);
                _InstallProgress(1.0f);
                return(addonsInPackage);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                Utility.MessageBoxShow("There was an error extracting the AddonPackage, Backup of anything deleted/replaced exists in the \"" + backupFile + "\" unfortunately automatic restoration is not implemented yet");
            }
            return(null);
        }
Пример #19
0
 private void SetupUserIDForm_Load(object sender, EventArgs e)
 {
     Utility.SetPositionToMouse(this);
     c_txtUserID.Text = Settings.UserID;
     if (RealmPlayersUploader.IsValidUserID(c_txtUserID.Text) == false)
     {
         if (System.IO.File.Exists(Settings.GetWowDirectory(WowVersionEnum.Vanilla) + "VF_RealmPlayersUploader\\Settings.cfg") == true)
         {
             var oldSettings = System.IO.File.ReadAllLines(Settings.GetWowDirectory(WowVersionEnum.Vanilla) + "VF_RealmPlayersUploader\\Settings.cfg");
             foreach (var settingsLine in oldSettings)
             {
                 if (settingsLine.StartsWith("UserID="))
                 {
                     c_txtUserID.Text = settingsLine.Substring("UserID=".Length);
                     Utility.MessageBoxShow("Found old installation of VF_RealmPlayersUploader, copied the UserID");
                 }
             }
         }
     }
     //this.TopMost = true;
 }
Пример #20
0
 private void c_btnOK_Click(object sender, EventArgs e)
 {
     if (c_txtValue.Text == m_OldValue)
     {
         Close();
         return;
     }
     if (m_ValueValidator != null)
     {
         if (m_ValueValidator(c_txtValue.Text) == false)
         {
             string oldDescValue = c_lblDescription.Text;
             c_lblDescription.ForeColor = Color.Red;
             c_lblDescription.Text      = c_lblDescription.Text += "\r\nNot Valid Value! Try another value or press cancel";
             System.Threading.Tasks.Task newTask = new System.Threading.Tasks.Task(() =>
             {
                 System.Threading.Thread.Sleep(5000);
                 c_lblDescription.BeginInvoke(new Action(() =>
                 {
                     c_lblDescription.ForeColor = Color.Black;
                     c_lblDescription.Text      = oldDescValue;
                 }));
             });
             newTask.Start();
             return;
         }
     }
     else
     {
         if (Utility.MessageBoxShow("Are you sure you want to change the value from \"" + m_OldValue + "\" to \"" + c_txtValue.Text + "\"?", "Are you sure?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
         {
             return;
         }
     }
     if (m_SetValueFunc != null)
     {
         m_SetValueFunc(c_txtValue.Text);
     }
     Close();
 }
Пример #21
0
 private void c_btnOK_Click(object sender, EventArgs e)
 {
     if (WowUtility.IsValidWowDirectory(c_txtWowDirectory.Text) == true)
     {
         if (WowUtility.IsWowDirectoryClassic(c_txtWowDirectory.Text) == true)
         {
             Settings.Instance._WowDirectory = c_txtWowDirectory.Text;
             if (Settings.Instance._WowDirectory.EndsWith("\\") == false && Settings.Instance._WowDirectory.EndsWith("/") == false)
             {
                 Settings.Instance._WowDirectory += "\\";
             }
             Settings.Save();
             Close();
         }
         else if (WowUtility.IsWowDirectoryTBC(c_txtWowDirectory.Text) == true)
         {
             Utility.MessageBoxShow("Please note that this Launcher was originally made for WoW Classic and that some features may not work 100% for WoW TBC. \r\nPlease report any bugs and errors found on the forum at forum.realmplayers.com");
             Settings.Instance._WowDirectory = c_txtWowDirectory.Text;
             if (Settings.Instance._WowDirectory.EndsWith("\\") == false && Settings.Instance._WowDirectory.EndsWith("/") == false)
             {
                 Settings.Instance._WowDirectory += "\\";
             }
             Settings.Instance._WowTBCDirectory = Settings.Instance._WowDirectory;
             Settings.Save();
             Close();
         }
         else
         {
             Utility.MessageBoxShow(c_txtWowDirectory.Text + " is not a valid Wow Directory. \r\nPlease choose the correct directory where Wow is installed.");
         }
     }
     else
     {
         c_txtWowDirectory.ForeColor = Color.Red;
         Utility.MessageBoxShow(c_txtWowDirectory.Text + " is not a valid Wow Directory. \r\nPlease choose the correct directory where Wow is installed.");
     }
 }
Пример #22
0
 private void c_btnCleanWTF_Click(object sender, EventArgs e)
 {
     if (Utility.MessageBoxShow("This command will clean the entire WTF folder of old unused data etc. Are you sure you want to continue?", "Are you sure you want to clean the entire WTF folder?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
     {
     }
 }
Пример #23
0
        bool ValidateUserID(string _UserID)
        {
            if (_UserID.Contains("Unknown.123456") || _UserID == "")
            {
                Utility.MessageBoxShow("You must fill in the correct UserID");
                return(false);
            }
            if (RealmPlayersUploader.IsValidUserID(c_txtUserID.Text) == false)
            {
                Utility.MessageBoxShow("UserID is not valid format, must be <name(a-z)>.<number> example of valid UserID: Unknown.123456");
                return(false);
            }
            if (char.IsUpper(c_txtUserID.Text[0]) == false ||
                c_txtUserID.Text.Last((char _Char) => char.IsUpper(_Char)) == c_txtUserID.Text[0])
            {
                Utility.MessageBoxShow("UserID have to start with capital letter and not contain any other capital letters in the UserName section!");
                return(false);
            }
            Socket tcpSocket = null;

            try
            {
                DateTime startConnectionTime = DateTime.Now;
                tcpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                var          ipAddress = System.Net.Dns.GetHostEntry(ServerComm.g_Host).AddressList[0];
                IAsyncResult ar        = tcpSocket.BeginConnect(ipAddress, 18374, null, null);
                System.Threading.WaitHandle waitHandle = ar.AsyncWaitHandle;
                try
                {
                    for (int t = 0; t < 5; ++t)
                    {
                        if (waitHandle.WaitOne(TimeSpan.FromSeconds(1), false))
                        {
                            break;
                        }
                        Application.DoEvents();
                        //Console.Write(".");
                    }
                    Console.Write("\r\n");
                    if (!waitHandle.WaitOne(TimeSpan.FromSeconds(1), false))
                    {
                        tcpSocket.Close();
                        Utility.SoftThreadSleep(1000);
                        waitHandle.Close();
                        Utility.MessageBoxShow("Could not validate UserID because connection to server failed, try again later.");
                        return(false);
                    }

                    tcpSocket.EndConnect(ar);
                }
                finally
                {
                    waitHandle.Close();
                }
                tcpSocket.ReceiveTimeout = 5000;
                tcpSocket.SendTimeout    = 5000;
                byte[] bytes  = System.Text.Encoding.UTF8.GetBytes("NullNullNullNullNullNullNullNull");
                byte[] header = System.Text.Encoding.UTF8.GetBytes("Command=UserCheck;UserID=" + _UserID + ";FileSize=" + bytes.Length + "%");
                tcpSocket.Send(header);
                tcpSocket.Send(bytes);
                tcpSocket.Shutdown(SocketShutdown.Send);
                Byte[] readBuffer = new Byte[1024];
                int    i          = 0;
                string data       = "";
                while ((i = tcpSocket.Receive(readBuffer, readBuffer.Length, SocketFlags.None)) != 0)
                {
                    data += System.Text.Encoding.UTF8.GetString(readBuffer, 0, i);
                    if ((DateTime.Now - startConnectionTime).TotalSeconds > 10)
                    {
                        throw new Exception("Transfer took longer than 10 seconds, should not be allowed, canceling");
                    }
                }
                bool wasSuccess = false;
                if (data.Contains(";") && data.Contains("="))
                {
                    string[] dataSplit = data.Split(';');
                    foreach (string currDataSplit in dataSplit)
                    {
                        if (currDataSplit.Contains("="))
                        {
                            string[] currValue = currDataSplit.Split('=');
                            if (currValue[0] == "VF_RPP_Success")
                            {
                                wasSuccess = ConvertBool(currValue[1]);
                            }
                            else if (currValue[0] == "Message")
                            {
                                Utility.MessageBoxShow(currValue[1]);
                            }
                        }
                    }
                }
                if (wasSuccess == true)
                {
                    Utility.MessageBoxShow("The UserID \"" + _UserID + "\" was valid and is now in use! The program will now start upload your inspected database automatically everytime you close wow(if started using the WowLauncher).");
                    return(true);
                }
                else
                {
                    Utility.MessageBoxShow("The UserID \"" + _UserID + "\" is not valid. Please enter the correct UserID that was given to you.");
                }
            }
            catch (Exception ex)
            {
                Utility.MessageBoxShow("Could not validate UserID because of a connection error. Printscreen this message and PM to Dilatazu @ realmplayers forums or try again later.\r\nException:\r\n" + ex.ToString());
            }
            return(false);
        }
Пример #24
0
        static void Main(string[] args)
        {
            g_LauncherApp = new WoWLauncherApp();
            g_LauncherApp.InitiateMessageIDs();
            try
            {
                try
                {
                    StaticValues.StartupArguments = new CMDArguments(args);
                    if (StaticValues.StartupArguments["RealmPlayersUploader"] != null) // /RealmPlayersUploader
                    {
                        Settings.Initialize();
                        ConsoleUtility.CreateConsole();
                        bool anyProblem = false;
                        if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == true)
                        {
                            bool sentAll = true;

                            if (Settings.HaveClassic == true)
                            {
                                if (Settings.Instance.ContributeRealmPlayers == true)
                                {
                                    Logger.ConsoleWriteLine("Starting to send VF_RealmPlayers Files", ConsoleColor.White);
                                    var sentRealmPlayersFiles = ServerComm.SendAddonData(Settings.UserID, "VF_RealmPlayers", WowVersionEnum.Vanilla, "VF_RealmPlayersData", 50, out sentAll);
                                    foreach (var file in sentRealmPlayersFiles)
                                    {
                                        Logger.ConsoleWriteLine("Sent VF_RealmPlayers File \"" + file + "\"", ConsoleColor.Green);
                                    }
                                    if (sentAll == true)
                                    {
                                        InstalledAddons.ModifyInstalledAddon("VF_RealmPlayers", WowVersionEnum.Vanilla, "VF_RP_LastUploadedData", "\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\"");
                                    }
                                    else
                                    {
                                        anyProblem = true;
                                    }
                                }


                                if (Settings.Instance.ContributeRaidStats == true)
                                {
                                    if (InstalledAddons.GetAddonInfo("VF_RaidStats", WowVersionEnum.Vanilla) != null)
                                    {
                                        Logger.ConsoleWriteLine("Starting to send VF_RaidStats Files", ConsoleColor.White);
                                        var sentRaidStatsFiles = ServerComm.SendAddonData(Settings.UserID, "VF_RaidStats", WowVersionEnum.Vanilla, "VF_RaidStatsData", 5000, out sentAll);
                                        foreach (var file in sentRaidStatsFiles)
                                        {
                                            Logger.ConsoleWriteLine("Sent VF_RaidStats File \"" + file + "\"", ConsoleColor.Cyan);
                                        }
                                        if (sentAll == true)
                                        {
                                            InstalledAddons.ModifyInstalledAddon("VF_RaidStats", WowVersionEnum.Vanilla, "VF_RS_LastUploadedData", "\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\"");
                                        }
                                        else
                                        {
                                            anyProblem = true;
                                        }
                                    }
                                    else
                                    {
                                        Logger.ConsoleWriteLine("Starting to send VF_RaidDamage Files", ConsoleColor.White);
                                        var sentRaidDamageFiles = ServerComm.SendAddonData(Settings.UserID, "VF_RaidDamage", WowVersionEnum.Vanilla, "VF_RaidDamageData", 5000, out sentAll);
                                        foreach (var file in sentRaidDamageFiles)
                                        {
                                            Logger.ConsoleWriteLine("Sent VF_RaidDamage File \"" + file + "\"", ConsoleColor.Cyan);
                                        }
                                        if (sentAll == true)
                                        {
                                            InstalledAddons.ModifyInstalledAddon("VF_RaidDamage", WowVersionEnum.Vanilla, "VF_RD_LastUploadedData", "\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\"");
                                        }
                                        else
                                        {
                                            anyProblem = true;
                                        }
                                    }
                                }
                            }
                            if (Settings.HaveTBC == true)
                            {
                                if (Settings.Instance.ContributeRealmPlayers == true)
                                {
                                    Logger.ConsoleWriteLine("Starting to send VF_RealmPlayersTBC Files", ConsoleColor.White);
                                    var sentRealmPlayersTBCFiles = ServerComm.SendAddonData(Settings.UserID, "VF_RealmPlayersTBC", WowVersionEnum.TBC, "VF_RealmPlayersData", 50, out sentAll);
                                    foreach (var file in sentRealmPlayersTBCFiles)
                                    {
                                        Logger.ConsoleWriteLine("Sent VF_RealmPlayersTBC File \"" + file + "\"", ConsoleColor.Cyan);
                                    }
                                    if (sentAll == true)
                                    {
                                        InstalledAddons.ModifyInstalledAddon("VF_RealmPlayersTBC", WowVersionEnum.TBC, "VF_RP_LastUploadedData", "\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\"");
                                    }
                                    else
                                    {
                                        anyProblem = true;
                                    }
                                }

                                if (Settings.Instance.ContributeRaidStats == true)
                                {
                                    Logger.ConsoleWriteLine("Starting to send VF_RaidStatsTBC Files", ConsoleColor.White);
                                    var sentRaidStatsTBCFiles = ServerComm.SendAddonData(Settings.UserID, "VF_RaidStatsTBC", WowVersionEnum.TBC, "VF_RaidStatsData", 5000, out sentAll);
                                    foreach (var file in sentRaidStatsTBCFiles)
                                    {
                                        Logger.ConsoleWriteLine("Sent VF_RaidStatsTBC File \"" + file + "\"", ConsoleColor.Cyan);
                                    }
                                    if (sentAll == true)
                                    {
                                        InstalledAddons.ModifyInstalledAddon("VF_RaidStatsTBC", WowVersionEnum.TBC, "VF_RS_LastUploadedData", "\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\"");
                                    }
                                    else
                                    {
                                        anyProblem = true;
                                    }
                                }
                            }
                            ServerComm.SendAddonData_Dispose();
                        }
                        else
                        {
                            anyProblem = true;
                            Logger.ConsoleWriteLine("UserID: " + Settings.UserID + " was not a valid UserID!");
                        }
                        if (anyProblem == true)
                        {
                            Logger.ConsoleWriteLine("Due to uploading problems, the window is closing in 10 seconds! Feel free to manually close it earlier. If this happens often and annoys you, please take a screenshot and make a thread on the realmplayers forum", ConsoleColor.White);
                            System.Threading.Thread.Sleep(10000);
                        }
                        else
                        {
                            if (Settings.Instance.Wait5SecondsAfterUpload == true)
                            {
                                Logger.ConsoleWriteLine("Closing in 5 seconds!", ConsoleColor.White);
                                System.Threading.Thread.Sleep(5000);
                            }
                        }
                        return;
                    }
                    else if (StaticValues.StartupArguments["LaunchWow"] != null)
                    {
                        Settings.Initialize();
                        ConsoleUtility.CreateConsole();
                        string useRealm         = StaticValues.StartupArguments["LaunchWow"];
                        string useConfigProfile = "Active Wow Config";
                        if (StaticValues.StartupArguments["ConfigProfile"] != null)
                        {
                            useConfigProfile = StaticValues.StartupArguments["ConfigProfile"];
                        }

                        System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();

                        if (Settings.Instance.RealmLists.ContainsKey(useRealm) == false)
                        {
                            return;
                        }

                        var realmInfo = Settings.Instance.RealmLists[useRealm];
                        if (realmInfo.WowVersion == WowVersionEnum.TBC)
                        {
                            useConfigProfile = "Active Wow Config";
                            if (Settings.Instance.ClearWDB == true)
                            {
                                Utility.DeleteDirectory(Settings.GetWowDirectory(realmInfo.WowVersion) + "Cache");
                            }
                        }
                        else
                        {
                            if (Settings.Instance.ClearWDB == true)
                            {
                                Utility.DeleteDirectory(Settings.GetWowDirectory(realmInfo.WowVersion) + "WDB");
                            }
                        }

                        if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == true)
                        {
                            if (System.IO.File.Exists(StaticValues.LauncherToolsDirectory + "RunWowAndUploader.bat") == false ||
                                System.IO.File.ReadAllText(StaticValues.LauncherToolsDirectory + "RunWowAndUploader.bat") != StaticValues.RunWowAndUploaderBatFileData)
                            {
                                Utility.AssertDirectory(StaticValues.LauncherToolsDirectory);
                                System.IO.File.WriteAllText(StaticValues.LauncherToolsDirectory + "RunWowAndUploader.bat", StaticValues.RunWowAndUploaderBatFileData);
                            }

                            if (Settings.Instance.RunWoWNotAdmin == false)
                            {
                                //startInfo.FileName = Settings.WowDirectory + "WoW.exe";
                                //startInfo.WorkingDirectory = Settings.WowDirectory;

                                startInfo.FileName = StaticValues.LauncherToolsDirectory + "RunWowAndUploader.bat";
                                //startInfo.FileName = Settings.WowDirectory + "22VF_RealmPlayersUploader 1.5\\RunWoWAndUploaderNoCMDWindow.vbs";
                                //startInfo.WorkingDirectory = Settings.WowDirectory + "22VF_RealmPlayersUploader 1.5\\";
                                startInfo.Arguments = "\"" + Settings.GetWowDirectory(realmInfo.WowVersion) + "\"";
                            }
                            else
                            {
                                string slash = "\\\\";
                                string snuff = "\\\"";

                                startInfo.FileName  = StaticValues.LauncherToolsDirectory + "NotAdmin.exe";
                                startInfo.Arguments = "\"cmd.exe\" \".\\\\\" "
                                                      + "\"/c "
                                                      + snuff
                                                      + snuff + StaticValues.LauncherWorkDirectory.Replace("\\", slash) + "/" + StaticValues.LauncherToolsDirectory.Replace("\\", slash) + "RunWowAndUploader.bat" + snuff
                                                      + " " + snuff + Settings.GetWowDirectory(realmInfo.WowVersion) + "\\" + snuff
                                                      + snuff
                                                      + "\" nowindow";
                            }
                            startInfo.UseShellExecute        = false;
                            startInfo.RedirectStandardOutput = false;
                            startInfo.CreateNoWindow         = true;
                        }
                        else
                        {
                            startInfo.FileName         = Settings.GetWowDirectory(realmInfo.WowVersion) + "WoW.exe";
                            startInfo.WorkingDirectory = Settings.GetWowDirectory(realmInfo.WowVersion);
                        }
                        Logger.ConsoleWriteLine("Starting to Launch WoW for realm: \"" + useRealm + "\", with ConfigProfile: \"" + useConfigProfile + "\"", ConsoleColor.Green);
                        LaunchFunctions.LaunchWow(useConfigProfile, useRealm, startInfo);
                        Logger.ConsoleWriteLine("Done with Launching WoW! Closing console window in 5 seconds!", ConsoleColor.White);
                        System.Threading.Thread.Sleep(5000);
                        return;
                    }

                    g_AppMutex = new Mutex(true, "Local\\VF_WoWLauncher");
                    if (g_AppMutex == null || g_AppMutex.WaitOne(TimeSpan.Zero, true))
                    {
                        Settings.Initialize();

                        if (Settings.DebugMode)
                        {
                            //ConsoleUtility.CreateConsole();
                        }

                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        var launcherWindow = new LauncherWindow();
                        g_LauncherApp.HandleJumpListCommands(launcherWindow, StaticValues.StartupArguments);
                        Application.Run(launcherWindow);
                        if (g_AppMutex != null)
                        {
                            ForumReader.SaveForumSections();
                            Settings.Save();
                            ReleaseAppMutex();
                        }
                    }
                    else
                    {
                        g_AppMutex = null;
                        g_LauncherApp.HandleJumpListCommands(null, StaticValues.StartupArguments);
                    }
                }
                catch (Exception ex)
                {
                    ReleaseAppMutex();
                    Utility.MessageBoxShow("Exception occured! Please printscreen this message and send to Dilatazu @ realmplayers forums:\r\n" + ex.ToString());
                    ConsoleUtility.CreateConsole();
                    Logger.LogException(ex);
                    Logger.ConsoleWriteLine("Closing in 10 seconds!", ConsoleColor.White);
                    System.Threading.Thread.Sleep(10000);
                }
            }
            catch (Exception ex)
            {
                ReleaseAppMutex();
                Utility.MessageBoxShow("Very unexpected Exception occured! Please printscreen this message and send to Dilatazu @ realmplayers forums:\r\n" + ex.ToString());
            }
            ReleaseAppMutex();
        }
Пример #25
0
        private static void _LaunchWow(string _Config, string _RealmName, ProcessStartInfo _WowProcessStartInfo)
        {
            if (System.IO.File.Exists("VF_WowLauncherTools\\NotAdmin.exe") == false)
            {
                VF_Utility.AssertDirectory("VF_WowLauncherTools");
                System.IO.File.WriteAllBytes("VF_WowLauncherTools\\NotAdmin.exe", Properties.Resources.NotAdmin);
            }

            Logger.LogText("Started Launching");

            WowVersionEnum wowVersion    = WowVersionEnum.Vanilla;
            string         realmListFile = "";

            if (Settings.Instance.RealmLists.ContainsKey(_RealmName) == true)
            {
                var realmList = Settings.Instance.RealmLists[_RealmName];
                realmListFile = realmList.GetRealmListWTF();
                wowVersion    = realmList.WowVersion;
            }
            else
            {
                Logger.LogText("Unexpected Error: No such Realm exists!");
                return;
            }

            if (_Config != "Active Wow Config")
            {
                ConfigWTF config = ConfigProfiles.GetProfileConfigFile(_Config);
                config.SaveWTFConfigFile(wowVersion);
                Settings.Instance.AddLaunchShortcut(_Config, _RealmName);
            }

            DateTime startCheck = DateTime.UtcNow;

            if (System.IO.File.Exists(Settings.GetWowDirectory(wowVersion) + "realmlist.wtf") == false || System.IO.File.ReadAllText(Settings.GetWowDirectory(wowVersion) + "realmlist.wtf") != realmListFile)
            {
                System.IO.File.WriteAllText(Settings.GetWowDirectory(wowVersion) + "realmlist.wtf", realmListFile);
                if (System.IO.File.Exists(Settings.GetWowDirectory(wowVersion) + "realmlist.wtf") == false)
                {
                    Logger.LogText("Unexpected Error: There is no realmlist.wtf!");
                    return;
                }
                Logger.LogText("Waiting for realmlist.wtf to get saved correctly");
                startCheck = DateTime.UtcNow;
                while ((startCheck - System.IO.File.GetLastWriteTimeUtc(Settings.GetWowDirectory(wowVersion) + "realmlist.wtf")).Seconds > 10)
                {
                    Logger.LogText(".", false);
                    System.Threading.Thread.Sleep(20);
                    if ((DateTime.UtcNow - startCheck).Seconds > 10)
                    {
                        Logger.LogText("Unexpected Error: Took too long trying to create the new realmlist.wtf!");
                        return;
                    }
                }
            }
            Logger.LogText("realmlist.wtf is saved, Launching World of Warcraft!");
            Process[] processesBeforeStart = Process.GetProcessesByName("Wow");
            var       wowProcess           = Process.Start(_WowProcessStartInfo);

            if (_WowProcessStartInfo.FileName.ToLower().EndsWith("wow.exe") == false)
            {
                wowProcess = null;
                while (wowProcess == null && (DateTime.UtcNow - startCheck).TotalSeconds < 30)
                {
                    Utility.SoftThreadSleep(500);
                    Process[] currentProcesses = Process.GetProcessesByName("Wow");
                    foreach (var currProcess in currentProcesses)
                    {
                        if (processesBeforeStart.Length == 0 || processesBeforeStart.FirstOrDefault((_Value) => _Value.Id == currProcess.Id) == null)
                        {
                            //Logger.LogText("found new Wow.exe Process!");
                            wowProcess = currProcess;
                            break;
                        }
                    }
                }
            }
            if (wowProcess == null)
            {
                Utility.MessageBoxShow("There was an error, WoW could not be launched");
                return;
            }
            startCheck = DateTime.UtcNow;
            try
            {
                while (wowProcess.WaitForInputIdle(50) == false && (DateTime.UtcNow - startCheck).TotalSeconds < 20)
                {
                    System.Windows.Forms.Application.DoEvents();
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            //wait 1 extra second
            Utility.SoftThreadSleep(1000);

            Logger.LogText("Done Launching");
        }
Пример #26
0
        private void c_btnClose_Click(object sender, EventArgs e)
        {
            if (WowUtility.IsValidWowDirectory(c_txtWowDirectory.Text) == false)
            {
                var dialogResult = Utility.MessageBoxShow("The specified WoW Classic Directory is not valid. Only valid WoW Classic Directory can be used. Use the old specified \"" + Settings.GetWowDirectory(WowVersionEnum.Vanilla) + "\"?", "Not valid Wow Directory", MessageBoxButtons.YesNo);
                if (dialogResult == System.Windows.Forms.DialogResult.No)
                {
                    c_txtWowDirectory.ForeColor = Color.Red;
                }
                else//if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    c_txtWowDirectory.Text = Settings.GetWowDirectory(WowVersionEnum.Vanilla);
                }
                return;
            }
            else
            {
                if (c_txtWowDirectory.Text.EndsWith("\\") == false && c_txtWowDirectory.Text.EndsWith("/") == false)
                {
                    c_txtWowDirectory.Text = c_txtWowDirectory.Text + "\\";
                }
                Settings.Instance._WowDirectory = c_txtWowDirectory.Text;
            }
            if (c_cbxEnableTBC.Checked == true)
            {
                if (WowUtility.IsValidWowDirectory(c_txtTBCWowDirectory.Text) == false)
                {
                    if (Settings.HaveTBC == true)
                    {
                        var dialogResult = Utility.MessageBoxShow("The specified WoW The Burning Crusade Directory is not valid. Only valid WoW TBC Directory can be used. Use the old specified \"" + Settings.GetWowDirectory(WowVersionEnum.TBC) + "\"?", "Not valid Wow Directory", MessageBoxButtons.YesNo);
                        if (dialogResult == System.Windows.Forms.DialogResult.No)
                        {
                            c_txtTBCWowDirectory.ForeColor = Color.Red;
                        }
                        else//if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                        {
                            c_txtTBCWowDirectory.Text = Settings.GetWowDirectory(WowVersionEnum.TBC);
                        }
                        return;
                    }
                    else
                    {
                        var dialogResult = Utility.MessageBoxShow("The specified WoW The Burning Crusade Directory is not valid. Only valid WoW TBC Directory can be used. Disable the use of WoW TBC Directory?", "Not valid Wow Directory", MessageBoxButtons.YesNo);
                        if (dialogResult == System.Windows.Forms.DialogResult.No)
                        {
                            c_txtTBCWowDirectory.ForeColor = Color.Red;
                        }
                        else//if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                        {
                            c_txtTBCWowDirectory.ForeColor = Color.Black;
                            c_cbxEnableTBC.Checked         = false;
                            c_txtTBCWowDirectory.Text      = "";
                        }
                        return;
                    }
                }
                else
                {
                    if (c_txtTBCWowDirectory.Text.EndsWith("\\") == false && c_txtTBCWowDirectory.Text.EndsWith("/") == false)
                    {
                        c_txtTBCWowDirectory.Text = c_txtTBCWowDirectory.Text + "\\";
                    }
                    Settings.Instance._WowTBCDirectory = c_txtTBCWowDirectory.Text;
                }
            }
            else
            {
                Settings.Instance._WowTBCDirectory = "";
            }

            Settings.Instance.RunWoWNotAdmin     = c_cbxRunNotAdmin.Checked;
            Settings.Instance.AutoHideOldNews    = c_cbxAutoHide.Checked;
            Settings.Instance.AutoUpdateVFAddons = c_cbAutoUpdateVF.Checked;
            //Settings.Instance.UseWoWNoDelay = c_cbxWoWNoDelay.Checked;
            Settings.Instance.AutoRefreshNews        = c_cbAutoRefresh.Checked;
            Settings.Instance.NewsSources_Feenix     = c_cbxFeenixNews.Checked;
            Settings.Instance.NewsSources_Nostalrius = c_cbxNostalriusNews.Checked;
            Settings.Instance.NewsSources_Kronos     = c_cbxKronosNews.Checked;

            if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == true)
            {
                Settings.Instance.ContributeRealmPlayers  = c_cbContributeRealmPlayers.Checked;
                Settings.Instance.ContributeRaidStats     = c_cbContributeRaidStats.Checked;
                Settings.Instance.Wait5SecondsAfterUpload = c_cbxWait5Seconds.Checked;
            }
            Close();
        }
Пример #27
0
        internal static List <string> SendAddonData(string _UserID, string _AddonName, WowVersionEnum _WowVersion, string _ClearLuaVariableName, int _LuaVariableDataLengthThreshold, out bool _SentAll)
        {
            var savedVariableFiles = WowUtility.GetSavedVariableFilePaths(_AddonName, _WowVersion);//For Accounts only

            _LuaVariableDataLengthThreshold = _LuaVariableDataLengthThreshold + 12 /*newlines = {} osv osv*/ + _ClearLuaVariableName.Length;
            VF.NetworkClient netClient = sm_Client;
            if (netClient != null && netClient.IsConnected() == false)
            {
                netClient.Disconnect();
                netClient = null;
            }
            List <string> sentAddonFiles = new List <string>();

            _SentAll = true;//Default läge
            try
            {
                foreach (var luaFilePath in savedVariableFiles)
                {
                    string luaFileData    = System.IO.File.ReadAllText(luaFilePath);
                    string resultFileData = "";
                    string variableData   = "";
                    if (WowUtility.ExtractLuaVariableFromFile(luaFileData, _ClearLuaVariableName, out resultFileData, out variableData) == true)
                    {
                        if (variableData.Length < _LuaVariableDataLengthThreshold)
                        {
                            continue;
                        }
                        if (netClient == null)
                        {
                            Logger.ConsoleWriteLine("Trying to connect to server...", ConsoleColor.Gray);
                            netClient = new VF.NetworkClient(g_Host, g_Port); //realmplayers.com
                            Logger.ConsoleWriteLine("Connected to server!", ConsoleColor.Green);
                        }

                        WLN_UploadPacket_AddonData addonData = new WLN_UploadPacket_AddonData();
                        addonData.AddonName  = _AddonName;
                        addonData.UserID     = _UserID;
                        addonData.FileStatus = WowUtility.GetFileStatus(luaFilePath);
                        addonData.Data       = luaFileData;
                        var newMessage = netClient.CreateMessage();
                        newMessage.WriteByte((byte)WLN_PacketType.Upload_AddonData);
                        newMessage.WriteClass(addonData);
                        netClient.WaitForConnect(TimeSpan.FromSeconds(60));
                        netClient.SendMessage(newMessage);
                        Logger.ConsoleWriteLine("Sent SavedVariables file \"" + luaFilePath + "\". Waiting for Response...", ConsoleColor.Gray);
                        WLN_UploadPacket_SuccessResponse response;
                        if (netClient.RecvPacket_VF(WLN_PacketType.Upload_SuccessResponse, out response, TimeSpan.FromSeconds(60)) == true)
                        {
                            Logger.ConsoleWriteLine("Received Response. Data was sent successfully!. Deleting old data", ConsoleColor.Gray);
                            sentAddonFiles.Add(luaFilePath);
                            if (response.MessageToUser != "")
                            {
                                Utility.MessageBoxShow(response.MessageToUser, "Message from Server");
                            }
                            //TODO: Do something with "response.MessageToUser"
                            System.IO.File.WriteAllText(luaFilePath, resultFileData); //Save the lua file with the variable cleared

                            Logger.ConsoleWriteLine("Operation Successfull! Preparing for next file.", ConsoleColor.Green);
                        }
                        else
                        {
                            Logger.ConsoleWriteLine("Operation Failed! Preparing for next file.", ConsoleColor.Red);
                            _SentAll = false;
                        }
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                _SentAll = false;
            }
            finally
            {
                if (_SentAll == false)
                {
                    if (netClient != null)
                    {
                        netClient.Disconnect();
                        netClient = null;
                    }
                }
                sm_Client = netClient;
            }
            return(sentAddonFiles);
        }