Exemplo n.º 1
0
 private void VerifyPath(LauncherPath path, bool throwErrors)
 {
     if (throwErrors && !Directory.Exists(path.GetFullPath()))
     {
         throw new DirectoryNotFoundException(path.GetPossiblyRelativePath());
     }
 }
Exemplo n.º 2
0
        private bool VerifyDatabase()
        {
            bool check = false;

            try
            {
                if (File.Exists(Path.Combine(LauncherPath.GetDataDirectory(), DbDataSourceAdapter.DatabaseFileName)))
                {
                    check = true;
                    // Still attempt to delete the init database here for people that manually update (not installed)
                    if (File.Exists(DbDataSourceAdapter.InitDatabaseFileName))
                    {
                        File.Delete(DbDataSourceAdapter.InitDatabaseFileName);
                    }
                    return(check);
                }

                check = InitFileCheck(DbDataSourceAdapter.DatabaseFileName, DbDataSourceAdapter.InitDatabaseFileName, false);

                if (!check)
                {
                    MessageBox.Show(this, "Initialization failure. Could not find DoomLauncher database",
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                Util.DisplayUnexpectedException(this, ex);
            }

            return(check);
        }
Exemplo n.º 3
0
        private bool HandleGameFileIWad(IGameFile gameFile, StringBuilder sb, LauncherPath gameFileDirectory, LauncherPath tempDirectory)
        {
            try
            {
                using (ZipArchive za = ZipFile.OpenRead(Path.Combine(gameFileDirectory.GetFullPath(), gameFile.FileName)))
                {
                    ZipArchiveEntry zae         = za.Entries.First();
                    string          extractFile = Path.Combine(tempDirectory.GetFullPath(), zae.Name);
                    if (ExtractFiles)
                    {
                        zae.ExtractToFile(extractFile, true);
                    }

                    sb.Append(string.Format(" -iwad \"{0}\" ", extractFile));
                }
            }
            catch (FileNotFoundException)
            {
                LastError = string.Format("File not found: {0}", gameFile.FileName);
                return(false);
            }
            catch
            {
                LastError = string.Format("There was an issue with the IWad: {0}. Corrupted file?", gameFile.FileName);
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        private List <string> GetFilesFromGameFileSettings(IGameFile gameFile, LauncherPath gameFileDirectory, LauncherPath tempDirectory, bool checkSpecific, string[] extensions)
        {
            List <string> files = new List <string>();

            using (ZipArchive za = ZipFile.OpenRead(Path.Combine(gameFileDirectory.GetFullPath(), gameFile.FileName)))
            {
                var entries = za.Entries.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.Contains('.') &&
                                               extensions.Any(y => y.Equals(Path.GetExtension(x.Name), StringComparison.OrdinalIgnoreCase)));

                foreach (ZipArchiveEntry zae in entries)
                {
                    bool useFile = true;

                    if (checkSpecific && SpecificFiles != null && SpecificFiles.Length > 0)
                    {
                        useFile = SpecificFiles.Contains(zae.FullName);
                    }

                    if (useFile)
                    {
                        string extractFile = Path.Combine(tempDirectory.GetFullPath(), zae.Name);
                        if (ExtractFiles)
                        {
                            zae.ExtractToFile(extractFile, true);
                        }
                        files.Add(extractFile);
                    }
                }
            }

            return(files);
        }
Exemplo n.º 5
0
        private string GetRelativeDirectory(string file)
        {
            string current = LauncherPath.GetDataDirectory();

            if (file.Contains(current))
            {
                string[] filePath    = file.Split(Path.DirectorySeparatorChar);
                string[] currentPath = current.Split(Path.DirectorySeparatorChar);

                string[] relativePath = filePath.Except(currentPath).ToArray();

                StringBuilder sb = new StringBuilder();

                foreach (string str in relativePath)
                {
                    sb.Append(str);
                    sb.Append(Path.DirectorySeparatorChar);
                }

                if (sb.Length > 1)
                {
                    sb.Remove(sb.Length - 1, 1);
                }

                return(sb.ToString());
            }

            return(file);
        }
Exemplo n.º 6
0
        public void Init(IDataSourceAdapter adapter)
        {
            DataSourceAdapter = adapter;
            AppConfiguration  = new AppConfiguration(adapter);
            TagMapLookup      = new TagMapLookup(adapter);
            DefaultImage      = Image.FromFile(Path.Combine(LauncherPath.GetDataDirectory(), "TileImages", "DoomLauncherTile.png"));

            UpdateTags();
        }
Exemplo n.º 7
0
        private void SetChildDirectories(IEnumerable <IConfigurationData> config)
        {
            string gameFileDir = GetValue(config, "GameFileDirectory");

            ScreenshotDirectory = SetChildDirectory(gameFileDir, "Screenshots");
            TempDirectory       = SetChildDirectory(gameFileDir, "Temp");
            DemoDirectory       = SetChildDirectory(gameFileDir, "Demos");
            SaveGameDirectory   = SetChildDirectory(gameFileDir, "SaveGames");
            GameFileDirectory   = new LauncherPath(gameFileDir);
        }
        public SyncLibraryHandler(IGameFileDataSourceAdapter dbDataSource, IGameFileDataSourceAdapter syncDataSource,
                                  LauncherPath gameFileDirectory, LauncherPath tempDirectory)
        {
            DbDataSource      = dbDataSource;
            SyncDataSource    = syncDataSource;
            GameFileDirectory = gameFileDirectory;
            TempDirectory     = tempDirectory;

            SyncFileCurrent = SyncFileCount = 0;
        }
Exemplo n.º 9
0
        public override bool Equals(object obj)
        {
            LauncherPath path = obj as LauncherPath;

            if (path != null)
            {
                return(GetFullPath() == path.GetFullPath());
            }

            return(false);
        }
Exemplo n.º 10
0
 public bool Execute()
 {
     if (LauncherPath.IsInstalled())
     {
         return(ExecuteInstallUpdate());
     }
     else
     {
         return(ExecuteNonInstallUpdate());
     }
 }
Exemplo n.º 11
0
        public SyncLibraryHandler(IGameFileDataSourceAdapter dbDataSource, IGameFileDataSourceAdapter syncDataSource,
                                  LauncherPath gameFileDirectory, LauncherPath tempDirectory, string[] dateParseFormats)
        {
            DbDataSource      = dbDataSource;
            SyncDataSource    = syncDataSource;
            GameFileDirectory = gameFileDirectory;
            TempDirectory     = tempDirectory;
            DateParseFormats  = dateParseFormats;

            SyncFileCurrent = SyncFileCount = 0;
        }
Exemplo n.º 12
0
        private void browseButton_Click(object sender, EventArgs e)
        {
            LauncherPath        path   = new LauncherPath(this.m_gameFileDirectory.Text);
            FolderBrowserDialog dialog = new FolderBrowserDialog {
                SelectedPath = path.GetFullPath()
            };

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                this.m_gameFileDirectory.Text = new LauncherPath(dialog.SelectedPath).GetPossiblyRelativePath();
            }
        }
Exemplo n.º 13
0
        private void VerifyPath(LauncherPath path, bool throwErrors)
        {
            bool exists = Directory.Exists(path.GetFullPath());

            if (throwErrors && !exists)
            {
                throw new DirectoryNotFoundException(path.GetPossiblyRelativePath());
            }

            if (!exists)
            {
                Directory.CreateDirectory(path.GetFullPath());
            }
        }
Exemplo n.º 14
0
        private void CleanupBackupDirectory()
        {
            string[]        files     = Directory.GetFiles(Path.Combine(LauncherPath.GetDataDirectory(), "Backup"), "*.sqlite");
            List <FileInfo> filesInfo = new List <FileInfo>();

            Array.ForEach(files, x => filesInfo.Add(new FileInfo(x)));
            List <FileInfo> filesInfoOrdered = filesInfo.OrderBy(x => x.CreationTime).ToList();

            while (filesInfoOrdered.Count > 10)
            {
                filesInfoOrdered.First().Delete();
                filesInfoOrdered.RemoveAt(0);
            }
        }
Exemplo n.º 15
0
        public void Pre_0_9_2()
        {
            DataTable dt = DataAccess.ExecuteSelect("select name from sqlite_master where type='table' and name='Configuration';").Tables[0];

            if (dt.Rows.Count == 0)
            {
                string query = @"CREATE TABLE 'Configuration' (
	                'ConfigID'	INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	                'Name'	TEXT NOT NULL,
	                'Value'	TEXT NOT NULL,
	                'AvailableValues'	TEXT NOT NULL,
	                'UserCanModify'	INTEGER);"    ;

                DataAccess.ExecuteNonQuery(query);

                query = string.Format(@"insert into Configuration (Name, Value, AvailableValues, UserCanModify) values('IdGamesUrl', 'http://www.doomworld.com/idgames/', '', 1);
                insert into Configuration (Name, Value, AvailableValues, UserCanModify) values('ApiPage', 'api/api.php', '', 1);
                insert into Configuration (Name, Value, AvailableValues, UserCanModify) values('MirrorUrl', 'ftp://mancubus.net/pub/idgames/', 'Germany;ftp://ftp.fu-berlin.de/pc/games/idgames/;Idaho;ftp://mirrors.syringanetworks.net/idgames/;Greece;ftp://ftp.ntua.gr/pub/vendors/idgames/;Texas;ftp://mancubus.net/pub/idgames/;New York;http://youfailit.net/pub/idgames/;Florida;http://www.gamers.org/pub/idgames/;', 1);
                insert into Configuration (Name, Value, AvailableValues, UserCanModify) values('ScreenshotCaptureDirectories', '', '', 1);
                insert into Configuration (Name, Value, AvailableValues, UserCanModify) values('DateParseFormats', 'dd/M/yy;dd/MM/yyyy;dd MMMM yyyy;', '', 0);
                insert into Configuration (Name, Value, AvailableValues, UserCanModify) values('CleanTemp', 'true', '', 0);
                insert into Configuration (Name, Value, AvailableValues, UserCanModify) values('GameFileDirectory', '{0}', '', 0);
                insert into Configuration (Name, Value, AvailableValues, UserCanModify) values('ScreenshotDirectory', '{1}', '', 0);
                insert into Configuration (Name, Value, AvailableValues, UserCanModify) values('TempDirectory', '{2}', '', 0);
                insert into Configuration (Name, Value, AvailableValues, UserCanModify) values('GameWadDirectory', '{3}', '', 0);
                insert into Configuration (Name, Value, AvailableValues, UserCanModify) values('DemoDirectory', '{4}', '', 0);
                insert into Configuration (Name, Value, AvailableValues, UserCanModify) values('SaveGameDirectory', '{5}', '', 0);",
                                      ConfigurationManager.AppSettings["GameFileDirectory"], ConfigurationManager.AppSettings["ScreenshotDirectory"], ConfigurationManager.AppSettings["TempDirectory"],
                                      ConfigurationManager.AppSettings["GameWadDirectory"], ConfigurationManager.AppSettings["DemoDirectory"], ConfigurationManager.AppSettings["GameFileDirectory"] + "SaveGames\\");

                DataAccess.ExecuteNonQuery(query);

                DirectoryInfo di = new DirectoryInfo(Path.Combine(LauncherPath.GetDataDirectory(), ConfigurationManager.AppSettings["GameFileDirectory"], "SaveGames"));
                if (!di.Exists)
                {
                    di.Create();
                }
            }

            dt = DataAccess.ExecuteSelect("pragma table_info(Files);").Tables[0];

            if (!dt.Select("name = 'OriginalFileName'").Any())
            {
                string query = @"alter table Files add column 'OriginalFileName' TEXT;
                alter table Files add column 'OriginalFilePath' TEXT;";

                DataAccess.ExecuteNonQuery(query);
            }
        }
Exemplo n.º 16
0
        private IArchiveReader CreateArchiveReader(IGameFile gameFile, LauncherPath gameFileDirectory)
        {
            string file = Path.Combine(gameFileDirectory.GetFullPath(), gameFile.FileName);

            // If the unmanaged file is a pk3 then ArchiveReader.Create will read it as a zip and try to unpack
            // Return FileArchiveReader instead so the pk3 will be added as a file
            // Zip extensions are ignored in this case since Doom Launcher's base functionality revovles around reading zip contents
            // SpecificFilesForm will also read zip files explicitly to allow user to select files in the archive
            if (gameFile.IsUnmanaged() && !Path.GetExtension(gameFile.FileName).Equals(".zip", StringComparison.OrdinalIgnoreCase))
            {
                return(new FileArchiveReader(file));
            }

            return(ArchiveReader.Create(file));
        }
Exemplo n.º 17
0
        private static LauncherPath GetGameFileDir(string gameFileDir)
        {
            if (gameFileDir == "GameFiles\\")
            {
                string dataDir = LauncherPath.GetDataDirectory();
                if (!Directory.Exists(dataDir))
                {
                    Directory.CreateDirectory(dataDir);
                    Directory.CreateDirectory(Path.Combine(dataDir, gameFileDir));
                }

                return(new LauncherPath(Path.Combine(dataDir, gameFileDir)));
            }

            return(new LauncherPath(gameFileDir));
        }
Exemplo n.º 18
0
        private List <string> GetFilesFromGameFileSettings(IGameFile gameFile, LauncherPath gameFileDirectory, LauncherPath tempDirectory,
                                                           bool checkSpecific, string[] extensions)
        {
            List <string> files = new List <string>();

            using (IArchiveReader reader = CreateArchiveReader(gameFile, gameFileDirectory))
            {
                IEnumerable <IArchiveEntry> entries;
                if (checkSpecific && SpecificFiles != null && SpecificFiles.Length > 0)
                {
                    entries = reader.Entries;
                }
                else
                {
                    entries = reader.Entries.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.Contains('.') &&
                                                   extensions.Any(y => y.Equals(Path.GetExtension(x.Name), StringComparison.OrdinalIgnoreCase)));
                }

                foreach (IArchiveEntry entry in entries)
                {
                    bool useFile = true;
                    if (checkSpecific && SpecificFiles != null && SpecificFiles.Length > 0)
                    {
                        useFile = SpecificFiles.Contains(entry.FullName);
                    }

                    if (useFile)
                    {
                        if (entry.ExtractRequired)
                        {
                            string extractFile = Path.Combine(tempDirectory.GetFullPath(), entry.Name);
                            if (ExtractFiles)
                            {
                                entry.ExtractToFile(extractFile, true);
                            }
                            files.Add(extractFile);
                        }
                        else
                        {
                            files.Add(entry.FullName);
                        }
                    }
                }
            }

            return(files);
        }
