99using BepInEx . NET . Common ;
1010using BepInExResoniteShim ;
1111using BepisLocaleLoader ;
12+ using BepisModSettings . ConfigAttributes ;
1213using Elements . Core ;
1314using FrooxEngine ;
1415using FrooxEngine . UIX ;
@@ -73,7 +74,7 @@ internal static async IAsyncEnumerable<DataFeedItem> Enumerate(IReadOnlyList<str
7374 modGroup . InitBase ( "Metadata" , path , null , "Settings.BepInEx.Plugins.Metadata" . AsLocaleKey ( ) ) ;
7475 yield return modGroup ;
7576
76- string [ ] metadataGroup = new [ ] { "Metadata" } ;
77+ string [ ] metadataGroup = [ "Metadata" ] ;
7778
7879 DataFeedIndicator < string > idIndicator = new DataFeedIndicator < string > ( ) ;
7980 idIndicator . InitBase ( "Id" , path , metadataGroup , "Settings.BepInEx.Plugins.Guid" . AsLocaleKey ( ) ) ;
@@ -119,6 +120,8 @@ private static async IAsyncEnumerable<DataFeedItem> EnumerateConfigs(ConfigFile
119120 List < string > added = new List < string > ( ) ;
120121 foreach ( ConfigEntryBase config in configFile . Values )
121122 {
123+ if ( ! Plugin . ShowHidden . Value && config . Description . Tags . Any ( x => x is HiddenConfig ) ) continue ;
124+
122125 Type valueType = config . SettingType ;
123126
124127 string section = config . Definition . Section ;
@@ -147,22 +150,24 @@ private static async IAsyncEnumerable<DataFeedItem> EnumerateConfigs(ConfigFile
147150 string initKey = section + "." + config . Definition . Key ;
148151 string key = added . Contains ( initKey ) ? initKey + added . Count : initKey ;
149152
150- // TODO: Figure out how to actually Localize config keys.
151- // TODO: Add Key for SubCategories
153+ // TODO: Somehow support subcategories
154+ LocaleString nameKey = config . Definition . Key ;
155+ LocaleString descKey = config . Description . Description ;
156+ LocaleString defaultKey = $ "{ config . Definition . Key } : { valueType } ";
157+ LocaleString valueKey = $ "{ config . Definition . Key } : { config . BoxedValue } ";
152158
153- string defaultKey = $ "{ config . Definition . Key } : { valueType } "; // "Settings.BepInEx.Plugins.Configs.Default".AsLocaleKey(("name", config.Definition.Key), ("type", valueType));
154- string valueKey = $ "{ config . Definition . Key } : { config . BoxedValue } "; // "Settings.BepInEx.Plugins.Configs.Value".AsLocaleKey(("name", config.Definition.Key), ("value", config.BoxedValue));
155- string nameKey = config . Definition . Key ; // "Settings.BepInEx.Plugins.Configs.Name".AsLocaleKey(("name", config.Definition.Key));
156- string descKey = config . Description . Description ; // "Settings.BepInEx.Plugins.Configs.Description".AsLocaleKey(("description", config.Description.Description));
159+ bool hasLocale = LocaleLoader . PluginsWithLocales . Any ( x => x . Metadata . GUID == metaData . ID ) ;
160+ if ( hasLocale && config . Description . Tags . FirstOrDefault ( x => x is ConfigLocale ) is ConfigLocale localeString )
161+ {
162+ nameKey = localeString . Name ;
163+ descKey = localeString . Description ;
157164
158- // if (SettingsLocaleHelper.PluginsWithLocales.Any(x => x.Metadata.GUID == metaData.ID))
159- // {
160- // nameKey = config.Definition.Key.AsLocaleKey();
161- // descKey = config.Description.Description.AsLocaleKey();
162- //
163- // defaultKey = $"Settings.{metaData.ID}.Configs.Default".AsLocaleKey(("name", nameKey.content), ("type", valueType));
164- // valueKey = $"Settings.{metaData.ID}.Configs.Value".AsLocaleKey(("name", nameKey.content), ("value", config.BoxedValue));
165- // }
165+ string formatted = localeString . Name . content . GetFormattedLocaleString ( ) ;
166+ defaultKey = $ "{ formatted } : { valueType } ";
167+ valueKey = $ "{ formatted } : { config . BoxedValue } ";
168+ }
169+
170+ InternalLocale internalLocale = new InternalLocale ( nameKey , descKey ) ;
166171
167172 added . Add ( key ) ;
168173
@@ -172,7 +177,7 @@ private static async IAsyncEnumerable<DataFeedItem> EnumerateConfigs(ConfigFile
172177 {
173178 DataFeedItem dummyField = null ;
174179
175- if ( config . Description . Tags . Contains ( "Action" ) && config . Description . Tags . FirstOrDefault ( x => x is Delegate ) is Delegate del )
180+ if ( config . Description . Tags . FirstOrDefault ( x => x is ActionConfig ) is ActionConfig action )
176181 {
177182 DataFeedAction actionField = new DataFeedAction ( ) ;
178183 actionField . InitBase ( key , path , groupingKeys , nameKey , descKey ) ;
@@ -181,23 +186,37 @@ private static async IAsyncEnumerable<DataFeedItem> EnumerateConfigs(ConfigFile
181186 Button btn = syncDelegate . Slot . GetComponent < Button > ( ) ;
182187 if ( btn == null ) return ;
183188
184- btn . LocalPressed += ( _ , _ ) => del . DynamicInvoke ( ) ;
189+ btn . LocalPressed += ( _ , _ ) => action . Invoke ( ) ;
185190 } ) ;
186191
187192 dummyField = actionField ;
188193 }
189194
190- if ( dummyField == null )
195+ bool customUi = false ;
196+ if ( config . Description . Tags . FirstOrDefault ( x => x is CustomDataFeed ) is CustomDataFeed customDataFeed )
197+ {
198+ customUi = true ;
199+ IAsyncEnumerable < DataFeedItem > datafeed = customDataFeed . Build ( path , groupingKeys ) ;
200+ await foreach ( DataFeedItem item in datafeed )
201+ {
202+ yield return item ;
203+ }
204+ }
205+
206+ if ( dummyField == null && ! customUi )
191207 {
192208 dummyField = new DataFeedValueField < dummy > ( ) ;
193209 dummyField . InitBase ( key , path , groupingKeys , nameKey , descKey ) ;
194210 }
195-
196- yield return dummyField ;
211+
212+ if ( ! customUi )
213+ {
214+ yield return dummyField ;
215+ }
197216 }
198217 else if ( valueType == typeof ( bool ) )
199218 {
200- yield return DataFeedHelpers . GenerateToggle ( key , path , groupingKeys , config ) ;
219+ yield return DataFeedHelpers . GenerateToggle ( key , path , groupingKeys , internalLocale , config ) ;
201220 }
202221 else if ( valueType . IsEnum )
203222 {
@@ -215,7 +234,7 @@ private static async IAsyncEnumerable<DataFeedItem> EnumerateConfigs(ConfigFile
215234 }
216235 else
217236 {
218- enumItem = ( DataFeedItem ) DataFeedHelpers . GenerateEnumItemsAsync . MakeGenericMethod ( valueType ) . Invoke ( null , [ key , path , groupingKeys , config ] ) ;
237+ enumItem = ( DataFeedItem ) DataFeedHelpers . GenerateEnumItemsAsync . MakeGenericMethod ( valueType ) . Invoke ( null , [ key , path , groupingKeys , internalLocale , config ] ) ;
219238 }
220239 }
221240 catch ( Exception e )
@@ -236,7 +255,7 @@ private static async IAsyncEnumerable<DataFeedItem> EnumerateConfigs(ConfigFile
236255
237256 try
238257 {
239- nullableEnumItems = ( IAsyncEnumerable < DataFeedItem > ) DataFeedHelpers . GenerateNullableEnumItemsAsync . MakeGenericMethod ( nullableType ) . Invoke ( null , [ key , path , groupingKeys , config ] ) ;
258+ nullableEnumItems = ( IAsyncEnumerable < DataFeedItem > ) DataFeedHelpers . GenerateNullableEnumItemsAsync . MakeGenericMethod ( nullableType ) . Invoke ( null , [ key , path , groupingKeys , internalLocale , config ] ) ;
240259 }
241260 catch ( Exception e )
242261 {
@@ -261,11 +280,11 @@ private static async IAsyncEnumerable<DataFeedItem> EnumerateConfigs(ConfigFile
261280 {
262281 if ( ! config . SettingType . IsTypeInjectable ( ) && TomlTypeConverter . CanConvert ( config . SettingType ) )
263282 {
264- valueItem = DataFeedHelpers . GenerateProxyField ( key , path , groupingKeys , config ) ;
283+ valueItem = DataFeedHelpers . GenerateProxyField ( key , path , groupingKeys , internalLocale , config ) ;
265284 }
266285 else
267286 {
268- valueItem = ( DataFeedItem ) DataFeedHelpers . GenerateValueField . MakeGenericMethod ( valueType ) . Invoke ( null , [ key , path , groupingKeys , config ] ) ;
287+ valueItem = ( DataFeedItem ) DataFeedHelpers . GenerateValueField . MakeGenericMethod ( valueType ) . Invoke ( null , [ key , path , groupingKeys , internalLocale , config ] ) ;
269288 }
270289 }
271290 catch ( Exception e )
@@ -292,7 +311,7 @@ private static async IAsyncEnumerable<DataFeedItem> EnumerateConfigs(ConfigFile
292311 {
293312 Button btn = syncDelegate . Slot . GetComponent < Button > ( ) ;
294313 if ( btn == null ) return ;
295-
314+
296315 btn . LocalPressed += ( _ , _ ) => LoadConfigs ( metaData . ID ) ;
297316 } ) ;
298317 yield return loadAct ;
@@ -348,6 +367,7 @@ private static async IAsyncEnumerable<DataFeedItem> GetDummyAsync(DataFeedItem i
348367
349368 yield return item ;
350369 }
370+
351371 private static void LoadConfigs ( string pluginId )
352372 {
353373 Plugin . Log . LogDebug ( $ "Loading Configs for { pluginId } ") ;
0 commit comments