Пример #1
0
        internal static bool UninstallAddon(string _AddonName, WowVersionEnum _WowVersion)
        {
            if (System.IO.Directory.Exists(Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + _AddonName))
            {
                Utility.DeleteDirectory(Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + _AddonName);

                //Delete WTF files
                var savedVariableFiles = WowUtility.GetPerCharacterSavedVariableFilePaths(_AddonName, _WowVersion);
                savedVariableFiles.AddRange(WowUtility.GetSavedVariableFilePaths(_AddonName, _WowVersion));
                foreach (string savedVariableFile in savedVariableFiles)
                {
                    Utility.DeleteFile(savedVariableFile);
                }
                //Delete WTF files
            }
            return(System.IO.Directory.Exists(Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + _AddonName) == false);
        }
Пример #2
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);
        }
Пример #3
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();
        }