Esempio n. 1
0
        /// <summary>
        /// Create a new instance of this command
        /// </summary>
        /// <param name="manager">The setting manager to use</param>
        public LaunchGameCommand(SettingManager manager)
        {
            ISettingFactory settingFactory = new WpfPropertySettingManagerFactory();

            this.manager   = settingFactory.GetSettingsManager();
            settingManager = manager;
        }
Esempio n. 2
0
        /// <summary>
        /// Do the pre installation steps
        /// </summary>
        /// <param name="zipArchive"></param>
        private void DoPreInstallSteps(ZipArchive zipArchive)
        {
            ISettingFactory settingFactory      = new WpfPropertySettingManagerFactory();
            SettingManager  applicationSettings = settingFactory.GetSettingsManager();
            string          preInstallFileName  = applicationSettings.GetValue <string>("PreInstall");
            ZipArchiveEntry preInstall          = GetSpecificEntry(preInstallFileName, zipArchive);

            if (preInstall != null)
            {
                using (StreamReader fileReader = new StreamReader(preInstall.OpenEntryStream()))
                {
                    string line       = string.Empty;
                    string gameFolder = settingManager.GetValue <string>("GameFolder");
                    gameFolder = Path.GetFullPath(gameFolder);
                    while ((line = fileReader.ReadLine()) != null)
                    {
                        string fullPath = gameFolder + line;
                        fullPath = Path.GetFullPath(fullPath);
                        FileInfo fileInfo     = new FileInfo(fullPath);
                        string   targetFolder = fileInfo.DirectoryName + Path.DirectorySeparatorChar;
                        if (!File.Exists(gameFolder + "S4_Main.exe") || !targetFolder.StartsWith(gameFolder))
                        {
                            continue;
                        }

                        if (File.Exists(fullPath))
                        {
                            File.Delete(fullPath);
                            continue;
                        }
                        DeleteFolder(fullPath);
                    }
                }
            }
        }
        /// <summary>
        /// Create a new instance of this class
        /// </summary>
        /// <param name="updateBranch">The update branch to use</param>
        /// <param name="parentWindow">The parent window which was calling the factory</param>
        /// <param name="showIfLocalIsNewer">Show if local version is newer</param>
        public UpdateClientFactory(UpdateBranchEnum updateBranch, Window parentWindow, bool showIfLocalIsNewer)
        {
            ISettingFactory factory = new WpfPropertySettingManagerFactory();

            manager                 = factory.GetSettingsManager();
            this.updateBranch       = updateBranch;
            this.parentWindow       = parentWindow;
            this.showIfLocalIsNewer = showIfLocalIsNewer;
        }
Esempio n. 4
0
        /// <inheritdoc/>
        public override bool Execute(bool previousTaskState)
        {
            string targetFolder = settingManager.GetValue <string>("GameFolder");
            string gameFile     = targetFolder + "S4_Main.exe";

            if (targetFolder == null || !File.Exists(gameFile))
            {
                return(false);
            }

            ISettingFactory settingFactory = new WpfPropertySettingManagerFactory();
            SettingManager  staticSettings = settingFactory.GetSettingsManager();
            Byte            speedByte      = staticSettings.GetValue <Byte>(speedMode.ToString());
            long            speedPosition  = staticSettings.GetValue <long>("PatchPosition");

            using (Stream writer = new FileStream((gameFile), FileMode.Open, FileAccess.ReadWrite))
            {
                writer.Position = speedPosition;
                writer.WriteByte(speedByte);
            }

            return(true);
        }
        public InstallationFromRegistryCommand()
        {
            ISettingFactory settingFactory = new WpfPropertySettingManagerFactory();

            manager = settingFactory.GetSettingsManager();
        }
Esempio n. 6
0
        /// <summary>
        /// Create a new instance of this model
        /// </summary>
        /// <param name="window"></param>
        public MainWindowModel(Window window) : base(window, true)
        {
            IconVisible        = false;
            updateSearched     = false;
            CloseWindowCommand = new CloseApplicationCommand();

            SetWindowTitle();

            object dockArea = window.FindName("DP_ContentDock");

            if (dockArea is DockPanel panel)
            {
                ISettingFactory settingFactory = new WpfPropertySettingManagerFactory();
                SettingManager  wpfSettings    = settingFactory.GetSettingsManager();

                contentDock = panel;

                BrowserUserControl localBrowser     = new BrowserUserControl(string.Empty);
                ICommand           openLocalBrowser = new MultiCommand(new List <ICommand>()
                {
                    new OpenControlToPanel(contentDock, localBrowser, false),
                    new ChangeBrowserContentCommand(localBrowser)
                });

                BrowserUserControl remoteBrowser     = new BrowserUserControl(string.Empty, new RemoteDocumentManagerFactory(new TimeSpan(0, 30, 0)));
                ICommand           openRemoteBrowser = new MultiCommand(new List <ICommand>()
                {
                    new OpenControlToPanel(contentDock, remoteBrowser, false),
                    new ChangeBrowserContentCommand(remoteBrowser)
                });

                OpenNewsCommand      = openRemoteBrowser;
                OpenChangelogCommand = openLocalBrowser;
                OpenDisclamerCommand = openLocalBrowser;
                OpenAboutCommand     = openLocalBrowser;
                OpenLicenseCommand   = openLocalBrowser;

                OpenHDPatchCommand = new OpenControlToPanel(contentDock, new ComingSoonControl());
                OpenMapCommand     = new OpenControlToPanel(contentDock, new MapUserControl());
                LaunchGameCommand  = new OpenControlToPanel(contentDock, new PatchVersionSelectionUserControl(window));
                OpenSettingCommand = new OpenControlToPanel(contentDock, new SettingsUserControl(currentWindow));
                ComingSoonCommand  = new OpenControlToPanel(contentDock, new ComingSoonControl());

                ReportIssueCommand = new OpenLinkCommand(wpfSettings.GetValue <string>("ReportIssueLink"));
                OpenEditorCommand  = new StartEditorCommand(settingManager);
                OpenSettlersConfigurationCommand = new StartSettlersConfigCommand(settingManager);
                OpenSavesFolderCommand           = new OpenFolderCommand(Environment.GetFolderPath(
                                                                             Environment.SpecialFolder.MyDocuments)
                                                                         + "/TheSettlers4/Save/"
                                                                         );

                string gameFolder    = settingManager.GetValue <string>("GameFolder");
                string textureChange = gameFolder + "Texturenwechsler.bat";
                OpenTextureChangerCommand = new StartProgramCommand(textureChange);

                OpenNewsCommand.Execute("News.md");
            }

            ChangeGroupVisiblity    = new ToggleSubGroupVisibilityCommand(currentWindow);
            window.ContentRendered += (sender, data) =>
            {
                if (updateSearched)
                {
                    return;
                }
                updateSearched = true;
                CheckForUpdateIfNeeded(window);
            };
        }