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
wyykak
ygopro
Commits
fe3a2554
Commit
fe3a2554
authored
Jul 10, 2017
by
mercury233
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sound' into link
parents
952fb20f
1b49dd79
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
42 deletions
+65
-42
gframe/event_handler.cpp
gframe/event_handler.cpp
+1
-1
gframe/game.cpp
gframe/game.cpp
+49
-39
gframe/game.h
gframe/game.h
+15
-2
No files found.
gframe/event_handler.cpp
View file @
fe3a2554
...
@@ -1976,9 +1976,9 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
...
@@ -1976,9 +1976,9 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
s32
id
=
event
.
GUIEvent
.
Caller
->
getID
();
s32
id
=
event
.
GUIEvent
.
Caller
->
getID
();
switch
(
event
.
GUIEvent
.
EventType
)
{
switch
(
event
.
GUIEvent
.
EventType
)
{
case
irr
:
:
gui
::
EGET_BUTTON_CLICKED
:
{
case
irr
:
:
gui
::
EGET_BUTTON_CLICKED
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
switch
(
id
)
{
switch
(
id
)
{
case
BUTTON_CLEAR_LOG
:
{
case
BUTTON_CLEAR_LOG
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
mainGame
->
lstLog
->
clear
();
mainGame
->
lstLog
->
clear
();
mainGame
->
logParam
.
clear
();
mainGame
->
logParam
.
clear
();
return
true
;
return
true
;
...
...
gframe/game.cpp
View file @
fe3a2554
...
@@ -44,6 +44,7 @@ bool Game::Initialize() {
...
@@ -44,6 +44,7 @@ bool Game::Initialize() {
ignore_chain
=
false
;
ignore_chain
=
false
;
chain_when_avail
=
false
;
chain_when_avail
=
false
;
is_building
=
false
;
is_building
=
false
;
bgm_scene
=
-
1
;
memset
(
&
dInfo
,
0
,
sizeof
(
DuelInfo
));
memset
(
&
dInfo
,
0
,
sizeof
(
DuelInfo
));
memset
(
chatTiming
,
0
,
sizeof
(
chatTiming
));
memset
(
chatTiming
,
0
,
sizeof
(
chatTiming
));
deckManager
.
LoadLFList
();
deckManager
.
LoadLFList
();
...
@@ -685,15 +686,15 @@ void Game::MainLoop() {
...
@@ -685,15 +686,15 @@ void Game::MainLoop() {
gMutex
.
Lock
();
gMutex
.
Lock
();
if
(
dInfo
.
isStarted
)
{
if
(
dInfo
.
isStarted
)
{
if
(
mainGame
->
showcardcode
==
1
||
mainGame
->
showcardcode
==
3
)
if
(
mainGame
->
showcardcode
==
1
||
mainGame
->
showcardcode
==
3
)
Play
Music
(
"./sound/duelwin.mp3"
,
true
);
Play
BGM
(
BGM_WIN
);
else
if
(
mainGame
->
showcardcode
==
2
)
else
if
(
mainGame
->
showcardcode
==
2
)
Play
Music
(
"./sound/duellose.mp3"
,
true
);
Play
BGM
(
BGM_LOSE
);
else
if
(
mainGame
->
dInfo
.
lp
[
0
]
>
0
&&
mainGame
->
dInfo
.
lp
[
LocalPlayer
(
0
)]
<=
mainGame
->
dInfo
.
lp
[
LocalPlayer
(
1
)]
/
2
)
else
if
(
mainGame
->
dInfo
.
lp
[
0
]
>
0
&&
mainGame
->
dInfo
.
lp
[
LocalPlayer
(
0
)]
<=
mainGame
->
dInfo
.
lp
[
LocalPlayer
(
1
)]
/
2
)
Play
Music
(
"./sound/song-disadvantage.mp3"
,
true
);
Play
BGM
(
BGM_DISADVANTAGE
);
else
if
(
mainGame
->
dInfo
.
lp
[
0
]
>
0
&&
mainGame
->
dInfo
.
lp
[
LocalPlayer
(
0
)]
>=
mainGame
->
dInfo
.
lp
[
LocalPlayer
(
1
)]
*
2
)
else
if
(
mainGame
->
dInfo
.
lp
[
0
]
>
0
&&
mainGame
->
dInfo
.
lp
[
LocalPlayer
(
0
)]
>=
mainGame
->
dInfo
.
lp
[
LocalPlayer
(
1
)]
*
2
)
Play
Music
(
"./sound/song-advantage.mp3"
,
true
);
Play
BGM
(
BGM_ADVANTAGE
);
else
else
PlayBGM
();
PlayBGM
(
BGM_DUEL
);
DrawBackImage
(
imageManager
.
tBackGround
);
DrawBackImage
(
imageManager
.
tBackGround
);
DrawBackGround
();
DrawBackGround
();
DrawCards
();
DrawCards
();
...
@@ -702,11 +703,11 @@ void Game::MainLoop() {
...
@@ -702,11 +703,11 @@ void Game::MainLoop() {
driver
->
setMaterial
(
irr
::
video
::
IdentityMaterial
);
driver
->
setMaterial
(
irr
::
video
::
IdentityMaterial
);
driver
->
clearZBuffer
();
driver
->
clearZBuffer
();
}
else
if
(
is_building
)
{
}
else
if
(
is_building
)
{
Play
Music
(
"./sound/deck.mp3"
,
true
);
Play
BGM
(
BGM_DECK
);
DrawBackImage
(
imageManager
.
tBackGround_deck
);
DrawBackImage
(
imageManager
.
tBackGround_deck
);
DrawDeckBd
();
DrawDeckBd
();
}
else
{
}
else
{
Play
Music
(
"./sound/menu.mp3"
,
true
);
Play
BGM
(
BGM_MENU
);
DrawBackImage
(
imageManager
.
tBackGround_menu
);
DrawBackImage
(
imageManager
.
tBackGround_menu
);
}
}
DrawGUI
();
DrawGUI
();
...
@@ -952,14 +953,28 @@ void Game::RefreshSingleplay() {
...
@@ -952,14 +953,28 @@ void Game::RefreshSingleplay() {
#endif
#endif
}
}
void
Game
::
RefreshBGMList
()
{
void
Game
::
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
Game
::
RefershBGMDir
(
std
::
wstring
path
,
int
scene
)
{
#ifdef _WIN32
#ifdef _WIN32
WIN32_FIND_DATAW
fdataw
;
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
L"./sound/BGM/*.mp3"
,
&
fdataw
);
std
::
wstring
search
=
L"./sound/BGM/"
+
path
+
L"*.mp3"
;
HANDLE
fh
=
FindFirstFileW
(
search
.
c_str
(),
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
return
;
do
{
do
{
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
))
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
))
{
BGMList
.
push_back
(
fdataw
.
cFileName
);
std
::
wstring
filename
=
path
+
(
std
::
wstring
)
fdataw
.
cFileName
;
BGMList
[
BGM_ALL
].
push_back
(
filename
);
BGMList
[
scene
].
push_back
(
filename
);
}
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
FindClose
(
fh
);
#else
#else
...
@@ -973,7 +988,7 @@ void Game::RefreshBGMList() {
...
@@ -973,7 +988,7 @@ void Game::RefreshBGMList() {
continue
;
continue
;
wchar_t
wname
[
256
];
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
BGMList
.
push_back
(
fdataw
.
cFileN
ame
);
BGMList
[
BGM_ALL
].
push_back
(
wn
ame
);
}
}
closedir
(
dir
);
closedir
(
dir
);
#endif
#endif
...
@@ -1282,36 +1297,31 @@ void Game::PlaySoundEffect(int sound) {
...
@@ -1282,36 +1297,31 @@ void Game::PlaySoundEffect(int sound) {
engineSound
->
setSoundVolume
(
gameConf
.
sound_volume
);
engineSound
->
setSoundVolume
(
gameConf
.
sound_volume
);
}
}
void
Game
::
PlayMusic
(
char
*
song
,
bool
loop
)
{
void
Game
::
PlayMusic
(
char
*
song
,
bool
loop
)
{
if
(
mainGame
->
chkEnableMusic
->
isChecked
())
{
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
())
if
(
!
engineMusic
->
isCurrentlyPlaying
(
song
))
{
return
;
engineMusic
->
stopAllSounds
();
if
(
!
engineMusic
->
isCurrentlyPlaying
(
song
))
{
engineMusic
->
play2D
(
song
,
loop
);
engineMusic
->
stopAllSounds
(
);
engineMusic
->
setSoundVolume
(
gameConf
.
music_volum
e
);
soundBGM
=
engineMusic
->
play2D
(
song
,
loop
,
false
,
tru
e
);
}
engineMusic
->
setSoundVolume
(
gameConf
.
music_volume
);
}
}
}
}
void
Game
::
PlayBGM
()
{
void
Game
::
PlayBGM
(
int
scene
)
{
if
(
mainGame
->
chkEnableMusic
->
isChecked
())
{
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
())
static
bool
is_playing
=
false
;
return
;
static
char
strBuffer
[
1024
];
if
(
!
mainGame
->
chkMusicMode
->
isChecked
())
if
(
is_playing
&&
!
engineMusic
->
isCurrentlyPlaying
(
strBuffer
))
scene
=
BGM_ALL
;
is_playing
=
false
;
char
BGMName
[
1024
];
if
(
!
is_playing
)
{
if
(
scene
!=
bgm_scene
||
(
soundBGM
&&
soundBGM
->
isFinished
()))
{
int
count
=
BGMList
.
size
();
int
count
=
BGMList
[
scene
].
size
();
if
(
count
<=
0
)
if
(
count
<=
0
)
return
;
return
;
int
bgm
=
(
gameConf
.
music_mode
>=
0
)
?
0
:
rand
()
%
count
;
bgm_scene
=
scene
;
auto
name
=
BGMList
[
bgm
].
c_str
();
int
bgm
=
rand
()
%
count
;
wchar_t
fname
[
256
];
auto
name
=
BGMList
[
scene
][
bgm
].
c_str
();
myswprintf
(
fname
,
L"./sound/BGM/%ls"
,
name
);
wchar_t
fname
[
1024
];
BufferIO
::
EncodeUTF8
(
fname
,
strBuffer
);
myswprintf
(
fname
,
L"./sound/BGM/%ls"
,
name
);
}
BufferIO
::
EncodeUTF8
(
fname
,
BGMName
);
if
(
!
engineMusic
->
isCurrentlyPlaying
(
strBuffer
))
{
PlayMusic
(
BGMName
,
false
);
engineMusic
->
stopAllSounds
();
engineMusic
->
play2D
(
strBuffer
,
true
);
engineMusic
->
setSoundVolume
(
gameConf
.
music_volume
);
is_playing
=
true
;
}
}
}
}
}
void
Game
::
ShowCardInfo
(
int
code
)
{
void
Game
::
ShowCardInfo
(
int
code
)
{
...
...
gframe/game.h
View file @
fe3a2554
...
@@ -96,6 +96,7 @@ public:
...
@@ -96,6 +96,7 @@ public:
void
RefreshReplay
();
void
RefreshReplay
();
void
RefreshSingleplay
();
void
RefreshSingleplay
();
void
RefreshBGMList
();
void
RefreshBGMList
();
void
RefershBGMDir
(
std
::
wstring
path
,
int
scene
);
void
DrawSelectionLine
(
irr
::
video
::
S3DVertex
*
vec
,
bool
strip
,
int
width
,
float
*
cv
);
void
DrawSelectionLine
(
irr
::
video
::
S3DVertex
*
vec
,
bool
strip
,
int
width
,
float
*
cv
);
void
DrawBackGround
();
void
DrawBackGround
();
void
DrawLinkedZones
(
ClientCard
*
pcard
);
void
DrawLinkedZones
(
ClientCard
*
pcard
);
...
@@ -122,7 +123,7 @@ public:
...
@@ -122,7 +123,7 @@ public:
void
CloseDuelWindow
();
void
CloseDuelWindow
();
void
PlaySoundEffect
(
int
sound
);
void
PlaySoundEffect
(
int
sound
);
void
PlayMusic
(
char
*
song
,
bool
loop
);
void
PlayMusic
(
char
*
song
,
bool
loop
);
void
PlayBGM
();
void
PlayBGM
(
int
mode
);
int
LocalPlayer
(
int
player
);
int
LocalPlayer
(
int
player
);
const
wchar_t
*
LocalName
(
int
local_player
);
const
wchar_t
*
LocalName
(
int
local_player
);
...
@@ -149,7 +150,7 @@ public:
...
@@ -149,7 +150,7 @@ public:
std
::
list
<
FadingUnit
>
fadingList
;
std
::
list
<
FadingUnit
>
fadingList
;
std
::
vector
<
int
>
logParam
;
std
::
vector
<
int
>
logParam
;
std
::
wstring
chatMsg
[
8
];
std
::
wstring
chatMsg
[
8
];
std
::
vector
<
std
::
wstring
>
BGMList
;
std
::
vector
<
std
::
wstring
>
BGMList
[
8
]
;
int
hideChatTimer
;
int
hideChatTimer
;
bool
hideChat
;
bool
hideChat
;
...
@@ -181,6 +182,8 @@ public:
...
@@ -181,6 +182,8 @@ public:
bool
is_building
;
bool
is_building
;
bool
is_siding
;
bool
is_siding
;
int
bgm_scene
;
ClientField
dField
;
ClientField
dField
;
DeckBuilder
deckBuilder
;
DeckBuilder
deckBuilder
;
MenuHandler
menuHandler
;
MenuHandler
menuHandler
;
...
@@ -440,6 +443,7 @@ public:
...
@@ -440,6 +443,7 @@ public:
//soundEngine
//soundEngine
irrklang
::
ISoundEngine
*
engineSound
;
irrklang
::
ISoundEngine
*
engineSound
;
irrklang
::
ISoundEngine
*
engineMusic
;
irrklang
::
ISoundEngine
*
engineMusic
;
irrklang
::
ISound
*
soundBGM
;
};
};
extern
Game
*
mainGame
;
extern
Game
*
mainGame
;
...
@@ -613,5 +617,14 @@ extern Game* mainGame;
...
@@ -613,5 +617,14 @@ extern Game* mainGame;
#define SOUND_PLAYER_ENTER 307
#define SOUND_PLAYER_ENTER 307
#define SOUND_CHAT 308
#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
#define DEFAULT_DUEL_RULE 4
#define DEFAULT_DUEL_RULE 4
#endif // GAME_H
#endif // GAME_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