Spacing, theme switch
This commit is contained in:
parent
bda3bd51b6
commit
3e8632d2a9
|
|
@ -1,2 +1,3 @@
|
||||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
pub const HOMEPAGE: &str = env!("CARGO_PKG_HOMEPAGE");
|
pub const HOMEPAGE: &str = env!("CARGO_PKG_HOMEPAGE");
|
||||||
|
pub const VERTICAL_SPACING: f32 = 8.0;
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,23 @@
|
||||||
use rfd::FileDialog;
|
use crate::{
|
||||||
use rusty_hub::hub::Hub;
|
consts::HOMEPAGE,
|
||||||
|
consts::{VERSION, VERTICAL_SPACING},
|
||||||
|
window_tab::WindowTab,
|
||||||
|
};
|
||||||
use eframe::{
|
use eframe::{
|
||||||
egui::{self, Layout, Ui},
|
egui::{self, Layout, Ui},
|
||||||
epaint::Color32
|
epaint::Color32,
|
||||||
};
|
};
|
||||||
use egui_extras::{Size, TableBuilder};
|
use egui_extras::{Size, TableBuilder};
|
||||||
use crate::{window_tab::WindowTab, consts::VERSION, consts::HOMEPAGE};
|
use rfd::FileDialog;
|
||||||
|
use rusty_hub::hub::Hub;
|
||||||
|
|
||||||
pub struct HubClient {
|
pub struct HubClient {
|
||||||
hub: Hub,
|
hub: Hub,
|
||||||
current_tab: WindowTab,
|
current_tab: WindowTab,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl HubClient {
|
impl HubClient {
|
||||||
pub fn new(cc: &eframe::CreationContext<'_>) -> Self {
|
pub fn new(_cc: &eframe::CreationContext<'_>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
hub: confy::load("lwa_unity_hub", "config").unwrap(),
|
hub: confy::load("lwa_unity_hub", "config").unwrap(),
|
||||||
current_tab: WindowTab::Projects,
|
current_tab: WindowTab::Projects,
|
||||||
|
|
@ -103,12 +106,15 @@ impl HubClient {
|
||||||
.header(20.0, |mut header| {
|
.header(20.0, |mut header| {
|
||||||
header.col(|ui| {
|
header.col(|ui| {
|
||||||
ui.heading("Name");
|
ui.heading("Name");
|
||||||
|
ui.add_space(VERTICAL_SPACING);
|
||||||
});
|
});
|
||||||
header.col(|ui| {
|
header.col(|ui| {
|
||||||
ui.heading("Version");
|
ui.heading("Version");
|
||||||
|
ui.add_space(VERTICAL_SPACING);
|
||||||
});
|
});
|
||||||
header.col(|ui| {
|
header.col(|ui| {
|
||||||
ui.heading("Directory");
|
ui.heading("Directory");
|
||||||
|
ui.add_space(VERTICAL_SPACING);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.body(|body| {
|
.body(|body| {
|
||||||
|
|
@ -120,10 +126,13 @@ impl HubClient {
|
||||||
let editor_for_project_exists =
|
let editor_for_project_exists =
|
||||||
self.hub.editor_for_project(project).is_some();
|
self.hub.editor_for_project(project).is_some();
|
||||||
row.col(|ui| {
|
row.col(|ui| {
|
||||||
ui.set_enabled(editor_for_project_exists);
|
|
||||||
ui.vertical_centered_justified(|ui| {
|
ui.vertical_centered_justified(|ui| {
|
||||||
|
ui.add_space(VERTICAL_SPACING - 2.0);
|
||||||
if ui
|
if ui
|
||||||
.button(format!("{}", &project.title))
|
.add_enabled(
|
||||||
|
editor_for_project_exists,
|
||||||
|
egui::Button::new(format!("{}", &project.title)),
|
||||||
|
)
|
||||||
.on_disabled_hover_text(format!(
|
.on_disabled_hover_text(format!(
|
||||||
"Select different Unity version"
|
"Select different Unity version"
|
||||||
))
|
))
|
||||||
|
|
@ -131,13 +140,14 @@ impl HubClient {
|
||||||
{
|
{
|
||||||
self.hub.run_project_nr(row_index);
|
self.hub.run_project_nr(row_index);
|
||||||
}
|
}
|
||||||
|
ui.add_space(VERTICAL_SPACING);
|
||||||
});
|
});
|
||||||
ui.set_enabled(true);
|
|
||||||
});
|
});
|
||||||
row.col(|ui| {
|
row.col(|ui| {
|
||||||
ui.with_layout(
|
ui.with_layout(
|
||||||
Layout::top_down_justified(eframe::emath::Align::Center),
|
Layout::top_down_justified(eframe::emath::Align::Center),
|
||||||
|ui| {
|
|ui| {
|
||||||
|
ui.add_space(VERTICAL_SPACING);
|
||||||
let mut text = egui::RichText::new(&project.version);
|
let mut text = egui::RichText::new(&project.version);
|
||||||
if !editor_for_project_exists {
|
if !editor_for_project_exists {
|
||||||
text = text.color(Color32::RED);
|
text = text.color(Color32::RED);
|
||||||
|
|
@ -146,10 +156,14 @@ impl HubClient {
|
||||||
ui.add(egui::Label::new(text).sense(egui::Sense::click()));
|
ui.add(egui::Label::new(text).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
|
let mut text = egui::RichText::new(format!(
|
||||||
.button(format!("Open in {}", &editor.version))
|
"Open in {}",
|
||||||
.clicked()
|
&editor.version
|
||||||
{
|
));
|
||||||
|
if editor.version.contains(&project.version) {
|
||||||
|
text = text.strong().color(Color32::GREEN);
|
||||||
|
}
|
||||||
|
if ui.button(text).clicked() {
|
||||||
Hub::run_project(&editor, &project);
|
Hub::run_project(&editor, &project);
|
||||||
ui.close_menu();
|
ui.close_menu();
|
||||||
}
|
}
|
||||||
|
|
@ -159,15 +173,25 @@ impl HubClient {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
row.col(|ui| {
|
row.col(|ui| {
|
||||||
let path_response =
|
ui.with_layout(
|
||||||
ui.add(egui::Label::new(&project.path).sense(egui::Sense::click()));
|
Layout::top_down_justified(eframe::emath::Align::Max),
|
||||||
path_response.context_menu(|ui| {
|
|ui| {
|
||||||
if ui.button("Open directory").clicked() {
|
ui.add_space(VERTICAL_SPACING);
|
||||||
use std::process::Command;
|
let path_response = ui.add(
|
||||||
Command::new("explorer").arg(&project.path).spawn().unwrap();
|
egui::Label::new(&project.path).sense(egui::Sense::click()),
|
||||||
ui.close_menu();
|
);
|
||||||
}
|
path_response.context_menu(|ui| {
|
||||||
});
|
if ui.button("Open directory").clicked() {
|
||||||
|
use std::process::Command;
|
||||||
|
Command::new("explorer")
|
||||||
|
.arg(&project.path)
|
||||||
|
.spawn()
|
||||||
|
.unwrap();
|
||||||
|
ui.close_menu();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -187,7 +211,7 @@ impl eframe::App for HubClient {
|
||||||
.resizable(false)
|
.resizable(false)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
ui.vertical_centered_justified(|ui| {
|
ui.vertical_centered_justified(|ui| {
|
||||||
ui.add_space(5.0);
|
ui.add_space(VERTICAL_SPACING);
|
||||||
|
|
||||||
let button =
|
let button =
|
||||||
egui::Button::new(egui::RichText::new("Projects").heading()).frame(false);
|
egui::Button::new(egui::RichText::new("Projects").heading()).frame(false);
|
||||||
|
|
@ -197,7 +221,7 @@ impl eframe::App for HubClient {
|
||||||
{
|
{
|
||||||
self.current_tab = WindowTab::Projects;
|
self.current_tab = WindowTab::Projects;
|
||||||
}
|
}
|
||||||
ui.add_space(5.0);
|
ui.add_space(VERTICAL_SPACING);
|
||||||
if ui
|
if ui
|
||||||
.add_enabled(
|
.add_enabled(
|
||||||
&self.current_tab != &WindowTab::Editors,
|
&self.current_tab != &WindowTab::Editors,
|
||||||
|
|
@ -212,8 +236,9 @@ impl eframe::App for HubClient {
|
||||||
});
|
});
|
||||||
self.draw_central_panel(&ctx);
|
self.draw_central_panel(&ctx);
|
||||||
egui::TopBottomPanel::bottom("bottomPanel").show(ctx, |ui| {
|
egui::TopBottomPanel::bottom("bottomPanel").show(ctx, |ui| {
|
||||||
ui.with_layout(Layout::top_down(eframe::emath::Align::Max), |ui| {
|
ui.with_layout(Layout::right_to_left(eframe::emath::Align::Center), |ui| {
|
||||||
ui.hyperlink_to(format!("v {}", VERSION), HOMEPAGE)
|
egui::widgets::global_dark_light_mode_switch(ui);
|
||||||
|
ui.hyperlink_to(format!("v {}", VERSION), HOMEPAGE);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
#![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
|
||||||
extern crate confy;
|
extern crate confy;
|
||||||
use eframe::{
|
use eframe::{egui, IconData, NativeOptions};
|
||||||
egui,
|
|
||||||
IconData, NativeOptions,
|
|
||||||
};
|
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
|
||||||
|
mod consts;
|
||||||
mod hub_client;
|
mod hub_client;
|
||||||
mod window_tab;
|
mod window_tab;
|
||||||
mod consts;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let img = image::io::Reader::new(Cursor::new(include_bytes!("../static/hub.png")))
|
let img = image::io::Reader::new(Cursor::new(include_bytes!("../static/hub.png")))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue