Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MobiusMei
ygopro
Commits
8e1826a8
Commit
8e1826a8
authored
Nov 24, 2018
by
VanillaSalt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add search operator " and -
parent
dc47725f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
54 deletions
+86
-54
gframe/deck_con.cpp
gframe/deck_con.cpp
+86
-54
No files found.
gframe/deck_con.cpp
View file @
8e1826a8
...
@@ -775,42 +775,78 @@ void DeckBuilder::StartFilter() {
...
@@ -775,42 +775,78 @@ void DeckBuilder::StartFilter() {
}
}
void
DeckBuilder
::
FilterCards
()
{
void
DeckBuilder
::
FilterCards
()
{
results
.
clear
();
results
.
clear
();
struct
element_t
{
std
::
wstring
keyword
;
int
setcode
;
enum
class
type_t
{
all
,
name
,
setcode
}
type
;
bool
exclude
;
element_t
()
:
setcode
(
0
),
type
(
type_t
::
all
),
exclude
(
false
)
{}
};
const
wchar_t
*
pstr
=
mainGame
->
ebCardName
->
getText
();
const
wchar_t
*
pstr
=
mainGame
->
ebCardName
->
getText
();
std
::
wstring
str
=
std
::
wstring
(
pstr
);
std
::
wstring
str
=
std
::
wstring
(
pstr
);
std
::
vector
<
std
::
wstring
>
query_elements
;
std
::
vector
<
element_t
>
query_elements
;
std
::
vector
<
std
::
vector
<
std
::
wstring
>::
iterator
>
query_elements_track
;
if
(
mainGame
->
gameConf
.
search_multiple_keywords
)
{
size_t
element_start
=
0
;
const
wchar_t
separator
=
mainGame
->
gameConf
.
search_multiple_keywords
==
1
?
L' '
:
L'+'
;
while
(
mainGame
->
gameConf
.
search_multiple_keywords
)
{
const
wchar_t
minussign
=
L'-'
;
size_t
element_end
=
str
.
find_first_of
(
mainGame
->
gameConf
.
search_multiple_keywords
==
1
?
L' '
:
L'+'
,
element_start
);
const
wchar_t
quotation
=
L'\"'
;
if
(
element_end
==
std
::
wstring
::
npos
)
size_t
element_start
=
0
;
break
;
for
(;;)
{
size_t
length
=
element_end
-
element_start
;
element_start
=
str
.
find_first_not_of
(
separator
,
element_start
);
if
(
length
>
0
)
{
if
(
element_start
==
std
::
wstring
::
npos
)
query_elements
.
push_back
(
str
.
substr
(
element_start
,
length
));
break
;
element_t
element
;
if
(
str
[
element_start
]
==
minussign
)
{
element
.
exclude
=
true
;
element_start
++
;
}
if
(
element_start
>=
str
.
size
())
break
;
if
(
str
[
element_start
]
==
L'$'
)
{
element
.
type
=
element_t
::
type_t
::
name
;
element_start
++
;
}
else
if
(
str
[
element_start
]
==
L'@'
)
{
element
.
type
=
element_t
::
type_t
::
setcode
;
element_start
++
;
}
if
(
element_start
>=
str
.
size
())
break
;
wchar_t
delimiter
=
separator
;
if
(
str
[
element_start
]
==
quotation
)
{
delimiter
=
quotation
;
element_start
++
;
}
size_t
element_end
=
str
.
find_first_of
(
delimiter
,
element_start
);
if
(
element_end
!=
std
::
wstring
::
npos
)
{
size_t
length
=
element_end
-
element_start
;
element
.
keyword
=
str
.
substr
(
element_start
,
length
);
}
else
element
.
keyword
=
str
.
substr
(
element_start
);
element
.
setcode
=
dataManager
.
GetSetCode
(
element
.
keyword
.
c_str
());
query_elements
.
push_back
(
element
);
if
(
element_end
==
std
::
wstring
::
npos
)
break
;
element_start
=
element_end
+
1
;
element_start
=
element_end
+
1
;
}
else
}
}
else
{
element_t
element
;
size_t
element_start
=
0
;
if
(
str
[
element_start
]
==
L'$'
)
{
element
.
type
=
element_t
::
type_t
::
name
;
element_start
++
;
element_start
++
;
}
else
if
(
str
[
element_start
]
==
L'@'
)
{
element
.
type
=
element_t
::
type_t
::
setcode
;
element_start
++
;
}
if
(
element_start
<
str
.
size
())
{
element
.
setcode
=
dataManager
.
GetSetCode
(
element
.
keyword
.
c_str
());
element
.
keyword
=
str
.
substr
(
element_start
);
query_elements
.
push_back
(
element
);
}
}
}
query_elements
.
push_back
(
str
.
substr
(
element_start
));
std
::
unordered_map
<
std
::
wstring
,
unsigned
int
>
set_code_map
;
for
(
auto
elements_iterator
=
query_elements
.
begin
();
elements_iterator
!=
query_elements
.
end
();
elements_iterator
++
)
{
const
wchar_t
*
element_pointer
=
elements_iterator
->
c_str
();
if
(
element_pointer
[
0
]
==
L'@'
)
set_code_map
[
*
elements_iterator
]
=
dataManager
.
GetSetCode
(
&
element_pointer
[
1
]);
else
set_code_map
[
*
elements_iterator
]
=
dataManager
.
GetSetCode
(
&
element_pointer
[
0
]);
if
(
element_pointer
[
0
]
==
0
||
(
element_pointer
[
0
]
==
L'$'
&&
element_pointer
[
1
]
==
0
)
||
(
element_pointer
[
0
]
==
L'@'
&&
element_pointer
[
1
]
==
0
))
query_elements_track
.
push_back
(
elements_iterator
);
}
for
(
auto
elements_track_iterator
=
query_elements_track
.
begin
();
elements_track_iterator
!=
query_elements_track
.
end
();
elements_track_iterator
++
)
query_elements
.
erase
(
*
elements_track_iterator
);
unsigned
int
set_code
=
0
;
if
(
pstr
[
0
]
==
L'@'
)
set_code
=
dataManager
.
GetSetCode
(
&
pstr
[
1
]);
else
set_code
=
dataManager
.
GetSetCode
(
&
pstr
[
0
]);
if
(
pstr
[
0
]
==
0
||
(
pstr
[
0
]
==
L'$'
&&
pstr
[
1
]
==
0
)
||
(
pstr
[
0
]
==
L'@'
&&
pstr
[
1
]
==
0
))
pstr
=
0
;
auto
strpointer
=
dataManager
.
_strings
.
begin
();
auto
strpointer
=
dataManager
.
_strings
.
begin
();
for
(
code_pointer
ptr
=
dataManager
.
_datas
.
begin
();
ptr
!=
dataManager
.
_datas
.
end
();
++
ptr
,
++
strpointer
)
{
for
(
code_pointer
ptr
=
dataManager
.
_datas
.
begin
();
ptr
!=
dataManager
.
_datas
.
end
();
++
ptr
,
++
strpointer
)
{
const
CardDataC
&
data
=
ptr
->
second
;
const
CardDataC
&
data
=
ptr
->
second
;
...
@@ -885,33 +921,29 @@ void DeckBuilder::FilterCards() {
...
@@ -885,33 +921,29 @@ void DeckBuilder::FilterCards() {
continue
;
continue
;
}
}
bool
is_target
=
true
;
bool
is_target
=
true
;
for
(
auto
elements_iterator
=
query_elements
.
begin
();
elements_iterator
!=
query_elements
.
end
();
elements_iterator
++
)
{
for
(
auto
elements_iterator
=
query_elements
.
begin
();
elements_iterator
!=
query_elements
.
end
();
++
elements_iterator
)
{
const
wchar_t
*
element_pointer
=
elements_iterator
->
c_str
();
bool
match
=
false
;
if
(
element_pointer
[
0
]
==
L'$'
)
{
if
(
elements_iterator
->
type
==
element_t
::
type_t
::
name
)
{
if
(
!
CardNameContains
(
text
.
name
.
c_str
(),
&
element_pointer
[
1
])){
match
=
CardNameContains
(
text
.
name
.
c_str
(),
elements_iterator
->
keyword
.
c_str
());
is_target
=
false
;
}
else
if
(
elements_iterator
->
type
==
element_t
::
type_t
::
setcode
)
{
break
;
match
=
elements_iterator
->
setcode
&&
check_set_code
(
data
,
elements_iterator
->
setcode
);
}
}
else
if
(
element_pointer
[
0
]
==
L'@'
&&
set_code_map
[
*
elements_iterator
])
{
if
(
!
check_set_code
(
data
,
set_code_map
[
*
elements_iterator
]))
{
is_target
=
false
;
break
;
}
}
else
{
}
else
{
int
trycode
=
BufferIO
::
GetVal
(
elements_iterator
->
c_str
());
int
trycode
=
BufferIO
::
GetVal
(
elements_iterator
->
keyword
.
c_str
());
bool
tryresult
=
dataManager
.
GetData
(
trycode
,
0
);
bool
tryresult
=
dataManager
.
GetData
(
trycode
,
0
);
if
(
!
tryresult
&&
!
CardNameContains
(
text
.
name
.
c_str
(),
elements_iterator
->
c_str
())
&&
text
.
text
.
find
(
elements_iterator
->
c_str
())
==
std
::
wstring
::
npos
if
(
!
tryresult
)
{
&&
(
!
set_code_map
[
*
elements_iterator
]
||
!
check_set_code
(
data
,
set_code_map
[
*
elements_iterator
])))
{
match
=
CardNameContains
(
text
.
name
.
c_str
(),
elements_iterator
->
keyword
.
c_str
())
is_target
=
false
;
||
text
.
text
.
find
(
elements_iterator
->
keyword
)
!=
std
::
wstring
::
npos
break
;
||
(
elements_iterator
->
setcode
&&
check_set_code
(
data
,
elements_iterator
->
setcode
));
}
}
else
{
if
(
tryresult
&&
data
.
code
!=
trycode
match
=
data
.
code
==
trycode
||
data
.
alias
==
trycode
;
&&
!
(
data
.
alias
==
trycode
&&
(
data
.
alias
-
data
.
code
<
CARD_ARTWORK_VERSIONS_OFFSET
||
data
.
code
-
data
.
alias
<
CARD_ARTWORK_VERSIONS_OFFSET
)))
{
is_target
=
false
;
break
;
}
}
}
}
if
(
elements_iterator
->
exclude
)
match
=
!
match
;
if
(
!
match
)
{
is_target
=
false
;
break
;
}
}
}
if
(
is_target
)
if
(
is_target
)
results
.
push_back
(
ptr
);
results
.
push_back
(
ptr
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment