mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-11 22:50:08 +00:00
style: simplify string formatting for readability (#686)
* style: simplify string formatting for readability * fix: formatting in 15 files
This commit is contained in:
@@ -128,7 +128,7 @@ impl ParameterPanel {
|
||||
|
||||
if let Err(sync_errors) = ctx.sync(parameters, ui, 0, true, Default::default()) {
|
||||
for error in sync_errors {
|
||||
Log::err(format!("Failed to sync property. Reason: {:?}", error))
|
||||
Log::err(format!("Failed to sync property. Reason: {error:?}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ impl StateViewer {
|
||||
ui.send_message(WindowMessage::title(
|
||||
self.window,
|
||||
MessageDirection::ToWidget,
|
||||
WindowTitle::text(format!("State Viewer - {}", state_name)),
|
||||
WindowTitle::text(format!("State Viewer - {state_name}")),
|
||||
));
|
||||
|
||||
ui.send_message(WidgetMessage::enabled(
|
||||
|
||||
@@ -247,7 +247,7 @@ impl Control for Ruler {
|
||||
let mut text = self.text.borrow_mut();
|
||||
|
||||
for x in self.transform.x_step_iter(STANDARD_GRID_SIZE) {
|
||||
text.set_text(format!("{:.1}s", x)).build();
|
||||
text.set_text(format!("{x:.1}s")).build();
|
||||
let vx = self.local_to_view(x);
|
||||
ctx.draw_text(self.clip_bounds(), Vector2::new(vx + 1.0, 0.0), &text);
|
||||
}
|
||||
|
||||
@@ -1087,7 +1087,7 @@ impl Toolbar {
|
||||
animation.set_name(if i == 0 {
|
||||
file_stem.clone()
|
||||
} else {
|
||||
format!("{} {}", file_stem, i)
|
||||
format!("{file_stem} {i}")
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -953,8 +953,7 @@ impl TrackList {
|
||||
}
|
||||
Err(e) => {
|
||||
Log::err(format!(
|
||||
"Invalid property path {:?}. Error: {:?}!",
|
||||
property_path, e
|
||||
"Invalid property path {property_path:?}. Error: {e:?}!"
|
||||
));
|
||||
}
|
||||
})
|
||||
@@ -1227,7 +1226,7 @@ impl TrackList {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
Log::err(format!("Invalid property path {:?}. Error: {:?}!", desc, e));
|
||||
Log::err(format!("Invalid property path {desc:?}. Error: {e:?}!"));
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1565,21 +1564,18 @@ impl TrackList {
|
||||
if let Some((_, type_)) = type_id_to_supported_type(property_type) {
|
||||
if *value_type != type_ {
|
||||
validation_result = Err(format!(
|
||||
"Property type mismatch. Expected {:?}, got {:?}",
|
||||
value_type, type_
|
||||
"Property type mismatch. Expected {value_type:?}, got {type_:?}"
|
||||
));
|
||||
}
|
||||
} else {
|
||||
validation_result = Err(format!(
|
||||
"Unsupported property type of {:?} type id.",
|
||||
property_type
|
||||
"Unsupported property type of {property_type:?} type id."
|
||||
));
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
validation_result = Err(format!(
|
||||
"Unable to resolve property path {}. Reason: {:?}",
|
||||
name, err
|
||||
"Unable to resolve property path {name}. Reason: {err:?}"
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -314,7 +314,7 @@ impl AssetItemBuilder {
|
||||
.with_margin(Thickness::uniform(1.0))
|
||||
.with_allow_drag(true)
|
||||
.with_foreground(Brush::Solid(Color::opaque(50, 50, 50)))
|
||||
.with_tooltip(make_tooltip(ctx, &format!("{:?}", path)))
|
||||
.with_tooltip(make_tooltip(ctx, &format!("{path:?}")))
|
||||
.with_child(
|
||||
GridBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
|
||||
@@ -109,8 +109,7 @@ fn execute_command(command: &mut Command) {
|
||||
match command.spawn() {
|
||||
Ok(mut process) => Log::verify(process.wait()),
|
||||
Err(err) => Log::err(format!(
|
||||
"Failed to show asset item in explorer. Reason: {:?}",
|
||||
err
|
||||
"Failed to show asset item in explorer. Reason: {err:?}"
|
||||
)),
|
||||
}
|
||||
}
|
||||
@@ -508,7 +507,7 @@ impl ResourceCreator {
|
||||
|
||||
asset_added = true;
|
||||
}
|
||||
Err(e) => Log::err(format!("Unable to create a resource. Reason: {:?}", e)),
|
||||
Err(e) => Log::err(format!("Unable to create a resource. Reason: {e:?}")),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1266,9 +1265,8 @@ impl AssetBrowser {
|
||||
}) {
|
||||
if ext == "fbx" {
|
||||
Log::warn(format!(
|
||||
"Resource {} cannot be scanned for \
|
||||
references, because FBX cannot be exported.",
|
||||
kind
|
||||
"Resource {kind} cannot be scanned for \
|
||||
references, because FBX cannot be exported."
|
||||
));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ impl CommandStack {
|
||||
) {
|
||||
for mut dropped_command in commands.drain(range) {
|
||||
if debug {
|
||||
println!("Finalizing command {:?}", dropped_command);
|
||||
println!("Finalizing command {dropped_command:?}");
|
||||
}
|
||||
dropped_command.finalize(context);
|
||||
}
|
||||
@@ -235,7 +235,7 @@ impl CommandStack {
|
||||
}
|
||||
|
||||
if self.debug {
|
||||
println!("Executing command {:?}", command);
|
||||
println!("Executing command {command:?}");
|
||||
}
|
||||
|
||||
command.execute(context);
|
||||
@@ -248,7 +248,7 @@ impl CommandStack {
|
||||
if let Some(top) = self.top.as_mut() {
|
||||
if let Some(command) = self.commands.get_mut(*top) {
|
||||
if self.debug {
|
||||
println!("Undo command {:?}", command);
|
||||
println!("Undo command {command:?}");
|
||||
}
|
||||
command.revert(context)
|
||||
}
|
||||
@@ -281,7 +281,7 @@ impl CommandStack {
|
||||
|
||||
if let Some(command) = command {
|
||||
if self.debug {
|
||||
println!("Redo command {:?}", command);
|
||||
println!("Redo command {command:?}");
|
||||
}
|
||||
command.execute(context)
|
||||
}
|
||||
@@ -291,7 +291,7 @@ impl CommandStack {
|
||||
pub fn clear(&mut self, context: &mut dyn CommandContext) {
|
||||
for mut dropped_command in self.commands.drain(..) {
|
||||
if self.debug {
|
||||
println!("Finalizing command {:?}", dropped_command);
|
||||
println!("Finalizing command {dropped_command:?}");
|
||||
}
|
||||
dropped_command.finalize(context);
|
||||
}
|
||||
@@ -329,10 +329,9 @@ where
|
||||
let mut func = Some(func);
|
||||
entity.resolve_path_mut(path, &mut |result| match result {
|
||||
Ok(field) => func.take().unwrap()(field),
|
||||
Err(e) => fyrox::core::log::Log::err(format!(
|
||||
"There is no such property {}! Reason: {:?}",
|
||||
path, e
|
||||
)),
|
||||
Err(e) => {
|
||||
fyrox::core::log::Log::err(format!("There is no such property {path}! Reason: {e:?}"))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+17
-29
@@ -193,19 +193,12 @@ fn read_metadata() -> Result<Metadata, String> {
|
||||
Ok(output) => match serde_json::from_slice::<Metadata>(&output.stdout) {
|
||||
Ok(metadata) => Ok(metadata),
|
||||
Err(err) => Err(format!(
|
||||
"Unable to parse workspace metadata. Reason {:?}",
|
||||
err
|
||||
"Unable to parse workspace metadata. Reason {err:?}"
|
||||
)),
|
||||
},
|
||||
Err(err) => Err(format!(
|
||||
"Unable to fetch project metadata. Reason {:?}",
|
||||
err
|
||||
)),
|
||||
Err(err) => Err(format!("Unable to fetch project metadata. Reason {err:?}")),
|
||||
},
|
||||
Err(err) => Err(format!(
|
||||
"Unable to fetch project metadata. Reason {:?}",
|
||||
err
|
||||
)),
|
||||
Err(err) => Err(format!("Unable to fetch project metadata. Reason {err:?}")),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -215,8 +208,7 @@ fn prepare_build_dir(path: &Path) -> Result<(), String> {
|
||||
|
||||
if let Err(err) = fs::remove_dir_all(path) {
|
||||
return Err(format!(
|
||||
"Unable to remove previous build at destination path! Reason: {:?}",
|
||||
err
|
||||
"Unable to remove previous build at destination path! Reason: {err:?}"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -224,8 +216,7 @@ fn prepare_build_dir(path: &Path) -> Result<(), String> {
|
||||
// Create the new clean folder.
|
||||
if let Err(err) = fs::create_dir_all(path) {
|
||||
return Err(format!(
|
||||
"Unable to create build directory at destination path! Reason: {:?}",
|
||||
err
|
||||
"Unable to create build directory at destination path! Reason: {err:?}"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -268,14 +259,14 @@ fn cargo_install(crate_name: &str) -> Result<(), String> {
|
||||
Err(String::from_utf8_lossy(&output.stderr).to_string())
|
||||
}
|
||||
}
|
||||
Err(err) => Err(format!("Unable to install {crate_name}. Reason: {:?}", err)),
|
||||
Err(err) => Err(format!("Unable to install {crate_name}. Reason: {err:?}")),
|
||||
},
|
||||
Err(err) => Err(format!("Unable to install {crate_name}. Reason: {:?}", err)),
|
||||
Err(err) => Err(format!("Unable to install {crate_name}. Reason: {err:?}")),
|
||||
}
|
||||
}
|
||||
|
||||
fn install_build_target(target: &str) -> Result<(), String> {
|
||||
Log::info(format!("Trying to install {} build target...", target));
|
||||
Log::info(format!("Trying to install {target} build target..."));
|
||||
|
||||
let mut process = make_command("rustup");
|
||||
match process
|
||||
@@ -288,7 +279,7 @@ fn install_build_target(target: &str) -> Result<(), String> {
|
||||
Ok(handle) => match handle.wait_with_output() {
|
||||
Ok(output) => {
|
||||
if output.status.code().unwrap_or(1) == 0 {
|
||||
Log::info(format!("{} target installed successfully!", target));
|
||||
Log::info(format!("{target} target installed successfully!"));
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
@@ -296,13 +287,11 @@ fn install_build_target(target: &str) -> Result<(), String> {
|
||||
}
|
||||
}
|
||||
Err(err) => Err(format!(
|
||||
"Unable to install {} target. Reason: {:?}",
|
||||
target, err
|
||||
"Unable to install {target} target. Reason: {err:?}"
|
||||
)),
|
||||
},
|
||||
Err(err) => Err(format!(
|
||||
"Unable to install {} target. Reason: {:?}",
|
||||
target, err
|
||||
"Unable to install {target} target. Reason: {err:?}"
|
||||
)),
|
||||
}
|
||||
}
|
||||
@@ -380,7 +369,7 @@ fn build_package(
|
||||
let mut handle = match process.spawn() {
|
||||
Ok(handle) => handle,
|
||||
Err(err) => {
|
||||
return Err(format!("Failed to build the game. Reason: {:?}", err));
|
||||
return Err(format!("Failed to build the game. Reason: {err:?}"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -411,7 +400,7 @@ fn build_package(
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
return Err(format!("Failed to build the game. Reason: {:?}", err));
|
||||
return Err(format!("Failed to build the game. Reason: {err:?}"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,8 +536,7 @@ fn export(export_options: ExportOptions, cancel_flag: Arc<AtomicBool>) -> Result
|
||||
|
||||
let Some(package) = metadata.packages.iter().find(|p| p.name == package_name) else {
|
||||
return Err(format!(
|
||||
"The project does not have `{}` package.",
|
||||
package_name
|
||||
"The project does not have `{package_name}` package."
|
||||
));
|
||||
};
|
||||
|
||||
@@ -713,7 +701,7 @@ fn export(export_options: ExportOptions, cancel_flag: Arc<AtomicBool>) -> Result
|
||||
.spawn(),
|
||||
);
|
||||
}
|
||||
Err(err) => Log::err(format!("ADB error: {:?}", err)),
|
||||
Err(err) => Log::err(format!("ADB error: {err:?}")),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1113,7 +1101,7 @@ impl ExportWindow {
|
||||
ctx.sync(&self.export_options, ui, 0, true, Default::default())
|
||||
{
|
||||
for error in sync_errors {
|
||||
Log::err(format!("Failed to sync property. Reason: {:?}", error))
|
||||
Log::err(format!("Failed to sync property. Reason: {error:?}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1156,7 +1144,7 @@ impl ExportWindow {
|
||||
Ok(_) => {
|
||||
Log::info("Build finished!");
|
||||
}
|
||||
Err(err) => Log::err(format!("Build failed! Reason: {}", err)),
|
||||
Err(err) => Log::err(format!("Build failed! Reason: {err}")),
|
||||
}
|
||||
|
||||
ui.send_message(WidgetMessage::enabled(
|
||||
|
||||
@@ -167,7 +167,7 @@ fn make_name(material: &MaterialResource) -> String {
|
||||
format!("{} - {} uses", header.kind, material.use_count())
|
||||
}
|
||||
ResourceState::LoadError { ref error, .. } => {
|
||||
format!("Loading failed: {:?}", error)
|
||||
format!("Loading failed: {error:?}")
|
||||
}
|
||||
ResourceState::Pending { .. } => {
|
||||
format!("Loading {}", header.kind)
|
||||
|
||||
@@ -146,7 +146,7 @@ fn print_errors(sync_errors: &[InspectorError]) {
|
||||
for error in sync_errors {
|
||||
Log::writeln(
|
||||
MessageKind::Error,
|
||||
format!("Failed to sync property. Reason: {:?}", error),
|
||||
format!("Failed to sync property. Reason: {error:?}"),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,7 +680,7 @@ impl BrushPanel {
|
||||
if let Err(e) = ctx.sync(brush, ui, 0, true, Default::default()) {
|
||||
Log::writeln(
|
||||
MessageKind::Error,
|
||||
format!("Failed to sync BrushPanel's inspector. Reason: {:?}", e),
|
||||
format!("Failed to sync BrushPanel's inspector. Reason: {e:?}"),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+14
-23
@@ -556,8 +556,7 @@ impl Editor {
|
||||
Log::info("Editor settings were loaded successfully!");
|
||||
}
|
||||
Err(e) => Log::warn(format!(
|
||||
"Failed to load settings, fallback to default. Reason: {:?}",
|
||||
e
|
||||
"Failed to load settings, fallback to default. Reason: {e:?}"
|
||||
)),
|
||||
}
|
||||
|
||||
@@ -925,8 +924,7 @@ impl Editor {
|
||||
self.settings = Default::default();
|
||||
|
||||
Log::warn(format!(
|
||||
"Failed to load settings, fallback to default. Reason: {:?}",
|
||||
e
|
||||
"Failed to load settings, fallback to default. Reason: {e:?}"
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -945,10 +943,7 @@ impl Editor {
|
||||
Ok(_) => {
|
||||
Log::info("Graphics settings were applied successfully!");
|
||||
}
|
||||
Err(e) => Log::info(format!(
|
||||
"Failed to apply graphics settings! Reason: {:?}",
|
||||
e
|
||||
)),
|
||||
Err(e) => Log::info(format!("Failed to apply graphics settings! Reason: {e:?}")),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1517,7 +1512,7 @@ impl Editor {
|
||||
|
||||
self.on_mode_changed();
|
||||
}
|
||||
Err(e) => Log::err(format!("Failed to enter play mode: {:?}", e)),
|
||||
Err(e) => Log::err(format!("Failed to enter play mode: {e:?}")),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2116,7 +2111,7 @@ impl Editor {
|
||||
engine.resource_manager.state().set_watcher(Some(watcher));
|
||||
}
|
||||
Err(e) => {
|
||||
Log::err(format!("Unable to create resource watcher. Reason {:?}", e));
|
||||
Log::err(format!("Unable to create resource watcher. Reason {e:?}"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2129,8 +2124,7 @@ impl Editor {
|
||||
.on_configure(engine.user_interfaces.first(), &self.settings);
|
||||
|
||||
Log::info(format!(
|
||||
"New working directory was successfully set: {:?}",
|
||||
working_directory
|
||||
"New working directory was successfully set: {working_directory:?}"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -2182,10 +2176,10 @@ impl Editor {
|
||||
self.mode = Mode::Edit;
|
||||
self.on_mode_changed();
|
||||
|
||||
Log::warn(format!("Game was closed: {:?}", status))
|
||||
Log::warn(format!("Game was closed: {status:?}"))
|
||||
}
|
||||
}
|
||||
Err(err) => Log::err(format!("Failed to wait for game process: {:?}", err)),
|
||||
Err(err) => Log::err(format!("Failed to wait for game process: {err:?}")),
|
||||
}
|
||||
}
|
||||
Mode::Build {
|
||||
@@ -2194,7 +2188,7 @@ impl Editor {
|
||||
} => {
|
||||
if process.is_none() {
|
||||
if let Some(command) = queue.pop_front() {
|
||||
Log::info(format!("Trying to run build command: {}", command));
|
||||
Log::info(format!("Trying to run build command: {command}"));
|
||||
|
||||
let mut new_process = std::process::Command::new(&command.command);
|
||||
new_process
|
||||
@@ -2216,7 +2210,7 @@ impl Editor {
|
||||
|
||||
*process = Some(new_process);
|
||||
}
|
||||
Err(e) => Log::err(format!("Failed to enter build mode: {:?}", e)),
|
||||
Err(e) => Log::err(format!("Failed to enter build mode: {e:?}")),
|
||||
}
|
||||
} else {
|
||||
Log::warn("Empty build command queue!");
|
||||
@@ -2251,7 +2245,7 @@ impl Editor {
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => Log::err(format!("Failed to wait for game process: {:?}", err)),
|
||||
Err(err) => Log::err(format!("Failed to wait for game process: {err:?}")),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2728,10 +2722,7 @@ impl Editor {
|
||||
Ok(_) => {
|
||||
Log::info("Graphics settings were applied successfully!");
|
||||
}
|
||||
Err(e) => Log::err(format!(
|
||||
"Failed to apply graphics settings! Reason: {:?}",
|
||||
e
|
||||
)),
|
||||
Err(e) => Log::err(format!("Failed to apply graphics settings! Reason: {e:?}")),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2788,7 +2779,7 @@ impl Editor {
|
||||
if let Err(e) = self.engine.set_frame_size((*size).into()) {
|
||||
fyrox::core::log::Log::writeln(
|
||||
MessageKind::Error,
|
||||
format!("Failed to set renderer size! Reason: {:?}", e),
|
||||
format!("Failed to set renderer size! Reason: {e:?}"),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2974,7 +2965,7 @@ fn update(editor: &mut Editor, window_target: &EventLoopWindowTarget<()>) {
|
||||
);
|
||||
entry.selection = Default::default();
|
||||
|
||||
Log::warn(format!("Command stack flushed for scene {}", i));
|
||||
Log::warn(format!("Command stack flushed for scene {i}"));
|
||||
}
|
||||
|
||||
editor.message_sender.send(Message::SelectionChanged {
|
||||
|
||||
+3
-4
@@ -350,8 +350,7 @@ impl LightPanel {
|
||||
})
|
||||
{
|
||||
Log::err(format!(
|
||||
"Failed to create a new lightmap generation thread. Reason: {}",
|
||||
e
|
||||
"Failed to create a new lightmap generation thread. Reason: {e}"
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -387,11 +386,11 @@ impl LightPanel {
|
||||
match result {
|
||||
Ok(lightmap) => {
|
||||
if let Err(err) = scene.graph.set_lightmap(lightmap) {
|
||||
Log::err(format!("Failed to set generated lightmap. Reason: {}", err));
|
||||
Log::err(format!("Failed to set generated lightmap. Reason: {err}"));
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
Log::err(format!("Failed to generated a lightmap. Reason: {}", err));
|
||||
Log::err(format!("Failed to generated a lightmap. Reason: {err}"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -493,7 +493,7 @@ impl MaterialEditor {
|
||||
let item = *self
|
||||
.properties
|
||||
.value_of(name)
|
||||
.unwrap_or_else(|| panic!("Property not found {}", name));
|
||||
.unwrap_or_else(|| panic!("Property not found {name}"));
|
||||
|
||||
match property_value {
|
||||
PropertyValue::Float(value) => {
|
||||
|
||||
@@ -267,7 +267,7 @@ impl TileSetEditor {
|
||||
if let Err(sync_errors) = ctx.sync(tile_definition, ui, 0, true, Default::default())
|
||||
{
|
||||
for error in sync_errors {
|
||||
Log::err(format!("Failed to sync property. Reason: {:?}", error))
|
||||
Log::err(format!("Failed to sync property. Reason: {error:?}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-11
@@ -269,7 +269,7 @@ impl GameScene {
|
||||
pure_scene.save("Scene", &mut visitor).unwrap();
|
||||
|
||||
if let Err(e) = visitor.save_binary(path) {
|
||||
Err(format!("Failed to save scene! Reason: {}", e))
|
||||
Err(format!("Failed to save scene! Reason: {e}"))
|
||||
} else {
|
||||
if settings.debugging.save_scene_in_text_form {
|
||||
let text = visitor.save_text();
|
||||
@@ -447,20 +447,13 @@ impl GameScene {
|
||||
|
||||
let mut visitor = Visitor::new();
|
||||
match dest_scene.save("Scene", &mut visitor) {
|
||||
Err(e) => Log::err(format!(
|
||||
"Failed to save selection as prefab! Reason: {:?}",
|
||||
e
|
||||
)),
|
||||
Err(e) => Log::err(format!("Failed to save selection as prefab! Reason: {e:?}")),
|
||||
Ok(_) => {
|
||||
if let Err(e) = visitor.save_binary(path) {
|
||||
Log::err(format!(
|
||||
"Failed to save selection as prefab! Reason: {:?}",
|
||||
e
|
||||
));
|
||||
Log::err(format!("Failed to save selection as prefab! Reason: {e:?}"));
|
||||
} else {
|
||||
Log::info(format!(
|
||||
"Selection was successfully saved as prefab to {:?}!",
|
||||
path
|
||||
"Selection was successfully saved as prefab to {path:?}!"
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,10 +198,10 @@ where
|
||||
|
||||
for i in 0..array.reflect_len() {
|
||||
let item = array.reflect_index(i).unwrap();
|
||||
let item_path = format!("{}[{}]", path, i);
|
||||
let item_path = format!("{path}[{i}]");
|
||||
descriptor.children_properties.push(PropertyDescriptor {
|
||||
path: item_path.clone(),
|
||||
display_name: format!("[{}]", i),
|
||||
display_name: format!("[{i}]"),
|
||||
type_name: item.type_name().to_owned(),
|
||||
type_id: item.type_id(),
|
||||
read_only: field_info.read_only,
|
||||
@@ -233,7 +233,7 @@ where
|
||||
|
||||
// TODO: Here we just using `Debug` impl to obtain string representation for keys. This is
|
||||
// fine for most cases in the engine.
|
||||
let mut key_str = format!("{:?}", key);
|
||||
let mut key_str = format!("{key:?}");
|
||||
|
||||
let mut is_key_string = false;
|
||||
key.downcast_ref::<String>(&mut |string| {
|
||||
@@ -251,11 +251,11 @@ where
|
||||
key_str.pop();
|
||||
}
|
||||
|
||||
let item_path = format!("{}[{}]", path, key_str);
|
||||
let item_path = format!("{path}[{key_str}]");
|
||||
|
||||
descriptor.children_properties.push(PropertyDescriptor {
|
||||
path: item_path.clone(),
|
||||
display_name: format!("[{}]", key_str),
|
||||
display_name: format!("[{key_str}]"),
|
||||
type_name: value.type_name().to_owned(),
|
||||
type_id: value.type_id(),
|
||||
read_only: field_info.read_only,
|
||||
|
||||
@@ -47,7 +47,7 @@ impl Display for BuildCommand {
|
||||
write!(f, "{}", self.command)?;
|
||||
|
||||
for arg in self.args.iter() {
|
||||
write!(f, " {}", arg)?;
|
||||
write!(f, " {arg}")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -400,8 +400,7 @@ impl SettingsWindow {
|
||||
.set_quality_settings(&settings.graphics.quality)
|
||||
{
|
||||
Log::err(format!(
|
||||
"An error occurred at attempt to set new graphics settings: {:?}",
|
||||
e
|
||||
"An error occurred at attempt to set new graphics settings: {e:?}"
|
||||
));
|
||||
} else {
|
||||
Log::info("New graphics quality settings were successfully set!");
|
||||
|
||||
@@ -1212,7 +1212,7 @@ impl RagdollWizard {
|
||||
|
||||
if let Err(sync_errors) = ctx.sync(&self.preset, ui, 0, true, Default::default()) {
|
||||
for error in sync_errors {
|
||||
Log::err(format!("Failed to sync property. Reason: {:?}", error))
|
||||
Log::err(format!("Failed to sync property. Reason: {error:?}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ impl WorldViewer {
|
||||
.with_text(if self.breadcrumbs.is_empty() {
|
||||
name.to_owned()
|
||||
} else {
|
||||
format!("{} >", name)
|
||||
format!("{name} >")
|
||||
})
|
||||
.with_font_size(11.0)
|
||||
.build(ctx),
|
||||
|
||||
@@ -305,7 +305,7 @@ impl Display for ValueBinding {
|
||||
ValueBinding::Position => write!(f, "Position"),
|
||||
ValueBinding::Scale => write!(f, "Scale"),
|
||||
ValueBinding::Rotation => write!(f, "Rotation"),
|
||||
ValueBinding::Property { name, .. } => write!(f, "{}", name),
|
||||
ValueBinding::Property { name, .. } => write!(f, "{name}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,14 +342,12 @@ impl BoundValue {
|
||||
match err {
|
||||
SetFieldByPathError::InvalidPath { reason, .. } => {
|
||||
Log::err(format!(
|
||||
"Failed to set property {}! Invalid path: {}",
|
||||
property_name, reason
|
||||
"Failed to set property {property_name}! Invalid path: {reason}"
|
||||
));
|
||||
}
|
||||
SetFieldByPathError::InvalidValue(_) => {
|
||||
Log::err(format!(
|
||||
"Failed to set property {}! Types mismatch!",
|
||||
property_name
|
||||
"Failed to set property {property_name}! Types mismatch!"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ pub fn enum_prop_ident(
|
||||
let variant_ident = &variant_args.ident;
|
||||
let field_ident = self::field_ident_string(&variant_args.fields, nth, field);
|
||||
|
||||
let ident = format!("{}_{}", variant_ident, field_ident).to_case(Case::UpperSnake);
|
||||
let ident = format!("{variant_ident}_{field_ident}").to_case(Case::UpperSnake);
|
||||
syn::parse_str(&ident).unwrap()
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ fn field_ident_string(fields: &args::Fields, nth: usize, field: &args::FieldArgs
|
||||
ast::Style::Struct => field.ident.as_ref().unwrap().to_string(),
|
||||
ast::Style::Tuple => {
|
||||
// this is actually `F_0` in UPPER_SNAKE_CASE
|
||||
format!("F{}", nth)
|
||||
format!("F{nth}")
|
||||
}
|
||||
ast::Style::Unit => unreachable!(),
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ fn impl_visit_struct(
|
||||
/// impl `Visit` for `enum`
|
||||
fn impl_visit_enum(ty_args: &args::TypeArgs, variant_args: &[args::VariantArgs]) -> TokenStream2 {
|
||||
let ty_ident = &ty_args.ident;
|
||||
let ty_name = format!("{}", ty_ident);
|
||||
let ty_name = format!("{ty_ident}");
|
||||
|
||||
// variant ID = variant index
|
||||
let id_type = quote!(u32);
|
||||
|
||||
@@ -91,10 +91,7 @@ pub fn create_field_visits<'a>(
|
||||
ast::Style::Struct => {
|
||||
let ident = field.ident.as_ref().unwrap_or_else(|| unreachable!());
|
||||
|
||||
(
|
||||
quote!(#ident),
|
||||
format!("{}", ident).to_case(Case::UpperCamel),
|
||||
)
|
||||
(quote!(#ident), format!("{ident}").to_case(Case::UpperCamel))
|
||||
}
|
||||
// `Tuple(f32, ..)`
|
||||
ast::Style::Tuple => {
|
||||
@@ -108,7 +105,7 @@ pub fn create_field_visits<'a>(
|
||||
quote!(#ident)
|
||||
};
|
||||
|
||||
(ident, format!("{}", field_index))
|
||||
(ident, format!("{field_index}"))
|
||||
}
|
||||
ast::Style::Unit => unreachable!(),
|
||||
};
|
||||
|
||||
@@ -38,8 +38,8 @@ pub fn save_load<T: Visit>(test_name: &str, data: &mut T, data_default: &mut T)
|
||||
let root = PathBuf::from(manifest_dir).join("test_output");
|
||||
let _ = std::fs::create_dir(&root);
|
||||
(
|
||||
root.join(format!("{}.bin", test_name)),
|
||||
root.join(format!("{}.txt", test_name)),
|
||||
root.join(format!("{test_name}.bin")),
|
||||
root.join(format!("{test_name}.txt")),
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ impl Log {
|
||||
if let Err(e) = result {
|
||||
Self::writeln(
|
||||
MessageKind::Error,
|
||||
format!("Operation failed! Reason: {:?}", e),
|
||||
format!("Operation failed! Reason: {e:?}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -221,7 +221,7 @@ impl Log {
|
||||
S: Display,
|
||||
{
|
||||
if let Err(e) = result {
|
||||
Self::writeln(MessageKind::Error, format!("{}. Reason: {:?}", msg, e));
|
||||
Self::writeln(MessageKind::Error, format!("{msg}. Reason: {e:?}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,8 +121,7 @@ impl NetStream {
|
||||
Ok(message) => Some(message),
|
||||
Err(err) => {
|
||||
Log::err(format!(
|
||||
"Failed to parse a network message of {} bytes long. Reason: {:?}",
|
||||
length, err
|
||||
"Failed to parse a network message of {length} bytes long. Reason: {err:?}"
|
||||
));
|
||||
|
||||
None
|
||||
@@ -161,8 +160,7 @@ impl NetStream {
|
||||
}
|
||||
_ => {
|
||||
Log::err(format!(
|
||||
"An error occurred when reading data from socket: {}",
|
||||
err
|
||||
"An error occurred when reading data from socket: {err}"
|
||||
));
|
||||
|
||||
self.rx_buffer.clear();
|
||||
|
||||
+11
-17
@@ -471,8 +471,7 @@ where
|
||||
|
||||
if record.payload.is_some() {
|
||||
panic!(
|
||||
"Attempt to spawn an object at pool record with payload! Record index is {}",
|
||||
free_index
|
||||
"Attempt to spawn an object at pool record with payload! Record index is {free_index}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -527,8 +526,7 @@ where
|
||||
|
||||
if record.payload.is_some() {
|
||||
panic!(
|
||||
"Attempt to spawn an object at pool record with payload! Record index is {}",
|
||||
free_index
|
||||
"Attempt to spawn an object at pool record with payload! Record index is {free_index}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -605,7 +603,7 @@ where
|
||||
if let Some(payload) = record.payload.as_ref() {
|
||||
payload
|
||||
} else {
|
||||
panic!("Attempt to borrow destroyed object at {:?} handle.", handle);
|
||||
panic!("Attempt to borrow destroyed object at {handle:?} handle.");
|
||||
}
|
||||
} else {
|
||||
panic!(
|
||||
@@ -648,15 +646,14 @@ where
|
||||
if let Some(payload) = record.payload.as_mut() {
|
||||
payload
|
||||
} else {
|
||||
panic!("Attempt to borrow destroyed object at {:?} handle.", handle);
|
||||
panic!("Attempt to borrow destroyed object at {handle:?} handle.");
|
||||
}
|
||||
} else {
|
||||
panic!("Attempt to borrow object using dangling handle {:?}. Record has {} generation!", handle, record.generation);
|
||||
}
|
||||
} else {
|
||||
panic!(
|
||||
"Attempt to borrow object using out-of-bounds handle {:?}! Record count is {}",
|
||||
handle, record_count
|
||||
"Attempt to borrow object using out-of-bounds handle {handle:?}! Record count is {record_count}"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -852,7 +849,7 @@ where
|
||||
if let Some(payload) = record.payload.take() {
|
||||
payload
|
||||
} else {
|
||||
panic!("Attempt to double free object at handle {:?}!", handle);
|
||||
panic!("Attempt to double free object at handle {handle:?}!");
|
||||
}
|
||||
} else {
|
||||
panic!(
|
||||
@@ -916,10 +913,7 @@ where
|
||||
};
|
||||
(ticket, payload)
|
||||
} else {
|
||||
panic!(
|
||||
"Attempt to take already taken object at handle {:?}!",
|
||||
handle
|
||||
);
|
||||
panic!("Attempt to take already taken object at handle {handle:?}!");
|
||||
}
|
||||
} else {
|
||||
panic!(
|
||||
@@ -1521,16 +1515,16 @@ mod test {
|
||||
pool.free(d);
|
||||
let baz = pool.spawn("Baz".to_string());
|
||||
for s in pool.iter() {
|
||||
println!("{}", s);
|
||||
println!("{s}");
|
||||
}
|
||||
for s in pool.iter_mut() {
|
||||
println!("{}", s);
|
||||
println!("{s}");
|
||||
}
|
||||
for s in &pool {
|
||||
println!("{}", s);
|
||||
println!("{s}");
|
||||
}
|
||||
for s in &mut pool {
|
||||
println!("{}", s);
|
||||
println!("{s}");
|
||||
}
|
||||
pool.free(foobar);
|
||||
pool.free(baz);
|
||||
|
||||
@@ -889,7 +889,7 @@ impl dyn Reflect {
|
||||
if let Some((key, value)) = hash_map.reflect_get_at(i) {
|
||||
// TODO: Here we just using `Debug` impl to obtain string representation for keys. This is
|
||||
// fine for most cases in the engine.
|
||||
let mut key_str = format!("{:?}", key);
|
||||
let mut key_str = format!("{key:?}");
|
||||
|
||||
let mut is_key_string = false;
|
||||
key.downcast_ref::<String>(&mut |string| is_key_string |= string.is_some());
|
||||
@@ -905,7 +905,7 @@ impl dyn Reflect {
|
||||
key_str.pop();
|
||||
}
|
||||
|
||||
let item_path = format!("{}[{}]", path, key_str);
|
||||
let item_path = format!("{path}[{key_str}]");
|
||||
|
||||
value.enumerate_fields_recursively_internal(
|
||||
&item_path,
|
||||
|
||||
@@ -1000,10 +1000,10 @@ mod test {
|
||||
#[test]
|
||||
fn inheritable_variable_try_sync_model() {
|
||||
let v = InheritableVariable::from(42);
|
||||
assert!(!v.try_sync_model(|s| println!("{}", s)));
|
||||
assert!(!v.try_sync_model(|s| println!("{s}")));
|
||||
|
||||
let v = InheritableVariable::new_with_flags(42, VariableFlags::NEED_SYNC);
|
||||
assert!(v.try_sync_model(|s| println!("{}", s)));
|
||||
assert!(v.try_sync_model(|s| println!("{s}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+34
-38
@@ -295,17 +295,17 @@ impl<'a, T: Pod> Visit for PodVecView<'a, T> {
|
||||
impl FieldKind {
|
||||
fn as_string(&self) -> String {
|
||||
match self {
|
||||
Self::Bool(data) => format!("<bool = {}>, ", data),
|
||||
Self::U8(data) => format!("<u8 = {}>, ", data),
|
||||
Self::I8(data) => format!("<i8 = {}>, ", data),
|
||||
Self::U16(data) => format!("<u16 = {}>, ", data),
|
||||
Self::I16(data) => format!("<i16 = {}>, ", data),
|
||||
Self::U32(data) => format!("<u32 = {}>, ", data),
|
||||
Self::I32(data) => format!("<i32 = {}>, ", data),
|
||||
Self::U64(data) => format!("<u64 = {}>, ", data),
|
||||
Self::I64(data) => format!("<i64 = {}>, ", data),
|
||||
Self::F32(data) => format!("<f32 = {}>, ", data),
|
||||
Self::F64(data) => format!("<f64 = {}>, ", data),
|
||||
Self::Bool(data) => format!("<bool = {data}>, "),
|
||||
Self::U8(data) => format!("<u8 = {data}>, "),
|
||||
Self::I8(data) => format!("<i8 = {data}>, "),
|
||||
Self::U16(data) => format!("<u16 = {data}>, "),
|
||||
Self::I16(data) => format!("<i16 = {data}>, "),
|
||||
Self::U32(data) => format!("<u32 = {data}>, "),
|
||||
Self::I32(data) => format!("<i32 = {data}>, "),
|
||||
Self::U64(data) => format!("<u64 = {data}>, "),
|
||||
Self::I64(data) => format!("<i64 = {data}>, "),
|
||||
Self::F32(data) => format!("<f32 = {data}>, "),
|
||||
Self::F64(data) => format!("<f64 = {data}>, "),
|
||||
Self::Vector2F32(data) => format!("<vec2f32 = {}; {}>, ", data.x, data.y),
|
||||
Self::Vector3F32(data) => format!("<vec3f32 = {}; {}; {}>, ", data.x, data.y, data.z),
|
||||
Self::Vector4F32(data) => {
|
||||
@@ -396,7 +396,7 @@ impl FieldKind {
|
||||
Self::Matrix4(data) => {
|
||||
let mut out = String::from("<mat4 = ");
|
||||
for f in data.iter() {
|
||||
out += format!("{}; ", f).as_str();
|
||||
out += format!("{f}; ").as_str();
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -405,17 +405,17 @@ impl FieldKind {
|
||||
Ok(s) => s,
|
||||
Err(_) => base64::engine::general_purpose::STANDARD.encode(data),
|
||||
};
|
||||
format!("<data = {}>, ", out)
|
||||
format!("<data = {out}>, ")
|
||||
}
|
||||
Self::Matrix3(data) => {
|
||||
let mut out = String::from("<mat3 = ");
|
||||
for f in data.iter() {
|
||||
out += format!("{}; ", f).as_str();
|
||||
out += format!("{f}; ").as_str();
|
||||
}
|
||||
out
|
||||
}
|
||||
Self::Uuid(uuid) => {
|
||||
format!("<uuid = {}", uuid)
|
||||
format!("<uuid = {uuid}")
|
||||
}
|
||||
Self::UnitComplex(data) => {
|
||||
format!("<complex = {}; {}>, ", data.re, data.im)
|
||||
@@ -426,15 +426,12 @@ impl FieldKind {
|
||||
bytes,
|
||||
} => {
|
||||
let base64_encoded = base64::engine::general_purpose::STANDARD.encode(bytes);
|
||||
format!(
|
||||
"<podarray = {}; {}; [{}]>",
|
||||
type_id, element_size, base64_encoded
|
||||
)
|
||||
format!("<podarray = {type_id}; {element_size}; [{base64_encoded}]>")
|
||||
}
|
||||
Self::Matrix2(data) => {
|
||||
let mut out = String::from("<mat2 = ");
|
||||
for f in data.iter() {
|
||||
out += format!("{}; ", f).as_str();
|
||||
out += format!("{f}; ").as_str();
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -653,23 +650,23 @@ impl Error for VisitError {}
|
||||
impl Display for VisitError {
|
||||
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Io(io) => write!(f, "io error: {}", io),
|
||||
Self::UnknownFieldType(type_index) => write!(f, "unknown field type {}", type_index),
|
||||
Self::FieldDoesNotExist(name) => write!(f, "field does not exists {}", name),
|
||||
Self::FieldAlreadyExists(name) => write!(f, "field already exists {}", name),
|
||||
Self::RegionAlreadyExists(name) => write!(f, "region already exists {}", name),
|
||||
Self::Io(io) => write!(f, "io error: {io}"),
|
||||
Self::UnknownFieldType(type_index) => write!(f, "unknown field type {type_index}"),
|
||||
Self::FieldDoesNotExist(name) => write!(f, "field does not exists {name}"),
|
||||
Self::FieldAlreadyExists(name) => write!(f, "field already exists {name}"),
|
||||
Self::RegionAlreadyExists(name) => write!(f, "region already exists {name}"),
|
||||
Self::InvalidCurrentNode => write!(f, "invalid current node"),
|
||||
Self::FieldTypeDoesNotMatch => write!(f, "field type does not match"),
|
||||
Self::RegionDoesNotExist(name) => write!(f, "region does not exists {}", name),
|
||||
Self::RegionDoesNotExist(name) => write!(f, "region does not exists {name}"),
|
||||
Self::NoActiveNode => write!(f, "no active node"),
|
||||
Self::NotSupportedFormat => write!(f, "not supported format"),
|
||||
Self::InvalidName => write!(f, "invalid name"),
|
||||
Self::TypeMismatch => write!(f, "type mismatch"),
|
||||
Self::RefCellAlreadyMutableBorrowed => write!(f, "ref cell already mutable borrowed"),
|
||||
Self::User(msg) => write!(f, "user defined error: {}", msg),
|
||||
Self::User(msg) => write!(f, "user defined error: {msg}"),
|
||||
Self::UnexpectedRcNullIndex => write!(f, "unexpected rc null index"),
|
||||
Self::PoisonedMutex => write!(f, "attempt to lock poisoned mutex"),
|
||||
Self::FileLoadError(e) => write!(f, "file load error: {:?}", e),
|
||||
Self::FileLoadError(e) => write!(f, "file load error: {e:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1590,7 +1587,7 @@ where
|
||||
if region.reading {
|
||||
self.clear();
|
||||
for index in 0..len {
|
||||
let region_name = format!("Item{}", index);
|
||||
let region_name = format!("Item{index}");
|
||||
let mut region = region.enter_region(region_name.as_str())?;
|
||||
let mut object = T::default();
|
||||
object.visit("ItemData", &mut region)?;
|
||||
@@ -1598,7 +1595,7 @@ where
|
||||
}
|
||||
} else {
|
||||
for (index, item) in self.iter_mut().enumerate() {
|
||||
let region_name = format!("Item{}", index);
|
||||
let region_name = format!("Item{index}");
|
||||
let mut region = region.enter_region(region_name.as_str())?;
|
||||
item.visit("ItemData", &mut region)?;
|
||||
}
|
||||
@@ -1951,7 +1948,7 @@ where
|
||||
if region.is_reading() {
|
||||
self.clear();
|
||||
for i in 0..(count as usize) {
|
||||
let name = format!("Item{}", i);
|
||||
let name = format!("Item{i}");
|
||||
|
||||
let mut region = region.enter_region(name.as_str())?;
|
||||
|
||||
@@ -1965,7 +1962,7 @@ where
|
||||
}
|
||||
} else {
|
||||
for (i, (key, value)) in self.iter_mut().enumerate() {
|
||||
let name = format!("Item{}", i);
|
||||
let name = format!("Item{i}");
|
||||
|
||||
let mut region = region.enter_region(name.as_str())?;
|
||||
|
||||
@@ -1994,7 +1991,7 @@ where
|
||||
if region.is_reading() {
|
||||
self.clear();
|
||||
for i in 0..(count as usize) {
|
||||
let name = format!("Item{}", i);
|
||||
let name = format!("Item{i}");
|
||||
|
||||
let mut region = region.enter_region(name.as_str())?;
|
||||
|
||||
@@ -2005,7 +2002,7 @@ where
|
||||
}
|
||||
} else {
|
||||
for (i, mut key) in self.clone().into_iter().enumerate() {
|
||||
let name = format!("Item{}", i);
|
||||
let name = format!("Item{i}");
|
||||
|
||||
let mut region = region.enter_region(name.as_str())?;
|
||||
|
||||
@@ -2027,13 +2024,12 @@ impl<T: Default + Visit, const SIZE: usize> Visit for [T; SIZE] {
|
||||
if region.reading {
|
||||
if len > SIZE as u32 {
|
||||
return VisitResult::Err(VisitError::User(format!(
|
||||
"Not enough space in static array, got {}, needed {}!",
|
||||
len, SIZE
|
||||
"Not enough space in static array, got {len}, needed {SIZE}!"
|
||||
)));
|
||||
}
|
||||
|
||||
for index in 0..len {
|
||||
let region_name = format!("Item{}", index);
|
||||
let region_name = format!("Item{index}");
|
||||
let mut region = region.enter_region(region_name.as_str())?;
|
||||
let mut object = T::default();
|
||||
object.visit("ItemData", &mut region)?;
|
||||
@@ -2041,7 +2037,7 @@ impl<T: Default + Visit, const SIZE: usize> Visit for [T; SIZE] {
|
||||
}
|
||||
} else {
|
||||
for (index, item) in self.iter_mut().enumerate() {
|
||||
let region_name = format!("Item{}", index);
|
||||
let region_name = format!("Item{index}");
|
||||
let mut region = region.enter_region(region_name.as_str())?;
|
||||
item.visit("ItemData", &mut region)?;
|
||||
}
|
||||
|
||||
@@ -497,8 +497,7 @@ pub trait SceneGraphNode: AbstractSceneNode + Clone + 'static {
|
||||
}
|
||||
}),
|
||||
Err(e) => Log::err(format!(
|
||||
"Failed to resolve parent path {}. Reason: {:?}",
|
||||
path, e
|
||||
"Failed to resolve parent path {path}. Reason: {e:?}"
|
||||
)),
|
||||
})
|
||||
});
|
||||
@@ -513,13 +512,12 @@ pub trait SceneGraphNode: AbstractSceneNode + Clone + 'static {
|
||||
if let Some(child_inheritable) = child_inheritable {
|
||||
need_revert = child_inheritable.is_modified();
|
||||
} else {
|
||||
Log::err(format!("Property {} is not inheritable!", path))
|
||||
Log::err(format!("Property {path} is not inheritable!"))
|
||||
}
|
||||
})
|
||||
}
|
||||
Err(e) => Log::err(format!(
|
||||
"Failed to resolve child path {}. Reason: {:?}",
|
||||
path, e
|
||||
"Failed to resolve child path {path}. Reason: {e:?}"
|
||||
)),
|
||||
});
|
||||
});
|
||||
@@ -541,8 +539,7 @@ pub trait SceneGraphNode: AbstractSceneNode + Clone + 'static {
|
||||
was_set = true;
|
||||
}
|
||||
Err(_) => Log::err(format!(
|
||||
"Failed to revert property {}. Reason: no such property!",
|
||||
path
|
||||
"Failed to revert property {path}. Reason: no such property!"
|
||||
)),
|
||||
},
|
||||
);
|
||||
@@ -1150,8 +1147,7 @@ pub trait SceneGraph: BaseSceneGraph {
|
||||
Log::writeln(
|
||||
MessageKind::Information,
|
||||
format!(
|
||||
"Integrity restored for {} instances! {} new nodes were added!",
|
||||
instance_count, restored_count
|
||||
"Integrity restored for {instance_count} instances! {restored_count} new nodes were added!"
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ impl From<NulError> for FrameworkError {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
impl From<glutin::error::Error> for FrameworkError {
|
||||
fn from(err: glutin::error::Error) -> Self {
|
||||
Self::Custom(format!("{:?}", err))
|
||||
Self::Custom(format!("{err:?}"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,6 +182,6 @@ impl From<String> for FrameworkError {
|
||||
|
||||
impl From<Box<dyn Error>> for FrameworkError {
|
||||
fn from(e: Box<dyn Error>) -> Self {
|
||||
Self::Custom(format!("{:?}", e))
|
||||
Self::Custom(format!("{e:?}"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ unsafe fn create_shader(
|
||||
if !status {
|
||||
Log::writeln(
|
||||
MessageKind::Error,
|
||||
format!("Failed to compile {} shader: {}", name, compilation_message),
|
||||
format!("Failed to compile {name} shader: {compilation_message}"),
|
||||
);
|
||||
Err(FrameworkError::ShaderCompilationFailed {
|
||||
shader_name: name,
|
||||
@@ -84,12 +84,9 @@ unsafe fn create_shader(
|
||||
let msg = if compilation_message.is_empty()
|
||||
|| compilation_message.chars().all(|c| c.is_whitespace())
|
||||
{
|
||||
format!("Shader {} compiled successfully!", name)
|
||||
format!("Shader {name} compiled successfully!")
|
||||
} else {
|
||||
format!(
|
||||
"Shader {} compiled successfully!\nAdditional info: {}",
|
||||
name, compilation_message
|
||||
)
|
||||
format!("Shader {name} compiled successfully!\nAdditional info: {compilation_message}")
|
||||
};
|
||||
|
||||
Log::writeln(MessageKind::Information, msg);
|
||||
@@ -310,14 +307,14 @@ impl GlProgram {
|
||||
unsafe {
|
||||
let vertex_shader = create_shader(
|
||||
server,
|
||||
format!("{}_VertexShader", name),
|
||||
format!("{name}_VertexShader"),
|
||||
glow::VERTEX_SHADER,
|
||||
vertex_source,
|
||||
server.gl_kind(),
|
||||
)?;
|
||||
let fragment_shader = create_shader(
|
||||
server,
|
||||
format!("{}_FragmentShader", name),
|
||||
format!("{name}_FragmentShader"),
|
||||
glow::FRAGMENT_SHADER,
|
||||
fragment_source,
|
||||
server.gl_kind(),
|
||||
@@ -334,22 +331,20 @@ impl GlProgram {
|
||||
if !status {
|
||||
Log::writeln(
|
||||
MessageKind::Error,
|
||||
format!("Failed to link {} shader: {}", name, link_message),
|
||||
format!("Failed to link {name} shader: {link_message}"),
|
||||
);
|
||||
Err(FrameworkError::ShaderLinkingFailed {
|
||||
shader_name: name.to_owned(),
|
||||
error_message: link_message,
|
||||
})
|
||||
} else {
|
||||
let msg =
|
||||
if link_message.is_empty() || link_message.chars().all(|c| c.is_whitespace()) {
|
||||
format!("Shader {} linked successfully!", name)
|
||||
} else {
|
||||
format!(
|
||||
"Shader {} linked successfully!\nAdditional info: {}",
|
||||
name, link_message
|
||||
)
|
||||
};
|
||||
let msg = if link_message.is_empty()
|
||||
|| link_message.chars().all(|c| c.is_whitespace())
|
||||
{
|
||||
format!("Shader {name} linked successfully!")
|
||||
} else {
|
||||
format!("Shader {name} linked successfully!\nAdditional info: {link_message}")
|
||||
};
|
||||
|
||||
Log::writeln(MessageKind::Information, msg);
|
||||
|
||||
|
||||
@@ -61,6 +61,6 @@ impl From<FrameworkError> for EngineError {
|
||||
|
||||
impl From<Box<dyn Error>> for EngineError {
|
||||
fn from(e: Box<dyn Error>) -> Self {
|
||||
Self::Custom(format!("{:?}", e))
|
||||
Self::Custom(format!("{e:?}"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ impl Executor {
|
||||
engine.resource_manager.state().set_watcher(Some(watcher));
|
||||
}
|
||||
Err(e) => {
|
||||
Log::err(format!("Unable to create resource watcher. Reason {:?}", e));
|
||||
Log::err(format!("Unable to create resource watcher. Reason {e:?}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -336,7 +336,7 @@ impl Executor {
|
||||
if let Err(e) = engine.set_frame_size(size.into()) {
|
||||
Log::writeln(
|
||||
MessageKind::Error,
|
||||
format!("Unable to set frame size: {:?}", e),
|
||||
format!("Unable to set frame size: {e:?}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2369,8 +2369,7 @@ impl Engine {
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
Log::info(format!(
|
||||
"Watching for changes in plugin {:?}...",
|
||||
source_lib_path
|
||||
"Watching for changes in plugin {source_lib_path:?}..."
|
||||
));
|
||||
|
||||
PluginContainer::Dynamic {
|
||||
@@ -2396,8 +2395,7 @@ impl Engine {
|
||||
self.plugins.push(plugin);
|
||||
|
||||
Log::info(format!(
|
||||
"Plugin {:?} was loaded successfully",
|
||||
source_lib_path
|
||||
"Plugin {source_lib_path:?} was loaded successfully"
|
||||
));
|
||||
|
||||
Ok(&**self.plugins.last().unwrap())
|
||||
@@ -2654,10 +2652,7 @@ impl Engine {
|
||||
task_pool: &mut self.task_pool,
|
||||
});
|
||||
|
||||
Log::info(format!(
|
||||
"Plugin {} was successfully reloaded!",
|
||||
plugin_index
|
||||
));
|
||||
Log::info(format!("Plugin {plugin_index} was successfully reloaded!"));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -575,7 +575,7 @@ impl Display for MaterialError {
|
||||
)
|
||||
}
|
||||
MaterialError::Visit(e) => {
|
||||
write!(f, "Failed to visit data source. Reason: {:?}", e)
|
||||
write!(f, "Failed to visit data source. Reason: {e:?}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -918,9 +918,8 @@ impl Material {
|
||||
);
|
||||
|
||||
Log::info(format!(
|
||||
"Added {} property to the material instance, since it exists in the \
|
||||
shader {}, but not in the material instance.",
|
||||
name, shader_kind
|
||||
"Added {name} property to the material instance, since it exists in the \
|
||||
shader {shader_kind}, but not in the material instance."
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -936,9 +935,8 @@ impl Material {
|
||||
self.properties.remove(&property_name);
|
||||
|
||||
Log::info(format!(
|
||||
"Removing {} property from the material instance, since it does \
|
||||
not exists in the shader {}.",
|
||||
property_name, shader_kind
|
||||
"Removing {property_name} property from the material instance, since it does \
|
||||
not exists in the shader {shader_kind}."
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -61,8 +61,7 @@ impl ShaderSet {
|
||||
}
|
||||
Err(e) => {
|
||||
return Err(FrameworkError::Custom(format!(
|
||||
"Failed to create {} shader' GPU program. Reason: {:?}",
|
||||
program_name, e
|
||||
"Failed to create {program_name} shader' GPU program. Reason: {e:?}"
|
||||
)));
|
||||
}
|
||||
};
|
||||
@@ -100,7 +99,7 @@ impl ShaderCache {
|
||||
) {
|
||||
Ok(shader_set) => Some(shader_set),
|
||||
Err(error) => {
|
||||
Log::err(format!("{}", error));
|
||||
Log::err(format!("{error}"));
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
+1
-4
@@ -112,10 +112,7 @@ impl TextureCache {
|
||||
) {
|
||||
Log::writeln(
|
||||
MessageKind::Error,
|
||||
format!(
|
||||
"Unable to upload new texture data to GPU. Reason: {:?}",
|
||||
e
|
||||
),
|
||||
format!("Unable to upload new texture data to GPU. Reason: {e:?}"),
|
||||
)
|
||||
} else {
|
||||
entry.modifications_counter = modifications_count;
|
||||
|
||||
@@ -1302,7 +1302,7 @@ impl Renderer {
|
||||
Err(e) => {
|
||||
Log::writeln(
|
||||
MessageKind::Error,
|
||||
format!("Failed to upload texture to GPU. Reason: {:?}", e),
|
||||
format!("Failed to upload texture to GPU. Reason: {e:?}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1397,8 +1397,7 @@ impl Renderer {
|
||||
let height = frame_size.y as usize;
|
||||
|
||||
Log::info(format!(
|
||||
"A new associated scene rendering data was created for scene {}!",
|
||||
scene_handle
|
||||
"A new associated scene rendering data was created for scene {scene_handle}!"
|
||||
));
|
||||
|
||||
AssociatedSceneData::new(server, width, height).unwrap()
|
||||
|
||||
@@ -33,13 +33,13 @@ pub enum FbxAttribute {
|
||||
impl std::fmt::Display for FbxAttribute {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), std::fmt::Error> {
|
||||
match self {
|
||||
FbxAttribute::Double(double) => write!(f, "{}", double),
|
||||
FbxAttribute::Float(float) => write!(f, "{}", float),
|
||||
FbxAttribute::Integer(integer) => write!(f, "{}", integer),
|
||||
FbxAttribute::Long(long) => write!(f, "{}", long),
|
||||
FbxAttribute::Bool(boolean) => write!(f, "{}", boolean),
|
||||
FbxAttribute::String(string) => write!(f, "{}", string),
|
||||
FbxAttribute::RawData(raw) => write!(f, "{:?}", raw),
|
||||
FbxAttribute::Double(double) => write!(f, "{double}"),
|
||||
FbxAttribute::Float(float) => write!(f, "{float}"),
|
||||
FbxAttribute::Integer(integer) => write!(f, "{integer}"),
|
||||
FbxAttribute::Long(long) => write!(f, "{long}"),
|
||||
FbxAttribute::Bool(boolean) => write!(f, "{boolean}"),
|
||||
FbxAttribute::String(string) => write!(f, "{string}"),
|
||||
FbxAttribute::RawData(raw) => write!(f, "{raw:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ impl FbxAttribute {
|
||||
FbxAttribute::Bool(val) => Ok(*val as i32),
|
||||
FbxAttribute::String(val) => match val.parse::<i32>() {
|
||||
Ok(i) => Ok(i),
|
||||
Err(_) => Err(format!("Unable to convert string {} to i32", val)),
|
||||
Err(_) => Err(format!("Unable to convert string {val} to i32")),
|
||||
},
|
||||
FbxAttribute::RawData(_) => Err("Unable to convert raw data to i32".to_string()),
|
||||
}
|
||||
@@ -69,7 +69,7 @@ impl FbxAttribute {
|
||||
FbxAttribute::Bool(val) => Ok(*val as i64),
|
||||
FbxAttribute::String(val) => match val.parse::<i64>() {
|
||||
Ok(i) => Ok(i),
|
||||
Err(_) => Err(format!("Unable to convert string {} to i64", val)),
|
||||
Err(_) => Err(format!("Unable to convert string {val} to i64")),
|
||||
},
|
||||
FbxAttribute::RawData(_) => Err("Unable to convert raw data to i64".to_string()),
|
||||
}
|
||||
@@ -84,7 +84,7 @@ impl FbxAttribute {
|
||||
FbxAttribute::Bool(val) => Ok((*val as i64) as f64),
|
||||
FbxAttribute::String(val) => match val.parse::<f64>() {
|
||||
Ok(i) => Ok(i),
|
||||
Err(_) => Err(format!("Unable to convert string {} to f64", val)),
|
||||
Err(_) => Err(format!("Unable to convert string {val} to f64")),
|
||||
},
|
||||
FbxAttribute::RawData(_) => Err("Unable to convert raw data to f64".to_string()),
|
||||
}
|
||||
@@ -99,7 +99,7 @@ impl FbxAttribute {
|
||||
FbxAttribute::Bool(val) => Ok((*val as i32) as f32),
|
||||
FbxAttribute::String(val) => match val.parse::<f32>() {
|
||||
Ok(i) => Ok(i),
|
||||
Err(_) => Err(format!("Unable to convert string {} to f32", val)),
|
||||
Err(_) => Err(format!("Unable to convert string {val} to f32")),
|
||||
},
|
||||
FbxAttribute::RawData(_) => Err("Unable to convert raw data to f32".to_string()),
|
||||
}
|
||||
|
||||
@@ -64,8 +64,7 @@ impl FbxNode {
|
||||
match self.attributes.get(n) {
|
||||
Some(attrib) => Ok(attrib),
|
||||
None => Err(format!(
|
||||
"Unable to get {} attribute because index out of bounds.",
|
||||
n
|
||||
"Unable to get {n} attribute because index out of bounds."
|
||||
)),
|
||||
}
|
||||
}
|
||||
@@ -106,7 +105,7 @@ impl FbxNodeContainer {
|
||||
}
|
||||
}
|
||||
|
||||
Err(format!("FBX DOM: Unable to find {} node", name))
|
||||
Err(format!("FBX DOM: Unable to find {name} node"))
|
||||
}
|
||||
|
||||
/// Searches node by specified name and borrows a reference to it
|
||||
@@ -123,7 +122,7 @@ impl FbxNodeContainer {
|
||||
}
|
||||
}
|
||||
|
||||
Err(format!("FBX DOM: Unable to find {} node", name))
|
||||
Err(format!("FBX DOM: Unable to find {name} node"))
|
||||
}
|
||||
|
||||
pub fn get(&self, handle: Handle<FbxNode>) -> &FbxNode {
|
||||
|
||||
@@ -322,10 +322,7 @@ async fn create_surfaces(
|
||||
{
|
||||
Log::writeln(
|
||||
MessageKind::Error,
|
||||
format!(
|
||||
"Failed to set diffuseColor property for material. Reason: {:?}",
|
||||
e,
|
||||
),
|
||||
format!("Failed to set diffuseColor property for material. Reason: {e:?}",),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -446,9 +443,8 @@ async fn create_surfaces(
|
||||
Log::writeln(
|
||||
MessageKind::Error,
|
||||
format!(
|
||||
"Unable to set material property {}\
|
||||
for FBX material! Reason: {:?}",
|
||||
property_name, e
|
||||
"Unable to set material property {property_name}\
|
||||
for FBX material! Reason: {e:?}"
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -457,8 +453,7 @@ async fn create_surfaces(
|
||||
Log::writeln(
|
||||
MessageKind::Warning,
|
||||
format!(
|
||||
"Unable to find a texture {:?} for 3D model {:?} using {:?} option!",
|
||||
filename, model_path, model_import_options
|
||||
"Unable to find a texture {filename:?} for 3D model {model_path:?} using {model_import_options:?} option!"
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -95,10 +95,7 @@ impl FbxLight {
|
||||
_ => {
|
||||
Log::writeln(
|
||||
MessageKind::Warning,
|
||||
format!(
|
||||
"FBX: Unknown light type {}, fallback to Point!",
|
||||
type_code
|
||||
),
|
||||
format!("FBX: Unknown light type {type_code}, fallback to Point!"),
|
||||
);
|
||||
FbxLightType::Point
|
||||
}
|
||||
|
||||
@@ -181,8 +181,7 @@ impl<'a> InstantiationContext<'a> {
|
||||
node.instance_id = *id;
|
||||
} else {
|
||||
Log::warn(format!(
|
||||
"No id specified for node {}! Random id will be used.",
|
||||
original_handle
|
||||
"No id specified for node {original_handle}! Random id will be used."
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -761,8 +760,7 @@ impl Model {
|
||||
// TODO: Add more formats.
|
||||
_ => {
|
||||
return Err(ModelLoadError::NotSupported(format!(
|
||||
"Unsupported model resource format: {}",
|
||||
extension
|
||||
"Unsupported model resource format: {extension}"
|
||||
)))
|
||||
}
|
||||
};
|
||||
|
||||
@@ -197,8 +197,7 @@ impl Visit for TextureKind {
|
||||
},
|
||||
_ => {
|
||||
return VisitResult::Err(VisitError::User(format!(
|
||||
"Invalid texture kind {}!",
|
||||
id
|
||||
"Invalid texture kind {id}!"
|
||||
)))
|
||||
}
|
||||
};
|
||||
@@ -974,7 +973,7 @@ impl TexturePixelKind {
|
||||
22 => Ok(Self::RGB16F),
|
||||
23 => Ok(Self::R32F),
|
||||
24 => Ok(Self::R16F),
|
||||
_ => Err(format!("Invalid texture kind {}!", id)),
|
||||
_ => Err(format!("Invalid texture kind {id}!")),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1046,8 +1046,7 @@ pub(crate) fn visit_opt_script(
|
||||
.try_create(&script_type_uuid)
|
||||
.ok_or_else(|| {
|
||||
VisitError::User(format!(
|
||||
"There is no corresponding script constructor for {} type!",
|
||||
script_type_uuid
|
||||
"There is no corresponding script constructor for {script_type_uuid} type!"
|
||||
))
|
||||
})?,
|
||||
)
|
||||
|
||||
@@ -725,8 +725,7 @@ impl Graph {
|
||||
Log::writeln(
|
||||
MessageKind::Error,
|
||||
format!(
|
||||
"Failed to apply light map texture to material. Reason {:?}",
|
||||
e
|
||||
"Failed to apply light map texture to material. Reason {e:?}"
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -789,8 +788,7 @@ impl Graph {
|
||||
Log::writeln(
|
||||
MessageKind::Error,
|
||||
format!(
|
||||
"Failed to apply light map texture to material. Reason {:?}",
|
||||
e
|
||||
"Failed to apply light map texture to material. Reason {e:?}"
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -340,8 +340,7 @@ impl SurfaceData {
|
||||
if v1 == v2 || v1 == v3 || v2 == v3 {
|
||||
Log::warn(format!(
|
||||
"Degenerated triangle found when calculating tangents. Lighting may be \
|
||||
incorrect! Triangle indices: {:?}. Triangle vertices: {v1} {v2} {v3}",
|
||||
triangle,
|
||||
incorrect! Triangle indices: {triangle:?}. Triangle vertices: {v1} {v2} {v3}",
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -356,16 +356,14 @@ impl SceneLoader {
|
||||
let used_resources_count = used_resources.len();
|
||||
|
||||
Log::info(format!(
|
||||
"SceneLoader::finish() - {} resources collected. Waiting them to load...",
|
||||
used_resources_count
|
||||
"SceneLoader::finish() - {used_resources_count} resources collected. Waiting them to load..."
|
||||
));
|
||||
|
||||
// Wait everything.
|
||||
join_all(used_resources.into_iter()).await;
|
||||
|
||||
Log::info(format!(
|
||||
"SceneLoader::finish() - All {} resources have finished loading.",
|
||||
used_resources_count
|
||||
"SceneLoader::finish() - All {used_resources_count} resources have finished loading."
|
||||
));
|
||||
|
||||
// TODO: Move into Camera::restore_resources?
|
||||
|
||||
@@ -69,8 +69,7 @@ fn read_node(name: &str, visitor: &mut Visitor) -> Result<Node, VisitError> {
|
||||
2 => Node::new(DirectionalLight::default()),
|
||||
_ => {
|
||||
return Err(VisitError::User(format!(
|
||||
"Invalid legacy light kind {}",
|
||||
light_id
|
||||
"Invalid legacy light kind {light_id}"
|
||||
)))
|
||||
}
|
||||
};
|
||||
@@ -96,8 +95,7 @@ fn read_node(name: &str, visitor: &mut Visitor) -> Result<Node, VisitError> {
|
||||
16 => Node::new(Listener::default()),
|
||||
_ => {
|
||||
return Err(VisitError::User(format!(
|
||||
"Invalid legacy node kind {}",
|
||||
kind_id
|
||||
"Invalid legacy node kind {kind_id}"
|
||||
)))
|
||||
}
|
||||
};
|
||||
@@ -120,7 +118,7 @@ fn read_node(name: &str, visitor: &mut Visitor) -> Result<Node, VisitError> {
|
||||
let mut node = serialization_context
|
||||
.node_constructors
|
||||
.try_create(&id)
|
||||
.ok_or_else(|| VisitError::User(format!("Unknown node type uuid {}!", id)))?;
|
||||
.ok_or_else(|| VisitError::User(format!("Unknown node type uuid {id}!")))?;
|
||||
|
||||
node.visit("NodeData", &mut region)?;
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ impl Emitter {
|
||||
1 => Ok(Self::Cuboid(Default::default())),
|
||||
2 => Ok(Self::Sphere(Default::default())),
|
||||
3 => Ok(Self::Cylinder(Default::default())),
|
||||
_ => Err(format!("Invalid emitter id {}!", id)),
|
||||
_ => Err(format!("Invalid emitter id {id}!")),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,10 +152,7 @@ impl SoundContext {
|
||||
if state.is_valid_handle(sound) {
|
||||
state.remove_source(sound);
|
||||
|
||||
Log::info(format!(
|
||||
"Native sound source was removed for node: {}",
|
||||
name
|
||||
));
|
||||
Log::info(format!("Native sound source was removed for node: {name}"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ impl NodeTrait for Sound {
|
||||
None => Err("Sound buffer is failed to load, the reason is unknown!"
|
||||
.to_string()),
|
||||
Some(err) => {
|
||||
Err(format!("Sound buffer is failed to load. Reason: {:?}", err))
|
||||
Err(format!("Sound buffer is failed to load. Reason: {err:?}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -148,7 +148,7 @@ mod tests {
|
||||
let ElementRange::Specific { count, .. } = q else {
|
||||
panic!("Quadrant is full.")
|
||||
};
|
||||
assert_eq!(count, 2, "Quadrant: {}", i);
|
||||
assert_eq!(count, 2, "Quadrant: {i}");
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
@@ -159,7 +159,7 @@ mod tests {
|
||||
let ElementRange::Specific { count, .. } = q else {
|
||||
panic!("Quadrant is full.")
|
||||
};
|
||||
assert_eq!(count, c, "Quadrant: {}", i);
|
||||
assert_eq!(count, c, "Quadrant: {i}");
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
@@ -169,7 +169,7 @@ mod tests {
|
||||
let ElementRange::Specific { count, .. } = q else {
|
||||
panic!("Quadrant is full.")
|
||||
};
|
||||
assert_eq!(count, 8, "Quadrant: {}", i);
|
||||
assert_eq!(count, 8, "Quadrant: {i}");
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
|
||||
@@ -1266,7 +1266,7 @@ impl Visit for Terrain {
|
||||
if region.is_reading() {
|
||||
self.geometry = TerrainGeometry::new(*self.block_size);
|
||||
if version < 2 {
|
||||
Log::info(format!("Updating terrain to version: {}", VERSION));
|
||||
Log::info(format!("Updating terrain to version: {VERSION}"));
|
||||
*self.height_map_size = self.height_map_size.map(|x| x + 2);
|
||||
for c in self.chunks.iter() {
|
||||
if c.height_map_size() != self.height_map_size() {
|
||||
|
||||
@@ -756,7 +756,7 @@ mod test {
|
||||
|
||||
println!();
|
||||
for size in [10, 40, 100, 500] {
|
||||
println!("benchmarking grid size of: {}^2", size);
|
||||
println!("benchmarking grid size of: {size}^2");
|
||||
let setup_start_time = Instant::now();
|
||||
|
||||
let mut pathfinder = Graph::new();
|
||||
|
||||
@@ -760,7 +760,7 @@ mod test {
|
||||
for entry_set in lightmap.map.values() {
|
||||
for entry in entry_set {
|
||||
let mut data = entry.texture.as_ref().unwrap().data_ref();
|
||||
data.save(Path::new(&format!("{}.png", counter))).unwrap();
|
||||
data.save(Path::new(&format!("{counter}.png"))).unwrap();
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,21 +96,21 @@ impl From<lewton::VorbisError> for SoundError {
|
||||
impl Display for SoundError {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
|
||||
match self {
|
||||
SoundError::Io(io) => write!(f, "io error: {}", io),
|
||||
SoundError::Io(io) => write!(f, "io error: {io}"),
|
||||
SoundError::NoBackend => write!(f, "no backend implemented for current platform"),
|
||||
SoundError::FailedToInitializeDevice(reason) => {
|
||||
write!(f, "failed to initialize device. reason: {}", reason)
|
||||
write!(f, "failed to initialize device. reason: {reason}")
|
||||
}
|
||||
SoundError::InvalidHeader => write!(f, "invalid header of sound file"),
|
||||
SoundError::UnsupportedFormat => write!(f, "unsupported format of sound file"),
|
||||
SoundError::PoisonedMutex => write!(f, "attempt to use poisoned mutex"),
|
||||
SoundError::MathError(reason) => {
|
||||
write!(f, "math error has occurred. reason: {}", reason)
|
||||
write!(f, "math error has occurred. reason: {reason}")
|
||||
}
|
||||
SoundError::StreamingBufferAlreadyInUse => {
|
||||
write!(f, "streaming buffer in already in use")
|
||||
}
|
||||
SoundError::DecoderError(de) => write!(f, "internal decoder error: {:?}", de),
|
||||
SoundError::DecoderError(de) => write!(f, "internal decoder error: {de:?}"),
|
||||
SoundError::BufferFailedToLoad => write!(f, "a buffer failed to load"),
|
||||
SoundError::BufferIsNotLoaded => write!(f, "a buffer is not loaded yet"),
|
||||
}
|
||||
|
||||
@@ -1394,7 +1394,7 @@ impl CurveEditor {
|
||||
|
||||
if self.show_y_values {
|
||||
for y in self.curve_transform.y_step_iter(self.grid_size.y) {
|
||||
text.set_text(format!("{:.1}", y)).build();
|
||||
text.set_text(format!("{y:.1}")).build();
|
||||
ctx.draw_text(
|
||||
self.clip_bounds(),
|
||||
self.point_to_screen_space(Vector2::new(local_left_bottom_n.x, y)),
|
||||
@@ -1405,7 +1405,7 @@ impl CurveEditor {
|
||||
|
||||
if self.show_x_values {
|
||||
for x in self.curve_transform.x_step_iter(self.grid_size.x) {
|
||||
text.set_text(format!("{:.1}", x)).build();
|
||||
text.set_text(format!("{x:.1}")).build();
|
||||
ctx.draw_text(
|
||||
self.clip_bounds(),
|
||||
self.point_to_screen_space(Vector2::new(x, local_left_bottom_n.y)),
|
||||
|
||||
@@ -338,7 +338,7 @@ impl PropertyChanged {
|
||||
FieldKind::Inspectable(inspectable) => {
|
||||
path += format!("[{}].{}", index, inspectable.path()).as_ref();
|
||||
}
|
||||
_ => path += format!("[{}]", index).as_ref(),
|
||||
_ => path += format!("[{index}]").as_ref(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -651,7 +651,7 @@ fn make_expander_check_box(
|
||||
let description = if property_description.is_empty() {
|
||||
property_name.to_string()
|
||||
} else {
|
||||
format!("{}\n\n{}", property_name, property_description)
|
||||
format!("{property_name}\n\n{property_description}")
|
||||
};
|
||||
|
||||
let handle = CheckBoxBuilder::new(
|
||||
@@ -826,7 +826,7 @@ impl InspectorContext {
|
||||
object.fields(&mut |fields| {
|
||||
for field in fields {
|
||||
fields_text.push(if generate_property_string_values {
|
||||
format!("{:?}", field)
|
||||
format!("{field:?}")
|
||||
} else {
|
||||
Default::default()
|
||||
})
|
||||
@@ -903,8 +903,7 @@ impl InspectorContext {
|
||||
.with_vertical_text_alignment(VerticalAlignment::Center)
|
||||
.with_text(format!(
|
||||
"Unable to create property \
|
||||
editor instance: Reason {:?}",
|
||||
e
|
||||
editor instance: Reason {e:?}"
|
||||
))
|
||||
.build(ctx),
|
||||
&description,
|
||||
|
||||
+3
-4
@@ -512,7 +512,7 @@ impl NodeStatistics {
|
||||
let prev_count = prev_stats.count_of(type_name);
|
||||
let delta = count - prev_count;
|
||||
if delta != 0 || show_unchanged {
|
||||
println!("{}: \x1b[93m{}\x1b[0m", type_name, delta);
|
||||
println!("{type_name}: \x1b[93m{delta}\x1b[0m");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -523,7 +523,7 @@ impl NodeStatistics {
|
||||
let count = self.count_of(type_name);
|
||||
let prev_count = prev_stats.count_of(type_name);
|
||||
if count - prev_count != 0 {
|
||||
println!("{}: \x1b[93m{}\x1b[0m", type_name, count);
|
||||
println!("{type_name}: \x1b[93m{count}\x1b[0m");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3015,8 +3015,7 @@ impl UserInterface {
|
||||
let used_resources_count = used_resources.len();
|
||||
|
||||
Log::info(format!(
|
||||
"UserInterface - {} resources collected. Waiting them to load...",
|
||||
used_resources_count
|
||||
"UserInterface - {used_resources_count} resources collected. Waiting them to load..."
|
||||
));
|
||||
|
||||
// Wait everything.
|
||||
|
||||
@@ -50,7 +50,7 @@ fn read_widget(name: &str, visitor: &mut Visitor) -> Result<UiNode, VisitError>
|
||||
|
||||
let mut widget = serialization_context
|
||||
.try_create(&id)
|
||||
.ok_or_else(|| panic!("Unknown widget type uuid {}!", id))
|
||||
.ok_or_else(|| panic!("Unknown widget type uuid {id}!"))
|
||||
.unwrap();
|
||||
|
||||
widget.visit("WidgetData", &mut region)?;
|
||||
|
||||
@@ -150,7 +150,7 @@ fn main() {
|
||||
if let Err(e) = engine.set_frame_size(size.into()) {
|
||||
Log::writeln(
|
||||
MessageKind::Error,
|
||||
format!("Unable to set frame size: {:?}", e),
|
||||
format!("Unable to set frame size: {e:?}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -452,7 +452,7 @@ impl ProjectManager {
|
||||
|
||||
self.build_window = Some(build_window);
|
||||
}
|
||||
Err(e) => Log::err(format!("Failed to start the editor: {:?}", e)),
|
||||
Err(e) => Log::err(format!("Failed to start the editor: {e:?}")),
|
||||
}
|
||||
} else if button == self.run {
|
||||
let mut new_process = std::process::Command::new("cargo");
|
||||
@@ -469,7 +469,7 @@ impl ProjectManager {
|
||||
|
||||
self.build_window = Some(build_window);
|
||||
}
|
||||
Err(e) => Log::err(format!("Failed to start the game: {:?}", e)),
|
||||
Err(e) => Log::err(format!("Failed to start the game: {e:?}")),
|
||||
}
|
||||
} else if button == self.delete {
|
||||
if let Some(dir) = project.manifest_path.parent() {
|
||||
|
||||
@@ -75,8 +75,7 @@ impl Display for NameErrors {
|
||||
match self {
|
||||
Self::CargoReserved(name) => write!(
|
||||
f,
|
||||
"The project name cannot be `{}` due to cargo's reserved keywords",
|
||||
name
|
||||
"The project name cannot be `{name}` due to cargo's reserved keywords"
|
||||
),
|
||||
Self::Hyphen => write!(f, "The project name cannot contain `-`"),
|
||||
Self::StartsWithNumber => write!(f, "The project name cannot start with a number"),
|
||||
@@ -528,8 +527,7 @@ crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
fyrox = {{ workspace = true }}
|
||||
{} = {{ path = "../game" }}"#,
|
||||
name,
|
||||
{name} = {{ path = "../game" }}"#,
|
||||
),
|
||||
)?;
|
||||
|
||||
@@ -636,7 +634,7 @@ fn init_data(base_path: &Path, style: &str) -> Result<(), String> {
|
||||
match style {
|
||||
"2d" => write_file_binary(scene_path, include_bytes!("2d.rgs")),
|
||||
"3d" => write_file_binary(scene_path, include_bytes!("3d.rgs")),
|
||||
_ => Err(format!("Unknown style: {}. Use either `2d` or `3d`", style)),
|
||||
_ => Err(format!("Unknown style: {style}. Use either `2d` or `3d`")),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -652,7 +650,7 @@ pub fn init_script(root_path: &Path, raw_name: &str) -> Result<(), String> {
|
||||
let file_name = base_path.join(script_file_stem.clone() + ".rs");
|
||||
|
||||
if file_name.exists() {
|
||||
return Err(format!("Script {} already exists!", script_name));
|
||||
return Err(format!("Script {script_name} already exists!"));
|
||||
}
|
||||
|
||||
let script_uuid = Uuid::new_v4().to_string();
|
||||
@@ -667,13 +665,13 @@ use fyrox::{{
|
||||
}};
|
||||
|
||||
#[derive(Visit, Reflect, Default, Debug, Clone, TypeUuidProvider, ComponentProvider)]
|
||||
#[type_uuid(id = "{id}")]
|
||||
#[type_uuid(id = "{script_uuid}")]
|
||||
#[visit(optional)]
|
||||
pub struct {name} {{
|
||||
pub struct {script_name} {{
|
||||
// Add fields here.
|
||||
}}
|
||||
|
||||
impl ScriptTrait for {name} {{
|
||||
impl ScriptTrait for {script_name} {{
|
||||
fn on_init(&mut self, context: &mut ScriptContext) {{
|
||||
// Put initialization logic here.
|
||||
}}
|
||||
@@ -695,9 +693,7 @@ impl ScriptTrait for {name} {{
|
||||
// Put object logic here.
|
||||
}}
|
||||
}}
|
||||
"#,
|
||||
name = script_name,
|
||||
id = script_uuid
|
||||
"#
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -713,7 +709,7 @@ pub fn init_project(
|
||||
let name = match name {
|
||||
Ok(s) => s,
|
||||
Err(name_error) => {
|
||||
println!("{}", name_error);
|
||||
println!("{name_error}");
|
||||
return Err(name_error.to_string());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -79,11 +79,8 @@ fn main() {
|
||||
fyrox_template_core::init_project(Path::new("./"), &name, &style, &vcs, overwrite)
|
||||
.unwrap();
|
||||
|
||||
println!("Project {} was generated successfully!", name);
|
||||
println!(
|
||||
"Navigate to {} directory and use one of the following commands:",
|
||||
name
|
||||
);
|
||||
println!("Project {name} was generated successfully!");
|
||||
println!("Navigate to {name} directory and use one of the following commands:");
|
||||
println!("\tRun the Editor: cargo run --package editor --release");
|
||||
println!("\tRun the Executor: cargo run --package executor --release");
|
||||
println!(
|
||||
@@ -103,7 +100,7 @@ fn main() {
|
||||
Commands::Upgrade { version, local } => {
|
||||
fyrox_template_core::upgrade_project(Path::new("./"), &version, local).unwrap();
|
||||
|
||||
println!("Fyrox version was successfully set to '{}'!", version);
|
||||
println!("Fyrox version was successfully set to '{version}'!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user