Skip to content

Commit

Permalink
Merge pull request #109 from Owen2k6/1.5
Browse files Browse the repository at this point in the history
1.5.2
  • Loading branch information
Owen2k6 authored Mar 16, 2024
2 parents b7365ca + 28127af commit 3b91af6
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 84 deletions.
74 changes: 37 additions & 37 deletions GoOS/BetterConsole/BetterConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
/// <summary>
/// <see cref="BetterConsole"/> class
/// </summary>
public static class BetterConsole //Shitter Console
public static class BetterConsole
{
/* The canvas for the console */
public static Canvas Canvas;

/* Character width and height */
public static ushort charWidth = 8, charHeight = 16;
public const ushort CharWidth = 8;
public const ushort CharHeight = 16;

private static List<string> menuOptions = new()
private static readonly List<string> MenuOptions = new()
{
"Launch Settings",
"Reboot"
Expand All @@ -30,7 +31,7 @@ public static class BetterConsole //Shitter Console

/// <summary>
/// The X position of the cursor
/// </remarks>
/// </summary>
public static int CursorLeft = 0;

/// <summary>
Expand All @@ -51,12 +52,12 @@ public static class BetterConsole //Shitter Console
/// <summary>
/// The foreground color of the <see cref="BetterConsole"/>
/// </summary>
public static Color ForegroundColor = Color.White;
public static Color ForegroundColor = ConsoleColorEx.White;

/// <summary>
/// The background color of the <see cref="BetterConsole"/>
/// </summary>
public static Color BackgroundColor = Color.Black;
public static Color BackgroundColor = ConsoleColorEx.Black;

/// <summary>
/// Determines if the cursor is visible
Expand All @@ -74,18 +75,17 @@ public static class BetterConsole //Shitter Console
public static Queue<KeyEvent> KeyBuffer = new Queue<KeyEvent>();

public static string Title = "GTerm";

/// <summary>
/// Initializes the <see cref="BetterConsole">
/// </summary>
/// <param name="videoWidth">The width of the canvas</param>
/// <param name="videoHeight">The height of the canvas</param>
public static void Init(ushort width, ushort height)
{
//Canvas = Display.GetDisplay(width, height);
Canvas = new Canvas(width, height);
WindowWidth = Convert.ToUInt16(width / charWidth);
WindowHeight = Convert.ToUInt16(height / charHeight);
WindowWidth = (ushort)(width / CharWidth);
WindowHeight = (ushort)(height / CharHeight);
Canvas.Clear();
}

Expand Down Expand Up @@ -152,7 +152,7 @@ public static ConsoleKeyInfo ReadKey(bool intercept = true)
{
if (CursorVisible)
{
Canvas.DrawString(CursorLeft * charWidth, CursorTop * charHeight, '_'.ToString(), Font_1x, ForegroundColor);
Canvas.DrawString(CursorLeft * CharWidth, CursorTop * CharHeight, '_'.ToString(), Font_1x, ForegroundColor);
}

var keyPressed = KeyBuffer.TryDequeue(out var key);
Expand All @@ -177,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_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);
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);
}
}
}
Expand All @@ -190,7 +190,7 @@ public static ConsoleKeyInfo ReadKey(bool intercept = true)
/// <summary>
/// Gets input from the user
/// </summary>
/// <returns>The teCursorLeftt that the user typed</returns>
/// <returns>The text that the user typed</returns>
public static string ReadLine()
{
int startCursorLeft = CursorLeft, startY = CursorTop;
Expand Down Expand Up @@ -226,7 +226,7 @@ public static string ReadLine()
{
PutChar(' ', CursorLeft, CursorTop); // Erase the cursor
CursorTop--;
CursorLeft = Canvas.Width / charWidth - 1;
CursorLeft = Canvas.Width / CharWidth - 1;
PutChar(' ', CursorLeft, CursorTop); // Erase the actual character
}
else
Expand Down Expand Up @@ -287,24 +287,24 @@ public static string ReadLine()

Clear();
Canvas.DrawRectangle((Canvas.Width / 2) - (144 / 2) + 0,
(Canvas.Height / 2) - ((menuOptions.Count + 4) * 16 / 2) + 0, 144,
Convert.ToUInt16((menuOptions.Count + 4) * 16), 0, ThemeManager.WindowBorder);
(Canvas.Height / 2) - ((MenuOptions.Count + 4) * 16 / 2) + 0, 144,
Convert.ToUInt16((MenuOptions.Count + 4) * 16), 0, ThemeManager.WindowBorder);
Canvas.DrawRectangle((Canvas.Width / 2) - (144 / 2) + 1,
(Canvas.Height / 2) - ((menuOptions.Count + 4) * 16 / 2) + 1, 144,
Convert.ToUInt16((menuOptions.Count + 4) * 16), 0, ThemeManager.WindowBorder);
(Canvas.Height / 2) - ((MenuOptions.Count + 4) * 16 / 2) + 1, 144,
Convert.ToUInt16((MenuOptions.Count + 4) * 16), 0, ThemeManager.WindowBorder);

