From 3da97c06c947ef47d40b22c323697c07f94d7863 Mon Sep 17 00:00:00 2001
From: theo-3 <85434590+theo-3@users.noreply.github.com>
Date: Fri, 13 Aug 2021 11:31:23 +0300
Subject: [PATCH] Better feedback for variant renaming
Initialize variant to null, so the prev check doesn't mess up the first time
Add removal message to modder "remove" for consistency
No message if variant was not changed
---
code/modules/hydroponics/gene_modder.dm | 1 +
code/modules/hydroponics/seeds.dm | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/code/modules/hydroponics/gene_modder.dm b/code/modules/hydroponics/gene_modder.dm
index 1796cd487ef..13cce41ed77 100644
--- a/code/modules/hydroponics/gene_modder.dm
+++ b/code/modules/hydroponics/gene_modder.dm
@@ -407,6 +407,7 @@
return
seed.variant = null
seed.apply_variant_name()
+ to_chat(usr, "You remove the [seed.plantname]'s variant designation.")
interact(usr)
diff --git a/code/modules/hydroponics/seeds.dm b/code/modules/hydroponics/seeds.dm
index 0b8eee55145..8cd43d55827 100644
--- a/code/modules/hydroponics/seeds.dm
+++ b/code/modules/hydroponics/seeds.dm
@@ -10,7 +10,7 @@
var/plantname = "Plants" // Name of plant when planted.
var/product // A type path. The thing that is created when the plant is harvested.
var/species = "" // Used to update icons. Should match the name in the sprites unless all icon_* are overriden.
- var/variant = "" // Optional custom name to track modified plants. Can be set with pen or from gene modder.
+ var/variant = null // Optional custom name to track modified plants. Can be set with pen or from gene modder.
var/growing_icon = 'icons/obj/hydroponics/growing.dmi' //the file that stores the sprites of the growing plant from this seed.
var/icon_grow // Used to override grow icon (default is "[species]-grow"). You can use one grow icon for multiple closely related plants with it.
@@ -335,6 +335,7 @@
// adj parameter changes what Adjacent is called from, such as the gene modder or a tray
/obj/item/seeds/proc/variant_prompt(mob/user, obj/item/container = null)
+ var/prev = variant
var/V = input(user, "Choose variant name:", "Plant Variant Naming", variant) as text|null
if(isnull(V)) // Did the user cancel?
return
@@ -349,7 +350,8 @@
variant = copytext(sanitize(html_encode(trim(V))), 1, 64) // Sanitization must happen after null check because it converts nulls to empty strings
if(variant == "")
variant = null
- to_chat(user, "You [variant ? "change" : "remove"] the [plantname]'s variant designation.")
+ if(prev != variant)
+ to_chat(user, "You [variant ? "change" : "remove"] the [plantname]'s variant designation.")
apply_variant_name()
/obj/item/seeds/proc/apply_variant_name()