Skip to content

Commit

Permalink
ref - brk|doc - Figlet tools class moved to Terminaux 3.0
Browse files Browse the repository at this point in the history
---

We've moved the FigletTextTools class from Nitrocid to Terminaux.

---

Type: ref
Breaking: True
Doc Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed Feb 9, 2024
1 parent 818526c commit 158a77c
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
using Terminaux.Base;
using Nitrocid.Users.Login.Motd;
using Nitrocid.Network.Types.RSS;
using Nitrocid.Kernel.Configuration;

namespace Nitrocid.Extras.Docking.Dock.Docks
{
Expand Down Expand Up @@ -112,7 +113,7 @@ static string UpdateHeadline()
CsiSequences.GenerateCsiEraseInDisplay(0)
);
cachedTimeStr = TimeDateRenderers.RenderTime(FormatType.Short);
var figFont = FigletTools.GetFigletFont(FigletTextTools.DefaultFigletFontName);
var figFont = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);
int figHeight = FigletTools.GetFigletHeight(timeStr, figFont) / 2;
display.Append(
clockColor.VTSequenceForeground +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using Terminaux.Colors;
using Terminaux.Base;
using Terminaux.Colors.Data;
using Nitrocid.Kernel.Configuration;

namespace Nitrocid.ScreensaverPacks.Animations.ExcaliBeats
{
Expand Down Expand Up @@ -107,7 +108,7 @@ public static void Simulate(ExcaliBeatsSettings Settings)

// Populate the text
string exStr = Settings.ExcaliBeatsExplicit ? "EXCALIBUR" : "EXCALIBEATS";
var figFont = FigletTools.GetFigletFont(FigletTextTools.DefaultFigletFontName);
var figFont = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);

// Fade out
for (int CurrentStep = 1; CurrentStep <= maxSteps; CurrentStep++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using Nitrocid.Kernel.Time;
using Nitrocid.Languages;
using Terminaux.Base;
using Nitrocid.Kernel.Configuration;

namespace Nitrocid.ScreensaverPacks.Screensavers
{
Expand Down Expand Up @@ -69,7 +70,7 @@ public override void ScreensaverLogic()
Color white = new(255, 255, 255);
Color selectedColor = Color.Empty;
string year = "2018";
var font = FigletTools.GetFigletFont(FigletTextTools.DefaultFigletFontName);
var font = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);

// Start stepping
for (step = 1; step <= maxSteps; step++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using Nitrocid.ScreensaverPacks.Animations.Glitch;
using Nitrocid.Languages;
using Nitrocid.Kernel.Time.Renderers;
using Nitrocid.Kernel.Configuration;

namespace Nitrocid.ScreensaverPacks.Screensavers
{
Expand Down Expand Up @@ -64,7 +65,7 @@ public override void ScreensaverLogic()
Color blue = new(0, 0, 255);
Color black = new(0, 0, 0);
Color white = new(255, 255, 255);
var font = FigletTools.GetFigletFont(FigletTextTools.DefaultFigletFontName);
var font = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);
int colorSteps = 30;
int currentR = 0;
int currentG = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using Nitrocid.Kernel.Threading;
using Terminaux.Base;
using Terminaux.Colors.Data;
using Nitrocid.Kernel.Configuration;

namespace Nitrocid.ScreensaverPacks.Screensavers
{
Expand Down Expand Up @@ -67,7 +68,7 @@ public override void ScreensaverLogic()
{
// We're at the new year!
string currentYearStr = currentYear.ToString();
var figFont = FigletTools.GetFigletFont(FigletTextTools.DefaultFigletFontName);
var figFont = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);
int figHeight = FigletTools.GetFigletHeight(currentYearStr, figFont) / 2;
CenteredFigletTextColor.WriteCenteredFigletColorBack(figFont, currentYearStr, green, black);

Expand All @@ -81,7 +82,7 @@ public override void ScreensaverLogic()
{
// Print the countdown, but print the next year first using Figlet
string nextYearStr = $"{currentYear + 1}";
var figFont = FigletTools.GetFigletFont(FigletTextTools.DefaultFigletFontName);
var figFont = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);
int figHeight = FigletTools.GetFigletHeight(nextYearStr, figFont) / 2;
CenteredFigletTextColor.WriteCenteredFigletColorBack(figFont, nextYearStr, darkGreen, black);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Nitrocid.Kernel;
using Terminaux.Base;
using Terminaux.Colors.Data;
using Nitrocid.Kernel.Configuration;

namespace Nitrocid.SplashPacks.Splashes
{
Expand All @@ -57,7 +58,7 @@ public override string Opening(SplashContext context)
// Write a glorious Welcome screen
Color col = KernelColorTools.GetColor(KernelColorType.Stage);
string text = $"{SplashReport.Progress}%";
var figFont = FigletTools.GetFigletFont(FigletTextTools.DefaultFigletFontName);
var figFont = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);
int figWidth = FigletTools.GetFigletWidth(text, figFont) / 2;
int figHeight = FigletTools.GetFigletHeight(text, figFont) / 2;
int consoleX, consoleY;
Expand Down Expand Up @@ -150,7 +151,7 @@ public override string Closing(SplashContext context, out bool delayRequired)
Translate.DoTranslation("Welcome!") :
Translate.DoTranslation("Goodbye!"))
.ToUpper();
var figFont = FigletTools.GetFigletFont(FigletTextTools.DefaultFigletFontName);
var figFont = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);
var figFontFallback = FigletTools.GetFigletFont("small");
int figWidth = FigletTools.GetFigletWidth(text, figFont) / 2;
int figHeight = FigletTools.GetFigletHeight(text, figFont) / 2;
Expand Down Expand Up @@ -216,7 +217,7 @@ private string ReportProgress(int Progress, string ProgressReport, KernelColorTy
var builder = new StringBuilder();
Color col = KernelColorTools.GetColor(colorType);
string text = $"{Progress}%";
var figFont = FigletTools.GetFigletFont(FigletTextTools.DefaultFigletFontName);
var figFont = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);
int figHeight = FigletTools.GetFigletHeight(text, figFont) / 2;
int consoleY = ConsoleWrapper.WindowHeight / 2 - figHeight;
builder.Append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static void WriteMessage()
TextWriters.Write(MessageWrite, true, KernelColorType.Banner, KernelMain.VersionFullStr);
}

string FigletRenderedBanner = FigletTools.RenderFiglet($"{KernelMain.VersionFullStr}", FigletTextTools.DefaultFigletFontName);
string FigletRenderedBanner = FigletTools.RenderFiglet($"{KernelMain.VersionFullStr}", Config.MainConfig.DefaultFigletFontName);
TextWriterColor.Write(CharManager.NewLine + FigletRenderedBanner + CharManager.NewLine);
ConsoleWrapper.CursorVisible = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class KernelMainConfig : BaseKernelConfig, IKernelConfig
public override SettingsEntry[] SettingsEntries =>
ConfigTools.GetSettingsEntries(Resources.SettingsResources.SettingsEntries);

[JsonIgnore]
private string defaultFigletFontName = "speed";

#region General
/// <summary>
/// Each startup, it will check for updates.
Expand Down Expand Up @@ -1379,8 +1382,8 @@ public char BorderRightFrameChar
/// </summary>
public string DefaultFigletFontName
{
get => FigletTextTools.defaultFigletFontName;
set => FigletTextTools.defaultFigletFontName = FigletTools.GetFigletFonts().ContainsKey(value) ? value : "speed";
get => defaultFigletFontName;
set => defaultFigletFontName = FigletTools.GetFigletFonts().ContainsKey(value) ? value : "speed";
}
/// <summary>
/// Whether to update the CPU usage or not
Expand Down
7 changes: 4 additions & 3 deletions public/Nitrocid/Misc/Splash/Splashes/Welcome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Nitrocid.Kernel.Power;
using Terminaux.Base;
using Terminaux.Colors.Data;
using Nitrocid.Kernel.Configuration;

namespace Nitrocid.Misc.Splash.Splashes
{
Expand Down Expand Up @@ -69,7 +70,7 @@ public override string Opening(SplashContext context)
Translate.DoTranslation("Please wait") :
Translate.DoTranslation("Loading"))
.ToUpper();
var figFont = FigletTools.GetFigletFont(FigletTextTools.DefaultFigletFontName);
var figFont = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);
int consoleY = (ConsoleWrapper.WindowHeight / 2) + FigletTools.GetFigletHeight(text, figFont);
builder.Append(
col.VTSequenceForeground +
Expand Down Expand Up @@ -184,7 +185,7 @@ public override string Closing(SplashContext context, out bool delayRequired)
Translate.DoTranslation("Welcome!") :
Translate.DoTranslation("Goodbye!"))
.ToUpper();
var figFont = FigletTools.GetFigletFont(FigletTextTools.DefaultFigletFontName);
var figFont = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);
int consoleY = (ConsoleWrapper.WindowHeight / 2) + FigletTools.GetFigletHeight(text, figFont);
builder.Append(
col.VTSequenceForeground +
Expand Down Expand Up @@ -217,7 +218,7 @@ private string ReportProgress(int Progress, string ProgressReport, KernelColorTy
Translate.DoTranslation("Welcome!") :
Translate.DoTranslation("Goodbye!"))
.ToUpper();
var figFont = FigletTools.GetFigletFont(FigletTextTools.DefaultFigletFontName);
var figFont = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);
int figHeight = FigletTools.GetFigletHeight(text, figFont) / 2;
int consoleY = ConsoleWrapper.WindowHeight / 2 - figHeight;
builder.Append(
Expand Down
37 changes: 0 additions & 37 deletions public/Nitrocid/Misc/Text/FigletTextTools.cs

This file was deleted.

2 changes: 1 addition & 1 deletion public/Nitrocid/Nitrocid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<NitrocidModAPIVersionMajor>3.0.25</NitrocidModAPIVersionMajor>

<!-- Increment NitrocidModAPIVersionChangeset every time there is a breaking change or an API addition in the N-KS API. -->
<NitrocidModAPIVersionChangeset>416</NitrocidModAPIVersionChangeset>
<NitrocidModAPIVersionChangeset>417</NitrocidModAPIVersionChangeset>

<!-- To be installed to the file version -->
<NitrocidModAPIVersion>$(NitrocidModAPIVersionMajor).$(NitrocidModAPIVersionChangeset)</NitrocidModAPIVersion>
Expand Down
2 changes: 1 addition & 1 deletion public/Nitrocid/Users/Login/ModernLogonScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static string UpdateHeadline()
CsiSequences.GenerateCsiEraseInDisplay(0)
);
cachedTimeStr = TimeDateRenderers.RenderTime(FormatType.Short);
var figFont = FigletTools.GetFigletFont(FigletTextTools.DefaultFigletFontName);
var figFont = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);
int figHeight = FigletTools.GetFigletHeight(timeStr, figFont) / 2;
display.Append(
KernelColorTools.GetColor(KernelColorType.Stage).VTSequenceForeground +
Expand Down

0 comments on commit 158a77c

Please sign in to comment.