mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 14:39:58 +01:00
[MIRROR] Sets a saner length limit to ID assignments and paintings' titles. [MDB IGNORE] (#22719)
* Sets a saner length limit to ID assignments and paintings' titles. (#76723) * Sets a saner length limit to ID assignments and paintings' titles. --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
@@ -1510,92 +1510,103 @@
|
||||
return TRUE
|
||||
|
||||
/obj/item/card/id/advanced/chameleon/attack_self(mob/user)
|
||||
if(isliving(user) && user.mind)
|
||||
var/popup_input = tgui_input_list(user, "Choose Action", "Agent ID", list("Show", "Forge/Reset", "Change Account ID"))
|
||||
if(user.incapacitated())
|
||||
return
|
||||
if(!user.is_holding(src))
|
||||
return
|
||||
if(popup_input == "Forge/Reset")
|
||||
if(!forged)
|
||||
var/input_name = tgui_input_text(user, "What name would you like to put on this card? Leave blank to randomise.", "Agent card name", registered_name ? registered_name : (ishuman(user) ? user.real_name : user.name), MAX_NAME_LEN)
|
||||
input_name = sanitize_name(input_name, allow_numbers = TRUE)
|
||||
if(!input_name)
|
||||
// Invalid/blank names give a randomly generated one.
|
||||
if(user.gender == MALE)
|
||||
input_name = "[pick(GLOB.first_names_male)] [pick(GLOB.last_names)]"
|
||||
else if(user.gender == FEMALE)
|
||||
input_name = "[pick(GLOB.first_names_female)] [pick(GLOB.last_names)]"
|
||||
else
|
||||
input_name = "[pick(GLOB.first_names)] [pick(GLOB.last_names)]"
|
||||
|
||||
registered_name = input_name
|
||||
|
||||
var/change_trim = tgui_alert(user, "Adjust the appearance of your card's trim?", "Modify Trim", list("Yes", "No"))
|
||||
if(change_trim == "Yes")
|
||||
var/list/blacklist = typecacheof(list(
|
||||
type,
|
||||
/obj/item/card/id/advanced/simple_bot,
|
||||
))
|
||||
var/list/trim_list = list()
|
||||
for(var/trim_path in typesof(/datum/id_trim))
|
||||
if(blacklist[trim_path])
|
||||
continue
|
||||
|
||||
var/datum/id_trim/trim = SSid_access.trim_singletons_by_path[trim_path]
|
||||
|
||||
if(trim && trim.trim_state && trim.assignment)
|
||||
var/fake_trim_name = "[trim.assignment] ([trim.trim_state])"
|
||||
trim_list[fake_trim_name] = trim_path
|
||||
|
||||
var/selected_trim_path = tgui_input_list(user, "Select trim to apply to your card.\nNote: This will not grant any trim accesses.", "Forge Trim", sort_list(trim_list, GLOBAL_PROC_REF(cmp_typepaths_asc)))
|
||||
if(selected_trim_path)
|
||||
SSid_access.apply_trim_to_chameleon_card(src, trim_list[selected_trim_path])
|
||||
|
||||
var/target_occupation = tgui_input_text(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels.", "Agent card job assignment", assignment ? assignment : "Assistant")
|
||||
if(target_occupation)
|
||||
assignment = target_occupation
|
||||
|
||||
var/new_age = tgui_input_number(user, "Choose the ID's age", "Agent card age", AGE_MIN, AGE_MAX, AGE_MIN)
|
||||
if(QDELETED(user) || QDELETED(src) || !user.can_perform_action(user, NEED_DEXTERITY| FORBID_TELEKINESIS_REACH))
|
||||
return
|
||||
if(new_age)
|
||||
registered_age = new_age
|
||||
|
||||
if(tgui_alert(user, "Activate wallet ID spoofing, allowing this card to force itself to occupy the visible ID slot in wallets?", "Wallet ID Spoofing", list("Yes", "No")) == "Yes")
|
||||
ADD_TRAIT(src, TRAIT_MAGNETIC_ID_CARD, CHAMELEON_ITEM_TRAIT)
|
||||
|
||||
update_label()
|
||||
update_icon()
|
||||
forged = TRUE
|
||||
to_chat(user, span_notice("You successfully forge the ID card."))
|
||||
user.log_message("forged \the [initial(name)] with name \"[registered_name]\", occupation \"[assignment]\" and trim \"[trim?.assignment]\".", LOG_GAME)
|
||||
|
||||
if(!registered_account)
|
||||
if(ishuman(user))
|
||||
var/mob/living/carbon/human/accountowner = user
|
||||
|
||||
var/datum/bank_account/account = SSeconomy.bank_accounts_by_id["[accountowner.account_id]"]
|
||||
if(account)
|
||||
account.bank_cards += src
|
||||
registered_account = account
|
||||
to_chat(user, span_notice("Your account number has been automatically assigned."))
|
||||
return
|
||||
if(forged)
|
||||
registered_name = initial(registered_name)
|
||||
assignment = initial(assignment)
|
||||
SSid_access.remove_trim_from_chameleon_card(src)
|
||||
REMOVE_TRAIT(src, TRAIT_MAGNETIC_ID_CARD, CHAMELEON_ITEM_TRAIT)
|
||||
user.log_message("reset \the [initial(name)] named \"[src]\" to default.", LOG_GAME)
|
||||
update_label()
|
||||
update_icon()
|
||||
forged = FALSE
|
||||
to_chat(user, span_notice("You successfully reset the ID card."))
|
||||
return
|
||||
if (popup_input == "Change Account ID")
|
||||
if(!user.can_perform_action(user, NEED_DEXTERITY| FORBID_TELEKINESIS_REACH))
|
||||
return ..()
|
||||
var/popup_input = tgui_input_list(user, "Choose Action", "Agent ID", list("Show", "Forge/Reset", "Change Account ID"))
|
||||
if(!popup_input || !after_input_check(user))
|
||||
return TRUE
|
||||
switch(popup_input)
|
||||
if ("Change Account ID")
|
||||
set_new_account(user)
|
||||
return
|
||||
return ..()
|
||||
if("Show")
|
||||
return ..()
|
||||
|
||||
///"Forge/Reset", kept outside the switch() statement to reduce indentation.
|
||||
if(forged) //reset the ID if forged
|
||||
registered_name = initial(registered_name)
|
||||
assignment = initial(assignment)
|
||||
SSid_access.remove_trim_from_chameleon_card(src)
|
||||
REMOVE_TRAIT(src, TRAIT_MAGNETIC_ID_CARD, CHAMELEON_ITEM_TRAIT)
|
||||
user.log_message("reset \the [initial(name)] named \"[src]\" to default.", LOG_GAME)
|
||||
update_label()
|
||||
update_icon()
|
||||
forged = FALSE
|
||||
to_chat(user, span_notice("You successfully reset the ID card."))
|
||||
return
|
||||
|
||||
///forge the ID if not forged.
|
||||
var/input_name = tgui_input_text(user, "What name would you like to put on this card? Leave blank to randomise.", "Agent card name", registered_name ? registered_name : (ishuman(user) ? user.real_name : user.name), MAX_NAME_LEN)
|
||||
if(!after_input_check(user))
|
||||
return TRUE
|
||||
if(input_name)
|
||||
input_name = sanitize_name(input_name, allow_numbers = TRUE)
|
||||
if(!input_name)
|
||||
// Invalid/blank names give a randomly generated one.
|
||||
if(user.gender == MALE)
|
||||
input_name = "[pick(GLOB.first_names_male)] [pick(GLOB.last_names)]"
|
||||
else if(user.gender == FEMALE)
|
||||
input_name = "[pick(GLOB.first_names_female)] [pick(GLOB.last_names)]"
|
||||
else
|
||||
input_name = "[pick(GLOB.first_names)] [pick(GLOB.last_names)]"
|
||||
|
||||
var/change_trim = tgui_alert(user, "Adjust the appearance of your card's trim?", "Modify Trim", list("Yes", "No"))
|
||||
if(!after_input_check(user))
|
||||
return TRUE
|
||||
var/selected_trim_path
|
||||
var/static/list/trim_list
|
||||
if(change_trim == "Yes")
|
||||
trim_list = list()
|
||||
for(var/trim_path in typesof(/datum/id_trim))
|
||||
var/datum/id_trim/trim = SSid_access.trim_singletons_by_path[trim_path]
|
||||
if(trim && trim.trim_state && trim.assignment)
|
||||
var/fake_trim_name = "[trim.assignment] ([trim.trim_state])"
|
||||
trim_list[fake_trim_name] = trim_path
|
||||
selected_trim_path = tgui_input_list(user, "Select trim to apply to your card.\nNote: This will not grant any trim accesses.", "Forge Trim", sort_list(trim_list, GLOBAL_PROC_REF(cmp_typepaths_asc)))
|
||||
if(!after_input_check(user))
|
||||
return TRUE
|
||||
|
||||
var/target_occupation = tgui_input_text(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels.", "Agent card job assignment", assignment ? assignment : "Assistant", MAX_NAME_LEN)
|
||||
if(!after_input_check(user))
|
||||
return TRUE
|
||||
|
||||
var/new_age = tgui_input_number(user, "Choose the ID's age", "Agent card age", AGE_MIN, AGE_MAX, AGE_MIN)
|
||||
if(!after_input_check(user))
|
||||
return TRUE
|
||||
|
||||
var/wallet_spoofing = tgui_alert(user, "Activate wallet ID spoofing, allowing this card to force itself to occupy the visible ID slot in wallets?", "Wallet ID Spoofing", list("Yes", "No"))
|
||||
if(!after_input_check(user))
|
||||
return
|
||||
|
||||
registered_name = input_name
|
||||
if(selected_trim_path)
|
||||
SSid_access.apply_trim_to_chameleon_card(src, trim_list[selected_trim_path])
|
||||
if(target_occupation)
|
||||
assignment = sanitize(target_occupation)
|
||||
if(new_age)
|
||||
registered_age = new_age
|
||||
if(wallet_spoofing == "Yes")
|
||||
ADD_TRAIT(src, TRAIT_MAGNETIC_ID_CARD, CHAMELEON_ITEM_TRAIT)
|
||||
|
||||
update_label()
|
||||
update_icon()
|
||||
forged = TRUE
|
||||
to_chat(user, span_notice("You successfully forge the ID card."))
|
||||
user.log_message("forged \the [initial(name)] with name \"[registered_name]\", occupation \"[assignment]\" and trim \"[trim?.assignment]\".", LOG_GAME)
|
||||
|
||||
if(!registered_account && ishuman(user))
|
||||
var/mob/living/carbon/human/accountowner = user
|
||||
|
||||
var/datum/bank_account/account = SSeconomy.bank_accounts_by_id["[accountowner.account_id]"]
|
||||
if(account)
|
||||
account.bank_cards += src
|
||||
registered_account = account
|
||||
to_chat(user, span_notice("Your account number has been automatically assigned."))
|
||||
|
||||
/obj/item/card/id/advanced/chameleon/proc/after_input_check(mob/user)
|
||||
if(QDELETED(user) || QDELETED(src) || !user.client || !user.can_perform_action(src, NEED_DEXTERITY|FORBID_TELEKINESIS_REACH))
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/obj/item/card/id/advanced/chameleon/add_item_context(obj/item/source, list/context, atom/target, mob/living/user,)
|
||||
. = ..()
|
||||
@@ -1727,7 +1738,7 @@
|
||||
var/input_assignment = tgui_input_text(user, "What assignment would you like to put on this card?", "Cardboard card job ssignment", scribbled_assignment || "Assistant", MAX_NAME_LEN)
|
||||
if(!after_input_check(user, item, input_assignment, scribbled_assignment))
|
||||
return
|
||||
scribbled_assignment = input_assignment
|
||||
scribbled_assignment = sanitize(input_assignment)
|
||||
var/list/details = item.get_writing_implement_details()
|
||||
details_colors[INDEX_ASSIGNMENT_COLOR] = details["color"] || "#000000"
|
||||
if("Trim")
|
||||
|
||||
Reference in New Issue
Block a user