Skip to content

Commit

Permalink
[MIRROR] Paint sprayer features and bugfix (#2829)
Browse files Browse the repository at this point in the history
Co-authored-by: Hubblenaut <[email protected]>
Co-authored-by: Lexanx <[email protected]>
  • Loading branch information
3 people authored Nov 24, 2024
1 parent 74c48a4 commit d38b823
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 93 deletions.
236 changes: 143 additions & 93 deletions code/game/objects/items/devices/paint_sprayer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,60 @@
#define AIRLOCK_REGION_STRIPE "Stripe"
#define AIRLOCK_REGION_WINDOW "Window"

#define PLACEMENT_MODE_QUARTERS 1
#define PLACEMENT_MODE_TRIANGLES 2

#define CATEGORY_NONE 0
#define CATEGORY_TILES 1
#define CATEGORY_HAZARD 2
#define CATEGORY_WARD 3
#define CATEGORY_MISC 4

/obj/item/device/paint_sprayer
name = "paint sprayer"
icon = 'icons/obj/tools/paint_sprayer.dmi'
icon_state = "paint_sprayer"
item_state = "paint_sprayer"
desc = "A slender and none-too-sophisticated device capable of applying paint on floors, walls, exosuits and certain airlocks."
var/decal = "Quarter-turf"
var/decal = "Quarter-Tile"
var/paint_color
var/category

var/list/decals = list(
"Quarter-turf" = list("path" = /obj/floor_decal/corner, "precise" = 1, "colored" = 1),
"Monotile full" = list("path" = /obj/floor_decal/corner/white/mono, "colored" = 1),
"Monotile halved" = list("path" = /obj/floor_decal/corner/white/half, "colored" = 1),
"Hazard stripes" = list("path" = /obj/floor_decal/industrial/warning/fulltile),
"Border, hazard" = list("path" = /obj/floor_decal/industrial/warning),
"Corner, hazard" = list("path" = /obj/floor_decal/industrial/warning/corner, "precise" = 1),
"Hatched marking" = list("path" = /obj/floor_decal/industrial/hatch, "colored" = 1),
"Dashed outline" = list("path" = /obj/floor_decal/industrial/outline, "colored" = 1),
"Loading sign" = list("path" = /obj/floor_decal/industrial/loading),
"Mosaic, large" = list("path" = /obj/floor_decal/chapel),
"1" = list("path" = /obj/floor_decal/sign),
"2" = list("path" = /obj/floor_decal/sign/two),
"A" = list("path" = /obj/floor_decal/sign/a),
"B" = list("path" = /obj/floor_decal/sign/b),
"C" = list("path" = /obj/floor_decal/sign/c),
"D" = list("path" = /obj/floor_decal/sign/d),
"M" = list("path" = /obj/floor_decal/sign/m),
"V" = list("path" = /obj/floor_decal/sign/v),
"CMO" = list("path" = /obj/floor_decal/sign/cmo),
"Ex" = list("path" = /obj/floor_decal/sign/ex),
"Psy" = list("path" = /obj/floor_decal/sign/p),
"Remove all decals" = list("path" = /obj/floor_decal/reset),
)

var/list/paint_dirs = list(
"North" = NORTH,
"Northwest" = NORTHWEST,
"West" = WEST,
"Southwest" = SOUTHWEST,
"South" = SOUTH,
"Southeast" = SOUTHEAST,
"East" = EAST,
"Northeast" = NORTHEAST,
"Precise" = 0,
)
"Quarter-Tile" = list("path" = /obj/floor_decal/corner, "category" = CATEGORY_TILES, "colored" = TRUE, "placement" = PLACEMENT_MODE_QUARTERS),
"Half-Tile" = list("path" = /obj/floor_decal/corner/white/half, "category" = CATEGORY_TILES, "colored" = TRUE, "placement" = PLACEMENT_MODE_TRIANGLES),
"Full Tile" = list("path" = /obj/floor_decal/corner/white/mono, "category" = CATEGORY_TILES, "colored" = TRUE),
"Hatched Marking" = list("path" = /obj/floor_decal/industrial/hatch, "category" = CATEGORY_TILES, "colored" = TRUE),
"Dashed Outline" = list("path" = /obj/floor_decal/industrial/outline, "category" = CATEGORY_TILES, "colored" = TRUE),
"Hazard Border" = list("path" = /obj/floor_decal/industrial/warning, "category" = CATEGORY_HAZARD, "placement" = PLACEMENT_MODE_TRIANGLES),
"Hazard Outer Corner" = list("path" = /obj/floor_decal/industrial/warning/corner, "category" = CATEGORY_HAZARD, "placement" = PLACEMENT_MODE_QUARTERS),
"Hazard Inner Corner" = list("path" = /obj/floor_decal/industrial/warning/inner, "category" = CATEGORY_HAZARD, "placement" = PLACEMENT_MODE_QUARTERS),
"Hazard U-Corner" = list("path" = /obj/floor_decal/industrial/warning/cee, "category" = CATEGORY_HAZARD),
"Hazard Full Tile" = list("path" = /obj/floor_decal/industrial/warning/full, "category" = CATEGORY_HAZARD),
"Hazard Stripes" = list("path" = /obj/floor_decal/industrial/warning/fulltile, "category" = CATEGORY_HAZARD),
"1" = list("path" = /obj/floor_decal/sign, "category" = CATEGORY_WARD, "use_decal_icon" = TRUE),
"2" = list("path" = /obj/floor_decal/sign/two, "category" = CATEGORY_WARD, "use_decal_icon" = TRUE),
"A" = list("path" = /obj/floor_decal/sign/a, "category" = CATEGORY_WARD, "use_decal_icon" = TRUE),
"B" = list("path" = /obj/floor_decal/sign/b, "category" = CATEGORY_WARD, "use_decal_icon" = TRUE),
"C" = list("path" = /obj/floor_decal/sign/c, "category" = CATEGORY_WARD, "use_decal_icon" = TRUE),
"D" = list("path" = /obj/floor_decal/sign/d, "category" = CATEGORY_WARD, "use_decal_icon" = TRUE),
"M" = list("path" = /obj/floor_decal/sign/m, "category" = CATEGORY_WARD, "use_decal_icon" = TRUE),
"V" = list("path" = /obj/floor_decal/sign/v, "category" = CATEGORY_WARD, "use_decal_icon" = TRUE),
"CMO" = list("path" = /obj/floor_decal/sign/cmo, "category" = CATEGORY_WARD, "use_decal_icon" = TRUE),
"Ex" = list("path" = /obj/floor_decal/sign/ex, "category" = CATEGORY_WARD, "use_decal_icon" = TRUE),
"Psy" = list("path" = /obj/floor_decal/sign/p, "category" = CATEGORY_WARD, "use_decal_icon" = TRUE),
"Shutoff" = list("path" = /obj/floor_decal/industrial/shutoff, "category" = CATEGORY_MISC, "placement" = PLACEMENT_MODE_TRIANGLES, "use_decal_icon" = TRUE),
"Loading Sign" = list("path" = /obj/floor_decal/industrial/loading, "category" = CATEGORY_MISC, "placement" = PLACEMENT_MODE_TRIANGLES),
"Mosaic" = list("path" = /obj/floor_decal/chapel, "category" = CATEGORY_MISC, "placement" = PLACEMENT_MODE_QUARTERS, "inversed" = TRUE),
"Remove all decals" = list("path" = /obj/floor_decal/reset),
)

