Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
AudDlg.cpp
Go to the documentation of this file.
1
/* Project Starshatter 4.5
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: Stars.exe
6
FILE: AudDlg.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Main Menu Dialog Active Window class
13
*/
14
15
#include "
MemDebug.h
"
16
#include "
AudDlg.h
"
17
#include "
MenuScreen.h
"
18
#include "
Starshatter.h
"
19
#include "
AudioConfig.h
"
20
21
#include "
DataLoader.h
"
22
#include "
Button.h
"
23
#include "
ListBox.h
"
24
#include "
Slider.h
"
25
#include "
Video.h
"
26
#include "
Keyboard.h
"
27
#include "
MachineInfo.h
"
28
29
// +--------------------------------------------------------------------+
30
// DECLARE MAPPING FUNCTIONS:
31
32
DEF_MAP_CLIENT
(
AudDlg
, OnApply);
33
DEF_MAP_CLIENT
(
AudDlg
, OnCancel);
34
DEF_MAP_CLIENT
(
AudDlg
, OnAudio);
35
DEF_MAP_CLIENT
(
AudDlg
, OnVideo);
36
DEF_MAP_CLIENT
(
AudDlg
, OnOptions);
37
DEF_MAP_CLIENT
(
AudDlg
, OnControls);
38
DEF_MAP_CLIENT
(
AudDlg
, OnMod);
39
40
// +--------------------------------------------------------------------+
41
42
AudDlg::AudDlg
(
Screen
* s,
FormDef
& def,
BaseScreen
* mgr)
43
:
FormWindow
(s, 0, 0, s->Width(), s->Height()), manager(mgr),
44
apply(0), cancel(0), vid_btn(0), aud_btn(0), ctl_btn(0), opt_btn(0), mod_btn(0),
45
closed(true)
46
{
47
Init
(def);
48
}
49
50
AudDlg::~AudDlg
()
51
{
52
}
53
54
// +--------------------------------------------------------------------+
55
56
void
57
AudDlg::RegisterControls
()
58
{
59
if
(
apply
)
60
return
;
61
62
efx_volume_slider
= (
Slider
*)
FindControl
(201);
63
gui_volume_slider
= (
Slider
*)
FindControl
(202);
64
wrn_volume_slider
= (
Slider
*)
FindControl
(203);
65
vox_volume_slider
= (
Slider
*)
FindControl
(204);
66
67
menu_music_slider
= (
Slider
*)
FindControl
(205);
68
game_music_slider
= (
Slider
*)
FindControl
(206);
69
70
apply
= (
Button
*)
FindControl
(1);
71
REGISTER_CLIENT
(
EID_CLICK
,
apply
,
AudDlg
,
OnApply
);
72
73
cancel
= (
Button
*)
FindControl
(2);
74
REGISTER_CLIENT
(
EID_CLICK
,
cancel
,
AudDlg
,
OnCancel
);
75
76
vid_btn
= (
Button
*)
FindControl
(901);
77
REGISTER_CLIENT
(
EID_CLICK
,
vid_btn
,
AudDlg
,
OnVideo
);
78
79
aud_btn
= (
Button
*)
FindControl
(902);
80
REGISTER_CLIENT
(
EID_CLICK
,
aud_btn
,
AudDlg
,
OnAudio
);
81
82
ctl_btn
= (
Button
*)
FindControl
(903);
83
REGISTER_CLIENT
(
EID_CLICK
,
ctl_btn
,
AudDlg
,
OnControls
);
84
85
opt_btn
= (
Button
*)
FindControl
(904);
86
REGISTER_CLIENT
(
EID_CLICK
,
opt_btn
,
AudDlg
,
OnOptions
);
87
88
mod_btn
= (
Button
*)
FindControl
(905);
89
if
(
mod_btn
) {
90
REGISTER_CLIENT
(
EID_CLICK
,
mod_btn
,
AudDlg
,
OnMod
);
91
}
92
}
93
94
// +--------------------------------------------------------------------+
95
96
void
97
AudDlg::Show
()
98
{
99
FormWindow::Show
();
100
101
if
(
closed
&&
AudioConfig::GetInstance
()) {
102
AudioConfig
* audio =
AudioConfig::GetInstance
();
103
104
if
(
efx_volume_slider
)
105
efx_volume_slider
->
SetValue
(audio->
GetEfxVolume
());
106
107
if
(
gui_volume_slider
)
108
gui_volume_slider
->
SetValue
(audio->
GetGuiVolume
());
109
110
if
(
wrn_volume_slider
)
111
wrn_volume_slider
->
SetValue
(audio->
GetWrnVolume
());
112
113
if
(
vox_volume_slider
)
114
vox_volume_slider
->
SetValue
(audio->
GetVoxVolume
());
115
116
if
(
menu_music_slider
)
117
menu_music_slider
->
SetValue
(audio->
GetMenuMusic
());
118
119
if
(
game_music_slider
)
120
game_music_slider
->
SetValue
(audio->
GetGameMusic
());
121
}
122
123
if
(
vid_btn
)
vid_btn
->
SetButtonState
(0);
124
if
(
aud_btn
)
aud_btn
->
SetButtonState
(1);
125
if
(
ctl_btn
)
ctl_btn
->
SetButtonState
(0);
126
if
(
opt_btn
)
opt_btn
->
SetButtonState
(0);
127
if
(
mod_btn
)
mod_btn
->
SetButtonState
(0);
128
129
closed
=
false
;
130
}
131
132
// +--------------------------------------------------------------------+
133
134
void
135
AudDlg::ExecFrame
()
136
{
137
if
(
Keyboard::KeyDown
(VK_RETURN)) {
138
OnApply
(0);
139
}
140
}
141
142
// +--------------------------------------------------------------------+
143
144
void
AudDlg::OnAudio
(
AWEvent
* event) {
manager
->
ShowAudDlg
(); }
145
void
AudDlg::OnVideo
(
AWEvent
* event) {
manager
->
ShowVidDlg
(); }
146
void
AudDlg::OnOptions
(
AWEvent
* event) {
manager
->
ShowOptDlg
(); }
147
void
AudDlg::OnControls
(
AWEvent
* event) {
manager
->
ShowCtlDlg
(); }
148
void
AudDlg::OnMod
(
AWEvent
* event) {
manager
->
ShowModDlg
(); }
149
150
// +--------------------------------------------------------------------+
151
152
void
153
AudDlg::OnApply
(
AWEvent
* event)
154
{
155
if
(
manager
)
156
manager
->
ApplyOptions
();
157
}
158
159
void
160
AudDlg::OnCancel
(
AWEvent
* event)
161
{
162
manager
->
CancelOptions
();
163
}
164
165
// +--------------------------------------------------------------------+
166
167
void
168
AudDlg::Apply
()
169
{
170
if
(!
closed
&&
AudioConfig::GetInstance
()) {
171
AudioConfig
* audio =
AudioConfig::GetInstance
();
172
173
if
(
efx_volume_slider
)
174
audio->
SetEfxVolume
(
efx_volume_slider
->
GetValue
());
175
176
if
(
gui_volume_slider
)
177
audio->
SetGuiVolume
(
gui_volume_slider
->
GetValue
());
178
179
if
(
wrn_volume_slider
)
180
audio->
SetWrnVolume
(
wrn_volume_slider
->
GetValue
());
181
182
if
(
vox_volume_slider
)
183
audio->
SetVoxVolume
(
vox_volume_slider
->
GetValue
());
184
185
if
(
menu_music_slider
)
186
audio->
SetMenuMusic
(
menu_music_slider
->
GetValue
());
187
188
if
(
game_music_slider
)
189
audio->
SetGameMusic
(
game_music_slider
->
GetValue
());
190
191
audio->
Save
();
192
}
193
194
closed
=
true
;
195
}
196
197
void
198
AudDlg::Cancel
()
199
{
200
closed
=
true
;
201
}
Stars45
AudDlg.cpp
Generated on Thu May 31 2012 16:31:00 for Starshatter_Open by
1.8.1