Skip to content

Commit 09539ec

Browse files
committed
feat(april): fools except no fun allowed
1 parent 56d1cd6 commit 09539ec

3 files changed

Lines changed: 75 additions & 4 deletions

File tree

VRCFaceTracking.Core/Params/Expressions/UnifiedExpressionsParameters.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ namespace VRCFaceTracking.Core.Params.Expressions;
99

1010
public static class UnifiedExpressionsParameters
1111
{
12+
public static bool AprilFoolsEnabled { get; set; } = false;
13+
1214
internal static bool IsAprilFoolsActive
1315
{
14-
get { var n = DateTime.Now; return n.Month == 4 && n.Day == 1 && n.Minute == 0 && n.Second < 30; }
16+
get { var n = DateTime.Now; return AprilFoolsEnabled && n.Month == 4 && n.Day == 1 && n.Minute == 0 && n.Second < 15; }
1517
}
1618

1719
private static readonly float[] _rightOpennessBuffer = new float[30];

VRCFaceTracking/ViewModels/MainViewModel.cs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using VRCFaceTracking.Core.Contracts;
44
using VRCFaceTracking.Core.Contracts.Services;
55
using VRCFaceTracking.Core.OSC;
6+
using VRCFaceTracking.Core.Params.Expressions;
67
using VRCFaceTracking.Core.Services;
78

89
namespace VRCFaceTracking.ViewModels;
@@ -25,6 +26,23 @@ public partial class MainViewModel : ObservableRecipient
2526

2627
[ObservableProperty] private bool _oscWasDisabled;
2728

29+
public bool IsAprilFoolsDay => DateTime.Now.Month == 4 && DateTime.Now.Day == 1;
30+
31+
private const string AprilFoolsSettingKey = "AprilFoolsEnabled";
32+
private const string AprilFoolsResetYearKey = "AprilFoolsResetYear";
33+
private readonly ILocalSettingsService _localSettingsService;
34+
35+
public bool AprilFoolsEnabled
36+
{
37+
get => UnifiedExpressionsParameters.AprilFoolsEnabled;
38+
set
39+
{
40+
UnifiedExpressionsParameters.AprilFoolsEnabled = value;
41+
OnPropertyChanged();
42+
_ = _localSettingsService.SaveSettingAsync(AprilFoolsSettingKey, value);
43+
}
44+
}
45+
2846
private DispatcherTimer msgCounterTimer;
2947

3048
public MainViewModel(
@@ -33,7 +51,8 @@ public MainViewModel(
3351
IModuleDataService moduleDataService,
3452
IOscTarget oscTarget,
3553
OscRecvService oscRecvService,
36-
OscSendService oscSendService
54+
OscSendService oscSendService,
55+
ILocalSettingsService localSettingsService
3756
)
3857
{
3958
//Services
@@ -42,6 +61,11 @@ OscSendService oscSendService
4261
OscTarget = oscTarget;
4362
OscRecvService = oscRecvService;
4463
OscSendService = oscSendService;
64+
_localSettingsService = localSettingsService;
65+
66+
// On the first boot of each April, reset the toggle to on
67+
LoadAprilFoolsSettingAsync();
68+
4569

4670
// Modules
4771
var installedNewModules = moduleDataService.GetInstalledModules();
@@ -66,6 +90,29 @@ OscSendService oscSendService
6690
msgCounterTimer.Start();
6791
}
6892

93+
private async void LoadAprilFoolsSettingAsync()
94+
{
95+
var now = DateTime.Now;
96+
var isApril = now.Month == 4;
97+
var lastResetYear = await _localSettingsService.ReadSettingAsync(AprilFoolsResetYearKey, 0);
98+
99+
bool enabled;
100+
if (isApril && lastResetYear != now.Year)
101+
{
102+
// First boot this April — turn it on and record the year
103+
enabled = true;
104+
await _localSettingsService.SaveSettingAsync(AprilFoolsResetYearKey, now.Year);
105+
await _localSettingsService.SaveSettingAsync(AprilFoolsSettingKey, true);
106+
}
107+
else
108+
{
109+
enabled = await _localSettingsService.ReadSettingAsync(AprilFoolsSettingKey, false);
110+
}
111+
112+
UnifiedExpressionsParameters.AprilFoolsEnabled = enabled;
113+
OnPropertyChanged(nameof(AprilFoolsEnabled));
114+
}
115+
69116
private void MessageReceived(OscMessage msg) => _messagesRecvd++;
70117
private void MessageDispatched(int msgCount) => _messagesSent += msgCount;
71118

VRCFaceTracking/Views/MainPage.xaml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,30 @@
577577
</Grid>
578578
</Border>
579579

580-
<views:AvatarInfoControl
581-
AvatarInfo="{x:Bind ViewModel.ParameterOutputService.AvatarInfo, Mode=OneWay}"
580+
<Border Margin="0, 10, 0, 0" Padding="20" CornerRadius="6" BorderThickness="1" Background="{ThemeResource LayerFillColorDefaultBrush}"
581+
Visibility="{x:Bind ViewModel.IsAprilFoolsDay, Converter={StaticResource BoolVisConverter}}">
582+
<Grid>
583+
<Grid.ColumnDefinitions>
584+
<ColumnDefinition Width="Auto"/>
585+
<ColumnDefinition Width="*"/>
586+
<ColumnDefinition Width="Auto"/>
587+
</Grid.ColumnDefinitions>
588+
<StackPanel Orientation="Horizontal" Grid.Column="0">
589+
<FontIcon Margin="10, 4" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE77B;" FontSize="28"/>
590+
<StackPanel Margin="20, 4" Orientation="Vertical">
591+
<TextBlock FontSize="20" Style="{ThemeResource SubtitleTextBlockStyle}" Text="April Fools"/>
592+
<TextBlock FontSize="13" Foreground="{ThemeResource TextFillColorSecondaryBrush}" Text="Enable or disable the April Fools tracking shenanigans"/>
593+
</StackPanel>
594+
</StackPanel>
595+
<ToggleSwitch Grid.Column="2" VerticalAlignment="Center" Margin="0, 0, 10, 0"
596+
FontSize="16"
597+
OnContent="Fun allowed" OffContent="No fun allowed"
598+
IsOn="{x:Bind ViewModel.AprilFoolsEnabled, Mode=TwoWay}"/>
599+
</Grid>
600+
</Border>
601+
602+
<views:AvatarInfoControl
603+
AvatarInfo="{x:Bind ViewModel.ParameterOutputService.AvatarInfo, Mode=OneWay}"
582604
AvatarParameters="{x:Bind ViewModel.ParameterOutputService.AvatarParameters, Mode=OneWay}"/>
583605
</StackPanel>
584606
</Grid>

0 commit comments

Comments
 (0)