[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>
This commit is contained in:
SkyratBot
2021-12-06 23:44:10 +01:00
committed by GitHub
parent 6eb443f00a
commit 3964e2febd
4 changed files with 8 additions and 28 deletions
+6 -6
View File
@@ -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("<span style='text-align: center'><span style='font-size: 32px'><span style='color:[usr.hud_used.screentip_color]: 32px'>[name]</span>")
//We inline a MAPTEXT() here, because there's no good way to statically add to a string like this
active_hud.screentip_text.maptext = "<span class='maptext' style='text-align: center; font-size: 32px; color: [active_hud.screentip_color]'>[name]</span>"
/// Gets a merger datum representing the connected blob of objects in the allowed_types argument
/atom/proc/GetMergeGroup(id, list/allowed_types)
-20
View File
@@ -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]")
+2 -1
View File
@@ -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
-1
View File
@@ -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"