Refresh:
if (selected > menuOptions.Count - 1)
Refresh:
if (selected > MenuOptions.Count - 1)
{
selected = 0;
}

if (selected < 0)
{
selected = menuOptions.Count - 1;
selected = MenuOptions.Count - 1;
}

for (int i = 0; i < menuOptions.Count; i++)
for (int i = 0; i < MenuOptions.Count; i++)
{
SetCursorPosition((WindowWidth / 2) - (15 / 2) - 1,
(WindowHeight / 2) - 1 + (i * 2));
Expand All @@ -319,7 +319,7 @@ public static string ReadLine()
BackgroundColor = ThemeManager.Background;
}

Write(menuOptions[i]);
Write(MenuOptions[i]);
}

var key2 = KeyboardManager.ReadKey();
Expand All @@ -329,9 +329,9 @@ public static string ReadLine()
break;

case ConsoleKeyEx.Enter:
if (menuOptions[selected] == menuOptions[0])
if (MenuOptions[selected] == MenuOptions[0])
GoOS.ControlPanel.Launch();
else if (menuOptions[selected] == menuOptions[1])
else if (MenuOptions[selected] == MenuOptions[1])
Power.Reboot();
break;

Expand Down Expand Up @@ -397,18 +397,18 @@ public static void Beep(uint freq = 800, uint duration = 125)

private static void Newline()
{
if (CursorLeft >= Canvas.Width / charWidth)
if (CursorLeft >= Canvas.Width / CharWidth)
{
CursorLeft = 0;
CursorTop++;
}

if (CursorTop >= Canvas.Height / charHeight)
if (CursorTop >= Canvas.Height / CharHeight)
{
Canvas.DrawImage(0, -charHeight, Canvas, false);
Canvas.DrawFilledRectangle(0, Canvas.Height - charHeight, Canvas.Width, charHeight, 0, Color.Black);
Canvas.DrawImage(0, -CharHeight, Canvas, false);
Canvas.DrawFilledRectangle(0, Canvas.Height - CharHeight, Canvas.Width, CharHeight, 0, Color.Black);
CursorLeft = 0;
CursorTop = (Canvas.Height / charHeight) - 1;
CursorTop = (Canvas.Height / CharHeight) - 1;

if (!DoubleBufferedMode)
Render();
Expand All @@ -420,10 +420,10 @@ private static void Newline()
public static void PutChar(char c, int CursorLeft, int y, bool quick = false)
{
if (!quick)
Canvas.DrawFilledRectangle(CursorLeft * charWidth, y * charHeight,
Convert.ToUInt16(charWidth + (charWidth / 8)), charHeight, 0, BackgroundColor); //yes this is correct
Canvas.DrawFilledRectangle(CursorLeft * CharWidth, y * CharHeight,
Convert.ToUInt16(CharWidth + (CharWidth / 8)), CharHeight, 0, BackgroundColor);
if (c != ' ')
Canvas.DrawString(CursorLeft * charWidth, y * charHeight, c.ToString(), Font_1x, ForegroundColor);
Canvas.DrawString(CursorLeft * CharWidth, y * CharHeight, c.ToString(), Font_1x, ForegroundColor);
}

#endregion
Expand All @@ -450,4 +450,4 @@ public static class ConsoleColorEx
public static readonly Color Magenta = new Color(255, 85, 255);
public static readonly Color Yellow = new Color(255, 255, 85);
public static readonly Color White = new Color(255, 255, 255);
}
}
8 changes: 6 additions & 2 deletions GoOS/GUI/Apps/About.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using IL2CPU.API.Attribs;
using GoGL.Graphics;
using GoOS._9xCode;

