Demodularizing the gear loadout code a little. (#12261)

This commit is contained in:
Ghom
2020-05-18 13:45:50 +02:00
committed by GitHub
parent 95249a4d79
commit 20ac2f26f4
10 changed files with 71 additions and 106 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -12,5 +12,5 @@
name = "Joy mask"
category = SLOT_WEAR_MASK
path = /obj/item/clothing/mask/joy
cost = 9
cost = 3

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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"