From 8d379460c6d57384ac47d611b33587f91ee68770 Mon Sep 17 00:00:00 2001
From: DreamySkrell <107256943+DreamySkrell@users.noreply.github.com>
Date: Sun, 30 Oct 2022 11:40:59 +0100
Subject: [PATCH] Loadout QoL - unavailable items grayed out and at end of
list, culture and origins under items (#14982)
---
.../preference_setup/loadout/loadout.dm | 86 ++++++++++++++++---
.../DreamySkrell-loadout-qol-236.yml | 7 ++
2 files changed, 82 insertions(+), 11 deletions(-)
create mode 100644 html/changelogs/DreamySkrell-loadout-qol-236.yml
diff --git a/code/modules/client/preference_setup/loadout/loadout.dm b/code/modules/client/preference_setup/loadout/loadout.dm
index a5550f6ed01..bc194dc242e 100644
--- a/code/modules/client/preference_setup/loadout/loadout.dm
+++ b/code/modules/client/preference_setup/loadout/loadout.dm
@@ -177,35 +177,79 @@ var/list/gear_datums = list()
. += "
|
"
. += "| [LC.category] |
"
. += "
|
"
+
+ var/available_items_html = "" // to be added to the top/beginning of the list
+ var/unavailable_items_html = "" // to be added to the end/bottom of the list
+
var/list/player_valid_gear_choices = valid_gear_choices()
for(var/gear_name in LC.gear)
if(!(gear_name in player_valid_gear_choices))
continue
var/datum/gear/G = LC.gear[gear_name]
+
+ var/temp_html = ""
+ var/datum/job/job = pref.return_chosen_high_job()
+ var/available = (G.check_faction(pref.faction) && (job && G.check_role(job.title)) && G.check_culture(pref.culture) && G.check_origin(pref.origin))
var/ticked = (G.display_name in pref.gear)
var/style = ""
+
+ if(!available)
+ style = "style='color: #B1B1B1;'"
if(ticked)
style = "style='color: #FF8000;'"
- . += "| [G.display_name] | "
- . += "[G.cost] | "
- . += "[G.description] "
+ temp_html += "| [G.display_name] | "
+ temp_html += "[G.cost] | "
+ temp_html += "[G.description] "
+
if(G.allowed_roles)
- . += "("
+ temp_html += "(Role: "
var/role_count = 0
for(var/role in G.allowed_roles)
- . += "[role]"
+ temp_html += "[role]"
role_count++
if(role_count == G.allowed_roles.len)
- . += ")"
+ temp_html += ") "
break
else
- . += ", "
- . += " | "
+ temp_html += ", "
+ if(G.culture_restriction)
+ temp_html += "(Culture: "
+ var/culture_count = 0
+ for(var/culture in G.culture_restriction)
+ var/decl/origin_item/C = decls_repository.get_decl(culture)
+ temp_html += "[C.name]"
+ culture_count++
+ if(culture_count == G.culture_restriction.len)
+ temp_html += ") "
+ break
+ else
+ temp_html += ", "
+ if(G.origin_restriction)
+ temp_html += "(Origin: "
+ var/origin_count = 0
+ for(var/origin in G.origin_restriction)
+ var/decl/origin_item/O = decls_repository.get_decl(origin)
+ temp_html += "[O.name]"
+ origin_count++
+ if(origin_count == G.origin_restriction.len)
+ temp_html += ") "
+ break
+ else
+ temp_html += ", "
+ temp_html += " |
"
+
if(ticked)
- . += "| "
+ temp_html += " |
| "
for(var/datum/gear_tweak/tweak in G.gear_tweaks)
- . += " [tweak.get_contents(get_tweak_metadata(G, tweak))]"
- . += " |
"
+ temp_html += " [tweak.get_contents(get_tweak_metadata(G, tweak))]"
+ temp_html += ""
+ if(!available)
+ available_items_html += temp_html
+ else
+ unavailable_items_html += temp_html
+
+ . += unavailable_items_html
+ . += available_items_html
. += ""
. = jointext(.,null)
@@ -351,3 +395,23 @@ var/list/gear_datums = list()
if(whitelisted && (!(H.species.name in whitelisted)))
return FALSE
return TRUE
+
+/datum/gear/proc/check_faction(var/faction_)
+ if((faction && faction_ && faction_ != "None" && faction_ != "Stellar Corporate Conglomerate") && (faction != faction_))
+ return FALSE
+ return TRUE
+
+/datum/gear/proc/check_role(var/role)
+ if(role && allowed_roles && !(role in allowed_roles))
+ return FALSE
+ return TRUE
+
+/datum/gear/proc/check_culture(var/culture)
+ if(culture && culture_restriction && !(culture in culture_restriction))
+ return FALSE
+ return TRUE
+
+/datum/gear/proc/check_origin(var/origin)
+ if(origin && origin_restriction && !(origin in origin_restriction))
+ return FALSE
+ return TRUE
diff --git a/html/changelogs/DreamySkrell-loadout-qol-236.yml b/html/changelogs/DreamySkrell-loadout-qol-236.yml
new file mode 100644
index 00000000000..6510c9b7314
--- /dev/null
+++ b/html/changelogs/DreamySkrell-loadout-qol-236.yml
@@ -0,0 +1,7 @@
+author: DreamySkrell
+
+delete-after: True
+
+changes:
+ - rscadd: "Unavailable items in the loadout (restricted for jobs, origins, cultures, or factions) are grayed out and appear at the bottom/end of the list."
+ - rscadd: "Culture and origin restrictions appear under items, same as job restrictions."