Skip to content

Commit

Permalink
imp - Timer now has color
Browse files Browse the repository at this point in the history
---

Added color to the timer for better look.

---

Type: imp
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Feb 28, 2024
1 parent 4222f87 commit 56b7052
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Terminaux.Colors;
using Terminaux.Base;
using Terminaux.Reader;
using Nitrocid.Drivers.RNG;

namespace Nitrocid.Extras.Timers.Timers
{
Expand All @@ -46,6 +47,7 @@ public static class TimerScreen
internal static int FigletTimeOldWidthEnd;
internal static string timerFigletFont = "Small";
internal static bool running;
internal static Color timerColor;
private static Timer _Timer;

internal static Timer Timer
Expand Down Expand Up @@ -94,6 +96,10 @@ public static void OpenTimer()
ColorTools.LoadBack();

// Populate the figlet font (if any)
int RedValue = RandomDriver.Random(255);
int GreenValue = RandomDriver.Random(255);
int BlueValue = RandomDriver.Random(255);
timerColor = new(RedValue, GreenValue, BlueValue);
var FigletFont = FigletTools.GetFigletFont(TimerFigletFont);

// Populate the time
Expand Down Expand Up @@ -145,13 +151,13 @@ public static void OpenTimer()
if (TimersInit.TimersConfig.EnableFigletTimer)
{
builder.Append(
FigletWhereColor.RenderFigletWhere(UntilText, TimeLeftPosition, TimeTopPosition, true, FigletFont, KernelColorTools.GetColor(KernelColorType.NeutralText), KernelColorTools.GetColor(KernelColorType.Background))
FigletWhereColor.RenderFigletWhere(UntilText, TimeLeftPosition, TimeTopPosition, true, FigletFont, timerColor, KernelColorTools.GetColor(KernelColorType.Background))
);
}
else
{
builder.Append(
TextWriterWhereColor.RenderWhereColorBack(UntilText, TimeLeftPosition, TimeTopPosition, true, KernelColorTools.GetColor(KernelColorType.NeutralText), KernelColorTools.GetColor(KernelColorType.Background))
TextWriterWhereColor.RenderWhereColorBack(UntilText, TimeLeftPosition, TimeTopPosition, true, timerColor, KernelColorTools.GetColor(KernelColorType.Background))
);
}
Expand Down Expand Up @@ -236,6 +242,10 @@ private static void TimerElapsed(object sender, ElapsedEventArgs e)
{
running = false;
Timer.Stop();
int RedValue = RandomDriver.Random(255);
int GreenValue = RandomDriver.Random(255);
int BlueValue = RandomDriver.Random(255);
timerColor = new(RedValue, GreenValue, BlueValue);
}

/// <summary>
Expand Down Expand Up @@ -284,12 +294,12 @@ private static void ClearRemainingTimeDisplay(string RemainingTimeText, int Figl
for (int Position = FigletOldWidth - 1; Position <= FigletTimeLeftPosition - 1; Position++)
{
ConsoleWrapper.CursorLeft = Position;
TextWriterColor.WriteColorBack(" ", false, KernelColorTools.GetColor(KernelColorType.NeutralText), KernelColorTools.GetColor(KernelColorType.Background));
TextWriterColor.Write(" ", false);
}
for (int Position = FigletOldWidthEnd; Position <= FigletTimeLeftEndPosition + 1; Position++)
{
ConsoleWrapper.CursorLeft = Position;
TextWriterColor.WriteColorBack(" ", false, KernelColorTools.GetColor(KernelColorType.NeutralText), KernelColorTools.GetColor(KernelColorType.Background));
TextWriterColor.Write(" ", false);
}
}
}
Expand Down

0 comments on commit 56b7052

Please sign in to comment.