Exemplo n.º 1
0
        public override void SetGameFiles()
        {
            GameFileGetOptions options = new GameFileGetOptions();

            options.SelectFields = m_selectFields;
            base.SetDataSource(m_tagAdapter.GetGameFiles(options, TagDataSource));
        }
Exemplo n.º 2
0
        public virtual void SetGameFiles()
        {
            GameFileGetOptions options = new GameFileGetOptions();

            options.SelectFields = m_selectFields;
            SetDataSource(Adapter.GetGameFiles(options));
        }
Exemplo n.º 3
0
        private void SetDefaultSelections()
        {
            int    port  = (int)AppConfiguration.GetTypedConfigValue(ConfigType.DefaultSourcePort, typeof(int));
            int    iwad  = (int)AppConfiguration.GetTypedConfigValue(ConfigType.DefaultIWad, typeof(int));
            string skill = (string)AppConfiguration.GetTypedConfigValue(ConfigType.DefaultSkill, typeof(string));

            ISourcePort sourcePort = DataSourceAdapter.GetSourcePorts().FirstOrDefault(x => x.SourcePortID == port);

            if (sourcePort != null)
            {
                m_currentPlayForm.SelectedSourcePort = sourcePort;
            }

            IIWadData iwadSource = DataSourceAdapter.GetIWads().FirstOrDefault(x => x.IWadID == Convert.ToInt32(iwad));

            if (iwadSource != null)
            {
                GameFileGetOptions      options      = new GameFileGetOptions(new GameFileSearchField(GameFileFieldType.GameFileID, iwadSource.GameFileID.Value.ToString()));
                IEnumerable <IGameFile> gameFileIwad = DataSourceAdapter.GetGameFiles(options);
                if (gameFileIwad.Any())
                {
                    m_currentPlayForm.SelectedIWad = gameFileIwad.First();
                }
            }

            if (skill != null)
            {
                m_currentPlayForm.SelectedSkill = skill;
            }
        }
Exemplo n.º 4
0
 public override void SetGameFiles(IEnumerable <GameFileSearchField> searchFields)
 {
     if (this.Options != null)
     {
         GameFileGetOptions options = new GameFileGetOptions {
             Limit        = 0x19,
             OrderBy      = 1,
             OrderField   = 7,
             SelectFields = base.m_selectFields
         };
         if ((searchFields != null) && (searchFields.Count <GameFileSearchField>() > 0))
         {
             IEnumerable <IGameFileDataSource> first = new IGameFileDataSource[0];
             foreach (GameFileSearchField field in searchFields)
             {
                 options.SearchField = field;
                 first = first.Union <IGameFileDataSource>(base.m_adapter.GetGameFiles(options));
             }
             base.SetDataSource(first);
         }
         else
         {
             base.SetDataSource(base.m_adapter.GetGameFiles(options));
         }
     }
     else
     {
         base.SetGameFiles(searchFields);
     }
 }
        public override void SetGameFiles(IEnumerable <GameFileSearchField> searchFields)
        {
            if (Options != null)
            {
                GameFileGetOptions options = new GameFileGetOptions();
                options.Limit        = 25;
                options.OrderBy      = OrderType.Desc;
                options.OrderField   = GameFileFieldType.Downloaded;
                options.SelectFields = base.m_selectFields;

                if (searchFields != null && searchFields.Any())
                {
                    IEnumerable <IGameFile> items = new IGameFile[0];

                    foreach (GameFileSearchField sf in searchFields)
                    {
                        options.SearchField = sf;
                        items = items.Union(Adapter.GetGameFiles(options));
                    }

                    base.SetDataSource(items);
                }
                else
                {
                    base.SetDataSource(Adapter.GetGameFiles(options));
                }
            }
            else
            {
                base.SetGameFiles(searchFields);
            }
        }
Exemplo n.º 6
0
        public virtual void SetGameFiles()
        {
            GameFileGetOptions options = new GameFileGetOptions {
                SelectFields = this.m_selectFields
            };

            this.SetDataSource(this.m_adapter.GetGameFiles(options));
        }
Exemplo n.º 7
0
        public override void SetGameFiles()
        {
            GameFileGetOptions options = new GameFileGetOptions {
                SelectFields = base.m_selectFields
            };

            base.SetDataSource(this.m_tagAdapter.GetGameFiles(options, this.TagDataSource));
        }
Exemplo n.º 8
0
        private IGameFileDataSource GetSelectedIWad()
        {
            IIWadDataSource selectedItem = this.cmbIwad.SelectedItem as IIWadDataSource;

            if (selectedItem != null)
            {
                GameFileGetOptions options = new GameFileGetOptions(new GameFileSearchField(GameFileFieldType.GameFileID, selectedItem.GameFileID.ToString()));
                return(this.DataSourceAdapter.GetGameFiles(options).FirstOrDefault <IGameFileDataSource>());
            }
            return(null);
        }
