Esempio n. 1
0
        /// <summary>
        /// Adds tags from the given DBEntry to the dictionary. Adds new elements if necessary, and increases values on existing elements.
        /// </summary>
        /// <param name="counts">Existing dictionary of tags and scores. Key is the tag as a string, value is the score</param>
        /// <param name="dbEntry">Entry to add tags from</param>
        /// <param name="weightFactor">The score value of the first tag in the list.
        /// The first tag on the game will have this score, and the last tag processed will always have score 1.
        /// The tags between will have linearly interpolated values between them.</param>
        /// <param name="tagsPerGame"></param>
        private void CalculateSortedTagListHelper(Dictionary <string, float> counts, GameDBEntry dbEntry, float weightFactor, int tagsPerGame)
        {
            if (dbEntry.Tags != null)
            {
                int tagsToLoad = (tagsPerGame == 0) ? dbEntry.Tags.Count : Math.Min(tagsPerGame, dbEntry.Tags.Count);
                for (int i = 0; i < tagsToLoad; i++)
                {
                    // Get the score based on the weighting factor
                    float score = 1;
                    if (weightFactor > 1)
                    {
                        if (tagsToLoad <= 1)
                        {
                            score = weightFactor;
                        }
                        else
                        {
                            float interp = (float)i / (float)(tagsToLoad - 1);
                            score = (1 - interp) * weightFactor + interp;
                        }
                    }

                    string tag = dbEntry.Tags[i];
                    if (counts.ContainsKey(tag))
                    {
                        counts[tag] += score;
                    }
                    else
                    {
                        counts[tag] = score;
                    }
                }
            }
        }