var/list/categories = list(
"Tile Decals" = list("id" = CATEGORY_TILES, "icon_state" = "tiles"),
"Hazard Decals" = list("id" = CATEGORY_HAZARD, "icon_state" = "stripefull"),
"Ward Decals" = list("id" = CATEGORY_WARD, "icon_state" = "ward"),
"Misc Decals" = list("id" = CATEGORY_MISC, "icon_state" = "misc"),
)

var/list/preset_colors = list(
"Beasty brown" = COLOR_BEASTY_BROWN,
Expand All @@ -68,7 +77,7 @@
"Yellow" = COLOR_AMBER,
"Sol blue" = COLOR_SOL,
"Bulkhead black" = COLOR_WALL_GUNMETAL,
)
)

/obj/item/device/paint_sprayer/Initialize()
. = ..()
Expand All @@ -90,6 +99,51 @@
ret.AddOverlays(overlay)
return ret

/obj/item/device/paint_sprayer/attack_self(mob/user)
if (!category)
show_home(user)
else
show_decals_by_category(user)

/obj/item/device/paint_sprayer/proc/show_home(mob/user)
var/radial = list()
radial["Remove all decals"] = mutable_appearance("icons/screen/radial.dmi", "cable_invalid")
radial["Pick color"] = mutable_appearance("icons/screen/radial.dmi", "color_hexagon")
for (var/key in categories)
radial[key] = mutable_appearance("icons/screen/radial.dmi", categories[key]["icon_state"])
var/choice = show_radial_menu(user, user, radial, require_near = TRUE, radius = 50, tooltips = TRUE, check_locs = list(src))
if (!choice || !user.use_sanity_check(src))
return
switch (choice)
if ("Remove all decals")
decal = choice
return
if ("Pick color")
choose_color(user)
return
category = categories[choice]["id"]
show_decals_by_category(user)