Exemplo n.º 9
0
        public void Pre_1_1_0()
        {
            DataTable table = this.DataAccess.ExecuteSelect("select name from sqlite_master where type='table' and name='Tags';").Tables[0];

            if (table.Rows.Count == 0)
            {
                string sql = "CREATE TABLE 'Tags' (\r\n\t            'TagID'\tINTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\r\n\t            'Name'\tTEXT NOT NULL,\r\n\t            'HasTab'\tINTEGER NOT NULL);";
                this.DataAccess.ExecuteSelect(sql);
                sql = "CREATE TABLE 'TagMapping' (\r\n\t            'FileID'\tINTEGER NOT NULL,\r\n\t            'TagID'\tINTEGER NOT NULL,\r\n\t            PRIMARY KEY(FileID,TagID));";
                this.DataAccess.ExecuteSelect(sql);
            }
            table = this.DataAccess.ExecuteSelect("pragma table_info(Tags);").Tables[0];
            if (table.Select("name = 'Color'").Count <DataRow>() == 0)
            {
                this.DataAccess.ExecuteNonQuery("alter table Tags add column 'HasColor' int;");
                this.DataAccess.ExecuteNonQuery("alter table Tags add column 'Color' int;");
            }
            table = this.DataAccess.ExecuteSelect("pragma table_info(GameFiles);").Tables[0];
            if (table.Select("name = 'MapCount'").Count <DataRow>() == 0)
            {
                new FileInfo("DoomLauncher.sqlite").CopyTo($"DoomLauncher_{Guid.NewGuid().ToString()}.sqlite.bak");
                this.DataAccess.ExecuteNonQuery("alter table GameFiles add column 'MapCount' int;");
                GameFileGetOptions options = new GameFileGetOptions();
                options.SelectFields = new GameFileFieldType[] { GameFileFieldType.GameFileID, GameFileFieldType.Map };
                IEnumerable <IGameFileDataSource> gameFiles = this.m_adapter.GetGameFiles(options);
                GameFileFieldType[] updateFields            = new GameFileFieldType[] { GameFileFieldType.MapCount };
                float num  = gameFiles.Count <IGameFileDataSource>();
                int   num2 = 0;
                foreach (IGameFileDataSource source in gameFiles)
                {
                    if (this.UpdateProgress != null)
                    {
                        this.ProgressPercent = Convert.ToInt32((float)((((float)num2) / num) * 100f));
                        this.UpdateProgress(this, new EventArgs());
                    }
                    if (source.Map != null)
                    {
                        source.MapCount = new int?(source.Map.Count <char>(x => (x == ',')) + 1);
                        this.m_adapter.UpdateGameFile(source, updateFields);
                    }
                    num2++;
                }
            }
            if (table.Select("name = 'SettingsSpecificFiles'").Count <DataRow>() == 0)
            {
                this.DataAccess.ExecuteNonQuery("alter table GameFiles add column 'SettingsSpecificFiles' TEXT;");
            }
            table = this.DataAccess.ExecuteSelect("select * from Configuration where Name = 'Version'").Tables[0];
            this.WriteVersion(AppVersion.Version_1_1_0);
            if (this.UpdateComplete != null)
            {
                this.UpdateComplete(this, new EventArgs());
            }
        }
