From 20ac2f26f4b62cf8e5d590fef295c9779b39c124 Mon Sep 17 00:00:00 2001 From: Ghom <42542238+Ghommie@users.noreply.github.com> Date: Mon, 18 May 2020 13:45:50 +0200 Subject: [PATCH] Demodularizing the gear loadout code a little. (#12261) --- .../configuration/entries/game_options.dm | 4 ++ code/modules/client/preferences.dm | 50 ++++++++++++++++--- code/modules/client/preferences_savefile.dm | 22 ++++++++ .../code/modules/client/loadout/_loadout.dm | 4 -- .../code/modules/client/loadout/backpack.dm | 19 +------ .../code/modules/client/loadout/mask.dm | 4 +- .../code/modules/client/loadout/suit.dm | 8 --- .../code/modules/client/preferences.dm | 47 ----------------- .../modules/client/preferences_savefile.dm | 18 ------- tgstation.dme | 1 - 10 files changed, 71 insertions(+), 106 deletions(-) delete mode 100644 modular_citadel/code/modules/client/preferences.dm diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index f8a66fce09..79b110a78a 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -508,6 +508,10 @@ //Allows players to set a hexadecimal color of their choice as skin tone, on top of the standard ones. /datum/config_entry/flag/allow_custom_skintones +///Initial loadout points +/datum/config_entry/number/initial_gear_points + config_entry_value = 10 + /** * Enables the FoV component, which hides objects and mobs behind the parent from their sight, unless they turn around, duh. * Camera mobs, AIs, ghosts and some other are of course exempt from this. This also doesn't influence simplemob AI, for the best. diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 4ffe7f2ea4..2bcb73ed22 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -1,11 +1,6 @@ - /* CAUTION! CAUTION! CAUTION! CAUTION! CAUTION! *\ - | THIS FILE CONTAINS HOOKS FOR FOR | - | CHANGES SPECIFIC TO CITADEL. IF | - | YOU'RE FIXING A MERGE CONFLICT | - | HERE, PLEASE ASK FOR REVIEW FROM | - | ANOTHER MAINTAINER TO ENSURE YOU | - | DON'T INTRODUCE REGRESSIONS. | - \* */ +#define DEFAULT_SLOT_AMT 2 +#define HANDS_SLOT_AMT 2 +#define BACKPACK_SLOT_AMT 4 GLOBAL_LIST_EMPTY(preferences_datums) @@ -204,6 +199,10 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/vore_flags = 0 var/list/belly_prefs = list() var/vore_taste = "nothing in particular" + var/toggleeatingnoise = TRUE + var/toggledigestionnoise = TRUE + var/hound_sleeper = TRUE + var/cit_toggles = TOGGLES_CITADEL //backgrounds var/mutable_appearance/character_background @@ -214,6 +213,19 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/no_tetris_storage = FALSE + ///loadout stuff + var/gear_points = 10 + var/list/gear_categories + var/list/chosen_gear = list() + var/gear_tab + + var/screenshake = 100 + var/damagescreenshake = 2 + var/arousable = TRUE + var/widescreenpref = TRUE + var/autostand = TRUE + var/auto_ooc = FALSE + /datum/preferences/New(client/C) parent = C @@ -2582,3 +2594,25 @@ GLOBAL_LIST_EMPTY(preferences_datums) if(!cached_holoform_icons[filter_type]) cached_holoform_icons[filter_type] = process_holoform_icon_filter(custom_holoform_icon, filter_type) return cached_holoform_icons[filter_type] + +/datum/preferences/proc/is_loadout_slot_available(slot) + var/list/L + LAZYINITLIST(L) + for(var/i in chosen_gear) + var/datum/gear/G = i + var/occupied_slots = L[slot_to_string(initial(G.category))] ? L[slot_to_string(initial(G.category))] + 1 : 1 + LAZYSET(L, slot_to_string(initial(G.category)), occupied_slots) + switch(slot) + if(SLOT_IN_BACKPACK) + if(L[slot_to_string(SLOT_IN_BACKPACK)] < BACKPACK_SLOT_AMT) + return TRUE + if(SLOT_HANDS) + if(L[slot_to_string(SLOT_HANDS)] < HANDS_SLOT_AMT) + return TRUE + else + if(L[slot_to_string(slot)] < DEFAULT_SLOT_AMT) + return TRUE + +#undef DEFAULT_SLOT_AMT +#undef HANDS_SLOT_AMT +#undef BACKPACK_SLOT_AMT diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index ca8599c4d5..a908e776d8 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -541,6 +541,21 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car S["vore_taste"] >> vore_taste S["belly_prefs"] >> belly_prefs + //gear loadout + var/text_to_load + S["loadout"] >> text_to_load + var/list/saved_loadout_paths = splittext(text_to_load, "|") + chosen_gear = list() + gear_points = CONFIG_GET(number/initial_gear_points) + for(var/i in saved_loadout_paths) + var/datum/gear/path = text2path(i) + if(path) + var/init_cost = initial(path.cost) + if(init_cost > gear_points) + continue + chosen_gear += path + gear_points -= init_cost + //try to fix any outdated data if necessary if(needs_update >= 0) update_character(needs_update, S) //needs_update == savefile_version if we need an update (positive integer) @@ -771,6 +786,13 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car WRITE_FILE(S["vore_taste"] , vore_taste) WRITE_FILE(S["belly_prefs"] , belly_prefs) + //gear loadout + if(chosen_gear.len) + var/text_to_save = chosen_gear.Join("|") + S["loadout"] << text_to_save + else + S["loadout"] << "" //empty string to reset the value + cit_character_pref_save(S) return 1 diff --git a/modular_citadel/code/modules/client/loadout/_loadout.dm b/modular_citadel/code/modules/client/loadout/_loadout.dm index d35bede179..51256f8cde 100644 --- a/modular_citadel/code/modules/client/loadout/_loadout.dm +++ b/modular_citadel/code/modules/client/loadout/_loadout.dm @@ -10,7 +10,6 @@ GLOBAL_LIST_EMPTY(loadout_whitelist_ids) /proc/load_loadout_config(loadout_config) if(!loadout_config) loadout_config = "config/loadout_config.txt" - LAZYINITLIST(GLOB.loadout_whitelist_ids) var/list/file_lines = world.file2list(loadout_config) for(var/line in file_lines) if(!line || line[1] == "#") @@ -26,12 +25,9 @@ GLOBAL_LIST_EMPTY(loadout_whitelist_ids) GLOB.loadout_whitelist_ids["[lineID]"] = sublinecontent /proc/initialize_global_loadout_items() - LAZYINITLIST(GLOB.loadout_items) load_loadout_config() for(var/item in subtypesof(/datum/gear)) var/datum/gear/I = new item - if(!GLOB.loadout_items[slot_to_string(I.category)]) - LAZYINITLIST(GLOB.loadout_items[slot_to_string(I.category)]) LAZYSET(GLOB.loadout_items[slot_to_string(I.category)], I.name, I) if(islist(I.geargroupID)) var/list/ggidlist = I.geargroupID diff --git a/modular_citadel/code/modules/client/loadout/backpack.dm b/modular_citadel/code/modules/client/loadout/backpack.dm index d51f4b6125..8d089a129a 100644 --- a/modular_citadel/code/modules/client/loadout/backpack.dm +++ b/modular_citadel/code/modules/client/loadout/backpack.dm @@ -69,18 +69,6 @@ path = /obj/item/toy/katana cost = 3 -/datum/gear/box - name = "Spare box" - category = SLOT_IN_BACKPACK - path = /obj/item/storage/box - cost = 2 - -/datum/gear/crowbar - name = "Pocket Crowbar" - category = SLOT_IN_BACKPACK - path = /obj/item/crowbar - cost = 2 - /datum/gear/tapeplayer name = "Taperecorder" category = SLOT_IN_BACKPACK @@ -96,11 +84,6 @@ category = SLOT_IN_BACKPACK path = /obj/item/newspaper -/datum/gear/paperbin - name = "Paper Bin" - category = SLOT_IN_BACKPACK - path = /obj/item/paper_bin - /datum/gear/crayons name = "Box of crayons" category = SLOT_IN_BACKPACK @@ -146,4 +129,4 @@ category = SLOT_IN_BACKPACK path = /obj/item/storage/fancy/ringbox/diamond cost = 5 - + diff --git a/modular_citadel/code/modules/client/loadout/mask.dm b/modular_citadel/code/modules/client/loadout/mask.dm index 82824814ae..eeba06cad4 100644 --- a/modular_citadel/code/modules/client/loadout/mask.dm +++ b/modular_citadel/code/modules/client/loadout/mask.dm @@ -12,5 +12,5 @@ name = "Joy mask" category = SLOT_WEAR_MASK path = /obj/item/clothing/mask/joy - cost = 9 - + cost = 3 + diff --git a/modular_citadel/code/modules/client/loadout/suit.dm b/modular_citadel/code/modules/client/loadout/suit.dm index 9b39d006bd..64deaf9be2 100644 --- a/modular_citadel/code/modules/client/loadout/suit.dm +++ b/modular_citadel/code/modules/client/loadout/suit.dm @@ -85,14 +85,6 @@ path = /obj/item/clothing/suit/hooded/wintercoat/polychromic cost = 4 //too many people with neon green coats is hard on the eyes -/* Commented out until it is "balanced" -/datum/gear/coat/sec - name = "Security winter coat" - category = SLOT_WEAR_SUIT - path = /obj/item/clothing/suit/hooded/wintercoat/security - restricted_roles = list("Head of Security", "Warden", "Detective", "Security Officer") // Reserve it to the Security Departement -*/ - /datum/gear/coat/med name = "Medical winter coat" category = SLOT_WEAR_SUIT diff --git a/modular_citadel/code/modules/client/preferences.dm b/modular_citadel/code/modules/client/preferences.dm deleted file mode 100644 index 8c55f2d9a8..0000000000 --- a/modular_citadel/code/modules/client/preferences.dm +++ /dev/null @@ -1,47 +0,0 @@ -#define DEFAULT_SLOT_AMT 2 -#define HANDS_SLOT_AMT 2 -#define BACKPACK_SLOT_AMT 4 - -/datum/preferences - //gear - var/gear_points = 10 - var/list/gear_categories - var/list/chosen_gear - var/gear_tab - - //pref vars - var/screenshake = 100 - var/damagescreenshake = 2 - var/arousable = TRUE - var/widescreenpref = TRUE - var/autostand = TRUE - var/auto_ooc = FALSE - - //vore prefs - var/toggleeatingnoise = TRUE - var/toggledigestionnoise = TRUE - var/hound_sleeper = TRUE - var/cit_toggles = TOGGLES_CITADEL - - -/datum/preferences/New(client/C) - ..() - LAZYINITLIST(chosen_gear) - -/datum/preferences/proc/is_loadout_slot_available(slot) - var/list/L - LAZYINITLIST(L) - for(var/i in chosen_gear) - var/datum/gear/G = i - var/occupied_slots = L[slot_to_string(initial(G.category))] ? L[slot_to_string(initial(G.category))] + 1 : 1 - LAZYSET(L, slot_to_string(initial(G.category)), occupied_slots) - switch(slot) - if(SLOT_IN_BACKPACK) - if(L[slot_to_string(SLOT_IN_BACKPACK)] < BACKPACK_SLOT_AMT) - return TRUE - if(SLOT_HANDS) - if(L[slot_to_string(SLOT_HANDS)] < HANDS_SLOT_AMT) - return TRUE - else - if(L[slot_to_string(slot)] < DEFAULT_SLOT_AMT) - return TRUE diff --git a/modular_citadel/code/modules/client/preferences_savefile.dm b/modular_citadel/code/modules/client/preferences_savefile.dm index d9b902656f..d0363d228f 100644 --- a/modular_citadel/code/modules/client/preferences_savefile.dm +++ b/modular_citadel/code/modules/client/preferences_savefile.dm @@ -14,17 +14,6 @@ features["mcolor2"] = sanitize_hexcolor(features["mcolor2"], 3, 0) features["mcolor3"] = sanitize_hexcolor(features["mcolor3"], 3, 0) - //gear loadout - var/text_to_load - S["loadout"] >> text_to_load - var/list/saved_loadout_paths = splittext(text_to_load, "|") - LAZYCLEARLIST(chosen_gear) - gear_points = initial(gear_points) - for(var/i in saved_loadout_paths) - var/datum/gear/path = text2path(i) - if(path) - LAZYADD(chosen_gear, path) - gear_points -= initial(path.cost) /datum/preferences/proc/cit_character_pref_save(savefile/S) //ipcs @@ -47,10 +36,3 @@ //flavor text WRITE_FILE(S["feature_flavor_text"], features["flavor_text"]) - //gear loadout - if(islist(chosen_gear)) - if(chosen_gear.len) - var/text_to_save = chosen_gear.Join("|") - S["loadout"] << text_to_save - else - S["loadout"] << "" //empty string to reset the value diff --git a/tgstation.dme b/tgstation.dme index 0f6a1fb1fe..f9f13c44a5 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -3344,7 +3344,6 @@ #include "modular_citadel\code\modules\admin\secrets.dm" #include "modular_citadel\code\modules\client\client_defines.dm" #include "modular_citadel\code\modules\client\client_procs.dm" -#include "modular_citadel\code\modules\client\preferences.dm" #include "modular_citadel\code\modules\client\preferences_savefile.dm" #include "modular_citadel\code\modules\client\preferences_toggles.dm" #include "modular_citadel\code\modules\client\loadout\__donator.dm"