add prof_span to hud elements

This commit is contained in:
Imbris 2021-06-19 01:04:05 -04:00
parent 659b42e813
commit 315ab872f5
25 changed files with 80 additions and 53 deletions

View File

@ -2065,10 +2065,7 @@ impl Client {
Ok(())
}
fn handle_messages(
&mut self,
frontend_events: &mut Vec<Event>,
) -> Result<u64, Error> {
fn handle_messages(&mut self, frontend_events: &mut Vec<Event>) -> Result<u64, Error> {
let mut cnt = 0;
loop {
let cnt_start = cnt;

View File

@ -574,6 +574,7 @@ impl<'a> Widget for Bag<'a> {
#[allow(clippy::useless_format)] // TODO: Pending review in #587
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Bag::update");
let widget::UpdateArgs { state, ui, .. } = args;
let i18n = &self.localized_strings;
let key_layout = &self.global_state.window.key_layout;

View File

@ -99,6 +99,7 @@ impl<'a> Widget for BuffsBar<'a> {
fn style(&self) -> Self::Style {}
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("BuffsBar::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut event = Vec::new();
let localized_strings = self.localized_strings;

View File

@ -123,6 +123,7 @@ impl<'a> Widget for Buttons<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Buttons::update");
let widget::UpdateArgs { state, ui, .. } = args;
let invs = self.client.inventories();
let inventory = match invs.get(self.client.entity()) {

View File

@ -203,6 +203,8 @@ impl<'a> Widget for Chat<'a> {
#[allow(clippy::redundant_clone)] // TODO: Pending review in #587
#[allow(clippy::single_match)] // TODO: Pending review in #587
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Chat::update");
let widget::UpdateArgs { id, state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -234,6 +234,7 @@ impl<'a> Widget for Crafting<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Crafting::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -260,6 +260,7 @@ impl<'a> Widget for Diary<'a> {
fn style(&self) -> Self::Style { () }
fn update(mut self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Diary::update");
let widget::UpdateArgs {
id: _, state, ui, ..
} = args;

View File

@ -67,6 +67,7 @@ impl<'a> Widget for EscMenu<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("EscMenu::update");
let widget::UpdateArgs { state, ui, .. } = args;
Image::new(self.imgs.esc_frame)

View File

@ -148,6 +148,7 @@ impl<'a> Widget for Group<'a> {
#[allow(clippy::unused_unit)] // TODO: Pending review in #587
#[allow(clippy::blocks_in_if_conditions)] // TODO: Pending review in #587
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Group::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();
let localized_strings = self.localized_strings;

View File

@ -194,6 +194,7 @@ impl<'a> Widget for Map<'a> {
#[allow(clippy::useless_format)] // TODO: Pending review in #587
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Map::update");
let widget::UpdateArgs { state, ui, .. } = args;
let zoom = self.global_state.settings.interface.map_zoom * 0.8;
let show_difficulty = self.global_state.settings.interface.map_show_difficulty;

View File

@ -437,6 +437,7 @@ impl<'a> Widget for MiniMap<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Minimap::update");
let mut events = Vec::new();
let widget::UpdateArgs { state, ui, .. } = args;

View File

@ -88,7 +88,7 @@ use common::{
util::srgba_to_linear,
vol::RectRasterableVol,
};
use common_base::span;
use common_base::{prof_span, span};
use common_net::{
msg::{world_msg::SiteId, Notification, PresenceKind},
sync::WorldSyncExt,
@ -977,6 +977,8 @@ impl Hud {
let key_layout = &global_state.window.key_layout;
if self.show.ingame {
prof_span!("ingame elements");
let ecs = client.state().ecs();
let pos = ecs.read_storage::<comp::Pos>();
let stats = ecs.read_storage::<comp::Stats>();
@ -1912,63 +1914,65 @@ impl Hud {
// Temporary Example Quest
let arrow_ani = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 0.8; //Animation timer
let show_intro = self.show.intro; // borrow check doesn't understand closures
if let Some(toggle_cursor_key) = global_state
.settings
.controls
.get_binding(GameInput::ToggleCursor)
.filter(|_| !show_intro)
{
if !self.show.intro {
match global_state.settings.interface.intro_show {
Intro::Show => {
if Button::image(self.imgs.button)
.w_h(150.0, 40.0)
.hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press)
.bottom_left_with_margins_on(ui_widgets.window, 200.0, 120.0)
.label(&i18n.get("hud.tutorial_btn"))
.label_font_id(self.fonts.cyri.conrod_id)
.label_font_size(self.fonts.cyri.scale(18))
.label_color(TEXT_COLOR)
.label_y(conrod_core::position::Relative::Scalar(2.0))
.image_color(ENEMY_HP_COLOR)
.set(self.ids.intro_button, ui_widgets)
.was_clicked()
{
self.show.intro = true;
self.show.want_grab = true;
}
Image::new(self.imgs.sp_indicator_arrow)
.w_h(20.0, 11.0)
.mid_top_with_margin_on(self.ids.intro_button, -20.0 + arrow_ani as f64)
.color(Some(QUALITY_LEGENDARY))
.set(self.ids.tut_arrow, ui_widgets);
Text::new(&i18n.get("hud.tutorial_click_here").replace(
"{key}",
toggle_cursor_key.display_string(key_layout).as_str(),
))
.mid_top_with_margin_on(self.ids.tut_arrow, -18.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(14))
.color(BLACK)
.set(self.ids.tut_arrow_txt_bg, ui_widgets);
Text::new(&i18n.get("hud.tutorial_click_here").replace(
"{key}",
toggle_cursor_key.display_string(key_layout).as_str(),
))
.bottom_right_with_margins_on(self.ids.tut_arrow_txt_bg, 1.0, 1.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(14))
.color(QUALITY_LEGENDARY)
.set(self.ids.tut_arrow_txt, ui_widgets);
},
Intro::Never => {
self.show.intro = false;
},
}
prof_span!("temporary example quest");
match global_state.settings.interface.intro_show {
Intro::Show => {
if Button::image(self.imgs.button)
.w_h(150.0, 40.0)
.hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press)
.bottom_left_with_margins_on(ui_widgets.window, 200.0, 120.0)
.label(&i18n.get("hud.tutorial_btn"))
.label_font_id(self.fonts.cyri.conrod_id)
.label_font_size(self.fonts.cyri.scale(18))
.label_color(TEXT_COLOR)
.label_y(conrod_core::position::Relative::Scalar(2.0))
.image_color(ENEMY_HP_COLOR)
.set(self.ids.intro_button, ui_widgets)
.was_clicked()
{
self.show.intro = true;
self.show.want_grab = true;
}
Image::new(self.imgs.sp_indicator_arrow)
.w_h(20.0, 11.0)
.mid_top_with_margin_on(self.ids.intro_button, -20.0 + arrow_ani as f64)
.color(Some(QUALITY_LEGENDARY))
.set(self.ids.tut_arrow, ui_widgets);
Text::new(&i18n.get("hud.tutorial_click_here").replace(
"{key}",
toggle_cursor_key.display_string(key_layout).as_str(),
))
.mid_top_with_margin_on(self.ids.tut_arrow, -18.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(14))
.color(BLACK)
.set(self.ids.tut_arrow_txt_bg, ui_widgets);
Text::new(&i18n.get("hud.tutorial_click_here").replace(
"{key}",
toggle_cursor_key.display_string(key_layout).as_str(),
))
.bottom_right_with_margins_on(self.ids.tut_arrow_txt_bg, 1.0, 1.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(14))
.color(QUALITY_LEGENDARY)
.set(self.ids.tut_arrow_txt, ui_widgets);
},
Intro::Never => {
self.show.intro = false;
},
}
}
// TODO: Add event/stat based tutorial system
if self.show.intro && !self.show.esc_menu {
prof_span!("intro show");
match global_state.settings.interface.intro_show {
Intro::Show => {
if self.show.intro {
@ -2062,6 +2066,7 @@ impl Hud {
// Display debug window.
if let Some(debug_info) = debug_info {
prof_span!("debug info");
// Alpha Version
Text::new(&version)
.top_left_with_margins_on(ui_widgets.window, 5.0, 5.0)
@ -2281,6 +2286,7 @@ impl Hud {
.set(self.ids.debug_info, ui_widgets);
}
} else {
prof_span!("help window");
// Help Window
if let Some(help_key) = global_state.settings.controls.get_binding(GameInput::Help) {
Text::new(

View File

@ -85,6 +85,7 @@ impl<'a> Widget for Popup<'a> {
#[allow(clippy::single_match)] // TODO: Pending review in #587
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Popup::update");
let widget::UpdateArgs { state, ui, .. } = args;
const FADE_IN: f32 = 0.5;

View File

@ -83,6 +83,7 @@ impl<'a> Widget for PromptDialog<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("PromptDialog::update");
let widget::UpdateArgs { state, ui, .. } = args;
let _localized_strings = &self.localized_strings;
let mut event: Option<DialogOutcomeEvent> = None;

View File

@ -122,6 +122,7 @@ impl<'a> Widget for Chat<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Chat::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -72,6 +72,7 @@ impl<'a> Widget for Controls<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Controls::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -98,6 +98,7 @@ impl<'a> Widget for Gameplay<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Gameplay::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -137,6 +137,7 @@ impl<'a> Widget for Interface<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Interface::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -67,6 +67,7 @@ impl<'a> Widget for Language<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Language::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -148,6 +148,7 @@ impl<'a> Widget for SettingsWindow<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("SettingsWindow::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -80,6 +80,7 @@ impl<'a> Widget for Sound<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Sound::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -177,6 +177,7 @@ impl<'a> Widget for Video<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Video::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -226,6 +226,7 @@ impl<'a> Widget for Skillbar<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Skillbar::update");
let widget::UpdateArgs { state, ui, .. } = args;
let max_hp = self.health.base_max().max(self.health.maximum());

View File

@ -109,6 +109,7 @@ impl<'a> Widget for Social<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Social::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();
let button_tooltip = Tooltip::new({

View File

@ -522,6 +522,7 @@ impl<'a> Widget for Trade<'a> {
fn style(&self) -> Self::Style {}
fn update(mut self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Trade::update");
let widget::UpdateArgs { mut state, ui, .. } = args;
let mut event = None;