Cleanup, project template class
This commit is contained in:
parent
365c724252
commit
4c3916e2d1
|
|
@ -46,8 +46,8 @@ jobs:
|
||||||
cache-on-failure: ""
|
cache-on-failure: ""
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cd egui_client && cargo build --verbose
|
run: cd rusty_hub_egui && cargo build --verbose
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: upload executable
|
name: upload executable
|
||||||
path: egui_client/target/release/rusty_hub_egui
|
path: rusty_hub_egui/target/release/rusty_hub_egui
|
||||||
|
|
@ -14,8 +14,8 @@ jobs:
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cd egui_client && cargo build --release --verbose
|
run: cd rusty_hub_egui && cargo build --release --verbose
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: build-exe
|
name: build-exe
|
||||||
path: egui_client/target/release/*exe
|
path: rusty_hub_egui/target/release/*exe
|
||||||
|
|
@ -12,11 +12,11 @@ There is ready to download Windows version. Go to [Releases](https://github.com/
|
||||||
|
|
||||||
[Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html) is required in order to build it.
|
[Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html) is required in order to build it.
|
||||||
|
|
||||||
Building is pretty simple, just copy repo, open `egui_client` subdirectory in `CLI` client and run these commands:
|
Building is pretty simple, just copy repo, open `rusty_hub_egui` subdirectory in `CLI` client and run these commands:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone git@github.com:Leinnan/rusty_hub.git
|
git clone git@github.com:Leinnan/rusty_hub.git
|
||||||
cd rusty_hub/egui_client
|
cd rusty_hub/rusty_hub_egui
|
||||||
cargo build --release
|
cargo build --release
|
||||||
cargo run --release
|
cargo run --release
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1700,18 +1700,6 @@ dependencies = [
|
||||||
"windows",
|
"windows",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rusty_hub"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"dpc-pariter",
|
|
||||||
"exe",
|
|
||||||
"registry",
|
|
||||||
"serde",
|
|
||||||
"serde_derive",
|
|
||||||
"walkdir",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rusty_hub_egui"
|
name = "rusty_hub_egui"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|
@ -1721,7 +1709,7 @@ dependencies = [
|
||||||
"egui_extras",
|
"egui_extras",
|
||||||
"image",
|
"image",
|
||||||
"rfd",
|
"rfd",
|
||||||
"rusty_hub",
|
"unity_hub_lib",
|
||||||
"winres",
|
"winres",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -2054,6 +2042,18 @@ dependencies = [
|
||||||
"tinyvec",
|
"tinyvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unity_hub_lib"
|
||||||
|
version = "0.2.0"
|
||||||
|
dependencies = [
|
||||||
|
"dpc-pariter",
|
||||||
|
"exe",
|
||||||
|
"registry",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
"walkdir",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "url"
|
name = "url"
|
||||||
version = "2.3.1"
|
version = "2.3.1"
|
||||||
|
|
@ -19,7 +19,7 @@ opt-level = 2
|
||||||
confy = "^0.5.0"
|
confy = "^0.5.0"
|
||||||
eframe = "0.19.0"
|
eframe = "0.19.0"
|
||||||
egui_extras = "0.19.0"
|
egui_extras = "0.19.0"
|
||||||
rusty_hub = { path="../rusty_hub" }
|
unity_hub_lib = { path="../unity_hub_lib" }
|
||||||
image = { version = "0.24.0", default-features = false, features = ["png"] }
|
image = { version = "0.24.0", default-features = false, features = ["png"] }
|
||||||
rfd = "0.10.0"
|
rfd = "0.10.0"
|
||||||
|
|
||||||
|
|
@ -9,7 +9,7 @@ use eframe::{
|
||||||
};
|
};
|
||||||
use egui_extras::{Size, TableBuilder};
|
use egui_extras::{Size, TableBuilder};
|
||||||
use rfd::FileDialog;
|
use rfd::FileDialog;
|
||||||
use rusty_hub::hub::Hub;
|
use unity_hub_lib::{consts::FILE_MANAGER, hub::Hub};
|
||||||
|
|
||||||
pub struct HubClient {
|
pub struct HubClient {
|
||||||
hub: Hub,
|
hub: Hub,
|
||||||
|
|
@ -18,7 +18,7 @@ pub struct HubClient {
|
||||||
|
|
||||||
impl HubClient {
|
impl HubClient {
|
||||||
pub fn new(_cc: &eframe::CreationContext<'_>) -> Self {
|
pub fn new(_cc: &eframe::CreationContext<'_>) -> Self {
|
||||||
let hub_option = confy::load("lwa_unity_hub", "config");
|
let hub_option = confy::load("rusty_hub_egui", "config");
|
||||||
|
|
||||||
let hub = if hub_option.is_ok() {
|
let hub = if hub_option.is_ok() {
|
||||||
let mut h: Hub = hub_option.unwrap();
|
let mut h: Hub = hub_option.unwrap();
|
||||||
|
|
@ -27,6 +27,7 @@ impl HubClient {
|
||||||
} else {
|
} else {
|
||||||
Hub::default()
|
Hub::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let client = Self {
|
let client = Self {
|
||||||
hub,
|
hub,
|
||||||
current_tab: WindowTab::Projects,
|
current_tab: WindowTab::Projects,
|
||||||
|
|
@ -39,7 +40,7 @@ impl HubClient {
|
||||||
if rebuild {
|
if rebuild {
|
||||||
self.hub.update_data();
|
self.hub.update_data();
|
||||||
}
|
}
|
||||||
let _ = confy::store("lwa_unity_hub", "config", &self.hub);
|
let _ = confy::store("rusty_hub_egui", "config", &self.hub);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_central_panel(&mut self, ctx: &egui::Context) {
|
pub fn draw_central_panel(&mut self, ctx: &egui::Context) {
|
||||||
|
|
@ -269,7 +270,7 @@ impl HubClient {
|
||||||
path_response.context_menu(|ui| {
|
path_response.context_menu(|ui| {
|
||||||
if ui.button("Open directory").clicked() {
|
if ui.button("Open directory").clicked() {
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
Command::new(rusty_hub::consts::FILE_MANAGER)
|
Command::new(FILE_MANAGER)
|
||||||
.arg(&project.path)
|
.arg(&project.path)
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
|
@ -371,8 +371,8 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rusty_hub"
|
name = "rusty_hub_lib"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dpc-pariter",
|
"dpc-pariter",
|
||||||
"exe",
|
"exe",
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "rusty_hub"
|
name = "unity_hub_lib"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
|
@ -12,7 +12,6 @@ pub struct Configuration {
|
||||||
impl Configuration {
|
impl Configuration {
|
||||||
pub fn rebuild(&mut self) {
|
pub fn rebuild(&mut self) {
|
||||||
let paths = self.get_unity_paths();
|
let paths = self.get_unity_paths();
|
||||||
println!("{}", paths.len());
|
|
||||||
self.editors_configurations = paths
|
self.editors_configurations = paths
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.parallel_map(|path| UnityEditor::new(&path))
|
.parallel_map(|path| UnityEditor::new(&path))
|
||||||
|
|
@ -36,19 +35,12 @@ impl Configuration {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
let uninstall_exists = true; // just check that on windows only
|
let uninstall_exists = true; // just check that on windows only
|
||||||
let unity_exe_exists = entry.path().clone().join(consts::UNITY_EXE_NAME).exists();
|
let unity_exe_exists = entry.path().clone().join(consts::UNITY_EXE_NAME).exists();
|
||||||
println!(
|
|
||||||
"PATH {} {:?}",
|
|
||||||
unity_exe_exists,
|
|
||||||
&entry.path().clone().join(consts::UNITY_EXE_NAME)
|
|
||||||
);
|
|
||||||
|
|
||||||
uninstall_exists && unity_exe_exists
|
uninstall_exists && unity_exe_exists
|
||||||
}
|
}
|
||||||
|
|
||||||
fn search_for_editor(path: &str) -> Vec<String> {
|
fn search_for_editor(path: &str) -> Vec<String> {
|
||||||
let path_exists = std::fs::metadata(path).is_ok();
|
let path_exists = std::fs::metadata(path).is_ok();
|
||||||
if !path_exists {
|
if !path_exists {
|
||||||
println!("PATH NOT EXIST {}", &path);
|
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -15,3 +15,10 @@ pub const FILE_MANAGER: &str = "explorer";
|
||||||
pub const FILE_MANAGER: &str = "open";
|
pub const FILE_MANAGER: &str = "open";
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub const FILE_MANAGER: &str = "xdg-open";
|
pub const FILE_MANAGER: &str = "xdg-open";
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
pub const TEMPLATES_DIR: &str = "Data\\Resources\\PackageManager\\ProjectTemplates";
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
pub const TEMPLATES_DIR: &str = "Contents/Resources/PackageManager/ProjectTemplates";
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
pub const TEMPLATES_DIR: &str = "Data/Resources/PackageManager/ProjectTemplates";
|
||||||
|
|
@ -4,5 +4,6 @@ extern crate serde_derive;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod consts;
|
pub mod consts;
|
||||||
pub mod hub;
|
pub mod hub;
|
||||||
|
pub mod project_template;
|
||||||
pub mod unity_editor;
|
pub mod unity_editor;
|
||||||
pub mod unity_project;
|
pub mod unity_project;
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
use dpc_pariter::IteratorExt;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone, Eq, Hash)]
|
||||||
|
pub struct ProjectTemplate {
|
||||||
|
pub path: String,
|
||||||
|
pub title: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for ProjectTemplate {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.path == other.path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ProjectTemplate {
|
||||||
|
pub fn find_templates(path: &str) -> Vec<ProjectTemplate> {
|
||||||
|
let dir = std::fs::read_dir(Path::new(&path).join(crate::consts::TEMPLATES_DIR));
|
||||||
|
|
||||||
|
if dir.is_err() {
|
||||||
|
return Vec::new();
|
||||||
|
}
|
||||||
|
|
||||||
|
dir.unwrap()
|
||||||
|
.into_iter()
|
||||||
|
.parallel_filter(|path| path.is_ok())
|
||||||
|
.parallel_map(|path| path.unwrap())
|
||||||
|
.parallel_filter(|path| path.file_name().into_string().unwrap().contains(".tgz"))
|
||||||
|
.parallel_map(|path| Self {
|
||||||
|
path: path.path().to_str().unwrap().to_string(),
|
||||||
|
title: path.file_name().into_string().unwrap().replace(".tgz", ""),
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
|
use crate::consts;
|
||||||
|
use crate::project_template::ProjectTemplate;
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::consts;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, Eq, Hash)]
|
#[derive(Debug, Serialize, Deserialize, Clone, Eq, Hash)]
|
||||||
pub struct UnityEditor {
|
pub struct UnityEditor {
|
||||||
pub version: String,
|
pub version: String,
|
||||||
pub exe_path: String,
|
pub exe_path: String,
|
||||||
pub base_path: String,
|
pub base_path: String,
|
||||||
pub platforms: Vec<String>,
|
pub platforms: Vec<String>,
|
||||||
|
pub templates: Vec<ProjectTemplate>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for UnityEditor {
|
impl PartialEq for UnityEditor {
|
||||||
|
|
@ -35,9 +36,7 @@ impl UnityEditor {
|
||||||
use exe::VSVersionInfo;
|
use exe::VSVersionInfo;
|
||||||
let image = VecPE::from_disk_file(&exe_path).unwrap();
|
let image = VecPE::from_disk_file(&exe_path).unwrap();
|
||||||
let vs_version_check = VSVersionInfo::parse(&image);
|
let vs_version_check = VSVersionInfo::parse(&image);
|
||||||
if vs_version_check.is_err() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
if let Some(string_file_info) = vs_version_check.unwrap().string_file_info {
|
if let Some(string_file_info) = vs_version_check.unwrap().string_file_info {
|
||||||
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") {
|
||||||
|
|
@ -65,7 +64,8 @@ impl UnityEditor {
|
||||||
version: version.unwrap().clone(),
|
version: version.unwrap().clone(),
|
||||||
exe_path: exe_path.into_os_string().into_string().unwrap(),
|
exe_path: exe_path.into_os_string().into_string().unwrap(),
|
||||||
base_path: String::from(path),
|
base_path: String::from(path),
|
||||||
platforms: UnityEditor::get_platforms(path),
|
platforms: UnityEditor::get_platforms(&path),
|
||||||
|
templates: ProjectTemplate::find_templates(&path),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue