Skip to content

Commit

Permalink
doc: update documents
Browse files Browse the repository at this point in the history
  • Loading branch information
comUserDummy committed Apr 23, 2024
1 parent 085d1d6 commit 7361b4a
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All notable changes to this project will be documented in this file.

## [unreleased]
## [0.4.0] - 2024-04-23

### Features

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bevy-input-sequence"
description = "Recognizes input sequences and send events"
version = "0.3.0"
version = "0.4.0"
edition = "2021"
authors = ["elm", "Shane Celis <shane.celis@gmail.com>"]
keywords = [
Expand Down
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,50 @@ fn check_events(mut events: EventReader<MyEvent>) {
}
```

## KeySequence creation patterns

`KeySequence::new` now returns an implementing of `Command` instead of itself.
Therefore, you need to call `Commands::add` instead of `Commands::spawn`.

```rust
use bevy::prelude::*;
use bevy_input_sequence::prelude::*;

#[derive(Event, Clone)]
struct MyEvent;

fn create_key_sequence(mut commands: Commands) {
commands.add(KeySequence::new(
action::send_event(bevy::app::AppExit),
keyseq! { ctrl-E L M }
));
}

fn create_key_sequence_and_add_it_to_an_entity(mut commands: Commands) {
let parent = commands.spawn_empty().id();
commands.entity(parent).add(KeySequence::new(
action::send_event(MyEvent),
keyseq! { ctrl-E L M }
));
// OR
commands.spawn_empty().add(KeySequence::new(
action::send_event(MyEvent),
keyseq! { ctrl-E L M }
));
}

fn create_key_sequence_within_command(mut commands: Commands) {
commands.add(|world: &mut World| {
let builder = KeySequence::new(
action::send_event(MyEvent),
keyseq! { ctrl-E L M }
);
let key_sequence = builder.build(world);
// And then put it somewhere?
});
}
```

# Runnable Examples

## keycode
Expand Down
25 changes: 13 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#![doc(html_root_url = "https://docs.rs/bevy-input-sequence/0.3.0")]
#![doc(html_root_url = "https://docs.rs/bevy-input-sequence/0.4.0")]
#![doc = include_str!("../README.md")]
#![forbid(missing_docs)]

pub use keyseq::{
bevy::{pkey as key, pkeyseq as keyseq},
Modifiers,
};

pub use chord::KeyChord;
pub use plugin::InputSequencePlugin;
pub use time_limit::TimeLimit;

pub mod action;
mod cache;
mod chord;
Expand All @@ -12,21 +21,13 @@ pub mod input_sequence;
mod plugin;
mod time_limit;

pub use keyseq::{
bevy::{pkey as key, pkeyseq as keyseq},
Modifiers,
};

/// Convenient splat import
pub mod prelude {
pub use super::{action, keyseq, InputSequencePlugin, Modifiers, TimeLimit};
pub use std::time::Duration;

pub use crate::input_sequence::{ButtonSequence, InputSequence, KeySequence};

pub use super::{action, InputSequencePlugin, keyseq, Modifiers, TimeLimit};
pub use super::cond_system::IntoCondSystem;
pub use std::time::Duration;
}

pub use time_limit::TimeLimit;

pub use chord::KeyChord;
pub use plugin::InputSequencePlugin;

0 comments on commit 7361b4a

Please sign in to comment.