@@ -49,15 +49,24 @@ public override async Task OnStart(IVoiceAttackProxy proxy)
4949
5050 _api . OnKeybindingsChanged ( bindings =>
5151 {
52- foreach ( var binding in bindings )
52+ var validBindings = bindings . Where ( x => x . IsValid ) . ToList ( ) ;
53+ var invalidBindings = bindings . Where ( x => ! x . IsValid && ( x . Primary . HasValue || x . Secondary . HasValue ) ) . ToList ( ) ;
54+
55+ foreach ( var binding in validBindings )
5356 Proxy . Variables . Set ( $ "EliteAPI.{ binding . Name } ", binding . KeyCode , TypeCode . String ) ;
5457
55- if ( ! Directory . Exists ( Path . Combine ( Dir , "Variables" ) ) )
56- Directory . CreateDirectory ( Path . Combine ( Dir , "Variables" ) ) ;
57-
58- FileUtils . WriteWithRetry ( Path . Combine ( Dir , "Variables" , "Keybindings.txt" ) , bindings . Select ( b => $ "{{TXT:EliteAPI.{ b . Name } }}: { b . KeyCode } ") . Aggregate ( ( a , b ) => $ "{ a } \n { b } ") ) ;
58+ var directory = Path . Combine ( Dir , "Variables" , "Keybindings" ) ;
59+ if ( ! Directory . Exists ( directory ) )
60+ Directory . CreateDirectory ( directory ) ;
5961
60- proxy . Log . Write ( $ "Applying { bindings . Count ( b => ! string . IsNullOrEmpty ( b . KeyCode ) ) } keybindings", VoiceAttackColor . Blue ) ;
62+ FileUtils . WriteWithRetry ( Path . Combine ( directory , "Keybindings.txt" ) , validBindings . Select ( b => $ "{{TXT:EliteAPI.{ b . Name } }}: { b . KeyCode } ") . Aggregate ( ( a , b ) => $ "{ a } \n { b } ") ) ;
63+ FileUtils . WriteWithRetry ( Path . Combine ( directory , "Invalid keybindings.txt" ) , validBindings . Select ( b => $ "{{TXT:EliteAPI.{ b . Name } }}: ?") . Aggregate ( ( a , b ) => $ "{ a } \n { b } ") ) ;
64+
65+ proxy . Log . Write ( $ "Applied { validBindings . Count ( b => ! string . IsNullOrEmpty ( b . KeyCode ) ) } keybindings", VoiceAttackColor . Blue ) ;
66+ if ( invalidBindings . Count > 0 )
67+ proxy . Log . Write (
68+ $ "Could not apply { invalidBindings . Count } keybindings. EliteAPI can only apply keyboard-only keybindings",
69+ VoiceAttackColor . Yellow ) ;
6170 } ) ;
6271
6372 // json event
@@ -88,10 +97,11 @@ public override async Task OnStart(IVoiceAttackProxy proxy)
8897 // Only write variable files for non-synthetic events (Status change events don't need variable files)
8998 if ( ! e . eventName . StartsWith ( "Status." ) && paths . Count > 0 )
9099 {
91- if ( ! Directory . Exists ( Path . Combine ( Dir , "Variables" ) ) )
92- Directory . CreateDirectory ( Path . Combine ( Dir , "Variables" ) ) ;
100+ var directory = Path . Combine ( Dir , "Variables" , "Journals" ) ;
101+ if ( ! Directory . Exists ( directory ) )
102+ Directory . CreateDirectory ( directory ) ;
93103
94- FileUtils . WriteWithRetry ( Path . Combine ( Dir , "Variables" , $ "{ e . eventName } .txt") , paths . Select ( p => $ "{{{p.Type.ToDisplayType()}:{ p . Path } }}: { p . Value } ") . Aggregate ( ( a , b ) => $ "{ a } \n { b } ") ) ;
104+ FileUtils . WriteWithRetry ( Path . Combine ( directory , $ "{ e . eventName } .txt") , paths . Select ( p => $ "{{{p.Type.ToDisplayType()}:{ p . Path } }}: { p . Value } ") . Aggregate ( ( a , b ) => $ "{ a } \n { b } ") ) ;
95105 }
96106 } ) ;
97107
0 commit comments