Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-2pick
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-2pick
Commits
1b49dd79
Commit
1b49dd79
authored
Jul 10, 2017
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update bgm
parent
ff5ae2ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
41 deletions
+64
-41
gframe/game.cpp
gframe/game.cpp
+49
-39
gframe/game.h
gframe/game.h
+15
-2
No files found.
gframe/game.cpp
View file @
1b49dd79
...
...
@@ -44,6 +44,7 @@ bool Game::Initialize() {
ignore_chain
=
false
;
chain_when_avail
=
false
;
is_building
=
false
;
bgm_scene
=
-
1
;
memset
(
&
dInfo
,
0
,
sizeof
(
DuelInfo
));
memset
(
chatTiming
,
0
,
sizeof
(
chatTiming
));
deckManager
.
LoadLFList
();
...
...
@@ -665,15 +666,15 @@ void Game::MainLoop() {
gMutex
.
Lock
();
if
(
dInfo
.
isStarted
)
{
if
(
mainGame
->
showcardcode
==
1
||
mainGame
->
showcardcode
==
3
)
Play
Music
(
"./sound/duelwin.mp3"
,
true
);
Play
BGM
(
BGM_WIN
);
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
)
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
)
Play
Music
(
"./sound/song-advantage.mp3"
,
true
);
Play
BGM
(
BGM_ADVANTAGE
);
else
PlayBGM
();
PlayBGM
(
BGM_DUEL
);
DrawBackImage
(
imageManager
.
tBackGround
);
DrawBackGround
();
DrawCards
();
...
...
@@ -682,11 +683,11 @@ void Game::MainLoop() {
driver
->
setMaterial
(
irr
::
video
::
IdentityMaterial
);
driver
->
clearZBuffer
();
}
else
if
(
is_building
)
{
Play
Music
(
"./sound/deck.mp3"
,
true
);
Play
BGM
(
BGM_DECK
);
DrawBackImage
(
imageManager
.
tBackGround_deck
);
DrawDeckBd
();
}
else
{
Play
Music
(
"./sound/menu.mp3"
,
true
);
Play
BGM
(
BGM_MENU
);
DrawBackImage
(
imageManager
.
tBackGround_menu
);
}
DrawGUI
();
...
...
@@ -932,14 +933,28 @@ void Game::RefreshSingleplay() {
#endif
}
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
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
)
return
;
do
{
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
))
BGMList
.
push_back
(
fdataw
.
cFileName
);
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
))
{
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
...
...
@@ -953,7 +968,7 @@ void Game::RefreshBGMList() {
continue
;
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
BGMList
.
push_back
(
fdataw
.
cFileN
ame
);
BGMList
[
BGM_ALL
].
push_back
(
wn
ame
);
}
closedir
(
dir
);
#endif
...
...
@@ -1262,36 +1277,31 @@ void Game::PlaySoundEffect(int sound) {
engineSound
->
setSoundVolume
(
gameConf
.
sound_volume
);
}
void
Game
::
PlayMusic
(
char
*
song
,
bool
loop
)
{
if
(
mainGame
->
chkEnableMusic
->
isChecked
())
{
if
(
!
engineMusic
->
isCurrentlyPlaying
(
song
))
{
engineMusic
->
stopAllSounds
();
engineMusic
->
play2D
(
song
,
loop
);
engineMusic
->
setSoundVolume
(
gameConf
.
music_volum
e
);
}
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
())
return
;
if
(
!
engineMusic
->
isCurrentlyPlaying
(
song
))
{
engineMusic
->
stopAllSounds
(
);
soundBGM
=
engineMusic
->
play2D
(
song
,
loop
,
false
,
tru
e
);
engineMusic
->
setSoundVolume
(
gameConf
.
music_volume
);
}
}
void
Game
::
PlayBGM
()
{
if
(
mainGame
->
chkEnableMusic
->
isChecked
())
{
static
bool
is_playing
=
false
;
static
char
strBuffer
[
1024
];
if
(
is_playing
&&
!
engineMusic
->
isCurrentlyPlaying
(
strBuffer
))
is_playing
=
false
;
if
(
!
is_playing
)
{
int
count
=
BGMList
.
size
();
if
(
count
<=
0
)
return
;
int
bgm
=
(
gameConf
.
music_mode
>=
0
)
?
0
:
rand
()
%
count
;
auto
name
=
BGMList
[
bgm
].
c_str
();
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./sound/BGM/%ls"
,
name
);
BufferIO
::
EncodeUTF8
(
fname
,
strBuffer
);
}
if
(
!
engineMusic
->
isCurrentlyPlaying
(
strBuffer
))
{
engineMusic
->
stopAllSounds
();
engineMusic
->
play2D
(
strBuffer
,
true
);
engineMusic
->
setSoundVolume
(
gameConf
.
music_volume
);
is_playing
=
true
;
}
void
Game
::
PlayBGM
(
int
scene
)
{
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
);
}
}
void
Game
::
ShowCardInfo
(
int
code
)
{
...
...
gframe/game.h
View file @
1b49dd79
...
...
@@ -96,6 +96,7 @@ public:
void
RefreshReplay
();
void
RefreshSingleplay
();
void
RefreshBGMList
();
void
RefershBGMDir
(
std
::
wstring
path
,
int
scene
);
void
DrawSelectionLine
(
irr
::
video
::
S3DVertex
*
vec
,
bool
strip
,
int
width
,
float
*
cv
);
void
DrawBackGround
();
void
DrawLinkedZones
(
ClientCard
*
pcard
);
...
...
@@ -122,7 +123,7 @@ public:
void
CloseDuelWindow
();
void
PlaySoundEffect
(
int
sound
);
void
PlayMusic
(
char
*
song
,
bool
loop
);
void
PlayBGM
();
void
PlayBGM
(
int
mode
);
int
LocalPlayer
(
int
player
);
const
wchar_t
*
LocalName
(
int
local_player
);
...
...
@@ -149,7 +150,7 @@ public:
std
::
list
<
FadingUnit
>
fadingList
;
std
::
vector
<
int
>
logParam
;
std
::
wstring
chatMsg
[
8
];
std
::
vector
<
std
::
wstring
>
BGMList
;
std
::
vector
<
std
::
wstring
>
BGMList
[
8
]
;
int
hideChatTimer
;
bool
hideChat
;
...
...
@@ -181,6 +182,8 @@ public:
bool
is_building
;
bool
is_siding
;
int
bgm_scene
;
ClientField
dField
;
DeckBuilder
deckBuilder
;
MenuHandler
menuHandler
;
...
...
@@ -440,6 +443,7 @@ public:
//soundEngine
irrklang
::
ISoundEngine
*
engineSound
;
irrklang
::
ISoundEngine
*
engineMusic
;
irrklang
::
ISound
*
soundBGM
;
};
extern
Game
*
mainGame
;
...
...
@@ -613,5 +617,14 @@ extern Game* mainGame;
#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
#define DEFAULT_DUEL_RULE 4
#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