Skip to content

Commit

Permalink
icon magic (#1029)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kapu1178 committed Aug 5, 2024
1 parent 7e9ee0f commit 4bc6684
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
6 changes: 6 additions & 0 deletions code/_onclick/hud/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ GLOBAL_LIST_INIT(available_ui_styles, list(

var/atom/movable/screen/holomap/holomap_container
var/atom/movable/screen/progbar_container/use_timer
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 @@ -126,6 +127,7 @@ GLOBAL_LIST_INIT(available_ui_styles, list(
owner.overlay_fullscreen("see_through_darkness", /atom/movable/screen/fullscreen/see_through_darkness)

holomap_container = new(null, src)
vis_holder = new(null, src)

RegisterSignal(mymob, COMSIG_VIEWDATA_UPDATE, PROC_REF(on_viewdata_update))

Expand Down Expand Up @@ -159,6 +161,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 @@ -271,6 +274,9 @@ GLOBAL_LIST_INIT(available_ui_styles, list(
if(holomap_container)
screenmob.client.screen += holomap_container

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

hud_version = display_hud_version
update_gunpoint(screenmob)
persistent_inventory_update(screenmob)
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 @@ -1025,3 +1025,7 @@
// We offset them by half the size on each axis to center them.
// We need to account for this object being 32x32, so we subtract 32 from the initial 480 before dividing
screen_loc = "CENTER:-224,CENTER:-224"

/atom/movable/screen/vis_holder
icon = ""
invisibility = INVISIBILITY_MAXIMUM
11 changes: 9 additions & 2 deletions code/game/objects/items/cards_ids.dm
Original file line number Diff line number Diff line change
Expand Up @@ -465,22 +465,29 @@
. += 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.")

/obj/item/card/id/proc/show(mob/user)
set waitfor = FALSE

var/atom/movable/screen/front_container = user.send_appearance(front_image)
var/atom/movable/screen/side_container = user.send_appearance(side_image)

var/list/content = list("<table style='width:100%'><tr><td>")
content += "Name: [registered_name]<br>"
content += "Age: [registered_age]<br>"
content += "Assignment: [assignment]<br><br>"
content += "Blood Type: [blood_type]<br>"
content += "Fingerprint: [fingerprint]<br>"
content += "DNA Hash: [dna_hash]<br>"

if(front_image && side_image)
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>"
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>"
content += "</tr></table>"
content = jointext(content, null)

var/datum/browser/popup = new(user, "idcard", name, 660, 270)
popup.set_content(content)
popup.open()
return
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.
popup.open()

/obj/item/card/id/GetAccess()
return access.Copy()
Expand Down
24 changes: 24 additions & 0 deletions code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1608,3 +1608,27 @@
set name = "View Skills"

mind?.print_levels(src)

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

var/atom/movable/screen/container
if(isatom(container))
container = appearance
else
container = new()
container.appearance = appearance

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

return container

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

hud_used.vis_holder.vis_contents -= appearance

0 comments on commit 4bc6684

Please sign in to comment.