11using System . Globalization ;
22using Microsoft . Extensions . Logging ;
33using System . Net . Sockets ;
4+ using System . Reflection ;
45using VRCFaceTracking ;
56using VRCFTPicoModule . Utils ;
67using static VRCFTPicoModule . Utils . Localization ;
@@ -22,7 +23,13 @@ public override (bool eyeSuccess, bool expressionSuccess) Initialize(bool eyeAva
2223 {
2324 Localization . Initialize ( CultureInfo . CurrentUICulture . Name ) ;
2425 Logger . LogInformation ( T ( "start-init" ) ) ;
25- _trackingAvailable = ( eyeAvailable , expressionAvailable ) ;
26+
27+ var config = ReadConfiguration ( ) ;
28+ _trackingAvailable = (
29+ ! config . Item1 && eyeAvailable ,
30+ ! config . Item2 && expressionAvailable
31+ ) ;
32+
2633 var initializationResult = InitializeAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
2734 UpdateModuleInfo ( initializationResult ) ;
2835
@@ -50,6 +57,35 @@ public override (bool eyeSuccess, bool expressionSuccess) Initialize(bool eyeAva
5057 return _trackingAvailable ;
5158 }
5259
60+ private ( bool , bool ) ReadConfiguration ( )
61+ {
62+ var currentDirectory = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
63+ Logger . LogInformation ( T ( "config-path" ) , currentDirectory ) ;
64+
65+ if ( ! Directory . Exists ( currentDirectory ) )
66+ return ( false , false ) ;
67+
68+ var disableEye = false ;
69+ var disableExpression = false ;
70+
71+ var eyeFilePath = Path . Combine ( currentDirectory , ".disable_eye" ) ;
72+ if ( File . Exists ( eyeFilePath ) )
73+ {
74+ disableEye = true ;
75+ Logger . LogInformation ( T ( "force-disable-eye" ) ) ;
76+ }
77+
78+ var expressionFilePath = Path . Combine ( currentDirectory , ".disable_expression" ) ;
79+ // ReSharper disable once InvertIf
80+ if ( File . Exists ( expressionFilePath ) )
81+ {
82+ disableExpression = true ;
83+ Logger . LogInformation ( T ( "force-disable-expression" ) ) ;
84+ }
85+
86+ return ( disableEye , disableExpression ) ;
87+ }
88+
5389 private void UpdateModuleInfo ( ( bool , bool ) initializationResult )
5490 {
5591 var moduleProtocol = _port == Ports [ 1 ] ? $ " [{ T ( "legacy-protocol" ) } ]" : "" ;
0 commit comments