-
Notifications
You must be signed in to change notification settings - Fork 0
/
Konami.cs
42 lines (37 loc) · 1.05 KB
/
Konami.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
/* LOIC - Low Orbit Ion Cannon
* Released to the public domain
* Enjoy getting v&, kids.
*/
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace LOIC
{
public class Konami
{
private static short KonamiState = 0;
private static Keys[] KonamiKeys = {Keys.Up, Keys.Up, Keys.Down, Keys.Down, Keys.Left, Keys.Right, Keys.Left, Keys.Right, Keys.B, Keys.A, Keys.Enter};
public static bool Check(Form frm)
{
bool on = Settings.HasKonamiCode();
if(!on) {
frm.KeyUp += new KeyEventHandler(HandleKonamiKeyPress);
}
return on;
}
public static void HandleKonamiKeyPress(object sender, KeyEventArgs e)
{
if (KonamiKeys[KonamiState] == e.KeyCode) {
KonamiState++;
if (KonamiState >= KonamiKeys.Length) {
KonamiState = 0;
e.Handled = true;
Settings.SaveKonamiCode();
MessageBox.Show("Close and re-open the application to apply the changes.", "Konami Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
} else if (KonamiState != 0) {
KonamiState = 0;
}
}
}
}