namespace GoOS.GUI.Apps
{
Expand All @@ -13,15 +14,18 @@ public class About : Window
public About()
{
// Create the window.
Contents = new Canvas(200, 180);
Contents = new Canvas(200, 220);
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);
Contents.DrawString(10, 152, "GoOS "+Kernel.version, Resources.Font_1x, Color.White);
Contents.DrawString(10, 164, "GoGL "+new GoGL.Info().getVersion(), Resources.Font_1x, Color.White);
Contents.DrawString(10, 176, "GoCode "+GoCode.GoCode.Version, Resources.Font_1x, Color.White);
Contents.DrawString(10, 188, "9xCode "+Interpreter.Version, Resources.Font_1x, Color.White);
}
}
}
27 changes: 7 additions & 20 deletions GoOS/GUI/Apps/GoStore/MainFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,8 @@ public class MainFrame : Window

public static readonly List<string> AllowDLFrom = new List<string>
{
"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.
*/

private Canvas _infoBoard;
private string _infoBoardText;

Expand Down Expand Up @@ -123,13 +110,13 @@ public MainFrame()
else
{
Contents.DrawImage(0, 0, Resources.GoStoreSoon, false);
long unixTime = Convert.ToInt64(1707955200); //1707955200
DateTime targetDate = DateTimeOffset.FromUnixTimeSeconds(unixTime).DateTime;
DateTime currentDate = DateTime.UtcNow;

TimeSpan difference = targetDate - currentDate;
int daysUntil = (int)difference.TotalDays;
Contents.DrawString(290, 467, daysUntil+" Days left", Resources.Font_2x, Color.Green);
// long unixTime = Convert.ToInt64(1707955200); //1707955200
// DateTime targetDate = DateTimeOffset.FromUnixTimeSeconds(unixTime).DateTime;
// DateTime currentDate = DateTime.UtcNow;
//
// TimeSpan difference = targetDate - currentDate;
// int daysUntil = (int)difference.TotalDays;
// Contents.DrawString(290, 467, daysUntil+" Days left", Resources.Font_2x, Color.Green);
RenderSystemStyleBorder();
}
}
Expand Down
2 changes: 2 additions & 0 deletions GoOS/GoCode/GoCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

namespace GoOS.GoCode;


public class GoCode
{
public static string Version = "0.0.1";
public static void Run(string file, bool usecurrentdir = true, bool unnecessaryOutputs = true)
{
try
Expand Down
4 changes: 4 additions & 0 deletions GoOS/GoOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@
<EmbeddedResource Include="Resources\GUI\TaskStart\taskbar.bmp" />
<None Remove="Resources\GUI\GoStoreSoon.bmp" />
<EmbeddedResource Include="Resources\GUI\GoStoreSoon.bmp" />
<None Remove="Resources\GUI\boot.bmp" />
<EmbeddedResource Include="Resources\GUI\boot.bmp" />
<None Remove="Resources\GUI\bootlogo.bmp" />
<EmbeddedResource Include="Resources\GUI\bootlogo.bmp" />
</ItemGroup>

<PropertyGroup>
Expand Down
Loading

0 comments on commit 3b91af6

Please sign in to comment.