Esempio n. 2
0
 void VisitStorePage(GameDBEntry game)
 {
     if (game != null)
     {
         System.Diagnostics.Process.Start(string.Format(Properties.Resources.UrlSteamStore, game.Id));
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Updated the database with information from the AppInfo cache file.
        /// </summary>
        /// <param name="path">Path to the cache file</param>
        /// <returns>The number of entries integrated into the database.</returns>
        public int UpdateFromAppInfo(string path)
        {
            int updated = 0;

            Dictionary <int, AppInfo> appInfos = AppInfo.LoadApps(path);
            int timestamp = Utility.GetCurrentUTime();

            foreach (AppInfo aInf in appInfos.Values)
            {
                GameDBEntry entry;
                if (!Games.ContainsKey(aInf.Id))
                {
                    entry    = new GameDBEntry();
                    entry.Id = aInf.Id;
                    Games.Add(entry.Id, entry);
                }
                else
                {
                    entry = Games[aInf.Id];
                }

                entry.LastAppInfoUpdate = timestamp;
                entry.AppType           = aInf.AppType;
                entry.Name      = aInf.Name;
                entry.Platforms = aInf.Platforms;
                entry.ParentId  = aInf.Parent;
                updated++;
            }
            return(updated);
        }
Esempio n. 4
0
        public int IntegrateAppList(XmlDocument doc)
        {
            int added = 0;

            foreach (XmlNode node in doc.SelectNodes("/applist/apps/app"))
            {
                int appId;
                if (XmlUtil.TryGetIntFromNode(node["appid"], out appId))
                {
                    string gameName = XmlUtil.GetStringFromNode(node["name"], null);
                    if (Games.ContainsKey(appId))
                    {
                        GameDBEntry g = Games[appId];
                        if (string.IsNullOrEmpty(g.Name) || g.Name != gameName)
                        {
                            g.Name    = gameName;
                            g.AppType = AppTypes.Unknown;
                        }
                    }
                    else
                    {
                        GameDBEntry g = new GameDBEntry();
                        g.Id   = appId;
                        g.Name = gameName;
                        Games.Add(appId, g);
                        added++;
                    }
                }
            }
            Program.Logger.Write(LoggerLevel.Info, GlobalStrings.GameDB_LoadedNewItemsFromAppList, added);
            return(added);
        }
Esempio n. 5
0
 /// <summary>
 /// Removes all selected games from the database.
 /// </summary>
 void DeleteSelectedGames()
 {
     if (lstGames.SelectedIndices.Count > 0)
     {
         DialogResult res = MessageBox.Show(string.Format(GlobalStrings.DBEditDlg_AreYouSureDeleteGames, lstGames.SelectedIndices.Count),
                                            GlobalStrings.DBEditDlg_Confirm, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
         if (res == System.Windows.Forms.DialogResult.Yes)
         {
             int deleted = 0;
             foreach (int index in lstGames.SelectedIndices)
             {
                 GameDBEntry game = displayedGames[index];
                 if (game != null)
                 {
                     Program.GameDB.Games.Remove(game.Id);
                     deleted++;
                 }
             }
             AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_DeletedGames, deleted));
             if (deleted > 0)
             {
                 UnsavedChanges = true;
                 RefilterDisplayList();
                 lstGames.SelectedIndices.Clear();
             }
         }
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Runs the next job in the queue, in a thread-safe manner. Aborts ASAP if the form is closed.
        /// </summary>
        /// <returns>True if a job was run, false if it was aborted first</returns>
        private bool RunNextJob()
        {
            int id = GetNextGameId();

            if (id == 0)
            {
                return(false);
            }
            if (Stopped)
            {
                return(false);
            }

            GameDBEntry newGame = new GameDBEntry();

            newGame.Id = id;
            newGame.ScrapeStore();

            // This lock is critical, as it makes sure that the abort check and the actual game update funtion essentially atomically with reference to form-closing.
            // If this isn't the case, the form could successfully close before this happens, but then it could still go through, and that's no good.
            lock (abortLock)
            {
                if (!Stopped)
                {
                    results.Add(newGame);
                    OnJobCompletion();
                    return(true);
                }
                return(false);
            }
        }
Esempio n. 7
0
        void AddGameToList(GameDBEntry g)
        {
            ListViewItem item = new ListViewItem(new string[] { g.Name, g.Id.ToString(), g.Genre, g.Type.ToString() });

            item.Tag = g;
            lstGames.Items.Add(item);
        }
        private void InitializeFields( GameDBEntry entry = null ) {
            if( entry == null ) {
                cmdSave.Text = GlobalStrings.DlgGameDBEntry_Add;
                cmbType.SelectedIndex = 0;
            } else {
                txtId.Text = Game.Id.ToString();
                txtId.Enabled = false;

                txtParent.Text = ( Game.ParentId < 0 ) ? "" : Game.ParentId.ToString();

                cmbType.SelectedItem = Game.AppType;

                this.txtName.Text = Game.Name;
                if( Game.Genres != null ) txtGenres.Text = string.Join( ",", Game.Genres );
                if( Game.Flags != null ) txtFlags.Text = string.Join( ",", Game.Flags );
                if( Game.Tags != null ) txtTags.Text = string.Join( ",", Game.Tags );
                if( Game.Developers != null ) txtDev.Text = string.Join( ",", Game.Developers );
                if( Game.Publishers != null ) txtPub.Text = string.Join( ",", Game.Publishers );
                if( Game.MC_Url != null ) txtMCName.Text = Game.MC_Url;
                if( Game.SteamReleaseDate != null ) txtRelease.Text = Game.SteamReleaseDate;
                numReviewScore.Value = Utility.Clamp( Game.ReviewPositivePercentage, (int)numReviewScore.Minimum, (int)numReviewScore.Maximum );
                numReviewCount.Value = Utility.Clamp( Game.ReviewTotal, (int)numReviewCount.Minimum, (int)numReviewCount.Maximum );
                chkPlatWin.Checked = Game.Platforms.HasFlag( AppPlatforms.Windows );
                chkPlatMac.Checked = Game.Platforms.HasFlag( AppPlatforms.Mac );
                chkPlatLinux.Checked = Game.Platforms.HasFlag( AppPlatforms.Linux );

                chkWebUpdate.Checked = Game.LastStoreScrape > 0;
                chkAppInfoUpdate.Checked = Game.LastAppInfoUpdate > 0;

                dateWeb.Value = Utility.GetDTFromUTime( Game.LastStoreScrape );
                dateAppInfo.Value = Utility.GetDTFromUTime( Game.LastAppInfoUpdate );
            }
        }
Esempio n. 9
0
 void DeleteSelectedGames()
 {
     if (lstGames.SelectedItems.Count > 0)
     {
         DialogResult res = MessageBox.Show(string.Format(GlobalStrings.DBEditDlg_AreYouSureDeleteGames, lstGames.SelectedItems.Count),
                                            GlobalStrings.DBEditDlg_Confirm, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
         if (res == System.Windows.Forms.DialogResult.Yes)
         {
             int deleted = 0;
             foreach (ListViewItem item in lstGames.SelectedItems)
             {
                 GameDBEntry game = item.Tag as GameDBEntry;
                 if (game != null)
                 {
                     Program.GameDB.Games.Remove(game.Id);
                     deleted++;
                 }
             }
             AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_DeletedGames, deleted));
             if (deleted > 0)
             {
                 UnsavedChanges = true;
                 UpdateSelectedGames();
             }
             UpdateForSelectChange();
         }
     }
 }
Esempio n. 10
0
        private void InitializeFields(GameDBEntry entry = null)
        {
            if (entry == null)
            {
                cmdSave.Text          = GlobalStrings.DlgGameDBEntry_Add;
                cmbType.SelectedIndex = 0;
            }
            else
            {
                txtId.Text    = Game.Id.ToString();
                txtId.Enabled = false;

                txtParent.Text = (Game.ParentId < 0) ? "" : Game.ParentId.ToString();

                cmbType.SelectedItem = Game.AppType;

                this.txtName.Text = Game.Name;
                if (Game.Genres != null)
                {
                    txtGenres.Text = string.Join(",", Game.Genres);
                }
                if (Game.Flags != null)
                {
                    txtFlags.Text = string.Join(",", Game.Flags);
                }
                if (Game.Tags != null)
                {
                    txtTags.Text = string.Join(",", Game.Tags);
                }
                if (Game.Developers != null)
                {
                    txtDev.Text = string.Join(",", Game.Developers);
                }
                if (Game.Publishers != null)
                {
                    txtPub.Text = string.Join(",", Game.Publishers);
                }
                if (Game.MC_Url != null)
                {
                    txtMCName.Text = Game.MC_Url;
                }
                if (Game.SteamReleaseDate != null)
                {
                    txtRelease.Text = Game.SteamReleaseDate;
                }
                numReviewScore.Value = Utility.Clamp(Game.ReviewPositivePercentage, (int)numReviewScore.Minimum, (int)numReviewScore.Maximum);
                numReviewCount.Value = Utility.Clamp(Game.ReviewTotal, (int)numReviewCount.Minimum, (int)numReviewCount.Maximum);
                chkPlatWin.Checked   = Game.Platforms.HasFlag(AppPlatforms.Windows);
                chkPlatMac.Checked   = Game.Platforms.HasFlag(AppPlatforms.Mac);
                chkPlatLinux.Checked = Game.Platforms.HasFlag(AppPlatforms.Linux);

                chkWebUpdate.Checked     = Game.LastStoreScrape > 0;
                chkAppInfoUpdate.Checked = Game.LastAppInfoUpdate > 0;

                dateWeb.Value     = Utility.GetDTFromUTime(Game.LastStoreScrape);
                dateAppInfo.Value = Utility.GetDTFromUTime(Game.LastAppInfoUpdate);
            }
        }
Esempio n. 11
0
        private bool SaveToGame()
        {
            int id, parent;

            if (!ValidateEntries(out id, out parent))
            {
                return(false);
            }

            if (Game == null)
            {
                Game    = new GameDBEntry();
                Game.Id = id;
            }

            Game.ParentId = parent;

            Game.AppType = (AppTypes)cmbType.SelectedItem;
            Game.Name    = txtName.Text;


            Game.Genres     = SplitAndTrim(txtGenres.Text);
            Game.Flags      = SplitAndTrim(txtFlags.Text);
            Game.Tags       = SplitAndTrim(txtTags.Text);
            Game.Developers = SplitAndTrim(txtDev.Text);
            Game.Publishers = SplitAndTrim(txtPub.Text);

            Game.Achievements             = (int)numAchievements.Value;
            Game.ReviewPositivePercentage = (int)numReviewScore.Value;
            Game.ReviewTotal = (int)numReviewCount.Value;

            Game.HltbMain          = (int)numHltbMain.Value;
            Game.HltbExtras        = (int)numHltbExtras.Value;
            Game.HltbCompletionist = (int)numHltbCompletionist.Value;

            Game.MC_Url           = txtMCName.Text;
            Game.SteamReleaseDate = txtRelease.Text;

            Game.Platforms = AppPlatforms.None;
            if (chkPlatWin.Checked)
            {
                Game.Platforms |= AppPlatforms.Windows;
            }
            if (chkPlatMac.Checked)
            {
                Game.Platforms |= AppPlatforms.Mac;
            }
            if (chkPlatLinux.Checked)
            {
                Game.Platforms |= AppPlatforms.Linux;
            }

            Game.LastStoreScrape   = chkWebUpdate.Checked ? Utility.GetUTime(dateWeb.Value) : 0;
            Game.LastAppInfoUpdate = chkAppInfoUpdate.Checked ? Utility.GetUTime(dateAppInfo.Value) : 0;

            return(true);
        }
Esempio n. 12
0
 ListViewItem CreateListViewItem(GameDBEntry g)
 {
     return(new ListViewItem(new string[] {
         g.Id.ToString(),
         g.Name,
         (g.Genres != null) ? string.Join(",", g.Genres) : "",
         g.AppType.ToString(),
         (g.LastStoreScrape == 0) ? "": "X",
         (g.LastAppInfoUpdate == 0) ? "" : "X",
         (g.ParentId <= 0) ? "" : g.ParentId.ToString()
     }));
 }
Esempio n. 13
0
 public int GetReleaseYear(int gameId)
 {
     if (Games.ContainsKey(gameId))
     {
         GameDBEntry dbEntry = Games[gameId];
         DateTime    releaseDate;
         if (DateTime.TryParse(dbEntry.SteamReleaseDate, out releaseDate))
         {
             return(releaseDate.Year);
         }
     }
     return(0);
 }
Esempio n. 14
0
 bool ShouldDisplayGame(GameDBEntry g)
 {
     return
         (chkAll.Checked ||
          (g.Type == AppType.DLC && chkDLC.Checked) ||
          (g.Type == AppType.WebError && chkWebError.Checked) ||
          (g.Type == AppType.SiteError && chkSiteError.Checked) ||
          (g.Type == AppType.Game && chkGame.Checked) ||
          (g.Type == AppType.IdRedirect && chkRedirect.Checked) ||
          (g.Type == AppType.NonApp && chkNonApp.Checked) ||
          (g.Type == AppType.NotFound && chkNotFound.Checked) ||
          (g.Type == AppType.Unknown && chkUnknown.Checked) ||
          (g.Type == AppType.New && chkNew.Checked) ||
          (g.Type == AppType.AgeGated && chkAgeGate.Checked));
 }
 private bool SaveToGame() {
     if( Game == null ) {
         Game = new GameDBEntry();
     }
     if( !editMode ) {
         if( !int.TryParse( txtId.Text, out Game.Id ) ) {
             MessageBox.Show(GlobalStrings.DlgGameDBEntry_IDMustBeInteger);
             return false;
         }
     }
     Game.Type = (AppType)cmbType.SelectedItem;
     Game.Name = txtTitle.Text;
     Game.Genre = txtGenre.Text;
     return true;
 }
Esempio n. 16
0
 /// <summary>
 /// Shows a dialog allowing the user to modify the entry for the first selected game.
 /// </summary>
 void EditSelectedGame()
 {
     if (lstGames.SelectedIndices.Count > 0)
     {
         GameDBEntry game = displayedGames[lstGames.SelectedIndices[0]];
         if (game != null)
         {
             GameDBEntryDialog dlg = new GameDBEntryDialog(game);
             DialogResult      res = dlg.ShowDialog();
             if (res == System.Windows.Forms.DialogResult.OK)
             {
                 lstGames.RedrawItems(lstGames.SelectedIndices[0], lstGames.SelectedIndices[0], true);
                 AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_EditedGame, game.Id));
                 UnsavedChanges = true;
             }
         }
     }
 }
