Enum yy_typings::object_yy::EventType
source · [−]pub enum EventType {
Show 14 variants
Create,
Destroy,
Cleanup,
Step(Stage),
Alarm(usize),
Draw(DrawEvent),
Collision,
Mouse(MouseEvent),
KeyDown(VirtualKeyCode),
KeyPress(VirtualKeyCode),
KeyRelease(VirtualKeyCode),
Gesture(GestureEvent),
Other(OtherEvent),
Async(AsyncEvent),
}
Expand description
Describes the current event type. Users can make most events freely, though
special care should be taken that Alarm
’s .0 field is less than
ALARM_MAX
, and the same for the OtherEvent
’s usize wrappers. To make
sure some event has been validly created, is_valid
has been provided.
Note: only serde_json serialization and deserialization is supported for
EventType. Yaml, and other text / WYSIWYG data formats should be fine, but
Bincode and other binary sequences are unlikely to succesfully serialize
this. This is due to our use of serde’s flatten
, which runs afoul of this issue: https://github.com/servo/bincode/issues/245
Variants
Create
Destroy
Cleanup
Step(Stage)
Alarm(usize)
Draw(DrawEvent)
Collision
Mouse(MouseEvent)
KeyDown(VirtualKeyCode)
KeyPress(VirtualKeyCode)
KeyRelease(VirtualKeyCode)
Gesture(GestureEvent)
Other(OtherEvent)
Async(AsyncEvent)
Implementations
sourceimpl EventType
impl EventType
sourcepub const ALARM_MAX: usize = 11usize
pub const ALARM_MAX: usize = 11usize
The maximum number of alarms which are available in the Gms2 IDE.
sourcepub fn filename(&self) -> (&'static str, usize)
pub fn filename(&self) -> (&'static str, usize)
Gets the filename for a given event with its requisite base. We return in this format to reduce allocating a string per call, as this filename will likely become allocated on some path in the future.
let (base_name, numeric_id) = EventType::Create;
assert_eq!(base_name, "Create_");
assert_eq!(numeric_id, 0);
sourcepub fn filename_simple(&self) -> String
pub fn filename_simple(&self) -> String
Returns the filename like it will appear in a file.
sourcepub fn parse_filename(
value: &str,
event_num: usize
) -> Result<EventType, EventTypeConvertErrors>
pub fn parse_filename(
value: &str,
event_num: usize
) -> Result<EventType, EventTypeConvertErrors>
Parses a given filename and number into an EventType
, if valid.
sourcepub fn parse_filename_simple(
value: &str
) -> Result<EventType, EventTypeConvertErrors>
pub fn parse_filename_simple(
value: &str
) -> Result<EventType, EventTypeConvertErrors>
A simple way to parse a value. It does a split on the string, which
basically means it needs to follow the pattern Create_0
and
similar.
pub fn is_valid(value: EventType) -> bool
Trait Implementations
sourceimpl<'de> Deserialize<'de> for EventType
impl<'de> Deserialize<'de> for EventType
sourcefn deserialize<D>(deserializer: D) -> Result<EventType, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<EventType, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<EventType> for EventIntermediary
impl From<EventType> for EventIntermediary
sourceimpl Ord for EventType
impl Ord for EventType
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<EventType> for EventType
impl PartialEq<EventType> for EventType
sourceimpl PartialOrd<EventType> for EventType
impl PartialOrd<EventType> for EventType
sourcefn partial_cmp(&self, other: &EventType) -> Option<Ordering>
fn partial_cmp(&self, other: &EventType) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl TryFrom<EventIntermediary> for EventType
impl TryFrom<EventIntermediary> for EventType
type Error = EventTypeConvertErrors
type Error = EventTypeConvertErrors
The type returned in the event of a conversion error.
sourcefn try_from(o: EventIntermediary) -> Result<Self, Self::Error>
fn try_from(o: EventIntermediary) -> Result<Self, Self::Error>
Performs the conversion.
impl Copy for EventType
impl Eq for EventType
impl StructuralEq for EventType
impl StructuralPartialEq for EventType
Auto Trait Implementations
impl RefUnwindSafe for EventType
impl Send for EventType
impl Sync for EventType
impl Unpin for EventType
impl UnwindSafe for EventType
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more