Skip to content

Conversation

@ChristopherBiscardi
Copy link
Contributor

Objective

Add an example displaying a Player's Inventory in a Grid.

  • Use a Relationship to associate entities with the Player.
  • Use Observers for hover/click on inventory items
  • Log an event using an observer when clicking items

I chose to not handle advanced inventory behavior like user-reordering, splitting stacks, etc. Instead leaving that to a different example.

Testing

cargo run --example inventory

Showcase

screenshot-2025-05-17-at-02.53.22.mp4

@ChristopherBiscardi ChristopherBiscardi added C-Examples An addition or correction to our examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-UI Graphical user interfaces, styles, layouts, and widgets labels May 17, 2025
Comment on lines +30 to +32
let Ok(mut background_color) = buttons.get_mut(trigger.target()) else {
return;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit/food for thoughts: We may consider returning a Result ? using ? would help reducing noise. but I'm not a fan of the default behaviour of panicking if a result is panicking.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BenjaminBrienen BenjaminBrienen added the D-Straightforward Simple bug fixes and API improvements, docs, test and examples label May 17, 2025
@ChristopherBiscardi
Copy link
Contributor Author

This was deemed "not useful enough" to add to the examples. Will re-open with a different PR.

name = "Inventory"
description = "Display a Player's Inventory in a grid"
category = "Usage"
wasm = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested with the Bevy CLI, it works on the web!

bevy run --example=inventory web --open
Suggested change
wasm = false
wasm = true

@inodentry inodentry reopened this May 18, 2025
@inodentry
Copy link
Contributor

I think this example is useful and we should have it. It would be nice to extend it with more functionality in a future PR.

Copy link
Contributor

@BenjaminBrienen BenjaminBrienen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some CI stuff is todo

@erictuvesson
Copy link

There is also #20718.

@ChristopherBiscardi
Copy link
Contributor Author

I haven't received any indication that this PR is desired as an example, and have received indication that a fuller "baldur's gate" style inventory would be preferred over this. So I am again re-closing this and will leave it to whatever #20718 or future work can get merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-UI Graphical user interfaces, styles, layouts, and widgets C-Examples An addition or correction to our examples D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants