diff --git a/GoOS/9xCode/Interpreter.cs b/GoOS/9xCode/Interpreter.cs index 87ffd64406..91457384a2 100644 --- a/GoOS/9xCode/Interpreter.cs +++ b/GoOS/9xCode/Interpreter.cs @@ -8,6 +8,7 @@ using static ConsoleColorEx; using Console = BetterConsole; using ConsoleColor = PrismAPI.Graphics.Color; +using static GoOS.Resources; // 9xCode Beta 3.1 // Licensed under the MIT license @@ -17,16 +18,20 @@ namespace GoOS._9xCode { public static partial class Interpreter { + public const string Version = "b3.1"; + public static void Run(string file) { if (!File.Exists(file)) { - HandleError("9xCode", "Script doesn't exist!"); + HandleError("9xCode", "Script not found!"); } Console.Title = $"{file.Substring(file.LastIndexOf(@"\")).Replace(".9xc", "")} - 9xCode"; Console.ForegroundColor = White; Interpret(File.ReadAllLines(file)); + Console.Title = "GTerm"; + Console.ForegroundColor = White; } private static bool Interpreting = false; @@ -36,14 +41,14 @@ private static void Interpret(string[] code) Interpreting = true; Console.ForegroundColor = Cyan; - Console.WriteLine("Mobren 9xCode Interpreter Version b3.1\n"); + Console.WriteLine($"Mobren 9xCode Interpreter Version {Version}\n"); Console.ForegroundColor = White; bool SysLib = false, ConsoleLib = false, IOLib = false, TimeLib = false, _9xGLLib = false, GoOSLib = false; Dictionary Booleans = new Dictionary() { }; Dictionary Integers = new Dictionary() { }; - Dictionary Strings = new Dictionary() { { "Version", "b3.0" } }; + Dictionary Strings = new Dictionary() { { "Version", Version } }; Dictionary Colors = new Dictionary() { }; Dictionary Windows = new Dictionary(); @@ -143,7 +148,13 @@ private static void Interpret(string[] code) { string sub = line.Substring(7); - if (sub.StartsWith("System")) + if (sub.StartsWith("*")) + { + SysLib = true; ConsoleLib = true; IOLib = true; TimeLib = true; _9xGLLib = true; GoOSLib = true; + continue; + } + + else if (sub.StartsWith("System")) { SysLib = true; continue; @@ -181,7 +192,7 @@ private static void Interpret(string[] code) else { - HandleError("Error", "Unknown library."); + HandleError("Error", $"Unknown library at line {i + 1}!"); } } @@ -198,7 +209,7 @@ private static void Interpret(string[] code) { if (key == "Cursor") { - HandleError("Error", "Console library not imported"); + HandleError("Error", $"Console library not imported at line {i + 1}!"); break; } } @@ -282,7 +293,7 @@ private static void Interpret(string[] code) } else { - HandleError("Syntax Error", "Unknown Color."); + HandleError("Syntax Error", $"Unknown Color at line {i + 1}!"); } continue; } @@ -318,7 +329,7 @@ private static void Interpret(string[] code) { if (sub.StartsWith("CursorX") || sub.StartsWith("CursorY")) { - HandleError("Error", "Console library not imported"); + HandleError("Error", $"Console library not imported at line {i + 1}!"); break; } } @@ -343,7 +354,7 @@ private static void Interpret(string[] code) { if (sub.StartsWith("Seconds") || sub.StartsWith("Minutes") || sub.Equals("Hours")) { - HandleError("Error", "Time library not imported"); + HandleError("Error", $"Time library not imported at line {i + 1}!"); break; } } @@ -379,7 +390,7 @@ private static void Interpret(string[] code) if (!Integers.TryGetValue(key, out int intval)) { - HandleError("Error", "Unknown variable."); + HandleError("Error", $"Unknown variable at line {i + 1}!"); break; } @@ -396,7 +407,7 @@ private static void Interpret(string[] code) if (!Integers.TryGetValue(key, out int intval)) { - HandleError("Error", "Unknown variable."); + HandleError("Error", $"Unknown variable at line {i + 1}!"); break; } @@ -436,7 +447,7 @@ private static void Interpret(string[] code) { if (line.Substring(line.IndexOf("= ") + 2).StartsWith("ReadFile")) { - HandleError("Error", "IO library not imported"); + HandleError("Error", $"IO library not imported at line {i + 1}!"); break; } } @@ -458,7 +469,7 @@ private static void Interpret(string[] code) } else if (line.Substring(line.IndexOf("= ") + 2).StartsWith("Read")) { - Strings.Add(key, Console.ReadKey(true).Key.ToString()); + Strings.Add(key, Console.ReadKey(true).KeyChar.ToString()); } else { @@ -497,12 +508,12 @@ private static void Interpret(string[] code) if (args2.Length < 3) { - HandleError("Error", "Argument underflow."); + HandleError("Error", $"Argument underflow at line {i + 1}!"); break; } if (args2.Length > 3) { - HandleError("Error", "Argument overflow."); + HandleError("Error", $"Argument overflow at line {i + 1}!"); break; } @@ -582,7 +593,7 @@ private static void Interpret(string[] code) else if (Strings.TryGetValue(comparation[0].Trim(), out string strval)) { comparation[1] = comparation[1].Substring(comparation[1].IndexOf('"') + 1, comparation[1].LastIndexOf('"') - 2); - if (comparation[1] != strval) + if (comparation[1] != strval) { i = endif + 1; } @@ -797,24 +808,80 @@ private static void Interpret(string[] code) #region 9xGL Library + else if (_9xGLLib && line.StartsWith("DrawLine") && line.Contains(">>")) + { + string[] args = line.Split('>')[2].Trim().Split(','); + + if (args.Length < 6) + { + HandleError("Error", $"Argument underflow at line {i + 1}!"); + break; + } + if (args.Length > 6) + { + HandleError("Error", $"Argument overflow at line {i + 1}!"); + break; + } + + if (!Windows.TryGetValue(args[0].Trim(), out Window wndval)) + { + HandleError("Error", $"Unknown variable at line {i + 1}!"); + break; + } + + if (!Integers.TryGetValue(args[1].Trim(), out int xval)) + { + xval = Convert.ToInt32(args[1].Trim()); + } + + if (!Integers.TryGetValue(args[2].Trim(), out int yval)) + { + yval = Convert.ToInt32(args[2].Trim()); + } + + if (!Integers.TryGetValue(args[3].Trim(), out int xval2)) + { + xval2 = Convert.ToInt32(args[3].Trim()); + } + + if (!Integers.TryGetValue(args[4].Trim(), out int yval2)) + { + yval2 = Convert.ToInt32(args[4].Trim()); + } + + if (!Colors.TryGetValue(args[5].Trim(), out Color colval)) + { + if (StringToConsoleColor.TryGetValue(args[5].Trim(), out Color colval2)) + { + colval = colval2; + } + else + { + HandleError("Syntax Error", $"Unknown Color at line {i + 1}!"); + } + } + + wndval.Contents.DrawLine(xval, yval, xval2, yval2, colval); + } + else if (_9xGLLib && line.StartsWith("DrawString") && line.Contains(">>")) { string[] args = line.Split('>')[2].Trim().Split(','); if (args.Length < 5) { - HandleError("Error", "Argument underflow."); + HandleError("Error", $"Argument underflow at line {i + 1}!"); break; } if (args.Length > 5) { - HandleError("Error", "Argument overflow."); + HandleError("Error", $"Argument overflow at line {i + 1}!"); break; } if (!Windows.TryGetValue(args[0].Trim(), out Window wndval)) { - HandleError("Error", "Unknown variable."); + HandleError("Error", $"Unknown variable at line {i + 1}!"); break; } @@ -826,7 +893,7 @@ private static void Interpret(string[] code) } else { - HandleError("Error", "Unknown variable."); + HandleError("Error", $"Unknown variable at line {i + 1}!"); break; } } @@ -849,11 +916,12 @@ private static void Interpret(string[] code) } else { - HandleError("Syntax Error", "Unknown Color."); + HandleError("Syntax Error", $"Unknown Color at line {i + 1}!"); } } - wndval.Contents.DrawString(xval, yval, strval, Fonts.Font_1x, colval); + wndval.Contents.DrawFilledRectangle(xval, xval, Convert.ToUInt16(strval.Length * 8), 16, 0, Color.LightGray); + wndval.Contents.DrawString(xval, yval, strval, Font_1x, colval); } else if (_9xGLLib && line.StartsWith("SetWindowPos") && line.Contains(">>")) @@ -862,37 +930,29 @@ private static void Interpret(string[] code) if (args.Length < 3) { - HandleError("Error", "Argument underflow."); + HandleError("Error", $"Argument underflow at line {i + 1}!"); break; } if (args.Length > 3) { - HandleError("Error", "Argument overflow."); + HandleError("Error", $"Argument overflow at line {i + 1}!"); break; } if (!Windows.TryGetValue(args[0].Trim(), out Window wndval)) { - HandleError("Error", "Unknown variable."); + HandleError("Error", $"Unknown variable at line {i + 1}!"); break; } - if (Integers.TryGetValue(args[1].Trim(), out int xval)) - { - wndval.X = xval; - } - else + if (!Integers.TryGetValue(args[1].Trim(), out int xval)) { - wndval.X = Convert.ToInt32(args[1].Trim()); + xval = Convert.ToInt32(args[1].Trim()); } - if (Integers.TryGetValue(args[2].Trim(), out int yval)) + if (!Integers.TryGetValue(args[2].Trim(), out int yval)) { - wndval.Y = yval; - } - else - { - wndval.Y = Convert.ToInt32(args[2].Trim()); + yval = Convert.ToInt32(args[2].Trim()); } wndval.X = xval; @@ -903,15 +963,7 @@ private static void Interpret(string[] code) #region GoOS Library - else if (GoOSLib && line.StartsWith("EnableKillingSystemTasks")) - { - GUI.Apps.TaskManager.pko = true; - } - else if (GoOSLib && line.StartsWith("DisableKillingSystemTasks")) - { - GUI.Apps.TaskManager.pko = false; - } else if (GoOSLib && line.StartsWith("RegProg") && line.Contains(">>")) { @@ -919,12 +971,12 @@ private static void Interpret(string[] code) if (args.Length < 1) { - HandleError("Error", "Argument underflow."); + HandleError("Error", $"Argument underflow at line {i + 1}!"); break; } if (args.Length > 1) { - HandleError("Error", "Argument overflow."); + HandleError("Error", $"Argument overflow at line {i + 1}!"); break; } @@ -936,7 +988,7 @@ private static void Interpret(string[] code) } else { - HandleError("Error", "Unknown variable."); + HandleError("Error", $"Unknown variable at line {i + 1}!"); break; } } @@ -951,12 +1003,12 @@ private static void Interpret(string[] code) else { - HandleError("Syntax Error", "Unknown function.\nMaybe try importing a library?"); + HandleError("Syntax Error", $"Unknown function at line {i + 1}.\nHave you forgotten to import a library?"); } } catch (Exception ex) { - HandleError("9xCode", "Unhandled exception in runtime:\n" + ex.Message); + HandleError("9xCode", $"Unhandled exception in runtime at line {i + 1}:\n" + ex.Message); } } } diff --git a/GoOS/BetterConsole/BetterConsole.cs b/GoOS/BetterConsole/BetterConsole.cs index 5b7287749c..9b4675d2bf 100644 --- a/GoOS/BetterConsole/BetterConsole.cs +++ b/GoOS/BetterConsole/BetterConsole.cs @@ -4,26 +4,14 @@ using Cosmos.System; using GoOS.GUI; using GoOS.Themes; -using IL2CPU.API.Attribs; using PrismAPI.Graphics; -using PrismAPI.Graphics.Fonts; +using static GoOS.Resources; /// /// class /// public static class BetterConsole { - /* The raw global font */ - [ManifestResourceStream(ResourceName = "GoOS.Resources.Font_1x.btf")] - public static byte[] rawFont; - - /* The credits easter egg */ - [ManifestResourceStream(ResourceName = "GoOS.Resources.Credits05.bmp")] - private static byte[] easterEgg; - - /* The global font */ - public static Font font; - /* The canvas for the console */ public static Canvas Canvas; @@ -94,7 +82,6 @@ public static class BetterConsole /// The height of the canvas public static void Init(ushort width, ushort height) { - font = new Font(rawFont, charHeight); //Canvas = Display.GetDisplay(width, height); Canvas = new Canvas(width, height); WindowWidth = Convert.ToUInt16(width / charWidth); @@ -165,7 +152,7 @@ public static ConsoleKeyInfo ReadKey(bool intercept = true) { if (CursorVisible) { - Canvas.DrawString(CursorLeft * charWidth, CursorTop * charHeight, '_'.ToString(), font, ForegroundColor); + Canvas.DrawString(CursorLeft * charWidth, CursorTop * charHeight, '_'.ToString(), Font_1x, ForegroundColor); } var keyPressed = KeyBuffer.TryDequeue(out var key); @@ -190,10 +177,10 @@ public static ConsoleKeyInfo ReadKey(bool intercept = true) if (CursorVisible) { // Just to be safe - Canvas.DrawString((CursorLeft - 1) * charWidth, CursorTop * charHeight, '_'.ToString(), font, Color.Black); - Canvas.DrawString((CursorLeft + 1) * charWidth, CursorTop * charHeight, '_'.ToString(), font, Color.Black); - Canvas.DrawString(CursorLeft * charWidth, (CursorTop - 1) * charHeight, '_'.ToString(), font, Color.Black); - Canvas.DrawString(CursorLeft * charWidth, (CursorTop + 1) * charHeight, '_'.ToString(), font, Color.Black); + Canvas.DrawString((CursorLeft - 1) * charWidth, CursorTop * charHeight, '_'.ToString(), Font_1x, Color.Black); + Canvas.DrawString((CursorLeft + 1) * charWidth, CursorTop * charHeight, '_'.ToString(), Font_1x, Color.Black); + Canvas.DrawString(CursorLeft * charWidth, (CursorTop - 1) * charHeight, '_'.ToString(), Font_1x, Color.Black); + Canvas.DrawString(CursorLeft * charWidth, (CursorTop + 1) * charHeight, '_'.ToString(), Font_1x, Color.Black); } } } @@ -273,7 +260,7 @@ public static string ReadLine() if (key.Key == ConsoleKeyEx.G) { string collected = Heap.Collect() + " items collected"; - Canvas.DrawString(Canvas.Width - (collected.Length * 8) - 8, Canvas.Height - 32, collected, font, ThemeManager.WindowText); + Canvas.DrawString(Canvas.Width - (collected.Length * 8) - 8, Canvas.Height - 32, collected, Font_1x, ThemeManager.WindowText); Write(returnValue); } else if (key.Key == ConsoleKeyEx.L) @@ -289,7 +276,7 @@ public static string ReadLine() if (input == "e015") { Clear(); - Canvas.DrawImage(0, 0, Image.FromBitmap(easterEgg, false), false); + Canvas.DrawImage(0, 0, easterEgg, false); ReadKey(true); Clear(); } @@ -436,7 +423,7 @@ public static void PutChar(char c, int CursorLeft, int y, bool quick = false) Canvas.DrawFilledRectangle(CursorLeft * charWidth, y * charHeight, Convert.ToUInt16(charWidth + (charWidth / 8)), charHeight, 0, BackgroundColor); //yes this is correct if (c != ' ') - Canvas.DrawString(CursorLeft * charWidth, y * charHeight, c.ToString(), font, ForegroundColor); + Canvas.DrawString(CursorLeft * charWidth, y * charHeight, c.ToString(), Font_1x, ForegroundColor); } #endregion diff --git a/GoOS/Commands/GoCodeInstaller.cs b/GoOS/Commands/GoCodeInstaller.cs index 86f2a5f7eb..61cf839e13 100644 --- a/GoOS/Commands/GoCodeInstaller.cs +++ b/GoOS/Commands/GoCodeInstaller.cs @@ -26,7 +26,7 @@ public static void Install(string file) if (file.Contains("\\")) { //Console.WriteLine("3"); - + string whatToRemove = file.Substring(file.LastIndexOf("\\")); string FullName = file.Replace(whatToRemove, ""); @@ -40,7 +40,7 @@ public static void Install(string file) else { //Console.WriteLine("4"); - + string FullName = file; string name = FullName.Replace(".gexe", ""); @@ -86,27 +86,50 @@ public static void CheckForInstalledPrograms() { try { - var directory_list = Directory.GetFiles(@"0:\content\GCI\"); + string[] firectories = File.ReadAllLines(@"0:\content\sys\path.ugms"); - foreach (var file in directory_list) + foreach (var firectory in firectories) { - if (file.EndsWith(".gexe")) - { - string name = file.Replace(".gexe", ""); - - string location = @"0:\content\GCI\" + file; - - if (!Kernel.InstalledPrograms.ContainsKey(name)) - Kernel.InstalledPrograms.Add(name, location); - } - else if (file.EndsWith(".goexe")) + if (!Kernel.pathPaths.Contains(firectory)) { - string name = file.Replace(".goexe", ""); + Kernel.pathPaths.Append(firectory); - string location = @"0:\content\GCI\" + file; + } + } + + foreach (var pathDir in Kernel.pathPaths) + { + var directory_list = Directory.GetFiles(pathDir); - if (!Kernel.InstalledPrograms.ContainsKey(name)) - Kernel.InstalledPrograms.Add(name, location); + foreach (var file in directory_list) + { + if (file.EndsWith(".gexe")) + { + string name = file.Replace(".gexe", ""); + + string location = pathDir + @"\" + file; + + if (!Kernel.InstalledPrograms.ContainsKey(name)) + Kernel.InstalledPrograms.Add(name, location); + } + else if (file.EndsWith(".goexe")) + { + string name = file.Replace(".goexe", ""); + + string location = pathDir + @"\" + file; + + if (!Kernel.InstalledPrograms.ContainsKey(name)) + Kernel.InstalledPrograms.Add(name, location); + } + else if (file.EndsWith(".9xc")) + { + string name = file.Replace(".9xc", ""); + + string location = pathDir + @"\" + file; + + if (!Kernel.InstalledPrograms.ContainsKey(name)) + Kernel.InstalledPrograms.Add(name, location); + } } } } @@ -123,21 +146,21 @@ public static void Uninstall(string name) string rootass = @"0:\"; string currentDIRRRRRR = Directory.GetCurrentDirectory(); - + Directory.SetCurrentDirectory(rootass); - + Kernel.InstalledPrograms.TryGetValue(name, out string locat); string TrueLocat = locat; - + if (locat.Contains(@"0:\")) { TrueLocat = TrueLocat.Replace(@"0:\", ""); } - + File.Delete(TrueLocat); Kernel.InstalledPrograms.Remove(name); - + Directory.SetCurrentDirectory(currentDIRRRRRR); } } diff --git a/GoOS/GUI/Apps/About.cs b/GoOS/GUI/Apps/About.cs new file mode 100644 index 0000000000..82254657dc --- /dev/null +++ b/GoOS/GUI/Apps/About.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using IL2CPU.API.Attribs; +using PrismAPI.Graphics; +using PrismAPI.UI; + +namespace GoOS.GUI.Apps +{ + public class About : Window + { + public About() + { + // Create the window. + Contents = new Canvas(200, 180); + Title = "About this GoPC"; + Visible = true; + Closable = true; + Sizable = false; + SetDock(WindowDock.Auto); + // Paint the window. + Contents.DrawImage(0, 0, Resources.abtbg, false); + Contents.DrawString(50, 150, "(Version " + Kernel.version + ")", Resources.Font_1x, Color.White); + } + } +} \ No newline at end of file diff --git a/GoOS/GUI/Apps/AppManager.cs b/GoOS/GUI/Apps/AppManager.cs index eb7884cbed..9393caa60f 100644 --- a/GoOS/GUI/Apps/AppManager.cs +++ b/GoOS/GUI/Apps/AppManager.cs @@ -1,33 +1,19 @@ using System; using IL2CPU.API.Attribs; using PrismAPI.Graphics; +using static GoOS.Resources; namespace GoOS.GUI.Apps { public class AppManager : Window { - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.gterm.bmp")] private static byte[] gtermIconRaw; - private static Canvas gtermIcon = Image.FromBitmap(gtermIconRaw, false); - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.clock.bmp")] private static byte[] clockIconRaw; - private static Canvas clockIcon = Image.FromBitmap(clockIconRaw, false); - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.TaskManager.bmp")] private static byte[] taskmanIconRaw; - private static Canvas taskmanIcon = Image.FromBitmap(taskmanIconRaw, false); - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.ide.bmp")] private static byte[] ideIconRaw; - private static Canvas ideIcon = Image.FromBitmap(ideIconRaw, false); - Button[] AppButtons; Button CloseButton; public AppManager() { - // Generate the fonts. - Fonts.Generate(); - // Create the window. - Contents = new Canvas(400, 350); + Contents = new Canvas(400, 300); Title = "GoOS Applications"; Visible = true; Closable = true; @@ -36,7 +22,7 @@ public AppManager() // Initialize the controls. AppButtons = new Button[] { - new Button(this, 10, 52, 64, 80, "GTerm") + new Button(this, 10, 10, 64, 80, "GTerm") { UseSystemStyle = false, BackgroundColour = Color.LightGray, @@ -46,7 +32,7 @@ public AppManager() Image = gtermIcon, Clicked = GTerm_Click }, - new Button(this, 84, 52, 96, 80, "Task Manager") + new Button(this, 84, 10, 96, 80, "Task Manager") { UseSystemStyle = false, BackgroundColour = Color.LightGray, @@ -56,7 +42,7 @@ public AppManager() Image = taskmanIcon, Clicked = TaskMan_Click }, - new Button(this, 10, 184, 64, 80, "Clock") + new Button(this, 190, 10, 64, 80, "Clock") { UseSystemStyle = false, BackgroundColour = Color.LightGray, @@ -66,7 +52,7 @@ public AppManager() Image = clockIcon, Clicked = Clock_Click }, - new Button(this, 84, 184, 64, 80, "IDE") + new Button(this, 262, 10, 64, 80, "IDE") { UseSystemStyle = false, BackgroundColour = Color.LightGray, @@ -75,7 +61,17 @@ public AppManager() Image = ideIcon, Clicked = IDE_Click - } + }, + new Button(this, 10, 100, 64, 80, "Store") + { + UseSystemStyle = false, + BackgroundColour = Color.LightGray, + SelectionColour = new Color(100, 100, 100), + TextColour = Color.White, + + Image = GoStoreicon, + Clicked = Store_Click + }, }; CloseButton = new Button(this, Convert.ToUInt16(Contents.Width - 90), Convert.ToUInt16(Contents.Height - 30), 80, 20, "Close") { Clicked = CloseButton_Click }; @@ -83,35 +79,20 @@ public AppManager() Contents.Clear(Color.LightGray); RenderSystemStyleBorder(); Contents.DrawFilledRectangle(2, Convert.ToUInt16(Contents.Height - 40), Convert.ToUInt16(Contents.Width - 4), 38, 0, Color.DeepGray); - Contents.DrawString(10, 10, "System Applications", Fonts.Font_2x, Color.White); - Contents.DrawString(10, 142, "Accessories", Fonts.Font_2x, Color.White); foreach (Button AppButton in AppButtons) AppButton.Render(); CloseButton.Render(); } - private void GTerm_Click() - { - WindowManager.AddWindow(new GTerm()); - } + private void GTerm_Click() => WindowManager.AddWindow(new GTerm()); - private void TaskMan_Click() - { - WindowManager.AddWindow(new TaskManager()); - } + private void TaskMan_Click() => WindowManager.AddWindow(new TaskManager()); - private void Clock_Click() - { - WindowManager.AddWindow(new Clock()); - } + private void Clock_Click() => WindowManager.AddWindow(new Clock()); - private void IDE_Click() - { - WindowManager.AddWindow(new GoIDE.ProjectsFrame()); - } + private void IDE_Click() => WindowManager.AddWindow(new GoIDE.ProjectsFrame()); - private void CloseButton_Click() - { - Dispose(); - } + private void Store_Click() => WindowManager.AddWindow(new GoStore.MainFrame()); + + private void CloseButton_Click() => Dispose(); } } \ No newline at end of file diff --git a/GoOS/GUI/Apps/BrownGhost.cs b/GoOS/GUI/Apps/BrownGhost.cs index 7e57ac4fd5..fc84f59eaf 100644 --- a/GoOS/GUI/Apps/BrownGhost.cs +++ b/GoOS/GUI/Apps/BrownGhost.cs @@ -6,14 +6,12 @@ using GoOS.GUI; using IL2CPU.API.Attribs; using PrismAPI.Graphics; +using static GoOS.Resources; namespace GoOS.GUI.Apps { public class BrownGhost : Window { - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.brown_ghost.bmp")] static byte[] brownGhostRaw; - static Canvas brownGhost = Image.FromBitmap(brownGhostRaw, false); - public BrownGhost() { Contents = new Canvas(238, 150); @@ -22,12 +20,10 @@ public BrownGhost() Closable = true; SetDock(WindowDock.Auto); - Fonts.Generate(); - Contents.Clear(Color.Black); RenderSystemStyleBorder(); Contents.DrawImage(10, 51, brownGhost); - Contents.DrawString(61, 67, "Aaaa! A brown ghost!", Fonts.Font_1x, Color.White); + Contents.DrawString(61, 67, "Aaaa! A brown ghost!", Font_1x, Color.White); } } } diff --git a/GoOS/GUI/Apps/Clock.cs b/GoOS/GUI/Apps/Clock.cs index c0124629bc..5703a0129c 100644 --- a/GoOS/GUI/Apps/Clock.cs +++ b/GoOS/GUI/Apps/Clock.cs @@ -6,6 +6,7 @@ using IL2CPU.API.Attribs; using PrismAPI.Graphics; using PrismAPI.UI; +using static GoOS.Resources; namespace GoOS.GUI.Apps { @@ -23,9 +24,6 @@ public class Clock : Window public Clock() { - // Generate the fonts. - Fonts.Generate(); - // Create the window. Contents = new Canvas(192, 192); Title = "Clock"; @@ -84,10 +82,10 @@ public override void Paint() } else { - int x = (Contents.Width / 2) - (Fonts.Font_2x.MeasureString(timeText) / 2); + int x = (Contents.Width / 2) - (Font_2x.MeasureString(timeText) / 2); int y = (Contents.Height / 2) - (32 / 2); - Contents.DrawString(x, y, timeText, Fonts.Font_2x, Color.CoolGreen); + Contents.DrawString(x, y, timeText, Font_2x, Color.CoolGreen); } } diff --git a/GoOS/GUI/Apps/CustomInterface.cs b/GoOS/GUI/Apps/CustomInterface.cs index bb886a0220..81f8822698 100644 --- a/GoOS/GUI/Apps/CustomInterface.cs +++ b/GoOS/GUI/Apps/CustomInterface.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using IL2CPU.API.Attribs; using PrismAPI.Graphics; +using static GoOS.Resources; namespace GoOS.GUI.Apps { @@ -29,7 +30,7 @@ public CustomInterface(string Name, ushort width, ushort height) public static void AddString(Window me, string Text, int X, int Y) { - me.Contents.DrawString(X, Y, Text, BetterConsole.font, Color.Black); + me.Contents.DrawString(X, Y, Text, Font_1x, Color.Black); } } } \ No newline at end of file diff --git a/GoOS/GUI/Apps/Cut.cs b/GoOS/GUI/Apps/Cut.cs index 120d1c6f19..ec5fa007fb 100644 --- a/GoOS/GUI/Apps/Cut.cs +++ b/GoOS/GUI/Apps/Cut.cs @@ -8,16 +8,12 @@ using PrismAPI.Graphics; using System.IO; using System.Threading; +using static GoOS.Resources; namespace GoOS.GUI.Apps; public class Cut : Window { - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Notepad.CUT.bmp")] - private static byte[] cutIconRaw; - - private static Canvas cutIcon = Image.FromBitmap(cutIconRaw, false); - public Cut() { Contents = new Canvas(148, 150); diff --git a/GoOS/GUI/Apps/Desktop.cs b/GoOS/GUI/Apps/Desktop.cs index 0aa36c3fc5..70e2407afb 100644 --- a/GoOS/GUI/Apps/Desktop.cs +++ b/GoOS/GUI/Apps/Desktop.cs @@ -3,26 +3,110 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Cosmos.Core.Memory; using Cosmos.System; +using Cosmos.System.Network.Config; +using Cosmos.System.Network.IPv4; +using Cosmos.System.Network.IPv4.TCP; +using Cosmos.System.Network.IPv4.UDP.DNS; using GoOS.GUI.Models; using IL2CPU.API.Attribs; using PrismAPI.Graphics; +using static GoOS.Resources; namespace GoOS.GUI.Apps { public class Desktop : Window { - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.folder.bmp")] private static byte[] folderIconRaw; - private static Canvas folderIcon = Image.FromBitmap(folderIconRaw, false); + Button AppsFolderButton; - Button FolderButton; + private string[] contextMenuButtons = + { + " About GoOS ", + " Garbage Collect ", + " Check for Updates " + }; - public Desktop() + public override void ShowContextMenu() { - Fonts.Generate(); + ContextMenu.Show(contextMenuButtons, 155, ContextMenu_Handle); + } + private void ContextMenu_Handle(string item) + { + switch (item) + { + case " About GoOS ": + WindowManager.AddWindow(new About()); + break; + case " Garbage Collect ": + Dialogue.Show("Garbage Collection", Heap.Collect() + " bytes freed"); + break; + case " Check for Updates ": + try + { + var dnsClient = new DnsClient(); + var tcpClient = new TcpClient(); + dnsClient.Connect(DNSConfig.DNSNameservers[0]); + dnsClient.SendAsk("api.goos.owen2k6.com"); + Address address = dnsClient.Receive(); + dnsClient.Close(); + tcpClient.Connect(address, 80); + string httpget = "GET /GoOS/" + Kernel.edition + ".goos HTTP/1.1\r\n" + + "User-Agent: GoOS\r\n" + + "Accept: */*\r\n" + + "Accept-Encoding: identity\r\n" + + "Host: api.goos.owen2k6.com\r\n" + + "Connection: Keep-Alive\r\n\r\n"; + tcpClient.Send(Encoding.ASCII.GetBytes(httpget)); + var ep = new EndPoint(Address.Zero, 0); + var data = tcpClient.Receive(ref ep); + tcpClient.Close(); + string httpresponse = Encoding.ASCII.GetString(data); + string[] responseParts = + httpresponse.Split(new[] { "\r\n\r\n" }, 2, StringSplitOptions.None); + if (responseParts.Length == 2) + { + string headers = responseParts[0]; + string content = responseParts[1]; + if (content != Kernel.version && content != Kernel.editionnext) + { + Dialogue.Show("GoOS Update", + "A newer version of GoOS is available on Github.\nWe recommend you update to the latest version for stability and security reasons.\nhttps://github.com/Owen2k6/GoOS/releases\nCurrent Version: " + + Kernel.version + "\nLatest Version: " + content); + } + else if (content == Kernel.editionnext) + { + Dialogue.Show("GoOS Update", + "The next GoOS has been released.\nWe don't want to force you to update but at least check out whats new in GoOS " + + Kernel.editionnext + "!\nhttps://github.com/Owen2k6/GoOS/releases/tag/" + + Kernel.editionnext); + } + else if (content == "404") + { + Dialogue.Show("GoOS Update", "Your Version of GoOS does not support GoOS Update."); + } + else + { + Dialogue.Show("GoOS Update", "You are running the latest version of GoOS.\nVersion: " + + Kernel.version + "\nLatest Version: " + content); + } + } + } + catch (Exception ex) + { + Dialogue.Show("GoOS Update", "Failed to connect to Owen2k6 Api. Error: " + ex); + } + + break; + } + } + + public Desktop() + { Contents = new Canvas(WindowManager.Canvas.Width, Convert.ToUInt16(WindowManager.Canvas.Height - 28)); - Contents.Clear(Kernel.DesktopColour); + //Contents.Clear(Kernel.DesktopColour); + Contents.DrawImage(0, 0, background, false); Title = nameof(Desktop); Visible = true; Closable = false; @@ -30,27 +114,99 @@ public Desktop() Unkillable = true; SetDock(WindowDock.None); - FolderButton = new Button(this, 20, 20, 64, 80, "Apps") + AppsFolderButton = new Button(this, 20, 20, 64, 80, "Apps") { UseSystemStyle = false, - BackgroundColour = Kernel.DesktopColour, - TextColour = Color.White, + BackgroundColour = Color.White, + TextColour = Color.Black, Image = folderIcon, - Clicked = FolderButton_Click + Clicked = AppsFolderButton_Click }; - FolderButton.Render(); - string line1 = "GoOS " + Kernel.BuildType + " " + Kernel.version; - string line2 = "Development build"; + AppsFolderButton.Render(); + //TODO: xrc if you dare edit this panel you wont exist on this project anymore + if (Kernel.BuildType != "R") + { + if (Kernel.BuildType == "NIFPR") + { + string line1 = "GoOS " + Kernel.BuildType + " " + Kernel.version; + string line2 = + "Shh lets not leak our hard work."; + string line3 = + "Despite this being open source, Lets keep the new features as secret as possible."; + string line4 = "Thank you to everyone that is actively developing and testing GoOS."; + + Contents.DrawString(Contents.Width - Font_1x.MeasureString(line1) - 1, Contents.Height - 53, line1, + Font_1x, + Color.White); + Contents.DrawString(Contents.Width - Font_1x.MeasureString(line2) - 1, Contents.Height - 41, line2, + Font_1x, + Color.White); + Contents.DrawString(Contents.Width - Font_1x.MeasureString(line3) - 1, Contents.Height - 29, line3, + Font_1x, + Color.White); + Contents.DrawString(Contents.Width - Font_1x.MeasureString(line4) - 1, Contents.Height - 17, line4, + Font_1x, + Color.White); + } + else if (Kernel.BuildType == "PRB") + { + string line1 = "GoOS " + Kernel.BuildType + " " + Kernel.version; + string line2 = + "This Build is not stable and is not recommended for use by Non-Testers"; + string line3 = + "Official use of this build type is limited to testers only."; + string line4 = "GoOS Update and Security are not available for these builds."; + + Contents.DrawString(Contents.Width - Font_1x.MeasureString(line1) - 1, Contents.Height - 53, line1, + Font_1x, + Color.White); + Contents.DrawString(Contents.Width - Font_1x.MeasureString(line2) - 1, Contents.Height - 41, line2, + Font_1x, + Color.White); + Contents.DrawString(Contents.Width - Font_1x.MeasureString(line3) - 1, Contents.Height - 29, line3, + Font_1x, + Color.White); + Contents.DrawString(Contents.Width - Font_1x.MeasureString(line4) - 1, Contents.Height - 17, line4, + Font_1x, + Color.White); + } + else if (Kernel.BuildType == "PRE") + { + string line1 = "GoOS " + Kernel.BuildType + " " + Kernel.version; + string line2 = + "This is a Pre Release of GoOS"; + string line3 = + "We don't recommend using this build for regular use."; + string line4 = "This build sports beta functions that may not be included in the final release."; - Contents.DrawString(Contents.Width - Fonts.Font_1x.MeasureString(line1)-1, Contents.Height - 29, line1, Fonts.Font_1x, Color.White); - Contents.DrawString(Contents.Width - Fonts.Font_1x.MeasureString(line2)-1, Contents.Height - 17, line2, Fonts.Font_1x, Color.White); + Contents.DrawString(Contents.Width - Font_1x.MeasureString(line1) - 1, Contents.Height - 53, line1, + Font_1x, + Color.White); + Contents.DrawString(Contents.Width - Font_1x.MeasureString(line2) - 1, Contents.Height - 41, line2, + Font_1x, + Color.White); + Contents.DrawString(Contents.Width - Font_1x.MeasureString(line3) - 1, Contents.Height - 29, line3, + Font_1x, + Color.White); + Contents.DrawString(Contents.Width - Font_1x.MeasureString(line4) - 1, Contents.Height - 17, line4, + Font_1x, + Color.White); + } + else + { + string line = "GoOS " + Kernel.BuildType + " " + Kernel.version; + Contents.DrawString(Contents.Width - Font_1x.MeasureString(line) - 1, Contents.Height - 17, line, + Font_1x, + Color.White); + } + } } - private void FolderButton_Click() + private void AppsFolderButton_Click() { WindowManager.AddWindow(new AppManager()); } } -} +} \ No newline at end of file diff --git a/GoOS/GUI/Apps/GTerm.cs b/GoOS/GUI/Apps/GTerm.cs index b070369ef7..bcd727461f 100644 --- a/GoOS/GUI/Apps/GTerm.cs +++ b/GoOS/GUI/Apps/GTerm.cs @@ -14,7 +14,6 @@ public GTerm(bool overrideTitle = true) Visible = true; Closable = true; SetDock(WindowDock.Auto); - BetterConsole.font = new Font(BetterConsole.rawFont, BetterConsole.charHeight); BetterConsole.Visible = true; } diff --git a/GoOS/GUI/Apps/GoIDE/IDEFrame.cs b/GoOS/GUI/Apps/GoIDE/IDEFrame.cs index 3e3a2124a8..0a1dfdd848 100644 --- a/GoOS/GUI/Apps/GoIDE/IDEFrame.cs +++ b/GoOS/GUI/Apps/GoIDE/IDEFrame.cs @@ -1,17 +1,16 @@ using System; using System.IO; +using GoOS.Commands; using IL2CPU.API.Attribs; using PrismAPI.Graphics; -using GoCode = GoOS.Commands.Run; +using static GoOS.Commands.Run; using Console = BetterConsole; +using static GoOS.Resources; namespace GoOS.GUI.Apps.GoIDE { public class IDEFrame : Window { - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.GoIDE.run.bmp")] static byte[] runRaw; - static Canvas RunImage = Image.FromBitmap(runRaw, false); - Button SaveButton; Button RunButton; InputNUMBERS Code; @@ -58,7 +57,7 @@ void Paint(string status) SaveButton.Render(); RunButton.Render(); Code.Render(); - Contents.DrawString(4, Contents.Height - 20, status, Fonts.Font_1x, Color.LighterBlack); + Contents.DrawString(4, Contents.Height - 20, status, Font_1x, Color.LighterBlack); } bool Debugging = false; @@ -83,7 +82,7 @@ void RunButton_Click() Console.Clear(); if (!Is9xCode) - GoCode.Main(ProjectPath, false); + Run.Main(ProjectPath, false); else _9xCode.Interpreter.Run(ProjectPath); diff --git a/GoOS/GUI/Apps/GoIDE/ImportFrame.cs b/GoOS/GUI/Apps/GoIDE/ImportFrame.cs index 1be3b945d7..e9a21bdb9d 100644 --- a/GoOS/GUI/Apps/GoIDE/ImportFrame.cs +++ b/GoOS/GUI/Apps/GoIDE/ImportFrame.cs @@ -17,9 +17,6 @@ public ImportProjectFrame() { try { - // Generate the fonts. - Fonts.Generate(); - // Create the window. Contents = new Canvas(400, 300); Title = "Load project - GoIDE"; @@ -35,8 +32,8 @@ public ImportProjectFrame() // Paint the window. Contents.Clear(Color.LightGray); RenderSystemStyleBorder(); - Contents.DrawString(10, 10, "Import project", Fonts.Font_2x, Color.White); - Contents.DrawString(10, 52, "Location: ", Fonts.Font_1x, Color.White); + Contents.DrawString(10, 10, "Import project", Resources.Font_2x, Color.White); + Contents.DrawString(10, 52, "Location: ", Resources.Font_1x, Color.White); Contents.DrawFilledRectangle(2, Convert.ToUInt16(Contents.Height - 40), Convert.ToUInt16(Contents.Width - 4), 38, 0, Color.DeepGray); ImportButton.Render(); CancelButton.Render(); diff --git a/GoOS/GUI/Apps/GoIDE/LoadProjectFrame.cs b/GoOS/GUI/Apps/GoIDE/LoadProjectFrame.cs index e32686be7a..57ba1b799e 100644 --- a/GoOS/GUI/Apps/GoIDE/LoadProjectFrame.cs +++ b/GoOS/GUI/Apps/GoIDE/LoadProjectFrame.cs @@ -3,6 +3,7 @@ using IL2CPU.API.Attribs; using PrismAPI.Graphics; using PrismAPI.Graphics.Fonts; +using static GoOS.Resources; namespace GoOS.GUI.Apps.GoIDE { @@ -17,9 +18,6 @@ public LoadProjectFrame() { try { - // Generate the fonts. - Fonts.Generate(); - // Create the window. Contents = new Canvas(400, 300); Title = "Load project - GoIDE"; @@ -35,8 +33,8 @@ public LoadProjectFrame() // Paint the window. Contents.Clear(Color.LightGray); RenderSystemStyleBorder(); - Contents.DrawString(10, 10, "Load project", Fonts.Font_2x, Color.White); - Contents.DrawString(10, 52, "Location: ", Fonts.Font_1x, Color.White); + Contents.DrawString(10, 10, "Load project", Font_2x, Color.White); + Contents.DrawString(10, 52, "Location: ", Font_1x, Color.White); Contents.DrawFilledRectangle(2, Convert.ToUInt16(Contents.Height - 40), Convert.ToUInt16(Contents.Width - 4), 38, 0, Color.DeepGray); LoadButton.Render(); CancelButton.Render(); diff --git a/GoOS/GUI/Apps/GoIDE/NewProjectFrame.cs b/GoOS/GUI/Apps/GoIDE/NewProjectFrame.cs index 859a7d8d3c..746cccee95 100644 --- a/GoOS/GUI/Apps/GoIDE/NewProjectFrame.cs +++ b/GoOS/GUI/Apps/GoIDE/NewProjectFrame.cs @@ -1,6 +1,7 @@ using System; using System.IO; using PrismAPI.Graphics; +using static GoOS.Resources; namespace GoOS.GUI.Apps.GoIDE { @@ -18,9 +19,6 @@ public NewProjectFrame() { try { - // Generate the fonts. - Fonts.Generate(); - // Create the window. Contents = new Canvas(400, 300); Title = "New project - GoIDE"; @@ -39,10 +37,10 @@ public NewProjectFrame() // Paint the window. Contents.Clear(Color.LightGray); RenderSystemStyleBorder(); - Contents.DrawString(10, 10, "New project", Fonts.Font_2x, Color.White); - Contents.DrawString(10, 52, "Name: ", Fonts.Font_1x, Color.White); - Contents.DrawString(10, 82, "Location: ", Fonts.Font_1x, Color.White); - Contents.DrawString(10, 112, "Language: ", Fonts.Font_1x, Color.White); + Contents.DrawString(10, 10, "New project", Font_2x, Color.White); + Contents.DrawString(10, 52, "Name: ", Font_1x, Color.White); + Contents.DrawString(10, 82, "Location: ", Font_1x, Color.White); + Contents.DrawString(10, 112, "Language: ", Font_1x, Color.White); Contents.DrawFilledRectangle(2, Convert.ToUInt16(Contents.Height - 40), Convert.ToUInt16(Contents.Width - 4), 38, 0, Color.DeepGray); CreateButton.Render(); CancelButton.Render(); diff --git a/GoOS/GUI/Apps/GoIDE/ProjectsFrame.cs b/GoOS/GUI/Apps/GoIDE/ProjectsFrame.cs index 6779fd48af..d36c545e6c 100644 --- a/GoOS/GUI/Apps/GoIDE/ProjectsFrame.cs +++ b/GoOS/GUI/Apps/GoIDE/ProjectsFrame.cs @@ -1,6 +1,7 @@ using System; using System.IO; using PrismAPI.Graphics; +using static GoOS.Resources; namespace GoOS.GUI.Apps.GoIDE { @@ -24,7 +25,7 @@ public ProjectsFrame() } // Generate the fonts. - Fonts.Generate(); + Generate(ResourceType.Fonts); // Create the window. Contents = new Canvas(400, 300); @@ -60,7 +61,7 @@ public ProjectsFrame() Contents.Clear(Color.LightGray); RenderSystemStyleBorder(); Contents.DrawFilledRectangle(2, Convert.ToUInt16(Contents.Height - 40), Convert.ToUInt16(Contents.Width - 4), 38, 0, Color.DeepGray); - Contents.DrawString(10, 10, "All projects", Fonts.Font_2x, Color.White); + Contents.DrawString(10, 10, "All projects", Font_2x, Color.White); foreach (Button i in RecentProjectsButtons) i.Render(); DeleteButton.Render(); ImportButton.Render(); diff --git a/GoOS/GUI/Apps/GoIDE/WelcomeFrame.cs b/GoOS/GUI/Apps/GoIDE/WelcomeFrame.cs index f9173e7460..5904db318e 100644 --- a/GoOS/GUI/Apps/GoIDE/WelcomeFrame.cs +++ b/GoOS/GUI/Apps/GoIDE/WelcomeFrame.cs @@ -1,6 +1,7 @@ using System; using System.IO; using PrismAPI.Graphics; +using static GoOS.Resources; namespace GoOS.GUI.Apps.GoIDE { @@ -22,23 +23,18 @@ public WelcomeFrame() Contents.Clear(Color.LightGray); RenderSystemStyleBorder(); Contents.DrawFilledRectangle(2, Convert.ToUInt16(Contents.Height - 40), Convert.ToUInt16(Contents.Width - 4), 38, 0, Color.DeepGray); - Contents.DrawString(10, 10, "Welcome", Fonts.Font_2x, Color.White); - Contents.DrawString(10, 52, "Welcome to GoIDE! This program will let you\ncreate and debug GoOS applications.\n\nGoIDE currently supports GoCode and 9xCode.\n\nPress next to install GoIDE and create a new\nproject.", Fonts.Font_1x, Color.White); + Contents.DrawString(10, 10, "Welcome", Font_2x, Color.White); + Contents.DrawString(10, 52, "Welcome to GoIDE! This program will let you\ncreate and debug GoOS applications.\n\nGoIDE currently supports GoCode and 9xCode.\n\nPress next to install GoIDE and create a new\nproject.", Resources.Font_1x, Color.White); CancelButton.Render(); NextButton.Render(); } private void NextButton_Click() { - Dialogue msg = new Dialogue("Setup Wizard", "Installing GoIDE...", default, Dialogue.infoIcon); - WindowManager.AddWindow(msg); - WindowManager.Update(); - Directory.CreateDirectory(@"0:\content\prf\GoIDE"); Directory.CreateDirectory(@"0:\content\prf\GoIDE\Projects"); Directory.CreateDirectory(@"0:\content\prf\GoIDE\SaveData"); - msg.Dispose(); Dispose(); WindowManager.AddWindow(new NewProjectFrame()); } diff --git a/GoOS/GUI/Apps/GoStore/DescriptionFrame.cs b/GoOS/GUI/Apps/GoStore/DescriptionFrame.cs new file mode 100644 index 0000000000..442727b246 --- /dev/null +++ b/GoOS/GUI/Apps/GoStore/DescriptionFrame.cs @@ -0,0 +1,149 @@ +using System; +using IO = System.IO; +using System.Text; +using Cosmos.System.Network.Config; +using Cosmos.System.Network.IPv4; +using Cosmos.System.Network.IPv4.UDP.DNS; +using TcpClient = Cosmos.System.Network.IPv4.TCP.TcpClient; +using PrismAPI.Graphics; +using static GoOS.Resources; + +/* + * == RC Release Notice. + * TODO: This page has too many issues related to both design and functionality. + * The following in this list are known issues related to this page. + * - This window recieves the category as the repository which is NOT correct. (MrDumbrava Assigned) + * - The window design does not match the GoStore design. + * - The window has a cancel button when it already has a close button on the Titlebar. + * - The window shouldn't have references to other applications but itself. (GoIDE should not be referenced here.) + * + * Extended Notes: + * - I will be pushing the bmps for this page and the buttons to the repo soon. I need to work on them a bit more. -- Owen2k6 + * - MrDumbrava has been assigned to the repository mismatch issues. + * TODO: Prevent Release Candidate or Release builds until this is resolved. + * - Owen2k6 DO NOT REMOVE. + */ + +namespace GoOS.GUI.Apps.GoStore +{ + public class DescriptionFrame : Window + { + Button IDEOpenButton; + Button CancelButton; + Button InstallButton; + String Name, File, Repo; + + public DescriptionFrame(string name, string version, string author, string description, string language, string repo) + { + // Set class variables + File = name + "." + language; + Name = name; + Repo = repo; + + // Create the window. + Contents = new Canvas(300, 250); + Title = "GoStore"; + Visible = true; + Closable = true; + SetDock(WindowDock.Center); + + // Initialize the controls + IDEOpenButton = new Button(this, 10, Convert.ToUInt16(Contents.Height - 30), 104, 20, "Open in IDE") { Clicked = IDEOpenButton_Click }; + CancelButton = new Button(this, Convert.ToUInt16(Contents.Width - 172), Convert.ToUInt16(Contents.Height - 30), 64, 20, "Cancel") { Clicked = CancelButton_Click }; + InstallButton = new Button(this, Convert.ToUInt16(Contents.Width - 98), Convert.ToUInt16(Contents.Height - 30), 88, 20, !IO.File.Exists(@"0:\go\" + File) ? " Install " : "Uninstall") { Clicked = InstallButton_Click }; + + // Paint the window. + Contents.Clear(Color.LightGray); + RenderSystemStyleBorder(); + Contents.DrawString(10, 10, name, Font_2x, Color.White); + Contents.DrawString(10, 56, "Version: " + version.Replace("\\n", "\n"), Font_1x, Color.White); + Contents.DrawString(10, 72, "Author: " + author.Replace("\\n", "\n"), Font_1x, Color.White); + Contents.DrawString(10, 86, "Language: " + language.Replace("\\n", "\n"), Font_1x, Color.White); + Contents.DrawString(10, 100, "Description: " + description.Replace("\\n", "\n"), Font_1x, Color.White); + Contents.DrawFilledRectangle(2, Convert.ToUInt16(Contents.Height - 40), Convert.ToUInt16(Contents.Width - 4), 38, 0, Color.DeepGray); Contents.DrawFilledRectangle(2, Convert.ToUInt16(Contents.Height - 40), Convert.ToUInt16(Contents.Width - 4), 38, 0, Color.DeepGray); + IDEOpenButton.Render(); + CancelButton.Render(); + InstallButton.Render(); + } + + private void InstallButton_Click() + { + try + { + if (!IO.File.Exists(@"0:\go\" + File)) + { + var dnsClient = new DnsClient(); + var tcpClient = new TcpClient(); + + dnsClient.Connect(DNSConfig.DNSNameservers[0]); + dnsClient.SendAsk(Repo); + Address address = dnsClient.Receive(); + dnsClient.Close(); + + tcpClient.Connect(address, 80); + + string httpget = "GET /" + File + " HTTP/1.1\r\n" + + "User-Agent: GoOS\r\n" + + "Accept: */*\r\n" + + "Accept-Encoding: identity\r\n" + + "Host: " + Repo + "\r\n" + + "Connection: Keep-Alive\r\n\r\n"; + + tcpClient.Send(Encoding.ASCII.GetBytes(httpget)); + + var ep = new EndPoint(Address.Zero, 0); + var data = tcpClient.Receive(ref ep); + tcpClient.Close(); + + string httpresponse = Encoding.ASCII.GetString(data); + + string[] responseParts = + httpresponse.Split(new[] { "\r\n\r\n" }, 2, StringSplitOptions.None); + + if (responseParts.Length == 2) + { + if (responseParts[1] == "404") + { + Dialogue.Show("404", "The requested file or resource was not found.", default, WindowManager.errorIcon); + return; + } + + if (!IO.Directory.Exists(@"0:\go")) IO.Directory.CreateDirectory(@"0:\go"); + + IO.File.WriteAllText(@"0:\go\" + File, responseParts[1]); + } + + Dialogue.Show("Success", "Application installed successfully."); + InstallButton.Title = "Uninstall"; + InstallButton.Render(); + } + else + { + while (IO.File.Exists(@"0:\go\" + File)) IO.File.Delete(@"0:\go\" + File); + + Dialogue.Show("Success", "Application uninstalled successfully."); + InstallButton.Title = " Install "; + InstallButton.Render(); + } + } + catch (Exception ex) + { + Dialogue.Show("Error", "Exception in GoOS.GUI.Apps.GoStore.DescriptionFrame.InstallButton_Click():\n" + ex.Message); + } + } + + private void CancelButton_Click() => Dispose(); + + private void IDEOpenButton_Click() + { + if (!IO.File.Exists(@"0:\go\" + File)) + { + Dialogue.Show("Error", "You need to install this package before you can use it.", default, WindowManager.errorIcon); + } + else + { + WindowManager.AddWindow(new GoIDE.IDEFrame(Name, @"0:\go\" + File, File.EndsWith(".9xc"))); + } + } + } +} diff --git a/GoOS/GUI/Apps/GoStore/MainFrame.cs b/GoOS/GUI/Apps/GoStore/MainFrame.cs new file mode 100644 index 0000000000..274895e1f3 --- /dev/null +++ b/GoOS/GUI/Apps/GoStore/MainFrame.cs @@ -0,0 +1,509 @@ +using System; +using System.Collections; +using System.IO; +using Cosmos.System.Network.Config; +using Cosmos.System.Network.IPv4; +using Cosmos.System.Network.IPv4.UDP.DNS; +using TcpClient = Cosmos.System.Network.IPv4.TCP.TcpClient; +using System.Text; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using GoOS.Themes; +using PrismAPI.Graphics; +using static GoOS.Resources; +using static GoOS.Resources; + +namespace GoOS.GUI.Apps.GoStore +{ + //TODO: The GoStore is no longer working after commit 3a1e7d6041df6df9409e1416c188419a6027d92f. I have repaired the GoStore Live checker to api.goos.* instead of api.* + public class MainFrame : Window + { + Button[] catagoryButtons = new Button[7]; + + readonly List Catagories = new(); + /* + * == RC Release Notice. + * TODO: This is bad practice as the list is stored on the client so as more categories are added the client will be unable to display apps from them. + * TODO: Prevent Release Candidate or Release builds until this is resolved. + * - Owen2k6 DO NOT REMOVE. + */ + + Button[] RepoFilesButtons; + private int[] RepoFilesButtonsPageNumbers; + + private int catagory = 0; + private int page = 0; + + List<(string, string, string, string, string, string, string)> repoFiles = + new(); + + private Dictionary GoOSversions = new(); + + private Button nextButton; + private Button prevousButton; + + readonly string[] repos = + { + "apps.goos.owen2k6.com", + "goos.ekeleze.org", + "repo.mobren.net" + }; + + private readonly string[] allowDLfrom = + { + "1.5pre1", + "1.5pre2", + "1.5pre3", + "1.5rc1", + "1.5rc2", + "1.5rc3", + "1.5" + }; + /* + * == RC Release Notice. + * TODO: This needs to be reset to just 1.5 before release. + * TODO: Prevent Release Candidate or Release builds until this is resolved. + * - Owen2k6 DO NOT REMOVE. + */ + + /* + * == RC Release Notice. + * TODO: Do it yourself, you added this part. + * TODO: I will only fix what I made badly, not what you made badly. + * - ekeleze DO NOT REMOVE + */ + //TODO: ekeleze these are notes to be done before RC, this isnt just for YOU. Besides thats just a list and nothing uses it since the people i asked to do it (9xbt) never did anything + + public MainFrame() + { + Catagories = new List { GetInfoFile(@"http://api.goos.owen2k6.com/GoOS/cat.gostore") }; + + // Get the file list from every repo + string[][] infoFiles = + { + GetInfoFile(repos[0]).Split('\n'), + GetInfoFile(repos[1]).Split('\n'), + GetInfoFile(repos[2]).Split('\n') + }; + try + { + int o = 0; + foreach (string[] file in infoFiles) + { + try + { + foreach (string program in file) + { + string[] metadata = program.Split('|'); + repoFiles.Add((metadata[0], metadata[1], metadata[2], metadata[3], metadata[4], metadata[5], + repos[o])); + if (GoOSversions.ContainsKey(metadata[0])) + GoOSversions.Remove(metadata[0]); + GoOSversions.Add(metadata[0], metadata[6]); + } + } + catch (Exception ex) + { + Dialogue.Show("GoStore had an issue.", ex.ToString()); + } + + o++; + } + + // Generate the fonts. + Generate(ResourceType.Fonts); + + // Create the window. + Contents = new Canvas(800, 600); + Title = "GoStore"; + Visible = true; + Closable = true; + SetDock(WindowDock.Center); + + // Initialize the controls. + RepoFilesButtons = new Button[repoFiles.Count]; + RepoFilesButtonsPageNumbers = new int[repoFiles.Count]; + bool GS = HasLaunched(); + if (GS || Kernel.BuildType == "NIFPR") + { + for (int i = 0; i < Catagories.Count; i++) + { + catagoryButtons[i] = new Button(this, Convert.ToUInt16(5), + Convert.ToUInt16(45 + i * 20), + Convert.ToUInt16(Catagories[i].Length * 8), 20, Catagories[i]) + { + Name = Catagories[i], + UseSystemStyle = false, + BackgroundColour = new Color(0, 0, 0, 0), + ClickedAlt = CatgoryAction, + RenderWithAlpha = true + }; + } + + nextButton = new Button(this, 685, 556, 109, 35, "Next") + { + Name = "next", + UseSystemStyle = false, + BackgroundColour = new Color(0, 0, 0, 0), + ClickedAlt = nextPage, + RenderWithAlpha = true + }; + + prevousButton = new Button(this, 514, 556, 109, 35, "Previous") + { + Name = "Previous", + UseSystemStyle = false, + BackgroundColour = new Color(0, 0, 0, 0), + ClickedAlt = previousPage, + RenderWithAlpha = true + }; + + CatgoryAction("Utilities"); + } + else + { + Contents.DrawImage(0, 0, Resources.GoStore, false); + RenderSystemStyleBorder(); + Contents.DrawString(150, 50, + "The GoStore is coming soon...\n\nThis will allow users to install applications\ndirectly to their device!\nWe are working on preparing the GoStore\nand getting apps made for you to enjoy!\n\nSee you on launch day!", + Font_1x, Color.White); + } + } + catch (Exception ex) + { + Dialogue.Show("Error", ex.ToString()); + } + } + + private void dostuff() + { + foreach (Button b in RepoFilesButtons) + Controls.Remove(b); + + RepoFilesButtons = null; + RepoFilesButtonsPageNumbers = null; + + Contents.Clear(); + Contents.DrawImage(0, 0, Resources.GoStore, false); + + int accountFor = 0; + + RepoFilesButtonsPageNumbers = new int[repoFiles.Count]; + RepoFilesButtons = new Button[repoFiles.Count]; + + int Line = 0; + int Colum = 0; + int ButtonPage = 0; + page = 0; + + int yOffset = 0; + + for (int i = 0; i < repoFiles.Count; i++) + { + // 207 x 78 + + int appCat = 0; + + for (int ii = 0; ii < Catagories.Count; ii++) + { + if (repoFiles[i].Item6 == Catagories[ii]) + { + appCat = ii; + } + } + + if (Colum >= 3 && Line >= 6 && appCat == catagory) + { + ButtonPage++; + } + else if (Line >= 6 && appCat == catagory) + { + Line = 0; + Colum++; + } + + if (appCat == catagory) + { + string GoOSversion = "1.5"; + string VersionSpaces = ""; + + if (GoOSversions.ContainsKey(repoFiles[i].Item1)) + GoOSversions.TryGetValue(repoFiles[i].Item1, out GoOSversion); + + for (int ii = 0; ii < 25 - repoFiles[i].Item1.Length - (GoOSversion.TrimEnd().Length + 6); ii++) + VersionSpaces += " "; + + int x = 150 + Colum * (207 + 5); // 150 + int y = 45 + (Line) * (78 + 5); + + RepoFilesButtons[i] = new Button(this, Convert.ToUInt16(x), // 150 + Convert.ToUInt16(y), + 207, 78, repoFiles[i].Item1 + VersionSpaces + "GoOS " + + GoOSversion.TrimEnd() + "+" + "\nBy " + repoFiles[i].Item5 + "\n" + + repoFiles[i].Item3.Replace(@"\n", "\n")) + { + Name = repoFiles[i].Item1, + UseSystemStyle = false, + BackgroundColour = new Color(0, 0, 0, 0), + ClickedAlt = repoFiles_Click, + RenderWithAlpha = true, + CenterTitle = false, + textX = 5, + textY = 2 + }; + + Line++; + + RepoFilesButtonsPageNumbers[i] = ButtonPage; + } + } + + RenderSystemStyleBorder(); + int a = 0; + foreach (Button i in RepoFilesButtons) + { + if (page == RepoFilesButtonsPageNumbers[a]) + { + int x = i.X; + int y = i.Y; + Contents.DrawImage(x, y, StoreButton); + if (i != null) i.Render(); + } + + a++; + } + + foreach (Button i in catagoryButtons) i.Render(); + + // y 556 + + // x 514 + + // Width 109 x Height 35 + + prevousButton.Render(); + nextButton.Render(); + } + + private string GetInfoFile(string repo) + { + try + { + var dnsClient = new DnsClient(); + var tcpClient = new TcpClient(); + + dnsClient.Connect(DNSConfig.DNSNameservers[0]); + dnsClient.SendAsk(repo); + Address address = dnsClient.Receive(); + dnsClient.Close(); + + tcpClient.Connect(address, 80); + + string httpget = "GET /info.glist HTTP/1.1\r\n" + + "User-Agent: GoOS\r\n" + + "Accept: */*\r\n" + + "Accept-Encoding: identity\r\n" + + "Host: " + repo + "\r\n" + + "Connection: Keep-Alive\r\n\r\n"; + + tcpClient.Send(Encoding.ASCII.GetBytes(httpget)); + + var ep = new EndPoint(Address.Zero, 0); + var data = tcpClient.Receive(ref ep); + tcpClient.Close(); + + string httpresponse = Encoding.ASCII.GetString(data); + + string[] responseParts = + httpresponse.Split(new[] { "\r\n\r\n" }, 2, StringSplitOptions.None); + + if (responseParts.Length == 2) + { + return responseParts[1]; + } + } + catch (Exception ex) + { + Dialogue.Show("GoStore Was unable to connect you.", + "Some apps may not be available as some servers were uncontactable. \nError: " + ex + + "\n\nPlease try again later."); + } + + return string.Empty; + } + + private Boolean HasLaunched() + { + try + { + var dnsClient = new DnsClient(); + var tcpClient = new TcpClient(); + + dnsClient.Connect(DNSConfig.DNSNameservers[0]); + dnsClient.SendAsk("apps.goos.owen2k6.com"); + Address address = dnsClient.Receive(); + dnsClient.Close(); + + tcpClient.Connect(address, 80); + + string httpget = "GET /GoOS/gslaunch.goos HTTP/1.1\r\n" + + "User-Agent: GoOS\r\n" + + "Accept: */*\r\n" + + "Accept-Encoding: identity\r\n" + + "Host: api.goos.owen2k6.com\r\n" + + "Connection: Keep-Alive\r\n\r\n"; + + tcpClient.Send(Encoding.ASCII.GetBytes(httpget)); + + var ep = new EndPoint(Address.Zero, 0); + var data = tcpClient.Receive(ref ep); + tcpClient.Close(); + + string httpresponse = Encoding.ASCII.GetString(data); + + string[] responseParts = + httpresponse.Split(new[] { "\r\n\r\n" }, 2, StringSplitOptions.None); + + if (responseParts.Length == 2) + { + if (responseParts[1] == "true") + { + return true; + } + } + } + catch + { + } + + return false; + } + + private int GetIndexByTitle(string title) + { + for (int i = 0; i < repoFiles.Count; i++) + { + if (repoFiles[i].Item1 == title) return i; + } + + return 0; + } + + private void repoFiles_Click(string i) + { + WindowManager.AddWindow(new DescriptionFrame( + repoFiles[GetIndexByTitle(i)].Item1, repoFiles[GetIndexByTitle(i)].Item4, + repoFiles[GetIndexByTitle(i)].Item5, repoFiles[GetIndexByTitle(i)].Item3, + repoFiles[GetIndexByTitle(i)].Item2, repoFiles[GetIndexByTitle(i)].Item6)); + + /* + * == RC Release Notice. + * TODO: This is bad practice. The repository is stored on the end of the metadata. We cant expand the GoStore abilities without breaking earlier clients. + * TODO: Assigned to @MrDumbrava as they created this. + * TODO: Prevent Release Candidate or Release builds until this is resolved. + * - Owen2k6 DO NOT REMOVE. + */ + } + + private void CatgoryAction(string name) + { + for (int ii = 0; ii < Catagories.Count; ii++) + { + if (name == Catagories[ii]) + { + catagory = ii; + } + } + + dostuff(); // 565 + + switch (name) + { + case "Utilities": + Contents.DrawString(38, 563, "Utilities", Font_1x, Color.White); + break; + case "Games": + Contents.DrawString(52, 563, "Games", Font_1x, Color.White); + break; + case "Demos": + Contents.DrawString(52, 563, "Demos", Font_1x, Color.White); + break; + case "Development": + Contents.DrawString(29, 563, "Development", Font_1x, Color.White); + break; + case "Updates": + Contents.DrawString(43, 563, "Updates", Font_1x, Color.White); + break; + case "Office": + Contents.DrawString(47, 563, "Office", Font_1x, Color.White); + break; + case "Production": + Contents.DrawString(33, 563, "Production", Font_1x, Color.White); + break; + + /* + * == RC Release Notice. + * TODO: This is bad practice as the list is stored on the client so as more categories are added the client will be unable to display apps from them. + * TODO: Prevent Release Candidate or Release builds until this is resolved. + * - Owen2k6 DO NOT REMOVE. + */ + } + + int pagex = 646 + 4; + if ((page + 1).ToString().Length == 2) + { + pagex -= 4; + } + + if ((page + 1).ToString().Length == 3) + { + pagex -= 8; + } + + Contents.DrawString(pagex, 563, (page + 1).ToString(), Font_1x, Color.White); + } + + private void nextPage(string useless) + { + if (RepoFilesButtonsPageNumbers.Contains(page + 1)) + { + page++; + dostuff(); + int pagex = 646 + 4; + if ((page + 1).ToString().Length == 2) + { + pagex -= 4; + } + + if ((page + 1).ToString().Length == 3) + { + pagex -= 8; + } + + Contents.DrawString(pagex, 563, (page + 1).ToString(), Font_1x, Color.White); + } + } + + private void previousPage(string useless) + { + if (RepoFilesButtonsPageNumbers.Contains(page - 1)) + { + page--; + dostuff(); + int pagex = 646 + 4; + if ((page + 1).ToString().Length == 2) + { + pagex -= 4; + } + + if ((page + 1).ToString().Length == 3) + { + pagex -= 8; + } + + Contents.DrawString(pagex, 563, (page + 1).ToString(), Font_1x, Color.White); + } + } + } +} \ No newline at end of file diff --git a/GoOS/GUI/Apps/Gosplorer.cs b/GoOS/GUI/Apps/Gosplorer.cs index b1fed48212..d8d9e46896 100644 --- a/GoOS/GUI/Apps/Gosplorer.cs +++ b/GoOS/GUI/Apps/Gosplorer.cs @@ -7,48 +7,12 @@ using PrismAPI.Graphics; using GoOS.Commands; using PrismAPI.Graphics.Fonts; +using static GoOS.Resources; namespace GoOS.GUI.Apps; public class Gosplorer : Window { - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Gosplorer.NEW.bmp")] - private static byte[] NewIconRaw; - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Gosplorer.BIN.bmp")] - private static byte[] BinIconRaw; - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Gosplorer.CHILD.bmp")] - private static byte[] ChildIconRaw; - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Gosplorer.PARENT.bmp")] - private static byte[] ParentIconRaw; - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Gosplorer.MOVE.bmp")] - private static byte[] MoveIconRaw; - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Notepad.COPY.bmp")] - private static byte[] copyIconRaw; - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Notepad.PASTE.bmp")] - private static byte[] pasteIconRaw; - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Gosplorer.REFRESH.bmp")] - private static byte[] refIconRaw; - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Gosplorer.LOADINNOTEPAD.bmp")] - private static byte[] linIconRaw; - - private static Canvas newIcon = Image.FromBitmap(NewIconRaw, false); - private static Canvas binIcon = Image.FromBitmap(BinIconRaw, false); - private static Canvas childIcon = Image.FromBitmap(ChildIconRaw, false); - private static Canvas parentIcon = Image.FromBitmap(ParentIconRaw, false); - private static Canvas moveIcon = Image.FromBitmap(MoveIconRaw, false); - private static Canvas copyIcon = Image.FromBitmap(copyIconRaw, false); - private static Canvas pasteIcon = Image.FromBitmap(pasteIconRaw, false); - private static Canvas refIcon = Image.FromBitmap(refIconRaw, false); - private static Canvas linIcon = Image.FromBitmap(linIconRaw, false); - List DAF; Button Parent; Button Child; @@ -70,7 +34,6 @@ public class Gosplorer : Window public Gosplorer() { - BetterConsole.font = new Font(BetterConsole.rawFont, BetterConsole.charHeight); Contents = new Canvas(500, 310); Title = "Gosplorer"; Visible = true; @@ -340,7 +303,6 @@ public NewFDWindow(string selected, string lcdir) cdir = lcdir; gsel = selected; - BetterConsole.font = new Font(BetterConsole.rawFont, BetterConsole.charHeight); Contents = new Canvas(300, 80); Title = "New - Gosplorer"; Visible = true; @@ -367,7 +329,7 @@ public NewFDWindow(string selected, string lcdir) Canel.Render(); Filename.Render(); - Contents.DrawString(5, 5, "Please input file name below:", BetterConsole.font, Color.White); + Contents.DrawString(5, 5, "Please input file name below:", Resources.Font_1x, Color.White); } private void OKClick() @@ -418,7 +380,6 @@ public MoveFWindow(string selected, string lcdir) gsel = selected; cdir = lcdir; - BetterConsole.font = new Font(BetterConsole.rawFont, BetterConsole.charHeight); Contents = new Canvas(300, 80); Title = "Move - Gosplorer"; Visible = true; @@ -445,7 +406,7 @@ public MoveFWindow(string selected, string lcdir) Canel.Render(); Filename.Render(); - Contents.DrawString(5, 5, "Please input new location below:", BetterConsole.font, Color.White); + Contents.DrawString(5, 5, "Please input new location below:", Resources.Font_1x, Color.White); } private void OKClick() diff --git a/GoOS/GUI/Apps/Notepad.cs b/GoOS/GUI/Apps/Notepad.cs index c072571ca2..b78b2da001 100644 --- a/GoOS/GUI/Apps/Notepad.cs +++ b/GoOS/GUI/Apps/Notepad.cs @@ -10,32 +10,12 @@ using System.Net.Security; using System.Threading; using GoOS.Security; +using static GoOS.Resources; namespace GoOS.GUI.Apps; public class Notepad : Window { - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Notepad.SAVE.bmp")] - private static byte[] saveIconRaw; - - private static Canvas saveIcon = Image.FromBitmap(saveIconRaw, false); - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Notepad.COPY.bmp")] - private static byte[] copyIconRaw; - - private static Canvas copyIcon = Image.FromBitmap(copyIconRaw, false); - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Notepad.PASTE.bmp")] - private static byte[] pasteIconRaw; - - private static Canvas pasteIcon = Image.FromBitmap(pasteIconRaw, false); - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.question.bmp")] - private static byte[] questionRaw; - - - private static Canvas question = Image.FromBitmap(questionRaw, false); - private Button SaveButton; private Button CopyButton; private Button PasteButton; @@ -347,7 +327,7 @@ public NotepadSaveAs(string placetheholderofthetextplease, string stufftosave) Contents.Clear(Color.LightGray); RenderSystemStyleBorder(); - Contents.DrawString(5, 5, "Please input file name below:", BetterConsole.font, Color.White); + Contents.DrawString(5, 5, "Please input file name below:", Resources.Font_1x, Color.White); AttemptOne.Text = placetheholderofthetextplease; AttemptOne.Text = placetheholderofthetextplease; diff --git a/GoOS/GUI/Apps/OOBE/ActivationFrame.cs b/GoOS/GUI/Apps/OOBE/ActivationFrame.cs new file mode 100644 index 0000000000..105a2f5016 --- /dev/null +++ b/GoOS/GUI/Apps/OOBE/ActivationFrame.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using GoOS.Themes; +using PrismAPI.Graphics; +using static GoOS.Resources; + +namespace GoOS.GUI.Apps.OOBE +{ + public class ActivationFrame : Window + { + Button NextButton; + String Username, Computername; + + public ActivationFrame(string username, string computername) + { + Username = username; + Computername = computername; + + // Create the window. + Contents = new Canvas(800, 600); + Title = "Activation - GoOS Setup"; + Visible = true; + Closable = false; + SetDock(WindowDock.Center); + + // Initialize the controls. + NextButton = new Button(this, 350, 456, 100, 20, "Next") { Clicked = NextButton_Click }; + + // Paint the window. + Contents.DrawImage(0, 0, OOBEblank, false); + NextButton.Render(); + Contents.DrawString(20, 5, "GoOS Online and Activation", Font_2x, Color.White); + Contents.DrawString(20, 27, "GoOS Activation is not available at this time. \nPlease continue to setup.", Font_1x, Color.White); + } + + private void NextButton_Click() + { + // Continue. + Directory.CreateDirectory(@"0:\content"); + Directory.CreateDirectory(@"0:\content\sys"); + Directory.CreateDirectory(@"0:\content\themes"); + Directory.CreateDirectory(@"0:\content\prf"); + Directory.CreateDirectory(@"0:\framework"); + Directory.CreateDirectory(@"0:\go"); + File.Create(@"0:\content\sys\option-showprotectedfiles.gms"); + File.Create(@"0:\content\sys\option-editprotectedfiles.gms"); + File.Create(@"0:\content\sys\option-deleteprotectedfiles.gms"); + File.Create(@"0:\content\sys\setup.gms"); + File.WriteAllText(@"0:\content\sys\version.gms", $"System.Version is set to {Kernel.version} \n Note to users reading this: DO NOT ALTER. IMPORTANT IF USER DATA NEEDS CONVERTING."); + File.WriteAllText(@"0:\content\sys\user.gms", $"username: {Username}\ncomputername: {Computername}"); + File.WriteAllBytes(@"0:\content\sys\resolution.gms", new byte[] { 2 }); // Video mode 2: 1280x720 + File.WriteAllText(@"0:\content\themes\default.gtheme", "Default = White\nBackground = Black\nStartup = DarkMagenta,Red,DarkRed\nWindowText = Cyan\nWindowBorder = Green\nErrorText = Red\nOther1 = Yellow"); + File.WriteAllText(@"0:\content\themes\mono.gtheme", "Default = White\nBackground = Black\nStartup = White,White,White\nWindowText = White\nWindowBorder = White\nErrorText = White\nOther1 = White"); + File.WriteAllText(@"0:\content\themes\dark.gtheme", "Default = Gray\nBackground = Black\nStartup = DarkGray,Gray,DarkGray\nWindowText = Gray\nWindowBorder = DarkGray\nErrorText = DarkGray\nOther1 = DarkGray"); + File.WriteAllText(@"0:\content\themes\light.gtheme", "Default = Black\nBackground = White\nStartup = Black,Black,Black\nWindowText = Black\nWindowBorder = Black\nErrorText = Black\nOther1 = Black"); + File.WriteAllText(@"0:\content\sys\theme.gms", "ThemeFile = " + @"0:\content\themes\default.gtheme"); + WindowManager.AddWindow(new DoneFrame()); + Dispose(); + } + } +} diff --git a/GoOS/GUI/Apps/OOBE/DoneFrame.cs b/GoOS/GUI/Apps/OOBE/DoneFrame.cs new file mode 100644 index 0000000000..bfefb14b55 --- /dev/null +++ b/GoOS/GUI/Apps/OOBE/DoneFrame.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrismAPI.Graphics; +using static GoOS.Resources; + +namespace GoOS.GUI.Apps.OOBE +{ + public class DoneFrame : Window + { + Button RestartButton; + + public DoneFrame() + { + // Create the window. + Contents = new Canvas(800, 600); + Title = "Finished - GoOS Setup"; + Visible = true; + Closable = false; + SetDock(WindowDock.Center); + + // Initialize the controls. + RestartButton = new Button(this, 350, 456, 100, 20, "Restart") { Clicked = RestartButton_Click }; + + // Paint the window. + Contents.DrawImage(0, 0, OOBEblank, false); + Contents.DrawString(20, Contents.Height / 3, "Welcome to GoOS.", Font_2x, Color.White); + Contents.DrawString(20, Contents.Height / 3+20, "We just need to restart the system in order to apply settings and load the OS fully!\nOnce you've restarted, You will be welcomed to the GoOS Desktop!", Font_1x, Color.White); + RestartButton.Render(); + } + + private void RestartButton_Click() + { + Cosmos.System.Power.Reboot(); + } + } +} diff --git a/GoOS/GUI/Apps/OOBE/MainFrame.cs b/GoOS/GUI/Apps/OOBE/MainFrame.cs new file mode 100644 index 0000000000..1e9945862f --- /dev/null +++ b/GoOS/GUI/Apps/OOBE/MainFrame.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PrismAPI.Graphics; +using static GoOS.Resources; + +namespace GoOS.GUI.Apps.OOBE +{ + public class MainFrame : Window + { + Button NextButton; + + public MainFrame() + { + // Create the window. + Contents = new Canvas(800, 600); + Title = "Welcome to GoOS"; + Visible = true; + Closable = false; + SetDock(WindowDock.Center); + + // Initialize the controls. + NextButton = new Button(this, 350, 456, 100, 20, "Next") { Clicked = NextButton_Click }; + + // Paint the window. + Contents.DrawImage(0, 0, OOBEmain, false); + NextButton.Render(); + } + + private void NextButton_Click() + { + // Continue. + WindowManager.AddWindow(new UserFrame()); + Dispose(); + } + } +} diff --git a/GoOS/GUI/Apps/OOBE/UserFrame.cs b/GoOS/GUI/Apps/OOBE/UserFrame.cs new file mode 100644 index 0000000000..70a3530f4b --- /dev/null +++ b/GoOS/GUI/Apps/OOBE/UserFrame.cs @@ -0,0 +1,48 @@ +using System.IO; +using PrismAPI.Graphics; +using static GoOS.Resources; + +namespace GoOS.GUI.Apps.OOBE +{ + public class UserFrame : Window + { + Input UserName; + Input ComputerName; + Button NextButton; + + public UserFrame() + { + // Create the window. + Contents = new Canvas(800, 600); + Title = "You and your Computer - GoOS Setup"; + Visible = true; + Closable = false; + SetDock(WindowDock.Center); + + // Initialize the controls. + UserName = new Input(this, 20, 190, 250, 20, "Enter a Username (e.g User)"); + ComputerName = new Input(this, 20, 216, 250, 20, "Name your computer (e.g MyPC)"); + NextButton = new Button(this, 20, 284, 100, 20, "Continue") { Clicked = NextButton_Click }; + + // Paint the window. + Contents.DrawImage(0, 0, OOBEblank, false); + Contents.DrawString(20, 10, "You and your Computer", Font_2x, Color.White); + Contents.DrawString(20, 50, + "Please make a username and name your computer. \nIt can be anything you want! We won't ever know or judge :) \nSpaces will be replaced with underscores (_) \nas to prevent Application compatability issues.\n\nYou will appear as user@computer in the terminal.", + Font_1x, Color.White); + Contents.DrawString(20, 246, + "Please keep in mind that this can not be changed later. \nWe plan on adding this feature in the future.", + Font_1x, Color.White); + UserName.Render(); + ComputerName.Render(); + NextButton.Render(); + } + + private void NextButton_Click() + { + // Continue. + WindowManager.AddWindow(new ActivationFrame(UserName.Text, ComputerName.Text)); + Dispose(); + } + } +} \ No newline at end of file diff --git a/GoOS/GUI/Apps/Paintbrush.cs b/GoOS/GUI/Apps/Paintbrush.cs index 384b45820b..506b704268 100644 --- a/GoOS/GUI/Apps/Paintbrush.cs +++ b/GoOS/GUI/Apps/Paintbrush.cs @@ -3,6 +3,7 @@ using GoOS.GUI.Models; using IL2CPU.API.Attribs; using PrismAPI.Graphics; +using static GoOS.Resources; namespace GoOS.GUI.Apps { @@ -16,27 +17,6 @@ public enum PaintTools public class Paintbrush : Window { - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Paint.colors.bmp")] private static byte[] colorTableRaw; - private static Canvas colorTable = Image.FromBitmap(colorTableRaw, false); - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Paint.brush.bmp")] private static byte[] brushRaw; - private static Canvas brush = Image.FromBitmap(brushRaw, false); - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Paint.bucket.bmp")] private static byte[] bucketRaw; - private static Canvas bucket = Image.FromBitmap(bucketRaw, false); - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Paint.text.bmp")] private static byte[] textRaw; - private static Canvas text = Image.FromBitmap(textRaw, false); - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.question.bmp")] private static byte[] questionRaw; - private static Canvas question = Image.FromBitmap(questionRaw, false); - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.mouse_text.bmp")] private static byte[] mouse_textRaw; - private static Canvas mouse_text = Image.FromBitmap(mouse_textRaw, false); - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.Paint.rubber.bmp")] private static byte[] rubberRaw; - private static Canvas rubber = Image.FromBitmap(rubberRaw, false); - private bool IsOverColorTable { get { return MouseManager.X > X + 54 && MouseManager.X < X + 278 && MouseManager.Y > Y + Convert.ToUInt16(Contents.Height - 26) && MouseManager.Y < Y + Convert.ToUInt16(Contents.Height + 6); } } private bool IsOverPaintableArea { get { return MouseManager.X > X && MouseManager.X < X + Contents.Width - BrushSize && MouseManager.Y > Y + TITLE_BAR_HEIGHT && MouseManager.Y < Y + Convert.ToUInt16(Contents.Height - 36); } } @@ -168,7 +148,7 @@ private void Rubber_Click() private void Text_Handler() { - Contents.DrawString(TextX, TextY, Dialog_TextBox.Text, BetterConsole.font, SelectedColor); + Contents.DrawString(TextX, TextY, Dialog_TextBox.Text, Resources.Font_1x, SelectedColor); } public override void HandleRun() diff --git a/GoOS/GUI/Apps/StartMenu.cs b/GoOS/GUI/Apps/StartMenu.cs index 33d28c25d4..8f3e2c8208 100644 --- a/GoOS/GUI/Apps/StartMenu.cs +++ b/GoOS/GUI/Apps/StartMenu.cs @@ -7,18 +7,12 @@ using IL2CPU.API.Attribs; using PrismAPI.Graphics; using PrismAPI.Hardware.GPU; +using static GoOS.Resources; namespace GoOS.GUI.Apps { public class StartMenu : Window { - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.user.bmp")] private static byte[] userImageRaw; - private static Canvas userImage = Image.FromBitmap(userImageRaw, false); - - [ManifestResourceStream(ResourceName = "GoOS.Resources.GUI.shutdown.bmp")] private static byte[] shutdownIconRaw; - private static Canvas shutdownIcon = Image.FromBitmap(shutdownIconRaw, false); - - List