|
@@ -51,6 +51,7 @@ namespace BsWidget
|
|
|
public int CurrentCombo { get; set; } = 120;
|
|
|
public string CurrentRank { get; set; } = "XX";
|
|
|
public int CurrentMaxScore { get; set; }
|
|
|
+ public int CurrentCutPerSecond { get; set; }
|
|
|
|
|
|
public float? CpuUsage { get; set; } = 12.3f;
|
|
|
public float? CpuGhz { get; set; } = 2.333f;
|
|
@@ -63,9 +64,12 @@ namespace BsWidget
|
|
|
|
|
|
public class HistoryModel
|
|
|
{
|
|
|
+ public DateTime Time { get; set; }
|
|
|
+
|
|
|
public int CutScore { get; set; }
|
|
|
public int CurrentCombo { get; set; }
|
|
|
public float Percent { get; set; }
|
|
|
+ public int CutsPerSecond { get; set; }
|
|
|
public float HeartRate { get; set; }
|
|
|
public float KcalPerMin { get; set; }
|
|
|
}
|
|
@@ -90,7 +94,6 @@ namespace BsWidget
|
|
|
_computer.RAMEnabled = false;
|
|
|
_computer.Open();
|
|
|
|
|
|
- Text = "Beat Saber Status Widget";
|
|
|
_queue = new BlockingCollection<UpdateFlags>();
|
|
|
CutHistory = new List<HistoryModel>();
|
|
|
|
|
@@ -103,6 +106,7 @@ namespace BsWidget
|
|
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
|
{
|
|
|
+ Text = "Beat Saber Status Widget";
|
|
|
base.OnLoad(e);
|
|
|
Font = new Font("", 30, FontStyle.Bold, GraphicsUnit.Pixel);
|
|
|
TopMost = false;
|
|
@@ -150,11 +154,6 @@ namespace BsWidget
|
|
|
|
|
|
private void BeatSaber_Event(object sender, BeatSaberStatusEventArgs e)
|
|
|
{
|
|
|
- if (e.Event == "noteMissed")
|
|
|
- {
|
|
|
- var bp = 0;
|
|
|
- }
|
|
|
-
|
|
|
var flags = (UpdateFlags)0;
|
|
|
|
|
|
if (e.Event == "menu" && CutHistory.Count > 0)
|
|
@@ -201,11 +200,16 @@ namespace BsWidget
|
|
|
{
|
|
|
lock (CutHistory)
|
|
|
{
|
|
|
+ var now = DateTime.Now;
|
|
|
+ var preNow = now.AddSeconds(-1);
|
|
|
+ CurrentCutPerSecond = CutHistory.Count(p => p.Time > preNow);
|
|
|
CutHistory.Add(new HistoryModel
|
|
|
{
|
|
|
+ Time = now,
|
|
|
CutScore = e.NoteCut.FinalScore.Value,
|
|
|
CurrentCombo = CurrentCombo,
|
|
|
Percent = (float)CurrentScore / CurrentMaxScore,
|
|
|
+ CutsPerSecond = CurrentCutPerSecond,
|
|
|
HeartRate = YurStatus.HeartRate,
|
|
|
KcalPerMin = YurStatus.KcalPerMin,
|
|
|
});
|
|
@@ -215,7 +219,6 @@ namespace BsWidget
|
|
|
|
|
|
if (flags == 0)
|
|
|
{
|
|
|
- var bp = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -229,16 +232,20 @@ namespace BsWidget
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- foreach (var hardware in _computer.Hardware.Where(p => p.HardwareType == HardwareType.CPU))
|
|
|
+ foreach (var hardware in _computer.Hardware.Where(p => p.HardwareType == HardwareType.CPU || p.HardwareType == HardwareType.GpuNvidia))
|
|
|
{
|
|
|
hardware.Update();
|
|
|
}
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- CpuUsage = _computer.Hardware.Where(p => p.HardwareType == HardwareType.CPU).SelectMany(p => p.Sensors)
|
|
|
- .Where(p => p.SensorType == SensorType.Load && p.Name=="CPU Total").Select(p => p.Value).Max();
|
|
|
-
|
|
|
+ try
|
|
|
+ {
|
|
|
var mhz = _computer.Hardware.Where(p => p.HardwareType == HardwareType.CPU).SelectMany(p => p.Sensors)
|
|
|
- .Where(p => p.SensorType == SensorType.Clock).Select(p => p.Value).Max();
|
|
|
+ .Where(p => p.SensorType == SensorType.Clock).Select(p => p.Value).Max();
|
|
|
|
|
|
if (mhz.HasValue)
|
|
|
{
|
|
@@ -251,17 +258,21 @@ namespace BsWidget
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
- CpuUsage = null;
|
|
|
CpuGhz = null;
|
|
|
}
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- foreach (var hardware in _computer.Hardware.Where(p => p.HardwareType == HardwareType.GpuNvidia))
|
|
|
- {
|
|
|
- hardware.Update();
|
|
|
- }
|
|
|
+ CpuUsage = _computer.Hardware.Where(p => p.HardwareType == HardwareType.CPU).SelectMany(p => p.Sensors)
|
|
|
+ .Where(p => p.SensorType == SensorType.Load && p.Name == "CPU Total").Select(p => p.Value).Max();
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ CpuUsage = null;
|
|
|
+ }
|
|
|
|
|
|
+ try
|
|
|
+ {
|
|
|
GpuUsage = _computer.Hardware.Where(p => p.HardwareType == HardwareType.GpuNvidia).SelectMany(p => p.Sensors)
|
|
|
.Where(p => p.SensorType == SensorType.Load && p.Name == "GPU Core").Select(p => p.Value).Max();
|
|
|
}
|
|
@@ -282,8 +293,8 @@ namespace BsWidget
|
|
|
protected override void RenderGraphic(Graphics g)
|
|
|
{
|
|
|
const int margin = 10;
|
|
|
- var ChWidth = ViewSize.Width - margin * 2;
|
|
|
- var ChHeight = 64;
|
|
|
+ const int chHeight = 64;
|
|
|
+ var chWidth = ViewSize.Width - margin * 2;
|
|
|
|
|
|
if (_queue.Count == 0) return;
|
|
|
|
|
@@ -293,40 +304,39 @@ namespace BsWidget
|
|
|
|
|
|
g.SetHighQuality();
|
|
|
|
|
|
- float nextY = 0;
|
|
|
-
|
|
|
if (flags.HasFlag(UpdateFlags.NoteFullyCut) || flags.HasFlag(UpdateFlags.RefreshAll))
|
|
|
{
|
|
|
- var ChLeft = margin;
|
|
|
- var ChTop = margin;
|
|
|
+ const int chLeft = margin;
|
|
|
+ const int chTop = margin;
|
|
|
|
|
|
- var ChBottom = ChTop + ChHeight;
|
|
|
+ var chBottom = chTop + chHeight;
|
|
|
|
|
|
float RecordPixel = 2.5f;
|
|
|
var LineWidth = 1.5f;
|
|
|
|
|
|
- var DisplayCount = (int)(ChWidth / RecordPixel);
|
|
|
+ var displayCount = (int)(chWidth / RecordPixel);
|
|
|
|
|
|
using var scorePen = new Pen(Color.FromArgb(200, 255, 0, 0), LineWidth) { LineJoin = LineJoin.Round };
|
|
|
using var comboPen = new Pen(Color.FromArgb(200, 0, 0, 255), LineWidth) { LineJoin = LineJoin.Round };
|
|
|
using var percentPen = new Pen(Color.FromArgb(200, Color.Green), LineWidth) { LineJoin = LineJoin.Round };
|
|
|
+ using var cpsPen = new Pen(Color.Yellow, LineWidth) { LineJoin = LineJoin.Round };
|
|
|
using var heartPen = new Pen(Color.FromArgb(200, Color.White), LineWidth) { LineJoin = LineJoin.Round };
|
|
|
using var calPen = new Pen(Color.FromArgb(200, Color.Lime), LineWidth) { LineJoin = LineJoin.Round };
|
|
|
|
|
|
//clear region 0,210 Wx200
|
|
|
- g.ClearRect(Color.Transparent, 0, ChTop - 3, ViewSize.Width, ChHeight + 6 + 20);
|
|
|
+ g.ClearRect(Color.Transparent, 0, chTop - 3, ViewSize.Width, chHeight + 6 + 20);
|
|
|
|
|
|
//draw chart
|
|
|
using var bgBrush = new SolidBrush(Color.FromArgb(90, 255, 255, 255));
|
|
|
- g.FillRectangle(bgBrush, ChLeft, ChTop, ChWidth, ChHeight);
|
|
|
- g.DrawRectangle(Pens.White, ChLeft - 1, ChTop - 1, ChWidth + 2, ChHeight + 2);
|
|
|
+ g.FillRectangle(bgBrush, chLeft, chTop, chWidth, chHeight);
|
|
|
+ g.DrawRectangle(Pens.White, chLeft - 1, chTop - 1, chWidth + 2, chHeight + 2);
|
|
|
|
|
|
if (CutHistory.Count > 1)
|
|
|
{
|
|
|
HistoryModel[] items;
|
|
|
lock (CutHistory)
|
|
|
{
|
|
|
- var skip = CutHistory.Count > DisplayCount ? CutHistory.Count - DisplayCount : 0;
|
|
|
+ var skip = CutHistory.Count > displayCount ? CutHistory.Count - displayCount : 0;
|
|
|
|
|
|
items = CutHistory.Skip(skip).ToArray();
|
|
|
}
|
|
@@ -353,39 +363,45 @@ namespace BsWidget
|
|
|
var rngCal = maxCal - minCal;
|
|
|
if (rngCal < 1) rngCal = 1;
|
|
|
|
|
|
- var x = ChWidth - items.Length * RecordPixel + ChLeft + 1;
|
|
|
+ var minCps = items.Select(p => p.CutsPerSecond).Min();
|
|
|
+ var maxCps = items.Select(p => p.CutsPerSecond).Max();
|
|
|
+ var rngCps = maxCps - minCps;
|
|
|
+ if (rngCps < 1) rngCps = 1;
|
|
|
+
|
|
|
+ var x = chWidth - items.Length * RecordPixel + chLeft + 1;
|
|
|
|
|
|
var scorePts = new List<PointF>();
|
|
|
var comboPts = new List<PointF>();
|
|
|
var percentPts = new List<PointF>();
|
|
|
var heaPts = new List<PointF>();
|
|
|
var calPts = new List<PointF>();
|
|
|
+ var cpsPts = new List<PointF>();
|
|
|
|
|
|
for (var i = 0; i < items.Length; i++)
|
|
|
{
|
|
|
var item = items[i];
|
|
|
- scorePts.Add(new PointF(x + RecordPixel * i, (ChBottom - 1) - (ChHeight - 2) * ((float)(item.CutScore - minScore) / rngScore)));
|
|
|
- comboPts.Add(new PointF(x + RecordPixel * i, (ChBottom - 1) - (ChHeight - 2) * ((float)(item.CurrentCombo - minCombo) / rngCombo)));
|
|
|
- percentPts.Add(new PointF(x + RecordPixel * i, (ChBottom - 1) - (ChHeight - 2) * item.Percent));
|
|
|
- heaPts.Add(new PointF(x + RecordPixel * i, (ChBottom - 1) - (ChHeight - 2) * ((item.HeartRate - minHea) / rngHea)));
|
|
|
- calPts.Add(new PointF(x + RecordPixel * i, (ChBottom - 1) - (ChHeight - 2) * ((item.KcalPerMin - minCal) / rngCal)));
|
|
|
+ scorePts.Add(new PointF(x + RecordPixel * i, (chBottom - 1) - (chHeight - 2) * ((float)(item.CutScore - minScore) / rngScore)));
|
|
|
+ comboPts.Add(new PointF(x + RecordPixel * i, (chBottom - 1) - (chHeight - 2) * ((float)(item.CurrentCombo - minCombo) / rngCombo)));
|
|
|
+ percentPts.Add(new PointF(x + RecordPixel * i, (chBottom - 1) - (chHeight - 2) * item.Percent));
|
|
|
+ cpsPts.Add(new PointF(x + RecordPixel * i, (chBottom - 1) - (chHeight - 2) * ((float)(item.CutsPerSecond - minCps) / rngCps)));
|
|
|
+ heaPts.Add(new PointF(x + RecordPixel * i, (chBottom - 1) - (chHeight - 2) * ((item.HeartRate - minHea) / rngHea)));
|
|
|
+ calPts.Add(new PointF(x + RecordPixel * i, (chBottom - 1) - (chHeight - 2) * ((item.KcalPerMin - minCal) / rngCal)));
|
|
|
}
|
|
|
|
|
|
g.DrawLines(scorePen, scorePts.ToArray());
|
|
|
g.DrawLines(comboPen, comboPts.ToArray());
|
|
|
g.DrawLines(percentPen, percentPts.ToArray());
|
|
|
+ g.DrawLines(cpsPen, cpsPts.ToArray());
|
|
|
g.DrawLines(heartPen, heaPts.ToArray());
|
|
|
g.DrawLines(calPen, calPts.ToArray());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- nextY = ChHeight + margin * 2;
|
|
|
}
|
|
|
|
|
|
if (flags.HasFlag(UpdateFlags.Performance) || flags.HasFlag(UpdateFlags.RefreshAll))
|
|
|
{
|
|
|
float x = margin;
|
|
|
- float y = ChHeight + margin * 2;
|
|
|
+ float y = chHeight + margin * 2;
|
|
|
|
|
|
//clear region 0,180 Wx180
|
|
|
g.ClearRect(Color.Transparent, 0, y, ViewSize.Width, 50);
|
|
@@ -412,6 +428,13 @@ namespace BsWidget
|
|
|
Brushes.Green, 2.5f);
|
|
|
x += sz.Width + margin * 2;
|
|
|
|
|
|
+ sz = g.DrawStringWithOutline($"{CurrentCutPerSecond}", Font, x, y, Color.Black, Color.White);
|
|
|
+ x += sz.Width + margin * 2;
|
|
|
+
|
|
|
+ sz = g.DrawStringWithRoundedRect("CUT / SEC", _smallFont, x, y + margin * 1.5f, Brushes.Black,
|
|
|
+ Brushes.Yellow, 2.5f);
|
|
|
+ x += sz.Width + margin * 2;
|
|
|
+
|
|
|
sz = g.DrawStringWithOutline($"{YurStatus.HeartRate:N1}", Font, x, y, Color.Black, Color.White);
|
|
|
x += sz.Width + margin * 2;
|
|
|
|
|
@@ -422,6 +445,7 @@ namespace BsWidget
|
|
|
sz = g.DrawStringWithOutline($"{YurStatus.KcalPerMin:N1}", Font, x, y, Color.Black, Color.White);
|
|
|
x += sz.Width + margin * 2;
|
|
|
|
|
|
+ // ReSharper disable once RedundantAssignment
|
|
|
sz = g.DrawStringWithRoundedRect("KCAL / MIN", _smallFont, x, y + margin * 1.5f, Brushes.Black,
|
|
|
Brushes.Lime, 2.5f);
|
|
|
}
|
|
@@ -459,6 +483,7 @@ namespace BsWidget
|
|
|
sz = g.DrawStringWithOutline($"{SongNjs}", Font, x, y, Color.Black, Color.White);
|
|
|
x += sz.Width + margin * 2;
|
|
|
|
|
|
+ // ReSharper disable once RedundantAssignment
|
|
|
sz = g.DrawStringWithRoundedRect("NJS", _smallFont, x, y + margin * 1.5f, Brushes.Black, Brushes.White, 2.5f);
|
|
|
}
|
|
|
|