Storage Fix 2, Featuring Maths (#20535)

I had to unironically bust out my pen and paper for this bullshit and
magnifying tool to actually check if things were pixel perfect.

- bugfix: "Fixes storage box alignment and storage space UI to use
better maths."
- qol: "Tweaks IDs, IDs and firing pins now rotate 90 degrees when in
storage for easier clickability."
  - bugfix: "Fixes Item Tooltip toggle message."
- bugfix: "Fixes roundstart items in storage not showing item outlines."

Fixes #20529

---------

Signed-off-by: Wowzewow (Wezzy) <42310821+alsoandanswer@users.noreply.github.com>
Co-authored-by: Fluffy <65877598+FluffyGhoster@users.noreply.github.com>
This commit is contained in:
Wowzewow (Wezzy)
2025-03-02 22:02:54 +00:00
committed by GitHub
co-authored by Fluffy
parent a217abf9ba
commit c46e21595b
15 changed files with 163 additions and 58 deletions
+45 -24
View File
@@ -26,6 +26,29 @@
drop_sound = 'sound/items/drop/card.ogg'
pickup_sound = 'sound/items/pickup/card.ogg'
/obj/item/card/Initialize()
. = ..()
update_icon()
/obj/item/card/pickup(mob/user)
..()
update_icon()
/obj/item/card/dropped(mob/user)
..()
update_icon()
/obj/item/card/attack_hand()
..()
update_icon()
/obj/item/card/update_icon()
var/matrix/tf = matrix()
if(istype(loc, /obj/item/storage))
tf.Turn(-90) //Vertical for storing compactly
tf.Translate(-1, 0) //Could do this with pixel_x but let's just update the appearance once.
transform = tf
/obj/item/card/data
name = "data disk"
desc = "A disk of data."
@@ -391,32 +414,12 @@
access = get_all_station_access() | get_all_centcom_access()
..()
// SCC ID cards
/obj/item/card/id/scc
desc = "A high-tech holocard displaying the credentials of a SCC employee."
icon_state = "bridge_card"
/obj/item/card/id/scc/bridge
desc = "A high-tech holocard displaying the lowly credentials of a SCC bridge crewman."
icon_state = "bridge_card"
/obj/item/card/id/scc/silver
desc = "A high-tech holocard displaying the credentials of a SCC command member."
icon_state = "command_card"
/obj/item/card/id/scc/gold
desc = "A high-tech holocard displaying the intimidating credentials of a SCC employee."
icon_state = "captain_card"
/obj/item/card/id/scc/gold/captain
desc = "A high-tech holocard displaying the commanding credentials of a SCC captain."
icon_state = "captain_card"
/obj/item/card/id/captains_spare
name = "captain's spare identification card"
desc = "A captain's spare identification card."
icon_state = "captain_card"
icon_state = "gold"
item_state = "gold_id"
overlay_state = "gold"
registered_name = "Captain"
assignment = "Captain"
@@ -478,12 +481,15 @@
/obj/item/card/id/ccia
name = "\improper CentCom. Internal Affairs identification card"
desc = "A high-tech holocard displaying the blood-chilling credentials of an Internal Affairs agent."
desc = "A synthleather ID displaying the blood-chilling credentials of an Internal Affairs agent."
icon_state = "ccia"
overlay_state = "ccia"
drop_sound = /singleton/sound_category/generic_drop_sound
pickup_sound = /singleton/sound_category/generic_pickup_sound
/obj/item/card/id/ccia/update_icon()
return
/obj/item/card/id/ccia/id_flash(var/mob/user)
var/add_text = "Done with prejudice and professionalism, [user.get_pronoun("he")] means business."
var/blind_add_text = "Done with prejudice and professionalism, you mean business."
@@ -557,6 +563,9 @@
icon_state = "pmc_card"
overlay_state = "pmc_card"
/obj/item/card/distress/ap_eridani/update_icon()
return
/obj/item/card/id/distress/ap_eridani/New()
access = get_distress_access()
..()
@@ -591,6 +600,9 @@
icon_state = "idris_card"
overlay_state = "idris_card"
/obj/item/card/id/idris/update_icon()
return
/obj/item/card/id/idris/sec
icon_state = "idrissec_card"
overlay_state = "idrissec_card"
@@ -601,18 +613,27 @@
icon_state = "iru_card"
overlay_state = "iru_card"
/obj/item/card/id/iru/update_icon()
return
/obj/item/card/id/pmc
name = "\improper PMCG identification card"
desc = "A high-tech holobadge, identifying the owner as a contractor from one of the many PMCs from the Private Military Contracting Group."
icon_state = "pmc_card"
overlay_state = "pmc_card"
/obj/item/card/id/pmc/update_icon()
return
/obj/item/card/id/zeng_hu
name = "\improper Zeng-Hu Pharmaceuticals identification card"
desc = "A synthleather card, belonging to one of the highly skilled members of Zeng-Hu."
icon_state = "zhu_card"
overlay_state = "zhu_card"
/obj/item/card/zeng_hu/update_icon()
return
/obj/item/card/id/hephaestus
name = "\improper Hephaestus Industries identification card"
desc = "A metal-backed card, belonging to the powerful Hephaestus Industries."
@@ -357,11 +357,11 @@
/obj/item/storage/proc/slot_orient_objs(var/rows, var/cols, var/list/obj/item/display_contents)
var/cx = 4
var/cy = 2+rows
src.boxes.screen_loc = "4:16,2:16 to [4+cols]:16,[2+rows]:16"
src.boxes.screen_loc = "4:12,2:16 to [4+cols]:16,[2+rows]:16"
if(display_contents_with_number)
for(var/datum/numbered_display/ND in display_contents)
ND.sample_object.screen_loc = "[cx]:16,[cy]:16"
ND.sample_object.screen_loc = "[cx]:12,[cy]:16"
ND.sample_object.maptext = SMALL_FONTS(7, "[(ND.number > 1)? "[ND.number]" : ""]")
ND.sample_object.hud_layerise()
if(display_contents_initials)
@@ -377,14 +377,14 @@
cy--
else
for(var/obj/O in contents)
O.screen_loc = "[cx]:16,[cy]:16"
O.screen_loc = "[cx]:12,[cy]:16"
O.maptext = ""
O.hud_layerise()
cx++
if (cx > (4+cols))
cx = 4
cy--
closer.screen_loc = "[4+cols+1]:16,2:16"
closer.screen_loc = "[4+cols+1]:12,2:16"
/obj/item/storage/proc/handle_name_initials(var/sample_name)
var/name_initials = ""
@@ -395,32 +395,33 @@
/obj/item/storage/proc/space_orient_objs(list/obj/item/display_contents, defer_overlays = FALSE)
// Don't touch these numbers. This works on literal pixel measurements. Unless you want to fix this shit.
var/baseline_max_storage_space = DEFAULT_BACKPACK_STORAGE //should be equal to default backpack capacity
// Don't touch these numbers. This works on literal pixel measurements. Unless you want to fix this shit or change the sprites.
var/storage_cap_width = 2 //length of sprite for start and end of the box representing total storage space
var/stored_cap_width = 4 //length of sprite for start and end of the box representing the stored item
var/storage_width = min(round(DEFAULT_BACKPACK_STORAGE*8*max_storage_space/baseline_max_storage_space ,1) , DEFAULT_BACKPACK_STORAGE*10) //length of sprite for the box representing total storage space
var/storage_width = (1+stored_cap_width*2)*max_storage_space - 1 //length of sprite for the box representing total storage space, -1px. because no spacing on left for first item.
storage_start.ClearOverlays()
var/matrix/M = matrix()
M.Scale((storage_width-storage_cap_width*2+11)/32,1)
M.Scale(storage_width / 32,1)
storage_continue.transform = M
storage_start.screen_loc = "4:16,2:16"
storage_continue.screen_loc = "4:[round(storage_cap_width+(storage_width-storage_cap_width*2)/2+6)],2:16"
storage_end.screen_loc = "4:[27+storage_width-storage_cap_width],2:16"
storage_start.screen_loc = "4:12,2:16"
storage_continue.screen_loc = "4:[12 - 16 + round((storage_width + storage_cap_width*2) / 2, 1)],2:16" // -16 to center the sprite, since we're 32x32
storage_end.screen_loc = "4:[12 + storage_cap_width + storage_width],2:16"
var/startpoint = 0
var/endpoint = 1
var/stored_width = 0
var/endpoint = 0 - storage_cap_width - 1
storage_start.vis_contents = list()
QDEL_LIST(storage_screens)
storage_screens = list()
for(var/obj/item/O in contents)
startpoint = endpoint + 1
endpoint = startpoint + storage_width * O.get_storage_cost()/max_storage_space
startpoint = endpoint + stored_cap_width + 1
stored_width = (9*O.get_storage_cost()-9)
endpoint = startpoint + stored_width + stored_cap_width
var/atom/movable/screen/storage/background/stored_start = new /atom/movable/screen/storage/background(null, O, "stored_start")
var/matrix/M_start = matrix()
@@ -429,26 +430,26 @@
var/atom/movable/screen/storage/background/stored_continue = new /atom/movable/screen/storage/background(null, O, "stored_continue")
var/matrix/M_continue = matrix()
M_continue.Scale((endpoint-startpoint-stored_cap_width*2)/32,1)
M_continue.Translate(startpoint+stored_cap_width+(endpoint-startpoint-stored_cap_width*2)/2 - 16,0)
M_continue.Scale(stored_width / 32, 1)
M_continue.Translate(startpoint - 16 + ((stored_width + stored_cap_width*2) / 2), 0) // -16 to center the sprite, since we're 32x32
stored_continue.transform = M_continue
var/atom/movable/screen/storage/background/stored_end = new /atom/movable/screen/storage/background(null, O, "stored_end")
var/matrix/M_end = matrix()
M_end.Translate(endpoint-stored_cap_width, 0)
M_end.Translate(endpoint, 0)
stored_end.transform = M_end
storage_screens += list(stored_start, stored_continue, stored_end)
storage_start.add_vis_contents(list(stored_start, stored_continue, stored_end))
O.screen_loc = "4:[round((startpoint+endpoint)/2)],2:16"
O.screen_loc = "4:[startpoint + round(stored_width/2)],2:16"
O.maptext = ""
O.hud_layerise()
if (!defer_overlays)
storage_start.UpdateOverlays()
closer.screen_loc = "4:[storage_width+27],2:16"
closer.screen_loc = "4:[12+storage_width+storage_cap_width*2],2:16"
return
/datum/numbered_display
@@ -829,6 +830,9 @@
fill()
for(var/obj/item/I in contents)
I.in_storage = TRUE
if(!allow_quick_empty)
verbs -= /obj/item/storage/verb/quick_empty
+1
View File
@@ -156,6 +156,7 @@
if(build_from_parts)
color = pick(color_options)
AddOverlays(overlay_image(icon, "[initial(icon_state)]_[worn_overlay]", flags=RESET_COLOR))
update_icon()
/obj/item/wirecutters/update_icon()
var/matrix/tf = matrix()