From 5127d23cc6fbc4ba0a2dcbd02c3dc1f860aa0d67 Mon Sep 17 00:00:00 2001 From: BoiHanny Date: Thu, 8 Feb 2024 17:33:28 +0100 Subject: [PATCH 1/2] The most significant changes include the addition of a condition check in the `OSCController.cs` file to allow for both random and sequential cycling through items, and the modification of the sorting order for `ViewModel.Instance.StatusList` in the `MainWindow.xaml.cs` file to ensure that more recently used items appear earlier in the list when sorting by favorites. A syntax error in the `MainWindow.xaml.cs` file was also corrected. 1. In the `OSCController.cs` file, a condition check for `ViewModel.Instance.IsRandomCycling` was added. If this condition is true, the code will execute the same logic as before. If it's false, the code will find the active item in `cycleItems`, deactivate it, and activate the next item in the list. If the active item is the last item in the list, it will activate the first item. In both cases, it will update `ViewModel.Instance.LastSwitchCycle` to the current time. This change allows for both random and sequential cycling through items. 2. In the `MainWindow.xaml.cs` file, the sorting order for `ViewModel.Instance.StatusList` was changed in the `SortFav_Click` method. Previously, the list was sorted in descending order by `UseInCycle` and then in ascending order by `LastUsed`. Now, it's sorted in descending order by both `UseInCycle` and `LastUsed`. This change ensures that items that were used more recently will appear earlier in the list when sorting by favorites. 3. An extra closing brace was added at the end of the `MainWindow.xaml.cs` file, correcting a syntax error in the code. --- .../Classes/DataAndSecurity/OSCController.cs | 55 +++++++++++++------ vrcosc-magicchatbox/MainWindow.xaml.cs | 4 +- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/vrcosc-magicchatbox/Classes/DataAndSecurity/OSCController.cs b/vrcosc-magicchatbox/Classes/DataAndSecurity/OSCController.cs index 92f5f36c..5ac9505f 100644 --- a/vrcosc-magicchatbox/Classes/DataAndSecurity/OSCController.cs +++ b/vrcosc-magicchatbox/Classes/DataAndSecurity/OSCController.cs @@ -279,30 +279,53 @@ public static void CycleStatus() if (elapsedTime >= TimeSpan.FromSeconds(ViewModel.Instance.SwitchStatusInterval)) { - foreach (var item in ViewModel.Instance.StatusList) - { - item.IsActive = false; - } - try + + if(ViewModel.Instance.IsRandomCycling) { - var rnd = new Random(); - var weights = cycleItems.Select(item => + foreach (var item in ViewModel.Instance.StatusList) + { + item.IsActive = false; + } + try { - var timeWeight = (DateTime.Now - item.LastUsed).TotalSeconds; - var randomFactor = rnd.NextDouble(); // Adding randomness - return timeWeight * randomFactor; // Combine time weight with random factor - }).ToList(); + var rnd = new Random(); + var weights = cycleItems.Select(item => + { + var timeWeight = (DateTime.Now - item.LastUsed).TotalSeconds; + var randomFactor = rnd.NextDouble(); // Adding randomness + return timeWeight * randomFactor; // Combine time weight with random factor + }).ToList(); - int selectedIndex = WeightedRandomIndex(weights); - cycleItems[selectedIndex].IsActive = true; + int selectedIndex = WeightedRandomIndex(weights); + cycleItems[selectedIndex].IsActive = true; - ViewModel.Instance.LastSwitchCycle = DateTime.Now; + ViewModel.Instance.LastSwitchCycle = DateTime.Now; + } + catch (Exception ex) + { + Logging.WriteException(ex, MSGBox: false); + } } - catch (Exception ex) + else { - Logging.WriteException(ex, MSGBox: false); + var activeItem = cycleItems.FirstOrDefault(item => item.IsActive); + if (activeItem != null) + { + var currentIndex = cycleItems.IndexOf(activeItem); + var nextIndex = currentIndex + 1; + if (nextIndex >= cycleItems.Count) + { + nextIndex = 0; + } + + activeItem.IsActive = false; + cycleItems[nextIndex].IsActive = true; + + ViewModel.Instance.LastSwitchCycle = DateTime.Now; + } } + } } diff --git a/vrcosc-magicchatbox/MainWindow.xaml.cs b/vrcosc-magicchatbox/MainWindow.xaml.cs index cbea1ddf..1de0c9bf 100644 --- a/vrcosc-magicchatbox/MainWindow.xaml.cs +++ b/vrcosc-magicchatbox/MainWindow.xaml.cs @@ -814,7 +814,7 @@ private void SortEdited_Click(object sender, RoutedEventArgs e) private void SortFav_Click(object sender, RoutedEventArgs e) { ViewModel.Instance.StatusList = new ObservableCollection( - ViewModel.Instance.StatusList.OrderByDescending(x => x.UseInCycle).ThenBy(x => x.LastUsed)); + ViewModel.Instance.StatusList.OrderByDescending(x => x.UseInCycle).ThenByDescending(x => x.LastUsed)); } private void SortUsed_Click(object sender, RoutedEventArgs e) @@ -1612,5 +1612,5 @@ private async void ShortenChat_Click(object sender, RoutedEventArgs e) } } - + } \ No newline at end of file From 7406e7798d7e38d057a64efc5f21ecbac1341139 Mon Sep 17 00:00:00 2001 From: BoiHanny Date: Thu, 8 Feb 2024 17:33:49 +0100 Subject: [PATCH 2/2] The most important changes involve updates to the versions of both the MagicChatbox project and the OpenAI-DotNet package. The MagicChatbox project version has been updated from 0.8.757 to 0.8.760, while the OpenAI-DotNet package that the project depends on has been updated from 7.6.4 to 7.6.5. Changes: 1. The MagicChatbox project version has been updated from 0.8.757 to 0.8.760. This change may include bug fixes, performance improvements, or new features. (Reference to code changes) 2. The version of the OpenAI-DotNet package that the project depends on has been updated from 7.6.4 to 7.6.5. This update may bring improvements or new features to the package, which could potentially enhance the functionality of the MagicChatbox project. (Reference to code changes) --- vrcosc-magicchatbox/MagicChatbox.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vrcosc-magicchatbox/MagicChatbox.csproj b/vrcosc-magicchatbox/MagicChatbox.csproj index f0f495a8..a8d46771 100644 --- a/vrcosc-magicchatbox/MagicChatbox.csproj +++ b/vrcosc-magicchatbox/MagicChatbox.csproj @@ -2,7 +2,7 @@ WinExe - 0.8.757 + 0.8.760 net6.0-windows10.0.22000.0 vrcosc_magicchatbox enable @@ -169,7 +169,7 @@ - +