Beispiel #1
0
        private void bwtBackgroundWorkerThread_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker backgroundWorker = (BackgroundWorker)sender;
            CopyProgress     hostForm         = (CopyProgress)e.Argument;
            List <string>    filesToProcess   = GetFilesToProcess(hostForm.SourceDirectory);

            //Debugger.Break();

            int currentFileCounter = 1;

            foreach (string fileToProcess in filesToProcess)
            {
                if (backgroundWorker.CancellationPending == true)
                {
                    e.Cancel = true;
                    break;
                }

                string relativePath = fileToProcess.Substring(hostForm.SourceDirectory.Length);
                if (relativePath.StartsWith("\\") == true)
                {
                    relativePath = relativePath.Substring(1);
                }

                string targetFile = Path.Combine(TargetDirectory, relativePath);

                hostForm.SetCurrentFile(fileToProcess);

                if (File.Exists(targetFile) == false)
                {
                    if (Directory.Exists(Path.GetDirectoryName(targetFile)) == false)
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(targetFile));
                    }

                    File.Copy(fileToProcess, targetFile, true);
                }

                int currentProgressPercent = (int)Math.Floor((double)currentFileCounter / (double)filesToProcess.Count * 100D);

                if (currentProgressPercent > 100)
                {
                    currentProgressPercent = 100;
                }

                System.Diagnostics.Debug.WriteLine(currentProgressPercent);

                backgroundWorker.ReportProgress(currentProgressPercent);

                currentFileCounter++;
            }

            e.Result = true;
        }
Beispiel #2
0
        private static bool UpgradeRegistryToUseDiscreetBetaAndProdPaths(out string returnMessage)
        {
            returnMessage = String.Empty;

            if (String.IsNullOrEmpty(AllegianceRegistry.ProductionArtPath) == true)
            {
                var productionArtworkPath = Path.Combine(Path.Combine(AllegianceRegistry.LobbyPath, LobbyType.Production.ToString()), "Artwork");

                var copyProgress = new CopyProgress();
                copyProgress.TopMost = true;
                //copyProgress.MinimizeBox = false;
                copyProgress.SourceDirectory = AllegianceRegistry.ArtPath;
                copyProgress.TargetDirectory = productionArtworkPath;
                copyProgress.LobbyType       = LobbyType.Production;

                if (copyProgress.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    returnMessage = "Artwork file copy was canceled. Launcher update incomplete, please restart ACSS Launcher to try again.";
                    return(false);
                }

                AllegianceRegistry.ProductionArtPath = productionArtworkPath;
            }

            if (String.IsNullOrEmpty(AllegianceRegistry.BetaArtPath) == true)
            {
                AllegianceRegistry.BetaArtPath = AllegianceRegistry.ArtPath;
            }

            if (String.IsNullOrEmpty(AllegianceRegistry.ProductionCfgFile) == true)
            {
                AllegianceRegistry.ProductionCfgFile = "http://acss.alleg.net/allegiance.txt";
            }

            if (String.IsNullOrEmpty(AllegianceRegistry.BetaCfgFile) == true)
            {
                AllegianceRegistry.BetaCfgFile = "http://acss.alleg.net/allegiance-beta.txt";
            }

            return(true);
        }
