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
20795dd0
Commit
20795dd0
authored
Oct 19, 2024
by
Chen Bill
Committed by
GitHub
Oct 19, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add IsExtension (#2604)
parent
c0230df1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
13 deletions
+32
-13
gframe/game.cpp
gframe/game.cpp
+29
-12
gframe/game.h
gframe/game.h
+2
-0
gframe/sound_manager.cpp
gframe/sound_manager.cpp
+1
-1
No files found.
gframe/game.cpp
View file @
20795dd0
...
@@ -50,6 +50,15 @@ void DuelInfo::Clear() {
...
@@ -50,6 +50,15 @@ void DuelInfo::Clear() {
time_left
[
1
]
=
0
;
time_left
[
1
]
=
0
;
}
}
bool
IsExtension
(
const
wchar_t
*
filename
,
const
wchar_t
*
extension
)
{
int
flen
=
std
::
wcslen
(
filename
);
int
elen
=
std
::
wcslen
(
extension
);
if
(
!
flen
||
!
elen
||
flen
<
elen
)
return
false
;
auto
fend
=
filename
+
flen
;
return
!
mywcsncasecmp
(
fend
-
elen
,
extension
,
elen
);
}
bool
Game
::
Initialize
()
{
bool
Game
::
Initialize
()
{
LoadConfig
();
LoadConfig
();
irr
::
SIrrlichtCreationParameters
params
=
irr
::
SIrrlichtCreationParameters
();
irr
::
SIrrlichtCreationParameters
params
=
irr
::
SIrrlichtCreationParameters
();
...
@@ -152,7 +161,7 @@ bool Game::Initialize() {
...
@@ -152,7 +161,7 @@ bool Game::Initialize() {
wchar_t
fpath
[
1024
]{};
wchar_t
fpath
[
1024
]{};
fpath
[
0
]
=
0
;
fpath
[
0
]
=
0
;
FileSystem
::
TraversalDir
(
L"./fonts"
,
[
&
fpath
](
const
wchar_t
*
name
,
bool
isdir
)
{
FileSystem
::
TraversalDir
(
L"./fonts"
,
[
&
fpath
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
(
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ttf"
,
4
)
||
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ttc"
,
4
)
||
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".otf"
,
4
)))
{
if
(
!
isdir
&&
(
IsExtension
(
name
,
L".ttf"
)
||
IsExtension
(
name
,
L".ttc"
)
||
IsExtension
(
name
,
L".otf"
)))
{
myswprintf
(
fpath
,
L"./fonts/%ls"
,
name
);
myswprintf
(
fpath
,
L"./fonts/%ls"
,
name
);
}
}
});
});
...
@@ -1139,15 +1148,17 @@ void Game::LoadExpansions() {
...
@@ -1139,15 +1148,17 @@ void Game::LoadExpansions() {
FileSystem
::
TraversalDir
(
L"./expansions"
,
[](
const
wchar_t
*
name
,
bool
isdir
)
{
FileSystem
::
TraversalDir
(
L"./expansions"
,
[](
const
wchar_t
*
name
,
bool
isdir
)
{
wchar_t
fpath
[
1024
];
wchar_t
fpath
[
1024
];
myswprintf
(
fpath
,
L"./expansions/%ls"
,
name
);
myswprintf
(
fpath
,
L"./expansions/%ls"
,
name
);
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".cdb"
,
4
))
{
if
(
!
isdir
&&
IsExtension
(
name
,
L".cdb"
))
{
dataManager
.
LoadDB
(
fpath
);
dataManager
.
LoadDB
(
fpath
);
return
;
}
}
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".conf"
,
5
))
{
if
(
!
isdir
&&
IsExtension
(
name
,
L".conf"
))
{
char
upath
[
1024
];
char
upath
[
1024
];
BufferIO
::
EncodeUTF8
(
fpath
,
upath
);
BufferIO
::
EncodeUTF8
(
fpath
,
upath
);
dataManager
.
LoadStrings
(
upath
);
dataManager
.
LoadStrings
(
upath
);
return
;
}
}
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
(
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".zip"
,
4
)
||
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ypk"
,
4
)))
{
if
(
!
isdir
&&
(
IsExtension
(
name
,
L".zip"
)
||
IsExtension
(
name
,
L".ypk"
)))
{
#ifdef _WIN32
#ifdef _WIN32
dataManager
.
FileSystem
->
addFileArchive
(
fpath
,
true
,
false
,
EFAT_ZIP
);
dataManager
.
FileSystem
->
addFileArchive
(
fpath
,
true
,
false
,
EFAT_ZIP
);
#else
#else
...
@@ -1155,6 +1166,7 @@ void Game::LoadExpansions() {
...
@@ -1155,6 +1166,7 @@ void Game::LoadExpansions() {
BufferIO
::
EncodeUTF8
(
fpath
,
upath
);
BufferIO
::
EncodeUTF8
(
fpath
,
upath
);
dataManager
.
FileSystem
->
addFileArchive
(
upath
,
true
,
false
,
EFAT_ZIP
);
dataManager
.
FileSystem
->
addFileArchive
(
upath
,
true
,
false
,
EFAT_ZIP
);
#endif
#endif
return
;
}
}
});
});
for
(
u32
i
=
0
;
i
<
DataManager
::
FileSystem
->
getFileArchiveCount
();
++
i
)
{
for
(
u32
i
=
0
;
i
<
DataManager
::
FileSystem
->
getFileArchiveCount
();
++
i
)
{
...
@@ -1167,18 +1179,22 @@ void Game::LoadExpansions() {
...
@@ -1167,18 +1179,22 @@ void Game::LoadExpansions() {
const
char
*
uname
=
archive
->
getFullFileName
(
j
).
c_str
();
const
char
*
uname
=
archive
->
getFullFileName
(
j
).
c_str
();
BufferIO
::
DecodeUTF8
(
uname
,
fname
);
BufferIO
::
DecodeUTF8
(
uname
,
fname
);
#endif
#endif
if
(
wcsrchr
(
fname
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
fname
,
'.'
),
L".cdb"
,
4
))
if
(
IsExtension
(
fname
,
L".cdb"
))
{
dataManager
.
LoadDB
(
fname
);
dataManager
.
LoadDB
(
fname
);
if
(
wcsrchr
(
fname
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
fname
,
'.'
),
L".conf"
,
5
))
{
continue
;
}
if
(
IsExtension
(
fname
,
L".conf"
))
{
#ifdef _WIN32
#ifdef _WIN32
IReadFile
*
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
fname
);
IReadFile
*
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
fname
);
#else
#else
IReadFile
*
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
uname
);
IReadFile
*
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
uname
);
#endif
#endif
dataManager
.
LoadStrings
(
reader
);
dataManager
.
LoadStrings
(
reader
);
continue
;
}
}
if
(
wcsrchr
(
fname
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
fname
,
'.'
),
L".ydk"
,
4
))
{
if
(
!
mywcsncasecmp
(
fname
,
L"pack/"
,
5
)
&&
IsExtension
(
fname
,
L".ydk"
))
{
deckBuilder
.
expansionPacks
.
push_back
(
fname
);
deckBuilder
.
expansionPacks
.
push_back
(
fname
);
continue
;
}
}
}
}
}
}
...
@@ -1227,14 +1243,15 @@ void Game::RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBo
...
@@ -1227,14 +1243,15 @@ void Game::RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBo
void
Game
::
RefreshDeck
(
const
wchar_t
*
deckpath
,
const
std
::
function
<
void
(
const
wchar_t
*
)
>&
additem
)
{
void
Game
::
RefreshDeck
(
const
wchar_t
*
deckpath
,
const
std
::
function
<
void
(
const
wchar_t
*
)
>&
additem
)
{
if
(
!
mywcsncasecmp
(
deckpath
,
L"./pack"
,
6
))
{
if
(
!
mywcsncasecmp
(
deckpath
,
L"./pack"
,
6
))
{
for
(
auto
&
pack
:
deckBuilder
.
expansionPacks
)
{
for
(
auto
&
pack
:
deckBuilder
.
expansionPacks
)
{
// add pack/xxx.ydk
additem
(
pack
.
substr
(
5
,
pack
.
size
()
-
9
).
c_str
());
additem
(
pack
.
substr
(
5
,
pack
.
size
()
-
9
).
c_str
());
}
}
}
}
FileSystem
::
TraversalDir
(
deckpath
,
[
additem
](
const
wchar_t
*
name
,
bool
isdir
)
{
FileSystem
::
TraversalDir
(
deckpath
,
[
additem
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ydk"
,
4
))
{
if
(
!
isdir
&&
IsExtension
(
name
,
L".ydk"
))
{
size_t
len
=
wcslen
(
name
);
size_t
len
=
std
::
wcslen
(
name
);
wchar_t
deckname
[
256
];
wchar_t
deckname
[
256
];
wcsncpy
(
deckname
,
name
,
len
-
4
);
std
::
wcsncpy
(
deckname
,
name
,
len
-
4
);
deckname
[
len
-
4
]
=
0
;
deckname
[
len
-
4
]
=
0
;
additem
(
deckname
);
additem
(
deckname
);
}
}
...
@@ -1243,7 +1260,7 @@ void Game::RefreshDeck(const wchar_t* deckpath, const std::function<void(const w
...
@@ -1243,7 +1260,7 @@ void Game::RefreshDeck(const wchar_t* deckpath, const std::function<void(const w
void
Game
::
RefreshReplay
()
{
void
Game
::
RefreshReplay
()
{
lstReplayList
->
clear
();
lstReplayList
->
clear
();
FileSystem
::
TraversalDir
(
L"./replay"
,
[
this
](
const
wchar_t
*
name
,
bool
isdir
)
{
FileSystem
::
TraversalDir
(
L"./replay"
,
[
this
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".yrp"
,
4
)
&&
Replay
::
CheckReplay
(
name
))
if
(
!
isdir
&&
IsExtension
(
name
,
L".yrp"
)
&&
Replay
::
CheckReplay
(
name
))
lstReplayList
->
addItem
(
name
);
lstReplayList
->
addItem
(
name
);
});
});
}
}
...
@@ -1251,7 +1268,7 @@ void Game::RefreshSingleplay() {
...
@@ -1251,7 +1268,7 @@ void Game::RefreshSingleplay() {
lstSinglePlayList
->
clear
();
lstSinglePlayList
->
clear
();
stSinglePlayInfo
->
setText
(
L""
);
stSinglePlayInfo
->
setText
(
L""
);
FileSystem
::
TraversalDir
(
L"./single"
,
[
this
](
const
wchar_t
*
name
,
bool
isdir
)
{
FileSystem
::
TraversalDir
(
L"./single"
,
[
this
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".lua"
,
4
))
if
(
!
isdir
&&
IsExtension
(
name
,
L".lua"
))
lstSinglePlayList
->
addItem
(
name
);
lstSinglePlayList
->
addItem
(
name
);
});
});
}
}
...
...
gframe/game.h
View file @
20795dd0
...
@@ -27,6 +27,8 @@ constexpr int CONFIG_LINE_SIZE = 1024;
...
@@ -27,6 +27,8 @@ constexpr int CONFIG_LINE_SIZE = 1024;
namespace
ygo
{
namespace
ygo
{
bool
IsExtension
(
const
wchar_t
*
filename
,
const
wchar_t
*
extension
);
struct
Config
{
struct
Config
{
bool
use_d3d
{
false
};
bool
use_d3d
{
false
};
bool
use_image_scale
{
true
};
bool
use_image_scale
{
true
};
...
...
gframe/sound_manager.cpp
View file @
20795dd0
...
@@ -40,7 +40,7 @@ void SoundManager::RefreshBGMList() {
...
@@ -40,7 +40,7 @@ void SoundManager::RefreshBGMList() {
void
SoundManager
::
RefershBGMDir
(
std
::
wstring
path
,
int
scene
)
{
void
SoundManager
::
RefershBGMDir
(
std
::
wstring
path
,
int
scene
)
{
std
::
wstring
search
=
L"./sound/BGM/"
+
path
;
std
::
wstring
search
=
L"./sound/BGM/"
+
path
;
FileSystem
::
TraversalDir
(
search
.
c_str
(),
[
this
,
&
path
,
scene
](
const
wchar_t
*
name
,
bool
isdir
)
{
FileSystem
::
TraversalDir
(
search
.
c_str
(),
[
this
,
&
path
,
scene
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
(
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".mp3"
,
4
)
||
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ogg"
,
4
)))
{
if
(
!
isdir
&&
(
IsExtension
(
name
,
L".mp3"
)
||
IsExtension
(
name
,
L".ogg"
)))
{
std
::
wstring
filename
=
path
+
L"/"
+
name
;
std
::
wstring
filename
=
path
+
L"/"
+
name
;
BGMList
[
BGM_ALL
].
push_back
(
filename
);
BGMList
[
BGM_ALL
].
push_back
(
filename
);
BGMList
[
scene
].
push_back
(
filename
);
BGMList
[
scene
].
push_back
(
filename
);
...
...
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