Exemplo n.º 19
0
        private async Task Initialize()
        {
            string     dataSource = Path.Combine(LauncherPath.GetDataDirectory(), DbDataSourceAdapter.DatabaseFileName);
            DataAccess access     = new DataAccess(new SqliteDatabaseAdapter(), DbDataSourceAdapter.CreateConnectionString(dataSource));

            m_versionHandler = new VersionHandler(access, DbDataSourceAdapter.CreateAdapter(true), AppConfiguration);

            if (m_versionHandler.UpdateRequired())
            {
                m_versionHandler.UpdateProgress += handler_UpdateProgress;

                m_progressBarUpdate = CreateProgressBar("Updating...", ProgressBarStyle.Continuous);
                ProgressBarStart(m_progressBarUpdate);

                await Task.Run(() => ExecuteVersionUpdate());

                ProgressBarEnd(m_progressBarUpdate);

                AppConfiguration.Refresh(); //We have to refresh here because a column may have been added to the Configuration table
            }

            if (AppConfiguration.CleanTemp)
            {
                CleanTempDirectory();
            }

            DirectoryDataSourceAdapter = new DirectoryDataSourceAdapter(AppConfiguration.GameFileDirectory);
            DataCache.Instance.Init(DataSourceAdapter);
            DataCache.Instance.AppConfiguration.GameFileViewTypeChanged += AppConfiguration_GameFileViewTypeChanged;
            DataCache.Instance.TagMapLookup.TagMappingChanged           += TagMapLookup_TagMappingChanged;
            DataCache.Instance.TagsChanged += DataCache_TagsChanged;

            CleanUpFiles();

            SetupTabs();
            RebuildUtilityToolStrip();
            BuildUtilityToolStrip();

            InitTagSelectControl();
            InitDownloadView();

            ctrlAssociationView.Initialize(DataSourceAdapter, AppConfiguration);
            ctrlAssociationView.FileDeleted        += ctrlAssociationView_FileDeleted;
            ctrlAssociationView.FileOrderChanged   += ctrlAssociationView_FileOrderChanged;
            ctrlAssociationView.RequestScreenshots += CtrlAssociationView_RequestScreenshots;
        }
