almost
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
use bevy::{prelude::*, window::PrimaryWindow};
|
||||
use bevy_egui::{EguiContext, EguiContexts, egui};
|
||||
use bevy::prelude::*;
|
||||
use bevy_egui::{EguiContexts, egui};
|
||||
use std::default::Default;
|
||||
|
||||
use crate::{GameState, util::single};
|
||||
use crate::{GameState, asset_loading::ImageAssets, interaction::Interact, util::single};
|
||||
|
||||
use super::Player;
|
||||
|
||||
#[derive(Component, Default, Debug)]
|
||||
pub struct Item(Option<Entity>);
|
||||
|
||||
#[derive(Component, Default, Debug)]
|
||||
pub struct ItemIcon(Handle<Image>);
|
||||
|
||||
impl Item {
|
||||
pub fn none() -> Self {
|
||||
Default::default()
|
||||
@@ -24,7 +27,13 @@ pub fn plugin(app: &mut App) {
|
||||
app.add_systems(Update, bottom_panel.run_if(in_state(GameState::Playing)));
|
||||
}
|
||||
|
||||
fn bottom_panel(mut egui_ctx: EguiContexts, item_query: Query<&Item, With<Player>>) {
|
||||
fn bottom_panel(
|
||||
mut egui_ctx: EguiContexts,
|
||||
player_item_query: Query<&Item, With<Player>>,
|
||||
item_query: Query<(&Name, &ItemIcon), With<Interact>>,
|
||||
models: Res<Assets<Image>>,
|
||||
gltf_assets: Res<ImageAssets>,
|
||||
) {
|
||||
egui::TopBottomPanel::bottom("inventory_toolbar")
|
||||
.frame(egui::Frame {
|
||||
fill: egui::Color32::from_rgba_premultiplied(0, 0, 0, 0),
|
||||
@@ -52,12 +61,17 @@ fn bottom_panel(mut egui_ctx: EguiContexts, item_query: Query<&Item, With<Player
|
||||
ui.add_sized([50.0, 50.0], |ui: &mut egui::Ui| {
|
||||
// Display the item
|
||||
ui.vertical_centered(|ui| {
|
||||
let item = single!(player_item_query);
|
||||
let item = item.0.and_then(|id| item_query.get(id).ok());
|
||||
// Placeholder for texture - in a real app, load the texture
|
||||
ui.label(egui::RichText::new("🔨").size(24.0));
|
||||
// let (name, icon) = item.map_or_else((Name::new(""), ), |(name, handle)|{
|
||||
|
||||
// });
|
||||
|
||||
// Item count (display only if > 1)
|
||||
ui.label(
|
||||
egui::RichText::new("LOL")
|
||||
egui::RichText::new("")
|
||||
.color(egui::Color32::WHITE)
|
||||
.size(12.0),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user