Skip to content

Commit

Permalink
Use isize for InputContext::PRIORITY
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Oct 27, 2024
1 parent 2b36a48 commit 89ee403
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rename `Pressed` into `Press`.
- Rename `BlockedBy` into `BlockBy`.
- Rename `Scalar` into `Scale`.
- Use `isize` for `InputContext::PRIORITY`.
- Replace `SmoothDelta` with `LerpDelta` that does only linear interpolation. Using easing functions for inputs doesn't make much sense.
- Modifiers are now allowed to change passed value dimensions.
- All built-in modifiers now handle values of any dimention.
Expand Down
2 changes: 1 addition & 1 deletion examples/context_layering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ struct EnterWater;
struct Swimming;

impl InputContext for Swimming {
const PRIORITY: usize = 1; // Set higher priority to execute its actions first.
const PRIORITY: isize = 1; // Set higher priority to execute its actions first.

fn context_instance(_world: &World, _entity: Entity) -> ContextInstance {
let mut ctx = ContextInstance::default();
Expand Down
8 changes: 4 additions & 4 deletions src/input_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ impl ContextInstances {
enum InstanceGroup {
Exclusive {
type_id: TypeId,
priority: usize,
priority: isize,
instances: Vec<(Entity, ContextInstance)>,
},
Shared {
type_id: TypeId,
priority: usize,
priority: isize,
entities: Vec<Entity>,
ctx: ContextInstance,
},
Expand All @@ -234,7 +234,7 @@ impl InstanceGroup {
}
}

fn priority(&self) -> usize {
fn priority(&self) -> isize {
match *self {
InstanceGroup::Exclusive { priority, .. } => priority,
InstanceGroup::Shared { priority, .. } => priority,
Expand Down Expand Up @@ -305,7 +305,7 @@ pub trait InputContext: Component {
///
/// Ordering is global.
/// Contexts with a higher priority evaluated first.
const PRIORITY: usize = 0;
const PRIORITY: isize = 0;

/// Creates a new instance for the given entity.
///
Expand Down
2 changes: 1 addition & 1 deletion tests/priority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn prioritization() {
struct First;

impl InputContext for First {
const PRIORITY: usize = Second::PRIORITY + 1;
const PRIORITY: isize = Second::PRIORITY + 1;

fn context_instance(_world: &World, _entity: Entity) -> ContextInstance {
let mut ctx = ContextInstance::default();
Expand Down

0 comments on commit 89ee403

Please sign in to comment.