Esempio n. 17
0
 void EditSelectedGame()
 {
     if (lstGames.SelectedIndices.Count > 0)
     {
         GameDBEntry game = lstGames.SelectedItems[0].Tag as GameDBEntry;
         if (game != null)
         {
             GameDBEntryDialog dlg = new GameDBEntryDialog(game);
             DialogResult      res = dlg.ShowDialog();
             if (res == System.Windows.Forms.DialogResult.OK)
             {
                 UpdateGameAtIndex(lstGames.SelectedIndices[0]);
                 AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_EditedGame, game.Id));
                 UnsavedChanges = true;
             }
         }
     }
 }
Esempio n. 18
0
        bool UpdateGameAtIndex(int index)
        {
            ListViewItem item = lstGames.Items[index];
            GameDBEntry  game = item.Tag as GameDBEntry;

            if (game == null || !Program.GameDB.Games.ContainsKey(game.Id) || !ShouldDisplayGame(game))
            {
                lstGames.Items.RemoveAt(index);
                return(false);
            }
            else
            {
                item.SubItems[0].Text = game.Name;
                item.SubItems[1].Text = game.Id.ToString();
                item.SubItems[2].Text = game.Genre;
                item.SubItems[3].Text = game.Type.ToString();
                return(true);
            }
        }
 private bool SaveToGame()
 {
     if (Game == null)
     {
         Game = new GameDBEntry();
     }
     if (!editMode)
     {
         if (!int.TryParse(txtId.Text, out Game.Id))
         {
             MessageBox.Show(GlobalStrings.DlgGameDBEntry_IDMustBeInteger);
             return(false);
         }
     }
     Game.Type  = (AppType)cmbType.SelectedItem;
     Game.Name  = txtTitle.Text;
     Game.Genre = txtGenre.Text;
     return(true);
 }
