Skip to content

Commit

Permalink
Merge pull request #22 from 9xbt/main
Browse files Browse the repository at this point in the history
Move all OOBE related stuff to OOBE.cs
  • Loading branch information
Owen2k6 authored Mar 19, 2023
2 parents a440788 + d0e1267 commit 5fbe69c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 45 deletions.
40 changes: 3 additions & 37 deletions GoOS/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ namespace GoOS
public class Kernel : Sys.Kernel
{
//Vars for OS
public string version = "1.5";
public string BuildType = "Beta";
public static string version = "1.5";
public static string BuildType = "Beta";
public bool cmdm = true;
public bool root = false;

Expand Down Expand Up @@ -152,45 +152,11 @@ protected override void BeforeRun()
}
if (!File.Exists(@"0:\content\sys\setup.gms"))
{
Console.WriteLine("GoOS is performing first boot...");
Console.WriteLine("initialising file system...");
Console.WriteLine("This may take some time.");
File.Create(@"0:\content\sys\version.gms");
File.Create(@"0:\content\sys\userinfo.gms");
File.Create(@"0:\content\sys\option-showprotectedfiles.gms");
File.Create(@"0:\content\sys\option-editprotectedfiles.gms");
File.Create(@"0:\content\sys\option-deleteprotectedfiles.gms");
var setupcontent = Sys.FileSystem.VFS.VFSManager.GetFile(@"0:\content\sys\version.gms");
var setupstream = setupcontent.GetFileStream();
if (setupstream.CanWrite)
{
byte[] textToWrite = Encoding.ASCII.GetBytes($"System.Version is set to {version} \n Note to users reading this: DO NOT ALTER. IMPORTANT IF USER DATA NEEDS CONVERTING.");
setupstream.Write(textToWrite, 0, textToWrite.Length);
}
else
{
CP737Console.Write("╔═══════════════════════ Alert! ═══════════════════════╗", 24, 10);
CP737Console.Write("║ ║", 24, 11);
CP737Console.Write("║ An error has occoured, system can not continue ║", 24, 12);
CP737Console.Write("║ Open a ticket on the discord server! ║", 24, 13);
CP737Console.Write("║ ║", 24, 13);
CP737Console.Write("╚══════════════════════════════════════════════════════╝", 24, 14);
Console.ReadKey();
bool pool = true;
while (pool)
{

}

}
OOBE.Open();
}
try
{
textcolour(ThemeManager.Default);
if (!File.Exists(@"0:\content\sys\setup.gms"))
{
OOBE.Open();
}
var systemsetup = File.ReadAllLines(@"0:\content\sys\setup.gms");
foreach (string line in systemsetup)
{
Expand Down
48 changes: 40 additions & 8 deletions GoOS/OOBE.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
using Cosmos.System.FileSystem.VFS;
using static System.ConsoleColor;
using static GoOS.Themes.ThemeManager;

Expand Down Expand Up @@ -118,21 +120,40 @@ public static void Write(string line, int x = -1, int y = -1)

public static void Open()
{
DrawFrame();
DrawTitle(" GoOS Setup ", 0);
MessageBox(1);
VFSManager.CreateFile(@"0:\content\sys\version.gms");
VFSManager.CreateFile(@"0:\content\sys\userinfo.gms");
VFSManager.CreateFile(@"0:\content\sys\option-showprotectedfiles.gms");
VFSManager.CreateFile(@"0:\content\sys\option-editprotectedfiles.gms");
VFSManager.CreateFile(@"0:\content\sys\option-deleteprotectedfiles.gms");
var setupcontent = VFSManager.GetFile(@"0:\content\sys\version.gms");
var setupstream = setupcontent.GetFileStream();
if (setupstream.CanWrite)
{
byte[] textToWrite = Encoding.ASCII.GetBytes($"System.Version is set to {Kernel.version} \n Note to users reading this: DO NOT ALTER. IMPORTANT IF USER DATA NEEDS CONVERTING.");
setupstream.Write(textToWrite, 0, textToWrite.Length);
}
else
{
MessageBox(2);
}
DrawPage(0);
DrawPage(1);
DrawPage(2);
MessageBox(0);
Sys.FileSystem.VFS.VFSManager.CreateFile(@"0:\content\sys\setup.gms");
var setupcontent = Sys.FileSystem.VFS.VFSManager.GetFile(@"0:\content\sys\setup.gms");
var setupstream = setupcontent.GetFileStream();
VFSManager.CreateFile(@"0:\content\sys\setup.gms");
var setupcontent1 = VFSManager.GetFile(@"0:\content\sys\setup.gms");
var setupstream1 = setupcontent1.GetFileStream();
if (setupstream.CanWrite)
{
byte[] textToWrite = Encoding.ASCII.GetBytes($"username: {usrn}\ncomputername: {cprn}");
setupstream.Write(textToWrite, 0, textToWrite.Length);
setupstream1.Write(textToWrite, 0, textToWrite.Length);
}
else
{
MessageBox(1);
MessageBox(2);
}
}

Expand Down Expand Up @@ -369,9 +390,21 @@ private static void MessageBox(int message)
DrawTitle(" Info ", 10);
Console.SetCursorPosition(31, 12);
Console.Write("Saving settings...");
Console.Clear();
}
else if (message == 1)
{
CP737Console.Write("╔════════════════════╗", 29, 10);
CP737Console.Write("║ ║", 29, 11);
CP737Console.Write("║ ║", 29, 12);
CP737Console.Write("║ ║", 29, 13);
CP737Console.Write("╚════════════════════╝", 29, 14);

Console.ForegroundColor = WindowText;
DrawTitle(" Info ", 10);
Console.SetCursorPosition(31, 12);
Console.Write("Preparing Setup...");
}
else if (message == 2)
{
CP737Console.Write("╔══════════════════════════════════════════════════════╗", 12, 10);
CP737Console.Write("║ ║", 12, 11);
Expand All @@ -383,8 +416,7 @@ private static void MessageBox(int message)
DrawTitle(" Info ", 10);
Console.SetCursorPosition(14, 12);
Console.Write("A serious error has occoured, setup cannot continue.");
Console.ReadKey();
Console.Clear();
while (true) { Console.ReadKey(true); } // Lock up
}
}
}
Expand Down

0 comments on commit 5fbe69c

Please sign in to comment.