Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre master #41

Merged
merged 7 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 39 additions & 16 deletions vrcosc-magicchatbox/Classes/DataAndSecurity/OSCController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{

// this function clears the chat window and resets the chat related variables to their default values
internal static void ClearChat(ChatItem lastsendchat = null)

Check warning on line 17 in vrcosc-magicchatbox/Classes/DataAndSecurity/OSCController.cs

View workflow job for this annotation

GitHub Actions / build-and-release

Cannot convert null literal to non-nullable reference type.
{
ViewModel.Instance.ScanPause = false;
ViewModel.Instance.OSCtoSent = string.Empty;
Expand Down Expand Up @@ -279,30 +279,53 @@
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;
}
}

}
}

Expand Down
4 changes: 2 additions & 2 deletions vrcosc-magicchatbox/MagicChatbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<Version>0.8.757</Version>
<Version>0.8.760</Version>
<TargetFramework>net6.0-windows10.0.22000.0</TargetFramework>
<RootNamespace>vrcosc_magicchatbox</RootNamespace>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -169,7 +169,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NHotkey.Wpf" Version="3.0.0" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="OpenAI-DotNet" Version="7.6.4" />
<PackageReference Include="OpenAI-DotNet" Version="7.6.5" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions vrcosc-magicchatbox/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<StatusItem>(
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)
Expand Down Expand Up @@ -1612,5 +1612,5 @@ private async void ShortenChat_Click(object sender, RoutedEventArgs e)
}
}


}
Loading