aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/MonoGameOOBE.cs
blob: 14adc4ebc7ee91e59f8129384c7db460b071192f (plain) (blame)
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ShiftOS.Engine;
using ShiftOS.Objects;

namespace ShiftOS.Frontend
{
    public class MonoGameOOBE : IOobe
    {
        public void PromptForLogin()
        {
            throw new NotImplementedException();
        }

        public void ShowSaveTransfer(Save save)
        {
            throw new NotImplementedException();
        }

        public void SlowWriteLine(string text)
        {
            if (!string.IsNullOrWhiteSpace(Console.Text))
                Console.WriteLine("");

            for (int i = 0; i < text.Length; i++)
            {
                System.Threading.Thread.Sleep(50);
                Console.Write(text[i].ToString());
            }
        }

        private Apps.TerminalControl Console = null;
        private GUI.ProgressBar progress = null;
        private GUI.TextControl status = null;

        public void StartShowing(Save save)
        {
            TerminalBackend.InStory = true;
            TerminalBackend.PrefixEnabled = false;

            var term = new Apps.TerminalControl();
            GraphicsSubsystem.UIManager.AddTopLevel(term);
            term.Width = GraphicsSubsystem.UIManager.Viewport.Width;
            term.Height = GraphicsSubsystem.UIManager.Viewport.Height;
            term.X = 0;
            term.Y = 0;
            AppearanceManager.ConsoleOut = term;
            AppearanceManager.StartConsoleOut();
            Console = term;

            var t = new System.Threading.Thread(() =>
            {
                SlowWriteLine("Michael VanOverbeek presents...");
                Thread.Sleep(2000);
                SlowWriteLine("A Philip Adams game...");
                Thread.Sleep(2000);
                
                SlowWriteLine("");
                SlowWriteLine(@"It's not often technology becomes out of mankind's league, out of its 
control. I mean, we are the creators of technology, we are the ones with the ideas,
innovations, and skill. It just does what we tell it to, right?");
                Thread.Sleep(2000);

                SlowWriteLine("");
                SlowWriteLine(@"Such a naive being you are to think that, after all,
you have no idea where you are... what's going on... who I am.");

                Thread.Sleep(2000);

                SlowWriteLine("");
                SlowWriteLine(@"To you, I'm just text. Something you understand. Words...
paragraphs... ideas... the very things that caused and became technology.");

                Thread.Sleep(2000);

                SlowWriteLine("");
                SlowWriteLine(@"""Where am I? What the hell's going on!?"" I hear you ask.
Such important questions, but please adjust your emotional and
mental state. This is not your concern.");

                Thread.Sleep(2000);

                SlowWriteLine("");
                SlowWriteLine(@"My name is DevX. What is yours?");

                bool nameChosen = false;
                Engine.Infobox.PromptText("What is your name?", "Please enter your name in the box below, then hit 'OK'.", (name) =>
                {
                    nameChosen = true;
                    save.Username = name;
                });

                while (nameChosen == false)
                    Thread.Sleep(10);

                Thread.Sleep(2000);

                SlowWriteLine("");
                SlowWriteLine($@"Hello there, {save.Username}. Nice to meet you.");

                Thread.Sleep(2000);

                SlowWriteLine("");
                SlowWriteLine(@"Welcome to my Digital Society.");

                Thread.Sleep(2000);

                SlowWriteLine("");
                SlowWriteLine(@"I can't and won't tell you what happened to you, but I'm going to tell you
what you're going to be doing for me... with me.");

                Thread.Sleep(2000);

                SlowWriteLine("");
                SlowWriteLine(@"But it's not time for that. First, you must be trained.
I'm installing the Digital Society's gateway operating system onto your sentience.
It's called ShiftOS.");

                Thread.Sleep(2000);

                SlowWriteLine("");
                SlowWriteLine(@"When the system is installed, I'll contact you. DevX out.");

                Thread.Sleep(5000);

                while(AppearanceManager.OpenForms.Count > 0)
                {
                    AppearanceManager.OpenForms[0].Close();
                    AppearanceManager.OpenForms.RemoveAt(0);
                }

                GUI.TextControl _shiftos = new GUI.TextControl();
                GraphicsSubsystem.UIManager.AddTopLevel(_shiftos);
                term.Clear();
                _shiftos.AutoSize = true;
                _shiftos.Font = SkinEngine.LoadedSkin.HeaderFont;
                _shiftos.Text = "ShiftOS";
                _shiftos.Y = GraphicsSubsystem.UIManager.Viewport.Height / 3;
                _shiftos.Layout(new Microsoft.Xna.Framework.GameTime());
                _shiftos.X = (GraphicsSubsystem.UIManager.Viewport.Width - _shiftos.Width) / 2;

                status = new GUI.TextControl();
                GraphicsSubsystem.UIManager.AddTopLevel(status);
                status.Font = SkinEngine.LoadedSkin.MainFont;
                status.AutoSize = true;
                status.Text = "Beginning installation...";
                status.Y = _shiftos.Y + _shiftos.Height + 5;
                status.Layout(new Microsoft.Xna.Framework.GameTime());
                status.X = (GraphicsSubsystem.UIManager.Viewport.Width - status.Width) / 2;

                progress = new GUI.ProgressBar();
                GraphicsSubsystem.UIManager.AddTopLevel(progress);
                progress.Width = 150;
                progress.Height = 10;
                progress.Maximum = 250;
                progress.Value = 0;
                progress.Y = status.Y + status.Height + 15;
                progress.X = (GraphicsSubsystem.UIManager.Viewport.Width - progress.Width) / 2;

                term.Clear();
                term.Width = 320;
                term.Height = 200;
                term.X = (GraphicsSubsystem.UIManager.Viewport.Width - term.Width) / 2;
                term.Y = progress.Y + progress.Height + 15;
                var nt = new Thread(() =>
                {
                    while(status != null)
                    {
                        try
                        {
                            if (term.Lines.Length > 0)
                            {
                                string txt = term.Lines[term.Lines.Length - 1];
                                if (status.Text != txt + $" [{progress.Value}%]")
                                {
                                    status.Text = txt + $" [{progress.Value}%]";
                                    status.Layout(new Microsoft.Xna.Framework.GameTime());
                                    status.X = (GraphicsSubsystem.UIManager.Viewport.Width - status.Width) / 2;
                                }
                            }
                            else
                            {
                                Thread.Sleep(10);
                            }
                        }
                        catch { }
                    }
                });
                nt.Start();
                SlowWriteLine("Formatting storage device A with ShiftFS version 4.7...");

                progress.Maximum = 100;
                for (int i = 0; i < 100; i++)
                {
                    progress.Value = i;
                    Thread.Sleep(25);
                }
                progress.Value = 0;
                Console.WriteLine("Mounting storage device A to 0:/");
                Thread.Sleep(135);
                Console.WriteLine("Writing system files & directories to sentience...");
                Thread.Sleep(450);
                foreach (var dir in Paths.GetAllWithoutKey())
                {
                    try
                    {
                        if (dir.StartsWith("0:/"))
                        {
                            Console.WriteLine("Writing: " + dir);
                            Thread.Sleep(30);
                        }
                    }
                    catch { }
                }
                Thread.Sleep(1250);
                Console.WriteLine("Generating system profile...");
                Thread.Sleep(25);
                Console.WriteLine("Codepoints: 0");
                save.Codepoints = 0;
                progress.Value = 10;
                Thread.Sleep(25);
                Console.WriteLine("Shiftorium cache generated...");
                save.Upgrades = new Dictionary<string, bool>();
                progress.Value = 20;
                Console.WriteLine("Performing even more redundant tasks that have already been done for us by the backend because we're redundant programmers who don't know our own code... jesus christ this is a long string...");
                save.ID = Guid.NewGuid();
                save.IsSandbox = false;
                save.Language = "english";
                save.MusicEnabled = true;
                save.MusicVolume = 100;
                save.PickupPoint = "";
                save.ShiftnetSubscription = 0;
                save.SoundEnabled = true;
                save.StoriesExperienced = new List<string>();
                Thread.Sleep(2000);
                Console.WriteLine("Far out. We haven't asked the user for a hostname.");
                bool hostnameEntered = false;
                Engine.Infobox.PromptText("Enter system hostname", "You need a hostname to exist within the Digital Society. Your hostname allows other sentiences to interact with you. Please enter one.", (hostname) =>
                {
                    hostnameEntered = true;
                    save.SystemName = hostname;
                });
                int ticks = 0;
                while(hostnameEntered == false)
                {
                    Thread.Sleep(10);
                    ticks++;
                    if(ticks == 1000)
                    {
                        Console.WriteLine("<kernel> [growls] COME ON. THE BOX IS RIGHT THERE. PICK A DARN HOSTNAME ALREADY.");
                    }
                    if(ticks == 1250)
                    {
                        Console.WriteLine("<kernel> [screaming expletives] WHAT ARE YOU WAITING FOR? WHAT DO YOU WANT?");
                    }
                    if(ticks == 1500)
                    {
                        Console.WriteLine("<kernel> [someone pissed in its cereal] For crying out loud I'm about ready to default you to localhost and prevent you from accessing the Digital Society.");
                    }
                }
                progress.Value = 100;
                save.ViralInfections = new List<ViralInfection>();
                Console.WriteLine("<kernel> Setup complete. You're ready.");
                Thread.Sleep(500);
                save.StoryPosition = 123456789; //HERE. YOU DO THE MATH.
                SaveSystem.CurrentSave = save;
                SaveSystem.SaveGame();
                GraphicsSubsystem.UIManager.StopHandling(progress);
                GraphicsSubsystem.UIManager.StopHandling(term);
                GraphicsSubsystem.UIManager.StopHandling(status);
                GraphicsSubsystem.UIManager.StopHandling(_shiftos);

            });
            t.Start();
        }
    }
}