Skip to content

Commit

Permalink
Merge branch 'develop/feature/pmd_tab' into release/1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DevTechProfile committed Sep 10, 2022
2 parents 06e5f52 + a129172 commit 68bd75d
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 3 deletions.
60 changes: 58 additions & 2 deletions source/CapFrameX.Overlay/OverlayEntryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CapFrameX.Overlay
{
Expand All @@ -32,7 +33,7 @@ public class OverlayEntryProvider : IOverlayEntryProvider
private static readonly HashSet<string> ONLINE_METRIC_NAMES = new HashSet<string>()
{
"OnlineAverage", "OnlineP1", "OnlineP0dot2", "OnlineApplicationLatency",
"OnlineStutteringPercentage", "SystemTime", "PmdGpuPowerCurrent", "PmdCpuPowerCurrent",
"OnlineStutteringPercentage", "PmdGpuPowerCurrent", "PmdCpuPowerCurrent",
"PmdSystemPowerCurrent"
};

Expand Down Expand Up @@ -256,6 +257,23 @@ void UpdateRealtimeMetricEntryDict(string onlineMetricName)
}

ONLINE_METRIC_NAMES.ForEach(UpdateRealtimeMetricEntryDict);

// System Time
if (!_overlayEntryCore.RealtimeMetricEntryDict.ContainsKey("SystemTime"))
_overlayEntryCore.RealtimeMetricEntryDict.Add("SystemTime", entry);
else
_overlayEntryCore.RealtimeMetricEntryDict["SystemTime"] = entry;

// Battery Info
if (!_overlayEntryCore.RealtimeMetricEntryDict.ContainsKey("BatteryLifePercent"))
_overlayEntryCore.RealtimeMetricEntryDict.Add("BatteryLifePercent", entry);
else
_overlayEntryCore.RealtimeMetricEntryDict["BatteryLifePercent"] = entry;

if (!_overlayEntryCore.RealtimeMetricEntryDict.ContainsKey("BatteryLifeRemaining"))
_overlayEntryCore.RealtimeMetricEntryDict.Add("BatteryLifeRemaining", entry);
else
_overlayEntryCore.RealtimeMetricEntryDict["BatteryLifeRemaining"] = entry;
}

CheckCustomSystemInfo();
Expand Down Expand Up @@ -286,6 +304,8 @@ private void ManageFormats()
SetHardwareIsNumericState();
SetAppInfoFormats();
SetAppInfoIsNumericState();
SetBatteryInfoFormats();
SetBatteryInfoIsNumericState();

_overlayEntries.ForEach(entry => entry.FormatChanged = true);
}
Expand Down Expand Up @@ -531,6 +551,12 @@ private async Task UpdateSensorData()
case EOverlayEntryType.CX when entry.Identifier == "SystemTime":
entry.Value = ShowSystemTimeSeconds ? DateTime.Now.ToString("HH:mm:ss") : DateTime.Now.ToString("HH:mm");
break;
case EOverlayEntryType.CX when entry.Identifier == "BatteryLifePercent":
entry.Value = SystemInformation.PowerStatus.BatteryLifePercent * 100d;
break;
case EOverlayEntryType.CX when entry.Identifier == "BatteryLifeRemaining":
entry.Value = SystemInformation.PowerStatus.BatteryLifeRemaining / 60d;
break;
default:
break;
}
Expand Down Expand Up @@ -631,7 +657,7 @@ private void UpdateAppInfo()

private void SetOnlineMetricsIsNumericState()
{
foreach (var metricName in ONLINE_METRIC_NAMES.Where(name => name != "SystemTime"))
foreach (var metricName in ONLINE_METRIC_NAMES)
{
_identifierOverlayEntryDict.TryGetValue(metricName, out IOverlayEntry metricEntry);

Expand Down Expand Up @@ -768,6 +794,36 @@ private void SetHardwareIsNumericState()
}
}

private void SetBatteryInfoIsNumericState()
{
foreach (var entry in _overlayEntries.Where(x =>
x.Identifier == "BatteryLifePercent" || x.Identifier == "BatteryLifeRemaining"))
{
entry.IsNumeric = true;
}
}

private void SetBatteryInfoFormats()
{
// BatteryLifePercent
_identifierOverlayEntryDict.TryGetValue("BatteryLifePercent", out IOverlayEntry batteryLifePercent);

if (batteryLifePercent != null)
{
batteryLifePercent.ValueUnitFormat = "%";
batteryLifePercent.ValueAlignmentAndDigits = "{0,5:F0}";
}

// BatteryLifeRemaining
_identifierOverlayEntryDict.TryGetValue("BatteryLifeRemaining", out IOverlayEntry batteryLifeRemaining);

if (batteryLifeRemaining != null)
{
batteryLifeRemaining.ValueUnitFormat = "min ";
batteryLifeRemaining.ValueAlignmentAndDigits = "{0,5:F0}";
}
}

private void UpdateFormatting()
{
bool updateVariables = false;
Expand Down
26 changes: 26 additions & 0 deletions source/CapFrameX.Overlay/OverlayUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,32 @@ public static List<OverlayEntryWrapper> GetOverlayEntryDefaults()
ShowGraph = false,
ShowGraphIsEnabled = false,
Color = string.Empty
},
new OverlayEntryWrapper("BatteryLifePercent")
{
OverlayEntryType = EOverlayEntryType.CX,
ShowOnOverlay = false,
ShowOnOverlayIsEnabled = true,
Description = "Battery Life (%)",
GroupName = "Battery Life",
Value = "0",
ValueFormat = default,
ShowGraph = false,
ShowGraphIsEnabled = false,
Color = string.Empty
},
new OverlayEntryWrapper("BatteryLifeRemaining")
{
OverlayEntryType = EOverlayEntryType.CX,
ShowOnOverlay = false,
ShowOnOverlayIsEnabled = true,
Description = "Battery Life Remaining (min)",
GroupName = "Battery Life",
Value = "0",
ValueFormat = default,
ShowGraph = false,
ShowGraphIsEnabled = false,
Color = string.Empty
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ public OnlinePmdMetrics GetPmdMetricsPowerCurrent()
return pmdMetrics;
}


private float GetPmdCurrentPowerByIndexGroup(IList<PmdChannel[]> channelData, int[] indexGroup)
{
double sum = 0;
Expand Down

0 comments on commit 68bd75d

Please sign in to comment.