From c15d0de20d61e0bd1350ca30a8b095df9df6c550 Mon Sep 17 00:00:00 2001 From: timothyteakettle <59849408+timothyteakettle@users.noreply.github.com> Date: Wed, 29 Jul 2020 03:57:16 +0100 Subject: [PATCH] subcategories work --- code/__DEFINES/loadout.dm | 1 - code/_globalvars/lists/loadout_categories.dm | 13 +++++ code/modules/client/preferences.dm | 53 ++++++++++++------- .../code/modules/client/loadout/__donator.dm | 2 +- .../code/modules/client/loadout/_loadout.dm | 12 ++--- .../code/modules/client/loadout/_medical.dm | 2 - .../code/modules/client/loadout/backpack.dm | 14 ++--- .../code/modules/client/loadout/hands.dm | 24 ++++----- .../code/modules/client/loadout/neck.dm | 4 +- tgstation.dme | 1 + 10 files changed, 73 insertions(+), 53 deletions(-) create mode 100644 code/_globalvars/lists/loadout_categories.dm diff --git a/code/__DEFINES/loadout.dm b/code/__DEFINES/loadout.dm index 18a24ff495..7bdfce3738 100644 --- a/code/__DEFINES/loadout.dm +++ b/code/__DEFINES/loadout.dm @@ -12,7 +12,6 @@ //mask #define CATEGORY_MASK "Mask" -#define SUBCATEGORY_MASK_DONATOR "Donator" //hands #define CATEGORY_HANDS "Hands" diff --git a/code/_globalvars/lists/loadout_categories.dm b/code/_globalvars/lists/loadout_categories.dm new file mode 100644 index 0000000000..e9f9e2c976 --- /dev/null +++ b/code/_globalvars/lists/loadout_categories.dm @@ -0,0 +1,13 @@ +GLOBAL_LIST_INIT(loadout_categories, list( + CATEGORY_BACKPACK = list(SUBCATEGORY_BACKPACK_GENERAL, SUBCATEGORY_BACKPACK_TOYS), + CATEGORY_NECK = list(SUBCATEGORY_NECK_GENERAL, SUBCATEGORY_NECK_TIE, SUBCATEGORY_NECK_SCARVES), + CATEGORY_MASK = list("NOSUBCATEGORY"), + CATEGORY_HANDS = list("NOSUBCATEGORY"), + CATEGORY_UNIFORM = list(SUBCATEGORY_UNIFORM_GENERAL, SUBCATEGORY_UNIFORM_JOBS), + CATEGORY_SUIT = list(SUBCATEGORY_SUIT_GENERAL, SUBCATEGORY_SUIT_COATS, SUBCATEGORY_SUIT_JACKETS, SUBCATEGORY_SUIT_JOBS), + CATEGORY_HEAD = list(SUBCATEGORY_HEAD_GENERAL, SUBCATEGORY_HEAD_JOBS), + CATEGORY_SHOES = list("NOSUBCATEGORY"), + CATEGORY_GLOVES = list("NOSUBCATEGORY"), + CATEGORY_GLASSES = list("NOSUBCATEGORY"), + CATEGORY_DONATOR = list("NOSUBCATEGORY") +)) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 75e914ea68..00ff8715d4 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -39,8 +39,6 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/tmp/old_be_special = 0 //Bitflag version of be_special, used to update old savefiles and nothing more //If it's 0, that's good, if it's anything but 0, the owner of this prefs file's antag choices were, //autocorrected this round, not that you'd need to check that. - - var/UI_style = null var/buttons_locked = FALSE var/hotkeys = FALSE @@ -53,7 +51,6 @@ GLOBAL_LIST_EMPTY(preferences_datums) /// List with a key string associated to a list of keybindings. Unlike key_bindings, this one operates on raw key, allowing for binding a key that triggers regardless of if a modifier is depressed as long as the raw key is sent. var/list/modless_key_bindings = list() - var/tgui_fancy = TRUE var/tgui_lock = TRUE var/windowflashing = TRUE @@ -231,6 +228,8 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/list/gear_categories var/list/chosen_gear = list() var/gear_tab + var/category = 1 + var/subcategory = 1 var/screenshake = 100 var/damagescreenshake = 2 @@ -1059,32 +1058,45 @@ GLOBAL_LIST_EMPTY(preferences_datums) dat += "
" if(3) - if(!gear_tab) - gear_tab = GLOB.loadout_items[1] dat += "" dat += "" dat += "" dat += "" dat += "" dat += "" dat += "" + var/subcategory_index = 1 + for(var/i in GLOB.loadout_categories[category_section]) + if(i == "NOSUBCATEGORY") + continue + if(subcategory_index != 1) + dat += " |" + if(subcategory_index == subcategory) + dat += " [i] " + else + dat += " [i] " + subcategory_index += 1 + dat += "" dat += "" dat += "" dat += "" - for(var/j in GLOB.loadout_items[gear_tab]) - var/datum/gear/gear = GLOB.loadout_items[gear_tab][j] + for(var/j in GLOB.loadout_items[category_section][subcategory_section]) + var/datum/gear/gear = GLOB.loadout_items[category_section][subcategory_section][j] + if(!gear.name) + continue var/donoritem = gear.donoritem if(donoritem && !gear.donator_ckey_check(user.ckey)) continue @@ -2687,11 +2699,14 @@ GLOBAL_LIST_EMPTY(preferences_datums) gear_points = CONFIG_GET(number/initial_gear_points) save_preferences() if(href_list["select_category"]) - for(var/i in GLOB.loadout_items) - if(i == href_list["select_category"]) - gear_tab = i + category = text2num(href_list["select_category"]) + message_admins(category) + if(href_list["select_subcategory"]) + subcategory = text2num(href_list["select_subcategory"]) if(href_list["toggle_gear_path"]) - var/datum/gear/G = GLOB.loadout_items[gear_tab][html_decode(href_list["toggle_gear_path"])] + var/category_section = GLOB.loadout_categories[category] + var/subcategory_section = GLOB.loadout_categories[category_section][subcategory] + var/datum/gear/G = GLOB.loadout_items[category_section][subcategory_section][html_decode(href_list["toggle_gear_path"])] if(!G) return var/toggle = text2num(href_list["toggle_gear"]) diff --git a/modular_citadel/code/modules/client/loadout/__donator.dm b/modular_citadel/code/modules/client/loadout/__donator.dm index 6259d5e08d..54dabba779 100644 --- a/modular_citadel/code/modules/client/loadout/__donator.dm +++ b/modular_citadel/code/modules/client/loadout/__donator.dm @@ -230,7 +230,7 @@ path = /obj/item/toy/darksabre ckeywhitelist = list("inferno707") -datum/gear/darksabresheath +/datum/gear/donator/darksabresheath name = "Dark Sabre Sheath" slot = SLOT_IN_BACKPACK path = /obj/item/storage/belt/sabre/darksabre diff --git a/modular_citadel/code/modules/client/loadout/_loadout.dm b/modular_citadel/code/modules/client/loadout/_loadout.dm index 4f48738ebf..9988519471 100644 --- a/modular_citadel/code/modules/client/loadout/_loadout.dm +++ b/modular_citadel/code/modules/client/loadout/_loadout.dm @@ -26,15 +26,11 @@ GLOBAL_LIST_EMPTY(loadout_whitelist_ids) /proc/initialize_global_loadout_items() load_loadout_config() - LAZYINITLIST(GLOB.loadout_items["NOSUBCATEGORY"]) //items without a subcategory just have one that doesnt show for(var/item in subtypesof(/datum/gear)) var/datum/gear/I = new item LAZYINITLIST(GLOB.loadout_items[I.category]) - if(I.subcategory) - LAZYINITLIST(GLOB.loadout_items[I.category][I.subcategory]) - GLOB.loadout_items[I.category][I.subcategory][I.name] = I - else - GLOB.loadout_items[I.category]["NOSUBCATEGORY"][I.name] = I + LAZYINITLIST(GLOB.loadout_items[I.category][I.subcategory]) + GLOB.loadout_items[I.category][I.subcategory][I.name] = I if(islist(I.geargroupID)) var/list/ggidlist = I.geargroupID I.ckeywhitelist = list() @@ -47,8 +43,8 @@ GLOBAL_LIST_EMPTY(loadout_whitelist_ids) /datum/gear var/name - var/category - var/subcategory + var/category = "NOCATEGORY" + var/subcategory = "NOSUBCATEGORY" var/slot var/description var/path //item-to-spawn path diff --git a/modular_citadel/code/modules/client/loadout/_medical.dm b/modular_citadel/code/modules/client/loadout/_medical.dm index 472b4dce52..bba100faff 100644 --- a/modular_citadel/code/modules/client/loadout/_medical.dm +++ b/modular_citadel/code/modules/client/loadout/_medical.dm @@ -32,7 +32,6 @@ /datum/gear/head/nursehat name = "Nurse Hat" - category = SLOT_HEAD path = /obj/item/clothing/head/nursehat subcategory = SUBCATEGORY_HEAD_JOBS restricted_roles = list("Medical Doctor", "Chief Medical Officer", "Geneticist", "Chemist", "Virologist") @@ -40,7 +39,6 @@ /datum/gear/uniform/nursesuit name = "Nurse Suit" - category = SLOT_W_UNIFORM path = /obj/item/clothing/under/rank/medical/doctor/nurse subcategory = SUBCATEGORY_UNIFORM_JOBS restricted_roles = list("Medical Doctor", "Chief Medical Officer", "Geneticist", "Chemist", "Virologist") diff --git a/modular_citadel/code/modules/client/loadout/backpack.dm b/modular_citadel/code/modules/client/loadout/backpack.dm index 61b6a35dc8..197005bf45 100644 --- a/modular_citadel/code/modules/client/loadout/backpack.dm +++ b/modular_citadel/code/modules/client/loadout/backpack.dm @@ -64,36 +64,36 @@ path = /obj/item/storage/crayons subcategory = SUBCATEGORY_BACKPACK_TOYS -/datum/gear/multipen +/datum/gear/backpack/multipen name = "A multicolored pen" path = /obj/item/pen/fourcolor -/datum/gear/fountainpen +/datum/gear/backpack/fountainpen name = "A fancy pen" path = /obj/item/pen/fountain cost = 2 -/datum/gear/modular_tablet +/datum/gear/backpack/modular_tablet name = "A modular tablet" path = /obj/item/modular_computer/tablet/preset/cheap/ cost = 4 -/datum/gear/modular_laptop +/datum/gear/backpack/modular_laptop name = "A modular laptop" path = /obj/item/modular_computer/laptop/preset/civilian cost = 7 -/datum/gear/ringbox_gold +/datum/gear/backpack/ringbox_gold name = "A gold ring box" path = /obj/item/storage/fancy/ringbox cost = 3 -/datum/gear/ringbox_silver +/datum/gear/backpack/ringbox_silver name = "A silver ring box" path = /obj/item/storage/fancy/ringbox/silver cost = 3 -/datum/gear/ringbox_diamond +/datum/gear/backpack/ringbox_diamond name = "A diamond ring box" path = /obj/item/storage/fancy/ringbox/diamond cost = 5 diff --git a/modular_citadel/code/modules/client/loadout/hands.dm b/modular_citadel/code/modules/client/loadout/hands.dm index 5af928b92b..04ab020779 100644 --- a/modular_citadel/code/modules/client/loadout/hands.dm +++ b/modular_citadel/code/modules/client/loadout/hands.dm @@ -1,53 +1,53 @@ /datum/gear/hands category = CATEGORY_HANDS -/datum/gear/cane +/datum/gear/hands/cane name = "Cane" path = /obj/item/cane -/datum/gear/cigarettes +/datum/gear/hands/cigarettes name = "Cigarette pack" path = /obj/item/storage/fancy/cigarettes -/datum/gear/dice +/datum/gear/hands/dice name = "Dice bag" path = /obj/item/storage/box/dice -/datum/gear/eightball +/datum/gear/hands/eightball name = "Magic eightball" path = /obj/item/toy/eightball -/datum/gear/matches +/datum/gear/hands/matches name = "Matchbox" path = /obj/item/storage/box/matches -/datum/gear/cheaplighter +/datum/gear/hands/cheaplighter name = "Cheap lighter" path = /obj/item/lighter/greyscale -/datum/gear/cards +/datum/gear/hands/cards name = "Playing cards" path = /obj/item/toy/cards/deck -/datum/gear/skub +/datum/gear/hands/skub name = "Skub" path = /obj/item/skub -/datum/gear/wallet +/datum/gear/hands/wallet name = "Wallet" path = /obj/item/storage/wallet -/datum/gear/flask +/datum/gear/hands/flask name = "Flask" path = /obj/item/reagent_containers/food/drinks/flask cost = 2 -/datum/gear/zippolighter +/datum/gear/hands/zippolighter name = "Zippo Lighter" path = /obj/item/lighter cost = 2 -/datum/gear/cigar +/datum/gear/hands/cigar name = "Cigar" path = /obj/item/clothing/mask/cigarette/cigar cost = 4 //smoking is bad mkay diff --git a/modular_citadel/code/modules/client/loadout/neck.dm b/modular_citadel/code/modules/client/loadout/neck.dm index d7a3b5334f..ac399b4287 100644 --- a/modular_citadel/code/modules/client/loadout/neck.dm +++ b/modular_citadel/code/modules/client/loadout/neck.dm @@ -9,7 +9,7 @@ /datum/gear/neck/redtie name = "Red tie" - category = SLOT_NECK + subcategory = SUBCATEGORY_NECK_TIE path = /obj/item/clothing/neck/tie/red /datum/gear/neck/blacktie @@ -80,10 +80,8 @@ /datum/gear/neck/headphones name = "Headphones" - category = SLOT_NECK path = /obj/item/clothing/ears/headphones /datum/gear/neck/polycloak name = "Polychromatic Cloak" - category = SLOT_NECK path = /obj/item/clothing/neck/cloak/polychromic diff --git a/tgstation.dme b/tgstation.dme index b351bf95cf..3df30eef97 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -201,6 +201,7 @@ #include "code\_globalvars\lists\client.dm" #include "code\_globalvars\lists\flavor_misc.dm" #include "code\_globalvars\lists\keybindings.dm" +#include "code\_globalvars\lists\loadout_categories.dm" #include "code\_globalvars\lists\maintenance_loot.dm" #include "code\_globalvars\lists\mapping.dm" #include "code\_globalvars\lists\medals.dm"
[gear_points] loadout points remaining. \[Clear Loadout\]
You can only choose one item per category, unless it's an item that spawns in your backpack or hands.
" - var/firstcat = TRUE - for(var/i in GLOB.loadout_items) - if(firstcat) - firstcat = FALSE - else - dat += " |" - if(i == gear_tab) + var/category_section = GLOB.loadout_categories[category] + var/subcategory_section = GLOB.loadout_categories[category_section][subcategory] + var/category_index = 1 + for(var/i in GLOB.loadout_categories) + if(category_index != 1) + dat += "
" + if(category_index == category) dat += " [i] " else - dat += " [i] " + dat += " [i] " + category_index += 1 dat += "

[gear_tab]

NameCostRestrictionsDescription