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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
|
/*
* MIT License
*
* Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
using ShiftOS.Engine;
using ShiftOS.Objects;
using ShiftOS.Objects.ShiftFS;
using ShiftOS.Unite;
using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms
{
public partial class Oobe : Form, IOobe, ITutorial
{
public Oobe()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.BackColor = Color.Black;
this.Load += (o, a) =>
{
ControlManager.SetupControls(this);
};
}
string rtext;
string gtexttotype;
int charcount;
int slashcount;
Label textgeninput;
public bool upgraded = false;
private bool typing = false;
public void TextType(string texttotype)
{
textgeninput.TextAlign = ContentAlignment.MiddleCenter;
while(typing == true)
{
//JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
charcount = texttotype.Length;
gtexttotype = texttotype;
slashcount = 1;
foreach (var c in gtexttotype)
{
typing = true;
rtext += c;
this.Invoke(new Action(() =>
{
textgeninput.Text = rtext + "|";
}));
slashcount++;
if (slashcount == 5)
slashcount = 1;
Thread.Sleep(50);
}
rtext += Environment.NewLine;
typing = false;
}
public Save MySave = null;
public event EventHandler OnComplete;
private int tutPrg = 0;
public int TutorialProgress
{
get
{
return tutPrg;
}
set
{
tutPrg = value;
}
}
public void StartShowing(Save save)
{
var t = new Thread(new ThreadStart(() =>
{
try
{
textgeninput = this.lblhackwords;
this.Invoke(new Action(() =>
{
lblHijack.Hide();
}));
TextType(@"Throughout many years, man has tried to develop
a digital environment usable by anyone that never goes
offline, full of AIs and humans alike, thinking, interacting,
innovating.
No one has ever come close to a digital society of such
properties yet, except for one sentient being. It does not
have a life, a gender, an age or a body, but simply one name.
They call it ""DevX"".
If anyone sees this message, my identity is anonymous, but I
need your help. I am trapped within ""DevX""'s digital society
with no way out, constantly under attack.
You must join the digital society, rise up the ranks, and save us.
- undisclosed_0x1DDFB5977.");
Thread.Sleep(5000);
while(this.Opacity > 0f)
{
this.Invoke(new Action(() =>
{
this.Opacity -= 0.01f;
}));
Thread.Sleep(25);
}
Story.Start("mud_fundamentals");
this.Invoke(new Action(this.Close));
}
catch (Exception e)
{
TextType("I have experienced an error.");
TextType(e.ToString());
}
}));
this.Show();
this.BringToFront();
this.TopMost = true;
t.IsBackground = true;
t.Start();
}
public void Clear()
{
this.Invoke(new Action(() =>
{
rtext = "";
textgeninput.Text = "";
}));
}
public void ShowSaveTransfer(Save save)
{
this.Show();
var fSetup = new FakeSetupScreen(this, 7);
var t = new Thread(() =>
{
textgeninput = lblhackwords;
Clear();
TextType("Welcome back to ShiftOS.");
Thread.Sleep(500);
TextType("Since your last time inside ShiftOS, the operating system has changed. Your user account is no longer stored on your local system.");
Thread.Sleep(500);
this.Invoke(new Action(() =>
{
//UPS is drunky heaven over here... it's a liquor store, I think... - Drunk Michael
fSetup.UserReregistered += (u, p, s) =>
{
save.Username = u;
save.Password = p;
save.SystemName = s;
SaveSystem.CurrentSave = save;
SaveSystem.CurrentSave.Upgrades = new Dictionary<string, bool>();
Shiftorium.Init();
SaveSystem.SaveGame();
if(Utils.FileExists(Paths.SaveFileInner))
Utils.Delete(Paths.SaveFileInner);
this.Close();
};
fSetup.Show();
}));
});
t.IsBackground = true;
t.Start();
}
public void PerformUniteLogin()
{
}
public void PromptForLogin()
{
Infobox.Show("Login", "Since the last time you've played ShiftOS, some changes have been made to the login system. You must now login using your website credentials.", () =>
{
Infobox.PromptYesNo("Website account", "Do you have an account at http://getshiftos.ml?", (hasAccount) =>
{
if(hasAccount == true)
{
var loginDialog = new UniteLoginDialog((success)=>
{
string token = success;
var uClient = new UniteClient("http://getshiftos.ml", token);
Infobox.Show("Welcome to ShiftOS.", $"Hello, {uClient.GetDisplayName()}! We've signed you into your account. We'll now try to link your ShiftOS account with your save file.", () =>
{
ServerMessageReceived smr = null;
smr = (msg) =>
{
ServerManager.MessageReceived -= smr;
if (msg.Name == "mud_savefile")
{
SaveSystem.CurrentSave = JsonConvert.DeserializeObject<Save>(msg.Contents);
SaveSystem.SaveGame();
}
else
{
LinkSaveFile(token);
}
};
ServerManager.MessageReceived += smr;
ServerManager.SendMessage("mud_token_login", token);
});
});
AppearanceManager.SetupDialog(loginDialog);
}
else
{
var signupDialog = new UniteSignupDialog((token) =>
{
ServerMessageReceived smr = null;
smr = (msg) =>
{
ServerManager.MessageReceived -= smr;
if (msg.Name == "mud_savefile")
{
SaveSystem.CurrentSave = JsonConvert.DeserializeObject<Save>(msg.Contents);
SaveSystem.SaveGame();
}
else
{
LinkSaveFile(token);
}
};
ServerManager.MessageReceived += smr;
ServerManager.SendMessage("mud_token_login", token);
});
AppearanceManager.SetupDialog(signupDialog);
}
});
});
}
public void LinkSaveFile(string token)
{
if (Utils.FileExists(Paths.GetPath("user.dat")))
{
try
{
var details = JsonConvert.DeserializeObject<ClientSave>(Utils.ReadAllText(Paths.GetPath("user.dat")));
ServerMessageReceived smr = null;
bool msgreceived = false;
bool found = false;
smr = (msg) =>
{
if (msg.Name == "mud_savefile")
{
var save = JsonConvert.DeserializeObject<Save>(msg.Contents);
save.UniteAuthToken = token;
Infobox.Show("Migration complete.", "We have migrated your old save file to the new system successfully. You can still log in using the old system on old builds of ShiftOS.", () =>
{
SaveSystem.CurrentSave = save;
SaveSystem.SaveGame();
found = true;
msgreceived = true;
});
}
else
{
found = false;
msgreceived = true;
}
ServerManager.MessageReceived -= smr;
};
ServerManager.MessageReceived += smr;
ServerManager.SendMessage("mud_login", JsonConvert.SerializeObject(new
{
username = details.Username,
password = details.Password
}));
while (msgreceived == false)
Thread.Sleep(10);
if (found)
return;
}
catch
{
}
}
var client = new UniteClient("http://getshiftos.ml", token);
var sve = new Save();
sve.Username = client.GetEmail();
sve.Password = Guid.NewGuid().ToString();
sve.SystemName = client.GetSysName();
sve.UniteAuthToken = token;
sve.Codepoints = 0;
sve.Upgrades = new Dictionary<string, bool>();
sve.ID = Guid.NewGuid();
Infobox.Show("Welcome to ShiftOS.", "Welcome to ShiftOS, " + client.GetDisplayName() + ". We have created a save file for you. Now, go on and Shift It Your Way.", () =>
{
sve.StoryPosition = 8675309;
SaveSystem.CurrentSave = sve;
SaveSystem.SaveGame();
});
}
public void ForceReboot()
{
string json = Utils.ExportMount(0);
System.IO.File.WriteAllText(Paths.SaveFile, json);
System.Diagnostics.Process.Start(Application.ExecutablePath);
Environment.Exit(0);
}
public void StartTrailer()
{
while(AppearanceManager.OpenForms.Count > 0)
{
AppearanceManager.OpenForms[0].Close();
}
this.Show();
this.TopMost = true;
this.TransparencyKey = Color.Magenta;
this.BackColor = this.TransparencyKey;
textgeninput = lblHijack;
textgeninput.BackColor = Color.Black;
textgeninput.Font = new Font("Lucida Console", 13F, FontStyle.Bold);
textgeninput.AutoSize = true;
textgeninput.TextAlign = ContentAlignment.MiddleCenter;
textgeninput.TextChanged += (o, a) =>
{
textgeninput.Location = new Point(
(this.Width - textgeninput.Width) / 2,
(this.Height - textgeninput.Height) / 2
);
};
var t = new Thread(() =>
{
Clear();
Thread.Sleep(5000);
TextType("Michael VanOverbeek");
TextType("presents...");
Thread.Sleep(2000);
Clear();
Thread.Sleep(1000);
TextType("A community-developed game");
Thread.Sleep(3000);
Clear();
Thread.Sleep(1000);
this.Invoke(new Action(() =>
{
textgeninput.Font = new Font("Lucida Console", 14F, FontStyle.Bold);
this.BackColor = Color.Black;
}));
TextType("Welcome to ShiftOS.");
Thread.Sleep(4000);
Clear();
textgeninput = lblhackwords;
TextType("Hello.");
Thread.Sleep(500);
TextType("You have been cordially and involuntarily selected to participate in the development and testing of an experimental operating system called ShiftOS.");
Thread.Sleep(500);
TextType("I want ShiftOS to be the most advanced operating system in the world.");
Thread.Sleep(500);
TextType("In ShiftOS, you start out with nothing.");
Thread.Sleep(500);
TextType("And your goal is to upgrade the operating system from a barebones command line to a fully graphical operating system.");
Thread.Sleep(500);
TextType("Along the way, you'll meet many people - hackers, rebels, programmers, administrators and many more.");
Thread.Sleep(500);
TextType("You'll meet new friends and foes.");
Thread.Sleep(500);
TextType("Your goal: Take it over. Upgrade the operating system, and take over its multi-user domain.");
Thread.Sleep(500);
TextType("I won't reveal quite what you have to do, but if you can handle it, head over to http://getshiftos.ml/ and download the operating system now.");
Thread.Sleep(5000);
Clear();
textgeninput = lblHijack;
TextType("Think you can handle it?");
});
t.IsBackground = false;
t.Start();
}
public void Start()
{
Shiftorium.Silent = false;
foreach(var frm in AppearanceManager.OpenForms)
{
(frm as Form).Invoke(new Action(() => {
frm.Close();
}));
}
TerminalBackend.CommandProcessed += (cmd, args) =>
{
if(cmd == "sos.help")
{
if (TutorialProgress == 0)
TutorialProgress = 1;
}
else if(cmd == "sos.status")
{
if (TutorialProgress == 1)
TutorialProgress = 2;
}
else if(cmd == "shiftorium.list")
{
if (TutorialProgress == 2)
{
TutorialProgress = 3;
SaveSystem.TransferCodepointsFrom("sys", 50);
}
}
else if(cmd == "shiftorium.info" && args == "{\"upgrade\":\"mud_fundamentals\"}")
{
if (TutorialProgress == 3)
TutorialProgress = 4;
}
else if(cmd == "win.open")
{
if (TutorialProgress == 4)
TutorialProgress = 5;
}
};
if(this.Visible == false)
this.Show();
var t = new Thread(() =>
{
textgeninput = lblHijack;
Clear();
textgeninput = lblhackwords;
Clear();
this.Invoke(new Action(() =>
{
textgeninput.Font = SkinEngine.LoadedSkin.TerminalFont;
}));
TextType("ShiftOS has been installed successfully.");
Thread.Sleep(500);
TextType("Before you can continue to the operating system, here's a little tutorial on how to use it.");
Thread.Sleep(500);
TextType("Starting a Terminal...");
Applications.Terminal term = null;
this.Invoke(new Action(() =>
{
term = new Applications.Terminal();
this.Controls.Add(term);
term.Location = new Point(
(this.Width - term.Width) / 2,
(this.Height - term.Height) / 2
);
term.Show();
term.OnLoad();
term.OnSkinLoad();
term.OnUpgrade();
}));
TextType("This little text box is called a Terminal.");
Thread.Sleep(500);
TextType("Normally, it would appear in full-screen, but this window is hosting it as a control so you can see this text as well.");
Thread.Sleep(500);
TextType("In ShiftOS, the Terminal is your main control centre for the operating system. You can see system status, check Codepoints, open other programs, buy upgrades, and more.");
Thread.Sleep(500);
TextType("Go ahead and type 'sos.help' to see a list of commands.");
while (TutorialProgress == 0)
{
//JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
TextType("As you can see, sos.help gives you a list of all commands in the system.");
Thread.Sleep(500);
TextType("You can run any command, by typing in their Namespace, followed by a period (.), followed by their Command Name.");
Thread.Sleep(500);
TextType("Go ahead and run the 'status' command within the 'sos' namespace to see what the command does.");
while (TutorialProgress == 1)
{
//JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
TextType("Brilliant. The sos.status command will tell you how many Codepoints you have, as well as how many upgrades you have installed and how many are available.");
Thread.Sleep(500);
TextType("Codepoints, as you know, are a special currency within ShiftOS. They are used to buy things within the multi-user domain, such as upgrades, scripts, and applications.");
Thread.Sleep(500);
TextType("You can earn Codepoints by doing things in ShiftOS - such as completing jobs for other users, making things like skins, scripts, documents, etc, and playing games like Pong.");
Thread.Sleep(500);
TextType("At times, you'll be given Codepoints to help complete a task. You will receive Codepoints from 'sys' - the multi-user domain itself.");
//SaveSystem.TransferCodepointsFrom("sys", 50);
TextType("Right now, you don't have any upgrades. Upgrades can give ShiftOS additional features and capabilities - like new core applications, supported file types, and new Terminal commands.");
Thread.Sleep(500);
TextType("You can easily get upgrades using the Shiftorium - a repository of approved ShiftOS upgrades.");
Thread.Sleep(500);
TextType("To start using the Shiftorium, simply type 'shiftorium.list' to see available upgrades.");
while (TutorialProgress == 2)
{
//JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
Clear();
TextType("Right now, you have enough Codepoints to buy the 'mud_fundamentals' upgrade. You can use shiftorium.info to see information about this upgrade.");
Thread.Sleep(500);
TextType("Some commands, like shiftorium.info, require you to pass information to them in the form of arguments.");
Thread.Sleep(500);
TextType("Argument pairs sit at the end of the command, and are enclosed in curly braces.");
Thread.Sleep(500);
TextType("Inside these curly braces, you can input an argument key, followed by a colon, followed by the value. Then, if you need multiple arguments, you can put a comma after the value, and then insert another argument pair.");
Thread.Sleep(500);
TextType("There are different value types - numeric values, which can be any positive or negative 32-bit integer");
Thread.Sleep(500);
TextType("Then there are boolean values which can be either 'true' or 'false'");
Thread.Sleep(500);
TextType("Then there are string values, which are enclosed in double-quotes.");
Thread.Sleep(500);
TextType(" If for some reason you need to use a double-quote inside a string, you must escape it using a single backslash followed by the quote, like this: key:\"My \\\"awesome\\\" value.\"");
Thread.Sleep(500);
TextType("If you want to escape a backslash inside a string, simply type two backslashes instead of one - for example key:\"Back\\\\slash.\"");
Thread.Sleep(500);
TextType("shiftorium.info requires an upgrade argument, which is a string type. Go ahead and give shiftorium.info's upgrade argument the 'mud_fundamentals' upgrade's ID.");
while (TutorialProgress == 3)
{
//JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
TextType("As you can see, mud_fundamentals is very useful. In fact, a lot of useful upgrades depend on it. You should buy it!");
Thread.Sleep(500);
TextType("shiftorium.info already gave you a command that will let you buy the upgrade - go ahead and run that command!");
while (!Shiftorium.UpgradeInstalled("mud_fundamentals"))
{ //JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
TextType("Hooray! You now have the MUD Fundamentals upgrade.");
Thread.Sleep(500);
TextType("You can also earn more Codepoints by playing Pong. To open Pong, you can use the win.open command.");
Thread.Sleep(500);
TextType("If you run win.open without arguments, you can see a list of applications that you can open.");
Thread.Sleep(500);
TextType("Just run win.open without arguments, and this tutorial will be completed!");
while (TutorialProgress == 4)
{
//JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
TextType("This concludes the ShiftOS beginners' guide brought to you by the multi-user domain. Stay safe in a connected world.");
Thread.Sleep(2000);
Desktop.InvokeOnWorkerThread(() =>
{
OnComplete?.Invoke(this, EventArgs.Empty);
SaveSystem.CurrentSave.StoryPosition = 2;
this.Close();
SaveSystem.SaveGame();
AppearanceManager.SetupWindow(new Applications.Terminal());
});
});
t.IsBackground = true;
t.Start();
}
}
}
|