Beispiel #3
0
        //public override void Install(IDictionary stateSaver)
        //{
        //    string launcherPath = this.Context.Parameters["targetpath"];
        //    string launcherExe = Path.Combine(launcherPath, "Launcher.exe");

        //    if (File.Exists(launcherExe) == true)
        //        File.Delete(launcherExe);

        //    base.Install(stateSaver);
        //}

        protected override void OnAfterInstall(IDictionary savedState)
        {
            int stepCount = 0;

            try
            {
                //StringBuilder sb = new StringBuilder();
                //foreach (string key in this.Context.Parameters.Keys)
                //{
                //    sb.AppendLine(String.Format("{0} = {1}", key, this.Context.Parameters[key]));
                //}
                //string exePath = this.Context.Parameters["targetpath"];
                //sb.AppendLine("wtf: " + exePath);
                //File.WriteAllText("c:\\out.txt", sb.ToString());

                // Clear any old DS databases.
                foreach (string filename in Directory.GetFiles(this.Context.Parameters["targetpath"], "*.ds"))
                {
                    File.Delete(filename);
                }

                stepCount++;

                // Create registry keys if they don't exist.
                RegistryKey rootKey           = Registry.LocalMachine.OpenSubKey(GetAllegianceRoot(), true);
                RegistryKey productionKey     = rootKey.OpenSubKey("1.0");
                string      artPath           = (String)productionKey.GetValue("ArtPath");
                string      productionExePath = (String)productionKey.GetValue("EXE Path");

                stepCount++;

                try
                {
                    if (RegistryAccess.DoesUserHaveAccess(rootKey, BuiltinUsersSID, System.Security.AccessControl.RegistryRights.FullControl) == false)
                    {
                        RegistryAccess.SetUserAccessBySID(rootKey, BuiltinUsersSID, System.Security.AccessControl.RegistryRights.FullControl);
                    }
                }
                catch (Exception ex)
                {
                    this.Context.LogMessage(ex.ToString());

                    // Ignore security exceptions for Windows8 and up.
                    if (WindowsVersion < Windows8Version)
                    {
                        throw;
                    }


                    //if (WindowsVersion >= 6.2)
                    //{
                    //    if (MessageBox.Show("There was an error granting permissions to the BUILTIN\\User account to: " + rootKey + "\r\n\r\nThis is specific to Windows 8, and can be ignored. Continue Installation?", "Permissions Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
                    //        throw;
                    //}
                    //else
                    //    throw;
                }

                stepCount++;

                RegistryKey developmentKey = rootKey.OpenSubKey("1.2", true);
                if (developmentKey == null)
                {
                    developmentKey = rootKey.CreateSubKey("1.2", RegistryKeyPermissionCheck.ReadWriteSubTree);
                }

                stepCount++;

                //if (developmentKey.GetValue("Allow3DAcceleration", null) == null)
                developmentKey.SetValue("Allow3DAcceleration", 1, RegistryValueKind.DWord);

                stepCount++;

                //if (developmentKey.GetValue("AllowSecondary", null) == null)
                developmentKey.SetValue("AllowSecondary", 1, RegistryValueKind.DWord);

                stepCount++;

                //if (developmentKey.GetValue("ArtPath", null) == null)
                developmentKey.SetValue("ArtPath", Path.Combine(this.Context.Parameters["targetpath"], Integration.LobbyType.Production.ToString() + "\\Artwork"), RegistryValueKind.String);

                developmentKey.SetValue("ProductionArtPath", Path.Combine(this.Context.Parameters["targetpath"], Integration.LobbyType.Production.ToString() + "\\Artwork"), RegistryValueKind.String);

                developmentKey.SetValue("BetaArtPath", Path.Combine(this.Context.Parameters["targetpath"], Integration.LobbyType.Beta.ToString() + "\\Artwork"), RegistryValueKind.String);

                stepCount++;

                //if (developmentKey.GetValue("Bandwidth", null) == null)
                developmentKey.SetValue("Bandwidth", 2, RegistryValueKind.DWord);

                stepCount++;

                // Don't delete this, might re-add post css beta.
                // If there is already a CfgFile entry, then store it for uninstallation only if there
                // is not already a PreviousCfgFile entry.
                //string cfgFile = (String)developmentKey.GetValue("CfgFile", null);
                //if (cfgFile != null)
                //{
                //    if (developmentKey.GetValue("PreviousCfgFile", null) == null)
                //        developmentKey.SetValue("PreviousCfgFile", cfgFile, RegistryValueKind.String);
                //}

                developmentKey.SetValue("CfgFile", "http://acss.alleg.net/allegiance.txt", RegistryValueKind.String);

                developmentKey.SetValue("ProductionCfgFile", "http://acss.alleg.net/allegiance.txt", RegistryValueKind.String);

                developmentKey.SetValue("BetaCfgFile", "http://acss.alleg.net/allegiance-beta.txt", RegistryValueKind.String);

                stepCount++;

                //if (developmentKey.GetValue("CharacterName", null) == null)
                developmentKey.SetValue("CharacterName", String.Empty, RegistryValueKind.String);

                stepCount++;

                //if (developmentKey.GetValue("CombatFullscreenXSize", null) == null)
                developmentKey.SetValue("CombatFullscreenXSize", 800, RegistryValueKind.DWord);

                stepCount++;

                //if (developmentKey.GetValue("CombatFullscreenYSize", null) == null)
                developmentKey.SetValue("CombatFullscreenYSize", 600, RegistryValueKind.DWord);

                stepCount++;

                //if (developmentKey.GetValue("CombatXSize", null) == null)
                developmentKey.SetValue("CombatXSize", 800, RegistryValueKind.DWord);

                stepCount++;

                //if (developmentKey.GetValue("CombatYSize", null) == null)
                developmentKey.SetValue("CombatYSize", 600, RegistryValueKind.DWord);

                stepCount++;

                //if (developmentKey.GetValue("DeadZone", null) == null)
                developmentKey.SetValue("DeadZone", 30, RegistryValueKind.DWord);

                stepCount++;

                // Don't delete this, might re-add post beta.
                //string exePath = (String)developmentKey.GetValue("EXE Path", null);
                //if (exePath != null)
                //{
                //    if (developmentKey.GetValue("PreviousEXEPath", null) == null)
                //        developmentKey.SetValue("PreviousEXEPath", exePath, RegistryValueKind.String);
                //}

                developmentKey.SetValue("Lobby Path", this.Context.Parameters["targetpath"].TrimEnd('\\'), RegistryValueKind.String);

                stepCount++;

                developmentKey.SetValue("EXE Path", productionExePath, RegistryValueKind.String);

                stepCount++;

                //if (developmentKey.GetValue("Gamma", null) == null)
                developmentKey.SetValue("Gamma", 1.13, RegistryValueKind.String);

                stepCount++;

                //if (developmentKey.GetValue("HasTrained", null) == null)
                developmentKey.SetValue("HasTrained", 1, RegistryValueKind.DWord);

                stepCount++;

                //if (developmentKey.GetValue("LogToFile", null) == null)
                developmentKey.SetValue("LogToFile", 1, RegistryValueKind.String);

                stepCount++;

                //if (developmentKey.GetValue("Music", null) == null)
                developmentKey.SetValue("Music", 1, RegistryValueKind.DWord);

                stepCount++;

                //if (developmentKey.GetValue("OutputDebugString", null) == null)
                developmentKey.SetValue("OutputDebugString", 1, RegistryValueKind.DWord);

                stepCount++;

                developmentKey.SetValue("ClientService", "https://acss.alleg.net/CSSServer/ClientService.svc", RegistryValueKind.String);

                stepCount++;

                developmentKey.SetValue("ManagementWebRoot", "http://acss.alleg.net", RegistryValueKind.String);

                stepCount++;

                try
                {
                    if (FileSystemAccess.DoesUserHaveAccessToDirectory(artPath, BuiltinUsersSID, System.Security.AccessControl.FileSystemRights.FullControl) == false)
                    {
                        FileSystemAccess.SetDirectoryAccessBySID(artPath, BuiltinUsersSID, System.Security.AccessControl.FileSystemRights.FullControl);
                    }
                }
                catch (Exception ex)
                {
                    this.Context.LogMessage(ex.ToString());

                    // Ignore security exceptions for Windows8 and up.
                    if (WindowsVersion < Windows8Version)
                    {
                        throw;
                    }

                    //if (WindowsVersion >= 6.2)
                    //{
                    //    if (MessageBox.Show("There was an error granting permissions to the BUILTIN\\User account to: " + artPath + "\r\n\r\nThis is specific to Windows 8, and can be ignored. Continue Installation?", "Permissions Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
                    //        throw;
                    //}
                    //else
                    //    throw;
                }

                stepCount++;

                try
                {
                    if (FileSystemAccess.DoesUserHaveAccessToDirectory(productionExePath, BuiltinUsersSID, System.Security.AccessControl.FileSystemRights.FullControl) == false)
                    {
                        FileSystemAccess.SetDirectoryAccessBySID(productionExePath, BuiltinUsersSID, System.Security.AccessControl.FileSystemRights.FullControl);
                    }
                }
                catch (Exception ex)
                {
                    this.Context.LogMessage(ex.ToString());

                    // Ignore security exceptions for Windows8 and up.
                    if (WindowsVersion < Windows8Version)
                    {
                        throw;
                    }

                    //if (WindowsVersion >= 6.2)
                    //{
                    //    if (MessageBox.Show("There was an error granting permissions to the BUILTIN\\User account to: " + productionExePath + "\r\n\r\nThis is specific to Windows 8, and can be ignored. Continue Installation?", "Permissions Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
                    //        throw;
                    //}
                    //else
                    //    throw;
                }

                stepCount++;

                try
                {
                    if (FileSystemAccess.DoesUserHaveAccessToDirectory(this.Context.Parameters["targetpath"], BuiltinUsersSID, System.Security.AccessControl.FileSystemRights.FullControl) == false)
                    {
                        FileSystemAccess.SetDirectoryAccessBySID(this.Context.Parameters["targetpath"], BuiltinUsersSID, System.Security.AccessControl.FileSystemRights.FullControl);
                    }
                }
                catch (Exception ex)
                {
                    this.Context.LogMessage(ex.ToString());

                    // Ignore security exceptions for Windows8 and up.
                    if (WindowsVersion < Windows8Version)
                    {
                        throw;
                    }

                    //if (WindowsVersion >= 6.2)
                    //{
                    //    if (MessageBox.Show("There was an error granting permissions to the BUILTIN\\User account to: " + this.Context.Parameters["targetpath"] + "\r\n\r\nThis is specific to Windows 8, and can be ignored. Continue Installation?", "Permissions Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
                    //        throw;
                    //}
                    //else
                    //    throw;
                }

                stepCount++;

                CopyProgress copyProgressBeta = new CopyProgress();
                copyProgressBeta.TopMost = true;
                //copyProgress.MinimizeBox = false;
                copyProgressBeta.SourceDirectory = artPath;
                copyProgressBeta.TargetDirectory = Path.Combine(Path.Combine(this.Context.Parameters["targetpath"], LobbyType.Beta.ToString()), "Artwork");
                copyProgressBeta.LobbyType       = LobbyType.Beta;

                if (copyProgressBeta.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    throw new InstallException("Beta Artwork file copy was canceled.");
                }

                stepCount++;

                CopyProgress copyProgressProduction = new CopyProgress();
                copyProgressProduction.TopMost = true;
                //copyProgress.MinimizeBox = false;
                copyProgressProduction.SourceDirectory = artPath;
                copyProgressProduction.TargetDirectory = Path.Combine(Path.Combine(this.Context.Parameters["targetpath"], LobbyType.Production.ToString()), "Artwork");
                copyProgressProduction.LobbyType       = LobbyType.Production;

                if (copyProgressProduction.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    throw new InstallException("Production Artwork file copy was canceled.");
                }


                base.OnAfterInstall(savedState);
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Windows Version: " + WindowsVersion +
                    "\r\nStep Count: " + stepCount +
                    "\r\n\r\n" + ex.ToString(), "BetaInstall::OnAfterInstall() - Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }