@@ -18,33 +18,30 @@ namespace Octgn.Scripting.Controls
1818
1919 using Octgn . Core . DataExtensionMethods ;
2020 using Octgn . Core . DataManagers ;
21- using Octgn . DataNew . Entities ;
21+ using Octgn . Play ;
2222
2323 public partial class SelectCardsDlg
2424 {
2525 public static readonly DependencyProperty IsCardSelectedProperty = DependencyProperty . Register (
2626 "IsCardSelected" , typeof ( bool ) , typeof ( SelectCardsDlg ) , new UIPropertyMetadata ( false ) ) ;
2727
28- private List < DataNew . Entities . Card > _allCards ;
28+ private List < Card > _allCards ;
2929 private string _filterText = "" ;
30+ private IEnumerable < string > textProperties = Program . GameEngine . Definition . CustomProperties
31+ . Where ( p => p . Type == DataNew . Entities . PropertyType . String && ! p . IgnoreText )
32+ . Select ( p => p . Name ) ;
3033
31- public SelectCardsDlg ( List < string > guidList , string prompt , string title )
34+ public SelectCardsDlg ( List < Card > cardList , string prompt , string title )
3235 {
3336 InitializeComponent ( ) ;
3437 Title = title ;
3538 promptLbl . Text = prompt ;
3639 Task . Factory . StartNew ( ( ) =>
3740 {
3841 var game = GameManager . Get ( ) . GetById ( Program . GameEngine . Definition . Id ) ;
39- if ( guidList == null ) guidList = new List < string > ( ) ;
40-
41- _allCards = new List < Card > ( ) ;
42- foreach ( var c in guidList )
43- {
44- var tlist = game . AllCards ( )
45- . Where ( y => y . Id . ToString ( ) . ToLower ( ) == c . ToLower ( ) ) . ToList ( ) ;
46- _allCards . AddRange ( tlist ) ;
47- }
42+ if ( cardList == null ) cardList = new List < Card > ( ) ;
43+
44+ _allCards = cardList ;
4845
4946 Dispatcher . BeginInvoke ( new Action ( ( ) => allList . ItemsSource = _allCards ) ) ;
5047 } ) ;
@@ -56,7 +53,7 @@ public bool IsCardSelected
5653 set { SetValue ( IsCardSelectedProperty , value ) ; }
5754 }
5855
59- public DataNew . Entities . Card SelectedCard { get ; private set ; }
56+ public Card SelectedCard { get ; private set ; }
6057
6158 public int returnIndex { get ; private set ; }
6259
@@ -70,7 +67,7 @@ private void SelectClicked(object sender, RoutedEventArgs e)
7067
7168 allList . ItemsSource = _allCards ;
7269
73- if ( allList . SelectedIndex != - 1 ) SelectedCard = ( DataNew . Entities . Card ) allList . SelectedItem ;
70+ if ( allList . SelectedIndex != - 1 ) SelectedCard = ( Card ) allList . SelectedItem ;
7471 returnIndex = allList . SelectedIndex ;
7572
7673 if ( SelectedCard == null ) return ;
@@ -102,11 +99,14 @@ private void FilterChanged(object sender, EventArgs e)
10299 ThreadPool . QueueUserWorkItem ( searchObj =>
103100 {
104101 var search = ( string ) searchObj ;
105- List < DataNew . Entities . Card > filtered =
102+ List < Card > filtered =
106103 _allCards . Where (
107104 m =>
108- m . Name . IndexOf ( search ,
109- StringComparison . CurrentCultureIgnoreCase ) >= 0 )
105+ m . RealName . IndexOf ( search , StringComparison . CurrentCultureIgnoreCase ) >= 0 ||
106+ textProperties . Select ( property => ( string ) m . GetProperty ( property ) ) .
107+ Where ( propertyValue => propertyValue != null ) . Any (
108+ propertyValue => propertyValue . IndexOf ( search , StringComparison . CurrentCultureIgnoreCase ) >= 0 )
109+ )
110110 . ToList ( ) ;
111111 if ( search == _filterText )
112112 Dispatcher . Invoke ( new Action ( ( ) => allList . ItemsSource = filtered ) ) ;
@@ -124,7 +124,7 @@ private void SetPicture(object sender, RoutedEventArgs e)
124124 {
125125 var img = sender as Image ;
126126 if ( img == null ) return ;
127- var model = img . DataContext as DataNew . Entities . Card ;
127+ var model = ( img . DataContext as Card ) . Type . Model ;
128128 if ( model != null ) ImageUtils . GetCardImage ( model , x => img . Source = x ) ;
129129 }
130130
0 commit comments