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
fb780c63
Commit
fb780c63
authored
Mar 18, 2021
by
mercury233
Committed by
GitHub
Mar 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add select bot deckfile (#2333)
parent
993ba1fc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
3 deletions
+42
-3
gframe/game.cpp
gframe/game.cpp
+26
-1
gframe/game.h
gframe/game.h
+3
-0
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+13
-2
No files found.
gframe/game.cpp
View file @
fb780c63
...
...
@@ -722,6 +722,9 @@ bool Game::Initialize() {
btnBotCancel
=
env
->
addButton
(
rect
<
s32
>
(
459
,
331
,
569
,
356
),
tabBot
,
BUTTON_CANCEL_SINGLEPLAY
,
dataManager
.
GetSysString
(
1210
));
env
->
addStaticText
(
dataManager
.
GetSysString
(
1382
),
rect
<
s32
>
(
360
,
10
,
550
,
30
),
false
,
true
,
tabBot
);
stBotInfo
=
env
->
addStaticText
(
L""
,
rect
<
s32
>
(
360
,
40
,
560
,
160
),
false
,
true
,
tabBot
);
cbBotDeck
=
env
->
addComboBox
(
rect
<
s32
>
(
360
,
130
,
560
,
155
),
tabBot
);
cbBotDeck
->
setMaxSelectionRows
(
6
);
cbBotDeck
->
setVisible
(
false
);
cbBotRule
=
env
->
addComboBox
(
rect
<
s32
>
(
360
,
165
,
560
,
190
),
tabBot
,
COMBOBOX_BOT_RULE
);
cbBotRule
->
addItem
(
dataManager
.
GetSysString
(
1262
));
cbBotRule
->
addItem
(
dataManager
.
GetSysString
(
1263
));
...
...
@@ -1105,6 +1108,7 @@ void Game::RefreshBot() {
newinfo
.
support_master_rule_3
=
!!
strstr
(
linebuf
,
"SUPPORT_MASTER_RULE_3"
);
newinfo
.
support_new_master_rule
=
!!
strstr
(
linebuf
,
"SUPPORT_NEW_MASTER_RULE"
);
newinfo
.
support_master_rule_2020
=
!!
strstr
(
linebuf
,
"SUPPORT_MASTER_RULE_2020"
);
newinfo
.
select_deckfile
=
!!
strstr
(
linebuf
,
"SELECT_DECKFILE"
);
int
rule
=
cbBotRule
->
getSelected
()
+
3
;
if
((
rule
==
3
&&
newinfo
.
support_master_rule_3
)
||
(
rule
==
4
&&
newinfo
.
support_new_master_rule
)
...
...
@@ -1120,8 +1124,23 @@ void Game::RefreshBot() {
for
(
unsigned
int
i
=
0
;
i
<
botInfo
.
size
();
++
i
)
{
lstBotList
->
addItem
(
botInfo
[
i
].
name
);
}
if
(
botInfo
.
size
()
==
0
)
if
(
botInfo
.
size
()
==
0
)
{
SetStaticText
(
stBotInfo
,
200
,
guiFont
,
dataManager
.
GetSysString
(
1385
));
}
else
{
cbBotDeck
->
clear
();
cbBotDeck
->
setVisible
(
false
);
irr
::
gui
::
IGUIComboBox
*
cbDeck
=
cbBotDeck
;
FileSystem
::
TraversalDir
(
gameConf
.
bot_deck_path
,
[
cbDeck
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ydk"
,
4
))
{
size_t
len
=
wcslen
(
name
);
wchar_t
deckname
[
256
];
wcsncpy
(
deckname
,
name
,
len
-
4
);
deckname
[
len
-
4
]
=
0
;
cbDeck
->
addItem
(
deckname
);
}
});
}
}
void
Game
::
LoadConfig
()
{
FILE
*
fp
=
fopen
(
"system.conf"
,
"r"
);
...
...
@@ -1144,6 +1163,7 @@ void Game::LoadConfig() {
gameConf
.
lasthost
[
0
]
=
0
;
gameConf
.
lastport
[
0
]
=
0
;
gameConf
.
roompass
[
0
]
=
0
;
gameConf
.
bot_deck_path
[
0
]
=
0
;
//settings
gameConf
.
chkMAutoPos
=
0
;
gameConf
.
chkSTAutoPos
=
1
;
...
...
@@ -1284,6 +1304,9 @@ void Game::LoadConfig() {
}
else
if
(
!
strcmp
(
strbuf
,
"lastdeck"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
lastdeck
,
64
);
}
else
if
(
!
strcmp
(
strbuf
,
"bot_deck_path"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
bot_deck_path
,
64
);
}
}
}
...
...
@@ -1335,6 +1358,8 @@ void Game::SaveConfig() {
fprintf
(
fp
,
"ignore_deck_changes = %d
\n
"
,
(
chkIgnoreDeckChanges
->
isChecked
()
?
1
:
0
));
fprintf
(
fp
,
"default_ot = %d
\n
"
,
gameConf
.
defaultOT
);
fprintf
(
fp
,
"enable_bot_mode = %d
\n
"
,
gameConf
.
enable_bot_mode
);
BufferIO
::
EncodeUTF8
(
gameConf
.
bot_deck_path
,
linebuf
);
fprintf
(
fp
,
"bot_deck_path = %s
\n
"
,
linebuf
);
fprintf
(
fp
,
"quick_animation = %d
\n
"
,
gameConf
.
quick_animation
);
fprintf
(
fp
,
"auto_save_replay = %d
\n
"
,
(
chkAutoSaveReplay
->
isChecked
()
?
1
:
0
));
fprintf
(
fp
,
"draw_single_chain = %d
\n
"
,
gameConf
.
draw_single_chain
);
...
...
gframe/game.h
View file @
fb780c63
...
...
@@ -25,6 +25,7 @@ struct Config {
wchar_t
textfont
[
256
];
wchar_t
numfont
[
256
];
wchar_t
roompass
[
20
];
wchar_t
bot_deck_path
[
64
];
//settings
int
chkMAutoPos
;
int
chkSTAutoPos
;
...
...
@@ -93,6 +94,7 @@ struct BotInfo {
bool
support_master_rule_3
;
bool
support_new_master_rule
;
bool
support_master_rule_2020
;
bool
select_deckfile
;
};
struct
FadingUnit
{
...
...
@@ -366,6 +368,7 @@ public:
irr
::
gui
::
IGUIStaticText
*
stBotInfo
;
irr
::
gui
::
IGUIButton
*
btnStartBot
;
irr
::
gui
::
IGUIButton
*
btnBotCancel
;
irr
::
gui
::
IGUIComboBox
*
cbBotDeck
;
irr
::
gui
::
IGUIComboBox
*
cbBotRule
;
irr
::
gui
::
IGUICheckBox
*
chkBotHand
;
irr
::
gui
::
IGUICheckBox
*
chkBotNoCheckDeck
;
...
...
gframe/menu_handler.cpp
View file @
fb780c63
...
...
@@ -293,9 +293,14 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
si
.
cb
=
sizeof
(
si
);
ZeroMemory
(
&
pi
,
sizeof
(
pi
));
wchar_t
cmd
[
MAX_PATH
];
wchar_t
arg1
[
512
];
if
(
mainGame
->
botInfo
[
sel
].
select_deckfile
)
myswprintf
(
arg1
,
L"%ls DeckFile='%ls'"
,
mainGame
->
botInfo
[
sel
].
command
,
mainGame
->
cbBotDeck
->
getItem
(
mainGame
->
cbBotDeck
->
getSelected
()));
else
myswprintf
(
arg1
,
L"%ls"
,
mainGame
->
botInfo
[
sel
].
command
);
int
flag
=
0
;
flag
+=
(
mainGame
->
chkBotHand
->
isChecked
()
?
0x1
:
0
);
myswprintf
(
cmd
,
L"Bot.exe
\"
%ls
\"
%d %d"
,
mainGame
->
botInfo
[
sel
].
command
,
flag
,
mainGame
->
gameConf
.
serverport
);
myswprintf
(
cmd
,
L"Bot.exe
\"
%ls
\"
%d %d"
,
arg1
,
flag
,
mainGame
->
gameConf
.
serverport
);
if
(
!
CreateProcessW
(
NULL
,
cmd
,
NULL
,
NULL
,
FALSE
,
0
,
NULL
,
NULL
,
&
si
,
&
pi
))
{
NetServer
::
StopServer
();
...
...
@@ -304,8 +309,13 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
#else
if
(
fork
()
==
0
)
{
usleep
(
100000
);
wchar_t
warg1
[
512
];
if
(
mainGame
->
botInfo
[
sel
].
select_deckfile
)
myswprintf
(
warg1
,
L"%ls DeckFile='%ls'"
,
mainGame
->
botInfo
[
sel
].
command
,
mainGame
->
cbBotDeck
->
getItem
(
mainGame
->
cbBotDeck
->
getSelected
()));
else
myswprintf
(
warg1
,
L"%ls"
,
mainGame
->
botInfo
[
sel
].
command
);
char
arg1
[
512
];
BufferIO
::
EncodeUTF8
(
mainGame
->
botInfo
[
sel
].
command
,
arg1
);
BufferIO
::
EncodeUTF8
(
warg1
,
arg1
);
int
flag
=
0
;
flag
+=
(
mainGame
->
chkBotHand
->
isChecked
()
?
0x1
:
0
);
char
arg2
[
8
];
...
...
@@ -514,6 +524,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
if
(
sel
==
-
1
)
break
;
mainGame
->
SetStaticText
(
mainGame
->
stBotInfo
,
200
,
mainGame
->
guiFont
,
mainGame
->
botInfo
[
sel
].
desc
);
mainGame
->
cbBotDeck
->
setVisible
(
mainGame
->
botInfo
[
sel
].
select_deckfile
);
break
;
}
}
...
...
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