From d92a0b9086a08a4e66f2a451dabab0f65f730f22 Mon Sep 17 00:00:00 2001 From: NovaBot <154629622+NovaBot13@users.noreply.github.com> Date: Fri, 8 Mar 2024 02:28:22 -0500 Subject: [PATCH 1/2] [MIRROR] Fixes tgui text input trimming the last char if the input hits the max length (#1333) * Fixes tgui text input trimming the last char if the input hits the max length (#81869) There's a one character discrepancy between the maximum length in the tgui input panel and that of the copied text, that's because `copytext("123456", 6)` will actually return `"12345"`, cutting off the last digit, so we need to increment the `max_length` by one if we want the right amount of characters to be return. This is also somewhat detailed in the DM lang "bluebook", and is in line with how `list.Copy()` also works. This fixes the museum password pad, which trimmed the last character of the input because of this oversight. :cl: fix: Fixed the tgui text input trimming the last character of the input if it hits the maximum length. fix: This also fixes the PIN pad leading to the right wing of the museum away mission. /:cl: * Fixes tgui text input trimming the last char if the input hits the max length * Fixes some of these edits from a prev merge because I'm dumb * Same as above --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> Co-authored-by: Mal <13398309+vinylspiders@users.noreply.github.com> --- code/__DEFINES/text.dm | 6 ++++ code/game/objects/items/food/sweets.dm | 39 ++++++++++++++++++++++++++ code/modules/tgui_input/text.dm | 6 ++-- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/code/__DEFINES/text.dm b/code/__DEFINES/text.dm index 9529d6c4fe2..18f1e9a5e1c 100644 --- a/code/__DEFINES/text.dm +++ b/code/__DEFINES/text.dm @@ -58,6 +58,12 @@ /// Removes everything enclose in < and > inclusive of the bracket, and limits the length of the message. #define STRIP_HTML_FULL(text, limit) (GLOB.html_tags.Replace(copytext(text, 1, limit), "")) +/** + * stuff like `copytext(input, length(input))` will trim the last character of the input, + * because DM does it so it copies until the char BEFORE the `end` arg, so we need to bump `end` by 1 in these cases. + */ +#define PREVENT_CHARACTER_TRIM_LOSS(integer) (integer + 1) + /// Folder directory for strings #define STRING_DIRECTORY "strings" diff --git a/code/game/objects/items/food/sweets.dm b/code/game/objects/items/food/sweets.dm index d757261ac01..f6cc9fbb6cf 100644 --- a/code/game/objects/items/food/sweets.dm +++ b/code/game/objects/items/food/sweets.dm @@ -306,12 +306,25 @@ venue_value = FOOD_PRICE_WORTHLESS var/mutable_appearance/head var/head_color = rgb(0, 0, 0) +<<<<<<< HEAD +======= + /// NOVA EDIT ADDITION BEGIN + //Copies reagent metabolization from bubblegum so that you cant get infinite reagents from wearing lolipops + var/metabolization_amount = REAGENTS_METABOLISM / 2 + // NOVA EDIT ADDITION END +>>>>>>> 6bc824c057f ([MIRROR] Fixes tgui text input trimming the last char if the input hits the max length (#1333)) /obj/item/food/lollipop/Initialize(mapload) . = ..() head = mutable_appearance('icons/obj/food/lollipop.dmi', "lollipop_head") change_head_color(rgb(rand(0, 255), rand(0, 255), rand(0, 255))) +<<<<<<< HEAD AddElement(/datum/element/chewable) +======= + // NOVA EDIT CHANGE BEGIN: Original: AddElement(/datum/element/chewable) + AddElement(/datum/element/chewable, metabolization_amount) + // NOVA EDIT CHANGE END +>>>>>>> 6bc824c057f ([MIRROR] Fixes tgui text input trimming the last char if the input hits the max length (#1333)) /obj/item/food/lollipop/proc/change_head_color(C) head_color = C @@ -350,10 +363,23 @@ food_flags = FOOD_FINGER_FOOD slot_flags = ITEM_SLOT_MASK crafting_complexity = FOOD_COMPLEXITY_1 +<<<<<<< HEAD /obj/item/food/spiderlollipop/Initialize(mapload) . = ..() AddElement(/datum/element/chewable) +======= + // NOVA EDIT ADDITION BEGIN + //Copies reagent metabolization from bubblegum so that you cant get infinite reagents from wearing lolipops + var/metabolization_amount = REAGENTS_METABOLISM / 2 + // NOVA EDIT ADDITION END + +/obj/item/food/spiderlollipop/Initialize(mapload) + . = ..() + // NOVA EDIT CHANGE BEGIN: Original: AddElement(/datum/element/chewable) + AddElement(/datum/element/chewable, metabolization_amount) + // NOVA EDIT CHANGE END +>>>>>>> 6bc824c057f ([MIRROR] Fixes tgui text input trimming the last char if the input hits the max length (#1333)) /obj/item/food/swirl_lollipop name = "swirl lollipop" @@ -371,7 +397,20 @@ food_flags = FOOD_FINGER_FOOD slot_flags = ITEM_SLOT_MASK crafting_complexity = FOOD_COMPLEXITY_1 +<<<<<<< HEAD /obj/item/food/swirl_lollipop/Initialize(mapload) . = ..() AddElement(/datum/element/chewable) +======= + /// NOVA EDIT ADDITION BEGIN + //Copies reagent metabolization from bubblegum so that you cant get infinite reagents from wearing lolipops + var/metabolization_amount = REAGENTS_METABOLISM / 2 + // NOVA EDIT ADDITION END + +/obj/item/food/swirl_lollipop/Initialize(mapload) + . = ..() + // NOVA EDIT ADDITIONBEGIN: Original: AddElement(/datum/element/chewable) + AddElement(/datum/element/chewable, metabolization_amount) + // NOVA EDIT ADDITION END +>>>>>>> 6bc824c057f ([MIRROR] Fixes tgui text input trimming the last char if the input hits the max length (#1333)) diff --git a/code/modules/tgui_input/text.dm b/code/modules/tgui_input/text.dm index f97e0326d58..4b3e59a6028 100644 --- a/code/modules/tgui_input/text.dm +++ b/code/modules/tgui_input/text.dm @@ -32,9 +32,9 @@ if(!user.client.prefs.read_preference(/datum/preference/toggle/tgui_input)) if(encode) if(multiline) - return stripped_multiline_input(user, message, title, default, max_length) + return stripped_multiline_input(user, message, title, default, PREVENT_CHARACTER_TRIM_LOSS(max_length)) else - return stripped_input(user, message, title, default, max_length) + return stripped_input(user, message, title, default, PREVENT_CHARACTER_TRIM_LOSS(max_length)) else if(multiline) return input(user, message, title, default) as message|null @@ -162,4 +162,4 @@ /datum/tgui_input_text/proc/set_entry(entry) if(!isnull(entry)) var/converted_entry = encode ? html_encode(entry) : entry - src.entry = trim(converted_entry, max_length) + src.entry = trim(converted_entry, PREVENT_CHARACTER_TRIM_LOSS(max_length)) From 304f71f24b54fb3d7207732d650224aea45772ca Mon Sep 17 00:00:00 2001 From: ReezeBL Date: Fri, 8 Mar 2024 12:47:27 +0300 Subject: [PATCH 2/2] Update sweets.dm mc resolve --- code/game/objects/items/food/sweets.dm | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/code/game/objects/items/food/sweets.dm b/code/game/objects/items/food/sweets.dm index f6cc9fbb6cf..538aad8826c 100644 --- a/code/game/objects/items/food/sweets.dm +++ b/code/game/objects/items/food/sweets.dm @@ -306,25 +306,18 @@ venue_value = FOOD_PRICE_WORTHLESS var/mutable_appearance/head var/head_color = rgb(0, 0, 0) -<<<<<<< HEAD -======= /// NOVA EDIT ADDITION BEGIN //Copies reagent metabolization from bubblegum so that you cant get infinite reagents from wearing lolipops var/metabolization_amount = REAGENTS_METABOLISM / 2 // NOVA EDIT ADDITION END ->>>>>>> 6bc824c057f ([MIRROR] Fixes tgui text input trimming the last char if the input hits the max length (#1333)) /obj/item/food/lollipop/Initialize(mapload) . = ..() head = mutable_appearance('icons/obj/food/lollipop.dmi', "lollipop_head") change_head_color(rgb(rand(0, 255), rand(0, 255), rand(0, 255))) -<<<<<<< HEAD - AddElement(/datum/element/chewable) -======= // NOVA EDIT CHANGE BEGIN: Original: AddElement(/datum/element/chewable) AddElement(/datum/element/chewable, metabolization_amount) // NOVA EDIT CHANGE END ->>>>>>> 6bc824c057f ([MIRROR] Fixes tgui text input trimming the last char if the input hits the max length (#1333)) /obj/item/food/lollipop/proc/change_head_color(C) head_color = C @@ -363,12 +356,6 @@ food_flags = FOOD_FINGER_FOOD slot_flags = ITEM_SLOT_MASK crafting_complexity = FOOD_COMPLEXITY_1 -<<<<<<< HEAD - -/obj/item/food/spiderlollipop/Initialize(mapload) - . = ..() - AddElement(/datum/element/chewable) -======= // NOVA EDIT ADDITION BEGIN //Copies reagent metabolization from bubblegum so that you cant get infinite reagents from wearing lolipops var/metabolization_amount = REAGENTS_METABOLISM / 2 @@ -379,7 +366,6 @@ // NOVA EDIT CHANGE BEGIN: Original: AddElement(/datum/element/chewable) AddElement(/datum/element/chewable, metabolization_amount) // NOVA EDIT CHANGE END ->>>>>>> 6bc824c057f ([MIRROR] Fixes tgui text input trimming the last char if the input hits the max length (#1333)) /obj/item/food/swirl_lollipop name = "swirl lollipop" @@ -397,12 +383,6 @@ food_flags = FOOD_FINGER_FOOD slot_flags = ITEM_SLOT_MASK crafting_complexity = FOOD_COMPLEXITY_1 -<<<<<<< HEAD - -/obj/item/food/swirl_lollipop/Initialize(mapload) - . = ..() - AddElement(/datum/element/chewable) -======= /// NOVA EDIT ADDITION BEGIN //Copies reagent metabolization from bubblegum so that you cant get infinite reagents from wearing lolipops var/metabolization_amount = REAGENTS_METABOLISM / 2 @@ -413,4 +393,3 @@ // NOVA EDIT ADDITIONBEGIN: Original: AddElement(/datum/element/chewable) AddElement(/datum/element/chewable, metabolization_amount) // NOVA EDIT ADDITION END ->>>>>>> 6bc824c057f ([MIRROR] Fixes tgui text input trimming the last char if the input hits the max length (#1333))