示例#1
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);
        }
示例#2
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);
            }
        }
示例#3
0
        /// <summary>
        ///     Removes all selected games from the database.
        /// </summary>
        private 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 == 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();
                    }
                }
            }
        }
示例#4
0
 /// <summary>
 ///     Shows a dialog allowing the user to modify the entry for the first selected game.
 /// </summary>
 private 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 == DialogResult.OK)
             {
                 lstGames.RedrawItems(lstGames.SelectedIndices[0], lstGames.SelectedIndices[0], true);
                 AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_EditedGame, game.Id));
                 UnsavedChanges = true;
             }
         }
     }
 }
示例#5
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;

                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;
                }
                numAchievements.Value = Utility.Clamp(Game.Achievements, (int)numAchievements.Minimum,
                                                      (int)numAchievements.Maximum);
                numReviewScore.Value = Utility.Clamp(Game.ReviewPositivePercentage, (int)numReviewScore.Minimum,
                                                     (int)numReviewScore.Maximum);
                numReviewCount.Value = Utility.Clamp(Game.ReviewTotal, (int)numReviewCount.Minimum,
                                                     (int)numReviewCount.Maximum);
                numHltbMain.Value   = Utility.Clamp(Game.HltbMain, (int)numHltbMain.Minimum, (int)numHltbMain.Maximum);
                numHltbExtras.Value = Utility.Clamp(Game.HltbExtras, (int)numHltbExtras.Minimum,
                                                    (int)numHltbExtras.Maximum);
                numHltbCompletionist.Value = Utility.Clamp(Game.HltbCompletionist, (int)numHltbCompletionist.Minimum,
                                                           (int)numHltbCompletionist.Maximum);
                chkPlatWin.Checked       = Game.Platforms.HasFlag(AppPlatforms.Windows);
                chkPlatMac.Checked       = Game.Platforms.HasFlag(AppPlatforms.Mac);
                chkPlatLinux.Checked     = Game.Platforms.HasFlag(AppPlatforms.Linux);
                chkPlatSteamplay.Checked = Game.Platforms.HasFlag(AppPlatforms.Steamplay);

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

                dateWeb.Value     = Utility.GetDTFromUTime(Game.LastStoreScrape);
                dateAppInfo.Value = Utility.GetDTFromUTime(Game.LastAppInfoUpdate);
            }
        }
示例#6
0
 public GameDBEntryDialog(GameDBEntry game)
 {
     InitializeComponent();
     Game     = game;
     editMode = game == null ? false : true;
 }
示例#7
0
 private bool ShouldHideGame(GameDBEntry g) => !ShouldDisplayGame(g);
示例#8
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>
        private 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 && !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 && (g.LastStoreScrape > 0))
                {
                    return(false);
                }
                if (radWebYes.Checked && (g.LastStoreScrape <= 0))
                {
                    return(false);
                }
                if (radWebSince.Checked && (g.LastStoreScrape > Utility.GetUTime(dateWeb.Value)))
                {
                    return(false);
                }
            }

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

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

            return(true);
        }
示例#9
0
 private ListViewItem CreateListViewItem(GameDBEntry g) => new ListViewItem(new[]
 {
     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()
 });