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
ffc16757
Commit
ffc16757
authored
Dec 15, 2017
by
mercury233
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sound' into test
parents
cc2fedfc
65f949f8
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
402 additions
and
335 deletions
+402
-335
gframe/client_field.cpp
gframe/client_field.cpp
+0
-2
gframe/config.h
gframe/config.h
+0
-4
gframe/deck_con.cpp
gframe/deck_con.cpp
+8
-11
gframe/drawing.cpp
gframe/drawing.cpp
+2
-0
gframe/duelclient.cpp
gframe/duelclient.cpp
+31
-43
gframe/event_handler.cpp
gframe/event_handler.cpp
+28
-29
gframe/game.cpp
gframe/game.cpp
+24
-228
gframe/game.h
gframe/game.h
+0
-13
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+3
-2
gframe/replay_mode.cpp
gframe/replay_mode.cpp
+0
-1
gframe/single_mode.cpp
gframe/single_mode.cpp
+0
-2
gframe/sound_manager.cpp
gframe/sound_manager.cpp
+264
-0
gframe/sound_manager.h
gframe/sound_manager.h
+42
-0
No files found.
gframe/client_field.cpp
View file @
ffc16757
...
@@ -1018,7 +1018,6 @@ bool ClientField::ShowSelectSum(bool panelmode) {
...
@@ -1018,7 +1018,6 @@ 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
);
}
}
}
else
{
}
else
{
select_ready
=
false
;
select_ready
=
false
;
...
@@ -1040,7 +1039,6 @@ bool ClientField::ShowSelectSum(bool panelmode) {
...
@@ -1040,7 +1039,6 @@ 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
);
}
}
}
else
}
else
select_ready
=
false
;
select_ready
=
false
;
...
...
gframe/config.h
View file @
ffc16757
...
@@ -48,10 +48,6 @@ inline int _wtoi(const wchar_t * s) {
...
@@ -48,10 +48,6 @@ inline int _wtoi(const wchar_t * s) {
#endif
#endif
#include <irrlicht.h>
#include <irrlicht.h>
#include <irrKlang.h>
#ifdef IRRKLANG_STATIC
#include "../ikpmp3/ikpMP3.h"
#endif
#include <GL/gl.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glu.h>
#include "CGUITTFont.h"
#include "CGUITTFont.h"
...
...
gframe/deck_con.cpp
View file @
ffc16757
...
@@ -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,12 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -121,13 +122,12 @@ 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
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
gMutex
.
Unlock
();
prev_operation
=
id
;
prev_operation
=
id
;
break
;
break
;
...
@@ -184,7 +184,6 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -184,7 +184,6 @@ 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
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
gMutex
.
Unlock
();
prev_operation
=
id
;
prev_operation
=
id
;
break
;
break
;
...
@@ -194,7 +193,6 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -194,7 +193,6 @@ 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
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
gMutex
.
Unlock
();
prev_operation
=
id
;
prev_operation
=
id
;
break
;
break
;
...
@@ -358,7 +356,6 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -358,7 +356,6 @@ 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
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
gMutex
.
Unlock
();
prev_operation
=
id
;
prev_operation
=
id
;
break
;
break
;
...
@@ -516,7 +513,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -516,7 +513,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 +543,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -546,7 +543,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 +561,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -564,7 +561,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 +578,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -581,7 +578,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 +605,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -608,7 +605,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 +624,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -627,7 +624,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/drawing.cpp
View file @
ffc16757
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include "materials.h"
#include "materials.h"
#include "image_manager.h"
#include "image_manager.h"
#include "deck_manager.h"
#include "deck_manager.h"
#include "sound_manager.h"
#include "duelclient.h"
#include "duelclient.h"
#include "../ocgcore/field.h"
#include "../ocgcore/field.h"
...
@@ -1008,6 +1009,7 @@ void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) {
...
@@ -1008,6 +1009,7 @@ void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) {
fadingList
.
push_back
(
fu
);
fadingList
.
push_back
(
fu
);
}
}
void
Game
::
PopupElement
(
irr
::
gui
::
IGUIElement
*
element
,
int
hideframe
)
{
void
Game
::
PopupElement
(
irr
::
gui
::
IGUIElement
*
element
,
int
hideframe
)
{
soundManager
.
PlayDialogSound
(
element
);
element
->
getParent
()
->
bringToFront
(
element
);
element
->
getParent
()
->
bringToFront
(
element
);
if
(
!
mainGame
->
is_building
)
if
(
!
mainGame
->
is_building
)
dField
.
panel
=
element
;
dField
.
panel
=
element
;
...
...
gframe/duelclient.cpp
View file @
ffc16757
This diff is collapsed.
Click to expand it.
gframe/event_handler.cpp
View file @
ffc16757
...
@@ -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,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -282,7 +283,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
}
else
{
else
{
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PlaySoundEffect
(
SOUND_QUESTION
);
ShowCancelOrFinishButton
(
0
);
ShowCancelOrFinishButton
(
0
);
}
}
if
(
mainGame
->
wOptions
->
isVisible
())
{
if
(
mainGame
->
wOptions
->
isVisible
())
{
...
@@ -304,13 +304,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -304,13 +304,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 +344,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -344,7 +344,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 +397,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -397,7 +397,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 +406,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -406,7 +406,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 +415,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -415,7 +415,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 +433,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -433,13 +433,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 +1456,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -1456,7 +1456,6 @@ 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
);
}
}
}
}
}
else
{
}
else
{
...
@@ -1632,7 +1631,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -1632,7 +1631,6 @@ 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
);
ShowCancelOrFinishButton
(
0
);
ShowCancelOrFinishButton
(
0
);
}
}
if
(
mainGame
->
wOptions
->
isVisible
())
{
if
(
mainGame
->
wOptions
->
isVisible
())
{
...
@@ -1985,7 +1983,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
...
@@ -1985,7 +1983,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
;
...
@@ -2003,7 +2001,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
...
@@ -2003,7 +2001,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
}
}
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
;
}
}
...
@@ -2047,8 +2045,9 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
...
@@ -2047,8 +2045,9 @@ 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
->
setSoundVolume
(
mainGame
->
gameConf
.
sound_volume
);
soundManager
.
SetSoundVolume
(
mainGame
->
gameConf
.
sound_volume
);
mainGame
->
engineMusic
->
setSoundVolume
(
mainGame
->
gameConf
.
music_volume
);
soundManager
.
SetMusicVolume
(
mainGame
->
gameConf
.
music_volume
);
return
true
;
break
;
break
;
}
}
}
}
...
...
gframe/game.cpp
View file @
ffc16757
...
@@ -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
();
...
@@ -670,30 +670,26 @@ bool Game::Initialize() {
...
@@ -670,30 +670,26 @@ 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
);
}
engineSound
=
irrklang
::
createIrrKlangDevice
();
engineMusic
=
irrklang
::
createIrrKlangDevice
();
if
(
!
engineSound
||
!
engineMusic
)
{
chkEnableSound
->
setChecked
(
false
);
chkEnableSound
->
setChecked
(
false
);
chkEnableSound
->
setEnabled
(
false
);
chkEnableSound
->
setEnabled
(
false
);
chkEnableSound
->
setVisible
(
false
);
chkEnableMusic
->
setChecked
(
false
);
chkEnableMusic
->
setChecked
(
false
);
chkEnableMusic
->
setEnabled
(
false
);
chkEnableMusic
->
setEnabled
(
false
);
chkEnableMusic
->
setVisible
(
false
);
scrSoundVolume
->
setVisible
(
false
);
scrMusicVolume
->
setVisible
(
false
);
chkMusicMode
->
setEnabled
(
false
);
chkMusicMode
->
setEnabled
(
false
);
chkMusicMode
->
setVisible
(
false
);
}
}
#ifdef IRRKLANG_STATIC
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
hideChat
=
false
;
hideChat
=
false
;
hideChatTimer
=
0
;
hideChatTimer
=
0
;
return
true
;
return
true
;
...
@@ -724,15 +720,15 @@ void Game::MainLoop() {
...
@@ -724,15 +720,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
();
...
@@ -741,11 +737,11 @@ void Game::MainLoop() {
...
@@ -741,11 +737,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
();
...
@@ -797,8 +793,6 @@ void Game::MainLoop() {
...
@@ -797,8 +793,6 @@ void Game::MainLoop() {
usleep
(
500000
);
usleep
(
500000
);
#endif
#endif
SaveConfig
();
SaveConfig
();
if
(
engineMusic
)
engineMusic
->
drop
();
// 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
)
{
...
@@ -986,47 +980,6 @@ void Game::RefreshSingleplay() {
...
@@ -986,47 +980,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 _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
Game
::
RefreshBot
()
{
void
Game
::
RefreshBot
()
{
if
(
!
gameConf
.
enable_bot_mode
)
if
(
!
gameConf
.
enable_bot_mode
)
return
;
return
;
...
@@ -1256,163 +1209,6 @@ void Game::SaveConfig() {
...
@@ -1256,163 +1209,6 @@ void Game::SaveConfig() {
fprintf
(
fp
,
"music_mode = %d
\n
"
,
((
mainGame
->
chkMusicMode
->
isChecked
())
?
1
:
0
));
fprintf
(
fp
,
"music_mode = %d
\n
"
,
((
mainGame
->
chkMusicMode
->
isChecked
())
?
1
:
0
));
fclose
(
fp
);
fclose
(
fp
);
}
}
void
Game
::
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
(
gameConf
.
sound_volume
);
}
void
Game
::
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
(
gameConf
.
music_volume
);
}
}
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
)
{
void
Game
::
ShowCardInfo
(
int
code
)
{
CardData
cd
;
CardData
cd
;
wchar_t
formatBuffer
[
256
];
wchar_t
formatBuffer
[
256
];
...
@@ -1504,17 +1300,17 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
...
@@ -1504,17 +1300,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
;
...
@@ -1523,7 +1319,7 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
...
@@ -1523,7 +1319,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 @
ffc16757
...
@@ -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
;
...
@@ -466,11 +458,6 @@ public:
...
@@ -466,11 +458,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
irrklang
::
ISoundEngine
*
engineSound
;
irrklang
::
ISoundEngine
*
engineMusic
;
irrklang
::
ISound
*
soundBGM
;
};
};
extern
Game
*
mainGame
;
extern
Game
*
mainGame
;
...
...
gframe/menu_handler.cpp
View file @
ffc16757
...
@@ -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 @
ffc16757
...
@@ -313,7 +313,6 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
...
@@ -313,7 +313,6 @@ 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
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
gMutex
.
Unlock
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Wait
();
mainGame
->
actionSignal
.
Wait
();
...
...
gframe/single_mode.cpp
View file @
ffc16757
...
@@ -179,7 +179,6 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
...
@@ -179,7 +179,6 @@ 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
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
gMutex
.
Unlock
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Wait
();
mainGame
->
actionSignal
.
Wait
();
...
@@ -786,7 +785,6 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
...
@@ -786,7 +785,6 @@ 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
);
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 @
ffc16757
#include "sound_manager.h"
namespace
ygo
{
SoundManager
soundManager
;
bool
SoundManager
::
Init
()
{
#ifdef YGOPRO_USE_IRRKLANG
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
;
}
#endif // YGOPRO_USE_IRRKLANG
// TODO: Implement other sound engines
return
false
;
}
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
)
{
#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
(
mainGame
->
gameConf
.
sound_volume
);
#endif
}
void
SoundManager
::
PlayDialogSound
(
irr
::
gui
::
IGUIElement
*
element
)
{
if
(
element
==
mainGame
->
wMessage
)
{
PlaySoundEffect
(
SOUND_INFO
);
}
else
if
(
element
==
mainGame
->
wQuery
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
else
if
(
element
==
mainGame
->
wOptions
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
else
if
(
element
==
mainGame
->
wANAttribute
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
else
if
(
element
==
mainGame
->
wANCard
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
else
if
(
element
==
mainGame
->
wANNumber
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
else
if
(
element
==
mainGame
->
wANRace
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
else
if
(
element
==
mainGame
->
wReplaySave
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
}
void
SoundManager
::
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
(
mainGame
->
gameConf
.
music_volume
);
}
#endif
}
void
SoundManager
::
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
SoundManager
::
StopBGM
()
{
#ifdef YGOPRO_USE_IRRKLANG
engineMusic
->
stopAllSounds
();
#endif
}
void
SoundManager
::
SetSoundVolume
(
double
volume
)
{
#ifdef YGOPRO_USE_IRRKLANG
engineSound
->
setSoundVolume
(
volume
);
#endif
}
void
SoundManager
::
SetMusicVolume
(
double
volume
)
{
#ifdef YGOPRO_USE_IRRKLANG
engineMusic
->
setSoundVolume
(
volume
);
#endif
}
}
gframe/sound_manager.h
0 → 100644
View file @
ffc16757
#ifndef SOUNDMANAGER_H
#define SOUNDMANAGER_H
#include "config.h"
#include "game.h"
#ifdef YGOPRO_USE_IRRKLANG
#include <irrKlang.h>
#ifdef IRRKLANG_STATIC
#include "../ikpmp3/ikpMP3.h"
#endif
#endif
namespace
ygo
{
class
SoundManager
{
private:
std
::
vector
<
std
::
wstring
>
BGMList
[
8
];
int
bgm_scene
;
#ifdef YGOPRO_USE_IRRKLANG
irrklang
::
ISoundEngine
*
engineSound
;
irrklang
::
ISoundEngine
*
engineMusic
;
irrklang
::
ISound
*
soundBGM
;
#endif
void
RefershBGMDir
(
std
::
wstring
path
,
int
scene
);
public:
bool
Init
();
void
RefreshBGMList
();
void
PlaySoundEffect
(
int
sound
);
void
PlayDialogSound
(
irr
::
gui
::
IGUIElement
*
element
);
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