Skip to content

Commit

Permalink
fix: let launcher handle ip addr if provided
Browse files Browse the repository at this point in the history
  • Loading branch information
iWas-Coder committed Apr 15, 2024
1 parent 8c51cae commit 2fcb356
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/sk_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extern "C" {
fn sk_server_run() -> u8;
}

static SK_LAUNCHER_NAME: &str = "sparky-client::launcher";
static SK_LAUNCHER_NAME: &str = "sparky::launcher";
static SK_LAUNCHER_TAB_MODULES: &str = "Modules";
static SK_LAUNCHER_TAB_LOG: &str = "Console Log";

Expand Down Expand Up @@ -69,7 +69,13 @@ impl eframe::App for Launcher {
let ip_label = ui.label("IP: ");
ui.text_edit_singleline(&mut self.ip).labelled_by(ip_label.id);
});
if ui.button("Play").clicked() { unsafe { sk_client_run(std::ptr::null()); } }
if ui.button("Play").clicked() {
if self.ip.is_empty() { unsafe { sk_client_run(std::ptr::null()); } }
else {
let ip_addr = std::ffi::CString::new(self.ip.clone()).unwrap();
unsafe { sk_client_run(ip_addr.as_ptr()); }
}
}
});
egui::Window::new("Server").show(ctx, |ui| {
if ui.button("Start").clicked() { unsafe { sk_server_run(); } }
Expand Down

0 comments on commit 2fcb356

Please sign in to comment.