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
9d9e27db
Commit
9d9e27db
authored
Nov 04, 2018
by
DailyShana
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Fluorohydride/master' into 'nekrozar/patch-2'
parents
b31b3684
9238d44e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
208 additions
and
292 deletions
+208
-292
gframe/config.h
gframe/config.h
+1
-0
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+2
-0
gframe/game.cpp
gframe/game.cpp
+38
-240
gframe/game.h
gframe/game.h
+3
-6
gframe/myfilesystem.h
gframe/myfilesystem.h
+145
-0
gframe/replay.cpp
gframe/replay.cpp
+4
-0
gframe/sound_manager.cpp
gframe/sound_manager.cpp
+15
-46
No files found.
gframe/config.h
View file @
9d9e27db
...
@@ -66,6 +66,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
...
@@ -66,6 +66,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include <memory.h>
#include <memory.h>
#include <time.h>
#include <time.h>
#include "bufferio.h"
#include "bufferio.h"
#include "myfilesystem.h"
#include "mymutex.h"
#include "mymutex.h"
#include "mysignal.h"
#include "mysignal.h"
#include "mythread.h"
#include "mythread.h"
...
...
gframe/deck_manager.cpp
View file @
9d9e27db
...
@@ -271,6 +271,8 @@ bool DeckManager::LoadDeck(const wchar_t* file) {
...
@@ -271,6 +271,8 @@ bool DeckManager::LoadDeck(const wchar_t* file) {
return
true
;
return
true
;
}
}
bool
DeckManager
::
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
name
)
{
bool
DeckManager
::
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
name
)
{
if
(
!
FileSystem
::
IsDirExists
(
L"./deck"
)
&&
!
FileSystem
::
MakeDir
(
L"./deck"
))
return
false
;
wchar_t
file
[
64
];
wchar_t
file
[
64
];
myswprintf
(
file
,
L"./deck/%ls.ydk"
,
name
);
myswprintf
(
file
,
L"./deck/%ls.ydk"
,
name
);
FILE
*
fp
=
OpenDeckFile
(
file
,
"w"
);
FILE
*
fp
=
OpenDeckFile
(
file
,
"w"
);
...
...
gframe/game.cpp
View file @
9d9e27db
...
@@ -10,16 +10,6 @@
...
@@ -10,16 +10,6 @@
#include "netserver.h"
#include "netserver.h"
#include "single_mode.h"
#include "single_mode.h"
#ifndef _WIN32
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
#else
#include <direct.h>
#include <io.h>
#endif
const
unsigned
short
PRO_VERSION
=
0x1346
;
const
unsigned
short
PRO_VERSION
=
0x1346
;
namespace
ygo
{
namespace
ygo
{
...
@@ -28,7 +18,6 @@ Game* mainGame;
...
@@ -28,7 +18,6 @@ Game* mainGame;
bool
Game
::
Initialize
()
{
bool
Game
::
Initialize
()
{
srand
(
time
(
0
));
srand
(
time
(
0
));
initUtils
();
LoadConfig
();
LoadConfig
();
irr
::
SIrrlichtCreationParameters
params
=
irr
::
SIrrlichtCreationParameters
();
irr
::
SIrrlichtCreationParameters
params
=
irr
::
SIrrlichtCreationParameters
();
params
.
AntiAlias
=
gameConf
.
antialias
;
params
.
AntiAlias
=
gameConf
.
antialias
;
...
@@ -872,142 +861,44 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
...
@@ -872,142 +861,44 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
}
}
void
Game
::
LoadExpansionDB
()
{
void
Game
::
LoadExpansionDB
()
{
LoadExpansionDBDirectry
(
"./expansions"
);
LoadExpansionDBDirectry
(
"./expansions"
);
#ifdef _WIN32
FileSystem
::
TraversalDir
(
"./expansions"
,
[
this
](
const
char
*
name
,
bool
isdir
)
{
char
fpath
[
1000
];
if
(
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
WIN32_FIND_DATAW
fdataw
;
char
subdir
[
1024
];
HANDLE
fh
=
FindFirstFileW
(
L"./expansions/*"
,
&
fdataw
);
sprintf
(
subdir
,
"./expansions/%s"
,
name
);
if
(
fh
!=
INVALID_HANDLE_VALUE
)
{
LoadExpansionDBDirectry
(
subdir
);
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
);
LoadExpansionDBDirectry
(
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
);
LoadExpansionDBDirectry
(
filepath
);
}
}
closedir
(
dir
);
});
}
#endif
}
}
void
Game
::
LoadExpansionDBDirectry
(
const
char
*
path
)
{
void
Game
::
LoadExpansionDBDirectry
(
const
char
*
path
)
{
#ifdef _WIN32
FileSystem
::
TraversalDir
(
path
,
[
path
](
const
char
*
name
,
bool
isdir
)
{
char
fpath
[
1000
];
if
(
!
isdir
&&
!
mystrncasecmp
(
strrchr
(
name
,
'.'
),
".cdb"
,
4
))
{
wchar_t
wpath1
[
1000
];
char
fpath
[
1024
];
wchar_t
wpath2
[
1000
];
sprintf
(
fpath
,
"%s/%s"
,
path
,
name
);
BufferIO
::
DecodeUTF8
(
path
,
wpath1
);
dataManager
.
LoadDB
(
fpath
);
myswprintf
(
wpath2
,
L"%ls/*.cdb"
,
wpath1
);
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
wpath2
,
&
fdataw
);
if
(
fh
!=
INVALID_HANDLE_VALUE
)
{
do
{
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
))
{
char
fname
[
780
];
BufferIO
::
EncodeUTF8
(
fdataw
.
cFileName
,
fname
);
sprintf
(
fpath
,
"%s/%s"
,
path
,
fname
);
dataManager
.
LoadDB
(
fpath
);
}
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
}
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
path
))
!=
NULL
)
{
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
if
(
len
<
5
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".cdb"
)
!=
0
)
continue
;
char
filepath
[
1000
];
sprintf
(
filepath
,
"%s/%s"
,
path
,
dirp
->
d_name
);
dataManager
.
LoadDB
(
filepath
);
}
}
closedir
(
dir
);
});
}
#endif
}
}
void
Game
::
LoadExpansionStrings
()
{
void
Game
::
LoadExpansionStrings
()
{
LoadExpansionStringsDirectry
(
"./expansions"
);
dataManager
.
LoadStrings
(
"./expansions/strings.conf"
);
#ifdef _WIN32
FileSystem
::
TraversalDir
(
"./expansions"
,
[](
const
char
*
name
,
bool
isdir
)
{
char
fpath
[
1000
];
if
(
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
WIN32_FIND_DATAW
fdataw
;
char
subdir
[
1024
];
HANDLE
fh
=
FindFirstFileW
(
L"./expansions/*"
,
&
fdataw
);
sprintf
(
subdir
,
"./expansions/%s/strings.conf"
,
name
);
if
(
fh
!=
INVALID_HANDLE_VALUE
)
{
dataManager
.
LoadStrings
(
subdir
);
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
);
LoadExpansionStringsDirectry
(
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
);
LoadExpansionStringsDirectry
(
filepath
);
}
}
closedir
(
dir
);
});
}
#endif
}
void
Game
::
LoadExpansionStringsDirectry
(
const
char
*
path
)
{
char
fpath
[
1000
];
sprintf
(
fpath
,
"%s/strings.conf"
,
path
);
dataManager
.
LoadStrings
(
fpath
)
}
}
void
Game
::
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
)
{
void
Game
::
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
)
{
cbDeck
->
clear
();
cbDeck
->
clear
();
#ifdef _WIN32
FileSystem
::
TraversalDir
(
L"./deck"
,
[
cbDeck
](
const
wchar_t
*
name
,
bool
isdir
)
{
WIN32_FIND_DATAW
fdataw
;
if
(
!
isdir
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ydk"
,
4
))
{
HANDLE
fh
=
FindFirstFileW
(
L"./deck/*.ydk"
,
&
fdataw
);
size_t
len
=
wcslen
(
name
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
wchar_t
deckname
[
256
];
return
;
wcsncpy
(
deckname
,
name
,
len
-
4
);
do
{
deckname
[
len
-
4
]
=
0
;
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
))
{
cbDeck
->
addItem
(
deckname
);
wchar_t
*
pf
=
fdataw
.
cFileName
;
while
(
*
pf
)
pf
++
;
while
(
*
pf
!=
L'.'
)
pf
--
;
*
pf
=
0
;
cbDeck
->
addItem
(
fdataw
.
cFileName
);
}
}
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
});
FindClose
(
fh
);
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./deck/"
))
==
NULL
)
return
;
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
if
(
len
<
5
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".ydk"
)
!=
0
)
continue
;
dirp
->
d_name
[
len
-
4
]
=
0
;
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
cbDeck
->
addItem
(
wname
);
}
closedir
(
dir
);
#endif
for
(
size_t
i
=
0
;
i
<
cbDeck
->
getItemCount
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
cbDeck
->
getItemCount
();
++
i
)
{
if
(
!
wcscmp
(
cbDeck
->
getItem
(
i
),
gameConf
.
lastdeck
))
{
if
(
!
wcscmp
(
cbDeck
->
getItem
(
i
),
gameConf
.
lastdeck
))
{
cbDeck
->
setSelected
(
i
);
cbDeck
->
setSelected
(
i
);
...
@@ -1017,61 +908,17 @@ void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) {
...
@@ -1017,61 +908,17 @@ void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) {
}
}
void
Game
::
RefreshReplay
()
{
void
Game
::
RefreshReplay
()
{
lstReplayList
->
clear
();
lstReplayList
->
clear
();
#ifdef _WIN32
FileSystem
::
TraversalDir
(
L"./replay"
,
[
this
](
const
wchar_t
*
name
,
bool
isdir
)
{
WIN32_FIND_DATAW
fdataw
;
if
(
!
isdir
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".yrp"
,
4
)
&&
Replay
::
CheckReplay
(
name
))
HANDLE
fh
=
FindFirstFileW
(
L"./replay/*.yrp"
,
&
fdataw
);
lstReplayList
->
addItem
(
name
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
});
return
;
do
{
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
&&
Replay
::
CheckReplay
(
fdataw
.
cFileName
))
{
lstReplayList
->
addItem
(
fdataw
.
cFileName
);
}
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./replay/"
))
==
NULL
)
return
;
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
if
(
len
<
5
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".yrp"
)
!=
0
)
continue
;
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
if
(
Replay
::
CheckReplay
(
wname
))
lstReplayList
->
addItem
(
wname
);
}
closedir
(
dir
);
#endif
}
}
void
Game
::
RefreshSingleplay
()
{
void
Game
::
RefreshSingleplay
()
{
lstSinglePlayList
->
clear
();
lstSinglePlayList
->
clear
();
#ifdef _WIN32
FileSystem
::
TraversalDir
(
L"./single"
,
[
this
](
const
wchar_t
*
name
,
bool
isdir
)
{
WIN32_FIND_DATAW
fdataw
;
if
(
!
isdir
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".lua"
,
4
))
HANDLE
fh
=
FindFirstFileW
(
L"./single/*.lua"
,
&
fdataw
);
lstSinglePlayList
->
addItem
(
name
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
});
return
;
do
{
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
))
lstSinglePlayList
->
addItem
(
fdataw
.
cFileName
);
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./single/"
))
==
NULL
)
return
;
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
if
(
len
<
5
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".lua"
)
!=
0
)
continue
;
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
lstSinglePlayList
->
addItem
(
wname
);
}
closedir
(
dir
);
#endif
}
}
void
Game
::
RefreshBot
()
{
void
Game
::
RefreshBot
()
{
if
(
!
gameConf
.
enable_bot_mode
)
if
(
!
gameConf
.
enable_bot_mode
)
...
@@ -1393,7 +1240,7 @@ void Game::ClearCardInfo(int player) {
...
@@ -1393,7 +1240,7 @@ void Game::ClearCardInfo(int player) {
stText
->
setText
(
L""
);
stText
->
setText
(
L""
);
scrCardText
->
setVisible
(
false
);
scrCardText
->
setVisible
(
false
);
}
}
void
Game
::
AddChatMsg
(
wchar_t
*
msg
,
int
player
)
{
void
Game
::
AddChatMsg
(
const
wchar_t
*
msg
,
int
player
)
{
for
(
int
i
=
7
;
i
>
0
;
--
i
)
{
for
(
int
i
=
7
;
i
>
0
;
--
i
)
{
chatMsg
[
i
]
=
chatMsg
[
i
-
1
];
chatMsg
[
i
]
=
chatMsg
[
i
-
1
];
chatTiming
[
i
]
=
chatTiming
[
i
-
1
];
chatTiming
[
i
]
=
chatTiming
[
i
-
1
];
...
@@ -1444,8 +1291,7 @@ void Game::ClearChatMsg() {
...
@@ -1444,8 +1291,7 @@ void Game::ClearChatMsg() {
chatTiming
[
i
]
=
0
;
chatTiming
[
i
]
=
0
;
}
}
}
}
void
Game
::
AddDebugMsg
(
char
*
msg
)
void
Game
::
AddDebugMsg
(
const
char
*
msg
)
{
{
if
(
enable_log
&
0x1
)
{
if
(
enable_log
&
0x1
)
{
wchar_t
wbuf
[
1024
];
wchar_t
wbuf
[
1024
];
BufferIO
::
DecodeUTF8
(
msg
,
wbuf
);
BufferIO
::
DecodeUTF8
(
msg
,
wbuf
);
...
@@ -1457,7 +1303,7 @@ void Game::AddDebugMsg(char* msg)
...
@@ -1457,7 +1303,7 @@ void Game::AddDebugMsg(char* msg)
ErrorLog
(
msgbuf
);
ErrorLog
(
msgbuf
);
}
}
}
}
void
Game
::
ErrorLog
(
char
*
msg
)
{
void
Game
::
ErrorLog
(
c
onst
c
har
*
msg
)
{
FILE
*
fp
=
fopen
(
"error.log"
,
"at"
);
FILE
*
fp
=
fopen
(
"error.log"
,
"at"
);
if
(
!
fp
)
if
(
!
fp
)
return
;
return
;
...
@@ -1468,54 +1314,6 @@ void Game::ErrorLog(char* msg) {
...
@@ -1468,54 +1314,6 @@ void Game::ErrorLog(char* msg) {
fprintf
(
fp
,
"[%s]%s
\n
"
,
timebuf
,
msg
);
fprintf
(
fp
,
"[%s]%s
\n
"
,
timebuf
,
msg
);
fclose
(
fp
);
fclose
(
fp
);
}
}
bool
Game
::
MakeDirectory
(
const
std
::
string
folder
)
{
std
::
string
folder_builder
;
std
::
string
sub
;
sub
.
reserve
(
folder
.
size
());
for
(
auto
it
=
folder
.
begin
();
it
!=
folder
.
end
();
++
it
)
{
const
char
c
=
*
it
;
sub
.
push_back
(
c
);
if
(
c
==
'/'
||
it
==
folder
.
end
()
-
1
)
{
folder_builder
.
append
(
sub
);
if
(
access
(
folder_builder
.
c_str
(),
0
)
!=
0
)
#ifdef _WIN32
if
(
mkdir
(
folder_builder
.
c_str
())
!=
0
)
#else
if
(
mkdir
(
folder_builder
.
c_str
(),
0777
)
!=
0
)
#endif
return
false
;
sub
.
clear
();
}
}
return
true
;
}
void
Game
::
initUtils
()
{
//user files
MakeDirectory
(
"replay"
);
//cards from extra pack
MakeDirectory
(
"expansions"
);
//files in ygopro-starter-pack
MakeDirectory
(
"deck"
);
MakeDirectory
(
"single"
);
//original files
MakeDirectory
(
"script"
);
MakeDirectory
(
"textures"
);
//sound
#ifdef YGOPRO_USE_IRRKLANG
MakeDirectory
(
"sound"
);
MakeDirectory
(
"sound/BGM"
);
MakeDirectory
(
"sound/BGM/advantage"
);
MakeDirectory
(
"sound/BGM/deck"
);
MakeDirectory
(
"sound/BGM/disadvantage"
);
MakeDirectory
(
"sound/BGM/duel"
);
MakeDirectory
(
"sound/BGM/lose"
);
MakeDirectory
(
"sound/BGM/menu"
);
MakeDirectory
(
"sound/BGM/win"
);
#endif
//pics
MakeDirectory
(
"pics"
);
MakeDirectory
(
"pics/field"
);
}
void
Game
::
ClearTextures
()
{
void
Game
::
ClearTextures
()
{
matManager
.
mCard
.
setTexture
(
0
,
0
);
matManager
.
mCard
.
setTexture
(
0
,
0
);
imgCard
->
setImage
(
imageManager
.
tCover
[
0
]);
imgCard
->
setImage
(
imageManager
.
tCover
[
0
]);
...
...
gframe/game.h
View file @
9d9e27db
...
@@ -108,7 +108,6 @@ public:
...
@@ -108,7 +108,6 @@ public:
void
LoadExpansionDB
();
void
LoadExpansionDB
();
void
LoadExpansionDBDirectry
(
const
char
*
path
);
void
LoadExpansionDBDirectry
(
const
char
*
path
);
void
LoadExpansionStrings
();
void
LoadExpansionStrings
();
void
LoadExpansionStringsDirectry
(
const
char
*
path
);
void
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
RefreshReplay
();
void
RefreshReplay
();
void
RefreshSingleplay
();
void
RefreshSingleplay
();
...
@@ -135,12 +134,10 @@ public:
...
@@ -135,12 +134,10 @@ public:
void
SaveConfig
();
void
SaveConfig
();
void
ShowCardInfo
(
int
code
);
void
ShowCardInfo
(
int
code
);
void
ClearCardInfo
(
int
player
=
0
);
void
ClearCardInfo
(
int
player
=
0
);
void
AddChatMsg
(
wchar_t
*
msg
,
int
player
);
void
AddChatMsg
(
const
wchar_t
*
msg
,
int
player
);
void
ClearChatMsg
();
void
ClearChatMsg
();
void
AddDebugMsg
(
char
*
msgbuf
);
void
AddDebugMsg
(
const
char
*
msgbuf
);
void
ErrorLog
(
char
*
msgbuf
);
void
ErrorLog
(
const
char
*
msgbuf
);
bool
MakeDirectory
(
const
std
::
string
folder
);
void
initUtils
();
void
ClearTextures
();
void
ClearTextures
();
void
CloseDuelWindow
();
void
CloseDuelWindow
();
...
...
gframe/myfilesystem.h
0 → 100644
View file @
9d9e27db
#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 @
9d9e27db
...
@@ -17,6 +17,8 @@ Replay::~Replay() {
...
@@ -17,6 +17,8 @@ Replay::~Replay() {
delete
[]
comp_data
;
delete
[]
comp_data
;
}
}
void
Replay
::
BeginRecord
()
{
void
Replay
::
BeginRecord
()
{
if
(
!
FileSystem
::
IsDirExists
(
L"./replay"
)
&&
!
FileSystem
::
MakeDir
(
L"./replay"
))
return
;
#ifdef _WIN32
#ifdef _WIN32
if
(
is_recording
)
if
(
is_recording
)
CloseHandle
(
recording_fp
);
CloseHandle
(
recording_fp
);
...
@@ -123,6 +125,8 @@ void Replay::EndRecord() {
...
@@ -123,6 +125,8 @@ void Replay::EndRecord() {
is_recording
=
false
;
is_recording
=
false
;
}
}
void
Replay
::
SaveReplay
(
const
wchar_t
*
name
)
{
void
Replay
::
SaveReplay
(
const
wchar_t
*
name
)
{
if
(
!
FileSystem
::
IsDirExists
(
L"./replay"
)
&&
!
FileSystem
::
MakeDir
(
L"./replay"
))
return
;
wchar_t
fname
[
256
];
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./replay/%ls.yrp"
,
name
);
myswprintf
(
fname
,
L"./replay/%ls.yrp"
,
name
);
#ifdef WIN32
#ifdef WIN32
...
...
gframe/sound_manager.cpp
View file @
9d9e27db
#include "sound_manager.h"
#include "sound_manager.h"
#ifndef _WIN32
#include <dirent.h>
#endif
#ifdef IRRKLANG_STATIC
#ifdef IRRKLANG_STATIC
#include "../ikpmp3/ikpMP3.h"
#include "../ikpmp3/ikpMP3.h"
#endif
#endif
...
@@ -30,51 +27,23 @@ bool SoundManager::Init() {
...
@@ -30,51 +27,23 @@ bool SoundManager::Init() {
}
}
void
SoundManager
::
RefreshBGMList
()
{
void
SoundManager
::
RefreshBGMList
()
{
RefershBGMDir
(
L""
,
BGM_DUEL
);
RefershBGMDir
(
L""
,
BGM_DUEL
);
RefershBGMDir
(
L"duel
/
"
,
BGM_DUEL
);
RefershBGMDir
(
L"duel"
,
BGM_DUEL
);
RefershBGMDir
(
L"menu
/
"
,
BGM_MENU
);
RefershBGMDir
(
L"menu"
,
BGM_MENU
);
RefershBGMDir
(
L"deck
/
"
,
BGM_DECK
);
RefershBGMDir
(
L"deck"
,
BGM_DECK
);
RefershBGMDir
(
L"advantage
/
"
,
BGM_ADVANTAGE
);
RefershBGMDir
(
L"advantage"
,
BGM_ADVANTAGE
);
RefershBGMDir
(
L"disadvantage
/
"
,
BGM_DISADVANTAGE
);
RefershBGMDir
(
L"disadvantage"
,
BGM_DISADVANTAGE
);
RefershBGMDir
(
L"win
/
"
,
BGM_WIN
);
RefershBGMDir
(
L"win"
,
BGM_WIN
);
RefershBGMDir
(
L"lose
/
"
,
BGM_LOSE
);
RefershBGMDir
(
L"lose"
,
BGM_LOSE
);
}
}
void
SoundManager
::
RefershBGMDir
(
std
::
wstring
path
,
int
scene
)
{
void
SoundManager
::
RefershBGMDir
(
std
::
wstring
path
,
int
scene
)
{
#ifdef _WIN32
std
::
wstring
search
=
L"./sound/BGM/"
+
path
;
WIN32_FIND_DATAW
fdataw
;
FileSystem
::
TraversalDir
(
search
.
c_str
(),
[
this
,
&
path
,
scene
](
const
wchar_t
*
name
,
bool
isdir
)
{
std
::
wstring
search
=
L"./sound/BGM/"
+
path
+
L"*.*"
;
if
(
!
isdir
&&
(
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".mp3"
,
4
)
||
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ogg"
,
4
)))
{
HANDLE
fh
=
FindFirstFileW
(
search
.
c_str
(),
&
fdataw
);
std
::
wstring
filename
=
path
+
L"/"
+
name
;
if
(
fh
==
INVALID_HANDLE_VALUE
)
BGMList
[
BGM_ALL
].
push_back
(
filename
);
return
;
BGMList
[
scene
].
push_back
(
filename
);
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
}
}
void
SoundManager
::
PlaySoundEffect
(
int
sound
)
{
void
SoundManager
::
PlaySoundEffect
(
int
sound
)
{
#ifdef YGOPRO_USE_IRRKLANG
#ifdef YGOPRO_USE_IRRKLANG
...
...
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