Skip to content

Implements ma2html (goodbye icon2html) #6654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

GLOBAL_VAR_INIT(magic_appearance_detecting_image, new /image) // appearances are awful to detect safely, but this seems to be the best way ~ninjanomnom
#define isappearance(thing) (!isimage(thing) && !ispath(thing) && istype(GLOB.magic_appearance_detecting_image, thing))
#define isappearance_or_image(thing) (isimage(thing) || (!ispath(thing) && istype(GLOB.magic_appearance_detecting_image, thing)))

// The filters list has the same ref type id as a filter, but isnt one and also isnt a list, so we have to check if the thing has Cut() instead
GLOBAL_VAR_INIT(refid_filter, TYPEID(filter(type="angular_blur")))
Expand Down
6 changes: 4 additions & 2 deletions code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,8 @@ GLOBAL_LIST_EMPTY(icon_dimensions)

/// Strips all underlays on a different plane from an appearance.
/// Returns the stripped appearance.
/proc/strip_appearance_underlays(mutable_appearance/appearance)
/proc/strip_appearance_underlays(mutable_appearance/appearance) as /mutable_appearance
RETURN_TYPE(/mutable_appearance)
var/base_plane = PLANE_TO_TRUE(appearance.plane)
for(var/mutable_appearance/underlay as anything in appearance.underlays)
if(isnull(underlay))
Expand All @@ -1551,7 +1552,8 @@ GLOBAL_LIST_EMPTY(icon_dimensions)
* Filters out certain overlays from the copy, depending on their planes
* Prevents stuff like lighting from being copied to the new appearance
*/
/proc/copy_appearance_filter_overlays(appearance_to_copy)
/proc/copy_appearance_filter_overlays(appearance_to_copy) as /mutable_appearance
RETURN_TYPE(/mutable_appearance)
var/mutable_appearance/copy = new(appearance_to_copy)
var/static/list/plane_whitelist = list(FLOAT_PLANE, GAME_PLANE, FLOOR_PLANE)

