From 4d41a2186a06db85e14fb1c73bcc217b7f5de96a Mon Sep 17 00:00:00 2001 From: Ghom <42542238+Ghommie@users.noreply.github.com> Date: Fri, 1 Apr 2022 00:38:18 +0200 Subject: [PATCH] Changes the values of the pen colour variable from color name to hexadecimal (#65553) About The Pull Request See the title. Hexadecimal values are better than color names for programming since they can be sanitized and are more easily converted to RGB(A) or HSV. Color names aren't really meant to be used in some functions and methods about colors. TL;DR: color names don't work with the Color common package in the TGUI folder. Why It's Good For The Game This will remove the need of a hacky bandaid from /obj/item/canvas/proc/get_paint_tool_color that only covers about half the pen colors anyway. Changelog cl fix: Fixed certain pens breaking painting on a canvas because of their peculiar colors. /cl --- code/modules/art/paintings.dm | 11 ++-------- code/modules/paperwork/pen.dm | 39 ++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/code/modules/art/paintings.dm b/code/modules/art/paintings.dm index 7760276b688..df8ec56e18b 100644 --- a/code/modules/art/paintings.dm +++ b/code/modules/art/paintings.dm @@ -301,15 +301,8 @@ var/obj/item/toy/crayon/crayon = painting_implement return crayon.paint_color else if(istype(painting_implement, /obj/item/pen)) - var/obj/item/pen/P = painting_implement - switch(P.colour) - if("black") - return "#000000" - if("blue") - return "#0000ff" - if("red") - return "#ff0000" - return P.colour + var/obj/item/pen/pen = painting_implement + return pen.colour else if(istype(painting_implement, /obj/item/soap) || istype(painting_implement, /obj/item/reagent_containers/glass/rag)) return canvas_color diff --git a/code/modules/paperwork/pen.dm b/code/modules/paperwork/pen.dm index ca4df513907..2d9d207ac4f 100644 --- a/code/modules/paperwork/pen.dm +++ b/code/modules/paperwork/pen.dm @@ -25,7 +25,7 @@ custom_materials = list(/datum/material/iron=10) pressure_resistance = 2 grind_results = list(/datum/reagent/iron = 2, /datum/reagent/iodine = 1) - var/colour = "black" //what colour the ink is! + var/colour = "#000000" //what colour the ink is! var/degrees = 0 var/font = PEN_FONT embedding = list(embed_chance = 50) @@ -38,39 +38,44 @@ /obj/item/pen/blue desc = "It's a normal blue ink pen." icon_state = "pen_blue" - colour = "blue" + colour = "#0000FF" /obj/item/pen/red desc = "It's a normal red ink pen." icon_state = "pen_red" - colour = "red" + colour = "#FF0000" throw_speed = 4 // red ones go faster (in this case, fast enough to embed!) /obj/item/pen/invisible desc = "It's an invisible pen marker." icon_state = "pen" - colour = "white" + colour = "#FFFFFF" /obj/item/pen/fourcolor desc = "It's a fancy four-color ink pen, set to black." name = "four-color pen" icon_state = "pen_4color" - colour = "black" + colour = "#000000" /obj/item/pen/fourcolor/attack_self(mob/living/carbon/user) + . = ..() + var/chosen_color = "black" switch(colour) - if("black") - colour = "red" + if("#000000") + colour = "#FF0000" + chosen_color = "red" throw_speed++ - if("red") - colour = "green" + if("#FF0000") + colour = "#00FF00" + chosen_color = "green" throw_speed = initial(throw_speed) - if("green") - colour = "blue" + if("#00FF00") + colour = "#0000FF" + chosen_color = "blue" else - colour = "black" - to_chat(user, span_notice("\The [src] will now write in [colour].")) - desc = "It's a fancy four-color ink pen, set to [colour]." + colour = "#000000" + to_chat(user, span_notice("\The [src] will now write in [chosen_color].")) + desc = "It's a fancy four-color ink pen, set to [chosen_color]." /obj/item/pen/fountain name = "fountain pen" @@ -82,7 +87,7 @@ name = "charcoal stylus" desc = "It's just a wooden stick with some compressed ash on the end. At least it can write." icon_state = "pen-charcoal" - colour = "dimgray" + colour = "#696969" font = CHARCOAL_FONT custom_materials = null grind_results = list(/datum/reagent/ash = 5, /datum/reagent/cellulose = 10) @@ -101,7 +106,7 @@ force = 5 throwforce = 5 throw_speed = 4 - colour = "crimson" + colour = "#DC143C" custom_materials = list(/datum/material/gold = 750) sharpness = SHARP_EDGED resistance_flags = FIRE_PROOF @@ -309,4 +314,4 @@ tool_behaviour = TOOL_MINING //For the classic "digging out of prison with a spoon but you're in space so this analogy doesn't work" situation. toolspeed = 10 //You will never willingly choose to use one of these over a shovel. font = FOUNTAIN_PEN_FONT - colour = "blue" + colour = "#0000FF"