Exemple #1
0
 private void AddonsSettingsForm_Load(object sender, EventArgs e)
 {
     Utility.SetPositionToMouse(this);
     //this.TopMost = true;
     (new System.Threading.Tasks.Task(() => {
         m_AddonsWTF = AddonsWTF.LoadAllAccountAddons(WowVersionEnum.Vanilla);
         var installedAddons = InstalledAddons.GetInstalledAddons(WowVersionEnum.Vanilla);
         foreach (var installedAddon in installedAddons)
         {
             m_AddonInfos[installedAddon] = InstalledAddons.GetAddonInfo(installedAddon, WowVersionEnum.Vanilla);
             c_lbAddons.BeginInvoke(new Action(() => {
                 c_lbAddons.Items.Add(installedAddon);
                 if (c_lbAddons.Items.Count == 1)
                 {
                     c_lbAddons.SelectedIndex = 0;
                 }
             }));
         }
         c_lbAddons.BeginInvoke(new Action(() => {
             c_lbAddons.SelectedIndexChanged += c_lbAddons_SelectedIndexChanged;
             c_lbAddons.Enabled = true;
         }));
     })).Start();
     c_btnSaveAllChanges.Enabled = false;
 }
Exemple #2
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);
            }
        }
Exemple #3
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;
        }
        private void c_txtAddonFolder_TextChanged(object sender, EventArgs e)
        {
            if (System.IO.Directory.Exists(c_txtAddonFolder.Text) == true)
            {
                c_txtAddonFolder.ForeColor = Color.Black;
                var addonName = c_txtAddonFolder.Text.Split(new char[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries).Last();
                var addonInfo = InstalledAddons.GetAddonInfo(addonName, c_txtAddonFolder.Text);
                if (addonInfo != null)
                {
                    c_txtVersion.Text = addonInfo.m_VersionString;
                    if (Utility.ContainsInvalidFilenameChars(c_txtVersion.Text) == false)
                    {
                        c_btnCreate.Enabled = true;
                        return;
                    }
                }
            }
            c_txtAddonFolder.ForeColor = Color.Red;

            c_btnCreate.Enabled = false;
            c_txtVersion.Text   = "Unknown Version!";
        }
        private void _LoadConfigFile(string _Filename)
        {
            if (System.IO.File.Exists(_Filename) == true)
            {
                string[] configLines = System.IO.File.ReadAllLines(_Filename);
                foreach (string configLine in configLines)
                {
                    string[] addoNameAndConfig = configLine.Split(new string[] { ": " }, StringSplitOptions.RemoveEmptyEntries);
                    if (addoNameAndConfig.Length == 2)
                    {
                        ConfigValues.AddOrSet(addoNameAndConfig[0], Tuple.Create(addoNameAndConfig[1], false));
                    }
                }
            }
            var addons = InstalledAddons.GetInstalledAddons(WowVersionEnum.Vanilla);

            foreach (var addon in addons)
            {
                if (ConfigValues.ContainsKey(addon) == false)
                {
                    ConfigValues.AddOrSet(addon, Tuple.Create("enabled(auto)", false));
                }
            }
        }
Exemple #6
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();
        }
Exemple #7
0
        internal static List <AddonUpdateInfo> GetAddonUpdateInfos(List <string> _AddonNames, WowVersionEnum _WowVersion)
        {
            VF.NetworkClient       netClient = new VF.NetworkClient(g_Host, g_Port);
            List <AddonUpdateInfo> retList   = new List <AddonUpdateInfo>();

            try
            {
                //VF.NetworkIncommingMessage msg;
                {
                    VF.NetworkOutgoingMessage            newMessage = netClient.CreateMessage();
                    WLN_RequestPacket_AddonUpdateInfoNew request    = new WLN_RequestPacket_AddonUpdateInfoNew();
                    request.UserID          = Settings.UserID;
                    request.LauncherVersion = StaticValues.LauncherVersion;
                    request.WowVersion      = _WowVersion;
                    for (int i = 0; i < _AddonNames.Count; ++i)
                    {
                        var addonUpdateInfo = new WLN_RequestPacket_AddonUpdateInfo();
                        addonUpdateInfo.AddonName = _AddonNames[i];
                        var addonInfo = InstalledAddons.GetAddonInfo(_AddonNames[i], _WowVersion);
                        if (addonInfo != null)
                        {
                            addonUpdateInfo.CurrentVersion = addonInfo.m_VersionString;
                        }
                        else
                        {
                            addonUpdateInfo.CurrentVersion = "0.0";
                        }
                        request.Addons.Add(addonUpdateInfo);
                    }
                    newMessage.WriteByte((byte)WLN_PacketType.Request_AddonUpdateInfoNew);
                    newMessage.WriteClass(request);
                    netClient.SendMessage(newMessage);
                }
                List <WLN_ResponsePacket_AddonUpdateInfo> recvAddonUpdateInfos = null;

                if (netClient.RecvPacket_VF(WLN_PacketType.Response_AddonUpdateInfo, out recvAddonUpdateInfos) == true)
                {
                    foreach (var recvAddonUpdateInfo in recvAddonUpdateInfos)
                    {
                        if (recvAddonUpdateInfo.AddonName == "null")
                        {
                            continue;
                        }
                        AddonUpdateInfo addonUpdateInfo = new AddonUpdateInfo();
                        addonUpdateInfo.AddonName                          = recvAddonUpdateInfo.AddonName;
                        addonUpdateInfo.InstalledAddonInfo                 = InstalledAddons.GetAddonInfo(recvAddonUpdateInfo.AddonName, _WowVersion);
                        addonUpdateInfo.CurrentVersion                     = recvAddonUpdateInfo.CurrentVersion;
                        addonUpdateInfo.UpdateVersion                      = recvAddonUpdateInfo.UpdateVersion;
                        addonUpdateInfo.UpdateDescription                  = recvAddonUpdateInfo.UpdateDescription;
                        addonUpdateInfo.AddonPackageDownloadFTP            = recvAddonUpdateInfo.AddonPackageDownloadFTP;
                        addonUpdateInfo.ClearAccountSavedVariablesRequired = recvAddonUpdateInfo.ClearAccountSavedVariablesRequired;
                        addonUpdateInfo.UpdateSubmitter                    = recvAddonUpdateInfo.UpdateSubmitter;
                        addonUpdateInfo.UpdateImportance                   = recvAddonUpdateInfo.UpdateImportance;
                        addonUpdateInfo.MoreInfoSite                       = recvAddonUpdateInfo.MoreInfoSite;
                        retList.Add(addonUpdateInfo);
                    }
                }
            }
            finally
            {
                netClient.Disconnect();
            }
            return(retList);
        }