Skip to content

Commit

Permalink
[VWS] Pop msgbox saying "Cannot use custom caps from MFEKglif."
Browse files Browse the repository at this point in the history
…instead of crashing.
  • Loading branch information
ctrlcctrlv committed Jan 7, 2022
1 parent 1d01bea commit 72e118d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tools/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub use std::cell::RefCell;
pub use std::mem;

//UI
pub use crate::user_interface::gui;
pub use crate::user_interface::{Interface, MouseInfo};
pub use imgui::Ui;
pub use sdl2::mouse::MouseButton;
5 changes: 5 additions & 0 deletions src/tools/vws/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ impl VWS {
let s_selection = idx_to_cap_type(s_current_selection);
let e_selection = idx_to_cap_type(e_current_selection);

if s_selection == CapType::Custom || e_selection == CapType::Custom {
gui::error!("Cannot use custom caps at this time from MFEKglif.");
return;
}

// we only update the contour and previews when our selection changes
if old_s != s_current_selection || e_current_selection != old_e {
let mut new_data = vws_contour;
Expand Down
3 changes: 3 additions & 0 deletions src/user_interface/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ use imgui_sdl2::ImguiSdl2;
use imgui_skia_renderer::Renderer;
use sdl2::{event::Event, mouse::MouseState, video::Window};

#[macro_use]
pub(crate) mod msgbox;
pub(crate) use self::msgbox::gui_error as error;
pub mod layer_list;
pub mod prompts;

Expand Down
15 changes: 15 additions & 0 deletions src/user_interface/gui/msgbox.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
macro_rules! gui_error {
($($format_args:tt),*) => {
use log;
use msgbox::{self, IconType::*};
use std::thread;
log::error!($($format_args),*);
thread::spawn(|| {
match msgbox::create("MFEKglif critical error", &format!($($format_args),*), Error) {
Ok(_) => log::trace!("Opened crash msgbox successfully"),
Err(e) => log::error!("Failed to create error box! {:?}", e),
}
});
}
}
pub(crate) use gui_error;

0 comments on commit 72e118d

Please sign in to comment.