Expand Down
8 changes: 8 additions & 0 deletions code/_onclick/hud/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ GLOBAL_LIST_INIT(available_ui_styles, list(

var/list/atom/movable/screen/cybernetics/ammo_counter/cybernetics_ammo = list() //monkestation edit - CYBERNETICS

var/atom/movable/screen/vis_holder/vis_holder

// subtypes can override this to force a specific UI style
var/ui_style

Expand Down Expand Up @@ -144,6 +146,8 @@ GLOBAL_LIST_INIT(available_ui_styles, list(
RegisterSignal(mymob, COMSIG_VIEWDATA_UPDATE, PROC_REF(on_viewdata_update))
update_sightflags(mymob, mymob.sight, NONE)

vis_holder = new(null, src)

/datum/hud/proc/client_refresh(datum/source)
SIGNAL_HANDLER
var/client/client = mymob.canon_client
Expand Down Expand Up @@ -236,6 +240,7 @@ GLOBAL_LIST_INIT(available_ui_styles, list(
QDEL_LIST(hotkeybuttons)
throw_icon = null
QDEL_LIST(infodisplay)
QDEL_NULL(vis_holder)

healths = null
stamina = null
Expand Down Expand Up @@ -385,6 +390,9 @@ GLOBAL_LIST_INIT(available_ui_styles, list(
if(always_visible_inventory.len)
screenmob.client.screen += always_visible_inventory

if(vis_holder)
screenmob.client.screen += vis_holder

hud_version = display_hud_version
persistent_inventory_update(screenmob)
// Gives all of the actions the screenmob owes to their hud
Expand Down
4 changes: 4 additions & 0 deletions code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,10 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/splash)
add_overlay(intent_icon)
return ..()

/atom/movable/screen/vis_holder
icon = ""
invisibility = INVISIBILITY_MAXIMUM

/atom/movable/screen/stamina
name = "stamina"
icon_state = "stamina0"
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/polling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ SUBSYSTEM_DEF(polling)
// monkestation end
var/surrounding_icon
if(surrounding_image)
surrounding_icon = icon2html(surrounding_image, candidate_mob, extra_classes = "bigicon")
surrounding_icon = ma2html(surrounding_image, candidate_mob, extra_classes = "bigicon")
var/final_message = boxed_message("<span style='text-align:center;display:block'>[surrounding_icon] <span style='font-size:1.2em'>[span_ooc(question)]</span> [surrounding_icon]\n[act_jump] [act_signup] [act_never]</span>")
to_chat(candidate_mob, final_message)

Expand Down
2 changes: 1 addition & 1 deletion code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@

///Generate the full examine string of this atom (including icon for goonchat)
/atom/proc/get_examine_string(mob/user, thats = FALSE)
return "[icon2html(src, user)] [thats? "That's ":""][get_examine_name(user)]"
return "[ma2html(src, user)] [thats? "That's ":""][get_examine_name(user)]"

/**
* Returns an extended list of examine strings for any contained ID cards.
Expand Down
8 changes: 4 additions & 4 deletions code/modules/mob/living/carbon/examine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
var/t_has = p_have()
var/t_is = p_are()

. = list("<span class='info'>This is [icon2html(src, user)] \a <EM>[src]</EM>!")
. = list("<span class='info'>This is [ma2html(src, user)] \a <EM>[src]</EM>!")
var/obscured = check_obscured_slots()

if (handcuffed)
. += span_warning("[t_He] [t_is] [icon2html(handcuffed, user)] handcuffed!")
. += span_warning("[t_He] [t_is] [ma2html(handcuffed, user)] handcuffed!")
if (head)
. += "[t_He] [t_is] wearing [head.get_examine_string(user)] on [t_his] head. "
if(wear_mask && !(obscured & ITEM_SLOT_MASK))
Expand Down Expand Up @@ -45,13 +45,13 @@
var/stuck_or_embedded = "embedded in"
if(leftover.isEmbedHarmless())
stuck_or_embedded = "stuck to"
msg += "<b>[t_He] [t_has] [icon2html(leftover, user)] \a [leftover] [stuck_or_embedded] [t_his] [body_part.plaintext_zone]!</b>\n"
msg += "<b>[t_He] [t_has] [ma2html(leftover, user)] \a [leftover] [stuck_or_embedded] [t_his] [body_part.plaintext_zone]!</b>\n"

if(body_part.current_gauze)
var/gauze_href = body_part.current_gauze.name
if(adjacent && isliving(user)) // only shows the href if we're adjacent
gauze_href = "<a href='byond://?src=[REF(src)];gauze_limb=[REF(body_part)]'>[gauze_href]</a>"
msg += span_notice("There is some [icon2html(body_part.current_gauze, user)] [gauze_href] wrapped around [t_his] [body_part.plaintext_zone].\n")
msg += span_notice("There is some [ma2html(body_part.current_gauze, user)] [gauze_href] wrapped around [t_his] [body_part.plaintext_zone].\n")

for(var/datum/wound/iter_wound as anything in body_part.wounds)
msg += "[iter_wound.get_examine_description(user)]\n"
Expand Down
40 changes: 40 additions & 0 deletions code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1582,3 +1582,43 @@
/mob/key_down(key, client/client, full_key)
..()
SEND_SIGNAL(src, COMSIG_MOB_KEYDOWN, key, client, full_key)

/// Makes a client temporarily aware of an appearance via and invisible vis contents object.
/mob/proc/send_appearance(mutable_appearance/appearance) as /atom/movable/screen
RETURN_TYPE(/atom/movable/screen)
if(!hud_used || isnull(appearance))
return

var/atom/movable/screen/container = new
container.appearance = appearance

hud_used.vis_holder.vis_contents += container
addtimer(CALLBACK(src, PROC_REF(remove_appearance), container), 5 SECONDS, TIMER_DELETE_ME)

return container

/mob/proc/remove_appearance(atom/movable/container)
if(!hud_used)
return

hud_used.vis_holder.vis_contents -= container

/proc/ma2html(mutable_appearance/appearance, mob/viewer, extra_classes = "")
if(isatom(appearance))
var/atom/atom = appearance
appearance = copy_appearance_filter_overlays(atom.appearance)
else if(isappearance_or_image(appearance))
appearance = copy_appearance_filter_overlays(appearance)
else
CRASH("Invalid appearance passed to ma2html - either a appearance, image, or atom must be passed!")

if(IS_CLIENT_OR_MOCK(viewer))
var/datum/client_interface/client = viewer
viewer = client.mob
if(!ismob(viewer))
CRASH("Invalid viewer passed to ma2html")
var/atom/movable/screen/container = viewer.send_appearance(appearance)
if(QDELETED(container))
CRASH("Failed to send appearance to client")
return "<img class='icon [extra_classes]' src='\ref[container]' style='image-rendering: pixelated; -ms-interpolation-mode: nearest-neighbor'>"

Loading