patch: listplugs, plugin version system and progress bar

This commit is contained in:
2022-08-25 15:15:47 +03:00
parent b98f57fcf8
commit f6442af30c
10 changed files with 210 additions and 55 deletions

View File

@@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace PluginManager.Others
{
@@ -33,15 +32,21 @@ namespace PluginManager.Others
/// </summary>
public class ProgressBar
{
public ProgressBar(ProgressBarType type)
{
this.type = type;
}
public float Max { get; init; }
public ConsoleColor Color { get; init; }
public bool NoColor { get; init; }
public ProgressBarType type { get; set; }
private int BarLength = 32;
private int position = 1;
private bool positive = true;
public void Update(ProgressBarType type, float progress)
public void Update(float progress)
{
switch (type)
{
@@ -52,6 +57,8 @@ namespace PluginManager.Others
if (progress <= 99.9f)
UpdateNoEnd();
return;
default:
return;
}
}
@@ -81,6 +88,8 @@ namespace PluginManager.Others
Console.CursorLeft = 1;
float onechunk = 30.0f / Max;
int position = 1;
for (int i = 0; i < onechunk * progress; i++)
{
Console.BackgroundColor = NoColor ? ConsoleColor.Black : this.Color;
@@ -88,14 +97,14 @@ namespace PluginManager.Others
Console.Write("#");
}
for (int i = position; i <= BarLength - 1; i++)
for (int i = position; i < BarLength; i++)
{
Console.BackgroundColor = NoColor ? ConsoleColor.Black : ConsoleColor.DarkGray;
Console.CursorLeft = position++;
Console.Write(" ");
}
Console.CursorLeft = 35;
Console.CursorLeft = BarLength + 4;
Console.BackgroundColor = ConsoleColor.Black;
if (progress.CanAproximateTo(Max))
Console.Write(progress + " % ✓");