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
YGOPRO-520DIY
ygopro
Commits
b9e1089f
Commit
b9e1089f
authored
Jun 18, 2025
by
mercury233
Committed by
GitHub
Jun 18, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add import/export deck code (#2577)
parent
97af9bb3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
17 deletions
+74
-17
gframe/deck_con.cpp
gframe/deck_con.cpp
+38
-4
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+19
-9
gframe/deck_manager.h
gframe/deck_manager.h
+2
-0
gframe/game.cpp
gframe/game.cpp
+8
-4
gframe/game.h
gframe/game.h
+4
-0
strings.conf
strings.conf
+3
-0
No files found.
gframe/deck_con.cpp
View file @
b9e1089f
...
@@ -394,6 +394,29 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -394,6 +394,29 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
prev_operation
=
id
;
prev_operation
=
id
;
break
;
break
;
}
}
case
BUTTON_IMPORT_DECK_CODE
:
{
time_t
nowtime
=
std
::
time
(
nullptr
);
wchar_t
timetext
[
40
];
std
::
wcsftime
(
timetext
,
sizeof
timetext
/
sizeof
timetext
[
0
],
L"%Y-%m-%d %H-%M-%S"
,
std
::
localtime
(
&
nowtime
));
mainGame
->
gMutex
.
lock
();
mainGame
->
stDMMessage
->
setText
(
dataManager
.
GetSysString
(
1471
));
mainGame
->
ebDMName
->
setVisible
(
true
);
mainGame
->
ebDMName
->
setText
(
timetext
);
mainGame
->
PopupElement
(
mainGame
->
wDMQuery
);
mainGame
->
gMutex
.
unlock
();
prev_operation
=
id
;
break
;
}
case
BUTTON_EXPORT_DECK_CODE
:
{
std
::
stringstream
textStream
;
deckManager
.
SaveDeck
(
deckManager
.
current_deck
,
textStream
);
wchar_t
text
[
0x10000
];
BufferIO
::
DecodeUTF8
(
textStream
.
str
().
c_str
(),
text
);
mainGame
->
env
->
getOSOperator
()
->
copyToClipboard
(
text
);
mainGame
->
stACMessage
->
setText
(
dataManager
.
GetSysString
(
1480
));
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
break
;
}
case
BUTTON_DM_OK
:
{
case
BUTTON_DM_OK
:
{
switch
(
prev_operation
)
{
switch
(
prev_operation
)
{
case
BUTTON_NEW_CATEGORY
:
{
case
BUTTON_NEW_CATEGORY
:
{
...
@@ -470,7 +493,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -470,7 +493,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
}
break
;
break
;
}
}
case
BUTTON_NEW_DECK
:
{
case
BUTTON_NEW_DECK
:
case
BUTTON_IMPORT_DECK_CODE
:
{
const
wchar_t
*
deckname
=
mainGame
->
ebDMName
->
getText
();
const
wchar_t
*
deckname
=
mainGame
->
ebDMName
->
getText
();
wchar_t
catepath
[
256
];
wchar_t
catepath
[
256
];
DeckManager
::
GetCategoryPath
(
catepath
,
mainGame
->
cbDBCategory
->
getSelected
(),
mainGame
->
cbDBCategory
->
getText
());
DeckManager
::
GetCategoryPath
(
catepath
,
mainGame
->
cbDBCategory
->
getSelected
(),
mainGame
->
cbDBCategory
->
getText
());
...
@@ -478,9 +502,19 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -478,9 +502,19 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
myswprintf
(
filepath
,
L"%ls/%ls.ydk"
,
catepath
,
deckname
);
myswprintf
(
filepath
,
L"%ls/%ls.ydk"
,
catepath
,
deckname
);
bool
res
=
false
;
bool
res
=
false
;
if
(
!
FileSystem
::
IsFileExists
(
filepath
))
{
if
(
!
FileSystem
::
IsFileExists
(
filepath
))
{
deckManager
.
current_deck
.
main
.
clear
();
if
(
prev_operation
==
BUTTON_NEW_DECK
)
{
deckManager
.
current_deck
.
extra
.
clear
();
deckManager
.
current_deck
.
main
.
clear
();
deckManager
.
current_deck
.
side
.
clear
();
deckManager
.
current_deck
.
extra
.
clear
();
deckManager
.
current_deck
.
side
.
clear
();
}
else
{
const
wchar_t
*
txt
=
mainGame
->
env
->
getOSOperator
()
->
getTextFromClipboard
();
if
(
txt
)
{
char
text
[
0x10000
];
BufferIO
::
EncodeUTF8
(
txt
,
text
);
std
::
istringstream
textStream
(
text
);
deckManager
.
LoadCurrentDeck
(
textStream
);
}
}
res
=
DeckManager
::
SaveDeck
(
deckManager
.
current_deck
,
filepath
);
res
=
DeckManager
::
SaveDeck
(
deckManager
.
current_deck
,
filepath
);
RefreshDeckList
();
RefreshDeckList
();
ChangeCategory
(
mainGame
->
lstCategories
->
getSelected
());
ChangeCategory
(
mainGame
->
lstCategories
->
getSelected
());
...
...
gframe/deck_manager.cpp
View file @
b9e1089f
...
@@ -277,6 +277,10 @@ irr::io::IReadFile* DeckManager::OpenDeckReader(const wchar_t* file) {
...
@@ -277,6 +277,10 @@ irr::io::IReadFile* DeckManager::OpenDeckReader(const wchar_t* file) {
#endif
#endif
return
reader
;
return
reader
;
}
}
bool
DeckManager
::
LoadCurrentDeck
(
std
::
istringstream
&
deckStream
,
bool
is_packlist
)
{
LoadDeckFromStream
(
current_deck
,
deckStream
,
is_packlist
);
return
true
;
// the above LoadDeck has return value but we ignore it here for now
}
bool
DeckManager
::
LoadCurrentDeck
(
const
wchar_t
*
file
,
bool
is_packlist
)
{
bool
DeckManager
::
LoadCurrentDeck
(
const
wchar_t
*
file
,
bool
is_packlist
)
{
current_deck
.
clear
();
current_deck
.
clear
();
auto
reader
=
OpenDeckReader
(
file
);
auto
reader
=
OpenDeckReader
(
file
);
...
@@ -311,21 +315,27 @@ bool DeckManager::LoadCurrentDeck(int category_index, const wchar_t* category_na
...
@@ -311,21 +315,27 @@ bool DeckManager::LoadCurrentDeck(int category_index, const wchar_t* category_na
mainGame
->
deckBuilder
.
RefreshPackListScroll
();
mainGame
->
deckBuilder
.
RefreshPackListScroll
();
return
res
;
return
res
;
}
}
void
DeckManager
::
SaveDeck
(
const
Deck
&
deck
,
std
::
stringstream
&
deckStream
)
{
deckStream
<<
"#created by ..."
<<
std
::
endl
;
deckStream
<<
"#main"
<<
std
::
endl
;
for
(
size_t
i
=
0
;
i
<
deck
.
main
.
size
();
++
i
)
deckStream
<<
deck
.
main
[
i
]
->
first
<<
std
::
endl
;
deckStream
<<
"#extra"
<<
std
::
endl
;
for
(
size_t
i
=
0
;
i
<
deck
.
extra
.
size
();
++
i
)
deckStream
<<
deck
.
extra
[
i
]
->
first
<<
std
::
endl
;
deckStream
<<
"!side"
<<
std
::
endl
;
for
(
size_t
i
=
0
;
i
<
deck
.
side
.
size
();
++
i
)
deckStream
<<
deck
.
side
[
i
]
->
first
<<
std
::
endl
;
}
bool
DeckManager
::
SaveDeck
(
const
Deck
&
deck
,
const
wchar_t
*
file
)
{
bool
DeckManager
::
SaveDeck
(
const
Deck
&
deck
,
const
wchar_t
*
file
)
{
if
(
!
FileSystem
::
IsDirExists
(
L"./deck"
)
&&
!
FileSystem
::
MakeDir
(
L"./deck"
))
if
(
!
FileSystem
::
IsDirExists
(
L"./deck"
)
&&
!
FileSystem
::
MakeDir
(
L"./deck"
))
return
false
;
return
false
;
FILE
*
fp
=
OpenDeckFile
(
file
,
"w"
);
FILE
*
fp
=
OpenDeckFile
(
file
,
"w"
);
if
(
!
fp
)
if
(
!
fp
)
return
false
;
return
false
;
std
::
fprintf
(
fp
,
"#created by ...
\n
#main
\n
"
);
std
::
stringstream
deckStream
;
for
(
size_t
i
=
0
;
i
<
deck
.
main
.
size
();
++
i
)
SaveDeck
(
deck
,
deckStream
);
std
::
fprintf
(
fp
,
"%u
\n
"
,
deck
.
main
[
i
]
->
first
);
std
::
fwrite
(
deckStream
.
str
().
c_str
(),
1
,
deckStream
.
str
().
length
(),
fp
);
std
::
fprintf
(
fp
,
"#extra
\n
"
);
for
(
size_t
i
=
0
;
i
<
deck
.
extra
.
size
();
++
i
)
std
::
fprintf
(
fp
,
"%u
\n
"
,
deck
.
extra
[
i
]
->
first
);
std
::
fprintf
(
fp
,
"!side
\n
"
);
for
(
size_t
i
=
0
;
i
<
deck
.
side
.
size
();
++
i
)
std
::
fprintf
(
fp
,
"%u
\n
"
,
deck
.
side
[
i
]
->
first
);
std
::
fclose
(
fp
);
std
::
fclose
(
fp
);
return
true
;
return
true
;
}
}
...
...
gframe/deck_manager.h
View file @
b9e1089f
...
@@ -55,6 +55,7 @@ public:
...
@@ -55,6 +55,7 @@ public:
unsigned
int
CheckDeck
(
const
Deck
&
deck
,
unsigned
int
lfhash
,
int
rule
);
unsigned
int
CheckDeck
(
const
Deck
&
deck
,
unsigned
int
lfhash
,
int
rule
);
bool
LoadCurrentDeck
(
const
wchar_t
*
file
,
bool
is_packlist
=
false
);
bool
LoadCurrentDeck
(
const
wchar_t
*
file
,
bool
is_packlist
=
false
);
bool
LoadCurrentDeck
(
int
category_index
,
const
wchar_t
*
category_name
,
const
wchar_t
*
deckname
);
bool
LoadCurrentDeck
(
int
category_index
,
const
wchar_t
*
category_name
,
const
wchar_t
*
deckname
);
bool
LoadCurrentDeck
(
std
::
istringstream
&
deckStream
,
bool
is_packlist
=
false
);
static
uint32_t
LoadDeck
(
Deck
&
deck
,
uint32_t
dbuf
[],
int
mainc
,
int
sidec
,
bool
is_packlist
=
false
);
static
uint32_t
LoadDeck
(
Deck
&
deck
,
uint32_t
dbuf
[],
int
mainc
,
int
sidec
,
bool
is_packlist
=
false
);
static
uint32_t
LoadDeckFromStream
(
Deck
&
deck
,
std
::
istringstream
&
deckStream
,
bool
is_packlist
=
false
);
static
uint32_t
LoadDeckFromStream
(
Deck
&
deck
,
std
::
istringstream
&
deckStream
,
bool
is_packlist
=
false
);
...
@@ -64,6 +65,7 @@ public:
...
@@ -64,6 +65,7 @@ public:
static
FILE
*
OpenDeckFile
(
const
wchar_t
*
file
,
const
char
*
mode
);
static
FILE
*
OpenDeckFile
(
const
wchar_t
*
file
,
const
char
*
mode
);
static
irr
::
io
::
IReadFile
*
OpenDeckReader
(
const
wchar_t
*
file
);
static
irr
::
io
::
IReadFile
*
OpenDeckReader
(
const
wchar_t
*
file
);
static
bool
SaveDeck
(
const
Deck
&
deck
,
const
wchar_t
*
file
);
static
bool
SaveDeck
(
const
Deck
&
deck
,
const
wchar_t
*
file
);
static
void
SaveDeck
(
const
Deck
&
deck
,
std
::
stringstream
&
deckStream
);
static
bool
DeleteDeck
(
const
wchar_t
*
file
);
static
bool
DeleteDeck
(
const
wchar_t
*
file
);
static
bool
CreateCategory
(
const
wchar_t
*
name
);
static
bool
CreateCategory
(
const
wchar_t
*
name
);
static
bool
RenameCategory
(
const
wchar_t
*
oldname
,
const
wchar_t
*
newname
);
static
bool
RenameCategory
(
const
wchar_t
*
oldname
,
const
wchar_t
*
newname
);
...
...
gframe/game.cpp
View file @
b9e1089f
...
@@ -634,10 +634,10 @@ bool Game::Initialize() {
...
@@ -634,10 +634,10 @@ bool Game::Initialize() {
wDeckEdit
->
setVisible
(
false
);
wDeckEdit
->
setVisible
(
false
);
btnManageDeck
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
225
,
5
,
290
,
30
),
wDeckEdit
,
BUTTON_MANAGE_DECK
,
dataManager
.
GetSysString
(
1328
));
btnManageDeck
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
225
,
5
,
290
,
30
),
wDeckEdit
,
BUTTON_MANAGE_DECK
,
dataManager
.
GetSysString
(
1328
));
//deck manage
//deck manage
wDeckManage
=
env
->
addWindow
(
irr
::
core
::
rect
<
irr
::
s32
>
(
310
,
135
,
800
,
46
5
),
false
,
dataManager
.
GetSysString
(
1460
),
0
,
WINDOW_DECK_MANAGE
);
wDeckManage
=
env
->
addWindow
(
irr
::
core
::
rect
<
irr
::
s32
>
(
310
,
135
,
800
,
51
5
),
false
,
dataManager
.
GetSysString
(
1460
),
0
,
WINDOW_DECK_MANAGE
);
wDeckManage
->
setVisible
(
false
);
wDeckManage
->
setVisible
(
false
);
lstCategories
=
env
->
addListBox
(
irr
::
core
::
rect
<
irr
::
s32
>
(
10
,
30
,
140
,
3
2
0
),
wDeckManage
,
LISTBOX_CATEGORIES
,
true
);
lstCategories
=
env
->
addListBox
(
irr
::
core
::
rect
<
irr
::
s32
>
(
10
,
30
,
140
,
3
7
0
),
wDeckManage
,
LISTBOX_CATEGORIES
,
true
);
lstDecks
=
env
->
addListBox
(
irr
::
core
::
rect
<
irr
::
s32
>
(
150
,
30
,
340
,
3
2
0
),
wDeckManage
,
LISTBOX_DECKS
,
true
);
lstDecks
=
env
->
addListBox
(
irr
::
core
::
rect
<
irr
::
s32
>
(
150
,
30
,
340
,
3
7
0
),
wDeckManage
,
LISTBOX_DECKS
,
true
);
posY
=
30
;
posY
=
30
;
btnNewCategory
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
350
,
posY
,
480
,
posY
+
25
),
wDeckManage
,
BUTTON_NEW_CATEGORY
,
dataManager
.
GetSysString
(
1461
));
btnNewCategory
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
350
,
posY
,
480
,
posY
+
25
),
wDeckManage
,
BUTTON_NEW_CATEGORY
,
dataManager
.
GetSysString
(
1461
));
posY
+=
35
;
posY
+=
35
;
...
@@ -654,6 +654,10 @@ bool Game::Initialize() {
...
@@ -654,6 +654,10 @@ bool Game::Initialize() {
btnMoveDeck
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
350
,
posY
,
480
,
posY
+
25
),
wDeckManage
,
BUTTON_MOVE_DECK
,
dataManager
.
GetSysString
(
1467
));
btnMoveDeck
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
350
,
posY
,
480
,
posY
+
25
),
wDeckManage
,
BUTTON_MOVE_DECK
,
dataManager
.
GetSysString
(
1467
));
posY
+=
35
;
posY
+=
35
;
btnCopyDeck
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
350
,
posY
,
480
,
posY
+
25
),
wDeckManage
,
BUTTON_COPY_DECK
,
dataManager
.
GetSysString
(
1468
));
btnCopyDeck
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
350
,
posY
,
480
,
posY
+
25
),
wDeckManage
,
BUTTON_COPY_DECK
,
dataManager
.
GetSysString
(
1468
));
posY
+=
35
;
btnImportDeckCode
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
350
,
posY
,
480
,
posY
+
25
),
wDeckManage
,
BUTTON_IMPORT_DECK_CODE
,
dataManager
.
GetSysString
(
1478
));
posY
+=
35
;
btnExportDeckCode
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
350
,
posY
,
480
,
posY
+
25
),
wDeckManage
,
BUTTON_EXPORT_DECK_CODE
,
dataManager
.
GetSysString
(
1479
));
//deck manage query
//deck manage query
wDMQuery
=
env
->
addWindow
(
irr
::
core
::
rect
<
irr
::
s32
>
(
400
,
200
,
710
,
320
),
false
,
dataManager
.
GetSysString
(
1460
));
wDMQuery
=
env
->
addWindow
(
irr
::
core
::
rect
<
irr
::
s32
>
(
400
,
200
,
710
,
320
),
false
,
dataManager
.
GetSysString
(
1460
));
wDMQuery
->
getCloseButton
()
->
setVisible
(
false
);
wDMQuery
->
getCloseButton
()
->
setVisible
(
false
);
...
@@ -1868,7 +1872,7 @@ void Game::OnResize() {
...
@@ -1868,7 +1872,7 @@ void Game::OnResize() {
ebDeckname
->
setRelativePosition
(
Resize
(
80
,
65
,
220
,
90
));
ebDeckname
->
setRelativePosition
(
Resize
(
80
,
65
,
220
,
90
));
cbDBCategory
->
setRelativePosition
(
Resize
(
80
,
5
,
220
,
30
));
cbDBCategory
->
setRelativePosition
(
Resize
(
80
,
5
,
220
,
30
));
btnManageDeck
->
setRelativePosition
(
Resize
(
225
,
5
,
290
,
30
));
btnManageDeck
->
setRelativePosition
(
Resize
(
225
,
5
,
290
,
30
));
wDeckManage
->
setRelativePosition
(
ResizeWin
(
310
,
135
,
800
,
46
5
));
wDeckManage
->
setRelativePosition
(
ResizeWin
(
310
,
135
,
800
,
51
5
));
scrPackCards
->
setRelativePosition
(
Resize
(
775
,
161
,
795
,
629
));
scrPackCards
->
setRelativePosition
(
Resize
(
775
,
161
,
795
,
629
));
wSort
->
setRelativePosition
(
Resize
(
930
,
132
,
1020
,
156
));
wSort
->
setRelativePosition
(
Resize
(
930
,
132
,
1020
,
156
));
...
...
gframe/game.h
View file @
b9e1089f
...
@@ -567,6 +567,8 @@ public:
...
@@ -567,6 +567,8 @@ public:
irr
::
gui
::
IGUIButton
*
btnDMDeleteDeck
;
irr
::
gui
::
IGUIButton
*
btnDMDeleteDeck
;
irr
::
gui
::
IGUIButton
*
btnMoveDeck
;
irr
::
gui
::
IGUIButton
*
btnMoveDeck
;
irr
::
gui
::
IGUIButton
*
btnCopyDeck
;
irr
::
gui
::
IGUIButton
*
btnCopyDeck
;
irr
::
gui
::
IGUIButton
*
btnImportDeckCode
;
irr
::
gui
::
IGUIButton
*
btnExportDeckCode
;
irr
::
gui
::
IGUIWindow
*
wDMQuery
;
irr
::
gui
::
IGUIWindow
*
wDMQuery
;
irr
::
gui
::
IGUIStaticText
*
stDMMessage
;
irr
::
gui
::
IGUIStaticText
*
stDMMessage
;
irr
::
gui
::
IGUIStaticText
*
stDMMessage2
;
irr
::
gui
::
IGUIStaticText
*
stDMMessage2
;
...
@@ -820,6 +822,8 @@ extern Game* mainGame;
...
@@ -820,6 +822,8 @@ extern Game* mainGame;
#define LISTBOX_DECKS 340
#define LISTBOX_DECKS 340
#define BUTTON_DM_OK 341
#define BUTTON_DM_OK 341
#define BUTTON_DM_CANCEL 342
#define BUTTON_DM_CANCEL 342
#define BUTTON_IMPORT_DECK_CODE 343
#define BUTTON_EXPORT_DECK_CODE 344
#define COMBOBOX_LFLIST 349
#define COMBOBOX_LFLIST 349
#define BUTTON_CLEAR_LOG 350
#define BUTTON_CLEAR_LOG 350
...
...
strings.conf
View file @
b9e1089f
...
@@ -493,6 +493,9 @@
...
@@ -493,6 +493,9 @@
!
system
1475
已存在同名卡组
!
system
1475
已存在同名卡组
!
system
1476
删除失败
!
system
1476
删除失败
!
system
1477
卡片数:
!
system
1477
卡片数:
!
system
1478
导入卡组码
!
system
1479
导出卡组码
!
system
1480
已导出到剪贴板
!
system
1481
OCG
!
system
1481
OCG
!
system
1482
TCG
!
system
1482
TCG
!
system
1483
简体中文
!
system
1483
简体中文
...
...
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