mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-23 04:51:32 +01:00
More gear tweak pain (#18607)
* sdfa * sfda * just to be safe, add some html strips guards to text inputs
This commit is contained in:
@@ -21,6 +21,9 @@
|
||||
|
||||
///Returns a list in plain english as a string
|
||||
/proc/english_list(list/input, nothing_text = "nothing", and_text = " and ", comma_text = ", ", final_comma_text = "" )
|
||||
SHOULD_BE_PURE(TRUE)
|
||||
SHOULD_NOT_SLEEP(TRUE)
|
||||
|
||||
var/total = length(input)
|
||||
switch(total)
|
||||
if (0)
|
||||
@@ -33,10 +36,8 @@
|
||||
var/output = ""
|
||||
var/index = 1
|
||||
while (index < total)
|
||||
if (index == total - 1)
|
||||
comma_text = final_comma_text
|
||||
|
||||
output += "[input[index]][comma_text]"
|
||||
//Slightly reformatted from overriding `comma_text` from the TG version as flags it as breaking purity otherwise
|
||||
output += "[input[index]][(index == total - 1) ? final_comma_text : comma_text]"
|
||||
index++
|
||||
|
||||
return "[output][and_text][input[index]]"
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* For example: a color tweak might show the user the currently selected color
|
||||
*/
|
||||
/datum/gear_tweak/proc/get_contents(var/metadata)
|
||||
SHOULD_NOT_SLEEP(TRUE)
|
||||
SHOULD_BE_PURE(TRUE)
|
||||
return
|
||||
|
||||
/**
|
||||
@@ -17,6 +19,8 @@
|
||||
* For example: A alpha tweak might return 255
|
||||
*/
|
||||
/datum/gear_tweak/proc/get_default()
|
||||
SHOULD_NOT_SLEEP(TRUE)
|
||||
SHOULD_BE_PURE(TRUE)
|
||||
return
|
||||
|
||||
/**
|
||||
@@ -24,18 +28,22 @@
|
||||
* For example: A alpha tweak might return something between 0 and 255
|
||||
*/
|
||||
/datum/gear_tweak/proc/get_random()
|
||||
SHOULD_NOT_SLEEP(TRUE)
|
||||
SHOULD_BE_PURE(TRUE)
|
||||
return get_default()
|
||||
|
||||
/**
|
||||
* Tweaks the gear data (parameter) based on the metadata (parameter)
|
||||
*/
|
||||
/datum/gear_tweak/proc/tweak_gear_data(var/metadata, var/datum/gear_data/gear_data)
|
||||
SHOULD_NOT_SLEEP(TRUE)
|
||||
return
|
||||
|
||||
/**
|
||||
* Applies the tweak to the item
|
||||
*/
|
||||
/datum/gear_tweak/proc/tweak_item(var/obj/item/I, var/metadata, var/mob/living/carbon/human/H)
|
||||
SHOULD_NOT_SLEEP(TRUE)
|
||||
return
|
||||
|
||||
/*
|
||||
@@ -82,7 +90,7 @@ Alpha adjustment
|
||||
return 255
|
||||
|
||||
/datum/gear_tweak/alpha/get_metadata(var/user, var/metadata, var/title = "Character Preference")
|
||||
var/selected_alpha = input(user, "Choose a color.", title, metadata) as num|null
|
||||
var/selected_alpha = tgui_input_number(user, "Choose a color.", title, 255)
|
||||
selected_alpha = Clamp(selected_alpha, 0, 255)
|
||||
return selected_alpha
|
||||
|
||||
@@ -116,7 +124,7 @@ var/datum/gear_tweak/color_rotation/gear_tweak_color_rotation = new()
|
||||
return 0
|
||||
|
||||
/datum/gear_tweak/color_rotation/get_metadata(var/user, var/metadata, var/title = "Color Rotation")
|
||||
return clamp(input(user, "Choose the amount of degrees to rotate the hue around the color wheel. (-180 - 180)", title, metadata) as num, -180, 180)
|
||||
return tgui_input_number(user, "Choose the amount of degrees to rotate the hue around the color wheel. (-180 - 180)", title, 0, 180, -180, round_value = TRUE)
|
||||
|
||||
/datum/gear_tweak/color_rotation/tweak_item(var/obj/item/I, var/metadata, var/mob/living/carbon/human/H)
|
||||
I.color = color_rotation(metadata)
|
||||
@@ -184,7 +192,7 @@ Content adjustment
|
||||
for(var/i = metadata.len to (valid_contents.len - 1))
|
||||
metadata += "Random"
|
||||
for(var/i = 1 to valid_contents.len)
|
||||
var/entry = input(user, "Choose an entry.", "Character Preference", metadata[i]) as null|anything in (valid_contents[i] + list("Random", "None"))
|
||||
var/entry = tgui_input_list(user, "Choose an entry.", "Character Preference", (valid_contents[i] + list("Random", "None")), metadata[i])
|
||||
if(entry)
|
||||
. += entry
|
||||
else
|
||||
@@ -223,7 +231,7 @@ Reagents adjustment
|
||||
return "Random"
|
||||
|
||||
/datum/gear_tweak/reagents/get_metadata(var/user, var/list/metadata)
|
||||
. = input(user, "Choose an entry.", "Character Preference", metadata) as null|anything in (valid_reagents + list("Random", "None"))
|
||||
. = tgui_input_list(user, "Choose an entry.", "Character Preference", (valid_reagents + list("Random", "None")), metadata)
|
||||
if(!.)
|
||||
return metadata
|
||||
|
||||
@@ -258,9 +266,13 @@ var/datum/gear_tweak/custom_name/gear_tweak_free_name = new()
|
||||
return ""
|
||||
|
||||
/datum/gear_tweak/custom_name/get_metadata(var/user, var/metadata)
|
||||
var/custom_name_input = null
|
||||
if(valid_custom_names)
|
||||
return input(user, "Choose an item name.", "Character Preference", metadata) as null|anything in valid_custom_names
|
||||
return sanitize(input(user, "Choose the item's name. Leave it blank to use the default name.", "Item Name", metadata) as text|null, MAX_LNAME_LEN, extra = 0)
|
||||
custom_name_input = tgui_input_list(user, "Choose an item name.", "Character Preference", valid_custom_names, metadata)
|
||||
else
|
||||
custom_name_input = strip_html(tgui_input_text(user, "Choose an item name.", "Character Preference", metadata, MAX_LNAME_LEN))
|
||||
|
||||
return custom_name_input
|
||||
|
||||
/datum/gear_tweak/custom_name/tweak_item(var/obj/item/I, var/metadata, var/mob/living/carbon/human/H)
|
||||
if(!metadata)
|
||||
@@ -291,20 +303,28 @@ var/datum/gear_tweak/custom_desc/gear_tweak_free_desc = new()
|
||||
return ""
|
||||
|
||||
/datum/gear_tweak/custom_desc/get_metadata(var/user, var/metadata)
|
||||
var/input_description = null
|
||||
|
||||
if(valid_custom_desc)
|
||||
return input(user, "Choose an item description.", "Character Preference", metadata) as null|anything in valid_custom_desc
|
||||
return sanitize(input(user, "Choose the item's description. Leave it blank to use the default description.", "Item Description", metadata) as message|null, extra = 0)
|
||||
input_description = tgui_input_list(user, "Choose an item description.", "Character Preference", valid_custom_desc, metadata)
|
||||
else
|
||||
input_description = strip_html(tgui_input_text(user, "Choose an item description.", "Character Preference", metadata))
|
||||
|
||||
return input_description
|
||||
|
||||
/datum/gear_tweak/custom_desc/tweak_item(var/obj/item/I, var/metadata, var/mob/living/carbon/human/H)
|
||||
if (!metadata && istype(I, /obj/item/clothing/accessory/badge))
|
||||
var/obj/item/clothing/accessory/badge/B = I
|
||||
B.stored_name = H.real_name
|
||||
return I.desc += "\nThe name [H.real_name] is written on it."
|
||||
if (!metadata)
|
||||
return I.desc
|
||||
//Snowflake customization for badges
|
||||
if(istype(I, /obj/item/clothing/accessory/badge))
|
||||
var/obj/item/clothing/accessory/badge/badge_to_tweak = I
|
||||
|
||||
badge_to_tweak.stored_name = H.real_name
|
||||
badge_to_tweak.desc = "[badge_to_tweak.desc]\nThe name [H.real_name] is written on it."
|
||||
|
||||
//If we don't have any metadata to apply, return
|
||||
if(!metadata)
|
||||
return
|
||||
|
||||
I.desc = metadata
|
||||
if ("stored_name" in I.vars)
|
||||
I.vars["stored_name"] = H.real_name
|
||||
|
||||
/*
|
||||
Paper Data
|
||||
@@ -316,7 +336,7 @@ Paper Data
|
||||
return ""
|
||||
|
||||
/datum/gear_tweak/paper_data/get_metadata(var/user, var/metadata)
|
||||
return sanitize(input(user, "Choose a pre-written message on the item.", "Pre-written Message", metadata) as message|null, MAX_PAPER_MESSAGE_LEN, extra = 0)
|
||||
return strip_html(tgui_input_text(user, "Choose a pre-written message on the item.", "Pre-written Message", metadata, MAX_PAPER_MESSAGE_LEN))
|
||||
|
||||
/datum/gear_tweak/paper_data/tweak_item(var/obj/item/paper/P, var/metadata, var/mob/living/carbon/human/H)
|
||||
if(!metadata || !istype(P))
|
||||
@@ -333,16 +353,20 @@ Paper Data
|
||||
return list(1, 10, 30)
|
||||
|
||||
/datum/gear_tweak/buddy_tag_config/get_metadata(var/user, var/metadata)
|
||||
var/newcode = input("Set new buddy ID number.", "Buddy Tag ID", metadata[1]) as num|null
|
||||
var/newcode = tgui_input_number(user, "Set new buddy ID number.", "Buddy Tag ID", metadata[1])
|
||||
if(isnull(newcode))
|
||||
newcode = metadata[1]
|
||||
var/newdist = input("Set new maximum range.", "Buddy Tag Range", metadata[2]) as num|null
|
||||
|
||||
var/newdist = tgui_input_number(user, "Set new maximum range.", "Buddy Tag Range", metadata[2])
|
||||
if(isnull(newdist))
|
||||
newdist = metadata[2]
|
||||
var/newtime = input("Set new search interval in seconds (minimum 30s).", "Buddy Tag Time Interval", metadata[3]) as num|null
|
||||
|
||||
var/newtime = tgui_input_number(user, "Set new search interval in seconds (minimum 30s).", "Buddy Tag Time Interval", metadata[3])
|
||||
if(isnull(newtime))
|
||||
newtime = metadata[3]
|
||||
|
||||
newtime = max(30, newtime)
|
||||
|
||||
return list(newcode, newdist, newtime)
|
||||
|
||||
/datum/gear_tweak/buddy_tag_config/tweak_item(var/obj/item/clothing/accessory/buddytag/BT, var/list/metadata, var/mob/living/carbon/human/H)
|
||||
|
||||
@@ -69,7 +69,7 @@ var/datum/gear_tweak/lipstick_application/gear_tweak_lipstick_application = new(
|
||||
return "No"
|
||||
|
||||
/datum/gear_tweak/lipstick_application/get_metadata(var/user, var/metadata, var/title = "Character Preference")
|
||||
var/selected_lipstick = input(user, "Do you want your character to start with lipstick applied?", title, metadata) as null|anything in list("Yes", "No")
|
||||
var/selected_lipstick = tgui_input_list(user, "Do you want your character to start with lipstick applied?", title, list("Yes", "No"), metadata)
|
||||
if(selected_lipstick)
|
||||
return selected_lipstick
|
||||
|
||||
|
||||
@@ -479,7 +479,7 @@ var/datum/gear_tweak/hair_block/gear_tweak_hair_block = new()
|
||||
return "Default"
|
||||
|
||||
/datum/gear_tweak/hair_block/get_metadata(var/user, var/metadata)
|
||||
return input(user, "Choose whether you want your headgear to block hair, or use the headgear's default.", "Hair Blocking", metadata) as anything in list("Yes", "No", "Default")
|
||||
return tgui_input_list(user, "Choose whether you want your headgear to block hair, or use the headgear's default.", "Hair Blocking", list("Yes", "No", "Default"), metadata)
|
||||
|
||||
/datum/gear_tweak/hair_block/tweak_item(var/obj/item/clothing/head/H, var/metadata)
|
||||
if(!istype(H))
|
||||
|
||||
@@ -175,7 +175,7 @@ var/datum/gear_tweak/shoe_layer/gear_tweak_shoe_layer = new()
|
||||
return "Over"
|
||||
|
||||
/datum/gear_tweak/shoe_layer/get_metadata(var/user, var/metadata)
|
||||
return input(user, "Choose whether you want the shoe to go over or under the uniform.", "Shoe Layer", metadata) as anything in list("Over", "Under")
|
||||
return tgui_input_list(user, "Choose whether you want the shoe to go over or under the uniform.", "Shoe Layer", list("Over", "Under"), metadata)
|
||||
|
||||
/datum/gear_tweak/shoe_layer/tweak_item(var/obj/item/clothing/shoes/S, var/metadata)
|
||||
if(!istype(S))
|
||||
|
||||
@@ -470,7 +470,8 @@ var/datum/gear_tweak/uniform_rolled_state/gear_tweak_uniform_rolled_state = new(
|
||||
if(rolled_down_state != -1 || ("[initial(uniform.icon_state)]_d[initial(uniform.contained_sprite) ? "_un" : "_s"]" in icon_states(under_icon)))
|
||||
possible_states += UNIFORM_ROLLED_DOWN
|
||||
|
||||
var/input = input(user, "Choose in which state you want your uniform to spawn in.", "Uniform State", metadata) as null|anything in possible_states
|
||||
var/input = tgui_input_list(user, "Choose in which state you want your uniform to spawn in.", "Uniform State", possible_states, metadata)
|
||||
|
||||
if(!input)
|
||||
input = metadata
|
||||
return input
|
||||
|
||||
@@ -257,7 +257,7 @@ var/datum/gear_tweak/social_credit/social_credit_tweak = new()
|
||||
return 5
|
||||
|
||||
/datum/gear_tweak/social_credit/get_metadata(var/user, var/metadata)
|
||||
var/credit_score = input(user, "Set the credit score your passport will display, refer to the wiki to gauge it. (It will be slightly randomized to simulate Nralakk calculations.)", "Social Credit Score") as null|num
|
||||
var/credit_score = tgui_input_number(user, "Set the credit score your passport will display, refer to the wiki to gauge it. (It will be slightly randomized to simulate Nralakk calculations.)", "Social Credit Score", round_value = FALSE)
|
||||
if(credit_score)
|
||||
return round(credit_score, 0.01)
|
||||
return metadata
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
################################
|
||||
# Example Changelog File
|
||||
#
|
||||
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
|
||||
#
|
||||
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
|
||||
# When it is, any changes listed below will disappear.
|
||||
#
|
||||
# Valid Prefixes:
|
||||
# bugfix
|
||||
# wip (For works in progress)
|
||||
# tweak
|
||||
# soundadd
|
||||
# sounddel
|
||||
# rscadd (general adding of nice things)
|
||||
# rscdel (general deleting of nice things)
|
||||
# imageadd
|
||||
# imagedel
|
||||
# maptweak
|
||||
# spellcheck (typo fixes)
|
||||
# experiment
|
||||
# balance
|
||||
# admin
|
||||
# backend
|
||||
# security
|
||||
# refactor
|
||||
#################################
|
||||
|
||||
# Your name.
|
||||
author: FluffyGhost
|
||||
|
||||
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
|
||||
delete-after: True
|
||||
|
||||
# Any changes you've made. See valid prefix list above.
|
||||
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
|
||||
# SCREW THIS UP AND IT WON'T WORK.
|
||||
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
|
||||
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
|
||||
changes:
|
||||
- backend: "Added various SDMM markings to the gear customization procs."
|
||||
- refactor: "Refactored the custom desc gear customization proc, that was extremely expensive for no reason."
|
||||
- refactor: "Refactored almost all the custom gear inputs to be TGUI ones."
|
||||
Reference in New Issue
Block a user