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
5370fb9a
Commit
5370fb9a
authored
Dec 15, 2017
by
mercury233
Committed by
nanahira
Dec 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mg_sound_1
parent
03d50421
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
382 additions
and
351 deletions
+382
-351
gframe/client_field.cpp
gframe/client_field.cpp
+3
-2
gframe/config.h
gframe/config.h
+0
-6
gframe/deck_con.cpp
gframe/deck_con.cpp
+12
-11
gframe/duelclient.cpp
gframe/duelclient.cpp
+44
-43
gframe/event_handler.cpp
gframe/event_handler.cpp
+30
-29
gframe/game.cpp
gframe/game.cpp
+19
-240
gframe/game.h
gframe/game.h
+0
-15
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+3
-2
gframe/replay_mode.cpp
gframe/replay_mode.cpp
+2
-1
gframe/single_mode.cpp
gframe/single_mode.cpp
+3
-2
gframe/sound_manager.cpp
gframe/sound_manager.cpp
+232
-0
gframe/sound_manager.h
gframe/sound_manager.h
+34
-0
No files found.
gframe/client_field.cpp
View file @
5370fb9a
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include "duelclient.h"
#include "duelclient.h"
#include "data_manager.h"
#include "data_manager.h"
#include "image_manager.h"
#include "image_manager.h"
#include "sound_manager.h"
#include "game.h"
#include "game.h"
#include "materials.h"
#include "materials.h"
#include "../ocgcore/field.h"
#include "../ocgcore/field.h"
...
@@ -1038,7 +1039,7 @@ bool ClientField::ShowSelectSum(bool panelmode) {
...
@@ -1038,7 +1039,7 @@ bool ClientField::ShowSelectSum(bool panelmode) {
BufferIO
::
CopyWStrRef
(
dataManager
.
GetSysString
(
210
),
pwbuf
,
256
);
BufferIO
::
CopyWStrRef
(
dataManager
.
GetSysString
(
210
),
pwbuf
,
256
);
mainGame
->
stQMessage
->
setText
(
wbuf
);
mainGame
->
stQMessage
->
setText
(
wbuf
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PlaySoundEffect
(
SOUND_QUESTION
);
soundManager
.
PlaySoundEffect
(
SOUND_QUESTION
);
}
}
}
else
{
}
else
{
select_ready
=
false
;
select_ready
=
false
;
...
@@ -1060,7 +1061,7 @@ bool ClientField::ShowSelectSum(bool panelmode) {
...
@@ -1060,7 +1061,7 @@ bool ClientField::ShowSelectSum(bool panelmode) {
BufferIO
::
CopyWStrRef
(
dataManager
.
GetSysString
(
210
),
pwbuf
,
256
);
BufferIO
::
CopyWStrRef
(
dataManager
.
GetSysString
(
210
),
pwbuf
,
256
);
mainGame
->
stQMessage
->
setText
(
wbuf
);
mainGame
->
stQMessage
->
setText
(
wbuf
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PlaySoundEffect
(
SOUND_QUESTION
);
soundManager
.
PlaySoundEffect
(
SOUND_QUESTION
);
}
}
}
else
}
else
select_ready
=
false
;
select_ready
=
false
;
...
...
gframe/config.h
View file @
5370fb9a
...
@@ -48,12 +48,6 @@ inline int _wtoi(const wchar_t * s) {
...
@@ -48,12 +48,6 @@ inline int _wtoi(const wchar_t * s) {
#endif
#endif
#include <irrlicht.h>
#include <irrlicht.h>
#ifdef YGOPRO_USE_IRRKLANG
#include <irrKlang.h>
#ifdef YGOPRO_USE_IKPMP3
#include "../ikpMP3/ikpMP3.h"
#endif
#endif
#ifdef __APPLE__
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glu.h>
...
...
gframe/deck_con.cpp
View file @
5370fb9a
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include "data_manager.h"
#include "data_manager.h"
#include "deck_manager.h"
#include "deck_manager.h"
#include "image_manager.h"
#include "image_manager.h"
#include "sound_manager.h"
#include "game.h"
#include "game.h"
#include "duelclient.h"
#include "duelclient.h"
#include <algorithm>
#include <algorithm>
...
@@ -121,13 +122,13 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -121,13 +122,13 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break
;
break
;
switch
(
event
.
GUIEvent
.
EventType
)
{
switch
(
event
.
GUIEvent
.
EventType
)
{
case
irr
:
:
gui
::
EGET_BUTTON_CLICKED
:
{
case
irr
:
:
gui
::
EGET_BUTTON_CLICKED
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
switch
(
id
)
{
switch
(
id
)
{
case
BUTTON_CLEAR_DECK
:
{
case
BUTTON_CLEAR_DECK
:
{
mainGame
->
gMutex
.
Lock
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
textFont
,
(
wchar_t
*
)
dataManager
.
GetSysString
(
1339
));
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
textFont
,
(
wchar_t
*
)
dataManager
.
GetSysString
(
1339
));
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PlaySoundEffect
(
SOUND_QUESTION
);
soundManager
.
PlaySoundEffect
(
SOUND_QUESTION
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
gMutex
.
Unlock
();
prev_operation
=
id
;
prev_operation
=
id
;
break
;
break
;
...
@@ -184,7 +185,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -184,7 +185,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
myswprintf
(
textBuffer
,
L"%ls
\n
%ls"
,
mainGame
->
cbDBDecks
->
getItem
(
sel
),
dataManager
.
GetSysString
(
1337
));
myswprintf
(
textBuffer
,
L"%ls
\n
%ls"
,
mainGame
->
cbDBDecks
->
getItem
(
sel
),
dataManager
.
GetSysString
(
1337
));
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
textFont
,
(
wchar_t
*
)
textBuffer
);
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
textFont
,
(
wchar_t
*
)
textBuffer
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PlaySoundEffect
(
SOUND_QUESTION
);
soundManager
.
PlaySoundEffect
(
SOUND_QUESTION
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
gMutex
.
Unlock
();
prev_operation
=
id
;
prev_operation
=
id
;
break
;
break
;
...
@@ -194,7 +195,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -194,7 +195,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame
->
gMutex
.
Lock
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
textFont
,
(
wchar_t
*
)
dataManager
.
GetSysString
(
1356
));
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
textFont
,
(
wchar_t
*
)
dataManager
.
GetSysString
(
1356
));
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PlaySoundEffect
(
SOUND_QUESTION
);
soundManager
.
PlaySoundEffect
(
SOUND_QUESTION
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
gMutex
.
Unlock
();
prev_operation
=
id
;
prev_operation
=
id
;
break
;
break
;
...
@@ -358,7 +359,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -358,7 +359,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame
->
gMutex
.
Lock
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
textFont
,
(
wchar_t
*
)
dataManager
.
GetSysString
(
1356
));
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
textFont
,
(
wchar_t
*
)
dataManager
.
GetSysString
(
1356
));
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PlaySoundEffect
(
SOUND_QUESTION
);
soundManager
.
PlaySoundEffect
(
SOUND_QUESTION
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
gMutex
.
Unlock
();
prev_operation
=
id
;
prev_operation
=
id
;
break
;
break
;
...
@@ -516,7 +517,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -516,7 +517,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
is_starting_dragging
=
false
;
is_starting_dragging
=
false
;
if
(
!
is_draging
)
if
(
!
is_draging
)
break
;
break
;
mainGame
->
PlaySoundEffect
(
SOUND_CARD_DROP
);
soundManager
.
PlaySoundEffect
(
SOUND_CARD_DROP
);
bool
pushed
=
false
;
bool
pushed
=
false
;
if
(
hovered_pos
==
1
)
if
(
hovered_pos
==
1
)
pushed
=
push_main
(
draging_pointer
,
hovered_seq
);
pushed
=
push_main
(
draging_pointer
,
hovered_seq
);
...
@@ -546,7 +547,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -546,7 +547,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
auto
pointer
=
dataManager
.
GetCodePointer
(
hovered_code
);
auto
pointer
=
dataManager
.
GetCodePointer
(
hovered_code
);
if
(
pointer
==
dataManager
.
_datas
.
end
())
if
(
pointer
==
dataManager
.
_datas
.
end
())
break
;
break
;
mainGame
->
PlaySoundEffect
(
SOUND_CARD_DROP
);
soundManager
.
PlaySoundEffect
(
SOUND_CARD_DROP
);
if
(
hovered_pos
==
1
)
{
if
(
hovered_pos
==
1
)
{
if
(
push_side
(
pointer
))
if
(
push_side
(
pointer
))
pop_main
(
hovered_seq
);
pop_main
(
hovered_seq
);
...
@@ -564,7 +565,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -564,7 +565,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if
(
!
is_draging
)
{
if
(
!
is_draging
)
{
if
(
hovered_pos
==
0
||
hovered_seq
==
-
1
)
if
(
hovered_pos
==
0
||
hovered_seq
==
-
1
)
break
;
break
;
mainGame
->
PlaySoundEffect
(
SOUND_CARD_DROP
);
soundManager
.
PlaySoundEffect
(
SOUND_CARD_DROP
);
if
(
hovered_pos
==
1
)
{
if
(
hovered_pos
==
1
)
{
pop_main
(
hovered_seq
);
pop_main
(
hovered_seq
);
}
else
if
(
hovered_pos
==
2
)
{
}
else
if
(
hovered_pos
==
2
)
{
...
@@ -581,7 +582,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -581,7 +582,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
push_side
(
pointer
);
push_side
(
pointer
);
}
}
}
else
{
}
else
{
mainGame
->
PlaySoundEffect
(
SOUND_CARD_PICK
);
soundManager
.
PlaySoundEffect
(
SOUND_CARD_PICK
);
if
(
click_pos
==
1
)
{
if
(
click_pos
==
1
)
{
push_side
(
draging_pointer
);
push_side
(
draging_pointer
);
}
else
if
(
click_pos
==
2
)
{
}
else
if
(
click_pos
==
2
)
{
...
@@ -608,7 +609,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -608,7 +609,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
auto
pointer
=
dataManager
.
GetCodePointer
(
hovered_code
);
auto
pointer
=
dataManager
.
GetCodePointer
(
hovered_code
);
if
(
!
check_limit
(
pointer
))
if
(
!
check_limit
(
pointer
))
break
;
break
;
mainGame
->
PlaySoundEffect
(
SOUND_CARD_PICK
);
soundManager
.
PlaySoundEffect
(
SOUND_CARD_PICK
);
if
(
hovered_pos
==
1
)
{
if
(
hovered_pos
==
1
)
{
if
(
!
push_main
(
pointer
))
if
(
!
push_main
(
pointer
))
push_side
(
pointer
);
push_side
(
pointer
);
...
@@ -627,7 +628,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -627,7 +628,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case
irr
:
:
EMIE_MOUSE_MOVED
:
{
case
irr
:
:
EMIE_MOUSE_MOVED
:
{
if
(
is_starting_dragging
)
{
if
(
is_starting_dragging
)
{
is_draging
=
true
;
is_draging
=
true
;
mainGame
->
PlaySoundEffect
(
SOUND_CARD_PICK
);
soundManager
.
PlaySoundEffect
(
SOUND_CARD_PICK
);
if
(
hovered_pos
==
1
)
if
(
hovered_pos
==
1
)
pop_main
(
hovered_seq
);
pop_main
(
hovered_seq
);
else
if
(
hovered_pos
==
2
)
else
if
(
hovered_pos
==
2
)
...
...
gframe/duelclient.cpp
View file @
5370fb9a
This diff is collapsed.
Click to expand it.
gframe/event_handler.cpp
View file @
5370fb9a
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include "duelclient.h"
#include "duelclient.h"
#include "data_manager.h"
#include "data_manager.h"
#include "image_manager.h"
#include "image_manager.h"
#include "sound_manager.h"
#include "replay_mode.h"
#include "replay_mode.h"
#include "single_mode.h"
#include "single_mode.h"
#include "materials.h"
#include "materials.h"
...
@@ -40,7 +41,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -40,7 +41,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
}
case
BUTTON_FIRST
:
case
BUTTON_FIRST
:
case
BUTTON_SECOND
:
{
case
BUTTON_SECOND
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
mainGame
->
HideElement
(
mainGame
->
wFTSelect
);
mainGame
->
HideElement
(
mainGame
->
wFTSelect
);
CTOS_TPResult
cstr
;
CTOS_TPResult
cstr
;
cstr
.
res
=
BUTTON_SECOND
-
id
;
cstr
.
res
=
BUTTON_SECOND
-
id
;
...
@@ -50,7 +51,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -50,7 +51,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case
BUTTON_REPLAY_START
:
{
case
BUTTON_REPLAY_START
:
{
if
(
!
mainGame
->
dInfo
.
isReplay
)
if
(
!
mainGame
->
dInfo
.
isReplay
)
break
;
break
;
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
mainGame
->
btnReplayStart
->
setVisible
(
false
);
mainGame
->
btnReplayStart
->
setVisible
(
false
);
mainGame
->
btnReplayPause
->
setVisible
(
true
);
mainGame
->
btnReplayPause
->
setVisible
(
true
);
mainGame
->
btnReplayStep
->
setVisible
(
false
);
mainGame
->
btnReplayStep
->
setVisible
(
false
);
...
@@ -61,7 +62,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -61,7 +62,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case
BUTTON_REPLAY_PAUSE
:
{
case
BUTTON_REPLAY_PAUSE
:
{
if
(
!
mainGame
->
dInfo
.
isReplay
)
if
(
!
mainGame
->
dInfo
.
isReplay
)
break
;
break
;
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
mainGame
->
btnReplayStart
->
setVisible
(
true
);
mainGame
->
btnReplayStart
->
setVisible
(
true
);
mainGame
->
btnReplayPause
->
setVisible
(
false
);
mainGame
->
btnReplayPause
->
setVisible
(
false
);
mainGame
->
btnReplayStep
->
setVisible
(
true
);
mainGame
->
btnReplayStep
->
setVisible
(
true
);
...
@@ -72,19 +73,19 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -72,19 +73,19 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case
BUTTON_REPLAY_STEP
:
{
case
BUTTON_REPLAY_STEP
:
{
if
(
!
mainGame
->
dInfo
.
isReplay
)
if
(
!
mainGame
->
dInfo
.
isReplay
)
break
;
break
;
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
ReplayMode
::
Pause
(
false
,
true
);
ReplayMode
::
Pause
(
false
,
true
);
break
;
break
;
}
}
case
BUTTON_REPLAY_EXIT
:
{
case
BUTTON_REPLAY_EXIT
:
{
if
(
!
mainGame
->
dInfo
.
isReplay
)
if
(
!
mainGame
->
dInfo
.
isReplay
)
break
;
break
;
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
ReplayMode
::
StopReplay
();
ReplayMode
::
StopReplay
();
break
;
break
;
}
}
case
BUTTON_REPLAY_SWAP
:
{
case
BUTTON_REPLAY_SWAP
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
if
(
mainGame
->
dInfo
.
isReplay
)
if
(
mainGame
->
dInfo
.
isReplay
)
ReplayMode
::
SwapField
();
ReplayMode
::
SwapField
();
else
if
(
mainGame
->
dInfo
.
player_type
==
7
)
else
if
(
mainGame
->
dInfo
.
player_type
==
7
)
...
@@ -94,28 +95,28 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -94,28 +95,28 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case
BUTTON_REPLAY_UNDO
:
{
case
BUTTON_REPLAY_UNDO
:
{
if
(
!
mainGame
->
dInfo
.
isReplay
)
if
(
!
mainGame
->
dInfo
.
isReplay
)
break
;
break
;
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
ReplayMode
::
Undo
();
ReplayMode
::
Undo
();
break
;
break
;
}
}
case
BUTTON_REPLAY_SAVE
:
{
case
BUTTON_REPLAY_SAVE
:
{
if
(
mainGame
->
ebRSName
->
getText
()[
0
]
==
0
)
if
(
mainGame
->
ebRSName
->
getText
()[
0
]
==
0
)
break
;
break
;
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
mainGame
->
actionParam
=
1
;
mainGame
->
actionParam
=
1
;
mainGame
->
HideElement
(
mainGame
->
wReplaySave
);
mainGame
->
HideElement
(
mainGame
->
wReplaySave
);
mainGame
->
replaySignal
.
Set
();
mainGame
->
replaySignal
.
Set
();
break
;
break
;
}
}
case
BUTTON_REPLAY_CANCEL
:
{
case
BUTTON_REPLAY_CANCEL
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
mainGame
->
actionParam
=
0
;
mainGame
->
actionParam
=
0
;
mainGame
->
HideElement
(
mainGame
->
wReplaySave
);
mainGame
->
HideElement
(
mainGame
->
wReplaySave
);
mainGame
->
replaySignal
.
Set
();
mainGame
->
replaySignal
.
Set
();
break
;
break
;
}
}
case
BUTTON_LEAVE_GAME
:
{
case
BUTTON_LEAVE_GAME
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
if
(
mainGame
->
dInfo
.
isSingleMode
)
{
if
(
mainGame
->
dInfo
.
isSingleMode
)
{
mainGame
->
singleSignal
.
SetNoWait
(
true
);
mainGame
->
singleSignal
.
SetNoWait
(
true
);
SingleMode
::
StopPlay
(
false
);
SingleMode
::
StopPlay
(
false
);
...
@@ -148,7 +149,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -148,7 +149,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_CHAIN_IGNORE
:
{
case
BUTTON_CHAIN_IGNORE
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
mainGame
->
ignore_chain
=
mainGame
->
btnChainIgnore
->
isPressed
();
mainGame
->
ignore_chain
=
mainGame
->
btnChainIgnore
->
isPressed
();
mainGame
->
always_chain
=
false
;
mainGame
->
always_chain
=
false
;
mainGame
->
chain_when_avail
=
false
;
mainGame
->
chain_when_avail
=
false
;
...
@@ -156,7 +157,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -156,7 +157,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_CHAIN_ALWAYS
:
{
case
BUTTON_CHAIN_ALWAYS
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
mainGame
->
always_chain
=
mainGame
->
btnChainAlways
->
isPressed
();
mainGame
->
always_chain
=
mainGame
->
btnChainAlways
->
isPressed
();
mainGame
->
ignore_chain
=
false
;
mainGame
->
ignore_chain
=
false
;
mainGame
->
chain_when_avail
=
false
;
mainGame
->
chain_when_avail
=
false
;
...
@@ -164,7 +165,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -164,7 +165,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_CHAIN_WHENAVAIL
:
{
case
BUTTON_CHAIN_WHENAVAIL
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
mainGame
->
chain_when_avail
=
mainGame
->
btnChainWhenAvail
->
isPressed
();
mainGame
->
chain_when_avail
=
mainGame
->
btnChainWhenAvail
->
isPressed
();
mainGame
->
always_chain
=
false
;
mainGame
->
always_chain
=
false
;
mainGame
->
ignore_chain
=
false
;
mainGame
->
ignore_chain
=
false
;
...
@@ -172,7 +173,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -172,7 +173,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_CANCEL_OR_FINISH
:
{
case
BUTTON_CANCEL_OR_FINISH
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
switch
(
mainGame
->
dInfo
.
curMsg
)
{
switch
(
mainGame
->
dInfo
.
curMsg
)
{
case
MSG_WAITING
:
{
case
MSG_WAITING
:
{
if
(
mainGame
->
wCardSelect
->
isVisible
())
{
if
(
mainGame
->
wCardSelect
->
isVisible
())
{
...
@@ -282,7 +283,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -282,7 +283,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
}
else
{
else
{
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PlaySoundEffect
(
SOUND_QUESTION
);
soundManager
.
PlaySoundEffect
(
SOUND_QUESTION
);
ShowCancelOrFinishButton
(
0
);
ShowCancelOrFinishButton
(
0
);
}
}
if
(
mainGame
->
wOptions
->
isVisible
())
{
if
(
mainGame
->
wOptions
->
isVisible
())
{
...
@@ -304,13 +305,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -304,13 +305,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_MSG_OK
:
{
case
BUTTON_MSG_OK
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
mainGame
->
HideElement
(
mainGame
->
wMessage
);
mainGame
->
HideElement
(
mainGame
->
wMessage
);
mainGame
->
actionSignal
.
Set
();
mainGame
->
actionSignal
.
Set
();
break
;
break
;
}
}
case
BUTTON_YES
:
{
case
BUTTON_YES
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
switch
(
mainGame
->
dInfo
.
curMsg
)
{
switch
(
mainGame
->
dInfo
.
curMsg
)
{
case
MSG_SELECT_YESNO
:
case
MSG_SELECT_YESNO
:
case
MSG_SELECT_EFFECTYN
:
{
case
MSG_SELECT_EFFECTYN
:
{
...
@@ -344,7 +345,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -344,7 +345,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_NO
:
{
case
BUTTON_NO
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
switch
(
mainGame
->
dInfo
.
curMsg
)
{
switch
(
mainGame
->
dInfo
.
curMsg
)
{
case
MSG_SELECT_YESNO
:
case
MSG_SELECT_YESNO
:
case
MSG_SELECT_EFFECTYN
:
{
case
MSG_SELECT_EFFECTYN
:
{
...
@@ -397,7 +398,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -397,7 +398,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_OPTION_PREV
:
{
case
BUTTON_OPTION_PREV
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
selected_option
--
;
selected_option
--
;
mainGame
->
btnOptionn
->
setVisible
(
true
);
mainGame
->
btnOptionn
->
setVisible
(
true
);
if
(
selected_option
==
0
)
if
(
selected_option
==
0
)
...
@@ -406,7 +407,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -406,7 +407,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_OPTION_NEXT
:
{
case
BUTTON_OPTION_NEXT
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
selected_option
++
;
selected_option
++
;
mainGame
->
btnOptionp
->
setVisible
(
true
);
mainGame
->
btnOptionp
->
setVisible
(
true
);
if
(
selected_option
==
select_options
.
size
()
-
1
)
if
(
selected_option
==
select_options
.
size
()
-
1
)
...
@@ -415,7 +416,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -415,7 +416,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_OPTION_OK
:
{
case
BUTTON_OPTION_OK
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
if
(
mainGame
->
dInfo
.
curMsg
==
MSG_SELECT_OPTION
)
{
if
(
mainGame
->
dInfo
.
curMsg
==
MSG_SELECT_OPTION
)
{
DuelClient
::
SetResponseI
(
selected_option
);
DuelClient
::
SetResponseI
(
selected_option
);
}
else
{
}
else
{
...
@@ -433,13 +434,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -433,13 +434,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_ANNUMBER_OK
:
{
case
BUTTON_ANNUMBER_OK
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
DuelClient
::
SetResponseI
(
mainGame
->
cbANNumber
->
getSelected
());
DuelClient
::
SetResponseI
(
mainGame
->
cbANNumber
->
getSelected
());
mainGame
->
HideElement
(
mainGame
->
wANNumber
,
true
);
mainGame
->
HideElement
(
mainGame
->
wANNumber
,
true
);
break
;
break
;
}
}
case
BUTTON_ANCARD_OK
:
{
case
BUTTON_ANCARD_OK
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
int
sel
=
mainGame
->
lstANCard
->
getSelected
();
int
sel
=
mainGame
->
lstANCard
->
getSelected
();
if
(
sel
==
-
1
)
if
(
sel
==
-
1
)
break
;
break
;
...
@@ -1456,7 +1457,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -1456,7 +1457,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
BufferIO
::
CopyWStrRef
(
dataManager
.
GetSysString
(
210
),
pwbuf
,
256
);
BufferIO
::
CopyWStrRef
(
dataManager
.
GetSysString
(
210
),
pwbuf
,
256
);
mainGame
->
stQMessage
->
setText
(
wbuf
);
mainGame
->
stQMessage
->
setText
(
wbuf
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PlaySoundEffect
(
SOUND_QUESTION
);
soundManager
.
PlaySoundEffect
(
SOUND_QUESTION
);
}
}
}
}
}
else
{
}
else
{
...
@@ -1632,7 +1633,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -1632,7 +1633,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame
->
HideElement
(
mainGame
->
wQuery
,
true
);
mainGame
->
HideElement
(
mainGame
->
wQuery
,
true
);
}
else
{
}
else
{
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PlaySoundEffect
(
SOUND_QUESTION
);
soundManager
.
PlaySoundEffect
(
SOUND_QUESTION
);
ShowCancelOrFinishButton
(
0
);
ShowCancelOrFinishButton
(
0
);
}
}
if
(
mainGame
->
wOptions
->
isVisible
())
{
if
(
mainGame
->
wOptions
->
isVisible
())
{
...
@@ -1985,7 +1986,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
...
@@ -1985,7 +1986,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
case
irr
:
:
gui
::
EGET_BUTTON_CLICKED
:
{
case
irr
:
:
gui
::
EGET_BUTTON_CLICKED
:
{
switch
(
id
)
{
switch
(
id
)
{
case
BUTTON_CLEAR_LOG
:
{
case
BUTTON_CLEAR_LOG
:
{
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
mainGame
->
lstLog
->
clear
();
mainGame
->
lstLog
->
clear
();
mainGame
->
logParam
.
clear
();
mainGame
->
logParam
.
clear
();
return
true
;
return
true
;
...
@@ -2004,7 +2005,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
...
@@ -2004,7 +2005,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
#ifdef YGOPRO_USE_IRRKLANG
#ifdef YGOPRO_USE_IRRKLANG
case
CHECKBOX_ENABLE_MUSIC
:
{
case
CHECKBOX_ENABLE_MUSIC
:
{
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
())
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
())
mainGame
->
engineMusic
->
stopAllSounds
();
soundManager
.
StopBGM
();
return
true
;
return
true
;
break
;
break
;
}
}
...
@@ -2050,8 +2051,8 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
...
@@ -2050,8 +2051,8 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
case
SCROLL_VOLUME
:
{
case
SCROLL_VOLUME
:
{
mainGame
->
gameConf
.
sound_volume
=
(
double
)
mainGame
->
scrSoundVolume
->
getPos
()
/
100
;
mainGame
->
gameConf
.
sound_volume
=
(
double
)
mainGame
->
scrSoundVolume
->
getPos
()
/
100
;
mainGame
->
gameConf
.
music_volume
=
(
double
)
mainGame
->
scrMusicVolume
->
getPos
()
/
100
;
mainGame
->
gameConf
.
music_volume
=
(
double
)
mainGame
->
scrMusicVolume
->
getPos
()
/
100
;
mainGame
->
engineSound
->
s
etSoundVolume
(
mainGame
->
gameConf
.
sound_volume
);
soundManager
.
S
etSoundVolume
(
mainGame
->
gameConf
.
sound_volume
);
mainGame
->
engineMusic
->
setSound
Volume
(
mainGame
->
gameConf
.
music_volume
);
soundManager
.
SetMusic
Volume
(
mainGame
->
gameConf
.
music_volume
);
break
;
break
;
}
}
#endif
#endif
...
...
gframe/game.cpp
View file @
5370fb9a
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include "image_manager.h"
#include "image_manager.h"
#include "data_manager.h"
#include "data_manager.h"
#include "deck_manager.h"
#include "deck_manager.h"
#include "sound_manager.h"
#include "replay.h"
#include "replay.h"
#include "materials.h"
#include "materials.h"
#include "duelclient.h"
#include "duelclient.h"
...
@@ -44,7 +45,6 @@ bool Game::Initialize() {
...
@@ -44,7 +45,6 @@ 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
();
...
@@ -655,32 +655,21 @@ bool Game::Initialize() {
...
@@ -655,32 +655,21 @@ bool Game::Initialize() {
stTip
->
setTextAlignment
(
irr
::
gui
::
EGUIA_CENTER
,
irr
::
gui
::
EGUIA_CENTER
);
stTip
->
setTextAlignment
(
irr
::
gui
::
EGUIA_CENTER
,
irr
::
gui
::
EGUIA_CENTER
);
stTip
->
setVisible
(
false
);
stTip
->
setVisible
(
false
);
device
->
setEventReceiver
(
&
menuHandler
);
device
->
setEventReceiver
(
&
menuHandler
);
RefreshBGMList
();
LoadConfig
();
LoadConfig
();
env
->
getSkin
()
->
setFont
(
guiFont
);
if
(
!
soundManager
.
Init
())
{
env
->
setFocus
(
wMainMenu
);
for
(
u32
i
=
0
;
i
<
EGDC_COUNT
;
++
i
)
{
SColor
col
=
env
->
getSkin
()
->
getColor
((
EGUI_DEFAULT_COLOR
)
i
);
col
.
setAlpha
(
224
);
env
->
getSkin
()
->
setColor
((
EGUI_DEFAULT_COLOR
)
i
,
col
);
}
#ifdef YGOPRO_USE_IRRKLANG
engineSound
=
irrklang
::
createIrrKlangDevice
();
engineMusic
=
irrklang
::
createIrrKlangDevice
();
if
(
!
engineSound
||
!
engineMusic
)
{
chkEnableSound
->
setChecked
(
false
);
chkEnableSound
->
setChecked
(
false
);
chkEnableSound
->
setEnabled
(
false
);
chkEnableSound
->
setEnabled
(
false
);
chkEnableMusic
->
setChecked
(
false
);
chkEnableMusic
->
setChecked
(
false
);
chkEnableMusic
->
setEnabled
(
false
);
chkEnableMusic
->
setEnabled
(
false
);
chkMusicMode
->
setEnabled
(
false
);
chkMusicMode
->
setEnabled
(
false
);
}
}
#ifdef YGOPRO_USE_IKPMP3
env
->
getSkin
()
->
setFont
(
guiFont
);
else
{
env
->
setFocus
(
wMainMenu
);
irrklang
::
ikpMP3Init
(
engineSound
);
for
(
u32
i
=
0
;
i
<
EGDC_COUNT
;
++
i
)
{
irrklang
::
ikpMP3Init
(
engineMusic
);
SColor
col
=
env
->
getSkin
()
->
getColor
((
EGUI_DEFAULT_COLOR
)
i
);
col
.
setAlpha
(
224
);
env
->
getSkin
()
->
setColor
((
EGUI_DEFAULT_COLOR
)
i
,
col
);
}
}
#endif
#endif
hideChat
=
false
;
hideChat
=
false
;
hideChatTimer
=
0
;
hideChatTimer
=
0
;
return
true
;
return
true
;
...
@@ -711,15 +700,15 @@ void Game::MainLoop() {
...
@@ -711,15 +700,15 @@ void Game::MainLoop() {
gMutex
.
Lock
();
gMutex
.
Lock
();
if
(
dInfo
.
isStarted
)
{
if
(
dInfo
.
isStarted
)
{
if
(
mainGame
->
dInfo
.
isFinished
&&
mainGame
->
showcardcode
==
1
)
if
(
mainGame
->
dInfo
.
isFinished
&&
mainGame
->
showcardcode
==
1
)
PlayBGM
(
BGM_WIN
);
soundManager
.
PlayBGM
(
BGM_WIN
);
else
if
(
mainGame
->
dInfo
.
isFinished
&&
(
mainGame
->
showcardcode
==
2
||
mainGame
->
showcardcode
==
3
))
else
if
(
mainGame
->
dInfo
.
isFinished
&&
(
mainGame
->
showcardcode
==
2
||
mainGame
->
showcardcode
==
3
))
PlayBGM
(
BGM_LOSE
);
soundManager
.
PlayBGM
(
BGM_LOSE
);
else
if
(
mainGame
->
dInfo
.
lp
[
0
]
>
0
&&
mainGame
->
dInfo
.
lp
[
0
]
<=
mainGame
->
dInfo
.
lp
[
1
]
/
2
)
else
if
(
mainGame
->
dInfo
.
lp
[
0
]
>
0
&&
mainGame
->
dInfo
.
lp
[
0
]
<=
mainGame
->
dInfo
.
lp
[
1
]
/
2
)
PlayBGM
(
BGM_DISADVANTAGE
);
soundManager
.
PlayBGM
(
BGM_DISADVANTAGE
);
else
if
(
mainGame
->
dInfo
.
lp
[
0
]
>
0
&&
mainGame
->
dInfo
.
lp
[
0
]
>=
mainGame
->
dInfo
.
lp
[
1
]
*
2
)
else
if
(
mainGame
->
dInfo
.
lp
[
0
]
>
0
&&
mainGame
->
dInfo
.
lp
[
0
]
>=
mainGame
->
dInfo
.
lp
[
1
]
*
2
)
PlayBGM
(
BGM_ADVANTAGE
);
soundManager
.
PlayBGM
(
BGM_ADVANTAGE
);
else
else
PlayBGM
(
BGM_DUEL
);
soundManager
.
PlayBGM
(
BGM_DUEL
);
DrawBackImage
(
imageManager
.
tBackGround
);
DrawBackImage
(
imageManager
.
tBackGround
);
DrawBackGround
();
DrawBackGround
();
DrawCards
();
DrawCards
();
...
@@ -728,11 +717,11 @@ void Game::MainLoop() {
...
@@ -728,11 +717,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
)
{
PlayBGM
(
BGM_DECK
);
soundManager
.
PlayBGM
(
BGM_DECK
);
DrawBackImage
(
imageManager
.
tBackGround_deck
);
DrawBackImage
(
imageManager
.
tBackGround_deck
);
DrawDeckBd
();
DrawDeckBd
();
}
else
{
}
else
{
PlayBGM
(
BGM_MENU
);
soundManager
.
PlayBGM
(
BGM_MENU
);
DrawBackImage
(
imageManager
.
tBackGround_menu
);
DrawBackImage
(
imageManager
.
tBackGround_menu
);
}
}
DrawGUI
();
DrawGUI
();
...
@@ -789,10 +778,6 @@ void Game::MainLoop() {
...
@@ -789,10 +778,6 @@ void Game::MainLoop() {
usleep
(
500000
);
usleep
(
500000
);
#endif
#endif
SaveConfig
();
SaveConfig
();
#ifdef YGOPRO_USE_IRRKLANG
if
(
engineMusic
)
engineMusic
->
drop
();
#endif
// device->drop();
// device->drop();
}
}
void
Game
::
BuildProjectionMatrix
(
irr
::
core
::
matrix4
&
mProjection
,
f32
left
,
f32
right
,
f32
bottom
,
f32
top
,
f32
znear
,
f32
zfar
)
{
void
Game
::
BuildProjectionMatrix
(
irr
::
core
::
matrix4
&
mProjection
,
f32
left
,
f32
right
,
f32
bottom
,
f32
top
,
f32
znear
,
f32
zfar
)
{
...
@@ -980,49 +965,6 @@ void Game::RefreshSingleplay() {
...
@@ -980,49 +965,6 @@ void Game::RefreshSingleplay() {
closedir
(
dir
);
closedir
(
dir
);
#endif
#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 YGOPRO_USE_IRRKLANG
#ifdef _WIN32
WIN32_FIND_DATAW
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
))
{
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
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./sound/BGM/*.mp3"
))
==
NULL
)
return
;
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
if
(
len
<
5
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".mp3"
)
!=
0
)
continue
;
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
BGMList
[
BGM_ALL
].
push_back
(
wname
);
}
closedir
(
dir
);
#endif
#endif
}
void
Game
::
RefreshBot
()
{
void
Game
::
RefreshBot
()
{
if
(
!
gameConf
.
enable_bot_mode
)
if
(
!
gameConf
.
enable_bot_mode
)
return
;
return
;
...
@@ -1256,169 +1198,6 @@ void Game::SaveConfig() {
...
@@ -1256,169 +1198,6 @@ void Game::SaveConfig() {
fprintf
(
fp
,
"enable_bot_mode = %d
\n
"
,
gameConf
.
enable_bot_mode
);
fprintf
(
fp
,
"enable_bot_mode = %d
\n
"
,
gameConf
.
enable_bot_mode
);
fclose
(
fp
);
fclose
(
fp
);
}
}
void
Game
::
PlaySoundEffect
(
int
sound
)
{
#ifdef YGOPRO_USE_IRRKLANG
if
(
!
mainGame
->
chkEnableSound
->
isChecked
())
return
;
switch
(
sound
)
{
case
SOUND_SUMMON
:
{
engineSound
->
play2D
(
"./sound/summon.wav"
);
break
;
}
case
SOUND_SPECIAL_SUMMON
:
{
engineSound
->
play2D
(
"./sound/specialsummon.wav"
);
break
;
}
case
SOUND_ACTIVATE
:
{
engineSound
->
play2D
(
"./sound/activate.wav"
);
break
;
}
case
SOUND_SET
:
{
engineSound
->
play2D
(
"./sound/set.wav"
);
break
;
}
case
SOUND_FILP
:
{
engineSound
->
play2D
(
"./sound/flip.wav"
);
break
;
}
case
SOUND_REVEAL
:
{
engineSound
->
play2D
(
"./sound/reveal.wav"
);
break
;
}
case
SOUND_EQUIP
:
{
engineSound
->
play2D
(
"./sound/equip.wav"
);
break
;
}
case
SOUND_DESTROYED
:
{
engineSound
->
play2D
(
"./sound/destroyed.wav"
);
break
;
}
case
SOUND_BANISHED
:
{
engineSound
->
play2D
(
"./sound/banished.wav"
);
break
;
}
case
SOUND_TOKEN
:
{
engineSound
->
play2D
(
"./sound/token.wav"
);
break
;
}
case
SOUND_ATTACK
:
{
engineSound
->
play2D
(
"./sound/attack.wav"
);
break
;
}
case
SOUND_DIRECT_ATTACK
:
{
engineSound
->
play2D
(
"./sound/directattack.wav"
);
break
;
}
case
SOUND_DRAW
:
{
engineSound
->
play2D
(
"./sound/draw.wav"
);
break
;
}
case
SOUND_SHUFFLE
:
{
engineSound
->
play2D
(
"./sound/shuffle.wav"
);
break
;
}
case
SOUND_DAMAGE
:
{
engineSound
->
play2D
(
"./sound/damage.wav"
);
break
;
}
case
SOUND_RECOVER
:
{
engineSound
->
play2D
(
"./sound/gainlp.wav"
);
break
;
}
case
SOUND_COUNTER_ADD
:
{
engineSound
->
play2D
(
"./sound/addcounter.wav"
);
break
;
}
case
SOUND_COUNTER_REMOVE
:
{
engineSound
->
play2D
(
"./sound/removecounter.wav"
);
break
;
}
case
SOUND_COIN
:
{
engineSound
->
play2D
(
"./sound/coinflip.wav"
);
break
;
}
case
SOUND_DICE
:
{
engineSound
->
play2D
(
"./sound/diceroll.wav"
);
break
;
}
case
SOUND_NEXT_TURN
:
{
engineSound
->
play2D
(
"./sound/nextturn.wav"
);
break
;
}
case
SOUND_PHASE
:
{
engineSound
->
play2D
(
"./sound/phase.wav"
);
break
;
}
case
SOUND_MENU
:
{
engineSound
->
play2D
(
"./sound/menu.wav"
);
break
;
}
case
SOUND_BUTTON
:
{
engineSound
->
play2D
(
"./sound/button.wav"
);
break
;
}
case
SOUND_INFO
:
{
engineSound
->
play2D
(
"./sound/info.wav"
);
break
;
}
case
SOUND_QUESTION
:
{
engineSound
->
play2D
(
"./sound/question.wav"
);
break
;
}
case
SOUND_CARD_PICK
:
{
engineSound
->
play2D
(
"./sound/cardpick.wav"
);
break
;
}
case
SOUND_CARD_DROP
:
{
engineSound
->
play2D
(
"./sound/carddrop.wav"
);
break
;
}
case
SOUND_PLAYER_ENTER
:
{
engineSound
->
play2D
(
"./sound/playerenter.wav"
);
break
;
}
case
SOUND_CHAT
:
{
engineSound
->
play2D
(
"./sound/chatmessage.wav"
);
break
;
}
default:
break
;
}
engineSound
->
setSoundVolume
(
gameConf
.
sound_volume
);
#endif
}
void
Game
::
PlayMusic
(
char
*
song
,
bool
loop
)
{
#ifdef YGOPRO_USE_IRRKLANG
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
())
return
;
if
(
!
engineMusic
->
isCurrentlyPlaying
(
song
))
{
engineMusic
->
stopAllSounds
();
soundBGM
=
engineMusic
->
play2D
(
song
,
loop
,
false
,
true
);
engineMusic
->
setSoundVolume
(
gameConf
.
music_volume
);
}
#endif
}
void
Game
::
PlayBGM
(
int
scene
)
{
#ifdef YGOPRO_USE_IRRKLANG
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
);
}
#endif
}
void
Game
::
ShowCardInfo
(
int
code
)
{
void
Game
::
ShowCardInfo
(
int
code
)
{
CardData
cd
;
CardData
cd
;
wchar_t
formatBuffer
[
256
];
wchar_t
formatBuffer
[
256
];
...
@@ -1519,17 +1298,17 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
...
@@ -1519,17 +1298,17 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
chatMsg
[
0
].
append
(
L": "
);
chatMsg
[
0
].
append
(
L": "
);
break
;
break
;
case
1
:
//from client
case
1
:
//from client
mainGame
->
PlaySoundEffect
(
SOUND_CHAT
);
soundManager
.
PlaySoundEffect
(
SOUND_CHAT
);
chatMsg
[
0
].
append
(
dInfo
.
clientname
);
chatMsg
[
0
].
append
(
dInfo
.
clientname
);
chatMsg
[
0
].
append
(
L": "
);
chatMsg
[
0
].
append
(
L": "
);
break
;
break
;
case
2
:
//host tag
case
2
:
//host tag
mainGame
->
PlaySoundEffect
(
SOUND_CHAT
);
soundManager
.
PlaySoundEffect
(
SOUND_CHAT
);
chatMsg
[
0
].
append
(
dInfo
.
hostname_tag
);
chatMsg
[
0
].
append
(
dInfo
.
hostname_tag
);
chatMsg
[
0
].
append
(
L": "
);
chatMsg
[
0
].
append
(
L": "
);
break
;
break
;
case
3
:
//client tag
case
3
:
//client tag
mainGame
->
PlaySoundEffect
(
SOUND_CHAT
);
soundManager
.
PlaySoundEffect
(
SOUND_CHAT
);
chatMsg
[
0
].
append
(
dInfo
.
clientname_tag
);
chatMsg
[
0
].
append
(
dInfo
.
clientname_tag
);
chatMsg
[
0
].
append
(
L": "
);
chatMsg
[
0
].
append
(
L": "
);
break
;
break
;
...
@@ -1538,7 +1317,7 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
...
@@ -1538,7 +1317,7 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
chatMsg
[
0
].
append
(
L": "
);
chatMsg
[
0
].
append
(
L": "
);
break
;
break
;
case
8
:
//system custom message, no prefix.
case
8
:
//system custom message, no prefix.
mainGame
->
PlaySoundEffect
(
SOUND_CHAT
);
soundManager
.
PlaySoundEffect
(
SOUND_CHAT
);
chatMsg
[
0
].
append
(
L"[System]: "
);
chatMsg
[
0
].
append
(
L"[System]: "
);
break
;
break
;
case
9
:
//error message
case
9
:
//error message
...
...
gframe/game.h
View file @
5370fb9a
...
@@ -107,8 +107,6 @@ public:
...
@@ -107,8 +107,6 @@ public:
void
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
RefreshReplay
();
void
RefreshReplay
();
void
RefreshSingleplay
();
void
RefreshSingleplay
();
void
RefreshBGMList
();
void
RefershBGMDir
(
std
::
wstring
path
,
int
scene
);
void
RefreshBot
();
void
RefreshBot
();
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
();
...
@@ -134,9 +132,6 @@ public:
...
@@ -134,9 +132,6 @@ public:
void
AddDebugMsg
(
char
*
msgbuf
);
void
AddDebugMsg
(
char
*
msgbuf
);
void
ClearTextures
();
void
ClearTextures
();
void
CloseDuelWindow
();
void
CloseDuelWindow
();
void
PlaySoundEffect
(
int
sound
);
void
PlayMusic
(
char
*
song
,
bool
loop
);
void
PlayBGM
(
int
scene
);
int
LocalPlayer
(
int
player
);
int
LocalPlayer
(
int
player
);
const
wchar_t
*
LocalName
(
int
local_player
);
const
wchar_t
*
LocalName
(
int
local_player
);
...
@@ -163,7 +158,6 @@ public:
...
@@ -163,7 +158,6 @@ 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
[
8
];
std
::
vector
<
BotInfo
>
botInfo
;
std
::
vector
<
BotInfo
>
botInfo
;
int
hideChatTimer
;
int
hideChatTimer
;
...
@@ -196,8 +190,6 @@ public:
...
@@ -196,8 +190,6 @@ 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
;
...
@@ -468,13 +460,6 @@ public:
...
@@ -468,13 +460,6 @@ public:
irr
::
gui
::
IGUIButton
*
btnChainWhenAvail
;
irr
::
gui
::
IGUIButton
*
btnChainWhenAvail
;
//cancel or finish
//cancel or finish
irr
::
gui
::
IGUIButton
*
btnCancelOrFinish
;
irr
::
gui
::
IGUIButton
*
btnCancelOrFinish
;
//soundEngine
#ifdef YGOPRO_USE_IRRKLANG
irrklang
::
ISoundEngine
*
engineSound
;
irrklang
::
ISoundEngine
*
engineMusic
;
irrklang
::
ISound
*
soundBGM
;
#endif
};
};
extern
Game
*
mainGame
;
extern
Game
*
mainGame
;
...
...
gframe/menu_handler.cpp
View file @
5370fb9a
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include "replay_mode.h"
#include "replay_mode.h"
#include "single_mode.h"
#include "single_mode.h"
#include "image_manager.h"
#include "image_manager.h"
#include "sound_manager.h"
#include "game.h"
#include "game.h"
namespace
ygo
{
namespace
ygo
{
...
@@ -33,9 +34,9 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -33,9 +34,9 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
switch
(
event
.
GUIEvent
.
EventType
)
{
switch
(
event
.
GUIEvent
.
EventType
)
{
case
irr
:
:
gui
::
EGET_BUTTON_CLICKED
:
{
case
irr
:
:
gui
::
EGET_BUTTON_CLICKED
:
{
if
(
id
<
110
)
if
(
id
<
110
)
mainGame
->
PlaySoundEffect
(
SOUND_MENU
);
soundManager
.
PlaySoundEffect
(
SOUND_MENU
);
else
else
mainGame
->
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
switch
(
id
)
{
switch
(
id
)
{
case
BUTTON_MODE_EXIT
:
{
case
BUTTON_MODE_EXIT
:
{
mainGame
->
device
->
closeDevice
();
mainGame
->
device
->
closeDevice
();
...
...
gframe/replay_mode.cpp
View file @
5370fb9a
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include "duelclient.h"
#include "duelclient.h"
#include "game.h"
#include "game.h"
#include "single_mode.h"
#include "single_mode.h"
#include "sound_manager.h"
#include "../ocgcore/duel.h"
#include "../ocgcore/duel.h"
#include "../ocgcore/field.h"
#include "../ocgcore/field.h"
#include "../ocgcore/mtrandom.h"
#include "../ocgcore/mtrandom.h"
...
@@ -313,7 +314,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
...
@@ -313,7 +314,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
mainGame
->
gMutex
.
Lock
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
stMessage
->
setText
(
L"Error occurs."
);
mainGame
->
stMessage
->
setText
(
L"Error occurs."
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
PlaySoundEffect
(
SOUND_INFO
);
soundManager
.
PlaySoundEffect
(
SOUND_INFO
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
gMutex
.
Unlock
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Wait
();
mainGame
->
actionSignal
.
Wait
();
...
...
gframe/single_mode.cpp
View file @
5370fb9a
#include "single_mode.h"
#include "single_mode.h"
#include "duelclient.h"
#include "duelclient.h"
#include "game.h"
#include "game.h"
#include "sound_manager.h"
#include "../ocgcore/duel.h"
#include "../ocgcore/duel.h"
#include "../ocgcore/field.h"
#include "../ocgcore/field.h"
#include "../ocgcore/mtrandom.h"
#include "../ocgcore/mtrandom.h"
...
@@ -179,7 +180,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
...
@@ -179,7 +180,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
mainGame
->
gMutex
.
Lock
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
stMessage
->
setText
(
L"Error occurs."
);
mainGame
->
stMessage
->
setText
(
L"Error occurs."
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
PlaySoundEffect
(
SOUND_INFO
);
soundManager
.
PlaySoundEffect
(
SOUND_INFO
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
gMutex
.
Unlock
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Wait
();
mainGame
->
actionSignal
.
Wait
();
...
@@ -786,7 +787,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
...
@@ -786,7 +787,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
mainGame
->
gMutex
.
Lock
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
SetStaticText
(
mainGame
->
stMessage
,
310
,
mainGame
->
textFont
,
msg
);
mainGame
->
SetStaticText
(
mainGame
->
stMessage
,
310
,
mainGame
->
textFont
,
msg
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
PlaySoundEffect
(
SOUND_INFO
);
soundManager
.
PlaySoundEffect
(
SOUND_INFO
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
gMutex
.
Unlock
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Wait
();
mainGame
->
actionSignal
.
Wait
();
...
...
gframe/sound_manager.cpp
0 → 100644
View file @
5370fb9a
#include "sound_manager.h"
#ifdef IRRKLANG_STATIC
#include "../ikpmp3/ikpMP3.h"
#endif
namespace
ygo
{
SoundManager
soundManager
;
bool
SoundManager
::
Init
()
{
bgm_scene
=
-
1
;
RefreshBGMList
();
engineSound
=
irrklang
::
createIrrKlangDevice
();
engineMusic
=
irrklang
::
createIrrKlangDevice
();
if
(
!
engineSound
||
!
engineMusic
)
{
return
false
;
}
else
{
#ifdef IRRKLANG_STATIC
irrklang
::
ikpMP3Init
(
engineSound
);
irrklang
::
ikpMP3Init
(
engineMusic
);
#endif
return
true
;
}
}
void
SoundManager
::
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
SoundManager
::
RefershBGMDir
(
std
::
wstring
path
,
int
scene
)
{
#ifdef _WIN32
WIN32_FIND_DATAW
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
))
{
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
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./sound/BGM/*.mp3"
))
==
NULL
)
return
;
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
if
(
len
<
5
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".mp3"
)
!=
0
)
continue
;
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
BGMList
[
BGM_ALL
].
push_back
(
wname
);
}
closedir
(
dir
);
#endif
}
void
SoundManager
::
PlaySoundEffect
(
int
sound
)
{
if
(
!
mainGame
->
chkEnableSound
->
isChecked
())
return
;
switch
(
sound
)
{
case
SOUND_SUMMON
:
{
engineSound
->
play2D
(
"./sound/summon.wav"
);
break
;
}
case
SOUND_SPECIAL_SUMMON
:
{
engineSound
->
play2D
(
"./sound/specialsummon.wav"
);
break
;
}
case
SOUND_ACTIVATE
:
{
engineSound
->
play2D
(
"./sound/activate.wav"
);
break
;
}
case
SOUND_SET
:
{
engineSound
->
play2D
(
"./sound/set.wav"
);
break
;
}
case
SOUND_FILP
:
{
engineSound
->
play2D
(
"./sound/flip.wav"
);
break
;
}
case
SOUND_REVEAL
:
{
engineSound
->
play2D
(
"./sound/reveal.wav"
);
break
;
}
case
SOUND_EQUIP
:
{
engineSound
->
play2D
(
"./sound/equip.wav"
);
break
;
}
case
SOUND_DESTROYED
:
{
engineSound
->
play2D
(
"./sound/destroyed.wav"
);
break
;
}
case
SOUND_BANISHED
:
{
engineSound
->
play2D
(
"./sound/banished.wav"
);
break
;
}
case
SOUND_TOKEN
:
{
engineSound
->
play2D
(
"./sound/token.wav"
);
break
;
}
case
SOUND_ATTACK
:
{
engineSound
->
play2D
(
"./sound/attack.wav"
);
break
;
}
case
SOUND_DIRECT_ATTACK
:
{
engineSound
->
play2D
(
"./sound/directattack.wav"
);
break
;
}
case
SOUND_DRAW
:
{
engineSound
->
play2D
(
"./sound/draw.wav"
);
break
;
}
case
SOUND_SHUFFLE
:
{
engineSound
->
play2D
(
"./sound/shuffle.wav"
);
break
;
}
case
SOUND_DAMAGE
:
{
engineSound
->
play2D
(
"./sound/damage.wav"
);
break
;
}
case
SOUND_RECOVER
:
{
engineSound
->
play2D
(
"./sound/gainlp.wav"
);
break
;
}
case
SOUND_COUNTER_ADD
:
{
engineSound
->
play2D
(
"./sound/addcounter.wav"
);
break
;
}
case
SOUND_COUNTER_REMOVE
:
{
engineSound
->
play2D
(
"./sound/removecounter.wav"
);
break
;
}
case
SOUND_COIN
:
{
engineSound
->
play2D
(
"./sound/coinflip.wav"
);
break
;
}
case
SOUND_DICE
:
{
engineSound
->
play2D
(
"./sound/diceroll.wav"
);
break
;
}
case
SOUND_NEXT_TURN
:
{
engineSound
->
play2D
(
"./sound/nextturn.wav"
);
break
;
}
case
SOUND_PHASE
:
{
engineSound
->
play2D
(
"./sound/phase.wav"
);
break
;
}
case
SOUND_MENU
:
{
engineSound
->
play2D
(
"./sound/menu.wav"
);
break
;
}
case
SOUND_BUTTON
:
{
engineSound
->
play2D
(
"./sound/button.wav"
);
break
;
}
case
SOUND_INFO
:
{
engineSound
->
play2D
(
"./sound/info.wav"
);
break
;
}
case
SOUND_QUESTION
:
{
engineSound
->
play2D
(
"./sound/question.wav"
);
break
;
}
case
SOUND_CARD_PICK
:
{
engineSound
->
play2D
(
"./sound/cardpick.wav"
);
break
;
}
case
SOUND_CARD_DROP
:
{
engineSound
->
play2D
(
"./sound/carddrop.wav"
);
break
;
}
case
SOUND_PLAYER_ENTER
:
{
engineSound
->
play2D
(
"./sound/playerenter.wav"
);
break
;
}
case
SOUND_CHAT
:
{
engineSound
->
play2D
(
"./sound/chatmessage.wav"
);
break
;
}
default:
break
;
}
engineSound
->
setSoundVolume
(
mainGame
->
gameConf
.
sound_volume
);
}
void
SoundManager
::
PlayMusic
(
char
*
song
,
bool
loop
)
{
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
())
return
;
if
(
!
engineMusic
->
isCurrentlyPlaying
(
song
))
{
engineMusic
->
stopAllSounds
();
soundBGM
=
engineMusic
->
play2D
(
song
,
loop
,
false
,
true
);
engineMusic
->
setSoundVolume
(
mainGame
->
gameConf
.
music_volume
);
}
}
void
SoundManager
::
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
SoundManager
::
StopBGM
()
{
engineMusic
->
stopAllSounds
();
}
void
SoundManager
::
SetSoundVolume
(
double
volume
)
{
engineSound
->
setSoundVolume
(
volume
);
}
void
SoundManager
::
SetMusicVolume
(
double
volume
)
{
engineMusic
->
setSoundVolume
(
volume
);
}
}
gframe/sound_manager.h
0 → 100644
View file @
5370fb9a
#ifndef SOUNDMANAGER_H
#define SOUNDMANAGER_H
#include "config.h"
#include "game.h"
#include <vector>
namespace
ygo
{
class
SoundManager
{
private:
std
::
vector
<
std
::
wstring
>
BGMList
[
8
];
int
bgm_scene
;
irrklang
::
ISoundEngine
*
engineSound
;
irrklang
::
ISoundEngine
*
engineMusic
;
irrklang
::
ISound
*
soundBGM
;
void
RefershBGMDir
(
std
::
wstring
path
,
int
scene
);
public:
bool
Init
();
void
RefreshBGMList
();
void
PlaySoundEffect
(
int
sound
);
void
PlayMusic
(
char
*
song
,
bool
loop
);
void
PlayBGM
(
int
scene
);
void
StopBGM
();
void
SetSoundVolume
(
double
volume
);
void
SetMusicVolume
(
double
volume
);
};
extern
SoundManager
soundManager
;
}
#endif //SOUNDMANAGER_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