Exemplo n.º 20
0
 public void Initialize(LauncherPath gameFileDirectory, IEnumerable <IGameFileDataSource> gameFiles, string[] supportedExtensions, string[] specificFiles)
 {
     if (specificFiles != null)
     {
         this.m_specificFiles = specificFiles.ToArray <string>();
     }
     this.m_supportedExtensions = supportedExtensions.ToArray <string>();
     this.m_gameFiles           = gameFiles.ToList <IGameFileDataSource>();
     this.m_directory           = gameFileDirectory;
     try
     {
         this.SetGrid();
     }
     catch (Exception exception)
     {
         DoomLauncher.Util.DisplayUnexpectedException(this, exception);
     }
 }
Exemplo n.º 21
0
        private void BackupDatabase(string dataSource)
        {
            FileInfo fi = new FileInfo(dataSource);

            if (fi.Exists)
            {
                Directory.CreateDirectory(Path.Combine(LauncherPath.GetDataDirectory(), "Backup"));
                string backupName = GetBackupFileName(fi);

                FileInfo fiBackup = new FileInfo(backupName);
                if (!fiBackup.Exists)
                {
                    fi.CopyTo(backupName);
                }

                CleanupBackupDirectory();
            }
        }
        public void Initialize(LauncherPath gameFileDirectory, IEnumerable <IGameFile> gameFiles, string[] supportedExtensions, string[] specificFiles, LauncherPath tempDirectory)
        {
            if (specificFiles != null)
            {
                m_specificFiles = specificFiles.ToArray();
            }
            m_supportedExtensions = supportedExtensions.ToArray();
            m_gameFiles           = gameFiles.ToList();
            m_directory           = gameFileDirectory;
            m_temp = tempDirectory;

            try
            {
                SetGrid();
            }
            catch (Exception ex)
            {
                Util.DisplayUnexpectedException(this, ex);
            }
        }
