From 07871b77f3d998efed9ce8cee5a2d7eb59469e7c Mon Sep 17 00:00:00 2001 From: Chance Date: Mon, 7 Apr 2025 23:06:48 -0400 Subject: [PATCH] chore: run clippy and cargo fmt on pending changes --- Cargo.lock | 7 ++----- engine/Cargo.toml | 3 +-- engine/build.rs | 5 ++--- engine/src/core/panic.rs | 3 --- engine/src/core/render/ctx.rs | 4 ++-- engine/src/core/render/mod.rs | 9 +++++---- engine/src/core/repl/input.rs | 23 +++++++++++++++++++++-- engine/src/metadata.rs | 4 +--- 8 files changed, 34 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1fd1b8..bc921db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -423,9 +423,7 @@ checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" dependencies = [ "android-tzdata", "iana-time-zone", - "js-sys", "num-traits", - "wasm-bindgen", "windows-link", ] @@ -2944,9 +2942,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.44.1" +version = "1.44.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a" +checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" dependencies = [ "backtrace", "bytes", @@ -4151,7 +4149,6 @@ dependencies = [ "bytemuck", "cargo-lock", "cgmath", - "chrono", "colored", "futures", "image", diff --git a/engine/Cargo.toml b/engine/Cargo.toml index b9d580d..1c1230c 100644 --- a/engine/Cargo.toml +++ b/engine/Cargo.toml @@ -8,14 +8,13 @@ repository = "https://github.com/Zenyx-Engine/Zenyx" # TBR (if possible) backtrace = "0.3.74" # TBR (if possible) -chrono = "0.4.39" colored = "3.0.0" parking_lot.workspace = true # TBR (if possible) rustyline = { version = "15.0.0", features = ["derive", "rustyline-derive"] } thiserror = "2.0.11" # Tokio is heavy but so far its the best option, we should make better use of it or switch to another runtime. -tokio = { version = "1.44.1", features = ["macros", "parking_lot", "rt-multi-thread"] } +tokio = { version = "1.44.2", features = ["macros", "parking_lot", "rt-multi-thread"] } wgpu = "24.0.3" winit = "0.30.9" bytemuck = "1.21.0" diff --git a/engine/build.rs b/engine/build.rs index 67187ba..ff9e5b4 100644 --- a/engine/build.rs +++ b/engine/build.rs @@ -85,8 +85,7 @@ fn main() { writeln!( built_rs, "{}pub static GIT_COMMIT_HASH: &str = \"{}\";", - ALLOW_DEAD_CODE, - git_info + ALLOW_DEAD_CODE, git_info ) .unwrap(); @@ -117,4 +116,4 @@ fn main() { std::println!("cargo:rerun-if-changed=Cargo.lock"); std::println!("cargo:rerun-if-changed=.git/HEAD"); std::println!("cargo:rerun-if-changed=.git/index"); -} \ No newline at end of file +} diff --git a/engine/src/core/panic.rs b/engine/src/core/panic.rs index 53e85f1..3c5abb6 100644 --- a/engine/src/core/panic.rs +++ b/engine/src/core/panic.rs @@ -1,9 +1,6 @@ -use std::fmt::Write as FmtWrite; -use std::mem; use std::str::FromStr; use std::{error::Error, path::PathBuf}; -use backtrace::Backtrace; use native_dialog::{MessageDialog, MessageType}; use parking_lot::Once; use tracing::error; diff --git a/engine/src/core/render/ctx.rs b/engine/src/core/render/ctx.rs index 664c01f..cee048c 100644 --- a/engine/src/core/render/ctx.rs +++ b/engine/src/core/render/ctx.rs @@ -5,7 +5,7 @@ use std::time::Instant; use cgmath::{Deg, Matrix4, Point3, Rad, SquareMatrix, Vector3, perspective}; use futures::executor::block_on; -use tracing::{debug, error, info, trace}; +use tracing::{debug, error, trace}; use wgpu::TextureUsages; use wgpu::{Backends, InstanceDescriptor, util::DeviceExt}; use wgpu_text::glyph_brush::ab_glyph::FontRef; @@ -586,7 +586,7 @@ impl<'window> Renderer<'window> { self.frame_count += 1; let elapsed_secs = self.last_frame_instant.elapsed().as_secs_f32(); - if (elapsed_secs >= 1.0) { + if elapsed_secs >= 1.0 { let fps = self.frame_count as f32 / elapsed_secs; // trace!("Renderer FPS: {:.2}", fps); self.fps = fps; diff --git a/engine/src/core/render/mod.rs b/engine/src/core/render/mod.rs index e4ead8d..56538ad 100644 --- a/engine/src/core/render/mod.rs +++ b/engine/src/core/render/mod.rs @@ -16,6 +16,7 @@ use winit::dpi::LogicalSize; use winit::dpi::Size; use winit::event::{KeyEvent, WindowEvent}; use winit::event_loop::{ActiveEventLoop, ControlFlow, EventLoop}; +#[cfg(target_os = "windows")] use winit::platform::windows::WindowAttributesExtWindows; use winit::window::Fullscreen; use winit::window::Icon; @@ -101,8 +102,8 @@ impl App<'_> { let win_attr = Window::default_attributes() .with_title("Zenyx") .with_min_inner_size(Size::Logical(LogicalSize::new(100.0, 100.0))) - .with_window_icon(icon.clone()) - .with_taskbar_icon(icon); + .with_window_icon(icon.clone()); + // .with_taskbar_icon(icon); match event_loop.create_window(win_attr) { Ok(window) => { @@ -268,8 +269,8 @@ impl App<'_> { let base = Window::default_attributes() .with_title(title) .with_min_inner_size(Size::Logical(LogicalSize::new(100.0, 100.0))) - .with_window_icon(icon.clone()) - .with_taskbar_icon(icon); + .with_window_icon(icon.clone()); + // .with_taskbar_icon(icon); match main_ctx.window_handle() { Ok(handle) => { diff --git a/engine/src/core/repl/input.rs b/engine/src/core/repl/input.rs index d146ecd..627ad88 100644 --- a/engine/src/core/repl/input.rs +++ b/engine/src/core/repl/input.rs @@ -1,9 +1,9 @@ use std::{ borrow::Cow::{self, Borrowed, Owned}, sync::Arc, + time::{SystemTime, UNIX_EPOCH}, }; -use chrono::Local; use colored::Colorize; use parking_lot::Mutex; use rustyline::{ @@ -11,6 +11,7 @@ use rustyline::{ Hinter, KeyEvent, RepeatCount, Validator, completion::Completer, error::ReadlineError, highlight::Highlighter, hint::HistoryHinter, history::DefaultHistory, }; +#[allow(unused_imports)] use tracing::{debug, error, info, warn}; use super::handler::COMMAND_MANAGER; @@ -178,6 +179,24 @@ pub fn evaluate_command(input: &str) -> Result<()> { Ok(()) } +fn format_time() -> String { + let now = SystemTime::now(); + let duration = now.duration_since(UNIX_EPOCH).unwrap(); + let total_seconds = duration.as_secs(); + let nanos = duration.subsec_nanos(); + let milliseconds = nanos / 1_000_000; + + let seconds_since_midnight_utc = total_seconds % (24 * 3600); + let hour = (seconds_since_midnight_utc / 3600) % 24; + let minute = (seconds_since_midnight_utc / 60) % 60; + let second = seconds_since_midnight_utc % 60; + + format!( + "{:02}:{:02}:{:02}.{:03}", + hour, minute, second, milliseconds + ) +} + pub async fn handle_repl() -> Result<()> { let mut rl = Editor::::new()?; rl.set_helper(Some(MyHelper { @@ -197,7 +216,7 @@ pub async fn handle_repl() -> Result<()> { } loop { - let time = Local::now().format("%H:%M:%S.%3f").to_string(); + let time = format_time(); let prompt = format!("[{}/{}] {}", time, "SHELL", ">>\t"); let sig = rl.readline(&prompt.bright_white()); diff --git a/engine/src/metadata.rs b/engine/src/metadata.rs index c8eee50..a44b862 100644 --- a/engine/src/metadata.rs +++ b/engine/src/metadata.rs @@ -195,10 +195,8 @@ impl CPU { ); sys.refresh_cpu_all(); - let cpu_opt = sys.cpus().first(); - let brand = cpu_opt .map(|cpu| cpu.brand().into()) .unwrap_or(CPUBrand::Other("unknown".into())); @@ -491,7 +489,7 @@ impl EngineInfo { rustc_version: build_info::RUSTC_VERSION.to_string(), wgpu_version: build_info::WGPU_VERSION.to_string(), winit_version: build_info::WGPU_VERSION.to_string(), - commit_hash: build_info::GIT_COMMIT_HASH.to_string() + commit_hash: build_info::GIT_COMMIT_HASH.to_string(), } }