Esempio n. 20
0
        /// <summary>
        /// Runs the next job in the queue, in a thread-safe manner. Aborts ASAP if the form is closed.
        /// </summary>
        /// <returns>True if a job was run, false if it was aborted first</returns>
        private bool RunNextJob()
        {
            Game game = GetNextGame();

            if (game == null)
            {
                return(false);
            }
            if (Stopped)
            {
                return(false);
            }
            // TODO: Make sure this gets Totally Revamped when multiple cat options are put in place.
            GameDBEntry dbEntry = new GameDBEntry();
            AppType     type    = dbEntry.ScrapeStore(game.Id);

            if (type == AppType.WebError)
            {
                Failures++;
            }
            string genre = dbEntry.Genre;

            if (!fullGenre)
            {
                genre = GameDB.TruncateGenre(genre);
            }

            // This lock is critical, as it makes sure that the abort check and the actual game update funtion essentially atomically with reference to form-closing.
            // If this isn't the case, the form could successfully close before this happens, but then it could still go through, and that's no good.
            lock ( abortLock ) {
                if (!Stopped)
                {
                    scrapeResults.Add(game.Id, genre);
                    OnJobCompletion();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Runs the next job in the queue, in a thread-safe manner. Aborts ASAP if the form is closed.
        /// </summary>
        /// <returns>True if a job was run, false if it was aborted first</returns>
        private bool RunNextJob() {
            int id = GetNextGameId();
            if( id == 0 ) {
                return false;
            }
            if( Stopped ) return false;

            GameDBEntry newGame = new GameDBEntry();
            newGame.ScrapeStore( id );

            // This lock is critical, as it makes sure that the abort check and the actual game update funtion essentially atomically with reference to form-closing.
            // If this isn't the case, the form could successfully close before this happens, but then it could still go through, and that's no good.
            lock( abortLock ) {
                if( !Stopped ) {
                    results.Add( newGame );
                    OnJobCompletion();
                    return true;
                } else {
                    return false;
                }
            }
        }
Esempio n. 22
0
        private void ScrapeSelected()
        {
            if (lstGames.SelectedItems.Count > 0)
            {
                Cursor = Cursors.WaitCursor;

                Queue <int> gamesToScrape = new Queue <int>();

                foreach (int index in lstGames.SelectedIndices)
                {
                    GameDBEntry game = lstGames.Items[index].Tag as GameDBEntry;
                    if (game != null)
                    {
                        gamesToScrape.Enqueue(game.Id);
                    }
                }

                ScrapeGames(gamesToScrape);

                UpdateForSelectChange();

                Cursor = Cursors.Default;
            }
        }
Esempio n. 23
0
        private bool SaveToGame()
        {
            int id, parent;
            if( !ValidateEntries( out id, out parent ) ) {
                return false;
            }

            if( Game == null ) {
                Game = new GameDBEntry();
                Game.Id = id;
            }

            Game.ParentId = parent;

            Game.AppType = (AppTypes)cmbType.SelectedItem;
            Game.Name = txtName.Text;

            Game.Genres = SplitAndTrim( txtGenres.Text );
            Game.Flags = SplitAndTrim( txtFlags.Text );
            Game.Tags = SplitAndTrim( txtTags.Text );
            Game.Developers = SplitAndTrim( txtDev.Text );
            Game.Publishers = SplitAndTrim( txtPub.Text );

            Game.Achievements = (int) numAchievements.Value;
            Game.ReviewPositivePercentage = (int)numReviewScore.Value;
            Game.ReviewTotal = (int)numReviewCount.Value;

            Game.HltbMain = (int)numHltbMain.Value;
            Game.HltbExtras = (int)numHltbExtras.Value;
            Game.HltbCompletionist = (int)numHltbCompletionist.Value;

            Game.MC_Url = txtMCName.Text;
            Game.SteamReleaseDate = txtRelease.Text;

            Game.Platforms = AppPlatforms.None;
            if( chkPlatWin.Checked ) Game.Platforms |= AppPlatforms.Windows;
            if( chkPlatMac.Checked ) Game.Platforms |= AppPlatforms.Mac;
            if( chkPlatLinux.Checked ) Game.Platforms |= AppPlatforms.Linux;
            if (chkPlatSteamplay.Checked) Game.Platforms |= AppPlatforms.Steamplay;

            Game.LastStoreScrape = chkWebUpdate.Checked ? Utility.GetUTime( dateWeb.Value ) : 0;
            Game.LastAppInfoUpdate = chkAppInfoUpdate.Checked ? Utility.GetUTime( dateAppInfo.Value ) : 0;

            return true;
        }
Esempio n. 24
0
        /// <summary>
        /// Merges in data from another entry. Useful for merging scrape results, but could also merge data from a different database.
        /// Uses newer data when there is a conflict.
        /// Does NOT perform deep copies of list fields.
        /// </summary>
        /// <param name="other">GameDBEntry containing info to be merged into this entry.</param>
        public void MergeIn(GameDBEntry other)
        {
            bool useAppInfoFields    = other.LastAppInfoUpdate > this.LastAppInfoUpdate || (this.LastAppInfoUpdate == 0 && other.LastStoreScrape >= this.LastStoreScrape);
            bool useScrapeOnlyFields = other.LastStoreScrape >= this.LastStoreScrape;

            if (other.AppType != AppTypes.Unknown && (this.AppType == AppTypes.Unknown || useAppInfoFields))
            {
                this.AppType = other.AppType;
            }

            if (other.LastAppInfoUpdate >= this.LastAppInfoUpdate)
            {
                this.Platforms = other.Platforms;
            }

            if (useAppInfoFields)
            {
                if (!string.IsNullOrEmpty(other.Name))
                {
                    Name = other.Name;
                }
                if (other.ParentId > 0)
                {
                    ParentId = other.ParentId;
                }
            }

            if (useScrapeOnlyFields)
            {
                if (other.Genres != null && other.Genres.Count > 0)
                {
                    Genres = other.Genres;
                }
                if (other.Flags != null && other.Flags.Count > 0)
                {
                    Flags = other.Flags;
                }
                if (other.Tags != null && other.Tags.Count > 0)
                {
                    Tags = other.Tags;
                }
                if (other.Developers != null && other.Developers.Count > 0)
                {
                    Developers = other.Developers;
                }
                if (other.Publishers != null && other.Publishers.Count > 0)
                {
                    Publishers = other.Publishers;
                }
                if (!string.IsNullOrEmpty(other.SteamReleaseDate))
                {
                    SteamReleaseDate = other.SteamReleaseDate;
                }

                if (other.ReviewTotal != 0)
                {
                    this.ReviewTotal = other.ReviewTotal;
                    this.ReviewPositivePercentage = other.ReviewPositivePercentage;
                }

                if (!string.IsNullOrEmpty(other.MC_Url))
                {
                    MC_Url = other.MC_Url;
                }
            }

            if (other.LastStoreScrape > this.LastStoreScrape)
            {
                this.LastStoreScrape = other.LastStoreScrape;
            }
            if (other.LastAppInfoUpdate > this.LastAppInfoUpdate)
            {
                this.LastAppInfoUpdate = other.LastAppInfoUpdate;
            }
        }
Esempio n. 25
0
 void AddGameToList( GameDBEntry g )
 {
     ListViewItem item = new ListViewItem( new string[] { g.Name, g.Id.ToString(), g.Genre, g.Type.ToString() } );
     item.Tag = g;
     lstGames.Items.Add( item );
 }
Esempio n. 26
0
 void VisitStorePage( GameDBEntry game )
 {
     if( game != null ) {
         System.Diagnostics.Process.Start( string.Format( Properties.Resources.UrlSteamStore, game.Id ) );
     }
 }
Esempio n. 27
0
 bool ShouldDisplayGame( GameDBEntry g )
 {
     return
         chkAll.Checked ||
         ( g.Type == AppType.DLC && chkDLC.Checked ) ||
         ( g.Type == AppType.WebError && chkWebError.Checked ) ||
         ( g.Type == AppType.SiteError && chkSiteError.Checked ) ||
         ( g.Type == AppType.Game && chkGame.Checked ) ||
         ( g.Type == AppType.IdRedirect && chkRedirect.Checked ) ||
         ( g.Type == AppType.NonApp && chkNonApp.Checked ) ||
         ( g.Type == AppType.NotFound && chkNotFound.Checked ) ||
         ( g.Type == AppType.Unknown && chkUnknown.Checked ) ||
         ( g.Type == AppType.New && chkNew.Checked ) ||
         ( g.Type == AppType.AgeGated && chkAgeGate.Checked );
 }
        /// <summary>
        /// Runs the next job in the queue, in a thread-safe manner. Aborts ASAP if the form is closed.
        /// </summary>
        /// <returns>True if a job was run, false if it was aborted first</returns>
        private bool RunNextJob() {
            Game game = GetNextGame();
            if( game == null ) {
                return false;
            }
            if( Stopped ) return false;
            // TODO: Make sure this gets Totally Revamped when multiple cat options are put in place.
            GameDBEntry dbEntry = new GameDBEntry();
            AppType type = dbEntry.ScrapeStore( game.Id );
            if( type == AppType.WebError ) {
                Failures++;
            }
            string genre = dbEntry.Genre;
            if( !fullGenre ) genre = GameDB.TruncateGenre( genre );

            // This lock is critical, as it makes sure that the abort check and the actual game update funtion essentially atomically with reference to form-closing.
            // If this isn't the case, the form could successfully close before this happens, but then it could still go through, and that's no good.
            lock( abortLock ) {
                if( !Stopped ) {
                    scrapeResults.Add( game.Id, genre );
                    OnJobCompletion();
                    return true;
                } else {
                    return false;
                }
            }
        }
Esempio n. 29
0
 public int IntegrateAppList( XmlDocument doc ) {
     int added = 0;
     foreach( XmlNode node in doc.SelectNodes( "/applist/apps/app" ) ) {
         int appId;
         if( XmlUtil.TryGetIntFromNode( node["appid"], out appId ) ) {
             string gameName = XmlUtil.GetStringFromNode( node["name"], null );
             if( Games.ContainsKey( appId ) ) {
                 GameDBEntry g = Games[appId];
                 if( string.IsNullOrEmpty( g.Name ) || g.Name != gameName ) {
                     g.Name = gameName;
                     g.Type = AppType.New;
                 }
             } else {
                 GameDBEntry g = new GameDBEntry();
                 g.Id = appId;
                 g.Name = gameName;
                 Games.Add( appId, g );
                 added++;
             }
         }
     }
     Program.Logger.Write(LoggerLevel.Info, GlobalStrings.GameDB_LoadedNewItemsFromAppList, added);
     return added;
 }
Esempio n. 30
0
 bool ShouldHideGame(GameDBEntry g)
 {
     return(!ShouldDisplayGame(g));
 }
Esempio n. 31
0
        /// <summary>
        /// Determine whether a particular entry should be displayed based on current filter selections
        /// </summary>
        /// <param name="g">entry to evaluate</param>
        /// <returns>True if the entry should be displayed</returns>
        bool ShouldDisplayGame(GameDBEntry g)
        {
            if (g == null)
            {
                return(false);
            }

            if (!Program.GameDB.Contains(g.Id))
            {
                return(false);
            }
            if (chkIdRange.Checked && (g.Id < currentMinId || g.Id > currentMaxId))
            {
                return(false);
            }

            if (ownedList != null && chkOwned.Checked == true && !ownedList.Games.ContainsKey(g.Id))
            {
                return(false);
            }

            if (chkTypeAll.Checked == false)
            {
                switch (g.AppType)
                {
                case AppTypes.Game:
                    if (chkTypeGame.Checked == false)
                    {
                        return(false);
                    }
                    break;

                case AppTypes.DLC:
                    if (chkTypeDLC.Checked == false)
                    {
                        return(false);
                    }
                    break;

                case AppTypes.Unknown:
                    if (chkTypeUnknown.Checked == false)
                    {
                        return(false);
                    }
                    break;

                default:
                    if (chkTypeOther.Checked == false)
                    {
                        return(false);
                    }
                    break;
                }
            }

            if (radWebAll.Checked == false)
            {
                if (radWebNo.Checked == true && g.LastStoreScrape > 0)
                {
                    return(false);
                }
                if (radWebYes.Checked == true && g.LastStoreScrape <= 0)
                {
                    return(false);
                }
                if (radWebSince.Checked == true && g.LastStoreScrape > Utility.GetUTime(dateWeb.Value))
                {
                    return(false);
                }
            }

            if (radAppAll.Checked == false)
            {
                if (radAppNo.Checked == true && g.LastAppInfoUpdate > 0)
                {
                    return(false);
                }
                if (radAppYes.Checked == true && g.LastAppInfoUpdate <= 0)
                {
                    return(false);
                }
            }

            if (currentFilter.Length > 0 && g.Name.IndexOf(currentFilter, StringComparison.CurrentCultureIgnoreCase) == -1)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 32
0
 public GameDBEntryDialog(GameDBEntry game)
 {
     InitializeComponent();
     Game     = game;
     editMode = (game == null) ? false : true;
 }
 public GameDBEntryDialog( GameDBEntry game )
 {
     InitializeComponent();
     Game = game;
     editMode = ( game == null ) ? false : true;
 }
Esempio n. 34
0
        public void Load(string path, bool compress)
        {
            Program.Logger.Write(LoggerLevel.Info, GlobalStrings.GameDB_LoadingGameDBFrom, path);
            XmlDocument doc = new XmlDocument();

            Stream stream = null;

            try {
                stream = new FileStream(path, FileMode.Open);
                if (compress)
                {
                    stream = new GZipStream(stream, CompressionMode.Decompress);
                }

                doc.Load(stream);

                Program.Logger.Write(LoggerLevel.Info, GlobalStrings.GameDB_GameDBXMLParsed);
                Games.Clear();

                foreach (XmlNode gameNode in doc.SelectNodes("/gamelist/game"))
                {
                    int id;
                    if (!XmlUtil.TryGetIntFromNode(gameNode["id"], out id) || Games.ContainsKey(id))
                    {
                        continue;
                    }
                    GameDBEntry g = new GameDBEntry();
                    g.Id = id;
                    XmlUtil.TryGetStringFromNode(gameNode["name"], out g.Name);
                    string typeString;
                    if (!XmlUtil.TryGetStringFromNode(gameNode["type"], out typeString) || !Enum.TryParse <AppType>(typeString, out g.Type))
                    {
                        g.Type = AppType.New;
                    }

                    g.Genre = XmlUtil.GetStringFromNode(gameNode["genre"], null);

                    g.Developer = XmlUtil.GetStringFromNode(gameNode["developer"], null);
                    g.Publisher = XmlUtil.GetStringFromNode(gameNode["publisher"], null);

                    int steamDate = XmlUtil.GetIntFromNode(gameNode["steamDate"], 0);
                    if (steamDate > 0)
                    {
                        g.SteamRelease = DateTime.FromOADate(steamDate);
                    }

                    foreach (XmlNode n in gameNode.SelectNodes("flag"))
                    {
                        string fName = XmlUtil.GetStringFromNode(n, null);
                        if (!string.IsNullOrEmpty(fName))
                        {
                            g.Flags.Add(fName);
                        }
                    }

                    g.MC_Url = XmlUtil.GetStringFromNode(gameNode["mcUrl"], null);


                    // TODO: Load MC extras

                    Games.Add(id, g);
                }
                Program.Logger.Write(LoggerLevel.Info, GlobalStrings.GameDB_GameDBXMLProcessed);
            } catch (Exception e) {
                throw e;
            } finally {
                if (stream != null)
                {
                    stream.Close();
                }
            }
        }
Esempio n. 35
0
        public void Load( string path, bool compress ) {
            Program.Logger.Write(LoggerLevel.Info, GlobalStrings.GameDB_LoadingGameDBFrom, path);
            XmlDocument doc = new XmlDocument();

            Stream stream = null;
            try {
                stream = new FileStream( path, FileMode.Open );
                if( compress ) {
                    stream = new GZipStream( stream, CompressionMode.Decompress );
                }

                doc.Load( stream );

                Program.Logger.Write(LoggerLevel.Info, GlobalStrings.GameDB_GameDBXMLParsed);
                Games.Clear();

                foreach( XmlNode gameNode in doc.SelectNodes( "/gamelist/game" ) ) {
                    int id;
                    if( !XmlUtil.TryGetIntFromNode( gameNode["id"], out id ) || Games.ContainsKey( id ) ) {
                        continue;
                    }
                    GameDBEntry g = new GameDBEntry();
                    g.Id = id;
                    XmlUtil.TryGetStringFromNode( gameNode["name"], out g.Name );
                    string typeString;
                    if( !XmlUtil.TryGetStringFromNode( gameNode["type"], out typeString ) || !Enum.TryParse<AppType>( typeString, out g.Type ) ) {
                        g.Type = AppType.New;
                    }

                    g.Genre = XmlUtil.GetStringFromNode( gameNode["genre"], null );

                    g.Developer = XmlUtil.GetStringFromNode( gameNode["developer"], null );
                    g.Publisher = XmlUtil.GetStringFromNode( gameNode["publisher"], null );

                    int steamDate = XmlUtil.GetIntFromNode( gameNode["steamDate"], 0 );
                    if( steamDate > 0 ) {
                        g.SteamRelease = DateTime.FromOADate( steamDate );
                    }

                    foreach( XmlNode n in gameNode.SelectNodes( "flag" ) ) {
                        string fName = XmlUtil.GetStringFromNode( n, null );
                        if( !string.IsNullOrEmpty( fName ) ) g.Flags.Add( fName );
                    }

                    g.MC_Url = XmlUtil.GetStringFromNode( gameNode["mcUrl"], null );


                    // TODO: Load MC extras

                    Games.Add( id, g );
                }
                Program.Logger.Write(LoggerLevel.Info, GlobalStrings.GameDB_GameDBXMLProcessed);
            } catch( Exception e ) {
                throw e;
            } finally {
                if( stream != null ) {
                    stream.Close();
                }
            }
        }
Esempio n. 36
0
        /// <summary>
        /// Determine whether a particular entry should be displayed based on current filter selections
        /// </summary>
        /// <param name="g">entry to evaluate</param>
        /// <returns>True if the entry should be displayed</returns>
        bool ShouldDisplayGame( GameDBEntry g ) {
            if( g == null ) return false;

            if( !Program.GameDB.Contains( g.Id ) ) return false;
            if( chkIdRange.Checked && ( g.Id < currentMinId || g.Id > currentMaxId ) ) return false;

            if( ownedList != null && chkOwned.Checked == true && !ownedList.Games.ContainsKey( g.Id ) ) return false;

            if( chkTypeAll.Checked == false ) {
                switch( g.AppType ) {
                    case AppTypes.Game:
                        if( chkTypeGame.Checked == false ) return false;
                        break;
                    case AppTypes.DLC:
                        if( chkTypeDLC.Checked == false ) return false;
                        break;
                    case AppTypes.Unknown:
                        if( chkTypeUnknown.Checked == false ) return false;
                        break;
                    default:
                        if( chkTypeOther.Checked == false ) return false;
                        break;
                }
            }

            if( radWebAll.Checked == false ) {
                if( radWebNo.Checked == true && g.LastStoreScrape > 0 ) return false;
                if( radWebYes.Checked == true && g.LastStoreScrape <= 0 ) return false;
                if( radWebSince.Checked == true && g.LastStoreScrape > Utility.GetUTime( dateWeb.Value ) ) return false;
            }

            if( radAppAll.Checked == false ) {
                if( radAppNo.Checked == true && g.LastAppInfoUpdate > 0 ) return false;
                if( radAppYes.Checked == true && g.LastAppInfoUpdate <= 0 ) return false;
            }

            if( currentFilter.Length > 0 && g.Name.IndexOf( currentFilter, StringComparison.CurrentCultureIgnoreCase ) == -1 ) return false;

            return true;
        }
Esempio n. 37
0
 ListViewItem CreateListViewItem( GameDBEntry g ) {
     return new ListViewItem( new string[] { 
             g.Id.ToString(),
             g.Name,
             ( g.Genres!=null ) ? string.Join(",",g.Genres) : "",
             g.AppType.ToString(),
             ( g.LastStoreScrape == 0 ) ? "": "X",
             ( g.LastAppInfoUpdate == 0 ) ? "" : "X",
             ( g.ParentId <= 0 ) ? "" : g.ParentId.ToString() } );
 }
Esempio n. 38
0
        public void Load(string path, bool compress)
        {
            Program.Logger.Write(LoggerLevel.Info, GlobalStrings.GameDB_LoadingGameDBFrom, path);
            XmlDocument doc = new XmlDocument();

            Stream stream = null;

            try {
                stream = new FileStream(path, FileMode.Open);
                if (compress)
                {
                    stream = new GZipStream(stream, CompressionMode.Decompress);
                }

                doc.Load(stream);

                Program.Logger.Write(LoggerLevel.Info, GlobalStrings.GameDB_GameDBXMLParsed);
                Games.Clear();
                ClearAggregates();

                XmlNode gameListNode = doc.SelectSingleNode("/" + XmlName_GameList);

                int fileVersion = XmlUtil.GetIntFromNode(gameListNode[XmlName_Version], 0);

                foreach (XmlNode gameNode in gameListNode.SelectNodes(XmlName_Game))
                {
                    int id;
                    if (!XmlUtil.TryGetIntFromNode(gameNode[XmlName_Game_Id], out id) || Games.ContainsKey(id))
                    {
                        continue;
                    }
                    GameDBEntry g = new GameDBEntry();
                    g.Id = id;

                    g.Name = XmlUtil.GetStringFromNode(gameNode[XmlName_Game_Name], null);

                    if (fileVersion < 1)
                    {
                        g.AppType = AppTypes.Unknown;
                        string typeString;
                        if (XmlUtil.TryGetStringFromNode(gameNode[XmlName_Game_Type], out typeString))
                        {
                            if (typeString == "DLC")
                            {
                                g.AppType = AppTypes.DLC;
                            }
                            else if (typeString == "Game")
                            {
                                g.AppType = AppTypes.Game;
                            }
                            else if (typeString == "NonApp")
                            {
                                g.AppType = AppTypes.Other;
                            }
                        }
                    }
                    else
                    {
                        g.AppType = XmlUtil.GetEnumFromNode <AppTypes>(gameNode[XmlName_Game_Type], AppTypes.Unknown);
                    }

                    g.Platforms = XmlUtil.GetEnumFromNode <AppPlatforms>(gameNode[XmlName_Game_Platforms], AppPlatforms.All);

                    g.ParentId = XmlUtil.GetIntFromNode(gameNode[XmlName_Game_Parent], -1);

                    if (fileVersion < 1)
                    {
                        List <string> genreList   = new List <string>();
                        string        genreString = XmlUtil.GetStringFromNode(gameNode["genre"], null);
                        if (genreString != null)
                        {
                            string[] genStrList = genreString.Split(',');
                            foreach (string s in genStrList)
                            {
                                genreList.Add(s.Trim());
                            }
                        }
                        g.Genres = genreList;
                    }
                    else
                    {
                        g.Genres = XmlUtil.GetStringsFromNodeList(gameNode.SelectNodes(XmlName_Game_Genre));
                    }

                    g.Tags = XmlUtil.GetStringsFromNodeList(gameNode.SelectNodes(XmlName_Game_Tag));

                    g.Developers = XmlUtil.GetStringsFromNodeList(gameNode.SelectNodes(XmlName_Game_Developer));

                    if (fileVersion < 1)
                    {
                        List <string> pubList   = new List <string>();
                        string        pubString = XmlUtil.GetStringFromNode(gameNode["publisher"], null);
                        if (pubString != null)
                        {
                            string[] pubStrList = pubString.Split(',');
                            foreach (string s in pubStrList)
                            {
                                pubList.Add(s.Trim());
                            }
                        }
                        g.Publishers = pubList;
                    }
                    else
                    {
                        g.Publishers = XmlUtil.GetStringsFromNodeList(gameNode.SelectNodes(XmlName_Game_Publisher));
                    }

                    if (fileVersion < 1)
                    {
                        int steamDate = XmlUtil.GetIntFromNode(gameNode["steamDate"], 0);
                        if (steamDate > 0)
                        {
                            g.SteamReleaseDate = DateTime.FromOADate(steamDate).ToString("MMM d, yyyy");
                        }
                        else
                        {
                            g.SteamReleaseDate = null;
                        }
                    }
                    else
                    {
                        g.SteamReleaseDate = XmlUtil.GetStringFromNode(gameNode[XmlName_Game_Date], null);
                    }

                    g.Flags = XmlUtil.GetStringsFromNodeList(gameNode.SelectNodes(XmlName_Game_Flag));

                    g.ReviewTotal = XmlUtil.GetIntFromNode(gameNode[XmlName_Game_ReviewTotal], 0);
                    g.ReviewPositivePercentage = XmlUtil.GetIntFromNode(gameNode[XmlName_Game_ReviewPositivePercent], 0);

                    g.MC_Url = XmlUtil.GetStringFromNode(gameNode[XmlName_Game_MCUrl], null);

                    g.LastAppInfoUpdate = XmlUtil.GetIntFromNode(gameNode[XmlName_Game_LastAppInfoUpdate], 0);
                    g.LastStoreScrape   = XmlUtil.GetIntFromNode(gameNode[XmlName_Game_LastStoreUpdate], 0);

                    Games.Add(id, g);
                }
                Program.Logger.Write(LoggerLevel.Info, GlobalStrings.GameDB_GameDBXMLProcessed);
            } catch (Exception e) {
                throw e;
            } finally {
                if (stream != null)
                {
                    stream.Close();
                }
            }
        }
Esempio n. 39
0
 bool ShouldHideGame( GameDBEntry g ) {
     return !ShouldDisplayGame( g );
 }