Exemplo n.º 23
0
 public void Initialize(IDataSourceAdapter adapter, LauncherPath screenshotDirectory, LauncherPath demoDirectory, LauncherPath savegameDirectory)
 {
     this.DataSourceAdapter   = adapter;
     this.ScreenshotDirectory = screenshotDirectory;
     this.SaveGameDirectory   = savegameDirectory;
     this.ctrlScreenshotView.DataSourceAdapter = this.DataSourceAdapter;
     this.ctrlScreenshotView.DataDirectory     = this.ScreenshotDirectory;
     this.ctrlScreenshotView.FileType          = FileType.Screenshot;
     this.ctrlScreenshotView.SetContextMenu(this.BuildContextMenuStrip(this.ctrlScreenshotView));
     this.ctrlSaveGameView.DataSourceAdapter = this.DataSourceAdapter;
     this.ctrlSaveGameView.DataDirectory     = this.SaveGameDirectory;
     this.ctrlSaveGameView.FileType          = FileType.SaveGame;
     this.ctrlSaveGameView.SetContextMenu(this.BuildContextMenuStrip(this.ctrlSaveGameView));
     this.ctrlDemoView.DataSourceAdapter = this.DataSourceAdapter;
     this.ctrlDemoView.DataDirectory     = demoDirectory;
     this.ctrlDemoView.FileType          = FileType.Demo;
     this.ctrlDemoView.SetContextMenu(this.BuildContextMenuStrip(this.ctrlDemoView));
     this.ctrlViewStats.DataSourceAdapter = this.DataSourceAdapter;
     this.ctrlViewStats.SetContextMenu(this.BuildContextMenuStrip(this.ctrlViewStats));
 }
