-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreenInstances.cs
153 lines (143 loc) · 4.52 KB
/
ScreenInstances.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
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
using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace ScreenSaver
{
internal static class ScreenInstances
{
public static List<ScreenSaverForm> ScrForms = new List<ScreenSaverForm>();
public static Random EntropySrc = new Random((int)DateTime.Now.Ticks);
public static Bitmap[] katakana = new Bitmap[480];
public static Bitmap[] katakana_glitch = new Bitmap[480];
public static CancellationTokenSource GlobalCTS = new CancellationTokenSource();
public static List<int> EmptySprites = new List<int>() { -1, 100, 220, 340, 460, 26, 116, 117, 118, 119, 146, 136, 137, 138, 139, 266, 256, 257, 258, 259, 376, 386, 387, 388, 389 };
static ScreenInstances()
{
LoadKatakanaSprites();
}
public static void TerminateSS()
{
GlobalCTS.Cancel();
Application.Exit();
}
public static Bitmap GetKatakanaSprite(int index, bool canglitch = true)
{
Bitmap resbitmap = null;
try
{
if (ScreenInstances.EntropySrc.Next(1000) >= 995 && canglitch) //chance to glitch is 0.1%
{
resbitmap = ScreenInstances.katakana_glitch[index];
}
else
{
resbitmap = ScreenInstances.katakana[index];
}
}
catch (Exception ex)
{
var s = ex.ToString();
}
return resbitmap;
}
private static void LoadKatakanaSprites()
{
using (var raw = new Bitmap(Properties.Resources.spd))
{
for (int i = 0; i < katakana.Length; i++)
{
var xptr = i * 16 % 640;
var yptr = ((int)(i / 40)) * 24;
Rectangle cloneRect = new Rectangle(xptr, yptr, 15, 24);
katakana[i] = raw.Clone(cloneRect, PixelFormat.Format32bppArgb);
}
}
using (var raw = new Bitmap(Properties.Resources.spd_glitch))
{
for (int i = 0; i < katakana.Length; i++)
{
var xptr = i * 16 % 640;
var yptr = ((int)(i / 40)) * 24;
Rectangle cloneRect = new Rectangle(xptr, yptr, 15, 24);
katakana_glitch[i] = raw.Clone(cloneRect, PixelFormat.Format32bppArgb);
}
}
}
public static List<string> CreditsStrings = new List<string>()
{
"The Matrix®",
".NET WinForms screensaver",
"© 2024 by Gordon Freeman [gfr20141201@gmail.com]",
"inspired by and dedicated to Burning_Thornbush [burning_thornbush@yahoo.com]",
};
public static List<string> ConsoleStrings = new List<string>()
{
"Wake up, Neo...",
"You have shitted. The Matrix is full of your shit...",
"Follow the white powder",
"Knock, knock, Neo",
};
public static int GetLetterSprite(char ch)
{
var res = -1;
if (ch >= 'A' && ch <= 'Z')
{
res = ch + 321;
}
if (ch >= 'a' && ch <= 'z')
{
res = ch + 315;
}
if (ch >= '0' && ch <= '9')
{
res = ch + 390;
}
if (ch == ' ')
{
res = 25;
}
if (ch == '[')
{
res = 465;
}
if (ch == ']')
{
res = 466;
}
if (ch == '©')
{
res = 473;
}
if (ch == '®')
{
res = 472;
}
if (ch == '@')
{
res = 471;
}
if (ch == '.')
{
res = 452;
}
if (ch == ',')
{
res = 453;
}
if (ch == '_')
{
res = 460;
}
return res;
}
public static bool CheckIndexEmptySprite(int katakanaIndex)
{
return EmptySprites.Contains(katakanaIndex);
}
}
}