From f80fbb7f5c5b02ae493948771fc516ed8eaad6cb Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Sat, 24 Sep 2022 23:02:03 +0200 Subject: [PATCH] Icon, minor improvements --- egui_client/Cargo.lock | 32 ++++++++++++++++++++ egui_client/Cargo.toml | 3 +- egui_client/src/main.rs | 55 +++++++++++++++++++++++++++------- egui_client/static/hub.png | Bin 0 -> 674 bytes rusty_hub/src/unity_editor.rs | 3 ++ 5 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 egui_client/static/hub.png diff --git a/egui_client/Cargo.lock b/egui_client/Cargo.lock index bf8d4df..6be625e 100644 --- a/egui_client/Cargo.lock +++ b/egui_client/Cargo.lock @@ -257,6 +257,12 @@ dependencies = [ "objc", ] +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + [[package]] name = "combine" version = "4.6.6" @@ -850,6 +856,20 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "image" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e30ca2ecf7666107ff827a8e481de6a132a9b687ed3bb20bb1c144a36c00964" +dependencies = [ + "bytemuck", + "byteorder", + "color_quant", + "num-rational", + "num-traits", + "png", +] + [[package]] name = "instant" version = "0.1.12" @@ -1155,6 +1175,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.15" @@ -1414,6 +1445,7 @@ name = "rusty_hub_egui" version = "0.1.0" dependencies = [ "eframe", + "image", "rusty_hub", ] diff --git a/egui_client/Cargo.toml b/egui_client/Cargo.toml index c2a0ca9..cb2220b 100644 --- a/egui_client/Cargo.toml +++ b/egui_client/Cargo.toml @@ -15,4 +15,5 @@ opt-level = 2 [dependencies] eframe = "0.19.0" -rusty_hub = { path="../rusty_hub" } \ No newline at end of file +rusty_hub = { path="../rusty_hub" } +image = { version = "0.24.0", default-features = false, features = ["png"] } \ No newline at end of file diff --git a/egui_client/src/main.rs b/egui_client/src/main.rs index 35f99cd..4d04f11 100644 --- a/egui_client/src/main.rs +++ b/egui_client/src/main.rs @@ -1,10 +1,31 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release -use eframe::egui; +use eframe::{egui, IconData, NativeOptions}; use rusty_hub::hub::Hub; +use std::io::Cursor; fn main() { - let options = eframe::NativeOptions::default(); + let img = image::io::Reader::new(Cursor::new(include_bytes!("../static/hub.png"))) + .with_guessed_format() + .unwrap() + .decode() + .unwrap(); + let icon = IconData { + width: 32, + height: 32, + rgba: img.into_rgba8().into_raw(), + }; + let options = NativeOptions { + always_on_top: false, + maximized: false, + decorated: true, + fullscreen: false, + drag_and_drop_support: false, + initial_window_size: Some(egui::vec2(920.0, 400.0)), + resizable: false, + icon_data: Some(icon), + ..NativeOptions::default() + }; eframe::run_native( "Rusty Hub", options, @@ -42,7 +63,6 @@ fn setup_custom_fonts(ctx: &egui::Context) { } struct MyApp { - text: String, hub: Hub, } @@ -50,7 +70,6 @@ impl MyApp { fn new(cc: &eframe::CreationContext<'_>) -> Self { setup_custom_fonts(&cc.egui_ctx); Self { - text: "Edit this text field if you want".to_owned(), hub: Hub::default(), } } @@ -58,25 +77,41 @@ impl MyApp { impl eframe::App for MyApp { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { + egui::SidePanel::left("dsadsa").show(ctx, |ui| { + ui.set_height(25.0); + ui.add_space(14.0); + ui.button("Projects"); + ui.add_space(14.0); + ui.button("Editors"); + }); egui::CentralPanel::default().show(ctx, |ui| { egui::Grid::new("some_unique_id") .striped(true) .min_row_height(30.0) - .max_col_width(500.0) + .min_col_width(150.0) + .max_col_width(800.0) + .num_columns(3) .show(ui, |ui| { let mut index: usize = 0; for project in &self.hub.projects { - if self.hub.editor_for_project(project).is_some() { - if ui.button("run").clicked() { + ui.set_row_height(40.0); + ui.scope(|ui| { + ui.set_enabled(self.hub.editor_for_project(project).is_some()); + if ui + .button(format!("Open {}", &project.title)) + .on_disabled_hover_text(format!("Select different Unity version")) + .clicked() + { self.hub.run_project_nr(index); } - } - ui.label(&project.title); + ui.set_enabled(true); + }); + let version_response = ui.add(egui::Label::new(&project.version).sense(egui::Sense::click())); version_response.context_menu(|ui| { for editor in &self.hub.config.editors_configurations { - if ui.button(format!("Open in {}", editor.version)).clicked() { + if ui.button(format!("Open in {}", &editor.version)).clicked() { Hub::run_project(&editor, &project); ui.close_menu(); } diff --git a/egui_client/static/hub.png b/egui_client/static/hub.png new file mode 100644 index 0000000000000000000000000000000000000000..7e1a57aaa5028af33b09471605942ca07d14ed1b GIT binary patch literal 674 zcmV;T0$u%yP) zNHj2t3MxU3Hrm1#MPzO)DC&PW=kdnz%~eOd-TwOj>8K}uKxCQ0^= zX%nD2ECEB{vQ;+-E`=rF8_CA~tmVTbu5~ah0c@+FLGK@eBR-w%)eGA6+UMKBe<|QO zxCYk170|jz0rx;ZH~{W~GeH8rgJWRbs2iuPF2}|(;I`i1A&CXHv1?v1%IRPQWV!@A z17%hx<)9N3Q!LOlff1|SMKG-Q9H`!ab}((Vn+2sV0bjvUuwm4l0t;KcyWWa(5zt zgU|!;g~S6skUQ`5IU$$C6Apn!l3?U5fCoQGvB;QDvc#^lABSN6M2lMH$oD!(#C8I1 zf^Mts1t@W}e+f=obvHnluYexyz%-s+o}>Meu99gyf$P2kI3JuNaXB{55xo>_S1EQr zVAq@>$pc;j*rKU5BVgw7R^kV3PT@`gN&huV`p+p*5`WMC0X$2QM>%N(1^@s607*qo IM6N<$f~?UewEzGB literal 0 HcmV?d00001 diff --git a/rusty_hub/src/unity_editor.rs b/rusty_hub/src/unity_editor.rs index d325f19..7d4dcd5 100644 --- a/rusty_hub/src/unity_editor.rs +++ b/rusty_hub/src/unity_editor.rs @@ -30,6 +30,9 @@ impl UnityEditor { let hashmap = string_file_info.children[0].string_map(); if let Some(result_version) = hashmap.get("ProductVersion") { version = Some(result_version.clone()); + if let Some(short) = result_version.clone().split("_").take(1).next() { + version = Some(short.to_string()); + } } // println!( // "Printing info for {}: \n{:#?}\n\n",