diff --git a/SAM.Game/Manager.Designer.cs b/SAM.Game/Manager.Designer.cs index f73df2d..e96da6f 100644 --- a/SAM.Game/Manager.Designer.cs +++ b/SAM.Game/Manager.Designer.cs @@ -29,7 +29,6 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.ToolStripSeparator _ToolStripSeparator1; System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Manager)); this._MainToolStrip = new System.Windows.Forms.ToolStrip(); this._StoreButton = new System.Windows.Forms.ToolStripButton(); @@ -53,7 +52,13 @@ this._StatisticsTabPage = new System.Windows.Forms.TabPage(); this._EnableStatsEditingCheckBox = new System.Windows.Forms.CheckBox(); this._StatisticsDataGridView = new System.Windows.Forms.DataGridView(); - _ToolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this._ToolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this._DisplayLabel = new System.Windows.Forms.ToolStripLabel(); + this._DisplayUnlockedOnlyButton = new System.Windows.Forms.ToolStripButton(); + this._DisplayLockedOnlyButton = new System.Windows.Forms.ToolStripButton(); + this._MatchingStringLabel = new System.Windows.Forms.ToolStripLabel(); + this._MatchingStringTextBox = new System.Windows.Forms.ToolStripTextBox(); + this._ToolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this._MainToolStrip.SuspendLayout(); this._MainStatusStrip.SuspendLayout(); this._MainTabControl.SuspendLayout(); @@ -219,9 +224,16 @@ // _AchievementsToolStrip // this._AchievementsToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this._LockAllButton, - this._InvertAllButton, - this._UnlockAllButton}); + this._LockAllButton, + this._InvertAllButton, + this._UnlockAllButton, + this._ToolStripSeparator1, + this._DisplayLabel, + this._DisplayLockedOnlyButton, + this._DisplayUnlockedOnlyButton, + this._ToolStripSeparator2, + this._MatchingStringLabel, + this._MatchingStringTextBox}); this._AchievementsToolStrip.Location = new System.Drawing.Point(3, 3); this._AchievementsToolStrip.Name = "_AchievementsToolStrip"; this._AchievementsToolStrip.Size = new System.Drawing.Size(602, 25); @@ -301,6 +313,54 @@ this._StatisticsDataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.OnStatCellEndEdit); this._StatisticsDataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.OnStatDataError); // + // toolStripSeparator2 + // + this._ToolStripSeparator2.Name = "_ToolStripSeparator2"; + this._ToolStripSeparator2.Size = new System.Drawing.Size(6, 25); + // + // DisplayLabel + // + this._DisplayLabel.Font = new System.Drawing.Font("Segoe UI", 9F); + this._DisplayLabel.Name = "_DisplayLabel"; + this._DisplayLabel.Size = new System.Drawing.Size(62, 22); + this._DisplayLabel.Text = "Show only"; + // + // _DisplayUnlockedOnlyButton + // + this._DisplayUnlockedOnlyButton.CheckOnClick = true; + this._DisplayUnlockedOnlyButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this._DisplayUnlockedOnlyButton.Image = ((System.Drawing.Image)(resources.GetObject("_DisplayUnlockedOnlyButton.Image"))); + this._DisplayUnlockedOnlyButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this._DisplayUnlockedOnlyButton.Name = "_DisplayUnlockedOnlyButton"; + this._DisplayUnlockedOnlyButton.Size = new System.Drawing.Size(60, 22); + this._DisplayUnlockedOnlyButton.Text = "unlocked"; + this._DisplayUnlockedOnlyButton.Click += new System.EventHandler(this._DisplayUncheckedOnlyButton_Click); + // + // _DisplayLockedOnlyButton + // + this._DisplayLockedOnlyButton.CheckOnClick = true; + this._DisplayLockedOnlyButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this._DisplayLockedOnlyButton.Image = ((System.Drawing.Image)(resources.GetObject("_DisplayLockedOnlyButton.Image"))); + this._DisplayLockedOnlyButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this._DisplayLockedOnlyButton.Name = "_DisplayLockedOnlyButton"; + this._DisplayLockedOnlyButton.Size = new System.Drawing.Size(46, 22); + this._DisplayLockedOnlyButton.Text = "locked"; + this._DisplayLockedOnlyButton.Click += new System.EventHandler(this._DisplayCheckedOnlyButton_Click); + // + // MatchingStringLabel + // + this._MatchingStringLabel.Font = new System.Drawing.Font("Segoe UI", 9F); + this._MatchingStringLabel.Name = "_MatchingStringLabel"; + this._MatchingStringLabel.Size = new System.Drawing.Size(33, 22); + this._MatchingStringLabel.Text = "Filter"; + // + // _MatchingStringTextBox + // + this._MatchingStringTextBox.Name = "_MatchingStringTextBox"; + this._MatchingStringTextBox.Size = new System.Drawing.Size(100, 25); + this._MatchingStringTextBox.ToolTipText = "Type at least 3 characters that must appear in the name or description"; + this._MatchingStringTextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnFilterUpdate); + // // Manager // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -354,6 +414,12 @@ public System.Windows.Forms.CheckBox _EnableStatsEditingCheckBox; private System.Windows.Forms.ToolStripButton _ResetButton; private System.Windows.Forms.ToolStripStatusLabel _DownloadStatusLabel; + private System.Windows.Forms.ToolStripSeparator _ToolStripSeparator1; + private System.Windows.Forms.ToolStripLabel _DisplayLabel; + private System.Windows.Forms.ToolStripButton _DisplayUnlockedOnlyButton; + private System.Windows.Forms.ToolStripButton _DisplayLockedOnlyButton; + private System.Windows.Forms.ToolStripLabel _MatchingStringLabel; + private System.Windows.Forms.ToolStripTextBox _MatchingStringTextBox; + private System.Windows.Forms.ToolStripSeparator _ToolStripSeparator2; } -} - +} \ No newline at end of file diff --git a/SAM.Game/Manager.cs b/SAM.Game/Manager.cs index 4b9bdc3..98efd02 100644 --- a/SAM.Game/Manager.cs +++ b/SAM.Game/Manager.cs @@ -449,6 +449,10 @@ namespace SAM.Game continue; } + if (!this.IsMatchingSearchAndDisplaySettings(isAchieved, def.Name, def.Description)) + { + continue; + } var info = new Stats.AchievementInfo() { Id = def.Id, @@ -860,6 +864,57 @@ namespace SAM.Game MessageBoxIcon.Error); e.NewValue = e.CurrentValue; } + } + + private bool IsMatchingSearchAndDisplaySettings(bool isLocked, string achievementName, string achievementDesc) + { + // display locked, unlocked or both + bool lockStateMatch = (!_DisplayLockedOnlyButton.Checked && !_DisplayUnlockedOnlyButton.Checked) || + (_DisplayLockedOnlyButton.Checked && isLocked) || + (_DisplayUnlockedOnlyButton.Checked && !isLocked); + // text filter on name / description + bool findTxtMatch = true; + if (lockStateMatch) + { + string searchString = _MatchingStringTextBox.Text.ToLowerInvariant(); + findTxtMatch = String.IsNullOrEmpty(searchString) || achievementName.ToLowerInvariant().Contains(searchString) || achievementDesc.ToLowerInvariant().Contains(searchString); + } + return lockStateMatch && findTxtMatch; + } + + private void _DisplayUncheckedOnlyButton_Click(object sender, EventArgs e) + { + if ((sender as ToolStripButton).Checked) + { + _DisplayLockedOnlyButton.Checked = false; + _DisplayUnlockedOnlyButton.ForeColor = Color.Blue; + _DisplayLockedOnlyButton.ForeColor = Color.Black; + } + else + { + _DisplayUnlockedOnlyButton.ForeColor = Color.Black; + } + this.GetAchievements(); + } + + private void _DisplayCheckedOnlyButton_Click(object sender, EventArgs e) + { + if ((sender as ToolStripButton).Checked) + { + _DisplayUnlockedOnlyButton.Checked = false; + _DisplayLockedOnlyButton.ForeColor = Color.Blue; + _DisplayUnlockedOnlyButton.ForeColor = Color.Black; + } + else + { + _DisplayLockedOnlyButton.ForeColor = Color.Black; + } + this.GetAchievements(); + } + + private void OnFilterUpdate(object sender, KeyEventArgs e) + { + this.GetAchievements(); } } } diff --git a/SAM.Picker/GamePicker.Designer.cs b/SAM.Picker/GamePicker.Designer.cs index 7afee59..14f22f7 100644 --- a/SAM.Picker/GamePicker.Designer.cs +++ b/SAM.Picker/GamePicker.Designer.cs @@ -51,6 +51,9 @@ this._ListWorker = new System.ComponentModel.BackgroundWorker(); _ToolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); _ToolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this._ToolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this._FindGamesLabel = new System.Windows.Forms.ToolStripLabel(); + this._SearchGameTextBox = new System.Windows.Forms.ToolStripTextBox(); this._PickerToolStrip.SuspendLayout(); this._PickerStatusStrip.SuspendLayout(); this.SuspendLayout(); @@ -65,6 +68,23 @@ _ToolStripSeparator2.Name = "_ToolStripSeparator2"; _ToolStripSeparator2.Size = new System.Drawing.Size(6, 25); // + // _ToolStripSeparator3 + // + this._ToolStripSeparator3.Name = "_ToolStripSeparator3"; + this._ToolStripSeparator3.Size = new System.Drawing.Size(6, 25); + // + // _FindGamesLabel + // + this._FindGamesLabel.Name = "_FindGamesLabel"; + this._FindGamesLabel.Size = new System.Drawing.Size(33, 22); + this._FindGamesLabel.Text = "Filter"; + // + // _SearchGameTextBox + // + this._SearchGameTextBox.Name = "_SearchGameTextBox"; + this._SearchGameTextBox.Size = new System.Drawing.Size(100, 25); + this._SearchGameTextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnFilterUpdate); + // // _LogoImageList // this._LogoImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; @@ -79,12 +99,15 @@ // _PickerToolStrip // this._PickerToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this._RefreshGamesButton, - _ToolStripSeparator1, - this._AddGameTextBox, - this._AddGameButton, - _ToolStripSeparator2, - this._FilterDropDownButton}); + this._RefreshGamesButton, + this._ToolStripSeparator1, + this._AddGameTextBox, + this._AddGameButton, + this._ToolStripSeparator2, + this._FilterDropDownButton, + this._ToolStripSeparator3, + this._FindGamesLabel, + this._SearchGameTextBox}); this._PickerToolStrip.Location = new System.Drawing.Point(0, 0); this._PickerToolStrip.Name = "_PickerToolStrip"; this._PickerToolStrip.Size = new System.Drawing.Size(742, 25); @@ -260,6 +283,8 @@ private System.Windows.Forms.ToolStripStatusLabel _PickerStatusLabel; private System.ComponentModel.BackgroundWorker _LogoWorker; private System.ComponentModel.BackgroundWorker _ListWorker; + private System.Windows.Forms.ToolStripTextBox _SearchGameTextBox; + private System.Windows.Forms.ToolStripLabel _FindGamesLabel; + private System.Windows.Forms.ToolStripSeparator _ToolStripSeparator3; } } - diff --git a/SAM.Picker/GamePicker.cs b/SAM.Picker/GamePicker.cs index 3ee096c..4b61954 100644 --- a/SAM.Picker/GamePicker.cs +++ b/SAM.Picker/GamePicker.cs @@ -136,6 +136,11 @@ namespace SAM.Picker this._FilteredGames.Clear(); foreach (var info in this._Games.Values.OrderBy(gi => gi.Name)) { + if (_SearchGameTextBox.Text.Length != 0 && + !info.Name.ToLowerInvariant().Contains(_SearchGameTextBox.Text.ToLowerInvariant())) + { + continue; + } if (info.Type == "normal" && _FilterGamesMenuItem.Checked == false) { continue; @@ -455,6 +460,7 @@ namespace SAM.Picker private void OnFilterUpdate(object sender, EventArgs e) { this.RefreshGames(); + this._SearchGameTextBox.Focus(); // Compatibility with _GameListView SearchForVirtualItemEventHandler (otherwise _SearchGameTextBox loose focus on KeyUp) } } }