Skip to content

Commit

Permalink
Merge pull request #41 from BoiHanny/Pre-Master
Browse files Browse the repository at this point in the history
Pre master
  • Loading branch information
BoiHanny authored Feb 8, 2024
2 parents c469969 + 7406e77 commit d43838d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 20 deletions.
55 changes: 39 additions & 16 deletions vrcosc-magicchatbox/Classes/DataAndSecurity/OSCController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

}
}

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)
}
}


}

0 comments on commit d43838d

Please sign in to comment.