From 0d8128ce1e53201cf5b405f87009c43a08b85a9b Mon Sep 17 00:00:00 2001 From: Geeves Date: Mon, 19 Apr 2021 18:39:02 +0200 Subject: [PATCH] Sheet Numbers (#11541) --- code/__defines/items_clothing.dm | 1 + code/_helpers/text.dm | 2 +- code/game/objects/items.dm | 31 ++++++++++++++-- code/game/objects/items/weapons/syndie.dm | 35 +++---------------- .../objects/items/weapons/teleportation.dm | 35 +++---------------- code/modules/materials/material_sheets.dm | 12 ++++--- html/changelogs/geeves-sheet_numbers.yml | 6 ++++ 7 files changed, 55 insertions(+), 67 deletions(-) create mode 100644 html/changelogs/geeves-sheet_numbers.yml diff --git a/code/__defines/items_clothing.dm b/code/__defines/items_clothing.dm index 3b16c9db8ac..3e3176bbea5 100644 --- a/code/__defines/items_clothing.dm +++ b/code/__defines/items_clothing.dm @@ -30,6 +30,7 @@ #define PHORONGUARD 0x20 // Does not get contaminated by phoron. #define NOREACT 0x40 // Reagents don't react inside this container. #define PROXMOVE 0x80 // Does this object require proximity checking in Enter()? +#define HELDMAPTEXT 0x100 // Uses the special held maptext system, which sets a specific maptext if the item is in possession of a mob. //Flags for items (equipment) #define THICKMATERIAL 0x1 // Prevents syringes, parapens and hyposprays if equiped to slot_suit or slot_head. diff --git a/code/_helpers/text.dm b/code/_helpers/text.dm index 1df208dbfcf..cb855ed3aef 100644 --- a/code/_helpers/text.dm +++ b/code/_helpers/text.dm @@ -1,4 +1,4 @@ -#define SMALL_FONTS(FONTSIZE, MSG) "[MSG]" +#define SMALL_FONTS(FONTSIZE, MSG) "[MSG]" /* * Holds procs designed to help with filtering text diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index bbc2a243923..9962fc95f85 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -92,6 +92,7 @@ var/charge_failure_message = " cannot be recharged." + var/held_maptext var/cleaving = FALSE var/reach = 1 // Length of tiles it can reach, 1 is adjacent. @@ -105,6 +106,9 @@ if(armor[type]) AddComponent(/datum/component/armor, armor) break + if(flags & HELDMAPTEXT) + set_initial_maptext() + check_maptext() /obj/item/Destroy() if(ismob(loc)) @@ -341,6 +345,8 @@ /obj/item/proc/pickup(mob/user) pixel_x = 0 pixel_y = 0 + if(flags & HELDMAPTEXT) + addtimer(CALLBACK(src, .proc/check_maptext), 1) // invoke async does not work here do_pickup_animation(user) // called when this item is removed from a storage item, which is passed on as S. The loc variable is already set to the new destination before this is called. @@ -502,8 +508,8 @@ var/list/global/slot_flags_enumeration = list( // override for give shenanigans /obj/item/proc/on_give(var/mob/giver, var/mob/receiver) - return - + if(flags & HELDMAPTEXT) + check_maptext() //This proc is executed when someone clicks the on-screen UI button. To make the UI button show, set the 'icon_action_button' to the icon_state of the image of the button in screen1_action.dmi //The default action is attack_self(). @@ -885,3 +891,24 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out. // this gets called when the item gets chucked by the vending machine /obj/item/proc/vendor_action(var/obj/machinery/vending/V) return + +/obj/item/proc/set_initial_maptext() + return + +/obj/item/proc/check_maptext(var/new_maptext) + if(new_maptext) + held_maptext = new_maptext + if(ismob(loc) || (loc && ismob(loc.loc))) + maptext = held_maptext + else + maptext = "" + +/obj/item/throw_at() + ..() + if(flags & HELDMAPTEXT) + check_maptext() + +/obj/item/dropped() + ..() + if(flags & HELDMAPTEXT) + check_maptext() \ No newline at end of file diff --git a/code/game/objects/items/weapons/syndie.dm b/code/game/objects/items/weapons/syndie.dm index 160e1eec5e4..4ac565be079 100644 --- a/code/game/objects/items/weapons/syndie.dm +++ b/code/game/objects/items/weapons/syndie.dm @@ -90,6 +90,7 @@ icon = 'icons/obj/bureaucracy.dmi' icon_state = "pen" item_state = "pen" + flags = HELDMAPTEXT slot_flags = SLOT_BELT | SLOT_EARS throwforce = 0 w_class = ITEMSIZE_TINY @@ -101,12 +102,9 @@ maptext_y = 2 var/ready_to_use = TRUE var/recharge_time = 1 MINUTE - var/held_maptext = "Ready" -/obj/item/syndie/teleporter/Initialize() - . = ..() - if(ismob(loc) || ismob(loc.loc)) - maptext = held_maptext +/obj/item/syndie/teleporter/set_initial_maptext() + held_maptext = SMALL_FONTS(7, "Ready") /obj/item/syndie/teleporter/attack() return @@ -134,34 +132,11 @@ user.visible_message("[user] appears out of thin air!", SPAN_NOTICE("You successfully step into your destination.")) use() -/obj/item/syndie/teleporter/proc/check_maptext(var/new_maptext) - if(new_maptext) - held_maptext = new_maptext - if(ismob(loc) || ismob(loc.loc)) - maptext = held_maptext - else - maptext = "" - /obj/item/syndie/teleporter/proc/use() addtimer(CALLBACK(src, .proc/recharge), recharge_time) ready_to_use = FALSE - check_maptext("Charge") + check_maptext(SMALL_FONTS(6, "Charge")) /obj/item/syndie/teleporter/proc/recharge() ready_to_use = TRUE - check_maptext("Ready") - -/obj/item/syndie/teleporter/throw_at() - ..() - check_maptext() - -/obj/item/syndie/teleporter/dropped() - ..() - check_maptext() - -/obj/item/syndie/teleporter/on_give() - check_maptext() - -/obj/item/syndie/teleporter/pickup() - ..() - addtimer(CALLBACK(src, .proc/check_maptext), 1) // invoke async does not work here + check_maptext(SMALL_FONTS(7, "Ready")) \ No newline at end of file diff --git a/code/game/objects/items/weapons/teleportation.dm b/code/game/objects/items/weapons/teleportation.dm index e0b23056fe0..395497decb5 100644 --- a/code/game/objects/items/weapons/teleportation.dm +++ b/code/game/objects/items/weapons/teleportation.dm @@ -130,18 +130,16 @@ Frequency: icon_state = "hand_tele" item_state = "electronic" throwforce = 5 + flags = HELDMAPTEXT w_class = ITEMSIZE_SMALL throw_speed = 3 throw_range = 5 origin_tech = list(TECH_MAGNET = 1, TECH_BLUESPACE = 3) matter = list(DEFAULT_WALL_MATERIAL = 10000) var/list/active_teleporters = list() - var/held_maptext = "Ready" -/obj/item/hand_tele/Initialize() - . = ..() - if(get(loc, /mob)) - maptext = held_maptext +/obj/item/hand_tele/set_initial_maptext() + held_maptext = SMALL_FONTS(7, "Ready") /obj/item/hand_tele/attack_self(mob/user) var/turf/current_location = get_turf(user)//What turf is the user on? @@ -184,36 +182,13 @@ Frequency: var/obj/effect/portal/P = new /obj/effect/portal(get_turf(src), T, src) active_teleporters += P if(length(active_teleporters) >= 3) - check_maptext("Charge") + check_maptext(SMALL_FONTS(6, "Charge")) add_fingerprint(user) /obj/item/hand_tele/proc/remove_portal(var/obj/effect/portal/P) active_teleporters -= P if(length(active_teleporters) < 3) - check_maptext("Ready") - -/obj/item/hand_tele/proc/check_maptext(var/new_maptext) - if(new_maptext) - held_maptext = new_maptext - if(ismob(loc) || ismob(loc.loc)) - maptext = held_maptext - else - maptext = "" - -/obj/item/hand_tele/throw_at() - ..() - check_maptext() - -/obj/item/hand_tele/dropped() - ..() - check_maptext() - -/obj/item/hand_tele/on_give() - check_maptext() - -/obj/item/hand_tele/pickup() - ..() - addtimer(CALLBACK(src, .proc/check_maptext), 1) // invoke async does not work here + check_maptext(SMALL_FONTS(7, "Ready")) /obj/item/closet_teleporter name = "closet teleporter" diff --git a/code/modules/materials/material_sheets.dm b/code/modules/materials/material_sheets.dm index 221857a28f3..e5637b8b771 100644 --- a/code/modules/materials/material_sheets.dm +++ b/code/modules/materials/material_sheets.dm @@ -3,6 +3,7 @@ desc_info = "Use in your hand to bring up the recipe menu. If you have enough sheets, click on something on the list to build it." force = 5 throwforce = 5 + flags = HELDMAPTEXT w_class = ITEMSIZE_NORMAL throw_speed = 3 throw_range = 3 @@ -15,16 +16,15 @@ var/apply_colour //temp pending icon rewrite var/use_material_sound = TRUE -/obj/item/stack/material/Initialize() - . = ..() +/obj/item/stack/material/Initialize(mapload, amount) + ..() randpixel_xy() if(!default_type) default_type = DEFAULT_WALL_MATERIAL material = SSmaterials.get_material_by_name(default_type) if(!material) - qdel(src) - return + return INITIALIZE_HINT_QDEL recipes = material.get_recipes() stacktype = material.stack_type @@ -43,6 +43,9 @@ flags |= CONDUCT matter = material.get_matter() + return INITIALIZE_HINT_LATELOAD + +/obj/item/stack/material/LateInitialize() update_strings() /obj/item/stack/material/get_material() @@ -60,6 +63,7 @@ name = "[material.use_name] [material.sheet_singular_name]" desc = "A [material.sheet_singular_name] of [material.use_name]." gender = NEUTER + check_maptext(SMALL_FONTS(7, amount)) /obj/item/stack/material/use(var/used) . = ..() diff --git a/html/changelogs/geeves-sheet_numbers.yml b/html/changelogs/geeves-sheet_numbers.yml new file mode 100644 index 00000000000..5c44d654086 --- /dev/null +++ b/html/changelogs/geeves-sheet_numbers.yml @@ -0,0 +1,6 @@ +author: Geeves + +delete-after: True + +changes: + - rscadd: "Material sheets now show the number of sheets left in the HUD now." \ No newline at end of file