Allow disabling gui

This commit is contained in:
Austen Adler
2025-01-10 22:41:13 -05:00
parent 999dd8db51
commit ab21b88c90
4 changed files with 69 additions and 41 deletions

View File

@@ -11,6 +11,10 @@ readme = "README.md"
[profile.release]
lto = "thin"
[features]
default = ["gui"]
gui = ["dep:tauri", "dep:tauri-plugin-log", "dep:tauri-plugin-shell"]
[build-dependencies]
tauri-build = "2"
@@ -34,7 +38,7 @@ rfd = "0.15.1"
semver = "1.0.23"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tauri = "2"
tauri-plugin-log = { version = "2.2.0" }
tauri-plugin-shell = "2"
tauri = { version = "2", optional = true }
tauri-plugin-log = { version = "2.2.0", optional = true }
tauri-plugin-shell = { version = "2", optional = true }
tokio = { version = "1.42.0", features = ["full"] }

View File

@@ -93,9 +93,9 @@ Feel free to choose an item from the To-Do or Known Bugs list, or bring your own
- **Cross-Platform Support**: Ensure the project runs smoothly on Windows, macOS, and Linux.
#### How to contribute
This project is open source and welcomes contributions from everyone! Whether you're interested in fixing bugs, improving performance, adding new features, or enhancing documentation, your input is valuable. Simply fork the repository, make your changes, and submit a pull request. We encourage discussions and suggestions to ensure the project remains modular, optimized, and easy to use for the community. You can use the parameter --debug to get a more detailed output of the processed values, which can be helpful for debugging and development. Contributions of all levels are appreciated, and your efforts help improve this tool for everyone.
This project is open source and welcomes contributions from everyone! Whether you're interested in fixing bugs, improving performance, adding new features, or enhancing documentation, your input is valuable. Simply fork the repository, make your changes, and submit a pull request. We encourage discussions and suggestions to ensure the project remains modular, optimized, and easy to use for the community. You can use the parameter --debug to get a more detailed output of the processed values, which can be helpful for debugging and development. Contributions of all levels are appreciated, and your efforts help improve this tool for everyone. You can add `--no-default-features` to disable the GUI (enabled by default).
Build and run it using: ```cargo run --release -- --path="C:/YOUR_PATH/.minecraft/saves/worldname" --bbox="min_lng,min_lat,max_lng,max_lat"```<br>
Build and run it using: ```cargo run --release --no-default-features -- --path="C:/YOUR_PATH/.minecraft/saves/worldname" --bbox="min_lng,min_lat,max_lng,max_lat"```<br>
For the GUI: ```cargo run --release```<br>
After your pull request was merged, I will take care of regularly creating update releases which will include your changes.

View File

@@ -1,3 +1,4 @@
fn main() {
#[cfg(feature = "gui")]
tauri_build::build()
}

View File

@@ -8,7 +8,17 @@ mod data_processing;
mod element_processing;
mod floodfill;
mod osm_parser;
#[cfg(feature = "gui")]
mod progress;
// If the user does not want the GUI, it's easiest to just mock the progress module to do nothing
#[cfg(not(feature = "gui"))]
mod progress {
pub fn emit_gui_error(_message: &str) {}
pub fn emit_gui_progress_update(_progress: f64, _message: &str) {}
pub fn is_running_with_gui() -> bool {
false
}
}
mod retrieve_data;
mod version_check;
mod world_editor;
@@ -28,6 +38,7 @@ use std::{
panic,
path::{Path, PathBuf},
};
#[cfg(feature = "gui")]
use tauri_plugin_log::{Builder as LogBuilder, Target, TargetKind};
fn print_banner() {
@@ -121,6 +132,13 @@ fn main() {
let _ =
data_processing::generate_world(parsed_elements, &args, scale_factor_x, scale_factor_z);
} else {
#[cfg(not(feature = "gui"))]
{
panic!("This version of arnis was not built with GUI enabled");
}
#[cfg(feature = "gui")]
{
// Launch the UI
println!("Launching UI...");
@@ -161,7 +179,9 @@ fn main() {
.expect("Error while starting the application UI (Tauri)");
}
}
}
#[cfg(feature = "gui")]
#[tauri::command]
fn gui_select_world(generate_new: bool) -> Result<String, i32> {
// Determine the default Minecraft 'saves' directory based on the OS
@@ -309,11 +329,13 @@ fn create_new_world(base_path: &Path) -> Result<String, String> {
Ok(new_world_path.display().to_string())
}
#[cfg(feature = "gui")]
#[tauri::command]
fn gui_get_version() -> String {
env!("CARGO_PKG_VERSION").to_string()
}
#[cfg(feature = "gui")]
#[tauri::command]
fn gui_check_for_updates() -> Result<bool, String> {
match version_check::check_for_updates() {
@@ -322,6 +344,7 @@ fn gui_check_for_updates() -> Result<bool, String> {
}
}
#[cfg(feature = "gui")]
#[tauri::command]
fn gui_start_generation(
bbox_text: String,