Exemplo n.º 10
0
        private void HandlePlay(IEnumerable <IGameFile> gameFiles, ISourcePortData sourcePort)
        {
            LaunchData launchData = GetLaunchFiles(gameFiles);

            if (launchData.Success)
            {
                if (launchData.GameFile == null)
                {
                    var iwad = DataSourceAdapter.GetIWad((int)AppConfiguration.GetTypedConfigValue(ConfigType.DefaultIWad, typeof(int)));
                    if (iwad != null)
                    {
                        GameFileGetOptions options = new GameFileGetOptions(new GameFileSearchField(GameFileFieldType.GameFileID, iwad.GameFileID.Value.ToString()));
                        launchData.GameFile = DataSourceAdapter.GetGameFiles(options).FirstOrDefault();
                    }
                }

                if (launchData.GameFile != null)
                {
                    SetupPlayForm(launchData.GameFile);
                    if (sourcePort != null)
                    {
                        m_currentPlayForm.SelectedSourcePort = sourcePort;
                    }

                    if (m_currentPlayForm.ShowDialog(this) == DialogResult.OK)
                    {
                        try
                        {
                            HandlePlaySettings(m_currentPlayForm, m_currentPlayForm.SelectedGameProfile);
                            if (m_currentPlayForm.SelectedSourcePort != null)
                            {
                                m_playInProgress = StartPlay(launchData.GameFile, m_currentPlayForm.SelectedSourcePort, m_currentPlayForm.ScreenFilter);
                            }
                            ctrlSummary.PauseSlideshow();
                        }
                        catch (IOException)
                        {
                            MessageBox.Show(this, "The file is in use and cannot be launched. Please close any programs that may be using the file and try again.", "File In Use",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        HandleSelectionChange(GetCurrentViewControl(), true);
                    }
                }
            }
            else if (!string.IsNullOrEmpty(launchData.ErrorTitle))
            {
                MessageBox.Show(this, launchData.ErrorTitle, launchData.ErrorDescription, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 11
0
        private void UpdateBase(IGameFileDataSourceAdapter adapter, GameFileViewControl ctrl, GameFileGetOptions options, IEnumerable <GameFileSearchField> searchFields)
        {
            IEnumerable <IGameFileDataSource> first = new IGameFileDataSource[0];

            GameFileFieldType[] defaultGameFileSelectFields = this.DefaultGameFileSelectFields;
            if (options == null)
            {
                foreach (GameFileSearchField field in searchFields)
                {
                    first = first.Union <IGameFileDataSource>(adapter.GetGameFiles(new GameFileGetOptions(defaultGameFileSelectFields, field)));
                }
            }
            else
            {
                foreach (GameFileSearchField field2 in searchFields)
                {
                    options.SearchField = field2;
                    first = first.Union <IGameFileDataSource>(adapter.GetGameFiles(options));
                }
                if (options.SearchField != null)
                {
                    first = first.Union <IGameFileDataSource>(adapter.GetGameFiles(new GameFileGetOptions(defaultGameFileSelectFields, options.SearchField)));
                }
            }
            this.SetDataSource(ctrl, first.ToList <IGameFileDataSource>());
        }
Exemplo n.º 12
0
 private void Update(IGameFileDataSourceAdapter adapter, GameFileViewControl ctrl, GameFileGetOptions options, IEnumerable <GameFileSearchField> searchFields)
 {
     if ((searchFields == null) || (searchFields.Count <GameFileSearchField>() == 0))
     {
         if (options == null)
         {
             this.SetDataSource(ctrl, adapter.GetGameFiles().ToList <IGameFileDataSource>());
         }
         else
         {
             this.SetDataSource(ctrl, adapter.GetGameFiles(options).ToList <IGameFileDataSource>());
         }
     }
     else
     {
         this.UpdateBase(adapter, ctrl, options, searchFields);
     }
 }
Exemplo n.º 13
0
 public void UpdateGameFileViewSearch(IGameFileDataSourceAdapter adapter, GameFileViewControl ctrl, GameFileGetOptions options)
 {
     this.Update(adapter, ctrl, options, null);
 }
Exemplo n.º 14
0
        public void Pre_1_1_0()
        {
            DataTable dt = DataAccess.ExecuteSelect("select name from sqlite_master where type='table' and name='Tags';").Tables[0];

            //tag table update
            if (dt.Rows.Count == 0)
            {
                string query = @"CREATE TABLE 'Tags' (
	            'TagID'	INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	            'Name'	TEXT NOT NULL,
	            'HasTab'	INTEGER NOT NULL);"    ;
                DataAccess.ExecuteSelect(query);

                query = @"CREATE TABLE 'TagMapping' (
	            'FileID'	INTEGER NOT NULL,
	            'TagID'	INTEGER NOT NULL,
	            PRIMARY KEY(FileID,TagID));"    ;
                DataAccess.ExecuteSelect(query);
            }

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

            if (!dt.Select("name = 'Color'").Any())
            {
                DataAccess.ExecuteNonQuery("alter table Tags add column 'HasColor' int;");
                DataAccess.ExecuteNonQuery("alter table Tags add column 'Color' int;");
            }

            dt = DataAccess.ExecuteSelect("pragma table_info(GameFiles);").Tables[0];
            //GameFile map count update
            if (!dt.Select("name = 'MapCount'").Any())
            {
                CreateDatabaseBackup();

                DataAccess.ExecuteNonQuery("alter table GameFiles add column 'MapCount' int;");

                GameFileGetOptions options = new GameFileGetOptions();
                options.SelectFields = new GameFileFieldType[] { GameFileFieldType.GameFileID, GameFileFieldType.Map };
                IEnumerable <IGameFile> gameFiles = m_adapter.GetGameFiles(options);

                GameFileFieldType[] updateFields = new GameFileFieldType[] { GameFileFieldType.MapCount };
                float total = gameFiles.Count();
                int   count = 0;

                foreach (IGameFile gameFile in gameFiles)
                {
                    if (UpdateProgress != null)
                    {
                        ProgressPercent = Convert.ToInt32(count / total * 100);
                        UpdateProgress(this, new EventArgs());
                    }

                    if (gameFile.Map != null)
                    {
                        gameFile.MapCount = gameFile.Map.Count(x => x == ',') + 1;
                        m_adapter.UpdateGameFile(gameFile, updateFields);
                    }

                    count++;
                }
            }

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

            WriteVersion(AppVersion.Version_1_1_0);

            UpdateComplete?.Invoke(this, new EventArgs());
        }