Skip to content

Commit

Permalink
Show version in both cli and gui
Browse files Browse the repository at this point in the history
  • Loading branch information
Not-A-Normal-Robot committed Oct 22, 2024
1 parent 40345b9 commit 0648864
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 13 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ mod conf;
slint::include_modules!();

fn main() -> Result<(), slint::PlatformError> {
println!("╔═════╗");
println!("║ ▄▄ ║ Boxedmino");
println!("║ ▀▀ ║ Sandboxed Techmino runner");
println!("╚═════╝");
println!("2024 - 26F-Studio | https://github.com/26F-Studio/Boxedmino\n\n");
print_intro();

if let Err(missing_dependencies) = check_dependencies() {
let mut message = "The following dependencies are missing:".to_string();
Expand Down Expand Up @@ -64,14 +60,23 @@ fn main() -> Result<(), slint::PlatformError> {
}

if config.use_gui {
open_window(&config)?;
open_main_window(&config)?;
} else {
run_game(&config);
}

return Ok(());
}

fn print_intro() {
let version = env!("CARGO_PKG_VERSION");
println!("╔═════╗");
println!("║ ▄▄ ║ Boxedmino v{version}");
println!("║ ▀▀ ║ Sandboxed Techmino runner");
println!("╚═════╝");
println!("2024 - 26F-Studio | https://github.com/26F-Studio/Boxedmino\n\n");
}

fn run_game(cfg: &Config) {
let path = PathBuf::from(cfg.game_repo_path.clone());

Expand Down Expand Up @@ -268,7 +273,7 @@ fn safe_todo(feature: Option<&str>) {
);
}

fn open_window(cfg: &Config) -> Result<MainWindow, slint::PlatformError> {
fn open_main_window(cfg: &Config) -> Result<MainWindow, slint::PlatformError> {
let main_window = MainWindow::new()?;
main_window.on_open_game(|_| {
run_game(&Config::load());
Expand All @@ -279,6 +284,7 @@ fn open_window(cfg: &Config) -> Result<MainWindow, slint::PlatformError> {
.to_string()
.into()
);
main_window.set_boxedmino_version(env!("CARGO_PKG_VERSION").into());
main_window.on_open_link(open_link);
main_window.on_copy_text(|string| {
copy_text_handled(string.as_str());
Expand Down
4 changes: 2 additions & 2 deletions ui/main.slint
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export component MainWindow inherits Window {
pure callback filter([string], string) -> [string];

in property <string> sandbox_path;
in property <string> boxedmino_version: "0.0.0";
in-out property <[string]> versions: ["Uninitialized A", "Uninitialized B", "Uninitialized C", "Uninitialized D"];
in-out property <[string]> matched_versions: versions;
in-out property <string> selected_version: "Uninitialized A";
Expand Down Expand Up @@ -288,8 +289,7 @@ export component MainWindow inherits Window {
font-size: 1.25rem;
}
Text {
text: "(C) 26F-Studio - 2024";
accessible-role: AccessibleRole.text;
text: "Version " + boxedmino_version + " | (C) 26F-Studio - 2024";
horizontal-alignment: TextHorizontalAlignment.center;
}
Text {
Expand Down

0 comments on commit 0648864

Please sign in to comment.