Skip to content

Commit 4bc6684

Browse files
authored
icon magic (#1029)
1 parent 7e9ee0f commit 4bc6684

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

code/_onclick/hud/hud.dm

+6
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ GLOBAL_LIST_INIT(available_ui_styles, list(
8989

9090
var/atom/movable/screen/holomap/holomap_container
9191
var/atom/movable/screen/progbar_container/use_timer
92+
var/atom/movable/screen/vis_holder/vis_holder
9293
// subtypes can override this to force a specific UI style
9394
var/ui_style
9495

@@ -126,6 +127,7 @@ GLOBAL_LIST_INIT(available_ui_styles, list(
126127
owner.overlay_fullscreen("see_through_darkness", /atom/movable/screen/fullscreen/see_through_darkness)
127128

128129
holomap_container = new(null, src)
130+
vis_holder = new(null, src)
129131

130132
RegisterSignal(mymob, COMSIG_VIEWDATA_UPDATE, PROC_REF(on_viewdata_update))
131133

@@ -159,6 +161,7 @@ GLOBAL_LIST_INIT(available_ui_styles, list(
159161
QDEL_LIST(hotkeybuttons)
160162
throw_icon = null
161163
QDEL_LIST(infodisplay)
164+
QDEL_NULL(vis_holder)
162165

163166
healths = null
164167
stamina = null
@@ -271,6 +274,9 @@ GLOBAL_LIST_INIT(available_ui_styles, list(
271274
if(holomap_container)
272275
screenmob.client.screen += holomap_container
273276

277+
if(vis_holder)
278+
screenmob.client.screen += vis_holder
279+
274280
hud_version = display_hud_version
275281
update_gunpoint(screenmob)
276282
persistent_inventory_update(screenmob)

code/_onclick/hud/screen_objects.dm

+4
Original file line numberDiff line numberDiff line change
@@ -1025,3 +1025,7 @@
10251025
// We offset them by half the size on each axis to center them.
10261026
// We need to account for this object being 32x32, so we subtract 32 from the initial 480 before dividing
10271027
screen_loc = "CENTER:-224,CENTER:-224"
1028+
1029+
/atom/movable/screen/vis_holder
1030+
icon = ""
1031+
invisibility = INVISIBILITY_MAXIMUM

code/game/objects/items/cards_ids.dm

+9-2
Original file line numberDiff line numberDiff line change
@@ -465,22 +465,29 @@
465465
. += HAS_TRAIT(src, TRAIT_JOB_FIRST_ID_CARD) ? span_boldnotice("Hmm... yes, this ID was issued from Central Command!") : span_boldnotice("This ID was created in this sector, not by Central Command.")
466466

467467
/obj/item/card/id/proc/show(mob/user)
468+
set waitfor = FALSE
469+
470+
var/atom/movable/screen/front_container = user.send_appearance(front_image)
471+
var/atom/movable/screen/side_container = user.send_appearance(side_image)
472+
468473
var/list/content = list("<table style='width:100%'><tr><td>")
469474
content += "Name: [registered_name]<br>"
470475
content += "Age: [registered_age]<br>"
471476
content += "Assignment: [assignment]<br><br>"
472477
content += "Blood Type: [blood_type]<br>"
473478
content += "Fingerprint: [fingerprint]<br>"
474479
content += "DNA Hash: [dna_hash]<br>"
480+
475481
if(front_image && side_image)
476-
content +="<td style='text-align:center; vertical-align:top'>Photo:<br><img src=\ref[front_image.appearance] height=128 width=128 border=4 style='image-rendering: pixelated;-ms-interpolation-mode: nearest-neighbor'><img src=\ref[side_image.appearance] height=128 width=128 border=4 style='image-rendering: pixelated;-ms-interpolation-mode: nearest-neighbor'></td>"
482+
content +="<td style='text-align:center; vertical-align:top'>Photo:<br><img src=\ref[front_container.appearance] height=128 width=128 border=4 style='image-rendering: pixelated;-ms-interpolation-mode: nearest-neighbor'><img src=\ref[side_container.appearance] height=128 width=128 border=4 style='image-rendering: pixelated;-ms-interpolation-mode: nearest-neighbor'></td>"
477483
content += "</tr></table>"
478484
content = jointext(content, null)
479485

480486
var/datum/browser/popup = new(user, "idcard", name, 660, 270)
481487
popup.set_content(content)
482488
popup.open()
483-
return
489+
sleep(1) // I don't know why but for some reason I need to re-send the entire UI to get it to display icons. Yes, I tried sleeping after sending the appearances.
490+
popup.open()
484491

485492
/obj/item/card/id/GetAccess()
486493
return access.Copy()

code/modules/mob/mob.dm

+24
Original file line numberDiff line numberDiff line change
@@ -1608,3 +1608,27 @@
16081608
set name = "View Skills"
16091609

16101610
mind?.print_levels(src)
1611+
1612+
/// Makes a client temporarily aware of an appearance via and invisible vis contents object.
1613+
/mob/proc/send_appearance(mutable_appearance/appearance)
1614+
RETURN_TYPE(/atom/movable/screen)
1615+
if(!hud_used || isnull(appearance))
1616+
return
1617+
1618+
var/atom/movable/screen/container
1619+
if(isatom(container))
1620+
container = appearance
1621+
else
1622+
container = new()
1623+
container.appearance = appearance
1624+
1625+
hud_used.vis_holder.vis_contents += appearance
1626+
addtimer(CALLBACK(src, PROC_REF(remove_appearance), appearance), 5 SECONDS, TIMER_DELETE_ME)
1627+
1628+
return container
1629+
1630+
/mob/proc/remove_appearance(atom/movable/appearance)
1631+
if(!hud_used)
1632+
return
1633+
1634+
hud_used.vis_holder.vis_contents -= appearance

0 commit comments

Comments
 (0)