mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'RunRobDog/Spawn-Entities-tab' into 'master'
RunRobDog/spawn entities tab See merge request veloren/veloren!3877
This commit is contained in:
commit
6d966eede2
@ -216,7 +216,7 @@ lazy_static! {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// List of all entity configs. Useful for tab completing
|
/// List of all entity configs. Useful for tab completing
|
||||||
static ref ENTITY_CONFIGS: Vec<String> = {
|
pub static ref ENTITY_CONFIGS: Vec<String> = {
|
||||||
try_all_entity_configs()
|
try_all_entity_configs()
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
warn!(?e, "Failed to load entity configs");
|
warn!(?e, "Failed to load entity configs");
|
||||||
|
@ -13,6 +13,16 @@ lazy_static! {
|
|||||||
item_specs
|
item_specs
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
lazy_static! {
|
||||||
|
static ref ENTITY_CONFIGS: Vec<String> = {
|
||||||
|
let mut entity_configs = common::cmd::ENTITY_CONFIGS
|
||||||
|
.iter()
|
||||||
|
.map(|entity_desc| entity_desc.replace("common.entity.", ""))
|
||||||
|
.collect::<Vec<String>>();
|
||||||
|
entity_configs.sort();
|
||||||
|
entity_configs
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn draw_admin_commands_window(
|
pub fn draw_admin_commands_window(
|
||||||
ctx: &CtxRef,
|
ctx: &CtxRef,
|
||||||
@ -37,6 +47,11 @@ pub fn draw_admin_commands_window(
|
|||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
draw_kits(ui, state, egui_actions);
|
draw_kits(ui, state, egui_actions);
|
||||||
});
|
});
|
||||||
|
CollapsingHeader::new("Spawn Entities")
|
||||||
|
.default_open(false)
|
||||||
|
.show(ui, |ui| {
|
||||||
|
draw_spawn_entities(ui, state, egui_actions);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -92,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,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -65,6 +65,9 @@ pub struct AdminCommandState {
|
|||||||
give_item_selected_idx: usize,
|
give_item_selected_idx: usize,
|
||||||
give_item_search_text: String,
|
give_item_search_text: String,
|
||||||
kits_selected_idx: usize,
|
kits_selected_idx: usize,
|
||||||
|
spawn_entity_qty: u32,
|
||||||
|
spawn_entity_selected_idx: usize,
|
||||||
|
spawn_entity_search_text: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AdminCommandState {
|
impl AdminCommandState {
|
||||||
@ -74,6 +77,9 @@ impl AdminCommandState {
|
|||||||
give_item_selected_idx: 0,
|
give_item_selected_idx: 0,
|
||||||
give_item_search_text: String::new(),
|
give_item_search_text: String::new(),
|
||||||
kits_selected_idx: 0,
|
kits_selected_idx: 0,
|
||||||
|
spawn_entity_qty: 1,
|
||||||
|
spawn_entity_selected_idx: 0,
|
||||||
|
spawn_entity_search_text: String::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user