Exemplo n.º 24
0
        private bool HandleGameFile(IGameFile gameFile, List <string> launchFiles, LauncherPath gameFileDirectory, LauncherPath tempDirectory,
                                    ISourcePortData sourcePort, bool checkSpecific)
        {
            try
            {
                string[] extensions = sourcePort.SupportedExtensions.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                launchFiles.AddRange(GetFilesFromGameFileSettings(gameFile, gameFileDirectory, tempDirectory, checkSpecific, extensions));
            }
            catch (FileNotFoundException)
            {
                LastError = string.Format("The game file was not found: {0}", gameFile.FileName);
                return(false);
            }
            catch (InvalidDataException)
            {
                LastError = string.Format("The game file does not appear to be a valid zip file: {0}", gameFile.FileName);
                return(false);
            }

            return(true);
        }
Exemplo n.º 25
0
        public bool Launch(LauncherPath gameFileDirectory, LauncherPath tempDirectory,
                           IGameFile gameFile, ISourcePortData sourcePort, bool isGameFileIwad)
        {
            if (!Directory.Exists(sourcePort.Directory.GetFullPath()))
            {
                LastError = string.Concat("The source port directory does not exist:", Environment.NewLine, Environment.NewLine,
                                          sourcePort.Directory.GetPossiblyRelativePath());
                return(false);
            }

            GameFile   = gameFile;
            SourcePort = sourcePort;

            string launchParameters = GetLaunchParameters(gameFileDirectory, tempDirectory, gameFile, sourcePort, isGameFileIwad);

            if (!string.IsNullOrEmpty(launchParameters))
            {
                Directory.SetCurrentDirectory(sourcePort.Directory.GetFullPath());

                try
                {
                    Process proc = Process.Start(sourcePort.GetFullExecutablePath(), launchParameters);
                    proc.EnableRaisingEvents = true;
                    proc.Exited += proc_Exited;
                }
                catch
                {
                    LastError = "Failed to execute the source port process.";
                    return(false);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 26
0
        //This function is currently only used for loading files by utility (which also uses ISourcePort).
        //This uses Util.ExtractTempFile to avoid extracting files with the same name where the user can have the previous file locked.
        //E.g. opening MAP01 from a pk3, and then opening another MAP01 from a different pk3
        public bool HandleGameFile(IGameFile gameFile, StringBuilder sb, LauncherPath gameFileDirectory, LauncherPath tempDirectory,
                                   ISourcePort sourcePort, List <SpecificFilesForm.SpecificFilePath> pathFiles)
        {
            try
            {
                List <string> files = new List <string>();

                foreach (var pathFile in pathFiles)
                {
                    if (File.Exists(pathFile.ExtractedFile))
                    {
                        using (ZipArchive za = ZipFile.OpenRead(pathFile.ExtractedFile))
                        {
                            var entry = za.Entries.FirstOrDefault(x => x.FullName == pathFile.InternalFilePath);
                            if (entry != null)
                            {
                                files.Add(Util.ExtractTempFile(tempDirectory.GetFullPath(), entry));
                            }
                        }
                    }
                }

                BuildLaunchString(sb, sourcePort, files);
            }
            catch (FileNotFoundException)
            {
                LastError = string.Format("The game file was not found: {0}", gameFile.FileName);
                return(false);
            }
            catch (InvalidDataException)
            {
                LastError = string.Format("The game file does not appear to be a valid zip file: {0}", gameFile.FileName);
                return(false);
            }

            return(true);
        }
        public async Task <ApplicationUpdateInfo> GetUpdateApplicationInfo(Version currentVersion)
        {
            try
            {
                var github = new GitHubClient(new ProductHeaderValue($"{Util.GitHubUser}.{Util.GitHubRepositoryName}"));
                github.SetRequestTimeout(m_timeout);
                var release = await github.Repository.Release.GetLatest(Util.GitHubUser, Util.GitHubRepositoryName);

                if (release != null)
                {
                    Version remoteVersion = new Version(release.Name);
                    if (remoteVersion > currentVersion)
                    {
                        ReleaseAsset asset;
                        if (LauncherPath.IsInstalled())
                        {
                            asset = release.Assets.FirstOrDefault(x => x.Name.EndsWith("_install.zip"));
                        }
                        else
                        {
                            asset = release.Assets.FirstOrDefault(x => x.Name.EndsWith(".zip") && !x.Name.EndsWith("_install.zip"));
                        }

                        if (asset != null)
                        {
                            return(new ApplicationUpdateInfo(remoteVersion, asset.BrowserDownloadUrl, release.HtmlUrl, asset.CreatedAt.LocalDateTime));
                        }
                    }
                }
            }
            catch (RateLimitExceededException)
            {
                return(null);
            }

            return(null);
        }
Exemplo n.º 28
0
        public static List <IFileData> CreateFileAssociation(IWin32Window parent, IDataSourceAdapter adapter, LauncherPath directory, FileType type, IGameFile gameFile, ISourcePortData sourcePort)
        {
            List <IFileData> fileDataList = new List <IFileData>();
            OpenFileDialog   dialog       = new OpenFileDialog();

            if (dialog.ShowDialog(parent) == DialogResult.OK)
            {
                FileDetailsEditForm detailsForm = new FileDetailsEditForm();
                detailsForm.Initialize(adapter);
                detailsForm.StartPosition = FormStartPosition.CenterParent;

                foreach (string file in dialog.FileNames)
                {
                    detailsForm.Description = Path.GetFileName(file);
                    if (sourcePort != null)
                    {
                        detailsForm.SourcePort = sourcePort;
                    }

                    if (detailsForm.ShowDialog(parent) == DialogResult.OK && detailsForm.SourcePort != null)
                    {
                        FileInfo  fi       = new FileInfo(file);
                        IFileData fileData = CreateNewFileDataSource(detailsForm, fi, type, gameFile);

                        fi.CopyTo(Path.Combine(directory.GetFullPath(), fileData.FileName));

                        adapter.InsertFile(fileData);
                        var fileSearch = adapter.GetFiles(gameFile, FileType.Demo).FirstOrDefault(x => x.FileName == fileData.FileName);
                        if (fileSearch != null)
                        {
                            fileData = fileSearch;
                        }
                        fileDataList.Add(fileData);
                    }
                    else if (detailsForm.SourcePort == null)
                    {
                        MessageBox.Show(parent, "A source port must be selected.", "Error", MessageBoxButtons.OK);
                    }
                }
            }

            return(fileDataList);
        }
Exemplo n.º 29
0
 public SaveGameHandler(IDataSourceAdapter adapter, LauncherPath savegameDirectory)
 {
     DataSourceAdapter = adapter;
     SaveGameDirectory = savegameDirectory;
 }
Exemplo n.º 30
0
 public ScreenshotHandler(IDataSourceAdapter adapter, LauncherPath screenshotDirectory)
 {
     DataSourceAdapter   = adapter;
     ScreenshotDirectory = screenshotDirectory;
 }