Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
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
fallenstardust
YGOMobile
Commits
abe0f0b9
Commit
abe0f0b9
authored
Nov 21, 2019
by
Unicorn369
Committed by
fallenstardust
Dec 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
f3973192
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
Classes/gframe/sound_manager.cpp
Classes/gframe/sound_manager.cpp
+29
-4
Classes/gframe/sound_manager.h
Classes/gframe/sound_manager.h
+3
-0
No files found.
Classes/gframe/sound_manager.cpp
View file @
abe0f0b9
...
@@ -52,9 +52,18 @@ void SoundManager::RefreshBGMDir(path_string path, BGM scene) {
...
@@ -52,9 +52,18 @@ void SoundManager::RefreshBGMDir(path_string path, BGM scene) {
void
SoundManager
::
RefreshChantsList
()
{
void
SoundManager
::
RefreshChantsList
()
{
for
(
auto
&
file
:
Utils
::
FindfolderFiles
(
TEXT
(
"./sound/chants"
),
{
TEXT
(
"mp3"
),
TEXT
(
"ogg"
),
TEXT
(
"wav"
)
}))
{
for
(
auto
&
file
:
Utils
::
FindfolderFiles
(
TEXT
(
"./sound/chants"
),
{
TEXT
(
"mp3"
),
TEXT
(
"ogg"
),
TEXT
(
"wav"
)
}))
{
auto
scode
=
Utils
::
GetFileName
(
TEXT
(
"./sound/chants/"
)
+
file
);
auto
scode
=
Utils
::
GetFileName
(
TEXT
(
"./sound/chants/"
)
+
file
);
unsigned
int
code
=
std
::
stoi
(
scode
);
try
{
if
(
code
&&
!
ChantsList
.
count
(
code
))
unsigned
int
code
=
std
::
stoi
(
scode
);
ChantsList
[
code
]
=
Utils
::
ToUTF8IfNeeded
(
file
);
if
(
code
&&
!
ChantsList
.
count
(
code
))
ChantsList
[
code
]
=
Utils
::
ToUTF8IfNeeded
(
file
);
}
catch
(
std
::
exception
&
e
)
{
char
buf
[
1040
];
auto
fileName
=
Utils
::
ToUTF8IfNeeded
(
TEXT
(
"./sound/chants/"
)
+
file
);
sprintf
(
buf
,
"[文件名只能为卡片ID]: %s"
,
fileName
.
c_str
());
Utils
::
Deletefile
(
fileName
);
mainGame
->
ErrorLog
(
buf
);
}
}
}
}
}
void
SoundManager
::
PlaySoundEffect
(
SFX
sound
)
{
void
SoundManager
::
PlaySoundEffect
(
SFX
sound
)
{
...
@@ -132,16 +141,29 @@ void SoundManager::PlayBGM(BGM scene) {
...
@@ -132,16 +141,29 @@ void SoundManager::PlayBGM(BGM scene) {
PlayMusic
(
BGMName
,
false
);
PlayMusic
(
BGMName
,
false
);
}
}
}
}
void
SoundManager
::
StopSound
()
{
sfx
->
stopAll
();
}
void
SoundManager
::
StopBGM
()
{
void
SoundManager
::
StopBGM
()
{
bgm
->
stopAll
();
bgm
->
stopAll
();
}
}
bool
SoundManager
::
PlayChant
(
unsigned
int
code
)
{
bool
SoundManager
::
PlayChant
(
unsigned
int
code
)
{
if
(
ChantsList
.
count
(
code
))
{
if
(
ChantsList
.
count
(
code
))
{
if
(
bgm
)
bgm
->
play
(
"./sound/chants/"
+
ChantsList
[
code
],
false
);
if
(
bgm
)
PlayMusic
(
"./sound/chants/"
+
ChantsList
[
code
],
false
);
return
true
;
return
true
;
}
}
return
false
;
return
false
;
}
}
void
SoundManager
::
PlayCustomSound
(
char
*
SoundName
)
{
if
(
!
soundsEnabled
)
return
;
if
(
access
(
SoundName
,
0
)
!=
0
)
return
;
if
(
sfx
)
sfx
->
play
(
SoundName
,
false
);
}
void
SoundManager
::
PlayCustomBGM
(
char
*
BGMName
)
{
if
(
!
musicEnabled
||
!
mainGame
->
chkMusicMode
->
isChecked
())
return
;
if
(
access
(
BGMName
,
0
)
!=
0
)
return
;
if
(
bgm
)
PlayMusic
(
BGMName
,
false
);
}
void
SoundManager
::
SetSoundVolume
(
double
volume
)
{
void
SoundManager
::
SetSoundVolume
(
double
volume
)
{
if
(
sfx
)
sfx
->
setVolume
(
volume
);
if
(
sfx
)
sfx
->
setVolume
(
volume
);
}
}
...
@@ -150,6 +172,9 @@ void SoundManager::SetMusicVolume(double volume) {
...
@@ -150,6 +172,9 @@ void SoundManager::SetMusicVolume(double volume) {
}
}
void
SoundManager
::
EnableSounds
(
bool
enable
)
{
void
SoundManager
::
EnableSounds
(
bool
enable
)
{
soundsEnabled
=
enable
;
soundsEnabled
=
enable
;
if
(
!
soundsEnabled
)
{
StopSound
();
}
}
}
void
SoundManager
::
EnableMusic
(
bool
enable
)
{
void
SoundManager
::
EnableMusic
(
bool
enable
)
{
musicEnabled
=
enable
;
musicEnabled
=
enable
;
...
...
Classes/gframe/sound_manager.h
View file @
abe0f0b9
...
@@ -56,8 +56,11 @@ public:
...
@@ -56,8 +56,11 @@ public:
void
PlayDialogSound
(
irr
::
gui
::
IGUIElement
*
element
);
void
PlayDialogSound
(
irr
::
gui
::
IGUIElement
*
element
);
void
PlayMusic
(
const
std
::
string
&
song
,
bool
loop
);
void
PlayMusic
(
const
std
::
string
&
song
,
bool
loop
);
void
PlayBGM
(
BGM
scene
);
void
PlayBGM
(
BGM
scene
);
void
StopSound
();
void
StopBGM
();
void
StopBGM
();
bool
PlayChant
(
unsigned
int
code
);
bool
PlayChant
(
unsigned
int
code
);
void
PlayCustomSound
(
char
*
SoundName
);
void
PlayCustomBGM
(
char
*
BGMName
);
void
SetSoundVolume
(
double
volume
);
void
SetSoundVolume
(
double
volume
);
void
SetMusicVolume
(
double
volume
);
void
SetMusicVolume
(
double
volume
);
void
EnableSounds
(
bool
enable
);
void
EnableSounds
(
bool
enable
);
...
...
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