mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Merge pull request #2329 from Yoshax/englishlist
Rewrite english_list to be a little nicer on lists of objects, and also faster
This commit is contained in:
@@ -11,24 +11,11 @@
|
|||||||
|
|
||||||
//Returns a list in plain english as a string
|
//Returns a list in plain english as a string
|
||||||
/proc/english_list(var/list/input, nothing_text = "nothing", and_text = " and ", comma_text = ", ", final_comma_text = "" )
|
/proc/english_list(var/list/input, nothing_text = "nothing", and_text = " and ", comma_text = ", ", final_comma_text = "" )
|
||||||
var/total = input.len
|
switch(input.len)
|
||||||
if (!total)
|
if(0) return nothing_text
|
||||||
return "[nothing_text]"
|
if(1) return "[input[1]]"
|
||||||
else if (total == 1)
|
if(2) return "[input[1]][and_text][input[2]]"
|
||||||
return "[input[1]]"
|
else return "[jointext(input, comma_text, 1, -1)][final_comma_text][and_text][input[input.len]]"
|
||||||
else if (total == 2)
|
|
||||||
return "[input[1]][and_text][input[2]]"
|
|
||||||
else
|
|
||||||
var/output = ""
|
|
||||||
var/index = 1
|
|
||||||
while (index < total)
|
|
||||||
if (index == total - 1)
|
|
||||||
comma_text = final_comma_text
|
|
||||||
|
|
||||||
output += "[input[index]][comma_text]"
|
|
||||||
index++
|
|
||||||
|
|
||||||
return "[output][and_text][input[index]]"
|
|
||||||
|
|
||||||
//Returns list element or null. Should prevent "index out of bounds" error.
|
//Returns list element or null. Should prevent "index out of bounds" error.
|
||||||
proc/listgetindex(var/list/list,index)
|
proc/listgetindex(var/list/list,index)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
. += "- [pref.species] cannot choose secondary languages.<br>"
|
. += "- [pref.species] cannot choose secondary languages.<br>"
|
||||||
|
|
||||||
. += "<b>Language Keys</b><br>"
|
. += "<b>Language Keys</b><br>"
|
||||||
. += " [english_list(pref.language_prefixes, and_text = " ", comma_text = " ")] <a href='?src=\ref[src];change_prefix=1'>Change</a> <a href='?src=\ref[src];reset_prefix=1'>Reset</a><br>"
|
. += " [jointext(pref.language_prefixes, " ")] <a href='?src=\ref[src];change_prefix=1'>Change</a> <a href='?src=\ref[src];reset_prefix=1'>Reset</a><br>"
|
||||||
|
|
||||||
/datum/category_item/player_setup_item/general/language/OnTopic(var/href,var/list/href_list, var/mob/user)
|
/datum/category_item/player_setup_item/general/language/OnTopic(var/href,var/list/href_list, var/mob/user)
|
||||||
if(href_list["remove_language"])
|
if(href_list["remove_language"])
|
||||||
|
|||||||
Reference in New Issue
Block a user