33using VRCFaceTracking . Core . Contracts ;
44using VRCFaceTracking . Core . Contracts . Services ;
55using VRCFaceTracking . Core . OSC ;
6+ using VRCFaceTracking . Core . Params . Expressions ;
67using VRCFaceTracking . Core . Services ;
78
89namespace 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
0 commit comments