-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use crate::bindings::wired::input::types::InputAction; | ||
|
||
impl PartialEq for InputAction { | ||
fn eq(&self, other: &Self) -> bool { | ||
matches!( | ||
(self, other), | ||
(Self::Collision, Self::Collision) | (Self::Hover, Self::Hover) | ||
) | ||
} | ||
} |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,37 @@ | ||
use std::{ | ||
cell::{LazyCell, RefCell}, | ||
rc::Rc, | ||
sync::atomic::AtomicUsize, | ||
}; | ||
|
||
use bindings::exports::unavi::ui::api::Guest; | ||
|
||
#[allow(warnings)] | ||
mod bindings; | ||
|
||
mod button; | ||
mod text; | ||
mod wired_input_impls; | ||
|
||
static ELEMENT_ID: AtomicUsize = AtomicUsize::new(0); | ||
static mut ELEMENTS: LazyCell<RefCell<Vec<Rc<dyn Updatable>>>> = LazyCell::new(RefCell::default); | ||
|
||
trait Updatable { | ||
fn id(&self) -> usize; | ||
fn update(&self, delta: f32); | ||
} | ||
|
||
struct GuestImpl; | ||
|
||
impl Guest for GuestImpl { | ||
fn update_ui(delta: f32) { | ||
// WASM is single-threaded, mutable statics are fine. | ||
unsafe { | ||
for item in ELEMENTS.borrow().iter() { | ||
item.update(delta); | ||
} | ||
} | ||
} | ||
} | ||
|
||
bindings::export!(GuestImpl with_types_in bindings); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../unavi-system/src/wired_input_impls.rs |