From 1821a17eb6b661d83c7bcb19b473d6e954fe6de3 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Wed, 15 Feb 2023 23:55:33 +0100 Subject: [PATCH] Update project Unity version on start --- rusty_hub_egui/Cargo.lock | 102 ++++++++++++++++++----------- rusty_hub_egui/Cargo.toml | 2 +- rusty_hub_egui/src/hub_client.rs | 26 ++++++-- unity_hub_lib/Cargo.lock | 24 +++---- unity_hub_lib/src/unity_project.rs | 30 ++++++--- 5 files changed, 115 insertions(+), 69 deletions(-) diff --git a/rusty_hub_egui/Cargo.lock b/rusty_hub_egui/Cargo.lock index af0b293..0174861 100644 --- a/rusty_hub_egui/Cargo.lock +++ b/rusty_hub_egui/Cargo.lock @@ -26,9 +26,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57e6e951cfbb2db8de1828d49073a113a29fd7117b1596caa781a258c7e38d72" +checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107" dependencies = [ "cfg-if 1.0.0", "getrandom", @@ -76,9 +76,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "atk-sys" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58aeb089fb698e06db8089971c7ee317ab9644bade33383f63631437b03aafb6" +checksum = "11ad703eb64dc058024f0e57ccfa069e15a413b98dbd50a1a950e743b7f11148" dependencies = [ "glib-sys", "gobject-sys", @@ -159,9 +159,9 @@ checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" [[package]] name = "cairo-sys-rs" -version = "0.15.1" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8" +checksum = "7c48f4af05fabdcfa9658178e1326efa061853f040ce7d72e33af6885196f421" dependencies = [ "libc", "system-deps", @@ -820,9 +820,9 @@ dependencies = [ [[package]] name = "gdk-pixbuf-sys" -version = "0.15.10" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "140b2f5378256527150350a8346dbdb08fadc13453a7a2d73aecd5fab3c402a7" +checksum = "3092cf797a5f1210479ea38070d9ae8a5b8e9f8f1be9f32f4643c529c7d70016" dependencies = [ "gio-sys", "glib-sys", @@ -833,9 +833,9 @@ dependencies = [ [[package]] name = "gdk-sys" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e7a08c1e8f06f4177fb7e51a777b8c1689f743a7bc11ea91d44d2226073a88" +checksum = "d76354f97a913e55b984759a997b693aa7dc71068c9e98bcce51aa167a0a5c5a" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -883,9 +883,9 @@ dependencies = [ [[package]] name = "gio-sys" -version = "0.15.10" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32157a475271e2c4a023382e9cab31c4584ee30a97da41d3c4e9fdd605abcf8d" +checksum = "e9b693b8e39d042a95547fc258a7b07349b1f0b48f4b2fa3108ba3c51c0b5229" dependencies = [ "glib-sys", "gobject-sys", @@ -907,9 +907,9 @@ dependencies = [ [[package]] name = "glib-sys" -version = "0.15.10" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef4b192f8e65e9cf76cbf4ea71fa8e3be4a0e18ffe3d68b8da6836974cc5bad4" +checksum = "c61a4f46316d06bfa33a7ac22df6f0524c8be58e3db2d9ca99ccb1f357b62a65" dependencies = [ "libc", "system-deps", @@ -994,9 +994,9 @@ dependencies = [ [[package]] name = "gobject-sys" -version = "0.15.10" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a" +checksum = "3520bb9c07ae2a12c7f2fbb24d4efc11231c8146a86956413fb1a79bb760a0f1" dependencies = [ "glib-sys", "libc", @@ -1005,9 +1005,9 @@ dependencies = [ [[package]] name = "gtk-sys" -version = "0.15.3" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5bc2f0587cba247f60246a0ca11fe25fb733eabc3de12d1965fc07efab87c84" +checksum = "89b5f8946685d5fe44497007786600c2f368ff6b1e61a16251c89f72a97520a3" dependencies = [ "atk-sys", "cairo-sys-rs", @@ -1502,9 +1502,9 @@ dependencies = [ [[package]] name = "pango-sys" -version = "0.15.10" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2a00081cde4661982ed91d80ef437c20eacaf6aa1a5962c0279ae194662c3aa" +checksum = "9e134909a9a293e04d2cc31928aa95679c5e4df954d0b85483159bd20d8f047f" dependencies = [ "glib-sys", "gobject-sys", @@ -1678,9 +1678,9 @@ dependencies = [ [[package]] name = "rfd" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0149778bd99b6959285b0933288206090c50e2327f47a9c463bfdbf45c8823ea" +checksum = "1fe3bae427b011620cf4436d5dd7405c1a86dce3dfcdc0cda12b41fd31569ac3" dependencies = [ "block", "dispatch", @@ -1688,7 +1688,6 @@ dependencies = [ "gobject-sys", "gtk-sys", "js-sys", - "lazy_static", "log", "objc", "objc-foundation", @@ -2339,15 +2338,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.37.0" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647" +checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b" dependencies = [ - "windows_aarch64_msvc 0.37.0", - "windows_i686_gnu 0.37.0", - "windows_i686_msvc 0.37.0", - "windows_x86_64_gnu 0.37.0", - "windows_x86_64_msvc 0.37.0", + "windows-targets", ] [[package]] @@ -2363,6 +2358,27 @@ dependencies = [ "windows_x86_64_msvc 0.36.1", ] +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + [[package]] name = "windows_aarch64_msvc" version = "0.36.1" @@ -2371,9 +2387,9 @@ checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] name = "windows_aarch64_msvc" -version = "0.37.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" [[package]] name = "windows_i686_gnu" @@ -2383,9 +2399,9 @@ checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] name = "windows_i686_gnu" -version = "0.37.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" [[package]] name = "windows_i686_msvc" @@ -2395,9 +2411,9 @@ checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] name = "windows_i686_msvc" -version = "0.37.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" [[package]] name = "windows_x86_64_gnu" @@ -2407,9 +2423,15 @@ checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] name = "windows_x86_64_gnu" -version = "0.37.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" [[package]] name = "windows_x86_64_msvc" @@ -2419,9 +2441,9 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] name = "windows_x86_64_msvc" -version = "0.37.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" [[package]] name = "winit" diff --git a/rusty_hub_egui/Cargo.toml b/rusty_hub_egui/Cargo.toml index 5900c8c..884cbb2 100644 --- a/rusty_hub_egui/Cargo.toml +++ b/rusty_hub_egui/Cargo.toml @@ -21,7 +21,7 @@ eframe = "0.19.0" egui_extras = "0.19.0" unity_hub_lib = { path="../unity_hub_lib" } image = { version = "0.24.0", default-features = false, features = ["png"] } -rfd = "0.10.0" +rfd = "0.11.1" [target.'cfg(windows)'.build-dependencies] winres = "0.1" \ No newline at end of file diff --git a/rusty_hub_egui/src/hub_client.rs b/rusty_hub_egui/src/hub_client.rs index fae855d..b373853 100644 --- a/rusty_hub_egui/src/hub_client.rs +++ b/rusty_hub_egui/src/hub_client.rs @@ -74,7 +74,7 @@ impl HubClient { row.col(|ui| { ui.vertical_centered_justified(|ui| { ui.add_space(VERTICAL_SPACING - 2.0); - if ui.button("Remove").clicked() { + if ui.button("🚮 Remove").clicked() { self.hub.config.unity_search_paths.remove(row_index); self.save_config(true); return; @@ -130,7 +130,21 @@ impl HubClient { Layout::top_down_justified(eframe::emath::Align::Max), |ui| { ui.add_space(VERTICAL_SPACING); - ui.label(&editor.base_path); + let version_response = ui.add( + egui::Label::new(&editor.base_path).sense(egui::Sense::click()), + ); + version_response.context_menu(|ui| { + let text = + egui::RichText::new("🗁 Open directory"); + if ui.button(text).clicked() { + use std::process::Command; + Command::new(FILE_MANAGER) + .arg(&editor.base_path) + .spawn() + .unwrap(); + ui.close_menu(); + } + }); }, ); }); @@ -254,7 +268,7 @@ impl HubClient { let label = ui.label(egui::RichText::new(short).small()); if is_long { - label.on_hover_text(&project.branch); + label.on_hover_text(format!(" {}", &project.branch)); } }, ); @@ -268,7 +282,7 @@ impl HubClient { egui::Label::new(&project.path).sense(egui::Sense::click()), ); path_response.context_menu(|ui| { - if ui.button("Open directory").clicked() { + if ui.button("🗁 Open directory").clicked() { use std::process::Command; Command::new(FILE_MANAGER) .arg(&project.path) @@ -297,7 +311,7 @@ impl HubClient { ui.vertical_centered_justified(|ui| { ui.add_space(VERTICAL_SPACING); if ui - .button("Add new path") + .button("🖴 Add new path") .on_hover_text("Add new editor search path") .clicked() { @@ -329,7 +343,7 @@ impl HubClient { ui.vertical_centered_justified(|ui| { ui.add_space(VERTICAL_SPACING); if ui - .button("Scan") + .button("🔭 Scan") .on_hover_text("Scan selected folder for projects") .clicked() { diff --git a/unity_hub_lib/Cargo.lock b/unity_hub_lib/Cargo.lock index c2551c8..c426ca4 100644 --- a/unity_hub_lib/Cargo.lock +++ b/unity_hub_lib/Cargo.lock @@ -370,18 +370,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rusty_hub_lib" -version = "0.2.0" -dependencies = [ - "dpc-pariter", - "exe", - "registry", - "serde", - "serde_derive", - "walkdir", -] - [[package]] name = "same-file" version = "1.0.6" @@ -494,6 +482,18 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" +[[package]] +name = "unity_hub_lib" +version = "0.2.0" +dependencies = [ + "dpc-pariter", + "exe", + "registry", + "serde", + "serde_derive", + "walkdir", +] + [[package]] name = "utfx" version = "0.1.0" diff --git a/unity_hub_lib/src/unity_project.rs b/unity_hub_lib/src/unity_project.rs index a8267ac..ecd1ccc 100644 --- a/unity_hub_lib/src/unity_project.rs +++ b/unity_hub_lib/src/unity_project.rs @@ -62,6 +62,23 @@ impl UnityProject { std::fs::metadata(&one).is_ok() && std::fs::metadata(&two).is_ok() } + pub fn get_version_at_path(path: &str) -> Option { + let project_version_file = std::fs::read_to_string( + Path::new(&path) + .join("ProjectSettings") + .join("ProjectVersion.txt"), + ); + if project_version_file.is_err() { + return None; + } + let binding = project_version_file.unwrap(); + let mut iter = binding.split_whitespace(); + iter.next(); + let project_version = iter.next().unwrap().to_string(); + + return Some(project_version); + } + pub fn try_get_project_at_path(path: &str) -> Option { #[cfg(windows)] let path = path.trim_matches(char::from(0)).replace("/", "\\"); @@ -70,21 +87,13 @@ impl UnityProject { if !UnityProject::is_project_at_path(&path) { return None; } - let project_version_file = std::fs::read_to_string( - Path::new(&path) - .join("ProjectSettings") - .join("ProjectVersion.txt"), - ); - let project_version_file = project_version_file.unwrap(); - let mut iter = project_version_file.split_whitespace(); - iter.next(); - let project_version = iter.next().unwrap().to_string(); + let mut project = UnityProject { path: path.to_string(), title: path.split(consts::SLASH).last().unwrap().to_string(), - version: project_version, branch: String::new(), + version: String::new(), is_valid: true, edit_time: std::time::SystemTime::now() .sub(std::time::Duration::new(60 * 60 * 24 * 365 * 30, 0)), @@ -106,6 +115,7 @@ impl UnityProject { } let mut base_path = Path::new(&self.path); + self.version = Self::get_version_at_path(&self.path).unwrap(); while let Some(path) = base_path.parent() { base_path = path;