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
nanahira
ygopro
Commits
0586ca05
Commit
0586ca05
authored
Jan 02, 2016
by
IceYGO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search the cards while typing in the deck editor and ignore the case
parent
bc0181d3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
172 additions
and
104 deletions
+172
-104
gframe/deck_con.cpp
gframe/deck_con.cpp
+170
-104
gframe/deck_con.h
gframe/deck_con.h
+2
-0
No files found.
gframe/deck_con.cpp
View file @
0586ca05
...
@@ -86,101 +86,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -86,101 +86,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
)
{
FilterCards
();
break
;
}
filter_attrib
=
mainGame
->
cbAttribute
->
getItemData
(
mainGame
->
cbAttribute
->
getSelected
());
filter_race
=
mainGame
->
cbRace
->
getItemData
(
mainGame
->
cbRace
->
getSelected
());
const
wchar_t
*
pstr
=
mainGame
->
ebAttack
->
getText
();
if
(
*
pstr
==
0
)
filter_atktype
=
0
;
else
{
if
(
*
pstr
==
L'='
)
{
filter_atktype
=
1
;
filter_atk
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
else
if
(
*
pstr
>=
L'0'
&&
*
pstr
<=
L'9'
)
{
filter_atktype
=
1
;
filter_atk
=
BufferIO
::
GetVal
(
pstr
);
}
else
if
(
*
pstr
==
L'>'
)
{
if
(
*
(
pstr
+
1
)
==
L'='
)
{
filter_atktype
=
2
;
filter_atk
=
BufferIO
::
GetVal
(
pstr
+
2
);
}
else
{
filter_atktype
=
3
;
filter_atk
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
}
else
if
(
*
pstr
==
L'<'
)
{
if
(
*
(
pstr
+
1
)
==
L'='
)
{
filter_atktype
=
4
;
filter_atk
=
BufferIO
::
GetVal
(
pstr
+
2
);
}
else
{
filter_atktype
=
5
;
filter_atk
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
}
else
if
(
*
pstr
==
L'?'
)
{
filter_atktype
=
6
;
}
else
filter_atktype
=
0
;
}
pstr
=
mainGame
->
ebDefence
->
getText
();
if
(
*
pstr
==
0
)
filter_deftype
=
0
;
else
{
if
(
*
pstr
==
L'='
)
{
filter_deftype
=
1
;
filter_def
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
else
if
(
*
pstr
>=
L'0'
&&
*
pstr
<=
L'9'
)
{
filter_deftype
=
1
;
filter_def
=
BufferIO
::
GetVal
(
pstr
);
}
else
if
(
*
pstr
==
L'>'
)
{
if
(
*
(
pstr
+
1
)
==
L'='
)
{
filter_deftype
=
2
;
filter_def
=
BufferIO
::
GetVal
(
pstr
+
2
);
}
else
{
filter_deftype
=
3
;
filter_def
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
}
else
if
(
*
pstr
==
L'<'
)
{
if
(
*
(
pstr
+
1
)
==
L'='
)
{
filter_deftype
=
4
;
filter_def
=
BufferIO
::
GetVal
(
pstr
+
2
);
}
else
{
filter_deftype
=
5
;
filter_def
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
}
else
if
(
*
pstr
==
L'?'
)
{
filter_deftype
=
6
;
}
else
filter_deftype
=
0
;
}
pstr
=
mainGame
->
ebStar
->
getText
();
if
(
*
pstr
==
0
)
filter_lvtype
=
0
;
else
{
if
(
*
pstr
==
L'='
)
{
filter_lvtype
=
1
;
filter_lv
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
else
if
(
*
pstr
>=
L'0'
&&
*
pstr
<=
L'9'
)
{
filter_lvtype
=
1
;
filter_lv
=
BufferIO
::
GetVal
(
pstr
);
}
else
if
(
*
pstr
==
L'>'
)
{
if
(
*
(
pstr
+
1
)
==
L'='
)
{
filter_lvtype
=
2
;
filter_lv
=
BufferIO
::
GetVal
(
pstr
+
2
);
}
else
{
filter_lvtype
=
3
;
filter_lv
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
}
else
if
(
*
pstr
==
L'<'
)
{
if
(
*
(
pstr
+
1
)
==
L'='
)
{
filter_lvtype
=
4
;
filter_lv
=
BufferIO
::
GetVal
(
pstr
+
2
);
}
else
{
filter_lvtype
=
5
;
filter_lv
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
}
else
filter_lvtype
=
0
;
}
FilterCards
();
break
;
break
;
}
}
case
BUTTON_CATEGORY_OK
:
{
case
BUTTON_CATEGORY_OK
:
{
...
@@ -227,12 +133,16 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -227,12 +133,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
;
}
}
}
}
...
@@ -645,6 +555,123 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -645,6 +555,123 @@ 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
)
{
FilterCards
();
return
;
}
filter_attrib
=
mainGame
->
cbAttribute
->
getItemData
(
mainGame
->
cbAttribute
->
getSelected
());
filter_race
=
mainGame
->
cbRace
->
getItemData
(
mainGame
->
cbRace
->
getSelected
());
const
wchar_t
*
pstr
=
mainGame
->
ebAttack
->
getText
();
if
(
*
pstr
==
0
)
filter_atktype
=
0
;
else
{
if
(
*
pstr
==
L'='
)
{
filter_atktype
=
1
;
filter_atk
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
else
if
(
*
pstr
>=
L'0'
&&
*
pstr
<=
L'9'
)
{
filter_atktype
=
1
;
filter_atk
=
BufferIO
::
GetVal
(
pstr
);
}
else
if
(
*
pstr
==
L'>'
)
{
if
(
*
(
pstr
+
1
)
==
L'='
)
{
filter_atktype
=
2
;
filter_atk
=
BufferIO
::
GetVal
(
pstr
+
2
);
}
else
{
filter_atktype
=
3
;
filter_atk
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
}
else
if
(
*
pstr
==
L'<'
)
{
if
(
*
(
pstr
+
1
)
==
L'='
)
{
filter_atktype
=
4
;
filter_atk
=
BufferIO
::
GetVal
(
pstr
+
2
);
}
else
{
filter_atktype
=
5
;
filter_atk
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
}
else
if
(
*
pstr
==
L'?'
)
{
filter_atktype
=
6
;
}
else
filter_atktype
=
0
;
}
pstr
=
mainGame
->
ebDefence
->
getText
();
if
(
*
pstr
==
0
)
filter_deftype
=
0
;
else
{
if
(
*
pstr
==
L'='
)
{
filter_deftype
=
1
;
filter_def
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
else
if
(
*
pstr
>=
L'0'
&&
*
pstr
<=
L'9'
)
{
filter_deftype
=
1
;
filter_def
=
BufferIO
::
GetVal
(
pstr
);
}
else
if
(
*
pstr
==
L'>'
)
{
if
(
*
(
pstr
+
1
)
==
L'='
)
{
filter_deftype
=
2
;
filter_def
=
BufferIO
::
GetVal
(
pstr
+
2
);
}
else
{
filter_deftype
=
3
;
filter_def
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
}
else
if
(
*
pstr
==
L'<'
)
{
if
(
*
(
pstr
+
1
)
==
L'='
)
{
filter_deftype
=
4
;
filter_def
=
BufferIO
::
GetVal
(
pstr
+
2
);
}
else
{
filter_deftype
=
5
;
filter_def
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
}
else
if
(
*
pstr
==
L'?'
)
{
filter_deftype
=
6
;
}
else
filter_deftype
=
0
;
}
pstr
=
mainGame
->
ebStar
->
getText
();
if
(
*
pstr
==
0
)
filter_lvtype
=
0
;
else
{
if
(
*
pstr
==
L'='
)
{
filter_lvtype
=
1
;
filter_lv
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
else
if
(
*
pstr
>=
L'0'
&&
*
pstr
<=
L'9'
)
{
filter_lvtype
=
1
;
filter_lv
=
BufferIO
::
GetVal
(
pstr
);
}
else
if
(
*
pstr
==
L'>'
)
{
if
(
*
(
pstr
+
1
)
==
L'='
)
{
filter_lvtype
=
2
;
filter_lv
=
BufferIO
::
GetVal
(
pstr
+
2
);
}
else
{
filter_lvtype
=
3
;
filter_lv
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
}
else
if
(
*
pstr
==
L'<'
)
{
if
(
*
(
pstr
+
1
)
==
L'='
)
{
filter_lvtype
=
4
;
filter_lv
=
BufferIO
::
GetVal
(
pstr
+
2
);
}
else
{
filter_lvtype
=
5
;
filter_lv
=
BufferIO
::
GetVal
(
pstr
+
1
);
}
}
else
filter_lvtype
=
0
;
}
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
();
...
@@ -724,7 +751,7 @@ void DeckBuilder::FilterCards() {
...
@@ -724,7 +751,7 @@ 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
)
{
unsigned
long
long
sc
=
data
.
setcode
;
unsigned
long
long
sc
=
data
.
setcode
;
...
@@ -743,7 +770,7 @@ void DeckBuilder::FilterCards() {
...
@@ -743,7 +770,7 @@ void DeckBuilder::FilterCards() {
}
}
if
(
!
res
)
continue
;
if
(
!
res
)
continue
;
}
else
{
}
else
{
if
(
wcsstr
(
text
.
name
,
pstr
)
==
0
&&
wcsstr
(
text
.
text
,
pstr
)
==
0
)
if
(
!
CardNameContains
(
text
.
name
,
pstr
)
&&
wcsstr
(
text
.
text
,
pstr
)
==
0
)
continue
;
continue
;
}
}
}
}
...
@@ -769,5 +796,44 @@ void DeckBuilder::FilterCards() {
...
@@ -769,5 +796,44 @@ void DeckBuilder::FilterCards() {
for
(
int
i
=
0
;
i
<
32
;
++
i
)
for
(
int
i
=
0
;
i
<
32
;
++
i
)
mainGame
->
chkCategory
[
i
]
->
setChecked
(
false
);
mainGame
->
chkCategory
[
i
]
->
setChecked
(
false
);
}
}
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 @
0586ca05
...
@@ -11,7 +11,9 @@ namespace ygo {
...
@@ -11,7 +11,9 @@ namespace ygo {
class
DeckBuilder
:
public
irr
::
IEventReceiver
{
class
DeckBuilder
:
public
irr
::
IEventReceiver
{
public:
public:
virtual
bool
OnEvent
(
const
irr
::
SEvent
&
event
);
virtual
bool
OnEvent
(
const
irr
::
SEvent
&
event
);
void
StartFilter
();
void
FilterCards
();
void
FilterCards
();
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
;
...
...
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