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
MobiusMei
ygopro
Commits
5884e5a2
Commit
5884e5a2
authored
Nov 12, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
merge new subdir
parents
8de09587
a6f86739
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
321 additions
and
495 deletions
+321
-495
gframe/config.h
gframe/config.h
+1
-0
gframe/data_manager.cpp
gframe/data_manager.cpp
+6
-0
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+14
-33
gframe/deck_manager.h
gframe/deck_manager.h
+0
-1
gframe/game.cpp
gframe/game.cpp
+68
-243
gframe/game.h
gframe/game.h
+3
-6
gframe/image_manager.cpp
gframe/image_manager.cpp
+22
-36
gframe/myfilesystem.h
gframe/myfilesystem.h
+145
-0
gframe/replay.cpp
gframe/replay.cpp
+4
-0
gframe/replay_mode.cpp
gframe/replay_mode.cpp
+10
-31
gframe/single_duel.cpp
gframe/single_duel.cpp
+10
-31
gframe/single_mode.cpp
gframe/single_mode.cpp
+11
-33
gframe/sound_manager.cpp
gframe/sound_manager.cpp
+15
-48
gframe/tag_duel.cpp
gframe/tag_duel.cpp
+10
-31
ocgcore
ocgcore
+1
-1
script
script
+1
-1
No files found.
gframe/config.h
View file @
5884e5a2
...
...
@@ -71,6 +71,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include <memory.h>
#include <time.h>
#include "bufferio.h"
#include "myfilesystem.h"
#include "mymutex.h"
#include "mysignal.h"
#include "mythread.h"
...
...
gframe/data_manager.cpp
View file @
5884e5a2
...
...
@@ -65,7 +65,13 @@ bool DataManager::LoadDB(const char* file) {
return
true
;
}
bool
DataManager
::
LoadStrings
(
const
char
*
file
)
{
#ifdef _WIN32
wchar_t
fname
[
1024
];
BufferIO
::
DecodeUTF8
(
file
,
fname
);
FILE
*
fp
=
_wfopen
(
fname
,
L"r"
);
#else
FILE
*
fp
=
fopen
(
file
,
"r"
);
#endif // _WIN32
if
(
!
fp
)
return
false
;
char
linebuf
[
256
];
...
...
gframe/deck_manager.cpp
View file @
5884e5a2
...
...
@@ -13,7 +13,13 @@ DeckManager deckManager;
void
DeckManager
::
LoadLFListSingle
(
const
char
*
path
)
{
LFList
*
cur
=
NULL
;
#ifdef _WIN32
wchar_t
fname
[
1024
];
BufferIO
::
DecodeUTF8
(
path
,
fname
);
FILE
*
fp
=
_wfopen
(
fname
,
L"r"
);
#else
FILE
*
fp
=
fopen
(
path
,
"r"
);
#endif // _WIN32
char
linebuf
[
256
];
wchar_t
strBuffer
[
256
];
if
(
fp
)
{
...
...
@@ -52,42 +58,15 @@ void DeckManager::LoadLFListSingle(const char* path) {
fclose
(
fp
);
}
}
void
DeckManager
::
LoadLFListDirectry
(
const
char
*
path
)
{
char
fpath
[
1000
];
sprintf
(
fpath
,
"%s/lflist.conf"
,
path
);
LoadLFListSingle
(
fpath
);
}
void
DeckManager
::
LoadLFList
()
{
LoadLFListSingle
(
"expansions/lflist.conf"
);
#ifdef _WIN32
char
fpath
[
1000
];
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
L"./expansions/*"
,
&
fdataw
);
if
(
fh
!=
INVALID_HANDLE_VALUE
)
{
do
{
if
(
wcscmp
(
L"."
,
fdataw
.
cFileName
)
!=
0
&&
wcscmp
(
L".."
,
fdataw
.
cFileName
)
!=
0
&&
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
{
char
fname
[
780
];
BufferIO
::
EncodeUTF8
(
fdataw
.
cFileName
,
fname
);
sprintf
(
fpath
,
"./expansions/%s"
,
fname
);
LoadLFListDirectry
(
fpath
);
}
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
}
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./expansions/"
))
!=
NULL
)
{
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strcmp
(
"."
,
dirp
->
d_name
)
==
0
||
strcmp
(
".."
,
dirp
->
d_name
)
==
0
||
dirp
->
d_type
!=
DT_DIR
)
continue
;
char
filepath
[
1000
];
sprintf
(
filepath
,
"./expansions/%s"
,
dirp
->
d_name
);
LoadLFListDirectry
(
filepath
);
FileSystem
::
TraversalDir
(
"./expansions"
,
[
this
](
const
char
*
name
,
bool
isdir
)
{
if
(
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
fpath
[
1024
];
sprintf
(
fpath
,
"./expansions/%s/lflist.conf"
,
name
);
LoadLFListSingle
(
fpath
);
}
closedir
(
dir
);
}
#endif
});
LoadLFListSingle
(
"lflist.conf"
);
LFList
nolimit
;
myswprintf
(
nolimit
.
listName
,
L"N/A"
);
...
...
@@ -288,6 +267,8 @@ bool DeckManager::LoadDeck(const wchar_t* file) {
return
true
;
}
bool
DeckManager
::
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
name
)
{
if
(
!
FileSystem
::
IsDirExists
(
L"./deck"
)
&&
!
FileSystem
::
MakeDir
(
L"./deck"
))
return
false
;
wchar_t
file
[
64
];
myswprintf
(
file
,
L"./deck/%ls.ydk"
,
name
);
FILE
*
fp
=
OpenDeckFile
(
file
,
"w"
);
...
...
gframe/deck_manager.h
View file @
5884e5a2
...
...
@@ -36,7 +36,6 @@ public:
std
::
vector
<
LFList
>
_lfList
;
void
LoadLFListSingle
(
const
char
*
path
);
void
LoadLFListDirectry
(
const
char
*
path
);
void
LoadLFList
();
wchar_t
*
GetLFListName
(
int
lfhash
);
int
CheckDeck
(
Deck
&
deck
,
int
lfhash
,
bool
allow_ocg
,
bool
allow_tcg
);
...
...
gframe/game.cpp
View file @
5884e5a2
This diff is collapsed.
Click to expand it.
gframe/game.h
View file @
5884e5a2
...
...
@@ -127,7 +127,6 @@ public:
void
LoadExpansionDB
();
void
LoadExpansionDBDirectry
(
const
char
*
path
);
void
LoadExpansionStrings
();
void
LoadExpansionStringsDirectry
(
const
char
*
path
);
void
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
RefreshReplay
();
void
RefreshSingleplay
();
...
...
@@ -157,12 +156,10 @@ public:
void
SaveConfig
();
void
ShowCardInfo
(
int
code
,
bool
resize
=
false
);
void
ClearCardInfo
(
int
player
=
0
);
void
AddChatMsg
(
wchar_t
*
msg
,
int
player
);
void
AddChatMsg
(
const
wchar_t
*
msg
,
int
player
);
void
ClearChatMsg
();
void
AddDebugMsg
(
char
*
msgbuf
);
void
ErrorLog
(
char
*
msgbuf
);
bool
MakeDirectory
(
const
std
::
string
folder
);
void
initUtils
();
void
AddDebugMsg
(
const
char
*
msgbuf
);
void
ErrorLog
(
const
char
*
msgbuf
);
void
ClearTextures
();
void
CloseDuelWindow
();
...
...
gframe/image_manager.cpp
View file @
5884e5a2
...
...
@@ -301,23 +301,30 @@ void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
}
}
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureFromFile
(
char
*
file
,
s32
width
,
s32
height
)
{
#ifdef _WIN32
wchar_t
name
[
1024
];
BufferIO
::
DecodeUTF8
(
file
,
name
);
#else
char
*
name
=
file
;
#endif // _WIN32
if
(
mainGame
->
gameConf
.
use_image_scale
)
{
irr
::
video
::
ITexture
*
texture
;
irr
::
video
::
IImage
*
srcimg
=
driver
->
createImageFromFile
(
fil
e
);
irr
::
video
::
IImage
*
srcimg
=
driver
->
createImageFromFile
(
nam
e
);
if
(
srcimg
==
NULL
)
return
NULL
;
if
(
srcimg
->
getDimension
()
==
irr
::
core
::
dimension2d
<
u32
>
(
width
,
height
))
{
texture
=
driver
->
addTexture
(
fil
e
,
srcimg
);
texture
=
driver
->
addTexture
(
nam
e
,
srcimg
);
}
else
{
video
::
IImage
*
destimg
=
driver
->
createImage
(
srcimg
->
getColorFormat
(),
irr
::
core
::
dimension2d
<
u32
>
(
width
,
height
));
imageScaleNNAA
(
srcimg
,
destimg
);
texture
=
driver
->
addTexture
(
fil
e
,
destimg
);
texture
=
driver
->
addTexture
(
nam
e
,
destimg
);
destimg
->
drop
();
}
srcimg
->
drop
();
return
texture
;
}
else
{
return
driver
->
getTexture
(
fil
e
);
return
driver
->
getTexture
(
nam
e
);
}
}
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureUnknown
(
s32
width
,
s32
height
,
int
index
)
{
...
...
@@ -329,39 +336,18 @@ irr::video::ITexture* ImageManager::GetTextureExpansions(char* file, s32 width,
irr
::
video
::
ITexture
*
img
=
GetTextureExpansionsDirectry
(
"./expansions"
,
file
,
width
,
height
);
if
(
img
!=
NULL
)
return
img
;
#ifdef _WIN32
char
fpath
[
1000
];
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
L"./expansions/*"
,
&
fdataw
);
if
(
fh
!=
INVALID_HANDLE_VALUE
)
{
do
{
if
(
wcscmp
(
L"."
,
fdataw
.
cFileName
)
!=
0
&&
wcscmp
(
L".."
,
fdataw
.
cFileName
)
!=
0
&&
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
{
char
fname
[
780
];
BufferIO
::
EncodeUTF8
(
fdataw
.
cFileName
,
fname
);
sprintf
(
fpath
,
"./expansions/%s"
,
fname
);
img
=
GetTextureExpansionsDirectry
(
fpath
,
file
,
width
,
height
);
if
(
img
!=
NULL
)
return
img
;
}
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
}
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./expansions/"
))
!=
NULL
)
{
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strcmp
(
"."
,
dirp
->
d_name
)
==
0
||
strcmp
(
".."
,
dirp
->
d_name
)
==
0
||
dirp
->
d_type
!=
DT_DIR
)
continue
;
char
filepath
[
1000
];
sprintf
(
filepath
,
"./expansions/%s/"
,
dirp
->
d_name
);
img
=
GetTextureExpansionsDirectry
(
filepath
,
file
,
width
,
height
);
if
(
img
!=
NULL
)
return
img
;
bool
find
=
false
;
FileSystem
::
TraversalDir
(
"./expansions"
,
[
this
,
file
,
width
,
height
,
&
img
,
&
find
](
const
char
*
name
,
bool
isdir
)
{
if
(
!
find
&&
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
subdir
[
1024
];
sprintf
(
subdir
,
"./expansions/%s"
,
name
);
img
=
GetTextureExpansionsDirectry
(
subdir
,
file
,
width
,
height
);
if
(
img
)
find
=
true
;
}
closedir
(
dir
);
}
#endif
}
);
if
(
find
)
return
img
;
return
img
;
}
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureExpansionsDirectry
(
const
char
*
path
,
char
*
file
,
s32
width
,
s32
height
)
{
...
...
gframe/myfilesystem.h
0 → 100644
View file @
5884e5a2
#ifndef FILESYSTEM_H
#define FILESYSTEM_H
#include <string.h>
#include <functional>
#include "bufferio.h"
#ifdef _WIN32
#include <direct.h>
#include <sys/stat.h>
#else
#include <dirent.h>
#include <sys/stat.h>
#endif
#ifdef _WIN32
#include <Windows.h>
class
FileSystem
{
public:
static
bool
IsFileExists
(
const
wchar_t
*
wfile
)
{
struct
_stat
fileStat
;
return
(
_wstat
(
wfile
,
&
fileStat
)
==
0
)
&&
!
(
fileStat
.
st_mode
&
_S_IFDIR
);
}
static
bool
IsFileExists
(
const
char
*
file
)
{
wchar_t
wfile
[
1024
];
BufferIO
::
DecodeUTF8
(
file
,
wfile
);
return
IsFileExists
(
wfile
);
}
static
bool
IsDirExists
(
const
wchar_t
*
wdir
)
{
struct
_stat
fileStat
;
return
(
_wstat
(
wdir
,
&
fileStat
)
==
0
)
&&
(
fileStat
.
st_mode
&
_S_IFDIR
);
}
static
bool
IsDirExists
(
const
char
*
dir
)
{
wchar_t
wdir
[
1024
];
BufferIO
::
DecodeUTF8
(
dir
,
wdir
);
return
IsDirExists
(
wdir
);
}
static
bool
MakeDir
(
const
wchar_t
*
wdir
)
{
return
_wmkdir
(
wdir
)
==
0
;
}
static
bool
MakeDir
(
const
char
*
dir
)
{
wchar_t
wdir
[
1024
];
BufferIO
::
DecodeUTF8
(
dir
,
wdir
);
return
MakeDir
(
wdir
);
}
static
void
TraversalDir
(
const
wchar_t
*
wpath
,
const
std
::
function
<
void
(
const
wchar_t
*
,
bool
)
>&
cb
)
{
wchar_t
findstr
[
1024
];
wcscpy
(
findstr
,
wpath
);
wcscat
(
findstr
,
L"/*"
);
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
findstr
,
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
do
{
cb
(
fdataw
.
cFileName
,
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
));
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
}
static
void
TraversalDir
(
const
char
*
path
,
const
std
::
function
<
void
(
const
char
*
,
bool
)
>&
cb
)
{
wchar_t
wpath
[
1024
];
BufferIO
::
DecodeUTF8
(
path
,
wpath
);
TraversalDir
(
wpath
,
[
&
cb
](
const
wchar_t
*
wname
,
bool
isdir
)
{
char
name
[
1024
];
BufferIO
::
EncodeUTF8
(
wname
,
name
);
cb
(
name
,
isdir
);
});
}
};
#else
class
FileSystem
{
public:
static
bool
IsFileExists
(
const
char
*
file
)
{
struct
stat
fileStat
;
return
(
stat
(
file
,
&
fileStat
)
==
0
)
&&
!
S_ISDIR
(
fileStat
.
st_mode
);
}
static
bool
IsFileExists
(
const
wchar_t
*
wfile
)
{
char
file
[
1024
];
BufferIO
::
EncodeUTF8
(
wfile
,
file
);
return
IsFileExists
(
file
);
}
static
bool
IsDirExists
(
const
char
*
dir
)
{
struct
stat
fileStat
;
return
(
stat
(
dir
,
&
fileStat
)
==
0
)
&&
S_ISDIR
(
fileStat
.
st_mode
);
}
static
bool
IsDirExists
(
const
wchar_t
*
wdir
)
{
char
dir
[
1024
];
BufferIO
::
EncodeUTF8
(
wdir
,
dir
);
return
IsDirExists
(
dir
);
}
static
bool
MakeDir
(
const
char
*
dir
)
{
return
mkdir
(
dir
,
0775
)
==
0
;
}
static
bool
MakeDir
(
const
wchar_t
*
wdir
)
{
char
dir
[
1024
];
BufferIO
::
EncodeUTF8
(
wdir
,
dir
);
return
MakeDir
(
dir
);
}
static
void
TraversalDir
(
const
char
*
path
,
const
std
::
function
<
void
(
const
char
*
,
bool
)
>&
cb
)
{
DIR
*
dir
=
nullptr
;
struct
dirent
*
dirp
=
nullptr
;
if
((
dir
=
opendir
(
path
))
==
nullptr
)
return
;
struct
stat
fileStat
;
while
((
dirp
=
readdir
(
dir
))
!=
nullptr
)
{
char
fname
[
1024
];
strcpy
(
fname
,
path
);
strcat
(
fname
,
"/"
);
strcat
(
fname
,
dirp
->
d_name
);
stat
(
fname
,
&
fileStat
);
cb
(
dirp
->
d_name
,
S_ISDIR
(
fileStat
.
st_mode
));
}
closedir
(
dir
);
}
static
void
TraversalDir
(
const
wchar_t
*
wpath
,
const
std
::
function
<
void
(
const
wchar_t
*
,
bool
)
>&
cb
)
{
char
path
[
1024
];
BufferIO
::
EncodeUTF8
(
wpath
,
path
);
TraversalDir
(
path
,
[
&
cb
](
const
char
*
name
,
bool
isdir
)
{
wchar_t
wname
[
1024
];
BufferIO
::
DecodeUTF8
(
name
,
wname
);
cb
(
wname
,
isdir
);
});
}
};
#endif // _WIN32
#endif //FILESYSTEM_H
gframe/replay.cpp
View file @
5884e5a2
...
...
@@ -17,6 +17,8 @@ Replay::~Replay() {
delete
[]
comp_data
;
}
void
Replay
::
BeginRecord
()
{
if
(
!
FileSystem
::
IsDirExists
(
L"./replay"
)
&&
!
FileSystem
::
MakeDir
(
L"./replay"
))
return
;
#ifdef _WIN32
if
(
is_recording
)
CloseHandle
(
recording_fp
);
...
...
@@ -123,6 +125,8 @@ void Replay::EndRecord() {
is_recording
=
false
;
}
void
Replay
::
SaveReplay
(
const
wchar_t
*
name
)
{
if
(
!
FileSystem
::
IsDirExists
(
L"./replay"
)
&&
!
FileSystem
::
MakeDir
(
L"./replay"
))
return
;
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./replay/%ls.yrp"
,
name
);
#ifdef WIN32
...
...
gframe/replay_mode.cpp
View file @
5884e5a2
...
...
@@ -952,39 +952,18 @@ byte* ReplayMode::ScriptReaderEx(const char* script_name, int* slen) {
buffer
=
ScriptReaderExDirectry
(
"./beta"
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
#ifdef _WIN32
char
fpath
[
1000
];
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
L"./expansions/*"
,
&
fdataw
);
if
(
fh
!=
INVALID_HANDLE_VALUE
)
{
do
{
if
(
wcscmp
(
L"."
,
fdataw
.
cFileName
)
!=
0
&&
wcscmp
(
L".."
,
fdataw
.
cFileName
)
!=
0
&&
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
{
char
fname
[
780
];
BufferIO
::
EncodeUTF8
(
fdataw
.
cFileName
,
fname
);
sprintf
(
fpath
,
"./expansions/%s"
,
fname
);
buffer
=
ScriptReaderExDirectry
(
fpath
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
}
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
}
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./expansions/"
))
!=
NULL
)
{
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strcmp
(
"."
,
dirp
->
d_name
)
==
0
||
strcmp
(
".."
,
dirp
->
d_name
)
==
0
||
dirp
->
d_type
!=
DT_DIR
)
continue
;
char
filepath
[
1000
];
sprintf
(
filepath
,
"./expansions/%s/"
,
dirp
->
d_name
);
buffer
=
ScriptReaderExDirectry
(
filepath
,
script_name
,
slen
);
bool
find
=
false
;
FileSystem
::
TraversalDir
(
"./expansions"
,
[
script_name
,
slen
,
&
buffer
,
&
find
](
const
char
*
name
,
bool
isdir
)
{
if
(
!
find
&&
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
subdir
[
1024
];
sprintf
(
subdir
,
"./expansions/%s"
,
name
);
buffer
=
ScriptReaderExDirectry
(
subdir
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
find
=
true
;
}
closedir
(
dir
);
}
#endif
}
);
if
(
find
)
return
buffer
;
return
default_script_reader
(
script_name
,
slen
);
}
byte
*
ReplayMode
::
ScriptReaderExDirectry
(
const
char
*
path
,
const
char
*
script_name
,
int
*
slen
,
int
pre_len
)
{
...
...
gframe/single_duel.cpp
View file @
5884e5a2
...
...
@@ -1565,39 +1565,18 @@ byte* SingleDuel::ScriptReaderEx(const char* script_name, int* slen) {
buffer
=
ScriptReaderExDirectry
(
"./beta"
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
#ifdef _WIN32
char
fpath
[
1000
];
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
L"./expansions/*"
,
&
fdataw
);
if
(
fh
!=
INVALID_HANDLE_VALUE
)
{
do
{
if
(
wcscmp
(
L"."
,
fdataw
.
cFileName
)
!=
0
&&
wcscmp
(
L".."
,
fdataw
.
cFileName
)
!=
0
&&
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
{
char
fname
[
780
];
BufferIO
::
EncodeUTF8
(
fdataw
.
cFileName
,
fname
);
sprintf
(
fpath
,
"./expansions/%s"
,
fname
);
buffer
=
ScriptReaderExDirectry
(
fpath
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
}
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
}
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./expansions/"
))
!=
NULL
)
{
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strcmp
(
"."
,
dirp
->
d_name
)
==
0
||
strcmp
(
".."
,
dirp
->
d_name
)
==
0
||
dirp
->
d_type
!=
DT_DIR
)
continue
;
char
filepath
[
1000
];
sprintf
(
filepath
,
"./expansions/%s/"
,
dirp
->
d_name
);
buffer
=
ScriptReaderExDirectry
(
filepath
,
script_name
,
slen
);
bool
find
=
false
;
FileSystem
::
TraversalDir
(
"./expansions"
,
[
script_name
,
slen
,
&
buffer
,
&
find
](
const
char
*
name
,
bool
isdir
)
{
if
(
!
find
&&
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
subdir
[
1024
];
sprintf
(
subdir
,
"./expansions/%s"
,
name
);
buffer
=
ScriptReaderExDirectry
(
subdir
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
find
=
true
;
}
closedir
(
dir
);
}
#endif
}
);
if
(
find
)
return
buffer
;
return
default_script_reader
(
script_name
,
slen
);
}
byte
*
SingleDuel
::
ScriptReaderExDirectry
(
const
char
*
path
,
const
char
*
script_name
,
int
*
slen
,
int
pre_len
)
{
...
...
gframe/single_mode.cpp
View file @
5884e5a2
...
...
@@ -873,45 +873,23 @@ byte* SingleMode::ScriptReaderEx(const char* script_name, int* slen) {
buffer
=
ScriptReaderExDirectry
(
"./beta"
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
#ifdef _WIN32
char
fpath
[
1000
];
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
L"./expansions/*"
,
&
fdataw
);
if
(
fh
!=
INVALID_HANDLE_VALUE
)
{
do
{
if
(
wcscmp
(
L"."
,
fdataw
.
cFileName
)
!=
0
&&
wcscmp
(
L".."
,
fdataw
.
cFileName
)
!=
0
&&
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
{
char
fname
[
780
];
BufferIO
::
EncodeUTF8
(
fdataw
.
cFileName
,
fname
);
sprintf
(
fpath
,
"./expansions/%s"
,
fname
);
buffer
=
ScriptReaderExDirectry
(
fpath
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
}
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
}
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./expansions/"
))
!=
NULL
)
{
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strcmp
(
"."
,
dirp
->
d_name
)
==
0
||
strcmp
(
".."
,
dirp
->
d_name
)
==
0
||
dirp
->
d_type
!=
DT_DIR
)
continue
;
char
filepath
[
1000
];
sprintf
(
filepath
,
"./expansions/%s/"
,
dirp
->
d_name
);
buffer
=
ScriptReaderExDirectry
(
filepath
,
script_name
,
slen
);
bool
find
=
false
;
FileSystem
::
TraversalDir
(
"./expansions"
,
[
script_name
,
slen
,
&
buffer
,
&
find
](
const
char
*
name
,
bool
isdir
)
{
if
(
!
find
&&
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
subdir
[
1024
];
sprintf
(
subdir
,
"./expansions/%s"
,
name
);
buffer
=
ScriptReaderExDirectry
(
subdir
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
find
=
true
;
}
closedir
(
dir
);
}
#endif
}
);
if
(
find
)
return
buffer
;
return
ScriptReader
(
script_name
,
slen
);
}
byte
*
SingleMode
::
ScriptReaderExDirectry
(
const
char
*
path
,
const
char
*
script_name
,
int
*
slen
,
int
pre_len
)
{
char
sname
[
256
];
strcpy
(
sname
,
path
);
strcat
(
sname
,
script_name
+
pre_len
);
//default script name: ./script/c%d.lua
sprintf
(
sname
,
"%s%s"
,
path
,
script_name
+
pre_len
);
//default script name: ./script/c%d.lua
return
ScriptReader
(
sname
,
slen
);
}
byte
*
SingleMode
::
ScriptReader
(
const
char
*
script_name
,
int
*
slen
)
{
...
...
gframe/sound_manager.cpp
View file @
5884e5a2
#include "sound_manager.h"
#ifndef _WIN32
#include <dirent.h>
#endif
#ifdef YGOPRO_USE_IRRKLANG
#include "../ikpmp3/ikpMP3.h"
#endif
...
...
@@ -31,55 +28,25 @@ bool SoundManager::Init() {
void
SoundManager
::
RefreshBGMList
()
{
#ifdef YGOPRO_USE_IRRKLANG
RefershBGMDir
(
L""
,
BGM_DUEL
);
RefershBGMDir
(
L"duel
/
"
,
BGM_DUEL
);
RefershBGMDir
(
L"menu
/
"
,
BGM_MENU
);
RefershBGMDir
(
L"deck
/
"
,
BGM_DECK
);
RefershBGMDir
(
L"advantage
/
"
,
BGM_ADVANTAGE
);
RefershBGMDir
(
L"disadvantage
/
"
,
BGM_DISADVANTAGE
);
RefershBGMDir
(
L"win
/
"
,
BGM_WIN
);
RefershBGMDir
(
L"lose
/
"
,
BGM_LOSE
);
RefershBGMDir
(
L"duel"
,
BGM_DUEL
);
RefershBGMDir
(
L"menu"
,
BGM_MENU
);
RefershBGMDir
(
L"deck"
,
BGM_DECK
);
RefershBGMDir
(
L"advantage"
,
BGM_ADVANTAGE
);
RefershBGMDir
(
L"disadvantage"
,
BGM_DISADVANTAGE
);
RefershBGMDir
(
L"win"
,
BGM_WIN
);
RefershBGMDir
(
L"lose"
,
BGM_LOSE
);
RefershBGMDir
(
L"custom/"
,
BGM_CUSTOM
);
#endif
}
void
SoundManager
::
RefershBGMDir
(
std
::
wstring
path
,
int
scene
)
{
#ifdef YGOPRO_USE_IRRKLANG
#ifdef _WIN32
WIN32_FIND_DATAW
fdataw
;
std
::
wstring
search
=
L"./sound/BGM/"
+
path
+
L"*.*"
;
HANDLE
fh
=
FindFirstFileW
(
search
.
c_str
(),
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
do
{
size_t
len
=
wcslen
(
fdataw
.
cFileName
);
if
((
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
||
len
<
5
||
!
(
_wcsicmp
(
fdataw
.
cFileName
+
len
-
4
,
L".mp3"
)
==
0
||
_wcsicmp
(
fdataw
.
cFileName
+
len
-
4
,
L".ogg"
)
==
0
))
continue
;
std
::
wstring
filename
=
path
+
(
std
::
wstring
)
fdataw
.
cFileName
;
BGMList
[
BGM_ALL
].
push_back
(
filename
);
BGMList
[
scene
].
push_back
(
filename
);
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
std
::
wstring
wsearchpath
=
L"./sound/BGM/"
+
path
;
char
searchpath
[
256
];
BufferIO
::
EncodeUTF8
(
wsearchpath
.
c_str
(),
searchpath
);
if
((
dir
=
opendir
(
searchpath
))
==
NULL
)
return
;
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
if
(
len
<
5
||
!
(
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".mp3"
)
==
0
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".ogg"
)))
continue
;
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
std
::
wstring
filename
=
path
+
(
std
::
wstring
)
wname
;
BGMList
[
BGM_ALL
].
push_back
(
filename
);
BGMList
[
scene
].
push_back
(
filename
);
}
closedir
(
dir
);
#endif
#endif
std
::
wstring
search
=
L"./sound/BGM/"
+
path
;
FileSystem
::
TraversalDir
(
search
.
c_str
(),
[
this
,
&
path
,
scene
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
(
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".mp3"
,
4
)
||
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ogg"
,
4
)))
{
std
::
wstring
filename
=
path
+
L"/"
+
name
;
BGMList
[
BGM_ALL
].
push_back
(
filename
);
BGMList
[
scene
].
push_back
(
filename
);
}
});
}
void
SoundManager
::
PlaySoundEffect
(
int
sound
)
{
#ifdef YGOPRO_USE_IRRKLANG
...
...
gframe/tag_duel.cpp
View file @
5884e5a2
...
...
@@ -1706,39 +1706,18 @@ byte* TagDuel::ScriptReaderEx(const char* script_name, int* slen) {
buffer
=
ScriptReaderExDirectry
(
"./beta"
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
#ifdef _WIN32
char
fpath
[
1000
];
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
L"./expansions/*"
,
&
fdataw
);
if
(
fh
!=
INVALID_HANDLE_VALUE
)
{
do
{
if
(
wcscmp
(
L"."
,
fdataw
.
cFileName
)
!=
0
&&
wcscmp
(
L".."
,
fdataw
.
cFileName
)
!=
0
&&
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
{
char
fname
[
780
];
BufferIO
::
EncodeUTF8
(
fdataw
.
cFileName
,
fname
);
sprintf
(
fpath
,
"./expansions/%s"
,
fname
);
buffer
=
ScriptReaderExDirectry
(
fpath
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
}
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
}
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./expansions/"
))
!=
NULL
)
{
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strcmp
(
"."
,
dirp
->
d_name
)
==
0
||
strcmp
(
".."
,
dirp
->
d_name
)
==
0
||
dirp
->
d_type
!=
DT_DIR
)
continue
;
char
filepath
[
1000
];
sprintf
(
filepath
,
"./expansions/%s/"
,
dirp
->
d_name
);
buffer
=
ScriptReaderExDirectry
(
filepath
,
script_name
,
slen
);
bool
find
=
false
;
FileSystem
::
TraversalDir
(
"./expansions"
,
[
script_name
,
slen
,
&
buffer
,
&
find
](
const
char
*
name
,
bool
isdir
)
{
if
(
!
find
&&
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
subdir
[
1024
];
sprintf
(
subdir
,
"./expansions/%s"
,
name
);
buffer
=
ScriptReaderExDirectry
(
subdir
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
find
=
true
;
}
closedir
(
dir
);
}
#endif
}
);
if
(
find
)
return
buffer
;
return
default_script_reader
(
script_name
,
slen
);
}
byte
*
TagDuel
::
ScriptReaderExDirectry
(
const
char
*
path
,
const
char
*
script_name
,
int
*
slen
,
int
pre_len
)
{
...
...
ocgcore
@
a85b90e1
Subproject commit
17c2dfaf1b157fb65e81ab05883106a3cc38e2ae
Subproject commit
a85b90e10c0a93763cc8650f743f924aae5a33b2
script
@
74c6c3d8
Subproject commit
aaef0a01369bd09bf0e4dd812483df1d0f856f3a
Subproject commit
74c6c3d87e622eaf8f80344d4b1578c69333cd16
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