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
REIKAI
ygopro
Commits
6667cdc5
Commit
6667cdc5
authored
Dec 08, 2018
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add load cdb from zip
parent
24e5ca92
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
18 deletions
+26
-18
gframe/data_manager.cpp
gframe/data_manager.cpp
+3
-3
gframe/data_manager.h
gframe/data_manager.h
+1
-1
gframe/game.cpp
gframe/game.cpp
+19
-7
gframe/game.h
gframe/game.h
+1
-1
gframe/gframe.cpp
gframe/gframe.cpp
+2
-6
No files found.
gframe/data_manager.cpp
View file @
6667cdc5
...
...
@@ -8,9 +8,7 @@ wchar_t DataManager::strBuffer[4096];
byte
DataManager
::
scriptBuffer
[
0x20000
];
DataManager
dataManager
;
bool
DataManager
::
LoadDB
(
const
char
*
file
)
{
wchar_t
wfile
[
256
];
BufferIO
::
DecodeUTF8
(
file
,
wfile
);
bool
DataManager
::
LoadDB
(
const
wchar_t
*
wfile
)
{
IReadFile
*
reader
=
FileSystem
->
createAndOpenFile
(
wfile
);
if
(
reader
==
NULL
)
return
false
;
...
...
@@ -22,6 +20,8 @@ bool DataManager::LoadDB(const char* file) {
reader
->
read
(
mem
->
data
,
mem
->
total
);
reader
->
drop
();
(
mem
->
data
)[
mem
->
total
]
=
'\0'
;
char
file
[
256
];
BufferIO
::
EncodeUTF8
(
wfile
,
file
);
if
(
spmemvfs_open_db
(
&
db
,
file
,
mem
)
!=
SQLITE_OK
)
return
Error
(
&
db
);
sqlite3
*
pDB
=
db
.
handle
;
...
...
gframe/data_manager.h
View file @
6667cdc5
...
...
@@ -12,7 +12,7 @@ namespace ygo {
class
DataManager
{
public:
DataManager
()
:
_datas
(
8192
),
_strings
(
8192
)
{}
bool
LoadDB
(
const
char
*
file
);
bool
LoadDB
(
const
wchar_t
*
w
file
);
bool
LoadStrings
(
const
char
*
file
);
bool
Error
(
spmemvfs_db_t
*
pDB
,
sqlite3_stmt
*
pStmt
=
0
);
bool
GetData
(
int
code
,
CardData
*
pData
);
...
...
gframe/game.cpp
View file @
6667cdc5
...
...
@@ -57,8 +57,8 @@ bool Game::Initialize() {
return
false
;
}
dataManager
.
FileSystem
=
device
->
getFileSystem
();
LoadExpansion
DB
();
if
(
!
dataManager
.
LoadDB
(
"cards.cdb"
))
{
LoadExpansion
s
();
if
(
!
dataManager
.
LoadDB
(
L
"cards.cdb"
))
{
ErrorLog
(
"Failed to load card database (cards.cdb)!"
);
return
false
;
}
...
...
@@ -866,13 +866,25 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
dataManager
.
strBuffer
[
pbuffer
]
=
0
;
pControl
->
setText
(
dataManager
.
strBuffer
);
}
void
Game
::
LoadExpansion
DB
()
{
FileSystem
::
TraversalDir
(
"./expansions"
,
[](
const
char
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
strrchr
(
name
,
'.'
)
&&
!
mystrncasecmp
(
strrchr
(
name
,
'.'
),
".cdb"
,
4
))
{
char
fpath
[
1024
];
sprintf
(
fpath
,
"./expansions/%s"
,
name
);
void
Game
::
LoadExpansion
s
()
{
FileSystem
::
TraversalDir
(
L"./expansions"
,
[](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L
".cdb"
,
4
))
{
wchar_t
fpath
[
1024
];
myswprintf
(
fpath
,
L
"./expansions/%s"
,
name
);
dataManager
.
LoadDB
(
fpath
);
}
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".zip"
,
4
))
{
wchar_t
fpath
[
1024
];
myswprintf
(
fpath
,
L"./expansions/%s"
,
name
);
dataManager
.
FileSystem
->
addFileArchive
(
fpath
);
size_t
len
=
wcslen
(
name
);
wchar_t
expansname
[
256
];
wcsncpy
(
expansname
,
name
,
len
-
4
);
expansname
[
len
-
4
]
=
0
;
wcscat
(
expansname
,
L".cdb"
);
dataManager
.
LoadDB
(
expansname
);
}
});
}
void
Game
::
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
)
{
...
...
gframe/game.h
View file @
6667cdc5
...
...
@@ -107,7 +107,7 @@ public:
void
BuildProjectionMatrix
(
irr
::
core
::
matrix4
&
mProjection
,
f32
left
,
f32
right
,
f32
bottom
,
f32
top
,
f32
znear
,
f32
zfar
);
void
InitStaticText
(
irr
::
gui
::
IGUIStaticText
*
pControl
,
u32
cWidth
,
u32
cHeight
,
irr
::
gui
::
CGUITTFont
*
font
,
const
wchar_t
*
text
);
void
SetStaticText
(
irr
::
gui
::
IGUIStaticText
*
pControl
,
u32
cWidth
,
irr
::
gui
::
CGUITTFont
*
font
,
const
wchar_t
*
text
,
u32
pos
=
0
);
void
LoadExpansion
DB
();
void
LoadExpansion
s
();
void
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
RefreshReplay
();
void
RefreshSingleplay
();
...
...
gframe/gframe.cpp
View file @
6667cdc5
...
...
@@ -77,17 +77,13 @@ int main(int argc, char* argv[]) {
bool
keep_on_return
=
false
;
for
(
int
i
=
1
;
i
<
wargc
;
++
i
)
{
if
(
wargv
[
i
][
0
]
==
L'-'
&&
wargv
[
i
][
1
]
==
L'e'
&&
wargv
[
i
][
2
]
!=
L'\0'
)
{
char
param
[
128
];
BufferIO
::
EncodeUTF8
(
&
wargv
[
i
][
2
],
param
);
ygo
::
dataManager
.
LoadDB
(
param
);
ygo
::
dataManager
.
LoadDB
(
&
wargv
[
i
][
2
]);
continue
;
}
if
(
!
wcscmp
(
wargv
[
i
],
L"-e"
))
{
// extra database
++
i
;
if
(
i
<
wargc
)
{
char
param
[
128
];
BufferIO
::
EncodeUTF8
(
wargv
[
i
],
param
);
ygo
::
dataManager
.
LoadDB
(
param
);
ygo
::
dataManager
.
LoadDB
(
wargv
[
i
]);
}
continue
;
}
else
if
(
!
wcscmp
(
wargv
[
i
],
L"-n"
))
{
// nickName
...
...
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