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
6e971263
Commit
6e971263
authored
Apr 21, 2018
by
edo9300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove
parent
bb84dbc3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
356 deletions
+0
-356
gframe/sound_manager.cpp
gframe/sound_manager.cpp
+0
-276
gframe/sound_manager.h
gframe/sound_manager.h
+0
-80
No files found.
gframe/sound_manager.cpp
deleted
100644 → 0
View file @
bb84dbc3
#include "sound_manager.h"
#ifndef _WIN32
#include <dirent.h>
#endif
#ifdef IRRKLANG_STATIC
#include "../ikpmp3/ikpMP3.h"
#endif
namespace
ygo
{
SoundManager
soundManager
;
bool
SoundManager
::
Init
()
{
#ifdef YGOPRO_USE_IRRKLANG
bgm_scene
=
-
1
;
RefreshBGMList
();
engineSound
=
irrklang
::
createIrrKlangDevice
();
engineMusic
=
irrklang
::
createIrrKlangDevice
();
if
(
!
engineSound
||
!
engineMusic
)
{
return
false
;
}
else
{
#ifdef IRRKLANG_STATIC
irrklang
::
ikpMP3Init
(
engineMusic
);
#endif
return
true
;
}
#endif // YGOPRO_USE_IRRKLANG
// TODO: Implement other sound engines
return
false
;
}
void
SoundManager
::
RefreshBGMList
()
{
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
);
}
void
SoundManager
::
RefershBGMDir
(
std
::
wstring
path
,
int
scene
)
{
#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
}
void
SoundManager
::
PlaySoundEffect
(
int
sound
)
{
#ifdef YGOPRO_USE_IRRKLANG
if
(
!
mainGame
->
chkEnableSound
->
isChecked
())
return
;
switch
(
sound
)
{
case
SOUND_SUMMON
:
{
engineSound
->
play2D
(
"./sound/summon.wav"
);
break
;
}
case
SOUND_SPECIAL_SUMMON
:
{
engineSound
->
play2D
(
"./sound/specialsummon.wav"
);
break
;
}
case
SOUND_ACTIVATE
:
{
engineSound
->
play2D
(
"./sound/activate.wav"
);
break
;
}
case
SOUND_SET
:
{
engineSound
->
play2D
(
"./sound/set.wav"
);
break
;
}
case
SOUND_FILP
:
{
engineSound
->
play2D
(
"./sound/flip.wav"
);
break
;
}
case
SOUND_REVEAL
:
{
engineSound
->
play2D
(
"./sound/reveal.wav"
);
break
;
}
case
SOUND_EQUIP
:
{
engineSound
->
play2D
(
"./sound/equip.wav"
);
break
;
}
case
SOUND_DESTROYED
:
{
engineSound
->
play2D
(
"./sound/destroyed.wav"
);
break
;
}
case
SOUND_BANISHED
:
{
engineSound
->
play2D
(
"./sound/banished.wav"
);
break
;
}
case
SOUND_TOKEN
:
{
engineSound
->
play2D
(
"./sound/token.wav"
);
break
;
}
case
SOUND_ATTACK
:
{
engineSound
->
play2D
(
"./sound/attack.wav"
);
break
;
}
case
SOUND_DIRECT_ATTACK
:
{
engineSound
->
play2D
(
"./sound/directattack.wav"
);
break
;
}
case
SOUND_DRAW
:
{
engineSound
->
play2D
(
"./sound/draw.wav"
);
break
;
}
case
SOUND_SHUFFLE
:
{
engineSound
->
play2D
(
"./sound/shuffle.wav"
);
break
;
}
case
SOUND_DAMAGE
:
{
engineSound
->
play2D
(
"./sound/damage.wav"
);
break
;
}
case
SOUND_RECOVER
:
{
engineSound
->
play2D
(
"./sound/gainlp.wav"
);
break
;
}
case
SOUND_COUNTER_ADD
:
{
engineSound
->
play2D
(
"./sound/addcounter.wav"
);
break
;
}
case
SOUND_COUNTER_REMOVE
:
{
engineSound
->
play2D
(
"./sound/removecounter.wav"
);
break
;
}
case
SOUND_COIN
:
{
engineSound
->
play2D
(
"./sound/coinflip.wav"
);
break
;
}
case
SOUND_DICE
:
{
engineSound
->
play2D
(
"./sound/diceroll.wav"
);
break
;
}
case
SOUND_NEXT_TURN
:
{
engineSound
->
play2D
(
"./sound/nextturn.wav"
);
break
;
}
case
SOUND_PHASE
:
{
engineSound
->
play2D
(
"./sound/phase.wav"
);
break
;
}
case
SOUND_MENU
:
{
engineSound
->
play2D
(
"./sound/menu.wav"
);
break
;
}
case
SOUND_BUTTON
:
{
engineSound
->
play2D
(
"./sound/button.wav"
);
break
;
}
case
SOUND_INFO
:
{
engineSound
->
play2D
(
"./sound/info.wav"
);
break
;
}
case
SOUND_QUESTION
:
{
engineSound
->
play2D
(
"./sound/question.wav"
);
break
;
}
case
SOUND_CARD_PICK
:
{
engineSound
->
play2D
(
"./sound/cardpick.wav"
);
break
;
}
case
SOUND_CARD_DROP
:
{
engineSound
->
play2D
(
"./sound/carddrop.wav"
);
break
;
}
case
SOUND_PLAYER_ENTER
:
{
engineSound
->
play2D
(
"./sound/playerenter.wav"
);
break
;
}
case
SOUND_CHAT
:
{
engineSound
->
play2D
(
"./sound/chatmessage.wav"
);
break
;
}
default:
break
;
}
engineSound
->
setSoundVolume
(
mainGame
->
gameConf
.
sound_volume
);
#endif
}
void
SoundManager
::
PlayDialogSound
(
irr
::
gui
::
IGUIElement
*
element
)
{
if
(
element
==
mainGame
->
wMessage
)
{
PlaySoundEffect
(
SOUND_INFO
);
}
else
if
(
element
==
mainGame
->
wQuery
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
else
if
(
element
==
mainGame
->
wOptions
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
else
if
(
element
==
mainGame
->
wANAttribute
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
else
if
(
element
==
mainGame
->
wANCard
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
else
if
(
element
==
mainGame
->
wANNumber
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
else
if
(
element
==
mainGame
->
wANRace
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
else
if
(
element
==
mainGame
->
wReplaySave
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
}
void
SoundManager
::
PlayMusic
(
char
*
song
,
bool
loop
)
{
#ifdef YGOPRO_USE_IRRKLANG
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
())
return
;
if
(
!
engineMusic
->
isCurrentlyPlaying
(
song
))
{
engineMusic
->
stopAllSounds
();
soundBGM
=
engineMusic
->
play2D
(
song
,
loop
,
false
,
true
);
engineMusic
->
setSoundVolume
(
mainGame
->
gameConf
.
music_volume
);
}
#endif
}
void
SoundManager
::
PlayBGM
(
int
scene
)
{
#ifdef YGOPRO_USE_IRRKLANG
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
())
return
;
if
(
!
mainGame
->
chkMusicMode
->
isChecked
())
scene
=
BGM_ALL
;
char
BGMName
[
1024
];
if
(
scene
!=
bgm_scene
||
(
soundBGM
&&
soundBGM
->
isFinished
()))
{
int
count
=
BGMList
[
scene
].
size
();
if
(
count
<=
0
)
return
;
bgm_scene
=
scene
;
int
bgm
=
rand
()
%
count
;
auto
name
=
BGMList
[
scene
][
bgm
].
c_str
();
wchar_t
fname
[
1024
];
myswprintf
(
fname
,
L"./sound/BGM/%ls"
,
name
);
BufferIO
::
EncodeUTF8
(
fname
,
BGMName
);
PlayMusic
(
BGMName
,
false
);
}
#endif
}
void
SoundManager
::
StopBGM
()
{
#ifdef YGOPRO_USE_IRRKLANG
engineMusic
->
stopAllSounds
();
#endif
}
void
SoundManager
::
SetSoundVolume
(
double
volume
)
{
#ifdef YGOPRO_USE_IRRKLANG
engineSound
->
setSoundVolume
(
volume
);
#endif
}
void
SoundManager
::
SetMusicVolume
(
double
volume
)
{
#ifdef YGOPRO_USE_IRRKLANG
engineMusic
->
setSoundVolume
(
volume
);
#endif
}
}
gframe/sound_manager.h
deleted
100644 → 0
View file @
bb84dbc3
#ifndef SOUNDMANAGER_H
#define SOUNDMANAGER_H
#include "game.h"
#ifdef YGOPRO_USE_IRRKLANG
#include <irrKlang.h>
#endif
namespace
ygo
{
class
SoundManager
{
private:
std
::
vector
<
std
::
wstring
>
BGMList
[
8
];
int
bgm_scene
;
#ifdef YGOPRO_USE_IRRKLANG
irrklang
::
ISoundEngine
*
engineSound
;
irrklang
::
ISoundEngine
*
engineMusic
;
irrklang
::
ISound
*
soundBGM
;
#endif
void
RefershBGMDir
(
std
::
wstring
path
,
int
scene
);
public:
bool
Init
();
void
RefreshBGMList
();
void
PlaySoundEffect
(
int
sound
);
void
PlayDialogSound
(
irr
::
gui
::
IGUIElement
*
element
);
void
PlayMusic
(
char
*
song
,
bool
loop
);
void
PlayBGM
(
int
scene
);
void
StopBGM
();
void
SetSoundVolume
(
double
volume
);
void
SetMusicVolume
(
double
volume
);
};
extern
SoundManager
soundManager
;
#define SOUND_SUMMON 101
#define SOUND_SPECIAL_SUMMON 102
#define SOUND_ACTIVATE 103
#define SOUND_SET 104
#define SOUND_FILP 105
#define SOUND_REVEAL 106
#define SOUND_EQUIP 107
#define SOUND_DESTROYED 108
#define SOUND_BANISHED 109
#define SOUND_TOKEN 110
#define SOUND_ATTACK 201
#define SOUND_DIRECT_ATTACK 202
#define SOUND_DRAW 203
#define SOUND_SHUFFLE 204
#define SOUND_DAMAGE 205
#define SOUND_RECOVER 206
#define SOUND_COUNTER_ADD 207
#define SOUND_COUNTER_REMOVE 208
#define SOUND_COIN 209
#define SOUND_DICE 210
#define SOUND_NEXT_TURN 211
#define SOUND_PHASE 212
#define SOUND_MENU 301
#define SOUND_BUTTON 302
#define SOUND_INFO 303
#define SOUND_QUESTION 304
#define SOUND_CARD_PICK 305
#define SOUND_CARD_DROP 306
#define SOUND_PLAYER_ENTER 307
#define SOUND_CHAT 308
#define BGM_ALL 0
#define BGM_DUEL 1
#define BGM_MENU 2
#define BGM_DECK 3
#define BGM_ADVANTAGE 4
#define BGM_DISADVANTAGE 5
#define BGM_WIN 6
#define BGM_LOSE 7
}
#endif //SOUNDMANAGER_H
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