This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuOptions.cs
86 lines (73 loc) · 3.04 KB
/
MenuOptions.cs
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
/*
Copyright (C) 2009 Tom Postma, Gertjan Buijs
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
namespace Frogger
{
using System;
using System.Drawing;
/// <summary>
/// Options screen
/// </summary>
class MenuOptions : MenuScreen
{
private FrmMenu frmmenu;
private BigCheckbox[] options;
private const int marginbigchx = 20;
public MenuOptions(FrmMenu frmmenu)
: base(frmmenu)
{
this.frmmenu = frmmenu;
bool sound = Frogger.Properties.Settings.Default.sound;
bool fullscreen = Frogger.Properties.Settings.Default.fullscreen;
options = new BigCheckbox[2];
options[0] = new BigCheckbox("sound", sound);
options[0].Location = new Point(frmmenu.Width / 2 - (options[0].Width / 2), frmmenu.Height / 2 - (options[0].Height / 2));
options[0].Click += new EventHandler(ToggleSound);
options[1] = new BigCheckbox("full screen", fullscreen);
options[1].Location = new Point(frmmenu.Width / 2 - (options[1].Width / 2), frmmenu.Height / 2 - (options[1].Height / 2) + options[1].Height + marginbigchx);
options[1].Click += new EventHandler(ToggleFullscreen);
frmmenu.Controls.AddRange(options);
}
override public void ClearScreen()
{
foreach (BigCheckbox curchx in options)
{
curchx.Dispose();
}
}
/// <summary>
/// Toggle between fulscreen and not.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ToggleFullscreen(object sender, EventArgs e)
{
Program.fullscreen = !Program.fullscreen;
Frogger.Properties.Settings.Default.fullscreen = Program.fullscreen;
Frogger.Properties.Settings.Default.Save();
Program.CheckFullScreen(frmmenu);
frmmenu.MenuUpdated = true;
frmmenu.Refresh();
}
/// <summary>
/// Toggle between sound on and off.
/// </summary>
public void ToggleSound(object sender, EventArgs e)
{
Program.sound = !Program.sound; //in memory, fast to access
Frogger.Properties.Settings.Default.sound = Program.sound; //on disk, slow to access
Frogger.Properties.Settings.Default.Save();
}
}
}