diff --git a/voxygen/egui/src/admin.rs b/voxygen/egui/src/admin.rs index 28fbe611b0..43f571d8a0 100644 --- a/voxygen/egui/src/admin.rs +++ b/voxygen/egui/src/admin.rs @@ -14,13 +14,13 @@ lazy_static! { }; } lazy_static! { - static ref ITEM_CONFIGS: Vec = { - let mut item_configs = common::cmd::ITEM_CONFIGS + static ref ENTITY_CONFIGS: Vec = { + let mut entity_configs = common::cmd::ENTITY_CONFIGS .iter() .map(|entity_desc| entity_desc.replace("common.entity.", "")) .collect::>(); entity_configs.sort(); - entity_confifs + entity_configs }; } @@ -107,3 +107,42 @@ fn draw_give_items(ui: &mut Ui, state: &mut AdminCommandState, egui_actions: &mu ); }); } +fn draw_spawn_entities(ui: &mut Ui, state: &mut AdminCommandState, egui_actions: &mut EguiActions) { + ui.spacing_mut().window_padding = Vec2::new(10.0, 10.0); + Resize::default() + .default_size([400.0, 200.0]) + .show(ui, |ui| { + ui.horizontal(|ui| { + ui.add( + Slider::new(&mut state.spawn_entity_qty, 1..=49) + .logarithmic(true) + .clamp_to_range(true) + .text("Qty"), + ); + if ui.button("Spawn Entities").clicked() { + egui_actions.actions.push(EguiAction::ChatCommand { + cmd: ServerChatCommand::MakeNpc, + args: vec![ + format!( + "common.entity.{}", + ENTITY_CONFIGS[state.spawn_entity_selected_idx].clone() + ), + format!("{}", state.spawn_entity_qty), + ], + }); + }; + }); + ui.horizontal(|ui| { + ui.label("Filter:"); + + ui.text_edit_singleline(&mut state.spawn_entity_search_text); + }); + + crate::widgets::filterable_list( + ui, + &ENTITY_CONFIGS, + &state.spawn_entity_search_text, + &mut state.spawn_entity_selected_idx, + ); + }); +} \ No newline at end of file diff --git a/voxygen/egui/src/lib.rs b/voxygen/egui/src/lib.rs index 25c2c699bf..279663f423 100644 --- a/voxygen/egui/src/lib.rs +++ b/voxygen/egui/src/lib.rs @@ -65,6 +65,9 @@ pub struct AdminCommandState { give_item_selected_idx: usize, give_item_search_text: String, kits_selected_idx: usize, + spawn_entity_qty: u32, + spawn_entity_selected_idx: usize, + spawn_entity_search_text: String, } impl AdminCommandState { @@ -74,6 +77,9 @@ impl AdminCommandState { give_item_selected_idx: 0, give_item_search_text: String::new(), kits_selected_idx: 0, + spawn_entity_qty: 1, + spawn_entity_selected_idx: 0, + spawn_entity_search_text: String::new(), } } }