/obj/item/device/paint_sprayer/proc/show_decals_by_category(mob/user)
var/radial = list()
radial["Home"] = mutable_appearance('icons/screen/radial.dmi', "radial_home")
for (var/key in decals)
if (decals[key]["category"] != category)
continue
var/obj/type = decals[key]["path"]
var/mutable_appearance/I = mutable_appearance(decals[key]["use_decal_icon"] ? initial(type.icon) : "icons/screen/radial.dmi", initial(type.icon_state), decals[key]["colored"] ? paint_color : initial(type.color))
radial[key] = I
var/choice = show_radial_menu(user, user, radial, require_near = TRUE, radius = 50, tooltips = TRUE, check_locs = list(src))
if (!choice || !user.use_sanity_check(src))
return
if (choice == "Home")
category = CATEGORY_NONE
show_home(user)
return
decal = choice
playsound(src, 'sound/weapons/flipblade.ogg', 30, 1)
to_chat(user, SPAN_NOTICE("You set \the [src] decal to '[decal]'."))

/obj/item/device/paint_sprayer/on_active_hand(mob/user)
. = ..()
if (user.PushClickHandler(/datum/click_handler/default/paint_sprayer))
Expand Down Expand Up @@ -140,10 +194,6 @@
. = paint_airlock(A, user)
else if (istype(A, /mob/living/exosuit))
to_chat(user, SPAN_WARNING("You can't paint an active exosuit. Dismantle it first."))
. = FALSE
else
to_chat(user, SPAN_WARNING("\The [src] can only be used on floors, windows, walls, exosuits or certain airlocks."))
. = FALSE
if (.)
playsound(get_turf(src), 'sound/effects/spray3.ogg', 30, 1, -6)
return .
Expand Down Expand Up @@ -208,37 +258,50 @@
to_chat(user, SPAN_WARNING("\The [src] flashes an error light. You might need to reconfigure it."))
return FALSE

if((F.decals && length(F.decals) > 5) && !ispath(painting_decal, /obj/floor_decal/reset))
if((F.decals && length(F.decals) > 7) && !ispath(painting_decal, /obj/floor_decal/reset))
to_chat(user, SPAN_WARNING("\The [F] has been painted too much; you need to clear it off."))
return FALSE

var/painting_dir = 0
if(!decal_data["precise"])
painting_dir = user.dir
else
var/mouse_x = text2num(click_parameters["icon-x"])
var/mouse_y = text2num(click_parameters["icon-y"])
if(isnum(mouse_x) && isnum(mouse_y))
if(mouse_x <= 16)
if(mouse_y <= 16)
painting_dir = WEST
else
painting_dir = NORTH
else
if(mouse_y <= 16)
painting_dir = SOUTH
else
painting_dir = EAST
else
painting_dir = user.dir

var/painting_dir = calc_paint_dir(user, decal_data["placement"], click_parameters, decal_data["inversed"])
var/painting_color
if(decal_data["colored"] && paint_color)
painting_color = paint_color

new painting_decal(F, painting_dir, painting_color)
return TRUE

