diff --git a/client/src/lib.rs b/client/src/lib.rs index df1c802071..75380a6c86 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -13,7 +13,7 @@ pub use common_net::msg::ServerInfo; pub use specs::{ join::Join, saveload::{Marker, MarkerAllocator}, - Builder, DispatcherBuilder, Entity as EcsEntity, ReadStorage, WorldExt, + Builder, DispatcherBuilder, Entity as EcsEntity, ReadStorage, World, WorldExt, }; use crate::addr::ConnectionArgs; diff --git a/common/src/clock.rs b/common/src/clock.rs index 0eed375d95..60dcb3eda4 100644 --- a/common/src/clock.rs +++ b/common/src/clock.rs @@ -85,7 +85,8 @@ impl Clock { .map_or(self.last_dt.as_secs_f32(), |t| t.into_inner()), ); if self.last_dts.len() >= NUMBER_OF_DELTAS_COMPARED && self.last_dt > 2 * stable_dt { - tracing::debug!(?self.last_dt, ?self.total_tick_time, "lag spike detected, unusually slow tick"); + //tracing::debug!(?self.last_dt, ?self.total_tick_time, "lag spike detected, + // unusually slow tick"); stable_dt } else { self.last_dt diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index 1a95d6c6d6..92ce8ca450 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -23,13 +23,14 @@ use crate::{ use serde::{Deserialize, Serialize}; use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; +use strum_macros::Display; use vek::*; use super::{BuffKind, Density, Mass}; make_case_elim!( body, - #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] + #[derive(Copy, Clone, Debug, Display, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] pub enum Body { Humanoid(body: humanoid::Body) = 0, diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 4e40b2ac6c..8c909a2735 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -8,6 +8,7 @@ use serde::{Deserialize, Serialize}; use specs::{Component, DerefFlaggedStorage, VecStorage}; use specs_idvs::IdvStorage; use std::collections::{BTreeMap, VecDeque}; +use strum_macros::Display; use vek::*; /// Data returned from character behavior fn's to Character Behavior System. @@ -42,7 +43,7 @@ impl From<&JoinData<'_>> for StateUpdate { } } } -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Display, PartialEq, Serialize, Deserialize)] pub enum CharacterState { Idle, Climb(climb::Data), diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index f1d4216ed3..9e33c3e66f 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -554,6 +554,7 @@ impl Item { ability_map, msm, ); + new_item.set_amount(self.amount()).expect( "`new_item` has the same `item_def` and as an invariant, \ self.set_amount(self.amount()) should always succeed.", diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index b95550ed1e..ee94bab493 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -15,6 +15,8 @@ use crate::{ }; use serde::{Deserialize, Serialize}; use std::time::Duration; + +use strum_macros::Display; use vek::*; pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; @@ -782,7 +784,7 @@ pub fn tick_attack_or_default( /// Determines what portion a state is in. Used in all attacks (eventually). Is /// used to control aspects of animation code, as well as logic within the /// character states. -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Display, Eq, Hash, PartialEq, Serialize, Deserialize)] pub enum StageSection { Buildup, Swing, diff --git a/voxygen/dynlib/src/lib.rs b/voxygen/dynlib/src/lib.rs index 4a72c4e43d..3602459c76 100644 --- a/voxygen/dynlib/src/lib.rs +++ b/voxygen/dynlib/src/lib.rs @@ -118,7 +118,7 @@ pub fn init( package_source_dir: &'static str, ) { let mut lock = lib_storage.lock().unwrap(); - *lock = Some(LoadedLib::compile_load(package)); + *lock = Some(LoadedLib::compile_load(dyn_package)); // TODO: use crossbeam let (reload_send, reload_recv) = mpsc::channel(); @@ -201,7 +201,7 @@ fn event_fn(res: notify::Result, sender: &mpsc::Sender) { .for_each(|p| { let _ = sender.send(p); }); } }, - Err(e) => error!(?e, "egui hotreload watcher error."), + Err(e) => error!(?e, "hotreload watcher error."), } } @@ -222,11 +222,11 @@ fn hotreload(dyn_package: &str, loaded_lib: Arc>>) { // Open new lib. *lock = Some(LoadedLib::load(dyn_package)); - info!("Updated egui."); + info!("Updated {}.", dyn_package); } } -/// Recompile the anim package +/// Recompile the dyn package /// /// Returns `false` if the compile failed. fn compile(dyn_package: &str) -> bool { @@ -234,8 +234,6 @@ fn compile(dyn_package: &str) -> bool { .stderr(Stdio::inherit()) .stdout(Stdio::inherit()) .arg("build") - .arg("-v") - .arg("-v") .arg("--package") .arg(dyn_package) .arg("--features") diff --git a/voxygen/egui/src/character_states.rs b/voxygen/egui/src/character_states.rs new file mode 100644 index 0000000000..806b685d1d --- /dev/null +++ b/voxygen/egui/src/character_states.rs @@ -0,0 +1,77 @@ +use crate::{two_col_row, SelectedEntityInfo}; +use common::{ + comp::CharacterState, + states::{charged_melee, combo_melee, dash_melee, leap_melee}, +}; +use egui::{Grid, Ui}; + +pub fn draw_char_state_group( + ui: &mut Ui, + _selected_entity_info: &SelectedEntityInfo, + character_state: &CharacterState, +) { + ui.horizontal(|ui| { + ui.label("Current State: "); + ui.label(format!("{}", character_state.to_string())); + }); + match character_state { + CharacterState::ComboMelee(data) => { + combo_melee_grid(ui, data); + }, + CharacterState::DashMelee(data) => dash_melee_grid(ui, data), + CharacterState::ChargedMelee(data) => charged_melee_grid(ui, data), + CharacterState::LeapMelee(data) => leap_melee_grid(ui, data), + _ => {}, + }; +} + +fn charged_melee_grid(ui: &mut Ui, data: &charged_melee::Data) { + Grid::new("selected_entity_charged_melee_grid") + .spacing([40.0, 4.0]) + .max_col_width(100.0) + .striped(true) + .show(ui, |ui| #[rustfmt::skip] { + two_col_row(ui, "Stage Section", format!("{}", data.stage_section)); + two_col_row(ui, "Timer", format!("{}ms", data.timer.as_millis())); + two_col_row(ui, "Charge Amount", format!("{:.1}", data.charge_amount)); + two_col_row(ui, "Exhausted", format!("{}", if data.exhausted { "True" } else { "False " })); + }); +} + +fn combo_melee_grid(ui: &mut Ui, data: &combo_melee::Data) { + Grid::new("selected_entity_combo_melee_grid") + .spacing([40.0, 4.0]) + .max_col_width(100.0) + .striped(true) + .show(ui, |ui| #[rustfmt::skip] { + two_col_row(ui, "Stage", format!("{}", data.stage)); + two_col_row(ui, "Timer", format!("{}ms", data.timer.as_millis())); + two_col_row(ui, "num_stages", format!("{}", data.static_data.num_stages)); + }); +} + +fn dash_melee_grid(ui: &mut Ui, data: &dash_melee::Data) { + Grid::new("selected_entity_dash_melee_grid") + .spacing([40.0, 4.0]) + .max_col_width(100.0) + .striped(true) + .show(ui, |ui| #[rustfmt::skip] { + two_col_row(ui, "Auto Charge", format!("{}", if data.auto_charge { "True" } else { "False " })); + two_col_row(ui, "Timer", format!("{}ms", data.timer.as_millis())); + two_col_row(ui, "Stage Section", data.stage_section.to_string()); + two_col_row(ui, "Exhausted", format!("{}", if data.exhausted { "True" } else { "False " })); + two_col_row(ui, "Charge End Timer", format!("{}ms", data.charge_end_timer.as_millis())); + }); +} + +fn leap_melee_grid(ui: &mut Ui, data: &leap_melee::Data) { + Grid::new("selected_entity_leap_melee_grid") + .spacing([40.0, 4.0]) + .max_col_width(100.0) + .striped(true) + .show(ui, |ui| #[rustfmt::skip] { + two_col_row(ui, "Stage Section", format!("{}", data.stage_section)); + two_col_row(ui, "Timer", format!("{}ms", data.timer.as_millis())); + two_col_row(ui, "Exhausted", format!("{}", if data.exhausted { "True" } else { "False " })); + }); +} diff --git a/voxygen/egui/src/lib.rs b/voxygen/egui/src/lib.rs index 62c05dd08c..a4eb5294b3 100644 --- a/voxygen/egui/src/lib.rs +++ b/voxygen/egui/src/lib.rs @@ -1,6 +1,8 @@ +#![feature(stmt_expr_attributes)] +mod character_states; #[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))] compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once"); -use client::{Client, Join, WorldExt}; +use client::{Client, Join, World, WorldExt}; use common::{ comp, comp::{Poise, PoiseState}, @@ -10,8 +12,17 @@ use core::mem; use egui::{ plot::{Plot, Value}, widgets::plot::Curve, - Color32, Grid, ScrollArea, Slider, Ui, + CollapsingHeader, Color32, Grid, Label, ScrollArea, Slider, Ui, Window, }; + +fn two_col_row(ui: &mut Ui, label: impl Into