Exemplo n.º 1
0
        private void Pre_2_6_4_1_Update()
        {
            var adapter     = DbDataSourceAdapter.CreateAdapter();
            var sourcePorts = adapter.GetSourcePorts();
            var stats       = adapter.GetStats();

            foreach (var stat in stats)
            {
                if (!sourcePorts.Any(x => x.SourcePortID == stat.SourcePortID))
                {
                    stat.SourcePortID = -1;
                    adapter.UpdateStats(stat);
                }
            }
        }
Exemplo n.º 2
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.º 3
0
        private void Pre_2_6_3_1()
        {
            DataTable dt = DataAccess.ExecuteSelect("pragma table_info(GameFiles);").Tables[0];

            if (!dt.Select("name = 'SettingsFilesSourcePort'").Any())
            {
                DataAccess.ExecuteNonQuery("alter table GameFiles add column 'SettingsFilesSourcePort' TEXT;");
            }
            if (!dt.Select("name = 'SettingsFilesIWAD'").Any())
            {
                DataAccess.ExecuteNonQuery("alter table GameFiles add column 'SettingsFilesIWAD' TEXT;");
            }

            var adapter       = DbDataSourceAdapter.CreateAdapter();
            var gameFiles     = adapter.GetGameFiles();
            var ports         = adapter.GetSourcePorts().ToDictionary(x => x.SourcePortID, x => x);
            var iwads         = adapter.GetIWads();
            var gameFileIwads = adapter.GetGameFileIWads().ToDictionary(x => iwads.First(y => y.GameFileID == x.GameFileID.Value).IWadID, x => x);

            foreach (var gameFile in gameFiles)
            {
                if (!string.IsNullOrEmpty(gameFile.SettingsFiles))
                {
                    var files = Util.GetAdditionalFiles(adapter, gameFile).Select(x => x.FileName);
                    FileLoadHandlerLegacy filehandler = new FileLoadHandlerLegacy(adapter, gameFile);
                    filehandler.CalculateAdditionalFiles(GetDictionaryData <IGameFile>(gameFile.IWadID, gameFileIwads),
                                                         GetDictionaryData <ISourcePort>(gameFile.SourcePortID, ports));

                    var sourcePortFiles = filehandler.GetSourcePortFiles().Select(x => x.FileName).Where(x => files.Contains(x));
                    var iwadFiles       = filehandler.GetIWadFiles().Select(x => x.FileName).Where(x => files.Contains(x)).Except(sourcePortFiles);

                    gameFile.SettingsFilesSourcePort = string.Join(";", sourcePortFiles.ToArray());
                    gameFile.SettingsFilesIWAD       = string.Join(";", iwadFiles.ToArray());

                    adapter.UpdateGameFile(gameFile);
                }
            }
        }
Exemplo n.º 4
0
        private async void Initialize()
        {
            string     dataSource = Path.Combine(Directory.GetCurrentDirectory(), DbDataSourceAdapter.GetDatabaseFileName());
            DataAccess access     = new DataAccess(new SqliteDatabaseAdapter(), DbDataSourceAdapter.CreateConnectionString(dataSource));

            m_versionHandler = new VersionHandler(access, DataSourceAdapter, 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
            }

            try
            {
                //Only set location and window state if the location is valid, either way we always set Width, Height, and splitter values
                if (ValidatePosition(AppConfiguration))
                {
                    StartPosition = FormStartPosition.Manual;
                    Location      = new Point(AppConfiguration.AppX, AppConfiguration.AppY);

                    WindowState = AppConfiguration.WindowState;
                }

                Width  = AppConfiguration.AppWidth;
                Height = AppConfiguration.AppHeight;

                splitTopBottom.SplitterDistance = AppConfiguration.SplitTopBottom;
                splitLeftRight.SplitterDistance = AppConfiguration.SplitLeftRight;
            }
            catch (DirectoryNotFoundException ex)
            {
                MessageBox.Show(this, string.Format("The directory specified in your settings was incorrect: '{0}'", ex.Message),
                                "Configuration Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tblMain.Enabled = false;
                return;
            }

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

            DirectoryDataSourceAdapter = new DirectoryDataSourceAdapter(AppConfiguration.GameFileDirectory);
            SetupTabs();
            RebuildTagToolStrip();
            RebuildUtilityToolStrip();

            m_downloadView           = new DownloadView();
            m_downloadView.UserPlay += DownloadView_UserPlay;
            m_downloadHandler        = new DownloadHandler(AppConfiguration.TempDirectory, m_downloadView);

            ctrlAssociationView.Initialize(DataSourceAdapter, AppConfiguration);
            ctrlAssociationView.FileDeleted        += ctrlAssociationView_FileDeleted;
            ctrlAssociationView.FileOrderChanged   += ctrlAssociationView_FileOrderChanged;
            ctrlAssociationView.RequestScreenshots += CtrlAssociationView_RequestScreenshots;

            m_splash.Close();

            await CheckFirstInit();

            UpdateLocal();

            SetupSearchFilters();
            HandleTabSelectionChange();
        }
Exemplo n.º 5
0
        private static void CreateDatabaseBackup()
        {
            FileInfo fi = new FileInfo(DbDataSourceAdapter.GetDatabaseFileName());

            fi.CopyTo(string.Format("{0}_{1}.sqlite.bak", DbDataSourceAdapter.GetDatabaseFileName(), Guid.NewGuid().ToString()));
        }