-
Notifications
You must be signed in to change notification settings - Fork 3
/
optiongui.asc
722 lines (596 loc) · 20.2 KB
/
optiongui.asc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
#ifdef __VERB_GUI_MODULE__ //check module's dependencies
// Options GUI
int ScreenWidth;
int ScreenHeight;
// Time count utility
struct TimeCount {
//members below would be better as static attributes
int playTimeSeconds;
int timeNow;
int timeThen;
DateTime *dt;
import static void GameStart();
import static void RepExec();
import static String GeneratePlayTimeString();
};
TimeCount timeCount;
static void TimeCount::GameStart() {
timeCount.dt = DateTime.Now;
timeCount.timeNow = timeCount.dt.RawTime;
timeCount.timeThen = timeCount.timeNow;
timeCount.playTimeSeconds = 0;
}
static void TimeCount::RepExec() {
timeCount.dt = DateTime.Now;
timeCount.timeNow = timeCount.dt.RawTime;
if (timeCount.timeNow > timeCount.timeThen) {
timeCount.timeThen = timeCount.timeNow;
timeCount.playTimeSeconds ++;
}
}
static String TimeCount::GeneratePlayTimeString() {
String playTimeResult = "";
int playMinutes = FloatToInt(IntToFloat(timeCount.playTimeSeconds) / 60.0, eRoundDown);
int playHours = FloatToInt(IntToFloat(timeCount.playTimeSeconds) / 3600.0, eRoundDown);
if (playHours == 0) playTimeResult = String.Format ("%dm", playMinutes);
else playTimeResult = String.Format ("%dh %dm", playHours, playMinutes);
return String.Format("%s;%04d/%02d/%02d %02d:%02d", playTimeResult, timeCount.dt.Year, timeCount.dt.Month, timeCount.dt.DayOfMonth, timeCount.dt.Hour, timeCount.dt.Minute);
}
// Save Load GUI functionality
DynamicSprite *saveScreenshot;
DynamicSprite *slotSprites[SAVE_SLOTS];
DynamicSprite *slotSprites_hi[SAVE_SLOTS];
DynamicSprite *old_slotSprites[SAVE_SLOTS];
DynamicSprite *old_slotSprites_hi[SAVE_SLOTS];
struct CustomLoadData {
GUI* gui;
GUI* confirmGui;
int slotSprite;
int slotSpriteHi;
Button *loadSlotButtons[SAVE_SLOTS];
FontType font;
int loadSlotId;
};
CustomLoadData customLoadData;
struct CustomSaveData {
GUI* gui;
GUI* confirmGui;
int slotSprite;
int slotSpriteHi;
Button *saveSlotButtons[SAVE_SLOTS];
FontType font;
int saveSlotId;
String saveSlotString;
bool save_scheduled;
};
CustomSaveData customSaveData;
// Accessors for static attributes of CustomLoad
void set_slotSprite(static CustomLoad, int value)
{
customLoadData.slotSprite = value;
}
int get_slotSprite(static CustomLoad)
{
return customLoadData.slotSprite;
}
void set_slotSpriteHi(static CustomLoad, int value)
{
customLoadData.slotSpriteHi = value;
}
int get_slotSpriteHi(static CustomLoad)
{
return customLoadData.slotSpriteHi;
}
void set_font(static CustomLoad, int value)
{
customLoadData.font = value;
}
int get_font(static CustomLoad)
{
return customLoadData.font;
}
// Accessors for static attributes of CustomSave
void set_slotSprite(static CustomSave, int value)
{
customSaveData.slotSprite = value;
}
int get_slotSprite(static CustomSave)
{
return customSaveData.slotSprite;
}
void set_slotSpriteHi(static CustomSave, int value)
{
customSaveData.slotSpriteHi = value;
}
int get_slotSpriteHi(static CustomSave)
{
return customSaveData.slotSpriteHi;
}
void set_font(static CustomSave, int value)
{
customSaveData.font = value;
}
int get_font(static CustomSave)
{
return customSaveData.font;
}
// Set GUI
static void CustomSave::SetGui(GUI* _gui, GUI* confirmGui) {
customSaveData.gui = _gui;
customSaveData.confirmGui = confirmGui;
}
// InitSaveDialog
static void CustomSave::InitSaveDialog() {
int i = 0;
while (i < SAVE_SLOTS) {
customSaveData.saveSlotButtons[i] = customSaveData.gui.Controls[i+1].AsButton;
i++;
}
}
// DisableSaveButtons
static void CustomSave::DisableSaveButtons() {
int i = 0;
while (i < SAVE_SLOTS) {
if (i+1 != customSaveData.saveSlotId) {
customSaveData.saveSlotButtons[i].Enabled=false;
}
i++;
}
btnSaveCancel.Enabled = false;
}
// EnableSaveButtons
static void CustomSave::EnableSaveButtons() {
int i;
while (i < SAVE_SLOTS) {
customSaveData.saveSlotButtons[i].Enabled=true;
i++;
}
btnSaveCancel.Enabled = true;
}
// Show the Save dialog
static void CustomSave::ShowSaveDialog() {
if (!customSaveData.save_scheduled) {
CustomSave.InitSaveDialog();
int i=0;
int btnHeight = Game.SpriteHeight[customSaveData.slotSprite];
int btnWidth = Game.SpriteWidth[customSaveData.slotSprite];
String tempSlotDesc = "";
// Check the slots
while (i < SAVE_SLOTS) {
slotSprites[i] = DynamicSprite.Create(btnWidth, btnHeight);
slotSprites_hi[i] = DynamicSprite.Create(btnWidth, btnHeight);
DrawingSurface *normGraphic= slotSprites[i].GetDrawingSurface();
DrawingSurface *hiGraphic= slotSprites_hi[i].GetDrawingSurface();
normGraphic.DrawImage(0, 0, customSaveData.slotSprite);
hiGraphic.DrawImage(0, 0, customSaveData.slotSpriteHi);
if (Game.GetSaveSlotDescription(i+1)!=null) {
DynamicSprite *tempSprite = DynamicSprite.CreateFromSaveGame(i+1, ScreenWidth, ScreenHeight);
if (tempSprite != null) {
tempSprite.Crop(0, 0, ScreenWidth, ScreenHeight - gMain.Height); //TODO : remove reference to gMain
tempSprite.Resize(btnWidth-4, btnHeight-6);
DrawingSurface *tempSurf = tempSprite.GetDrawingSurface();
tempSurf.DrawingColor = 15;
tempSlotDesc = Game.GetSaveSlotDescription(i+1);
if (tempSlotDesc != null && tempSlotDesc.IndexOf(";") > 0) {
tempSurf.DrawString(0, 1, customSaveData.font, tempSlotDesc.Substring(0, tempSlotDesc.IndexOf(";")));
tempSurf.DrawString(0, btnHeight-15, customSaveData.font, tempSlotDesc.Substring(tempSlotDesc.IndexOf(";")+1, tempSlotDesc.Length));
}
tempSurf.Release();
}
else {
tempSprite = DynamicSprite.Create(btnWidth-4, btnHeight-6);
DrawingSurface *tempSurf = tempSprite.GetDrawingSurface();
tempSurf.Clear(0);
tempSurf.DrawingColor = 15;
tempSlotDesc = Game.GetSaveSlotDescription(i+1);
if (tempSlotDesc != null && tempSlotDesc.IndexOf(";") > 0) {
tempSurf.DrawString(0, 1, customSaveData.font, tempSlotDesc.Substring(0, tempSlotDesc.IndexOf(";")));
tempSurf.DrawString(0, btnHeight-15, customSaveData.font, tempSlotDesc.Substring(tempSlotDesc.IndexOf(";")+1, tempSlotDesc.Length));
}
tempSurf.Release();
}
normGraphic.DrawImage(2, 3, tempSprite.Graphic);
hiGraphic.DrawImage(2, 3, tempSprite.Graphic);
tempSprite.Delete();
}
normGraphic.Release();
hiGraphic.Release();
customSaveData.saveSlotButtons[i].NormalGraphic=slotSprites[i].Graphic;
customSaveData.saveSlotButtons[i].MouseOverGraphic=slotSprites_hi[i].Graphic;
i++;
}
customSaveData.gui.Visible=true;
gOptions.Visible = false;
}
}
// clicked on a save slot
static void CustomSave::SelectSaveSlot(int control_id)
{
int btnWidth = Game.SpriteWidth[customSaveData.saveSlotButtons[0].Graphic];
int btnHeight = Game.SpriteHeight[customSaveData.saveSlotButtons[0].Graphic];
int slot;
int i;
while (i < SAVE_SLOTS) {
if (control_id == customSaveData.saveSlotButtons[i].ID) slot = i+1;
i++;
}
// backup old setting in case of cancel
old_slotSprites[slot-1] = DynamicSprite.CreateFromExistingSprite(customSaveData.saveSlotButtons[slot-1].NormalGraphic);
old_slotSprites_hi[slot-1] = DynamicSprite.CreateFromExistingSprite(customSaveData.saveSlotButtons[slot-1].MouseOverGraphic);
// Create new sprites
slotSprites[slot-1] = DynamicSprite.Create(btnWidth, btnHeight);
slotSprites_hi[slot-1] = DynamicSprite.Create(btnWidth, btnHeight);
DrawingSurface *normGraphic= slotSprites[slot-1].GetDrawingSurface();
DrawingSurface *hiGraphic= slotSprites_hi[slot-1].GetDrawingSurface();
normGraphic.DrawImage(0, 0, customSaveData.slotSprite);
hiGraphic.DrawImage(0, 0, customSaveData.slotSpriteHi);
if(saveScreenshot != null) {
normGraphic.DrawImage(2, 3, saveScreenshot.Graphic);
hiGraphic.DrawImage(2, 3, saveScreenshot.Graphic);
}
// pass these to Okay and Cancel
customSaveData.saveSlotId = slot;
customSaveData.saveSlotButtons[slot-1].NormalGraphic=slotSprites[slot-1].Graphic;
customSaveData.saveSlotButtons[slot-1].MouseOverGraphic=slotSprites_hi[slot-1].Graphic;
normGraphic.Release();
hiGraphic.Release();
// Show Confirm
btnSaveOk.X = customSaveData.saveSlotButtons[slot-1].X+customSaveData.saveSlotButtons[slot-1].Width-7;
btnSaveOk.Y = customSaveData.saveSlotButtons[slot-1].Y + 4;
btnSaveNo.X = btnSaveOk.X;
btnSaveNo.Y = btnSaveOk.Y + btnSaveOk.Height;
CustomSave.DisableSaveButtons();
customSaveData.confirmGui.Visible=true;
}
// Red Button clicked: don't save
static void CustomSave::SaveNo()
{
int slot = customSaveData.saveSlotId;
customSaveData.saveSlotButtons[slot-1].NormalGraphic=old_slotSprites[slot-1].Graphic;
customSaveData.saveSlotButtons[slot-1].MouseOverGraphic=old_slotSprites_hi[slot-1].Graphic;
customSaveData.confirmGui.Visible=false;
CustomSave.EnableSaveButtons();
}
// Green Button clicked: Okay
static void CustomSave::SaveYes()
{
int slot = customSaveData.saveSlotId;
int i;
if (customSaveData.confirmGui.Visible==true) customSaveData.confirmGui.Visible=false;
customSaveData.gui.Visible=false;
gOptions.Visible = false;
customSaveData.save_scheduled = true; //We don't save right now. We schedule it for after the GUI gets closed.
if (saveScreenshot != null) saveScreenshot.Delete();
while (i < SAVE_SLOTS) {
if (old_slotSprites[i]!=null) old_slotSprites[i].Delete();
if (old_slotSprites_hi[i]!=null) old_slotSprites_hi[i].Delete();
if (slotSprites[i]!=null) slotSprites[i].Delete();
if (slotSprites_hi[i]!=null) slotSprites_hi[i].Delete();
i++;
}
CustomSave.EnableSaveButtons();
}
// Close Save GUI
static void CustomSave::SaveCancel()
{
int i;
customSaveData.saveSlotId = 0;
customSaveData.saveSlotString = "";
if (customSaveData.confirmGui.Visible==true) {
customSaveData.confirmGui.Visible=false;
}
customSaveData.gui.Visible=false;
gOptions.Visible = true;
}
// Set GUI
static void CustomLoad::SetGui(GUI* _gui, GUI* confirmGui) {
customLoadData.gui = _gui;
customLoadData.confirmGui = confirmGui;
}
static void CustomLoad::InitLoadDialog()
{
int i = 0;
while (i < SAVE_SLOTS) {
customLoadData.loadSlotButtons[i] = customLoadData.gui.Controls[i+1].AsButton;
i++;
}
}
// Display load dialog
static void CustomLoad::ShowLoadDialog() {
if (!customSaveData.save_scheduled) {
int i=0;
int btnHeight = Game.SpriteHeight[customLoadData.slotSprite];
int btnWidth = Game.SpriteWidth[customLoadData.slotSprite];
String tempSlotDesc;
CustomLoad.InitLoadDialog();
// Check the slots
while (i < SAVE_SLOTS) {
customLoadData.loadSlotButtons[i].Enabled=false;
slotSprites[i] = DynamicSprite.Create(btnWidth, btnHeight);
slotSprites_hi[i] = DynamicSprite.Create(btnWidth, btnHeight);
DrawingSurface *normGraphic= slotSprites[i].GetDrawingSurface();
DrawingSurface *hiGraphic= slotSprites_hi[i].GetDrawingSurface();
normGraphic.DrawImage(0, 0, customLoadData.slotSprite);
hiGraphic.DrawImage(0, 0, customLoadData.slotSpriteHi);
if (Game.GetSaveSlotDescription(i+1)!=null) {
DynamicSprite *tempSprite = DynamicSprite.CreateFromSaveGame(i+1, ScreenWidth, ScreenHeight);
if (tempSprite != null) {
tempSprite.Crop(0, 0, ScreenWidth, ScreenHeight - gMain.Height); //TODO : remove reference to gMain
tempSprite.Resize(btnWidth-4, btnHeight-6);
DrawingSurface *tempSurf = tempSprite.GetDrawingSurface();
tempSurf.DrawingColor = 15;
tempSlotDesc = Game.GetSaveSlotDescription(i+1);
if (tempSlotDesc != null && tempSlotDesc.IndexOf(";") > 0) {
tempSurf.DrawString(0, 1, customLoadData.font, tempSlotDesc.Substring(0, tempSlotDesc.IndexOf(";")));
tempSurf.DrawString(0, btnHeight-15, customLoadData.font, tempSlotDesc.Substring(tempSlotDesc.IndexOf(";")+1, tempSlotDesc.Length));
}
tempSurf.Release();
}
else {
tempSprite = DynamicSprite.Create(btnWidth-4, btnHeight-6);
DrawingSurface *tempSurf = tempSprite.GetDrawingSurface();
tempSurf.Clear(0);
tempSurf.DrawingColor = 15;
tempSlotDesc = Game.GetSaveSlotDescription(i+1);
if (tempSlotDesc != null && tempSlotDesc.IndexOf(";") > 0) {
tempSurf.DrawString(0, 1, customLoadData.font, tempSlotDesc.Substring(0, tempSlotDesc.IndexOf(";")));
tempSurf.DrawString(0, btnHeight-15, customLoadData.font, tempSlotDesc.Substring(tempSlotDesc.IndexOf(";")+1, tempSlotDesc.Length));
}
tempSurf.Release();
}
normGraphic.DrawImage(2, 3, tempSprite.Graphic);
hiGraphic.DrawImage(2, 3, tempSprite.Graphic);
tempSprite.Delete();
customLoadData.loadSlotButtons[i].Enabled = true;
}
normGraphic.Release();
hiGraphic.Release();
customLoadData.loadSlotButtons[i].NormalGraphic=slotSprites[i].Graphic;
customLoadData.loadSlotButtons[i].MouseOverGraphic=slotSprites_hi[i].Graphic;
i++;
}
customLoadData.gui.Visible = true;
gOptions.Visible = false;
}
}
// click on a slot button
static void CustomLoad::SelectLoadSlot(int control_id)
{
int slot;
int i;
while (i < SAVE_SLOTS) {
if (control_id == customLoadData.loadSlotButtons[i].ID) slot = i+1;
i++;
}
if (slot > 0 ) {
if (saveScreenshot!=null) saveScreenshot.Delete();
while (i < SAVE_SLOTS) {
if (slotSprites[i]!=null) slotSprites[i].Delete();
if (slotSprites_hi[i]!=null) slotSprites_hi[i].Delete();
i++;
}
RestoreGameSlot(slot);
}
}
// Cancel loading
static void CustomLoad::LoadCancel() {
customLoadData.gui.Visible=false;
gOptions.Visible = true;
}
// Prepare a screenshot
static void OptionGui::CreateScreenshot(FontType font)
{
customSaveData.saveSlotString = TimeCount.GeneratePlayTimeString();
int btnWidth = Game.SpriteWidth[customLoadData.slotSprite];
int btnHeight = Game.SpriteHeight[customLoadData.slotSprite];
saveScreenshot = DynamicSprite.CreateFromScreenShot();
saveScreenshot.Crop(0, 0, ScreenWidth, ScreenHeight - gMain.Height); //TODO : remove reference to gMain
saveScreenshot.Resize(btnWidth-4, btnHeight-6);
DrawingSurface *tempSurf = saveScreenshot.GetDrawingSurface();
tempSurf.DrawingColor = 15;
tempSurf.DrawString(0, 1, font, customSaveData.saveSlotString.Substring(0, customSaveData.saveSlotString.IndexOf(";")));
String st = customSaveData.saveSlotString;
tempSurf.DrawString(0, btnHeight-15, font, st.Substring(st.IndexOf(";")+1, st.Length));
tempSurf.Release();
}
// Show control panel
static void OptionGui::ShowOptions()
{
if (!customSaveData.save_scheduled) {
OptionGui.CreateScreenshot(customSaveData.font);
gOptions.Visible = true;
}
}
// Click on "default" button
static void OptionGui::Default()
{
sldOptionsMusic.Value = 80;
sldOptionsSound.Value = 90;
//sldOptionsStyle.Value = 1;
Game.SetAudioTypeVolume(eAudioTypeMusic, sldOptionsMusic.Value, eVolExistingAndFuture);
Game.SetAudioTypeVolume(eAudioTypeSound, sldOptionsSound.Value, eVolExistingAndFuture);
Game.SetAudioTypeVolume(eAudioTypeAmbientSound, sldOptionsSound.Value, eVolExistingAndFuture);
}
//Returns true if 'control' is one of the 9 save slots controls in the Save Gui
bool IsSaveSlot(GUIControl *control) {
return (control.OwningGUI.ID == customSaveData.gui.ID && control.ID >= btnSaveSlot1.ID && control.ID <= btnSaveSlot9.ID);
}
//Returns true if 'control' is one of the 9 restore slots controls in the Load Gui
bool IsRestoreSlot(GUIControl *control) {
return (control.OwningGUI.ID == customLoadData.gui.ID && control.ID >= btnLoadSlot1.ID && control.ID <= btnLoadSlot9.ID);
}
static void OptionGui::OnClick(GUIControl *control, MouseButton button)
{
//== MAIN OPTIONS DIALOG ==
// Default
/*if (control==btnOptionsDefault) {
OptionGui.Default();
}*/
// Save
// if (control==btnOptionsSave) {
// gOptions.Visible=false;
// CustomSave.ShowSaveDialog();
//}
// Load
//else if (control==btnOptionsLoad) {
// gOptions.Visible=false;
// CustomLoad.ShowLoadDialog();
//}
// Resume
if (control==btnOptionsResume // || control == btnOptionsClose
) {
gOptions.Visible=false;
}
// Quit
else if (control==btnOptionsQuit) {
gOptions.Visible=false;
gQuit.Visible=true;
}
//== 'SAVE' DIALOG ==
//Slot click
else if (IsSaveSlot(control)) {
CustomSave.SelectSaveSlot(control.ID);
}
//OK
else if (control==btnSaveOk) {
CustomSave.SaveYes();
}
//No
else if (control==btnSaveNo) {
CustomSave.SaveNo();
}
//Cancel
else if (control==btnSaveCancel) {
CustomSave.SaveCancel();
}
//Close
else if (control==btnSaveClose) {
CustomSave.SaveCancel();
}
//== 'LOAD' DIALOG ==
//Slot click
else if (IsRestoreSlot(control)) {
CustomLoad.SelectLoadSlot(control.ID);
}
//Cancel
else if (control==btnLoadCancel) {
CustomLoad.LoadCancel();
}
//Close
else if (control==btnLoadClose) {
CustomLoad.LoadCancel();
}
//== 'QUIT' DIALOG ==
//Yes
else if (control==btnQuitYes) {
QuitGame(0);
}
//No
else if (control==btnQuitNo) {
gQuit.Visible = false;
}
//== 'RESTART' DIALOG ==
//Yes
else if (control==btnRestartYes) {
SetNextScreenTransition(eTransitionInstant);
RestartGame();
}
//No
else if (control==btnRestartNo) {
gRestart.Visible = false;
}
//== 'THANKS FOR PLAYING' DIALOG ==
//Yes
else if (control==btnRestart) {
SetNextScreenTransition(eTransitionInstant);
RestartGame();
}
//No
else if (control==btnQuit_ThanksForPlaying) {
QuitGame(0);
}
}
AudioChannel* pacifierChannel;
AudioChannel* pacifierMusicChannel; //a copy of the pacifier sound set to use the music channel so it updates correctly
function sldOptionsMusic_OnChange(GUIControl *control)
{
Game.SetAudioTypeVolume(eAudioTypeMusic, sldOptionsMusic.Value, eVolExistingAndFuture);
if(pacifierMusicChannel) //make sure it's not null
{
if(pacifierMusicChannel.IsPlaying == false)
{
pacifierMusicChannel = aPacifierMusic.Play();
}
}
else
{
pacifierMusicChannel = aPacifierMusic.Play();
}
}
function sldOptionsSound_OnChange(GUIControl *control)
{
Game.SetAudioTypeVolume(eAudioTypeSound, sldOptionsSound.Value, eVolExistingAndFuture);
Game.SetAudioTypeVolume(eAudioTypeAmbientSound, sldOptionsSound.Value, eVolExistingAndFuture);
if(pacifierChannel) //make sure it's not null
{
if(pacifierChannel.IsPlaying == false)
{
pacifierChannel = aPacifier.Play();
}
}
else
{
pacifierChannel = aPacifier.Play();
}
}
/*
function sldOptionsStyle_OnChange(GUIControl *control)
{
Verbs.ToogleGuiStyle(sldOptionsStyle.Value);
}
*/
static void OptionGui::OnSliderChange(GUIControl *control)
{
//Music slider
if (control==sldOptionsMusic) {
sldOptionsMusic_OnChange(control);
}
//Sound slider
else if (control==sldOptionsSound) {
sldOptionsSound_OnChange(control);
}
/*
//GUI Style slider
else if (control==sldOptionsStyle) {
sldOptionsStyle_OnChange(control);
}
*/
}
// Remember when the game was started
function game_start()
{
TimeCount.GameStart();
#ifdef SCRIPT_API_v3507
ScreenWidth = Screen.Width;
ScreenHeight = Screen.Height;
#endif
#ifndef SCRIPT_API_v3507
ScreenWidth = System.ScreenWidth;
ScreenHeight = System.ScreenHeight;
#endif
}
// workaround to take a savegame screenshot without the gui
function repeatedly_execute()
{
TimeCount.RepExec();
if (customSaveData.save_scheduled) {
SaveGameSlot(customSaveData.saveSlotId, customSaveData.saveSlotString);
customSaveData.saveSlotId = 0;
customSaveData.saveSlotString = "";
customSaveData.save_scheduled = false;
}
}
#endif
#ifndef __VERB_GUI_MODULE__ //A dependency is missing
#error Missing module 'OptionGui'
#endif