From 3964e2febded604ff330c9831dbc3c2c23705401 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Mon, 6 Dec 2021 23:44:10 +0100 Subject: [PATCH] [MIRROR] Optimizes MouseEntered [MDB IGNORE] (#9900) * Optimizes MouseEntered (#63246) * Optimizes MouseEntered Moves status_bar_set_text into the interface definition itself. We don't need to use MouseEntered for this anymore, since lummy added an on-status paramerter to the main window This saves us a little under half our cpu time Gets rid of a needless ?. check, caches a datum var access, inlines a text define. These all lower the cost of MouseEntered to some degree, though to be perfectly honest with you I really think we should be doing everything on the client side. The only reason I'm not moving screentext over there too is because there are plans to expand on screentips to be contextual, which wouldn't be possible. Though now that I think about it maybe that's not even true.... Anyway, I'm doing what I can to not change behavior for now. Really kinda cheesed about this though. * Some people are saying this (Cleans up the html a bit, tnx mothman) Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> * Optimizes MouseEntered Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> --- code/game/atoms.dm | 12 ++++++------ code/modules/status_bar/status_bar.dm | 20 -------------------- interface/skin.dmf | 3 ++- tgstation.dme | 1 - 4 files changed, 8 insertions(+), 28 deletions(-) delete mode 100644 code/modules/status_bar/status_bar.dm diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 9339b16a8fa..0c34ecf1f01 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -2106,14 +2106,14 @@ //Update the screentip to reflect what we're hoverin over /atom/MouseEntered(location, control, params) . = ..() - // Statusbar - status_bar_set_text(usr, name) // Screentips - if(usr?.hud_used) - if(!usr.hud_used.screentips_enabled || (flags_1 & NO_SCREENTIPS_1)) - usr.hud_used.screentip_text.maptext = "" + var/datum/hud/active_hud = usr.hud_used + if(active_hud) + if(!active_hud.screentips_enabled || (flags_1 & NO_SCREENTIPS_1)) + active_hud.screentip_text.maptext = "" else - usr.hud_used.screentip_text.maptext = MAPTEXT("[name]") + //We inline a MAPTEXT() here, because there's no good way to statically add to a string like this + active_hud.screentip_text.maptext = "[name]" /// Gets a merger datum representing the connected blob of objects in the allowed_types argument /atom/proc/GetMergeGroup(id, list/allowed_types) diff --git a/code/modules/status_bar/status_bar.dm b/code/modules/status_bar/status_bar.dm deleted file mode 100644 index 8e3431b5fd3..00000000000 --- a/code/modules/status_bar/status_bar.dm +++ /dev/null @@ -1,20 +0,0 @@ -/*! - * Copyright (c) 2021 Aleksej Komarov - * SPDX-License-Identifier: MIT - */ - -/client/var/status_bar_prev_text = "" - -/** - * Set status bar text for the provided `target`. - * - * Target can be either of `/client` or `/mob`. - */ -/proc/status_bar_set_text(target, text) - var/client/client = CLIENT_FROM_VAR(target) - // Stop a winset call if text didn't change. - if(!client || client.status_bar_prev_text == text) - return - client.status_bar_prev_text = text - winset(client, "mapwindow.status_bar", - "text=[url_encode(text)]&is-visible=[!!text]") diff --git a/interface/skin.dmf b/interface/skin.dmf index 168dd6eb06c..1880d4071bb 100644 --- a/interface/skin.dmf +++ b/interface/skin.dmf @@ -104,6 +104,7 @@ window "mapwindow" anchor2 = -1,-1 saved-params = "pos;size;is-minimized;is-maximized" is-pane = true + on-status = ".winset \"status_bar.text=[[*]]\" " elem "map" type = MAP pos = 0,0 @@ -121,7 +122,7 @@ window "mapwindow" pos = 0,464 size = 280x16 anchor1 = 0,100 - is-visible = false + is-visible = true text = "" align = left background-color = #222222 diff --git a/tgstation.dme b/tgstation.dme index 61a41c5833a..ee318e1766c 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -3796,7 +3796,6 @@ #include "code\modules\station_goals\dna_vault.dm" #include "code\modules\station_goals\shield.dm" #include "code\modules\station_goals\station_goal.dm" -#include "code\modules\status_bar\status_bar.dm" #include "code\modules\surgery\amputation.dm" #include "code\modules\surgery\blood_filter.dm" #include "code\modules\surgery\bone_mending.dm"