-
Notifications
You must be signed in to change notification settings - Fork 2
/
MainMenu.cs
97 lines (71 loc) · 2.1 KB
/
MainMenu.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
87
88
89
90
91
92
93
94
95
96
97
using System;
namespace Nitemare3D
{
public class MainMenu : Scene
{
const uint textX = 110;
const uint textY = 60;
float enterTime = .1f;
float enterTimer = 0f;
Pcx menu = new Pcx(Dat.Uif[ImageConsts.MENU_MAIN]);
void LoadSoundEditor()
{
FadeOut(Scene.LEVEL_SOUNDEDITOR, 1f);
}
string[] mainMenuItems = new string[]
{
"New game",
"Configure game...",
"Load game...",
"Instructions",
"Demo",
"Sound Editor",
"Quit"
};
Action[] menufunctions = new Action[6];
void SelectLevel()
{
FadeOut(Scene.LEVEL_LEVELSELECT, 1f);
}
int selection = 0;
public override void Update()
{
enterTimer += Time.dt;
if (enterTimer > enterTime)
{
if (Input.IsKeyDown(KeyboardKey.Down))
{
enterTimer = 0;
selection++;
}
if (Input.IsKeyDown(KeyboardKey.Up))
{
enterTimer = 0;
selection--;
}
if (selection < 0) { selection = 0; }
if (selection >= mainMenuItems.Length) { selection = mainMenuItems.Length - 1; }
if (Input.IsKeyDown(KeyboardKey.Enter))
{
menufunctions[selection].Invoke();
}
}
for (uint i = 0; i < mainMenuItems.Length; i++)
{
int color = (selection == i) ? 175 : 254;
uint y = textY + (i * 15);
GameWindow.DrawText(textX, y, mainMenuItems[i], color);
}
}
public override void Load()
{
songid = MidiConsts.MIDI_FANTASIA;
pcx = menu;
menufunctions[0] = (Action)SelectLevel;
menufunctions[5] = (Action)LoadSoundEditor;
}
public override void UnLoad()
{
}
}
}