54 lines
1.3 KiB
Rust
54 lines
1.3 KiB
Rust
#[global_allocator]
|
|
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
|
|
|
pub mod anim;
|
|
pub mod draw;
|
|
pub mod main_menu;
|
|
pub mod panel;
|
|
pub mod widgets;
|
|
|
|
use canary_script::*;
|
|
use api::*;
|
|
use widgets::Widget;
|
|
use main_menu::MainMenuPanel;
|
|
|
|
export_abi!(MainMenuPanel);
|
|
|
|
pub const ICON_FONT: &str = "Iosevka Nerd Font";
|
|
pub const DISPLAY_FONT: &str = "Homenaje";
|
|
pub const CONTENT_FONT: &str = "Ubuntu";
|
|
|
|
pub struct ConfirmationDialogPanel {
|
|
panel: Panel,
|
|
dialog: widgets::dialog::Dialog,
|
|
}
|
|
|
|
impl BindPanel for ConfirmationDialogPanel {
|
|
fn bind(panel: Panel, msg: Message) -> Box<dyn PanelImpl> {
|
|
let msg = msg.to_vec();
|
|
let info: DialogInfo = serde_json::from_slice(&msg).unwrap();
|
|
|
|
use widgets::dialog::*;
|
|
let style = DialogStyle::default();
|
|
let dialog = Dialog::new(style, &info);
|
|
Box::new(Self { panel, dialog })
|
|
}
|
|
}
|
|
|
|
impl PanelImpl for ConfirmationDialogPanel {
|
|
fn update(&mut self, dt: f32) {
|
|
self.dialog.update(dt);
|
|
}
|
|
|
|
fn draw(&mut self) {
|
|
let ctx = DrawContext::new(self.panel);
|
|
self.dialog.draw(&ctx);
|
|
}
|
|
|
|
fn on_cursor_event(&mut self, kind: CursorEventKind, at: canary_script::Vec2) {
|
|
self.dialog.on_cursor_event(kind, at.into());
|
|
}
|
|
|
|
fn on_message(&mut self, _msg: Message) {}
|
|
}
|