From b48ddb99fc6381412b5a887169300097544028a4 Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Thu, 14 Nov 2019 02:56:26 +0100 Subject: [PATCH 1/4] Uplink items are now automatically sorted alphabetically. Fixed categories. --- code/__HELPERS/cmp.dm | 3 + code/__HELPERS/global_lists.dm | 10 ++ code/_globalvars/lists/objects.dm | 2 + code/modules/holiday/halloween/halloween.dm | 3 +- code/modules/uplink/uplink_items.dm | 153 +++++++++++--------- 5 files changed, 99 insertions(+), 72 deletions(-) diff --git a/code/__HELPERS/cmp.dm b/code/__HELPERS/cmp.dm index 37f36a7e0d..2e938e1e60 100644 --- a/code/__HELPERS/cmp.dm +++ b/code/__HELPERS/cmp.dm @@ -84,3 +84,6 @@ GLOBAL_VAR_INIT(cmp_field, "name") /proc/cmp_job_display_asc(datum/job/A, datum/job/B) return A.display_order - B.display_order + +/proc/cmp_uplink_items_asc(datum/uplink_item/A, datum/uplink_item/B) + return sorttext(initial(A.name), initial(B.name)) diff --git a/code/__HELPERS/global_lists.dm b/code/__HELPERS/global_lists.dm index 7852251230..05816912b0 100644 --- a/code/__HELPERS/global_lists.dm +++ b/code/__HELPERS/global_lists.dm @@ -97,6 +97,16 @@ var/datum/emote/E = new path() E.emote_list[E.key] = E + //Uplink Items + for(var/path in subtypesof(/datum/uplink_item)) + var/datum/uplink_item/I = path + if(!initial(I.item)) //We add categories to a separate list. + GLOB.uplink_categories |= initial(I.category) + continue + GLOB.uplink_items += path + //(sub)typesof entries are listed by the order they are loaded in the code, so we'll have to rearrange them here. + sortList(GLOB.uplink_items, /proc/cmp_uplink_items_asc) + init_subtypes(/datum/crafting_recipe, GLOB.crafting_recipes) //creates every subtype of prototype (excluding prototype) and adds it to list L. diff --git a/code/_globalvars/lists/objects.dm b/code/_globalvars/lists/objects.dm index 14c752613b..fa68fab85f 100644 --- a/code/_globalvars/lists/objects.dm +++ b/code/_globalvars/lists/objects.dm @@ -19,6 +19,8 @@ GLOBAL_LIST(chemical_reagents_list) //list of all /datum/reagent datums index GLOBAL_LIST_EMPTY(materials_list) //list of all /datum/material datums indexed by material id. GLOBAL_LIST_EMPTY(tech_list) //list of all /datum/tech datums indexed by id. GLOBAL_LIST_EMPTY(surgeries_list) //list of all surgeries by name, associated with their path. +GLOBAL_LIST_EMPTY(uplink_items) //list of all uplink item typepaths, ascendingly sorted by their initial name. +GLOBAL_LIST_EMPTY(uplink_categories) //list of all uplink categories, listed by the order they are loaded in code. Be careful. GLOBAL_LIST_EMPTY(crafting_recipes) //list of all table craft recipes GLOBAL_LIST_EMPTY(rcd_list) //list of Rapid Construction Devices. GLOBAL_LIST_EMPTY(apcs_list) //list of all Area Power Controller machines, separate from machines for powernet speeeeeeed. diff --git a/code/modules/holiday/halloween/halloween.dm b/code/modules/holiday/halloween/halloween.dm index 5635994a7a..e3b3564dbc 100644 --- a/code/modules/holiday/halloween/halloween.dm +++ b/code/modules/holiday/halloween/halloween.dm @@ -259,12 +259,11 @@ // Spooky Uplink Items // ///////////////////////// -/datum/uplink_item/dangerous/crossbow/candy +/datum/uplink_item/stealthy_weapons/crossbow/candy name = "Candy Corn Crossbow" desc = "A standard miniature energy crossbow that uses a hard-light projector to transform bolts into candy corn. Happy Halloween!" category = "Holiday" item = /obj/item/gun/energy/kinetic_accelerator/crossbow/halloween - cost = 12 surplus = 0 /datum/uplink_item/device_tools/emag/hack_o_lantern diff --git a/code/modules/uplink/uplink_items.dm b/code/modules/uplink/uplink_items.dm index 280740688e..3591264cdc 100644 --- a/code/modules/uplink/uplink_items.dm +++ b/code/modules/uplink/uplink_items.dm @@ -1,13 +1,9 @@ -GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item)) - -/proc/get_uplink_items(var/datum/game_mode/gamemode = null, allow_sales = TRUE, allow_restricted = TRUE) - var/list/filtered_uplink_items = list() +/proc/get_uplink_items(datum/game_mode/gamemode, allow_sales = TRUE, allow_restricted = TRUE) + var/list/filtered_uplink_items = GLOB.uplink_categories.Copy() // list of uplink categories without associated values. var/list/sale_items = list() for(var/path in GLOB.uplink_items) var/datum/uplink_item/I = new path - if(!I.item) - continue if(I.include_modes.len) if(!gamemode && SSticker.mode && !(SSticker.mode.type in I.include_modes)) continue @@ -23,9 +19,8 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item)) if (I.restricted && !allow_restricted) continue - if(!filtered_uplink_items[I.category]) - filtered_uplink_items[I.category] = list() - filtered_uplink_items[I.category][I.name] = I + LAZYSET(filtered_uplink_items[I.category], I.name, I) + if(I.limited_stock < 0 && !I.cant_discount && I.item && I.cost > 1) sale_items += I if(allow_sales) @@ -45,9 +40,12 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item)) A.desc += " Normally costs [initial(A.cost)] TC. All sales final. [pick(disclaimer)]" A.item = I.item - if(!filtered_uplink_items[A.category]) - filtered_uplink_items[A.category] = list() - filtered_uplink_items[A.category][A.name] = A + LAZYSET(filtered_uplink_items[A.category], A.name, A) + + for(var/category in filtered_uplink_items) + if(!filtered_uplink_items[category]) //empty categories with no associated uplink item. Remove. + filtered_uplink_items -= category + return filtered_uplink_items @@ -106,16 +104,77 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item)) to_chat(user, "[A] materializes onto the floor.") return A -//Discounts (dynamically filled above) -/datum/uplink_item/discounts - category = "Discounted Gear" +/* + Uplink Categories: + Due to how the typesof() in-built byond proc works, it should be kept in mind + the order categories are displayed in the uplink UI is same to the order they are loaded in the code. + I trust no extra filter is needed as long as all they are contained within the following lines. + When adding new uplink categories, please keep them separate from their sub paths here and without set item. + Failure to comply may result in the new categories being listed at the bottom of the UI. +*/ + +/datum/uplink_item/holiday + category = "Holiday" -//All bundles and telecrystals /datum/uplink_item/bundles_TC category = "Bundles and Telecrystals" surplus = 0 cant_discount = TRUE +/datum/uplink_item/dangerous + category = "Conspicuous and Dangerous Weapons" + +/datum/uplink_item/stealthy_weapons + category = "Stealthy and Inconspicuous Weapons" + +/datum/uplink_item/ammo + category = "Ammunition" + surplus = 40 + +/datum/uplink_item/explosives + category = "Grenades and Explosives" + +/datum/uplink_item/support + category = "Support and Mechanized Exosuits" + surplus = 0 + include_modes = list(/datum/game_mode/nuclear) + +/datum/uplink_item/suits + category = "Space Suits, Hardsuits and Clothing" + surplus = 40 + +/datum/uplink_item/stealthy_tools + category = "Stealth and Camouflage Items" + +/datum/uplink_item/device_tools + category = "Devices and Tools" + +/datum/uplink_item/implants + category = "Implants" + surplus = 50 + +/datum/uplink_item/role_restricted + category = "Role-Restricted" + exclude_modes = list(/datum/game_mode/nuclear, /datum/game_mode/nuclear/clown_ops) + surplus = 0 + +/datum/uplink_item/badass + category = "(Pointless) Badassery" + surplus = 0 + +//Discounts (dynamically filled above) +/datum/uplink_item/discounts + category = "Discounted Gear" + + +/* + Uplink Items: + Unlike categories, uplink item entries are automatically sorted alphabetically on server init in a global list, + When adding new entries to the file, please keep them sorted by category. +*/ + +//All bundles and telecrystals + /datum/uplink_item/bundles_TC/chemical name = "Bioterror bundle" desc = "For the madman: Contains a handheld Bioterror chem sprayer, a Bioterror foam grenade, a box of lethal chemicals, a dart pistol, \ @@ -288,8 +347,6 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item)) cost = 20 // Dangerous Items -/datum/uplink_item/dangerous - category = "Conspicuous and Dangerous Weapons" /datum/uplink_item/dangerous/pistol name = "Stechkin Pistol" @@ -544,8 +601,6 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item)) surplus = 10 // Stealthy Weapons -/datum/uplink_item/stealthy_weapons - category = "Stealthy and Inconspicuous Weapons" /datum/uplink_item/stealthy_weapons/combatglovesplus name = "Combat Gloves Plus" @@ -564,12 +619,6 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item)) cost = 13 surplus = 0 -/datum/uplink_item/dangerous/phantomthief - name = "Syndicate Mask" - desc = "A cheap plastic mask fitted with an adrenaline autoinjector, which can be used by simply tensing your muscles" - item = /obj/item/clothing/glasses/phantomthief/syndicate - cost = 2 - /datum/uplink_item/stealthy_weapons/dart_pistol name = "Dart Pistol" desc = "A miniaturized version of a normal syringe gun. It is very quiet when fired and can fit into any \ @@ -671,9 +720,6 @@ datum/uplink_item/stealthy_weapons/taeclowndo_shoes cost = 6 // Ammunition -/datum/uplink_item/ammo - category = "Ammunition" - surplus = 40 /datum/uplink_item/ammo/pistol name = "10mm Handgun Magazine" @@ -917,8 +963,7 @@ datum/uplink_item/stealthy_weapons/taeclowndo_shoes cost = 1 include_modes = list(/datum/game_mode/nuclear) -/datum/uplink_item/explosives - category = "Grenades and Explosives" +//Grenades and Explosives /datum/uplink_item/explosives/bioterrorfoam name = "Bioterror Foam Grenade" @@ -1075,10 +1120,6 @@ datum/uplink_item/stealthy_weapons/taeclowndo_shoes //Support and Mechs -/datum/uplink_item/support - category = "Support and Mechanized Exosuits" - surplus = 0 - include_modes = list(/datum/game_mode/nuclear) /datum/uplink_item/support/clown_reinforcement name = "Clown Reinforcements" @@ -1139,8 +1180,6 @@ datum/uplink_item/stealthy_weapons/taeclowndo_shoes cost = 140 // Stealth Items -/datum/uplink_item/stealthy_tools - category = "Stealth and Camouflage Items" /datum/uplink_item/stealthy_tools/agent_card name = "Agent Identification Card" @@ -1250,17 +1289,6 @@ datum/uplink_item/stealthy_weapons/taeclowndo_shoes item = /obj/item/jammer cost = 5 -/*/datum/uplink_item/stealthy_tools/syndi_borer - name = "Syndicate Brain Slug" - desc = "A small cortical borer, modified to be completely loyal to the owner. \ - Genetically infertile, these brain slugs can assist medically in a support role, or take direct action \ - to assist their host." - item = /obj/item/antag_spawner/syndi_borer - refundable = TRUE - cost = 10 - surplus = 20 //Let's not have this be too common - exclude_modes = list(/datum/game_mode/nuclear) */ - /datum/uplink_item/stealthy_tools/smugglersatchel name = "Smuggler's Satchel" desc = "This satchel is thin enough to be hidden in the gap between plating and tiling; great for stashing \ @@ -1271,9 +1299,6 @@ datum/uplink_item/stealthy_weapons/taeclowndo_shoes surplus = 30 //Space Suits and Hardsuits -/datum/uplink_item/suits - category = "Space Suits, Hardsuits and Clothing" - surplus = 40 /datum/uplink_item/suits/turtlenck name = "Tactical Turtleneck" @@ -1348,8 +1373,6 @@ datum/uplink_item/stealthy_weapons/taeclowndo_shoes exclude_modes = list() // Devices and Tools -/datum/uplink_item/device_tools - category = "Devices and Tools" /datum/uplink_item/device_tools/emag name = "Cryptographic Sequencer" @@ -1364,6 +1387,12 @@ datum/uplink_item/stealthy_weapons/taeclowndo_shoes item = /obj/item/emagrecharge cost = 2 +/datum/uplink_item/device_tools/phantomthief + name = "Syndicate Mask" + desc = "A cheap plastic mask fitted with an adrenaline autoinjector, which can be used by simply tensing your muscles" + item = /obj/item/clothing/glasses/phantomthief/syndicate + cost = 2 + /datum/uplink_item/device_tools/cutouts name = "Adaptive Cardboard Cutouts" desc = "These cardboard cutouts are coated with a thin material that prevents discoloration and makes the images on them appear more lifelike. \ @@ -1583,9 +1612,6 @@ datum/uplink_item/stealthy_weapons/taeclowndo_shoes // Implants -/datum/uplink_item/implants - category = "Implants" - surplus = 50 /datum/uplink_item/implants/adrenal name = "Adrenal Implant" @@ -1682,10 +1708,6 @@ datum/uplink_item/stealthy_weapons/taeclowndo_shoes include_modes = list(/datum/game_mode/nuclear) // Role-specific items -/datum/uplink_item/role_restricted - category = "Role-Restricted" - exclude_modes = list(/datum/game_mode/nuclear, /datum/game_mode/nuclear/clown_ops) - surplus = 0 /datum/uplink_item/role_restricted/ancient_jumpsuit name = "Ancient Jumpsuit" @@ -1898,10 +1920,7 @@ datum/uplink_item/stealthy_weapons/taeclowndo_shoes item = /obj/item/gun/energy/emitter restricted_roles = list("Chief Engineer", "Station Engineer", "Atmospheric Technician") -// Pointless -/datum/uplink_item/badass - category = "(Pointless) Badassery" - surplus = 0 +// Pointless (Badassery) /datum/uplink_item/badass/costumes/obvious_chameleon name = "Broken Chameleon Kit" @@ -1955,12 +1974,6 @@ datum/uplink_item/stealthy_weapons/taeclowndo_shoes item = /obj/item/storage/secure/briefcase/syndie cost = 1 -/datum/uplink_item/badass/phantomthief - name = "Syndicate Mask" - desc = "A cheap plastic mask fitted with an adrenaline autoinjector, which can be used by simply tensing your muscles" - item = /obj/item/clothing/glasses/phantomthief/syndicate - cost = 2 - /datum/uplink_item/badass/syndiecards name = "Syndicate Playing Cards" desc = "A special deck of space-grade playing cards with a mono-molecular edge and metal reinforcement, \ From a7b6443217d070a8a71cebf2f408c46e1ccc3291 Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Thu, 14 Nov 2019 03:20:43 +0100 Subject: [PATCH 2/4] typo. --- code/modules/uplink/uplink_items.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/uplink/uplink_items.dm b/code/modules/uplink/uplink_items.dm index 3591264cdc..ba29d3a069 100644 --- a/code/modules/uplink/uplink_items.dm +++ b/code/modules/uplink/uplink_items.dm @@ -108,7 +108,7 @@ Uplink Categories: Due to how the typesof() in-built byond proc works, it should be kept in mind the order categories are displayed in the uplink UI is same to the order they are loaded in the code. - I trust no extra filter is needed as long as all they are contained within the following lines. + I trust no extra filter is needed as long as they are all contained within the following lines. When adding new uplink categories, please keep them separate from their sub paths here and without set item. Failure to comply may result in the new categories being listed at the bottom of the UI. */ From 3cc0207e73297fbff8cb9313db6c21f4a9519da2 Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Fri, 22 Nov 2019 01:04:39 +0100 Subject: [PATCH 3/4] Ready for merge. --- code/__HELPERS/cmp.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/__HELPERS/cmp.dm b/code/__HELPERS/cmp.dm index 123dfb8cf9..87f3a32b0d 100644 --- a/code/__HELPERS/cmp.dm +++ b/code/__HELPERS/cmp.dm @@ -85,8 +85,8 @@ GLOBAL_VAR_INIT(cmp_field, "name") /proc/cmp_job_display_asc(datum/job/A, datum/job/B) return A.display_order - B.display_order -/proc/cmp_uplink_items_asc(datum/uplink_item/A, datum/uplink_item/B) - return sorttext(initial(A.name), initial(B.name)) +/proc/cmp_uplink_items_dsc(datum/uplink_item/A, datum/uplink_item/B) + return sorttext(initial(B.name), initial(A.name)) /proc/cmp_numbered_displays_name_asc(datum/numbered_display/A, datum/numbered_display/B) return sorttext(A.sample_object.name, B.sample_object.name) From 9f6d595ad58aad2cba114cc3d1b73d622b95ee74 Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Fri, 22 Nov 2019 05:08:58 +0100 Subject: [PATCH 4/4] Ouch --- code/__HELPERS/global_lists.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/__HELPERS/global_lists.dm b/code/__HELPERS/global_lists.dm index 4cfbd6a510..a7bf5da17f 100644 --- a/code/__HELPERS/global_lists.dm +++ b/code/__HELPERS/global_lists.dm @@ -105,7 +105,7 @@ continue GLOB.uplink_items += path //(sub)typesof entries are listed by the order they are loaded in the code, so we'll have to rearrange them here. - GLOB.uplink_items = sortList(GLOB.uplink_items, /proc/cmp_uplink_items_asc) + GLOB.uplink_items = sortList(GLOB.uplink_items, /proc/cmp_uplink_items_dsc) init_subtypes(/datum/crafting_recipe, GLOB.crafting_recipes)