4
4
5
5
use crate :: event:: ScriptErrorEvent ;
6
6
use asset:: {
7
- configure_asset_systems, configure_asset_systems_for_plugin,
8
- Language , ScriptAsset , ScriptAssetLoader , ScriptAssetSettings ,
7
+ configure_asset_systems, configure_asset_systems_for_plugin, Language , ScriptAsset ,
8
+ ScriptAssetLoader , ScriptAssetSettings ,
9
9
} ;
10
10
use bevy:: prelude:: * ;
11
11
use bindings:: {
@@ -97,7 +97,6 @@ pub struct ScriptingPlugin<P: IntoScriptPluginParams> {
97
97
pub context_initializers : Vec < ContextInitializer < P > > ,
98
98
/// initializers for the contexts run every time before handling events
99
99
pub context_pre_handling_initializers : Vec < ContextPreHandlingInitializer < P > > ,
100
-
101
100
}
102
101
103
102
impl < P : IntoScriptPluginParams > Default for ScriptingPlugin < P > {
@@ -138,7 +137,10 @@ impl<P: IntoScriptPluginParams> Plugin for ScriptingPlugin<P> {
138
137
once_per_app_init ( app) ;
139
138
140
139
if !self . additional_supported_extensions . is_empty ( ) {
141
- app. add_supported_script_extensions ( self . additional_supported_extensions , self . language . clone ( ) ) ;
140
+ app. add_supported_script_extensions (
141
+ self . additional_supported_extensions ,
142
+ self . language . clone ( ) ,
143
+ ) ;
142
144
}
143
145
144
146
register_types ( app) ;
@@ -202,7 +204,7 @@ pub trait ConfigureScriptPlugin {
202
204
fn enable_context_sharing ( self ) -> Self ;
203
205
204
206
/// Set the set of extensions to be added for the plugin's language.
205
- ///
207
+ ///
206
208
/// This is useful for adding extensions that are not supported by default by BMS.
207
209
fn set_additional_supported_extensions ( self , extensions : & ' static [ & ' static str ] ) -> Self ;
208
210
}
@@ -238,8 +240,6 @@ impl<P: IntoScriptPluginParams + AsMut<ScriptingPlugin<P>>> ConfigureScriptPlugi
238
240
self . as_mut ( ) . additional_supported_extensions = extensions;
239
241
self
240
242
}
241
-
242
-
243
243
}
244
244
245
245
fn once_per_app_finalize ( app : & mut App ) {
@@ -395,13 +395,21 @@ impl ManageStaticScripts for App {
395
395
/// Any changes to the asset settings after that will not be reflected in the asset loader.
396
396
pub trait ConfigureScriptAssetSettings {
397
397
/// Adds a supported extension to the asset settings
398
- ///
398
+ ///
399
399
/// This is only valid to call in the plugin building phase, as the asset loader will be created in the `finalize` phase.
400
- fn add_supported_script_extensions ( & mut self , extensions : & [ & ' static str ] , language : Language ) -> & mut Self ;
400
+ fn add_supported_script_extensions (
401
+ & mut self ,
402
+ extensions : & [ & ' static str ] ,
403
+ language : Language ,
404
+ ) -> & mut Self ;
401
405
}
402
406
403
407
impl ConfigureScriptAssetSettings for App {
404
- fn add_supported_script_extensions ( & mut self , extensions : & [ & ' static str ] , language : Language ) -> & mut Self {
408
+ fn add_supported_script_extensions (
409
+ & mut self ,
410
+ extensions : & [ & ' static str ] ,
411
+ language : Language ,
412
+ ) -> & mut Self {
405
413
let mut asset_settings = self
406
414
. world_mut ( )
407
415
. get_resource_or_init :: < ScriptAssetSettings > ( ) ;
@@ -414,7 +422,9 @@ impl ConfigureScriptAssetSettings for App {
414
422
415
423
asset_settings. supported_extensions = new_arr_static;
416
424
for extension in extensions {
417
- asset_settings. extension_to_language_map . insert ( * extension, language. clone ( ) ) ;
425
+ asset_settings
426
+ . extension_to_language_map
427
+ . insert ( * extension, language. clone ( ) ) ;
418
428
}
419
429
420
430
self
0 commit comments