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
|
Public Class Terminal
Public currentdir As String = root
Public prompttoupdatesave As Boolean = False
Dim trackpos As Integer = 0
Public Sub terminal_Innitiate(sender As Object, e As EventArgs) Handles MyBase.Load
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.WindowState = FormWindowState.Maximized
loadgame()
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
SelectBottom()
If prompttoupdatesave = True Then
AddLine("ShiftOS has encountered an error loading configuration files. Press any key to reset damaged files.")
End If
End Sub
Public Sub Interpret(command As String)
command = command.ToLower
If command Like "help" Then
ShowHelp()
ElseIf command Like "cd *" Then
If boughtdirectorysurfing = True Then
Dim folder As String = command.Replace("cd ", "")
If folder = ".." Then
If currentdir.ToLower = "c:\shiftos" Then
AddLine("cd: Error! You are at the root of your drive.")
Else
currentdir = IO.Directory.GetParent(currentdir).ToString
End If
Else
If IO.Directory.Exists(currentdir + "\" + folder) Then
currentdir = currentdir & "\" & folder
ElseIf IO.Directory.Exists(folder) Then
currentdir = folder
Else
AddLine("cd: Directory """ & folder & """ doesn't exist.")
End If
End If
Else
wrongcommand()
End If
ElseIf command = "dir" Or command = "ls" Then
If boughtdirectorysurfing Then
AddLine("Type | Name ")
AddLine("-------+-------------------------------------------")
For Each Dir As String In IO.Directory.GetDirectories(currentdir)
Dim dirinf As New IO.DirectoryInfo(Dir)
AddLine("[DIR] | " & dirinf.Name)
Next
For Each file As String In IO.Directory.GetFiles(currentdir)
Dim filinf As New IO.FileInfo(file)
AddLine(filinf.Extension & " | " & filinf.Name)
Next
Else
wrongcommand()
End If
ElseIf command Like "mkdir *" Then
If boughtdirectorysurfing = True Then
Dim foldertomake As String = command.Replace("mkdir ", "")
If IO.Directory.Exists(currentdir + "\" + foldertomake) Then
AddLine("Directory already exists!")
Else
IO.Directory.CreateDirectory(currentdir + "\" + foldertomake)
AddLine("mkdir: Directory created successfully.")
End If
Else
wrongcommand()
End If
ElseIf command Like "give me * codepoints" Then
Dim args() As String = command.Split(" ")
Dim cp As String = args(2)
AddCP(cp)
AddLine("Added " & cp & " to your existing ammount of Codepoints.")
ElseIf command Like "set * *" Then
Dim args() As String = command.Split(" ")
Select Case args(1)
Case "username"
If boughtcustomusername Then
username = args(2)
Else
wrongcommand()
End If
Case "textcolor"
If boughtterminalsettextcolor Then
Select Case args(2)
Case "black"
AddLine("Error! Black and black don't go too well...")
Case "white"
txtterm.ForeColor = Color.White
Case "gray"
If boughtgray Then
txtterm.ForeColor = Color.Gray
Else
AddLine("Error! Unsupported color.")
End If
Case "red"
If boughtred Then
txtterm.ForeColor = Color.Red
Else
AddLine("Error! Unsupported color.")
End If
Case "green"
If boughtgreen Then
txtterm.ForeColor = Color.Green
Else
AddLine("Error! Unsupported color.")
End If
Case "blue"
If boughtblue Then
txtterm.ForeColor = Color.Blue
Else
AddLine("Error! Unsupported color.")
End If
Case "yellow"
If boughtyellow Then
txtterm.ForeColor = Color.Yellow
Else
AddLine("Error! Unsupported color.")
End If
Case "orange"
If boughtorange Then
txtterm.ForeColor = Color.Orange
Else
AddLine("Error! Unsupported color.")
End If
Case "pink"
If boughtpink Then
txtterm.ForeColor = Color.Pink
Else
AddLine("Error! Unsupported color.")
End If
Case "purple"
If boughtpurple Then
txtterm.ForeColor = Color.Purple
Else
AddLine("Error! Unsupported color.")
End If
Case "brown"
If boughtbrown Then
txtterm.ForeColor = Color.Brown
Else
AddLine("Error! Unsupported color.")
End If
Case Else
AddLine("Error! Unsupported color, check 'colors' for a list of supported colors.")
End Select
End If
Case Else
AddLine("set: No valid setting node in configuration file for """ & args(1) & """.")
End Select
ElseIf command Like "open *" Then
Dim progtoopen As String = command.Replace("open ", "")
Select Case progtoopen
Case "shiftorium", "packages", "pacman", "code shop"
shiftorium_cmd.Show()
Case "files", "fileskimmer", "file skimmer", "fs", "file browser"
If boughtfileskimmer = True Then
file_skimmer.Show()
Else
AddLine("open: Invalid program """ & progtoopen & """.")
End If
Case "textpad", "text", "notepad"
If boughttextpad = True Then
TextPad.Show()
Else
AddLine("open: Invalid program """ & progtoopen & """.")
End If
Case Else
AddLine("open: Invalid program """ & progtoopen & """.")
End Select
ElseIf command Like "shutdown" Then
savegame()
Me.Close()
ElseIf command Like "math*" Then
mathquiz = True
changeinterpreter()
ElseIf command Like "guess the number" Or command Like "guess" Then
guessthenumber = True
changeinterpreter()
ElseIf command Like "code*" Or command = "code points" Then
AddLine("You have " & codepoints & " Codepoints.")
ElseIf command = "colors" Then
showterminalcolors()
ElseIf command Like "" Then
'This is here to make it so that the Terminal doesn't say "Wrong Command" if the user doesn't input anything.
Else
If IO.File.Exists(currentdir + "\" + command) Then
OpenFile(currentdir + "\" + command)
ElseIf IO.File.Exists(command) Then
OpenFile(command)
Else
wrongcommand()
End If
End If
End Sub
Dim firstuseconversation As Integer = 0
Private Sub tmrfirstuse_Tick(sender As Object, e As EventArgs) Handles tmrfirstuse.Tick
Select Case firstuseconversation
Case 0
txtterm.ReadOnly = True
AddLine("IP Address 170.245.12.80 is connecting as ""DevX"".")
Case 1
AddLine("DevX: It seems my updates have completly installed.")
Case 2
AddLine("DevX: Unfortunately, due to your hard drive being formatted, you have lost all your data.")
Case 3
AddLine("DevX: However, Don't worry! I've added some pretty cool features to the Terminal to make up for this.")
Case 4
AddLine("DevX: I can't tell you much, except for ""Type Help for a list of commands"".")
Case 5
AddLine("DevX: I've got to go, but I'll contact you as I develop more updates; and you test the OS.")
Case 6
AddLine("User ""DevX"" has disconnected.")
Case 7
txtterm.ResetText()
AddLine("user@shiftos ~$> ")
txtterm.ReadOnly = False
tmrfirstuse.Stop()
End Select
firstuseconversation += 1
End Sub
Private Sub txtterm_KeyDown(sender As Object, e As KeyEventArgs) Handles txtterm.KeyDown
If prompttoupdatesave = False Then
Select Case e.KeyCode
Case Keys.ShiftKey
trackpos = trackpos - 1
Case Keys.Alt
trackpos = trackpos - 1
Case Keys.CapsLock
trackpos = trackpos - 1
Case Keys.ControlKey
trackpos = trackpos - 1
Case Keys.LWin
trackpos = trackpos - 1
Case Keys.RWin
trackpos = trackpos - 1
Case Keys.Right
If txtterm.SelectionStart = txtterm.TextLength Then
trackpos = trackpos - 1
End If
Case Keys.Left
If trackpos < 1 Then
e.SuppressKeyPress = True
trackpos = trackpos - 1
Else
trackpos = trackpos - 2
End If
Case Keys.Up
e.SuppressKeyPress = True
trackpos = trackpos - 1
Case Keys.Down
e.SuppressKeyPress = True
trackpos = trackpos - 1
End Select
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
If mathquiz = True Then
Dim question As String = txtterm.Lines(txtterm.Lines.Length - 2)
Dim answer As String = txtterm.Lines(txtterm.Lines.Length - 1).Replace("> ", "")
If answer = "exit" Then
mathquiz = False
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
Else
Try
MQInterpret(question, answer)
Catch ex As Exception
AddLine("The answer provided isn't a proper number!")
End Try
AddLine("> ")
End If
ElseIf guessthenumber = True Then
Dim answer As String = txtterm.Lines(txtterm.Lines.Length - 1).Replace("> ", "")
If answer = "exit" Then
guessthenumber = False
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
Else
Try
GTNInterpret(answer)
Catch ex As Exception
AddLine("The answer provided isn't a proper number.")
End Try
AddLine("> ")
End If
Else
Dim command As String = txtterm.Lines(txtterm.Lines.Length - 1).Replace(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ", "").ToLower
Interpret(command)
If mathquiz Or guessthenumber Then
AddLine("> ")
Else
If command = "clear" Then
txtterm.Text = username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> "
txtterm.Select(txtterm.Text.Length, 0)
Else
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
txtterm.Select(txtterm.Text.Length, 0)
End If
End If
End If
trackpos = 0
Else
If e.KeyCode = Keys.Back Then
Else
trackpos = trackpos + 1
End If
End If
If e.KeyCode = Keys.Back Then
If trackpos < 1 Then
e.SuppressKeyPress = True
Else
If txtterm.SelectedText.Length < 1 Then
trackpos = trackpos - 1
Else
e.SuppressKeyPress = True
End If
End If
End If
SelectBottom()
Else
e.SuppressKeyPress = True
savegame()
loadgame()
AddLine("Self-repair complete with no errors.")
prompttoupdatesave = False
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
End If
End Sub
End Class
|