Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-2pick
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
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
MyCard
ygopro-2pick
Commits
bad09d56
Commit
bad09d56
authored
Nov 04, 2018
by
mercury233
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/Fluorohydride/ygopro
into server
parents
42f6ed00
9238d44e
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
247 additions
and
285 deletions
+247
-285
gframe/config.h
gframe/config.h
+1
-0
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+9
-39
gframe/deck_manager.h
gframe/deck_manager.h
+1
-0
gframe/event_handler.cpp
gframe/event_handler.cpp
+13
-2
gframe/game.cpp
gframe/game.cpp
+54
-193
gframe/game.h
gframe/game.h
+4
-4
gframe/myfilesystem.h
gframe/myfilesystem.h
+145
-0
gframe/premake4.lua
gframe/premake4.lua
+1
-1
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 @
bad09d56
...
@@ -68,6 +68,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
...
@@ -68,6 +68,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 @
bad09d56
...
@@ -8,47 +8,11 @@ namespace ygo {
...
@@ -8,47 +8,11 @@ namespace ygo {
DeckManager
deckManager
;
DeckManager
deckManager
;
void
DeckManager
::
LoadLFList
(
)
{
void
DeckManager
::
LoadLFList
Single
(
const
char
*
path
)
{
LFList
*
cur
=
NULL
;
LFList
*
cur
=
NULL
;
FILE
*
fp
=
fopen
(
"lflist.conf"
,
"r"
);
FILE
*
fp
=
fopen
(
path
,
"r"
);
FILE
*
fp_custom
=
fopen
(
"expansions/lflist.conf"
,
"r"
);
char
linebuf
[
256
];
char
linebuf
[
256
];
wchar_t
strBuffer
[
256
];
wchar_t
strBuffer
[
256
];
if
(
fp_custom
)
{
while
(
fgets
(
linebuf
,
256
,
fp_custom
))
{
if
(
linebuf
[
0
]
==
'#'
)
continue
;
int
p
=
0
,
sa
=
0
,
code
,
count
;
if
(
linebuf
[
0
]
==
'!'
)
{
sa
=
BufferIO
::
DecodeUTF8
((
const
char
*
)(
&
linebuf
[
1
]),
strBuffer
);
while
(
strBuffer
[
sa
-
1
]
==
L'\r'
||
strBuffer
[
sa
-
1
]
==
L'\n'
)
sa
--
;
LFList
newlist
;
_lfList
.
push_back
(
newlist
);
cur
=
&
_lfList
[
_lfList
.
size
()
-
1
];
memcpy
(
cur
->
listName
,
(
const
void
*
)
strBuffer
,
40
);
cur
->
listName
[
sa
]
=
0
;
cur
->
content
=
new
std
::
unordered_map
<
int
,
int
>
;
cur
->
hash
=
0x7dfcee6a
;
continue
;
}
while
(
linebuf
[
p
]
!=
' '
&&
linebuf
[
p
]
!=
'\t'
&&
linebuf
[
p
]
!=
0
)
p
++
;
if
(
linebuf
[
p
]
==
0
)
continue
;
linebuf
[
p
++
]
=
0
;
sa
=
p
;
code
=
atoi
(
linebuf
);
if
(
code
==
0
)
continue
;
while
(
linebuf
[
p
]
==
' '
||
linebuf
[
p
]
==
'\t'
)
p
++
;
while
(
linebuf
[
p
]
!=
' '
&&
linebuf
[
p
]
!=
'\t'
&&
linebuf
[
p
]
!=
0
)
p
++
;
linebuf
[
p
]
=
0
;
count
=
atoi
(
&
linebuf
[
sa
]);
if
(
cur
==
NULL
)
continue
;
(
*
cur
->
content
)[
code
]
=
count
;
cur
->
hash
=
cur
->
hash
^
((
code
<<
18
)
|
(
code
>>
14
))
^
((
code
<<
(
27
+
count
))
|
(
code
>>
(
5
-
count
)));
}
fclose
(
fp_custom
);
}
if
(
fp
)
{
if
(
fp
)
{
while
(
fgets
(
linebuf
,
256
,
fp
))
{
while
(
fgets
(
linebuf
,
256
,
fp
))
{
if
(
linebuf
[
0
]
==
'#'
)
if
(
linebuf
[
0
]
==
'#'
)
...
@@ -60,7 +24,7 @@ void DeckManager::LoadLFList() {
...
@@ -60,7 +24,7 @@ void DeckManager::LoadLFList() {
LFList
newlist
;
LFList
newlist
;
_lfList
.
push_back
(
newlist
);
_lfList
.
push_back
(
newlist
);
cur
=
&
_lfList
[
_lfList
.
size
()
-
1
];
cur
=
&
_lfList
[
_lfList
.
size
()
-
1
];
memcpy
(
cur
->
listName
,
(
const
void
*
)
strBuffer
,
40
);
memcpy
(
cur
->
listName
,
(
const
void
*
)
strBuffer
,
20
*
sizeof
(
wchar_t
)
);
cur
->
listName
[
sa
]
=
0
;
cur
->
listName
[
sa
]
=
0
;
cur
->
content
=
new
std
::
unordered_map
<
int
,
int
>
;
cur
->
content
=
new
std
::
unordered_map
<
int
,
int
>
;
cur
->
hash
=
0x7dfcee6a
;
cur
->
hash
=
0x7dfcee6a
;
...
@@ -84,6 +48,10 @@ void DeckManager::LoadLFList() {
...
@@ -84,6 +48,10 @@ void DeckManager::LoadLFList() {
}
}
fclose
(
fp
);
fclose
(
fp
);
}
}
}
void
DeckManager
::
LoadLFList
()
{
LoadLFListSingle
(
"expansions/lflist.conf"
);
LoadLFListSingle
(
"lflist.conf"
);
LFList
nolimit
;
LFList
nolimit
;
myswprintf
(
nolimit
.
listName
,
L"N/A"
);
myswprintf
(
nolimit
.
listName
,
L"N/A"
);
nolimit
.
hash
=
0
;
nolimit
.
hash
=
0
;
...
@@ -266,6 +234,8 @@ bool DeckManager::LoadDeck(const wchar_t* file) {
...
@@ -266,6 +234,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/deck_manager.h
View file @
bad09d56
...
@@ -35,6 +35,7 @@ public:
...
@@ -35,6 +35,7 @@ public:
Deck
current_deck
;
Deck
current_deck
;
std
::
vector
<
LFList
>
_lfList
;
std
::
vector
<
LFList
>
_lfList
;
void
LoadLFListSingle
(
const
char
*
path
);
void
LoadLFList
();
void
LoadLFList
();
wchar_t
*
GetLFListName
(
int
lfhash
);
wchar_t
*
GetLFListName
(
int
lfhash
);
int
CheckDeck
(
Deck
&
deck
,
int
lfhash
,
bool
allow_ocg
,
bool
allow_tcg
);
int
CheckDeck
(
Deck
&
deck
,
int
lfhash
,
bool
allow_ocg
,
bool
allow_tcg
);
...
...
gframe/event_handler.cpp
View file @
bad09d56
...
@@ -995,6 +995,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -995,6 +995,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame
->
ClearCardInfo
(
mcard
->
controler
);
mainGame
->
ClearCardInfo
(
mcard
->
controler
);
}
}
}
}
if
(
id
==
TEXT_CARD_LIST_TIP
)
{
mainGame
->
stCardListTip
->
setVisible
(
true
);
}
break
;
break
;
}
}
case
irr
:
:
gui
::
EGET_ELEMENT_LEFT
:
{
case
irr
:
:
gui
::
EGET_ELEMENT_LEFT
:
{
...
@@ -1010,6 +1013,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -1010,6 +1013,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
SetShowMark
(
mcard
,
false
);
SetShowMark
(
mcard
,
false
);
mainGame
->
stCardListTip
->
setVisible
(
false
);
mainGame
->
stCardListTip
->
setVisible
(
false
);
}
}
if
(
id
==
TEXT_CARD_LIST_TIP
)
{
mainGame
->
stCardListTip
->
setVisible
(
false
);
}
break
;
break
;
}
}
default:
default:
...
@@ -2243,9 +2249,14 @@ void ClientField::ShowCardInfoInList(ClientCard* pcard, irr::gui::IGUIElement* e
...
@@ -2243,9 +2249,14 @@ void ClientField::ShowCardInfoInList(ClientCard* pcard, irr::gui::IGUIElement* e
irr
::
core
::
rect
<
s32
>
ePos
=
element
->
getRelativePosition
();
irr
::
core
::
rect
<
s32
>
ePos
=
element
->
getRelativePosition
();
s32
x
=
(
ePos
.
UpperLeftCorner
.
X
+
ePos
.
LowerRightCorner
.
X
)
/
2
;
s32
x
=
(
ePos
.
UpperLeftCorner
.
X
+
ePos
.
LowerRightCorner
.
X
)
/
2
;
s32
y
=
ePos
.
LowerRightCorner
.
Y
;
s32
y
=
ePos
.
LowerRightCorner
.
Y
;
mainGame
->
SetStaticText
(
mainGame
->
stCardListTip
,
16
0
,
mainGame
->
guiFont
,
str
.
c_str
());
mainGame
->
SetStaticText
(
mainGame
->
stCardListTip
,
32
0
,
mainGame
->
guiFont
,
str
.
c_str
());
irr
::
core
::
dimension2d
<
unsigned
int
>
dTip
=
mainGame
->
guiFont
->
getDimension
(
mainGame
->
stCardListTip
->
getText
())
+
irr
::
core
::
dimension2d
<
unsigned
int
>
(
10
,
10
);
irr
::
core
::
dimension2d
<
unsigned
int
>
dTip
=
mainGame
->
guiFont
->
getDimension
(
mainGame
->
stCardListTip
->
getText
())
+
irr
::
core
::
dimension2d
<
unsigned
int
>
(
10
,
10
);
mainGame
->
stCardListTip
->
setRelativePosition
(
recti
(
x
-
dTip
.
Width
/
2
,
y
-
10
,
x
+
dTip
.
Width
/
2
,
y
-
10
+
dTip
.
Height
));
s32
w
=
dTip
.
Width
/
2
;
if
(
x
-
w
<
10
)
x
=
w
+
10
;
if
(
x
+
w
>
670
)
x
=
670
-
w
;
mainGame
->
stCardListTip
->
setRelativePosition
(
recti
(
x
-
w
,
y
-
10
,
x
+
w
,
y
-
10
+
dTip
.
Height
));
mainGame
->
stCardListTip
->
setVisible
(
true
);
mainGame
->
stCardListTip
->
setVisible
(
true
);
}
}
}
}
...
...
gframe/game.cpp
View file @
bad09d56
This diff is collapsed.
Click to expand it.
gframe/game.h
View file @
bad09d56
...
@@ -145,11 +145,10 @@ public:
...
@@ -145,11 +145,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
);
bool
MakeDirectory
(
const
std
::
string
folder
);
void
ErrorLog
(
const
char
*
msgbuf
);
void
initUtils
();
void
ClearTextures
();
void
ClearTextures
();
void
CloseDuelWindow
();
void
CloseDuelWindow
();
...
@@ -572,6 +571,7 @@ extern HostInfo game_info;
...
@@ -572,6 +571,7 @@ extern HostInfo game_info;
#define BUTTON_CARD_4 234
#define BUTTON_CARD_4 234
#define SCROLL_CARD_SELECT 235
#define SCROLL_CARD_SELECT 235
#define BUTTON_CARD_SEL_OK 236
#define BUTTON_CARD_SEL_OK 236
#define TEXT_CARD_LIST_TIP 237
#define BUTTON_CMD_ACTIVATE 240
#define BUTTON_CMD_ACTIVATE 240
#define BUTTON_CMD_SUMMON 241
#define BUTTON_CMD_SUMMON 241
#define BUTTON_CMD_SPSUMMON 242
#define BUTTON_CMD_SPSUMMON 242
...
...
gframe/myfilesystem.h
0 → 100644
View file @
bad09d56
#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/premake4.lua
View file @
bad09d56
...
@@ -6,7 +6,7 @@ project "ygopro"
...
@@ -6,7 +6,7 @@ project "ygopro"
defines
{
"YGOPRO_SERVER_MODE"
}
defines
{
"YGOPRO_SERVER_MODE"
}
files
{
"gframe.cpp"
,
"config.h"
,
files
{
"gframe.cpp"
,
"config.h"
,
"game.cpp"
,
"game.h"
,
"game.cpp"
,
"game.h"
,
"myfilesystem.h"
,
"deck_manager.cpp"
,
"deck_manager.h"
,
"deck_manager.cpp"
,
"deck_manager.h"
,
"data_manager.cpp"
,
"data_manager.h"
,
"data_manager.cpp"
,
"data_manager.h"
,
"replay.cpp"
,
"replay.h"
,
"replay.cpp"
,
"replay.h"
,
...
...
gframe/replay.cpp
View file @
bad09d56
...
@@ -24,6 +24,8 @@ void Replay::BeginRecord() {
...
@@ -24,6 +24,8 @@ void Replay::BeginRecord() {
#ifdef YGOPRO_SERVER_MODE
#ifdef YGOPRO_SERVER_MODE
if
(
replay_mode
>
0
)
{
if
(
replay_mode
>
0
)
{
#endif
#endif
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
);
...
@@ -177,6 +179,8 @@ void Replay::EndRecord() {
...
@@ -177,6 +179,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 @
bad09d56
#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