aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/OobeStory.cs
blob: 8d86b9e8bb4d2fb540679f758156a91730bac13b (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
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
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;

namespace ShiftOS.WinForms
{
    [Namespace("test")]
    public class OobeStory
    {
        [Command("test")]
        [RequiresArgument("num")]
        public static bool TestThingy(Dictionary<string, object> args)
        {
            long num = Convert.ToInt64(args["num"].ToString());
            string hex = num.ToString("X");
            string bin = Convert.ToString(num, 2);
            Console.WriteLine("Hex: " + hex);
            Console.WriteLine("Bin: " + bin);
            return true;
        }


        [Story("mud_fundamentals")]
        public static void DoStory()
        {
            Applications.Terminal term = null;
            TerminalBackend.PrefixEnabled = false;
            Desktop.InvokeOnWorkerThread(() =>
            {
                term = new Applications.Terminal();
                AppearanceManager.SetupWindow(term);
                ConsoleEx.Bold = true;
                ConsoleEx.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Welcome to ShiftOS.");
                Console.WriteLine();
                ConsoleEx.Bold = false;
                ConsoleEx.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Before we can bring you to your new system, we must perform some system tasks.");
                Console.WriteLine();
                Console.WriteLine("Here's the installation outline.");
                Console.WriteLine();
                Console.Write(" - ");
                ConsoleEx.Bold = true;
                Console.Write("Storage preparation");
                ConsoleEx.Bold = false;
                Console.Write(" First, we have to prepare your computer's storage device for ShiftOS. This \r\nincludes formatting your drive with the ShiftFS file \r\nsystem, creating system directories, and generating system files.");
                Console.WriteLine();
                Console.Write(" - ");
                ConsoleEx.Bold = true;
                Console.Write("User configuration");
                ConsoleEx.Bold = false;
                Console.Write(" Next it's up to you to set up a system hostname, create a user account, and personalize it.");
                Console.WriteLine();
                Console.Write(" - ");
                ConsoleEx.Bold = true;
                Console.Write("System tutorial");
                ConsoleEx.Bold = false;
                Console.WriteLine("Finally, we'll teach you how to use ShiftOS.");

                Console.WriteLine();

                ConsoleEx.Bold = true;
                ConsoleEx.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Let's get started!");
            });
            int position = 0;

            Thread.Sleep(5000);

            ConsoleEx.Bold = true;
            Console.WriteLine("System preparation");


            Console.WriteLine();
            ConsoleEx.Bold = false;
            ConsoleEx.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(@"We'll now begin formatting your drive. Please be patient.");
            Console.WriteLine();
            var dinf = new DriveInfo("C:\\");
            decimal bytesFree = ((dinf.AvailableFreeSpace / 1024) / 1024) / 1024;
            decimal totalBytes = ((dinf.TotalSize / 1024) / 1024) / 1024;
            string type = dinf.DriveType.ToString();
            string name = dinf.Name;
            ConsoleEx.Bold = true;
            Console.Write("Drive name: ");
            ConsoleEx.Bold = false;
            Console.WriteLine(name);
            ConsoleEx.Bold = true;
            Console.Write("Drive type: ");
            ConsoleEx.Bold = false;
            Console.WriteLine(type);
            ConsoleEx.Bold = true;
            Console.Write("Total space: ");
            ConsoleEx.Bold = false;
            Console.WriteLine(totalBytes.ToString() + " GB");
            ConsoleEx.Bold = true;
            Console.Write("Free space: ");
            Console.WriteLine(bytesFree.ToString() + " GB");
            Console.WriteLine();


            ConsoleEx.Bold = false;
            ConsoleEx.BackgroundColor = ConsoleColor.Black;
            Console.Write("Formatting: [");
            ConsoleEx.OnFlush?.Invoke();
            int formatProgress = 3;
            while (formatProgress <= 100)
            {
                if (formatProgress % 3 == 0)
                {
                    ConsoleEx.BackgroundColor = ConsoleColor.White;
                    Console.Write(" ");
                    ConsoleEx.OnFlush?.Invoke();
                    ConsoleEx.BackgroundColor = ConsoleColor.Black;
                }
                Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.typesound));
                formatProgress++;
                Thread.Sleep(175);
            }
            Console.WriteLine("] ..done.");
            Thread.Sleep(1000);
            ConsoleEx.Bold = true;
            Console.WriteLine("Creating directories...");
            ConsoleEx.Bold = false;
            foreach (var dir in Paths.GetAllWithoutKey())
            {
                if (!dir.Contains(".") && dir.StartsWith("0:/"))
                {
                    Console.WriteLine("Creating: " + dir);
                    Thread.Sleep(125);
                    Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.writesound));
                }
            }
            Console.WriteLine();
            Console.WriteLine("Next, let's get user information.");
            Console.WriteLine();
            ShiftOS.Engine.OutOfBoxExperience.PromptForLogin();
        }

        private static bool isValid(string text, string chars)
        {
            foreach(var c in text)
            {
                if (!chars.Contains(c))
                    return false;
            }
            return true;
        }
    }
}