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
baichixing
ygopro
Commits
317ce145
Commit
317ce145
authored
Apr 27, 2017
by
mercury233
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-deck-autosearch' of
https://github.com/IceYGO/ygopro
into temp-merge
parents
2df085c6
0586ca05
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
21 deletions
+70
-21
gframe/deck_con.cpp
gframe/deck_con.cpp
+67
-21
gframe/deck_con.h
gframe/deck_con.h
+3
-0
No files found.
gframe/deck_con.cpp
View file @
317ce145
...
@@ -159,18 +159,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -159,18 +159,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_START_FILTER
:
{
case
BUTTON_START_FILTER
:
{
filter_type
=
mainGame
->
cbCardType
->
getSelected
();
StartFilter
();
filter_type2
=
mainGame
->
cbCardType2
->
getItemData
(
mainGame
->
cbCardType2
->
getSelected
());
filter_lm
=
mainGame
->
cbLimit
->
getSelected
();
if
(
filter_type
==
1
)
{
filter_attrib
=
mainGame
->
cbAttribute
->
getItemData
(
mainGame
->
cbAttribute
->
getSelected
());
filter_race
=
mainGame
->
cbRace
->
getItemData
(
mainGame
->
cbRace
->
getSelected
());
filter_atk
=
parse_filter
(
mainGame
->
ebAttack
->
getText
(),
&
filter_atktype
);
filter_def
=
parse_filter
(
mainGame
->
ebDefense
->
getText
(),
&
filter_deftype
);
filter_lv
=
parse_filter
(
mainGame
->
ebStar
->
getText
(),
&
filter_lvtype
);
filter_scl
=
parse_filter
(
mainGame
->
ebScale
->
getText
(),
&
filter_scltype
);
}
FilterCards
();
if
(
!
mainGame
->
gameConf
.
separate_clear_button
)
if
(
!
mainGame
->
gameConf
.
separate_clear_button
)
ClearFilter
();
ClearFilter
();
break
;
break
;
...
@@ -285,12 +274,16 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -285,12 +274,16 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case
irr
:
:
gui
::
EGET_EDITBOX_ENTER
:
{
case
irr
:
:
gui
::
EGET_EDITBOX_ENTER
:
{
switch
(
id
)
{
switch
(
id
)
{
case
EDITBOX_KEYWORD
:
{
case
EDITBOX_KEYWORD
:
{
irr
::
SEvent
me
;
StartFilter
();
me
.
EventType
=
irr
::
EET_GUI_EVENT
;
break
;
me
.
GUIEvent
.
EventType
=
irr
::
gui
::
EGET_BUTTON_CLICKED
;
}
me
.
GUIEvent
.
Caller
=
mainGame
->
btnStartFilter
;
}
me
.
GUIEvent
.
Element
=
mainGame
->
btnStartFilter
;
break
;
mainGame
->
device
->
postEventFromUser
(
me
);
}
case
irr
:
:
gui
::
EGET_EDITBOX_CHANGED
:
{
switch
(
id
)
{
case
EDITBOX_KEYWORD
:
{
StartFilter
();
break
;
break
;
}
}
}
}
...
@@ -810,6 +803,20 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -810,6 +803,20 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
}
return
false
;
return
false
;
}
}
void
DeckBuilder
::
StartFilter
()
{
filter_type
=
mainGame
->
cbCardType
->
getSelected
();
filter_type2
=
mainGame
->
cbCardType2
->
getItemData
(
mainGame
->
cbCardType2
->
getSelected
());
filter_lm
=
mainGame
->
cbLimit
->
getSelected
();
if
(
filter_type
==
1
)
{
filter_attrib
=
mainGame
->
cbAttribute
->
getItemData
(
mainGame
->
cbAttribute
->
getSelected
());
filter_race
=
mainGame
->
cbRace
->
getItemData
(
mainGame
->
cbRace
->
getSelected
());
filter_atk
=
parse_filter
(
mainGame
->
ebAttack
->
getText
(),
&
filter_atktype
);
filter_def
=
parse_filter
(
mainGame
->
ebDefense
->
getText
(),
&
filter_deftype
);
filter_lv
=
parse_filter
(
mainGame
->
ebStar
->
getText
(),
&
filter_lvtype
);
filter_scl
=
parse_filter
(
mainGame
->
ebScale
->
getText
(),
&
filter_scltype
);
}
FilterCards
();
}
void
DeckBuilder
::
FilterCards
()
{
void
DeckBuilder
::
FilterCards
()
{
results
.
clear
();
results
.
clear
();
const
wchar_t
*
pstr
=
mainGame
->
ebCardName
->
getText
();
const
wchar_t
*
pstr
=
mainGame
->
ebCardName
->
getText
();
...
@@ -903,12 +910,12 @@ void DeckBuilder::FilterCards() {
...
@@ -903,12 +910,12 @@ void DeckBuilder::FilterCards() {
}
}
if
(
pstr
)
{
if
(
pstr
)
{
if
(
pstr
[
0
]
==
L'$'
)
{
if
(
pstr
[
0
]
==
L'$'
)
{
if
(
wcsstr
(
text
.
name
,
&
pstr
[
1
])
==
0
)
if
(
!
CardNameContains
(
text
.
name
,
&
pstr
[
1
])
)
continue
;
continue
;
}
else
if
(
pstr
[
0
]
==
L'@'
&&
set_code
)
{
}
else
if
(
pstr
[
0
]
==
L'@'
&&
set_code
)
{
if
(
!
check_set_code
(
data
,
set_code
))
continue
;
if
(
!
check_set_code
(
data
,
set_code
))
continue
;
}
else
{
}
else
{
if
(
wcsstr
(
text
.
name
,
pstr
)
==
0
&&
wcsstr
(
text
.
text
,
pstr
)
==
0
if
(
!
CardNameContains
(
text
.
name
,
pstr
)
&&
wcsstr
(
text
.
text
,
pstr
)
==
0
&&
(
!
set_code
||
!
check_set_code
(
data
,
set_code
)))
&&
(
!
set_code
||
!
check_set_code
(
data
,
set_code
)))
continue
;
continue
;
}
}
...
@@ -978,5 +985,44 @@ void DeckBuilder::SortList() {
...
@@ -978,5 +985,44 @@ void DeckBuilder::SortList() {
break
;
break
;
}
}
}
}
static
inline
wchar_t
NormalizeChar
(
wchar_t
c
)
{
// Convert all symbols and punctuations to space.
if
(
c
!=
0
&&
c
<
128
&&
!
isalnum
(
c
))
{
return
' '
;
}
// Convert latin chararacters to uppercase to ignore case.
if
(
c
<
128
&&
isalpha
(
c
))
{
return
toupper
(
c
);
}
// Remove some accentued characters that are not supported by the editbox.
if
(
c
>=
232
&&
c
<=
235
)
{
return
'E'
;
}
if
(
c
>=
238
&&
c
<=
239
)
{
return
'I'
;
}
return
c
;
}
bool
DeckBuilder
::
CardNameContains
(
const
wchar_t
*
haystack
,
const
wchar_t
*
needle
)
{
if
(
!
needle
[
0
])
{
return
true
;
}
int
i
=
0
;
int
j
=
0
;
while
(
haystack
[
i
])
{
wchar_t
ca
=
NormalizeChar
(
haystack
[
i
]);
wchar_t
cb
=
NormalizeChar
(
needle
[
j
]);
if
(
ca
==
cb
)
{
j
++
;
if
(
!
needle
[
j
])
{
return
true
;
}
}
else
{
j
=
0
;
}
i
++
;
}
return
false
;
}
}
}
gframe/deck_con.h
View file @
317ce145
...
@@ -12,10 +12,13 @@ class DeckBuilder: public irr::IEventReceiver {
...
@@ -12,10 +12,13 @@ class DeckBuilder: public irr::IEventReceiver {
public:
public:
virtual
bool
OnEvent
(
const
irr
::
SEvent
&
event
);
virtual
bool
OnEvent
(
const
irr
::
SEvent
&
event
);
void
FilterCards
();
void
FilterCards
();
void
StartFilter
();
void
ClearFilter
();
void
ClearFilter
();
void
ClearSearch
();
void
ClearSearch
();
void
SortList
();
void
SortList
();
bool
CardNameContains
(
const
wchar_t
*
haystack
,
const
wchar_t
*
needle
);
long
long
filter_effect
;
long
long
filter_effect
;
unsigned
int
filter_type
;
unsigned
int
filter_type
;
unsigned
int
filter_type2
;
unsigned
int
filter_type2
;
...
...
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