diff --git a/MagicChatboxTests/MagicChatboxTests.csproj b/MagicChatboxTests/MagicChatboxTests.csproj
deleted file mode 100644
index 7300a717..00000000
--- a/MagicChatboxTests/MagicChatboxTests.csproj
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
- net6.0-windows10.0.22000.0
- enable
- enable
-
- false
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ..\..\..\..\..\..\Temp\CoreOSC.dll
-
-
-
-
diff --git a/MagicChatboxTests/Usings.cs b/MagicChatboxTests/Usings.cs
deleted file mode 100644
index e69de29b..00000000
diff --git a/PulsoidOAuthLib/OAuthService.cs b/PulsoidOAuthLib/OAuthService.cs
deleted file mode 100644
index b98782ba..00000000
--- a/PulsoidOAuthLib/OAuthService.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-using System.Text.Json;
-
-namespace PulsoidOAuthLib
-{
- public class OAuthService
- {
- private const string AuthorizeUrl = "https://pulsoid.net/oauth2/authorize";
- private const string TokenUrl = "https://pulsoid.net/oauth2/token";
- private const string ValidateUrl = "https://dev.pulsoid.net/api/v1/token/validate";
-
- private readonly string _clientId;
- private readonly string _clientSecret;
- private readonly string _redirectUri;
-
- private DateTime _accessTokenExpiry;
- private string _accessToken;
- private string _refreshToken;
-
- public OAuthService(string clientId, string clientSecret, string redirectUri)
- {
- _clientId = clientId ?? throw new ArgumentNullException(nameof(clientId));
- _clientSecret = clientSecret ?? throw new ArgumentNullException(nameof(clientSecret));
- _redirectUri = redirectUri ?? throw new ArgumentNullException(nameof(redirectUri));
- }
-
- public string GetAuthorizationUrl(string scope, string state)
- {
- return $"{AuthorizeUrl}?response_type=code&client_id={_clientId}&redirect_uri={_redirectUri}&scope={scope}&state={state}";
- }
-
- public async Task IsAccessTokenValid()
- {
- using (var httpClient = new HttpClient())
- {
- httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {_accessToken}");
- var response = await httpClient.GetAsync(ValidateUrl);
- return response.IsSuccessStatusCode;
- }
- }
-
- public async Task GetValidAccessTokenAsync()
- {
- if (_accessToken == null || DateTime.UtcNow > _accessTokenExpiry)
- {
- if (_refreshToken != null)
- {
- (_accessToken, _refreshToken) = await RefreshTokenAsync(_refreshToken);
- }
- else
- {
- throw new Exception("Token has expired and no refresh token is available.");
- }
- }
-
- return _accessToken;
- }
-
- public async Task<(string accessToken, string refreshToken)> ExchangeCodeForTokensAsync(string code)
- {
- using (var httpClient = new HttpClient())
- {
- var requestData = new Dictionary
- {
- ["grant_type"] = "authorization_code",
- ["code"] = code,
- ["client_id"] = _clientId,
- ["client_secret"] = _clientSecret,
- ["redirect_uri"] = _redirectUri
- };
-
- var response = await httpClient.PostAsync(TokenUrl, new FormUrlEncodedContent(requestData));
- var content = await response.Content.ReadAsStringAsync();
-
- if (!response.IsSuccessStatusCode)
- {
- throw new Exception($"Failed to get tokens. Response: {content}");
- }
-
- var jsonDoc = JsonDocument.Parse(content);
- var root = jsonDoc.RootElement;
-
- _accessToken = root.GetProperty("access_token").GetString();
- _refreshToken = root.GetProperty("refresh_token").GetString();
- _accessTokenExpiry = DateTime.UtcNow.AddSeconds(root.GetProperty("expires_in").GetInt32());
-
- return (_accessToken, _refreshToken);
- }
- }
-
- public async Task<(string accessToken, string refreshToken)> RefreshTokenAsync(string refreshToken)
- {
- using (var httpClient = new HttpClient())
- {
- var requestData = new Dictionary
- {
- ["grant_type"] = "refresh_token",
- ["refresh_token"] = refreshToken,
- ["client_id"] = _clientId,
- ["client_secret"] = _clientSecret
- };
-
- var response = await httpClient.PostAsync(TokenUrl, new FormUrlEncodedContent(requestData));
- var content = await response.Content.ReadAsStringAsync();
-
- if (!response.IsSuccessStatusCode)
- {
- throw new Exception($"Failed to refresh token. Response: {content}");
- }
-
- var jsonDoc = JsonDocument.Parse(content);
- var root = jsonDoc.RootElement;
-
- _accessToken = root.GetProperty("access_token").GetString();
- _refreshToken = root.GetProperty("refresh_token").GetString();
- _accessTokenExpiry = DateTime.UtcNow.AddSeconds(root.GetProperty("expires_in").GetInt32());
-
- return (_accessToken, _refreshToken);
- }
- }
- }
-}
diff --git a/PulsoidOAuthLib/PulsoidOAuthLib.csproj b/PulsoidOAuthLib/PulsoidOAuthLib.csproj
deleted file mode 100644
index 132c02c5..00000000
--- a/PulsoidOAuthLib/PulsoidOAuthLib.csproj
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- net6.0
- enable
- enable
-
-
-
diff --git a/vrcosc-magicchatbox/Classes/DataAndSecurity/DataController.cs b/vrcosc-magicchatbox/Classes/DataAndSecurity/DataController.cs
index 4bf62f77..4f9137a9 100644
--- a/vrcosc-magicchatbox/Classes/DataAndSecurity/DataController.cs
+++ b/vrcosc-magicchatbox/Classes/DataAndSecurity/DataController.cs
@@ -321,7 +321,6 @@ public static void LoadComponentStats()
{ "BlankEgg", (typeof(bool), "DEV") },
- { "Egg_Dev", (typeof(bool), "DEV") },
{ "SwitchStatusInterval", (typeof(int), "StatusSetting") },
{ "IsRandomCycling", (typeof(bool), "StatusSetting") },
@@ -661,6 +660,11 @@ public static void LoadStatusList()
return;
}
ViewModel.Instance.StatusList = JsonConvert.DeserializeObject>(json);
+ // check if we have a status with the msg 'BoiHanny' or 'Gun'
+ if (ViewModel.Instance.StatusList.Any(x => x.msg == "boihanny" || x.msg == "sr4 series"))
+ {
+ ViewModel.Instance.Egg_Dev = true;
+ }
}
else
{
diff --git a/vrcosc-magicchatbox/Classes/DataAndSecurity/HotkeyManagement.cs b/vrcosc-magicchatbox/Classes/DataAndSecurity/HotkeyManagement.cs
index 875aaf58..dad3d398 100644
--- a/vrcosc-magicchatbox/Classes/DataAndSecurity/HotkeyManagement.cs
+++ b/vrcosc-magicchatbox/Classes/DataAndSecurity/HotkeyManagement.cs
@@ -83,25 +83,55 @@ public void SaveHotkeyConfigurations()
private void LoadHotkeyConfigurations()
{
- if (!File.Exists(HotkeyConfigFile))
+ try
{
- AddDefaultHotkeys();
- SaveHotkeyConfigurations();
- return;
- }
+ if (!File.Exists(HotkeyConfigFile))
+ {
+ AddDefaultHotkeys();
+ SaveHotkeyConfigurations();
+ return;
+ }
- var json = File.ReadAllText(HotkeyConfigFile);
- var deserialized = JsonConvert.DeserializeObject>>(json);
+ var json = File.ReadAllText(HotkeyConfigFile);
+ var deserialized = JsonConvert.DeserializeObject>>(json);
+ if (deserialized == null)
+ {
+ // Log an error message stating that the deserialization returned null
+ Logging.WriteException(new Exception("Failed to deserialize hotkey configurations."), MSGBox: true);
+ AddDefaultHotkeys();
+ return;
+ }
- _hotkeyActions.Clear();
- foreach (var entry in deserialized)
+ _hotkeyActions.Clear();
+ foreach (var entry in deserialized)
+ {
+ if (!Enum.TryParse(entry.Value["Key"], out var key) ||
+ !Enum.TryParse(entry.Value["Modifiers"], out var modifiers))
+ {
+ // Log an error message about the specific hotkey that failed to parse
+ Logging.WriteException(new Exception($"Failed to parse hotkey configuration for {entry.Key}."), MSGBox: true);
+ continue;
+ }
+
+ var action = GetActionForHotkey(entry.Key);
+ if (action == null)
+ {
+ // Log an error message stating that no action is defined for this hotkey
+ Logging.WriteException(new Exception($"No action defined for hotkey {entry.Key}."), MSGBox: true);
+ continue;
+ }
+
+ AddKeyBinding(entry.Key, key, modifiers, action);
+ }
+ }
+ catch (Exception ex)
{
- var key = (Key)Enum.Parse(typeof(Key), entry.Value["Key"]);
- var modifiers = (ModifierKeys)Enum.Parse(typeof(ModifierKeys), entry.Value["Modifiers"]);
- AddKeyBinding(entry.Key, key, modifiers, GetActionForHotkey(entry.Key));
+ Logging.WriteException(ex, MSGBox: true);
}
+
}
+
private Action GetActionForHotkey(string hotkeyName)
{
return hotkeyName switch
diff --git a/vrcosc-magicchatbox/Classes/DataAndSecurity/OSCController.cs b/vrcosc-magicchatbox/Classes/DataAndSecurity/OSCController.cs
index c18d3ffa..92f5f36c 100644
--- a/vrcosc-magicchatbox/Classes/DataAndSecurity/OSCController.cs
+++ b/vrcosc-magicchatbox/Classes/DataAndSecurity/OSCController.cs
@@ -210,7 +210,7 @@ public static void AddStatusMessage(List Uncomplete)
CycleStatus();
}
- var activeItem = ViewModel.Instance.StatusList.FirstOrDefault(item => item.IsActive == true);
+ StatusItem? activeItem = ViewModel.Instance.StatusList.FirstOrDefault(item => item.IsActive == true);
if (activeItem != null)
{
// Update LastUsed property for the active item
@@ -268,9 +268,8 @@ public static void AddWindowActivity(List Uncomplete)
public static void CycleStatus()
{
- if (ViewModel.Instance == null) return;
-
- if (ViewModel.Instance.StatusList == null || !ViewModel.Instance.StatusList.Any()) return;
+ if (ViewModel.Instance == null || ViewModel.Instance.StatusList == null || !ViewModel.Instance.StatusList.Any())
+ return;
var cycleItems = ViewModel.Instance.StatusList.Where(item => item.UseInCycle).ToList();
if (cycleItems.Count == 0) return;
@@ -279,28 +278,24 @@ public static void CycleStatus()
if (elapsedTime >= TimeSpan.FromSeconds(ViewModel.Instance.SwitchStatusInterval))
{
- // Reset all status items to inactive before setting the next one to active
- ViewModel.Instance.StatusList.All(item => { item.IsActive = false; return true; });
+
+ foreach (var item in ViewModel.Instance.StatusList)
+ {
+ item.IsActive = false;
+ }
try
{
- if (ViewModel.Instance.IsRandomCycling)
+ var rnd = new Random();
+ var weights = cycleItems.Select(item =>
{
- // Calculate weights for each cycle item
- var weights = cycleItems.Select(item =>
- (DateTime.Now - item.LastUsed).TotalSeconds).ToList();
-
- // Select a random index based on weights
- int selectedIndex = WeightedRandomIndex(weights);
+ var timeWeight = (DateTime.Now - item.LastUsed).TotalSeconds;
+ var randomFactor = rnd.NextDouble(); // Adding randomness
+ return timeWeight * randomFactor; // Combine time weight with random factor
+ }).ToList();
- cycleItems[selectedIndex].IsActive = true;
- }
- else
- {
- // Improved Sequential selection
- ViewModel.Instance.StatusIndex = (ViewModel.Instance.StatusIndex + 1) % cycleItems.Count;
- cycleItems[ViewModel.Instance.StatusIndex].IsActive = true;
- }
+ int selectedIndex = WeightedRandomIndex(weights);
+ cycleItems[selectedIndex].IsActive = true;
ViewModel.Instance.LastSwitchCycle = DateTime.Now;
}
@@ -311,6 +306,7 @@ public static void CycleStatus()
}
}
+
private static int WeightedRandomIndex(List weights)
{
Random rnd = new Random();
diff --git a/vrcosc-magicchatbox/MainWindow.xaml b/vrcosc-magicchatbox/MainWindow.xaml
index 27fed38e..05988bc9 100644
--- a/vrcosc-magicchatbox/MainWindow.xaml
+++ b/vrcosc-magicchatbox/MainWindow.xaml
@@ -7,8 +7,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:vrcosc_magicchatbox.ViewModels"
Title="MagicChatbox by BoiHanny"
- Width="1000"
- Height="750"
+ Width="900"
+ Height="675"
MinWidth="1000"
MinHeight="500"
VerticalAlignment="Bottom"
@@ -373,15 +373,7 @@
Radius="{Binding MainWindowBlurEffect}" />
-
-
-
+
@@ -4000,7 +3992,7 @@
@@ -4188,7 +4180,6 @@
Width="745"
Height="auto"
Margin="8,0,0,8"
- Background="DarkSlateBlue"
BorderThickness="0"
CornerRadius="5"
Opacity="{Binding Opacity}">
@@ -4196,10 +4187,10 @@
+ Opacity="{Binding Opacity}"
+ RenderOptions.BitmapScalingMode="NearestNeighbor">
+
+
+
+
+
+