Skip to content

Commit

Permalink
imp - bkp - Widgets now only initialize one in TNH
Browse files Browse the repository at this point in the history
---

In "The Nitrocid Homepage", a selected widget must only initialize once.

  - Backportable for 0.1.1.x

---

Type: imp
Breaking: False
Doc Required: False
Backport Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed Jan 3, 2025
1 parent 9cc5273 commit 79f7bc8
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions public/Nitrocid/Shell/Homepage/HomepageTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ public static void OpenHomepage()
ScreenTools.SetCurrent(homeScreen);
ColorTools.LoadBack();

// Prepare the widget
var widget =
WidgetTools.CheckWidget(Config.MainConfig.HomepageWidget) ?
WidgetTools.GetWidget(Config.MainConfig.HomepageWidget) :
WidgetTools.GetWidget(nameof(AnalogClock));
if (Config.MainConfig.EnableHomepageWidgets)
{
int widgetLeft = ConsoleWrapper.WindowWidth / 2 + ConsoleWrapper.WindowWidth % 2;
int widgetWidth = ConsoleWrapper.WindowWidth / 2 - 4;
int widgetHeight = ConsoleWrapper.WindowHeight - 11;
int widgetTop = 2;
string widgetInit = widget.Initialize(widgetLeft + 1, widgetTop + 1, widgetWidth, widgetHeight);
TextWriterRaw.WriteRaw(widgetInit);
}

// Now, render the homepage
homeScreenBuffer.AddDynamicText(() =>
{
Expand Down Expand Up @@ -174,13 +189,8 @@ public static void OpenHomepage()
// Render the widget
if (Config.MainConfig.EnableHomepageWidgets)
{
var widget =
WidgetTools.CheckWidget(Config.MainConfig.HomepageWidget) ?
WidgetTools.GetWidget(Config.MainConfig.HomepageWidget) :
WidgetTools.GetWidget(nameof(AnalogClock));
string widgetInit = widget.Initialize(widgetLeft + 1, widgetTop + 1, widgetWidth, widgetHeight);
string widgetSeq = widget.Render(widgetLeft + 1, widgetTop + 1, widgetWidth, widgetHeight);
builder.Append(widgetInit + widgetSeq);
builder.Append(widgetSeq);
}

// Render the first three RSS feeds
Expand Down

0 comments on commit 79f7bc8

Please sign in to comment.