use super::{ComponentInspector, InspectorContext, impl_simple_inspector};
use nightshade::prelude::*;

fn add_name(world: &mut World, entity: Entity) {
    world.core.set_name(entity, Name("New Entity".to_string()));
}

fn name_ui(world: &mut World, entity: Entity, ui: &mut egui::Ui, _context: &mut InspectorContext) {
    if let Some(Name(name)) = world.core.get_name_mut(entity) {
        ui.label("Name");
        ui.text_edit_singleline(name);
    }
}

impl_simple_inspector!(NameInspector, "Name", entity_has_name, remove_name, name_ui, custom_add => add_name);
