Icon, minor improvements

This commit is contained in:
Piotr Siuszko 2022-09-24 23:02:03 +02:00
parent ffb7baaaa1
commit f80fbb7f5c
5 changed files with 82 additions and 11 deletions

32
egui_client/Cargo.lock generated
View File

@ -257,6 +257,12 @@ dependencies = [
"objc", "objc",
] ]
[[package]]
name = "color_quant"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]] [[package]]
name = "combine" name = "combine"
version = "4.6.6" version = "4.6.6"
@ -850,6 +856,20 @@ dependencies = [
"unicode-normalization", "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]] [[package]]
name = "instant" name = "instant"
version = "0.1.12" version = "0.1.12"
@ -1155,6 +1175,17 @@ dependencies = [
"num-traits", "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]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.15" version = "0.2.15"
@ -1414,6 +1445,7 @@ name = "rusty_hub_egui"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"eframe", "eframe",
"image",
"rusty_hub", "rusty_hub",
] ]

View File

@ -15,4 +15,5 @@ opt-level = 2
[dependencies] [dependencies]
eframe = "0.19.0" eframe = "0.19.0"
rusty_hub = { path="../rusty_hub" } rusty_hub = { path="../rusty_hub" }
image = { version = "0.24.0", default-features = false, features = ["png"] }

View File

@ -1,10 +1,31 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![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 rusty_hub::hub::Hub;
use std::io::Cursor;
fn main() { 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( eframe::run_native(
"Rusty Hub", "Rusty Hub",
options, options,
@ -42,7 +63,6 @@ fn setup_custom_fonts(ctx: &egui::Context) {
} }
struct MyApp { struct MyApp {
text: String,
hub: Hub, hub: Hub,
} }
@ -50,7 +70,6 @@ impl MyApp {
fn new(cc: &eframe::CreationContext<'_>) -> Self { fn new(cc: &eframe::CreationContext<'_>) -> Self {
setup_custom_fonts(&cc.egui_ctx); setup_custom_fonts(&cc.egui_ctx);
Self { Self {
text: "Edit this text field if you want".to_owned(),
hub: Hub::default(), hub: Hub::default(),
} }
} }
@ -58,25 +77,41 @@ impl MyApp {
impl eframe::App for MyApp { impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { 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::CentralPanel::default().show(ctx, |ui| {
egui::Grid::new("some_unique_id") egui::Grid::new("some_unique_id")
.striped(true) .striped(true)
.min_row_height(30.0) .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| { .show(ui, |ui| {
let mut index: usize = 0; let mut index: usize = 0;
for project in &self.hub.projects { for project in &self.hub.projects {
if self.hub.editor_for_project(project).is_some() { ui.set_row_height(40.0);
if ui.button("run").clicked() { 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); self.hub.run_project_nr(index);
} }
} ui.set_enabled(true);
ui.label(&project.title); });
let version_response = let version_response =
ui.add(egui::Label::new(&project.version).sense(egui::Sense::click())); ui.add(egui::Label::new(&project.version).sense(egui::Sense::click()));
version_response.context_menu(|ui| { version_response.context_menu(|ui| {
for editor in &self.hub.config.editors_configurations { 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); Hub::run_project(&editor, &project);
ui.close_menu(); ui.close_menu();
} }

BIN
egui_client/static/hub.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 B

View File

@ -30,6 +30,9 @@ impl UnityEditor {
let hashmap = string_file_info.children[0].string_map(); let hashmap = string_file_info.children[0].string_map();
if let Some(result_version) = hashmap.get("ProductVersion") { if let Some(result_version) = hashmap.get("ProductVersion") {
version = Some(result_version.clone()); version = Some(result_version.clone());
if let Some(short) = result_version.clone().split("_").take(1).next() {
version = Some(short.to_string());
}
} }
// println!( // println!(
// "Printing info for {}: \n{:#?}\n\n", // "Printing info for {}: \n{:#?}\n\n",