Skip to content

Commit

Permalink
Merge pull request #91 from BoiHanny/Pre-Master
Browse files Browse the repository at this point in the history
New features and optimizations across multiple modules, including network statistics monitoring, RAM DDR version display, and UI enhancements
  • Loading branch information
BoiHanny authored Nov 30, 2024
2 parents fe64132 + bcc8324 commit f4124e6
Show file tree
Hide file tree
Showing 7 changed files with 563 additions and 334 deletions.
12 changes: 7 additions & 5 deletions vrcosc-magicchatbox/Classes/DataAndSecurity/DataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ public static void LoadComponentStats()
{ "ChatAddSmallDelayTIME", (typeof(double), "Chat") },
{ "ChattingUpdateRate", (typeof(double), "Chat") },
{ "RealTimeChatEdit", (typeof(bool), "Chat") },
{ "HideOpenAITools", (typeof(bool), "Chat") },

{ "SeperateWithENTERS", (typeof(bool), "Custom") },

Expand Down Expand Up @@ -1054,7 +1055,11 @@ public static List<Voice> ReadTkTkTTSVoices()
{
try
{
string json = File.ReadAllText(@"Json\voices.json");
string currentrunningAppdir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);


string voicesFilePath = Path.Combine(currentrunningAppdir, "Json", "voices.json");
string json = File.ReadAllText(voicesFilePath);
List<Voice> ConfirmList = JsonConvert.DeserializeObject<List<Voice>>(json);

if (string.IsNullOrEmpty(ViewModel.Instance.RecentTikTokTTSVoice) || ConfirmList.Count == 0)
Expand All @@ -1064,10 +1069,7 @@ public static List<Voice> ReadTkTkTTSVoices()
if (!string.IsNullOrEmpty(ViewModel.Instance.RecentTikTokTTSVoice) || ConfirmList.Count == 0)
{
Voice selectedVoice = ConfirmList.FirstOrDefault(v => v.ApiName == ViewModel.Instance.RecentTikTokTTSVoice);
if (selectedVoice == null)
{
}
else
if (selectedVoice != null)
{
ViewModel.Instance.SelectedTikTokTTSVoice = selectedVoice;
}
Expand Down
99 changes: 98 additions & 1 deletion vrcosc-magicchatbox/Classes/Modules/ComponentStatsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Management;
using System.Threading.Tasks;
using System.Windows;
using vrcosc_magicchatbox.Classes.DataAndSecurity;
Expand All @@ -20,14 +21,89 @@ public class ComponentStatsModule
private readonly List<ComponentStatsItem> _componentStats = new List<ComponentStatsItem>();
private static string FileName = null;
public bool started = false;
private string _ramDDRVersion = "Unknown";

public void StartModule()
{
if (ViewModel.Instance.IntgrComponentStats && ViewModel.Instance.IntgrComponentStats_VR &&
ViewModel.Instance.IsVRRunning || ViewModel.Instance.IntgrComponentStats &&
ViewModel.Instance.IntgrComponentStats_DESKTOP &&
!ViewModel.Instance.IsVRRunning)
{
LoadComponentStats();
FetchAndStoreDDRVersion();
}

}

private void FetchAndStoreDDRVersion()
{
_ramDDRVersion = GetDDRVersion();
var ramItem = _componentStats.FirstOrDefault(stat => stat.ComponentType == StatsComponentType.RAM);
if (ramItem != null)
{
ramItem.DDRVersion = _ramDDRVersion;
}
}

public string GetDDRVersion()
{
try
{
HashSet<string> ddrVersions = new HashSet<string>();

ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT SMBIOSMemoryType FROM Win32_PhysicalMemory");
foreach (ManagementObject queryObj in searcher.Get())
{
ushort smbiosMemoryType = Convert.ToUInt16(queryObj["SMBIOSMemoryType"]);
string ddrVersion = GetDDRVersionFromSMBIOSMemoryType(smbiosMemoryType);
if (!string.IsNullOrEmpty(ddrVersion))
{
ddrVersions.Add(ddrVersion);
}
}

if (ddrVersions.Count > 0)
{
// Return the unique DDR versions, joined by a slash if multiple
return string.Join("'", ddrVersions);
}
}
catch (Exception ex)
{
Logging.WriteException(ex, MSGBox: false);
}

// Return null if DDR version cannot be determined
return null;
}

private string GetDDRVersionFromSMBIOSMemoryType(ushort smbiosMemoryType)
{
// Map the SMBIOSMemoryType to DDR version numbers 0-5
switch (smbiosMemoryType)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
return "ᴰᴰᴿ";
case 20:
return "ᴰᴰᴿ¹";
case 21:
return "ᴰᴰᴿ²";
case 24:
return "ᴰᴰᴿ³";
case 26:
return "ᴰᴰᴿ⁴";
case 34:
return "ᴰᴰᴿ⁵";
// Include other cases as needed
default:
return null;
}
}

public IReadOnlyList<ComponentStatsItem> GetAllStats()
Expand Down Expand Up @@ -346,6 +422,21 @@ public void SetShowGPUTemperature(bool state)
}
}

public bool GetShowRamDDRVersion()
{
var item = _componentStats.FirstOrDefault(stat => stat.ComponentType == StatsComponentType.RAM);
return item?.ShowDDRVersion ?? false;
}

public void SetShowRamDDRVersion(bool state)
{
var item = _componentStats.FirstOrDefault(stat => stat.ComponentType == StatsComponentType.RAM);
if (item != null)
{
item.ShowDDRVersion = state;
}
}

public bool GetShowGPUHotspotTemperature()
{
var item = _componentStats.FirstOrDefault(stat => stat.ComponentType == StatsComponentType.GPU);
Expand Down Expand Up @@ -499,7 +590,6 @@ public void SetStatMaxValueShown(StatsComponentType type, bool state)
StatsComponentType.GPU,
StatsComponentType.VRAM,
StatsComponentType.RAM,
//StatsComponentType.FPS
};

public string GenerateStatsDescription()
Expand Down Expand Up @@ -551,6 +641,11 @@ public string GenerateStatsDescription()
}
}

if (stat.ComponentType == StatsComponentType.RAM && stat.ShowDDRVersion && !string.IsNullOrWhiteSpace(stat.DDRVersion))
{
componentDescription += $" ⁽{stat.DDRVersion}⁾";
}

// Combine the additionalInfo parts with a single space
string additionalInfo = string.Join(" ", additionalInfoParts).Trim();

Expand Down Expand Up @@ -1100,6 +1195,8 @@ private static string FetchStat(
}
}



private static string FetchHotspotTemperatureStat(IHardware hardware, ComponentStatsItem item)
{
foreach (var sensor in hardware.Sensors)
Expand Down
Loading

0 comments on commit f4124e6

Please sign in to comment.