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
1
Merge Requests
1
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
c2e71eef
Commit
c2e71eef
authored
Mar 31, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test se
parent
82f1e003
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
11 deletions
+35
-11
gframe/sound_manager.cpp
gframe/sound_manager.cpp
+34
-11
gframe/sound_manager.h
gframe/sound_manager.h
+1
-0
No files found.
gframe/sound_manager.cpp
View file @
c2e71eef
...
@@ -36,6 +36,7 @@ bool SoundManager::Init() {
...
@@ -36,6 +36,7 @@ bool SoundManager::Init() {
}
}
engineConfig
.
pResourceManager
=
&
resourceManager
;
engineConfig
.
pResourceManager
=
&
resourceManager
;
#endif
#endif
playingSoundEffect
=
FALSE
;
if
(
ma_engine_init
(
&
engineConfig
,
&
engineSound
)
!=
MA_SUCCESS
||
ma_engine_init
(
&
engineConfig
,
&
engineMusic
)
!=
MA_SUCCESS
)
{
if
(
ma_engine_init
(
&
engineConfig
,
&
engineSound
)
!=
MA_SUCCESS
||
ma_engine_init
(
&
engineConfig
,
&
engineMusic
)
!=
MA_SUCCESS
)
{
return
false
;
return
false
;
}
else
{
}
else
{
...
@@ -85,6 +86,28 @@ void SoundManager::RefershBGMDir(std::wstring path, int scene) {
...
@@ -85,6 +86,28 @@ void SoundManager::RefershBGMDir(std::wstring path, int scene) {
}
}
});
});
}
}
void
SoundManager
::
PlaySound
(
char
*
sound
)
{
#ifdef YGOPRO_USE_AUDIO
if
(
!
mainGame
->
chkEnableSound
->
isChecked
())
return
;
#ifdef YGOPRO_USE_MINIAUDIO
StopSound
();
SetSoundVolume
(
mainGame
->
gameConf
.
sound_volume
);
#ifdef _WIN32
wchar_t
sound_w
[
1024
];
BufferIO
::
DecodeUTF8
(
song
,
sound_w
);
ma_sound_init_from_file_w
(
&
engineSound
,
sound_w
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
&
soundEffect
);
#else
ma_sound_init_from_file
(
&
engineSound
,
sound
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
&
soundEffect
);
#endif
ma_sound_start
(
&
soundEffect
);
#endif
#ifdef YGOPRO_USE_IRRKLANG
SetSoundVolume
(
mainGame
->
gameConf
.
sound_volume
);
engineSound
->
play2D
(
soundPath
);
#endif
#endif
}
void
SoundManager
::
PlaySoundEffect
(
int
sound
)
{
void
SoundManager
::
PlaySoundEffect
(
int
sound
)
{
#ifdef YGOPRO_USE_AUDIO
#ifdef YGOPRO_USE_AUDIO
if
(
!
mainGame
->
chkEnableSound
->
isChecked
())
if
(
!
mainGame
->
chkEnableSound
->
isChecked
())
...
@@ -220,14 +243,7 @@ void SoundManager::PlaySoundEffect(int sound) {
...
@@ -220,14 +243,7 @@ void SoundManager::PlaySoundEffect(int sound) {
}
}
char
soundPath
[
40
];
char
soundPath
[
40
];
std
::
snprintf
(
soundPath
,
40
,
"./sound/%s.wav"
,
soundName
);
std
::
snprintf
(
soundPath
,
40
,
"./sound/%s.wav"
,
soundName
);
#ifdef YGOPRO_USE_MINIAUDIO
PlaySound
(
soundPath
);
ma_engine_set_volume
(
&
engineSound
,
mainGame
->
gameConf
.
sound_volume
);
ma_engine_play_sound
(
&
engineSound
,
soundPath
,
nullptr
);
#endif
#ifdef YGOPRO_USE_IRRKLANG
engineSound
->
setSoundVolume
(
mainGame
->
gameConf
.
sound_volume
);
engineSound
->
play2D
(
soundPath
);
#endif
#endif // YGOPRO_USE_AUDIO
#endif // YGOPRO_USE_AUDIO
}
}
void
SoundManager
::
PlayDialogSound
(
irr
::
gui
::
IGUIElement
*
element
)
{
void
SoundManager
::
PlayDialogSound
(
irr
::
gui
::
IGUIElement
*
element
)
{
...
@@ -268,6 +284,7 @@ void SoundManager::PlayMusic(char* song, bool loop) {
...
@@ -268,6 +284,7 @@ void SoundManager::PlayMusic(char* song, bool loop) {
return
;
return
;
if
(
!
IsCurrentlyPlaying
(
song
))
{
if
(
!
IsCurrentlyPlaying
(
song
))
{
StopBGM
();
StopBGM
();
SetSoundVolume
(
mainGame
->
gameConf
.
music_volume
);
#ifdef YGOPRO_USE_MINIAUDIO
#ifdef YGOPRO_USE_MINIAUDIO
strcpy
(
currentPlayingMusic
,
song
);
strcpy
(
currentPlayingMusic
,
song
);
#ifdef _WIN32
#ifdef _WIN32
...
@@ -281,8 +298,6 @@ void SoundManager::PlayMusic(char* song, bool loop) {
...
@@ -281,8 +298,6 @@ void SoundManager::PlayMusic(char* song, bool loop) {
ma_sound_start
(
&
soundBGM
);
ma_sound_start
(
&
soundBGM
);
#endif
#endif
#ifdef YGOPRO_USE_IRRKLANG
#ifdef YGOPRO_USE_IRRKLANG
engineMusic
->
stopAllSounds
();
engineMusic
->
setSoundVolume
(
mainGame
->
gameConf
.
music_volume
);
soundBGM
=
engineMusic
->
play2D
(
song
,
loop
,
false
,
true
);
soundBGM
=
engineMusic
->
play2D
(
song
,
loop
,
false
,
true
);
#endif
#endif
}
}
...
@@ -352,7 +367,15 @@ void SoundManager::StopBGM() {
...
@@ -352,7 +367,15 @@ void SoundManager::StopBGM() {
#endif
#endif
}
}
void
SoundManager
::
StopSound
()
{
void
SoundManager
::
StopSound
()
{
// TODO: stop all sounds
#ifdef YGOPRO_USE_MINIAUDIO
if
(
!
playingSoundEffect
||
!
ma_sound_is_playing
(
&
soundEffect
))
return
;
playingSoundEffect
=
FALSE
;
ma_sound_uninit
(
&
soundEffect
);
#endif
#ifdef YGOPRO_USE_IRRKLANG
engineSound
->
stopAllSounds
();
#endif
}
}
void
SoundManager
::
SetSoundVolume
(
double
volume
)
{
void
SoundManager
::
SetSoundVolume
(
double
volume
)
{
#ifdef YGOPRO_USE_MINIAUDIO
#ifdef YGOPRO_USE_MINIAUDIO
...
...
gframe/sound_manager.h
View file @
c2e71eef
...
@@ -30,6 +30,7 @@ private:
...
@@ -30,6 +30,7 @@ private:
ma_sound
soundBGM
;
ma_sound
soundBGM
;
char
currentPlayingMusic
[
1024
]{};
char
currentPlayingMusic
[
1024
]{};
ma_sound
soundEffect
;
ma_sound
soundEffect
;
char
playingSoundEffect
;
#endif
#endif
#ifdef YGOPRO_USE_IRRKLANG
#ifdef YGOPRO_USE_IRRKLANG
irrklang
::
ISoundEngine
*
engineSound
;
irrklang
::
ISoundEngine
*
engineSound
;
...
...
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