/obj/item/device/paint_sprayer/proc/calc_paint_dir(mob/user, placement_mode, click_parameters, inversed)
if (!placement_mode)
return user.dir
var/mouse_x = text2num(click_parameters["icon-x"])
var/mouse_y = text2num(click_parameters["icon-y"])
switch (placement_mode)
if (PLACEMENT_MODE_QUARTERS)
// One case for each of the four quarters of a turf
if (mouse_x <= 16)
if (mouse_y <= 16)
. = WEST
else
. = NORTH
else
if (mouse_y <= 16)
. = SOUTH
else
. = EAST
if (PLACEMENT_MODE_TRIANGLES)
// One case for each triangle sectioned off by the diagonals of a square
if (mouse_y > mouse_x)
if (mouse_y > 32-mouse_x)
. = NORTH
else
. = WEST
else
if (mouse_y > 32-mouse_x)
. = EAST
else
. = SOUTH
return inversed ? reverse_direction(.) : .

/obj/item/device/paint_sprayer/proc/pick_color_from_airlock(obj/machinery/door/airlock/D, mob/user)
if (!D.paintable)
return FALSE
Expand Down Expand Up @@ -282,9 +345,6 @@
return FALSE
return choice

/obj/item/device/paint_sprayer/attack_self(mob/user)
choose_decal()

/obj/item/device/paint_sprayer/proc/change_color(new_color, mob/user)
if (new_color)
paint_color = new_color
Expand All @@ -306,27 +366,22 @@
return TRUE
return ..()

/obj/item/device/paint_sprayer/CtrlClick()
/obj/item/device/paint_sprayer/CtrlClick(mob/user)
if (!isturf(loc))
choose_color()
choose_color(user)
return TRUE
return ..()

/obj/item/device/paint_sprayer/verb/choose_color()
set name = "Choose color"
set desc = "Choose a color."
set category = "Object"
set src in usr

if(usr.incapacitated())
/obj/item/device/paint_sprayer/proc/choose_color(mob/user)
if(user.incapacitated())
return
var/new_color = input(usr, "Choose a color.", name, paint_color) as color|null
if (usr.incapacitated())
var/new_color = input(user, "Choose a color.", name, paint_color) as color|null
if (user.incapacitated())
return
change_color(new_color, usr)
change_color(new_color, user)

/obj/item/device/paint_sprayer/verb/choose_preset_color()
set name = "Choose Preset color"
set name = "Choose Preset Color"
set desc = "Choose a preset color."
set category = "Object"
set src in usr
Expand All @@ -338,21 +393,6 @@
return
change_color(preset_colors[preset], usr)

/obj/item/device/paint_sprayer/verb/choose_decal()
set name = "Choose Decal"
set desc = "Choose a flooring decal."
set category = "Object"
set src in usr

if(usr.incapacitated())
return
var/new_decal = input("Select a decal.") as null|anything in decals
if(usr.incapacitated())
return
if(new_decal && !isnull(decals[new_decal]))
decal = new_decal
to_chat(usr, SPAN_NOTICE("You set \the [src] decal to '[decal]'."))

/datum/click_handler/default/paint_sprayer
var/obj/item/device/paint_sprayer/paint_sprayer

Expand All @@ -369,3 +409,13 @@

#undef AIRLOCK_REGION_PAINT
#undef AIRLOCK_REGION_STRIPE
#undef AIRLOCK_REGION_WINDOW

#undef PLACEMENT_MODE_QUARTERS
#undef PLACEMENT_MODE_TRIANGLES

#undef CATEGORY_NONE
#undef CATEGORY_TILES
#undef CATEGORY_HAZARD
#undef CATEGORY_WARD
#undef CATEGORY_MISC
3 changes: 3 additions & 0 deletions code/game/turfs/flooring/flooring_decals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,9 @@ var/global/list/floor_decals = list()
/obj/floor_decal/industrial/warning/corner
icon_state = "stripecorner"

/obj/floor_decal/industrial/warning/inner
icon_state = "stripeinner"

/obj/floor_decal/industrial/warning/full
icon_state = "stripefull"

Expand Down
Binary file modified icons/screen/radial.dmi
Binary file not shown.
Binary file modified icons/turf/flooring/decals.dmi
Binary file not shown.

0 comments on commit d38b823

Please sign in to comment.