From f483ed11573b072cefade8305321103e8a2e6348 Mon Sep 17 00:00:00 2001 From: Arkatos1 <43862960+Arkatos1@users.noreply.github.com> Date: Thu, 24 Dec 2020 10:05:05 +0100 Subject: [PATCH] WireArt: Fixed and improved (#55622) Cyborg's pipe cleaner is now using a radial menu for choosing it's colors instead of a clumsy input one. RCL now properly updates it's pipe cleaner holder's color, so you can actually see the color when using RCL radial menu. RCL is now able to put cables down on floors seamlessly, as there is no reason to restrict it to just a plating and catwalks anymore due to the fact that pipe cleaner coils no longer function as a power carriers, but are merely visual entities for players to play with. And lastly, pipe cleaners now use color defines and are setting its color directly instead of having redundant variable do it for them, which was needlessly complicating it. --- code/__DEFINES/colors.dm | 4 + code/game/objects/items/RCL.dm | 17 +-- code/modules/power/pipecleaners.dm | 172 ++++++++++++++--------------- 3 files changed, 97 insertions(+), 96 deletions(-) diff --git a/code/__DEFINES/colors.dm b/code/__DEFINES/colors.dm index cb6328110c3..119473eecf1 100644 --- a/code/__DEFINES/colors.dm +++ b/code/__DEFINES/colors.dm @@ -33,6 +33,7 @@ #define COLOR_OLIVE "#808000" #define COLOR_VIBRANT_LIME "#00FF00" #define COLOR_LIME "#32CD32" +#define COLOR_DARK_LIME "#00aa00" #define COLOR_VERY_PALE_LIME_GREEN "#DDFFD3" #define COLOR_VERY_DARK_LIME_GREEN "#003300" #define COLOR_GREEN "#008000" @@ -42,6 +43,7 @@ #define COLOR_DARK_CYAN "#00A2FF" #define COLOR_TEAL "#008080" #define COLOR_BLUE "#0000FF" +#define COLOR_STRONG_BLUE "#1919c8" #define COLOR_BRIGHT_BLUE "#2CB2E8" #define COLOR_MODERATE_BLUE "#555CC2" #define COLOR_BLUE_LIGHT "#33CCFF" @@ -49,6 +51,7 @@ #define COLOR_BLUE_GRAY "#75A2BB" #define COLOR_PINK "#FFC0CB" +#define COLOR_LIGHT_PINK "#ff3cc8" #define COLOR_MOSTLY_PURE_PINK "#E4005B" #define COLOR_MAGENTA "#FF00FF" #define COLOR_STRONG_MAGENTA "#B800B8" @@ -57,6 +60,7 @@ #define COLOR_STRONG_VIOLET "#6927c5" #define COLOR_ORANGE "#FF9900" +#define COLOR_MOSTLY_PURE_ORANGE "#ff8000" #define COLOR_TAN_ORANGE "#FF7B00" #define COLOR_BRIGHT_ORANGE "#E2853D" #define COLOR_LIGHT_ORANGE "#ffc44d" diff --git a/code/game/objects/items/RCL.dm b/code/game/objects/items/RCL.dm index 8cb70bb2669..32b7523cbd4 100644 --- a/code/game/objects/items/RCL.dm +++ b/code/game/objects/items/RCL.dm @@ -198,7 +198,7 @@ if(last) if(get_dist(last, user) == 1) //hacky, but it works var/turf/T = get_turf(user) - if(T.intact || !T.can_have_cabling()) + if(!T.can_have_cabling()) last = null return if(get_dir(last, user) == last.d2) @@ -210,7 +210,8 @@ return //If we've run out, display message and exit else last = null - loaded.pipe_cleaner_color = colors[current_color_index] + loaded.color = GLOB.pipe_cleaner_colors[colors[current_color_index]] + loaded.update_icon() last = loaded.place_turf(get_turf(src), user, turn(user.dir, 180)) is_empty(user) //If we've run out, display message update_icon() @@ -223,13 +224,13 @@ return T = get_turf(user) - if(T.intact || !T.can_have_cabling()) + if(!T.can_have_cabling()) return for(var/obj/structure/pipe_cleaner/C in T) if(!C) continue - if(C.pipe_cleaner_color != GLOB.pipe_cleaner_colors[colors[current_color_index]]) + if(C.color != GLOB.pipe_cleaner_colors[colors[current_color_index]]) continue if(C.d1 == 0) return C @@ -280,10 +281,11 @@ return var/turf/T = get_turf(user) - if(T.intact || !T.can_have_cabling()) + if(!T.can_have_cabling()) return - loaded.pipe_cleaner_color = colors[current_color_index] + loaded.color = GLOB.pipe_cleaner_colors[colors[current_color_index]] + loaded.update_icon() var/obj/structure/pipe_cleaner/linkingCable = findLinkingCable(user) if(linkingCable) @@ -316,7 +318,8 @@ var/cwname = colors[current_color_index] to_chat(user, "Color changed to [cwname]!") if(loaded) - loaded.pipe_cleaner_color = colors[current_color_index] + loaded.color = GLOB.pipe_cleaner_colors[colors[current_color_index]] + loaded.update_icon() if(wiring_gui_menu) wiringGuiUpdate(user) else if(istype(action, /datum/action/item_action/rcl_gui)) diff --git a/code/modules/power/pipecleaners.dm b/code/modules/power/pipecleaners.dm index 444a72dee1a..ee389e0e5d0 100644 --- a/code/modules/power/pipecleaners.dm +++ b/code/modules/power/pipecleaners.dm @@ -1,12 +1,12 @@ GLOBAL_LIST_INIT(pipe_cleaner_colors, list( - "yellow" = "#ffff00", - "green" = "#00aa00", - "blue" = "#1919c8", - "pink" = "#ff3cc8", - "orange" = "#ff8000", - "cyan" = "#00ffff", - "white" = "#ffffff", - "red" = "#ff0000" + "blue" = COLOR_STRONG_BLUE, + "cyan" = COLOR_CYAN, + "green" = COLOR_DARK_LIME, + "orange" = COLOR_MOSTLY_PURE_ORANGE, + "pink" = COLOR_LIGHT_PINK, + "red" = COLOR_RED, + "white" = COLOR_WHITE, + "yellow" = COLOR_YELLOW )) //This is the old cable code, but minus any actual powernet logic @@ -42,40 +42,34 @@ By design, d1 is the smallest direction and d2 is the highest layer = WIRE_LAYER //Above hidden pipes, GAS_PIPE_HIDDEN_LAYER anchored = TRUE obj_flags = CAN_BE_HIT | ON_BLUEPRINTS - var/d1 = 0 // pipe_cleaner direction 1 (see above) - var/d2 = 1 // pipe_cleaner direction 2 (see above) + color = COLOR_RED + /// Pipe_cleaner direction 1 (see above) + var/d1 = 0 + /// pipe_cleaner direction 2 (see above) + var/d2 = 1 + /// Internal cable stack var/obj/item/stack/pipe_cleaner_coil/stored - var/pipe_cleaner_color = "red" - color = "#ff0000" - /obj/structure/pipe_cleaner/yellow - pipe_cleaner_color = "yellow" - color = "#ffff00" + color = COLOR_YELLOW /obj/structure/pipe_cleaner/green - pipe_cleaner_color = "green" - color = "#00aa00" + color = COLOR_DARK_LIME /obj/structure/pipe_cleaner/blue - pipe_cleaner_color = "blue" - color = "#1919c8" + color = COLOR_STRONG_BLUE /obj/structure/pipe_cleaner/pink - pipe_cleaner_color = "pink" - color = "#ff3cc8" + color = COLOR_LIGHT_PINK /obj/structure/pipe_cleaner/orange - pipe_cleaner_color = "orange" - color = "#ff8000" + color = COLOR_MOSTLY_PURE_ORANGE /obj/structure/pipe_cleaner/cyan - pipe_cleaner_color = "cyan" - color = "#00ffff" + color = COLOR_CYAN /obj/structure/pipe_cleaner/white - pipe_cleaner_color = "white" - color = "#ffffff" + color = COLOR_WHITE // the power pipe_cleaner object /obj/structure/pipe_cleaner/Initialize(mapload, param_color) @@ -87,14 +81,15 @@ By design, d1 is the smallest direction and d2 is the highest d2 = text2num(copytext(icon_state, dash + length(icon_state[dash]))) if(d1) - stored = new/obj/item/stack/pipe_cleaner_coil(null,2,pipe_cleaner_color) + stored = new/obj/item/stack/pipe_cleaner_coil(null, 2, color) else - stored = new/obj/item/stack/pipe_cleaner_coil(null,1,pipe_cleaner_color) + stored = new/obj/item/stack/pipe_cleaner_coil(null, 1, color) - var/list/pipe_cleaner_colors = GLOB.pipe_cleaner_colors - pipe_cleaner_color = param_color || pipe_cleaner_color || pick(pipe_cleaner_colors) - if(pipe_cleaner_colors[pipe_cleaner_color]) - pipe_cleaner_color = pipe_cleaner_colors[pipe_cleaner_color] + color = param_color || color + if(!color) + var/list/pipe_cleaner_colors = GLOB.pipe_cleaner_colors + var/random_color = pick(pipe_cleaner_colors) + color = pipe_cleaner_colors[random_color] update_icon() /obj/structure/pipe_cleaner/Destroy() // called when a pipe_cleaner is deleted @@ -120,8 +115,7 @@ By design, d1 is the smallest direction and d2 is the highest /obj/structure/pipe_cleaner/update_icon() icon_state = "[d1]-[d2]" - color = null - add_atom_colour(pipe_cleaner_color, FIXED_COLOUR_PRIORITY) + add_atom_colour(color, FIXED_COLOUR_PRIORITY) // Items usable on a pipe_cleaner : // - Wirecutters : cut it duh ! @@ -150,15 +144,14 @@ By design, d1 is the smallest direction and d2 is the highest /obj/structure/pipe_cleaner/attackby(obj/item/W, mob/user, params) handlecable(W, user, params) - /obj/structure/pipe_cleaner/singularity_pull(S, current_size) ..() if(current_size >= STAGE_FIVE) deconstruct() -/obj/structure/pipe_cleaner/proc/update_stored(length = 1, colorC = "red") +/obj/structure/pipe_cleaner/proc/update_stored(length = 1, colorC = COLOR_RED) stored.amount = length - stored.pipe_cleaner_color = colorC + stored.color = colorC stored.update_icon() /obj/structure/pipe_cleaner/AltClick(mob/living/user) @@ -203,16 +196,37 @@ By design, d1 is the smallest direction and d2 is the highest usesound = 'sound/items/deconstruct.ogg' cost = 1 source = /datum/robot_energy_storage/pipe_cleaner - /// Currently set cable color - var/pipe_cleaner_color = COLOR_RED + color = COLOR_RED /obj/item/stack/pipe_cleaner_coil/cyborg/attack_self(mob/user) - var/selected_color = input(user, "Pick a pipe cleaner color.", "Cable Color") as null|anything in list("blue", "cyan", "green", "orange", "pink", "red", "white", "yellow") + var/list/pipe_cleaner_colors = GLOB.pipe_cleaner_colors + var/list/possible_colors = list() + for(var/color in pipe_cleaner_colors) + var/image/pipe_icon = image(icon = src.icon, icon_state = src.icon_state) + pipe_icon.color = pipe_cleaner_colors[color] + possible_colors += list("[color]" = pipe_icon) + + var/selected_color = show_radial_menu(user, src, possible_colors, custom_check = CALLBACK(src, .proc/check_menu, user), radius = 40, require_near = TRUE) if(!selected_color) return - pipe_cleaner_color = GLOB.pipe_cleaner_colors[selected_color] + color = pipe_cleaner_colors[selected_color] update_icon() +/** + * Checks if we are allowed to interact with a radial menu + * + * Arguments: + * * user The mob interacting with the menu + */ +/obj/item/stack/pipe_cleaner_coil/cyborg/proc/check_menu(mob/user) + if(!istype(user)) + return FALSE + if(!user.is_holding(src)) + return FALSE + if(user.incapacitated()) + return FALSE + return TRUE + /obj/item/stack/pipe_cleaner_coil/suicide_act(mob/user) if(locate(/obj/structure/chair/stool) in get_turf(user)) user.visible_message("[user] is making a noose with [src]! It looks like [user.p_theyre()] trying to commit suicide!") @@ -223,10 +237,11 @@ By design, d1 is the smallest direction and d2 is the highest /obj/item/stack/pipe_cleaner_coil/Initialize(mapload, new_amount = null, param_color = null) . = ..() - var/list/pipe_cleaner_colors = GLOB.pipe_cleaner_colors - pipe_cleaner_color = param_color || pipe_cleaner_color || pick(pipe_cleaner_colors) - if(pipe_cleaner_colors[pipe_cleaner_color]) - pipe_cleaner_color = pipe_cleaner_colors[pipe_cleaner_color] + color = param_color || color + if(!color) + var/list/pipe_cleaner_colors = GLOB.pipe_cleaner_colors + var/random_color = pick(pipe_cleaner_colors) + color = pipe_cleaner_colors[random_color] pixel_x = base_pixel_x + rand(-2, 2) pixel_y = base_pixel_y + rand(-2, 2) @@ -236,12 +251,10 @@ By design, d1 is the smallest direction and d2 is the highest // General procedures /////////////////////////////////// - /obj/item/stack/pipe_cleaner_coil/update_icon() icon_state = "[initial(inhand_icon_state)][amount < 3 ? amount : ""]" name = "pipe cleaner [amount < 3 ? "piece" : "coil"]" - color = null - add_atom_colour(pipe_cleaner_color, FIXED_COLOUR_PRIORITY) + add_atom_colour(color, FIXED_COLOUR_PRIORITY) /obj/item/stack/pipe_cleaner_coil/attack_hand(mob/user) . = ..() @@ -249,7 +262,7 @@ By design, d1 is the smallest direction and d2 is the highest return var/obj/item/stack/pipe_cleaner_coil/new_pipe_cleaner = ..() if(istype(new_pipe_cleaner)) - new_pipe_cleaner.pipe_cleaner_color = pipe_cleaner_color + new_pipe_cleaner.color = color new_pipe_cleaner.update_icon() //add pipe_cleaners to the stack @@ -260,15 +273,13 @@ By design, d1 is the smallest direction and d2 is the highest amount += extra update_icon() - - /////////////////////////////////////////////// // Cable laying procedures ////////////////////////////////////////////// /obj/item/stack/pipe_cleaner_coil/proc/get_new_pipe_cleaner(location) var/path = /obj/structure/pipe_cleaner - return new path(location, pipe_cleaner_color) + return new path(location, color) // called when pipe_cleaner_coil is clicked on a turf /obj/item/stack/pipe_cleaner_coil/proc/place_turf(turf/T, mob/user, dirnew) @@ -395,7 +406,7 @@ By design, d1 is the smallest direction and d2 is the highest C.d2 = nd2 //updates the stored pipe_cleaner coil - C.update_stored(2, pipe_cleaner_color) + C.update_stored(2, color) C.add_fingerprint(user) C.update_icon() @@ -409,40 +420,31 @@ By design, d1 is the smallest direction and d2 is the highest ///////////////////////////// /obj/item/stack/pipe_cleaner_coil/red - pipe_cleaner_color = "red" - color = "#ff0000" + color = COLOR_RED /obj/item/stack/pipe_cleaner_coil/yellow - pipe_cleaner_color = "yellow" - color = "#ffff00" + color = COLOR_YELLOW /obj/item/stack/pipe_cleaner_coil/blue - pipe_cleaner_color = "blue" - color = "#1919c8" + color = COLOR_STRONG_BLUE /obj/item/stack/pipe_cleaner_coil/green - pipe_cleaner_color = "green" - color = "#00aa00" + color = COLOR_DARK_LIME /obj/item/stack/pipe_cleaner_coil/pink - pipe_cleaner_color = "pink" - color = "#ff3ccd" + color = COLOR_LIGHT_PINK /obj/item/stack/pipe_cleaner_coil/orange - pipe_cleaner_color = "orange" - color = "#ff8000" + color = COLOR_MOSTLY_PURE_ORANGE /obj/item/stack/pipe_cleaner_coil/cyan - pipe_cleaner_color = "cyan" - color = "#00ffff" + color = COLOR_CYAN /obj/item/stack/pipe_cleaner_coil/white - pipe_cleaner_color = "white" + color = COLOR_WHITE /obj/item/stack/pipe_cleaner_coil/random - pipe_cleaner_color = null - color = "#ffffff" - + color = null /obj/item/stack/pipe_cleaner_coil/random/five amount = 5 @@ -460,36 +462,28 @@ By design, d1 is the smallest direction and d2 is the highest update_icon() /obj/item/stack/pipe_cleaner_coil/cut/red - pipe_cleaner_color = "red" - color = "#ff0000" + color = COLOR_RED /obj/item/stack/pipe_cleaner_coil/cut/yellow - pipe_cleaner_color = "yellow" - color = "#ffff00" + color = COLOR_YELLOW /obj/item/stack/pipe_cleaner_coil/cut/blue - pipe_cleaner_color = "blue" - color = "#1919c8" + color = COLOR_STRONG_BLUE /obj/item/stack/pipe_cleaner_coil/cut/green - pipe_cleaner_color = "green" - color = "#00aa00" + color = COLOR_DARK_LIME /obj/item/stack/pipe_cleaner_coil/cut/pink - pipe_cleaner_color = "pink" - color = "#ff3ccd" + color = COLOR_LIGHT_PINK /obj/item/stack/pipe_cleaner_coil/cut/orange - pipe_cleaner_color = "orange" - color = "#ff8000" + color = COLOR_MOSTLY_PURE_ORANGE /obj/item/stack/pipe_cleaner_coil/cut/cyan - pipe_cleaner_color = "cyan" - color = "#00ffff" + color = COLOR_CYAN /obj/item/stack/pipe_cleaner_coil/cut/white - pipe_cleaner_color = "white" + color = COLOR_WHITE /obj/item/stack/pipe_cleaner_coil/cut/random - pipe_cleaner_color = null - color = "#ffffff" + color = null