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
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
Commits
15687a2c
Commit
15687a2c
authored
Mar 31, 2025
by
mercury233
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
less conversion
parent
df24544f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
21 deletions
+17
-21
gframe/sound_manager.cpp
gframe/sound_manager.cpp
+14
-18
gframe/sound_manager.h
gframe/sound_manager.h
+3
-3
No files found.
gframe/sound_manager.cpp
View file @
15687a2c
...
...
@@ -250,37 +250,35 @@ void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) {
PlaySoundEffect
(
SOUND_QUESTION
);
}
}
bool
SoundManager
::
IsCurrentlyPlaying
(
char
*
song
)
{
bool
SoundManager
::
IsCurrentlyPlaying
(
wchar_t
*
music
)
{
#ifdef YGOPRO_USE_MINIAUDIO
return
currentPlayingMusic
[
0
]
&&
strcmp
(
currentPlayingMusic
,
song
)
==
0
&&
ma_sound_is_playing
(
&
soundBGM
);
return
currentPlayingMusic
[
0
]
&&
!
mywcsncasecmp
(
currentPlayingMusic
,
music
,
1024
)
&&
ma_sound_is_playing
(
&
soundBGM
);
#endif
#ifdef YGOPRO_USE_IRRKLANG
return
engineMusic
->
isCurrentlyPlaying
(
song
);
char
cmusic
[
1024
];
BufferIO
::
EncodeUTF8
(
music
,
cmusic
);
return
engineMusic
->
isCurrentlyPlaying
(
cmusic
);
#endif
return
false
;
}
void
SoundManager
::
PlayMusic
(
char
*
song
,
bool
loop
)
{
void
SoundManager
::
PlayMusic
(
wchar_t
*
music
,
bool
loop
)
{
#ifdef YGOPRO_USE_AUDIO
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
())
return
;
if
(
!
IsCurrentlyPlaying
(
song
))
{
if
(
!
IsCurrentlyPlaying
(
music
))
{
StopBGM
();
#ifdef YGOPRO_USE_MINIAUDIO
strcpy
(
currentPlayingMusic
,
song
);
#ifdef _WIN32
wchar_t
song_w
[
1024
];
BufferIO
::
DecodeUTF8
(
song
,
song_w
);
ma_sound_init_from_file_w
(
&
engineMusic
,
song_w
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
&
soundBGM
);
#else
ma_sound_init_from_file
(
&
engineMusic
,
song
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
&
soundBGM
);
#endif
BufferIO
::
CopyWStr
(
music
,
currentPlayingMusic
,
1024
);
ma_sound_init_from_file_w
(
&
engineMusic
,
music
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
&
soundBGM
);
ma_sound_set_looping
(
&
soundBGM
,
loop
);
ma_sound_start
(
&
soundBGM
);
#endif
#ifdef YGOPRO_USE_IRRKLANG
engineMusic
->
stopAllSounds
();
engineMusic
->
setSoundVolume
(
mainGame
->
gameConf
.
music_volume
);
soundBGM
=
engineMusic
->
play2D
(
song
,
loop
,
false
,
true
);
char
cmusic
[
1024
];
BufferIO
::
EncodeUTF8
(
music
,
cmusic
);
soundBGM
=
engineMusic
->
play2D
(
cmusic
,
loop
,
false
,
true
);
#endif
}
#endif
...
...
@@ -291,7 +289,6 @@ void SoundManager::PlayBGM(int scene) {
return
;
if
(
!
mainGame
->
chkMusicMode
->
isChecked
())
scene
=
BGM_ALL
;
char
BGMName
[
1024
];
#if defined(YGOPRO_USE_MINIAUDIO)
if
(
scene
!=
bgm_scene
||
!
IsCurrentlyPlaying
(
currentPlayingMusic
))
{
#elif defined(YGOPRO_USE_IRRKLANG)
...
...
@@ -303,9 +300,8 @@ void SoundManager::PlayBGM(int scene) {
bgm_scene
=
scene
;
int
bgm
=
rnd
.
get_random_integer
(
0
,
count
-
1
);
auto
name
=
BGMList
[
scene
][
bgm
].
c_str
();
wchar_t
fname
[
1024
];
myswprintf
(
fname
,
L"./sound/BGM/%ls"
,
name
);
BufferIO
::
EncodeUTF8
(
fname
,
BGMName
);
wchar_t
BGMName
[
1024
];
myswprintf
(
BGMName
,
L"./sound/BGM/%ls"
,
name
);
PlayMusic
(
BGMName
,
false
);
}
#endif
...
...
gframe/sound_manager.h
View file @
15687a2c
...
...
@@ -26,7 +26,7 @@ private:
ma_engine
engineSound
;
ma_engine
engineMusic
;
ma_sound
soundBGM
;
char
currentPlayingMusic
[
1024
]{};
wchar_t
currentPlayingMusic
[
1024
]{};
#endif
#ifdef YGOPRO_USE_IRRKLANG
irrklang
::
ISoundEngine
*
engineSound
;
...
...
@@ -40,8 +40,8 @@ public:
void
RefreshBGMList
();
void
PlaySoundEffect
(
int
sound
);
void
PlayDialogSound
(
irr
::
gui
::
IGUIElement
*
element
);
bool
IsCurrentlyPlaying
(
char
*
song
);
void
PlayMusic
(
char
*
song
,
bool
loop
);
bool
IsCurrentlyPlaying
(
wchar_t
*
music
);
void
PlayMusic
(
wchar_t
*
music
,
bool
loop
);
void
PlayBGM
(
int
scene
);
void
StopBGM
();
void
SetSoundVolume
(
double
volume
);
...
...
mercury233
@mercury233
mentioned in commit
e337da72
·
May 04, 2025
mentioned in commit
e337da72
mentioned in commit e337da729bc7e0c2a89255b0a78a29f37202be9b
Toggle commit list
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