Skip to content

Commit

Permalink
add - Added DanceNumbers
Browse files Browse the repository at this point in the history
---

We've added another screensaver: DanceNumbers, based on the codebase of
DanceLines

---

Type: add
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Dec 26, 2024
1 parent 0abd04b commit 8649938
Show file tree
Hide file tree
Showing 4 changed files with 389 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6486,5 +6486,92 @@
"Description": "How many milliseconds to wait before making the next write?"
}
]
},
{
"Name": "DanceNumbers",
"Desc": "Shows you dancing numbers.",
"Keys": [
{
"Name": "Activate true colors",
"Type": "SBoolean",
"Variable": "DanceNumbersTrueColor",
"Description": "Activates the true color support."
},
{
"Name": "Delay in Milliseconds",
"Type": "SInt",
"Variable": "DanceNumbersDelay",
"Description": "How many milliseconds to wait before making the next write?"
},
{
"Name": "Background color",
"Type": "SColor",
"Variable": "DanceNumbersBackgroundColor"
},
{
"Name": "Minimum red color level",
"Type": "SIntSlider",
"Variable": "DanceNumbersMinimumRedColorLevel",
"Description": "Minimum red color level. The minimum accepted value is 0 and the maximum accepted value is 255.",
"MinimumValue": 0,
"MaximumValue": 255
},
{
"Name": "Minimum green color level",
"Type": "SIntSlider",
"Variable": "DanceNumbersMinimumGreenColorLevel",
"Description": "Minimum green color level. The minimum accepted value is 0 and the maximum accepted value is 255.",
"MinimumValue": 0,
"MaximumValue": 255
},
{
"Name": "Minimum blue color level",
"Type": "SIntSlider",
"Variable": "DanceNumbersMinimumBlueColorLevel",
"Description": "Minimum blue color level. The minimum accepted value is 0 and the maximum accepted value is 255.",
"MinimumValue": 0,
"MaximumValue": 255
},
{
"Name": "Minimum color level",
"Type": "SIntSlider",
"Variable": "DanceNumbersMinimumColorLevel",
"Description": "Minimum color level. The minimum accepted value is 0 and the maximum accepted value is 255 for 255 colors or 16 for 16 colors.",
"MinimumValue": 0,
"MaximumValue": 255
},
{
"Name": "Maximum red color level",
"Type": "SIntSlider",
"Variable": "DanceNumbersMaximumRedColorLevel",
"Description": "Maximum red color level. The minimum accepted value is 0 and the maximum accepted value is 255.",
"MinimumValue": 0,
"MaximumValue": 255
},
{
"Name": "Maximum green color level",
"Type": "SIntSlider",
"Variable": "DanceNumbersMaximumGreenColorLevel",
"Description": "Maximum green color level. The minimum accepted value is 0 and the maximum accepted value is 255.",
"MinimumValue": 0,
"MaximumValue": 255
},
{
"Name": "Maximum blue color level",
"Type": "SIntSlider",
"Variable": "DanceNumbersMaximumBlueColorLevel",
"Description": "Maximum blue color level. The minimum accepted value is 0 and the maximum accepted value is 255.",
"MinimumValue": 0,
"MaximumValue": 255
},
{
"Name": "Maximum color level",
"Type": "SIntSlider",
"Variable": "DanceNumbersMaximumColorLevel",
"Description": "Maximum color level. The minimum accepted value is 0 and the maximum accepted value is 255 for 255 colors or 16 for 16 colors.",
"MinimumValue": 0,
"MaximumValue": 255
}
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ internal class ScreensaverPackInit : IAddon
{ "colormix", new ColorMixDisplay() },
{ "commitmilestone", new CommitMilestoneDisplay() },
{ "dancelines", new DanceLinesDisplay() },
{ "dancenumbers", new DanceNumbersDisplay() },
{ "dateandtime", new DateAndTimeDisplay() },
{ "diamond", new DiamondDisplay() },
{ "disco", new DiscoDisplay() },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//
// Nitrocid KS Copyright (C) 2018-2025 Aptivi
//
// This file is part of Nitrocid KS
//
// Nitrocid KS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Nitrocid KS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY, without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using Nitrocid.Drivers.RNG;
using Nitrocid.Kernel.Debugging;
using Nitrocid.Kernel.Threading;
using Nitrocid.Misc.Screensaver;
using Terminaux.Base;
using Terminaux.Colors;
using Nitrocid.Kernel.Configuration;
using System.Text;

namespace Nitrocid.ScreensaverPacks.Screensavers
{
/// <summary>
/// Display code for DanceNumbers
/// </summary>
public class DanceNumbersDisplay : BaseScreensaver, IScreensaver
{

/// <inheritdoc/>
public override string ScreensaverName =>
"DanceNumbers";

/// <inheritdoc/>
public override void ScreensaverPreparation()
{
// Variable preparations
DebugWriter.WriteDebug(DebugLevel.I, "Console geometry: {0}x{1}", ConsoleWrapper.WindowWidth, ConsoleWrapper.WindowHeight);
}

/// <inheritdoc/>
public override void ScreensaverLogic()
{
ConsoleWrapper.CursorVisible = false;
ColorTools.LoadBackDry(new Color(ScreensaverPackInit.SaversConfig.DanceNumbersBackgroundColor));

// Draw few numbers
for (int i = 0; i < ConsoleWrapper.WindowHeight; i++)
{
// Draw a randomly-sized line
int width = RandomDriver.Random(ConsoleWrapper.WindowWidth);
StringBuilder numbers = new();
for (int j = 0; j < width; j++)
numbers.Append(RandomDriver.Random(9));
string line = numbers.ToString();

// Select a color
if (ScreensaverPackInit.SaversConfig.DanceNumbersTrueColor)
{
int RedColorNum = RandomDriver.Random(ScreensaverPackInit.SaversConfig.DanceNumbersMinimumRedColorLevel, ScreensaverPackInit.SaversConfig.DanceNumbersMaximumRedColorLevel);
int GreenColorNum = RandomDriver.Random(ScreensaverPackInit.SaversConfig.DanceNumbersMinimumGreenColorLevel, ScreensaverPackInit.SaversConfig.DanceNumbersMaximumGreenColorLevel);
int BlueColorNum = RandomDriver.Random(ScreensaverPackInit.SaversConfig.DanceNumbersMinimumBlueColorLevel, ScreensaverPackInit.SaversConfig.DanceNumbersMaximumBlueColorLevel);
DebugWriter.WriteDebugConditional(Config.MainConfig.ScreensaverDebug, DebugLevel.I, "Got color (R;G;B: {0};{1};{2})", RedColorNum, GreenColorNum, BlueColorNum);
var ColorStorage = new Color(RedColorNum, GreenColorNum, BlueColorNum);
ColorTools.SetConsoleColor(ColorStorage);
}
else
{
int color = RandomDriver.Random(ScreensaverPackInit.SaversConfig.DanceNumbersMinimumColorLevel, ScreensaverPackInit.SaversConfig.DanceNumbersMaximumColorLevel);
DebugWriter.WriteDebugConditional(Config.MainConfig.ScreensaverDebug, DebugLevel.I, "Got color ({0})", color);
ColorTools.SetConsoleColor(new Color(color));
}

// Now, draw a line
DebugWriter.WriteDebugConditional(Config.MainConfig.ScreensaverDebug, DebugLevel.I, "Got top position ({0})", i);
if (!ConsoleResizeHandler.WasResized(false))
{
ConsoleWrapper.SetCursorPosition(0, i);
ConsoleWrapper.Write(line);
}
}

// Reset resize sync
ConsoleResizeHandler.WasResized();
ThreadManager.SleepNoBlock(ScreensaverPackInit.SaversConfig.DanceNumbersDelay, ScreensaverDisplayer.ScreensaverDisplayerThread);
}

}
}
Loading

0 comments on commit 8649938

Please sign in to comment.