From 8898ad9b25fca6afe2374d293a981db02a83d7e9 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Thu, 31 May 2012 14:46:27 +0000 Subject: Committing the documentation to svn to have it accessible online --- Doc/doxygen/html/_audio_config_8cpp_source.html | 501 ++++++++++++++++++++++++ 1 file changed, 501 insertions(+) create mode 100644 Doc/doxygen/html/_audio_config_8cpp_source.html (limited to 'Doc/doxygen/html/_audio_config_8cpp_source.html') diff --git a/Doc/doxygen/html/_audio_config_8cpp_source.html b/Doc/doxygen/html/_audio_config_8cpp_source.html new file mode 100644 index 0000000..e3e5fac --- /dev/null +++ b/Doc/doxygen/html/_audio_config_8cpp_source.html @@ -0,0 +1,501 @@ + + + + + +Starshatter_Open: D:/SRC/StarshatterSVN/Stars45/AudioConfig.cpp Source File + + + + + + + + + + + + + +
+
+ + + + + + +
+
Starshatter_Open +
+
Open source Starshatter engine
+
+
+ + + + + +
+
+ +
+
+
+ +
+ + + + +
+ +
+ +
+
+
AudioConfig.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: AudioConfig.cpp
+
7  AUTHOR: John DiCamillo
+
8 
+
9 
+
10  OVERVIEW
+
11  ========
+
12  Audio Configuration class
+
13 */
+
14 
+
15 #include "MemDebug.h"
+
16 #include "AudioConfig.h"
+
17 
+
18 #include "DataLoader.h"
+
19 #include "ParseUtil.h"
+
20 #include "Button.h"
+
21 #include "Game.h"
+
22 
+
23 // +--------------------------------------------------------------------+
+
24 
+
25 static AudioConfig* audio_config = 0;
+
26 
+
27 // +--------------------------------------------------------------------+
+
28 
+ +
30 : menu_music(90),
+
31 game_music(90),
+
32 efx_volume(90),
+
33 gui_volume(90),
+
34 wrn_volume(90),
+
35 vox_volume(90),
+
36 training(false)
+
37 {
+
38  if (!audio_config)
+
39  audio_config = this;
+
40 }
+
41 
+ +
43 {
+
44  if (audio_config == this)
+
45  audio_config = 0;
+
46 }
+
47 
+
48 // +--------------------------------------------------------------------+
+
49 
+
50 void
+ +
52 {
+
53  audio_config = new(__FILE__,__LINE__) AudioConfig;
+
54  if (audio_config)
+
55  audio_config->Load();
+
56 }
+
57 
+
58 void
+ +
60 {
+
61  delete audio_config;
+
62  audio_config = 0;
+
63 }
+
64 
+ + +
67 {
+
68  return audio_config;
+
69 }
+
70 
+
71 // +--------------------------------------------------------------------+
+
72 
+
73 int
+ +
75 {
+
76  if (audio_config)
+
77  return -50 * (100 - audio_config->menu_music);
+
78 
+
79  return 0;
+
80 }
+
81 
+
82 int
+ +
84 {
+
85  int vol = 0;
+
86 
+
87  if (audio_config) {
+
88  vol = -50 * (100 - audio_config->game_music);
+
89 
+
90  if (audio_config->training)
+
91  vol -= 2000;
+
92  }
+
93 
+
94  return vol;
+
95 }
+
96 
+
97 int
+ +
99 {
+
100  int vol = 0;
+
101 
+
102  if (audio_config) {
+
103  vol = -50 * (100 - audio_config->efx_volume);
+
104 
+
105  if (audio_config->training)
+
106  vol -= 2000;
+
107  }
+
108 
+
109  return vol;
+
110 }
+
111 
+
112 int
+ +
114 {
+
115  if (audio_config)
+
116  return -50 * (100 - audio_config->gui_volume);
+
117 
+
118  return 0;
+
119 }
+
120 
+
121 int
+ +
123 {
+
124  int vol = 0;
+
125 
+
126  if (audio_config) {
+
127  vol = -50 * (100 - audio_config->wrn_volume);
+
128 
+
129  if (audio_config->training)
+
130  vol -= 2000;
+
131  }
+
132 
+
133  return vol;
+
134 }
+
135 
+
136 int
+ +
138 {
+
139  int vol = 0;
+
140 
+
141  if (audio_config) {
+
142  vol = -50 * (100 - audio_config->vox_volume);
+
143 
+
144  if (audio_config->training && vol < -750)
+
145  vol = -750;
+
146  }
+
147 
+
148  return vol;
+
149 }
+
150 
+
151 int
+ +
153 {
+
154  return -5000;
+
155 }
+
156 
+
157 void
+ +
159 {
+
160  if (audio_config)
+
161  audio_config->training = t;
+
162 }
+
163 
+
164 // +--------------------------------------------------------------------+
+
165 
+
166 void
+ +
168 {
+
169  if (v < 0) v = 0;
+
170  else if (v > 100) v = 100;
+
171 
+
172  menu_music = v;
+
173 }
+
174 
+
175 void
+ +
177 {
+
178  if (v < 0) v = 0;
+
179  else if (v > 100) v = 100;
+
180 
+
181  game_music = v;
+
182 }
+
183 
+
184 void
+ +
186 {
+
187  if (v < 0) v = 0;
+
188  else if (v > 100) v = 100;
+
189 
+
190  efx_volume = v;
+
191 }
+
192 
+
193 void
+ +
195 {
+
196  if (v < 0) v = 0;
+
197  else if (v > 100) v = 100;
+
198 
+
199  gui_volume = v;
+
200  Button::SetVolume(-50 * (100 - gui_volume));
+
201 }
+
202 
+
203 void
+ +
205 {
+
206  if (v < 0) v = 0;
+
207  else if (v > 100) v = 100;
+
208 
+
209  wrn_volume = v;
+
210  Button::SetVolume(-50 * (100 - wrn_volume));
+
211 }
+
212 
+
213 void
+ +
215 {
+
216  if (v < 0) v = 0;
+
217  else if (v > 100) v = 100;
+
218 
+
219  vox_volume = v;
+
220 }
+
221 
+
222 // +--------------------------------------------------------------------+
+
223 
+
224 void
+ +
226 {
+
227  DataLoader* loader = DataLoader::GetLoader();
+
228  Text old_path = loader->GetDataPath();
+
229  loader->SetDataPath(0);
+
230 
+
231  // read the config file:
+
232  BYTE* block = 0;
+
233  int blocklen = 0;
+
234  const char* filename = "audio.cfg";
+
235 
+
236  FILE* f;
+
237  ::fopen_s(&f, filename, "rb");
+
238 
+
239  if (f) {
+
240  ::fseek(f, 0, SEEK_END);
+
241  blocklen = ftell(f);
+
242  ::fseek(f, 0, SEEK_SET);
+
243 
+
244  block = new(__FILE__,__LINE__) BYTE[blocklen+1];
+
245  block[blocklen] = 0;
+
246 
+
247  ::fread(block, blocklen, 1, f);
+
248  ::fclose(f);
+
249  }
+
250 
+
251  if (blocklen == 0)
+
252  return;
+
253 
+
254  Parser parser(new(__FILE__,__LINE__) BlockReader((const char*) block, blocklen));
+
255  Term* term = parser.ParseTerm();
+
256 
+
257  if (!term) {
+
258  Print("ERROR: could not parse '%s'.\n", filename);
+
259  exit(-3);
+
260  }
+
261  else {
+
262  TermText* file_type = term->isText();
+
263  if (!file_type || file_type->value() != "AUDIO") {
+
264  Print("WARNING: invalid %s file. Using defaults\n", filename);
+
265  return;
+
266  }
+
267  }
+
268 
+
269  do {
+
270  delete term;
+
271 
+
272  term = parser.ParseTerm();
+
273 
+
274  if (term) {
+
275  int v = 0;
+
276  TermDef* def = term->isDef();
+
277 
+
278  if (def) {
+
279  if (def->name()->value() == "menu_music") {
+
280  GetDefNumber(v, def, filename);
+
281 
+
282  if (v < 0 || v > 100) {
+
283  Print("WARNING: Invalid menu_music (%d) in '%s'\n", v, filename);
+
284  }
+
285  else {
+
286  menu_music = v;
+
287  }
+
288  }
+
289 
+
290  else if (def->name()->value() == "game_music") {
+
291  GetDefNumber(v, def, filename);
+
292 
+
293  if (v < 0 || v > 100) {
+
294  Print("WARNING: Invalid game_music (%d) in '%s'\n", v, filename);
+
295  }
+
296  else {
+
297  game_music = v;
+
298  }
+
299  }
+
300 
+
301  else if (def->name()->value() == "efx_volume") {
+
302  GetDefNumber(v, def, filename);
+
303 
+
304  if (v < 0 || v > 100) {
+
305  Print("WARNING: Invalid efx_volume (%d) in '%s'\n", v, filename);
+
306  }
+
307  else {
+
308  efx_volume = v;
+
309  }
+
310  }
+
311 
+
312  else if (def->name()->value() == "gui_volume") {
+
313  GetDefNumber(v, def, filename);
+
314 
+
315  if (v < 0 || v > 100) {
+
316  Print("WARNING: Invalid gui_volume (%d) in '%s'\n", v, filename);
+
317  }
+
318  else {
+
319  gui_volume = v;
+
320 
+
321  Button::SetVolume(-50 * (100 - gui_volume));
+
322  }
+
323  }
+
324 
+
325  else if (def->name()->value() == "wrn_volume") {
+
326  GetDefNumber(v, def, filename);
+
327 
+
328  if (v < 0 || v > 100) {
+
329  Print("WARNING: Invalid wrn_volume (%d) in '%s'\n", v, filename);
+
330  }
+
331  else {
+
332  wrn_volume = v;
+
333  }
+
334  }
+
335 
+
336  else if (def->name()->value() == "vox_volume") {
+
337  GetDefNumber(v, def, filename);
+
338 
+
339  if (v < 0 || v > 100) {
+
340  Print("WARNING: Invalid vox_volume (%d) in '%s'\n", v, filename);
+
341  }
+
342  else {
+
343  vox_volume = v;
+
344  }
+
345  }
+
346 
+
347  else
+
348  Print("WARNING: unknown label '%s' in '%s'\n",
+
349  def->name()->value().data(), filename);
+
350  }
+
351  else {
+
352  Print("WARNING: term ignored in '%s'\n", filename);
+
353  term->print();
+
354  Print("\n");
+
355  }
+
356  }
+
357  }
+
358  while (term);
+
359 
+
360  loader->ReleaseBuffer(block);
+
361  loader->SetDataPath(old_path);
+
362 }
+
363 
+
364 void
+ +
366 {
+
367  FILE* f;
+
368  fopen_s(&f, "audio.cfg", "w");
+
369  if (f) {
+
370  fprintf(f, "AUDIO\n\n");
+
371  fprintf(f, "menu_music: %3d\n", menu_music);
+
372  fprintf(f, "game_music: %3d\n\n", game_music);
+
373  fprintf(f, "efx_volume: %3d\n", efx_volume);
+
374  fprintf(f, "gui_volume: %3d\n", gui_volume);
+
375  fprintf(f, "wrn_volume: %3d\n", wrn_volume);
+
376  fprintf(f, "vox_volume: %3d\n", vox_volume);
+
377  fclose(f);
+
378  }
+
379 }
+
380 
+
381 // +--------------------------------------------------------------------+
+
382 
+
383 
+
384 
+
+
+ + + + -- cgit v1.1