Skip to content

Commit

Permalink
Merge pull request #49 from out-of-phaze/lighthouse-feature/gear-painter
Browse files Browse the repository at this point in the history
Add gear painter
  • Loading branch information
out-of-phaze authored Mar 27, 2024
2 parents 682281a + f77df64 commit c3c6fa7
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 0 deletions.
104 changes: 104 additions & 0 deletions code/game/machinery/gear_painter.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/obj/machinery/gear_painter
name = "\improper ColorMate"
desc = "A machine to give your apparel a fresh new color! Recommended to use with white items for best results."
icon = 'icons/obj/machines/gear_painter.dmi'
icon_state = "colormate"
density = TRUE
anchored = TRUE
/// The item to be colored.
var/obj/item/inserted
var/painting_color = COLOR_WHITE
var/list/allowed_types = list(
/obj/item/clothing,
/obj/item/towel,
/obj/item/storage/backpack,
/obj/item/storage/belt,
// todo: make color variant toys (plushies, etc) greyscaled?
// todo: make headsets use greyscale and decals? handling for painting stripes, etc. on specific objects?
)

/obj/machinery/gear_painter/on_update_icon()
if(panel_open)
icon_state = "colormate_open"
else if(inoperable())
icon_state = "colormate_off"
else if(inserted)
icon_state = "colormate_active"
else
icon_state = "colormate"

/obj/machinery/gear_painter/Destroy()
dump_contents() // this will handle try_unset_paintable as well
return ..()

/obj/machinery/gear_painter/proc/insert_paintable(obj/item/to_insert, mob/user)
if(user)
user.visible_message("<b>\The [user]</b> inserts \the [to_insert] into [src]'s receptable.", SPAN_NOTICE("You insert \the [to_insert] into [src]'s receptacle."))
user.drop_from_inventory(to_insert)
to_insert.forceMove(src)
inserted = to_insert
events_repository.register(/decl/observ/moved, to_insert, src, PROC_REF(try_unset_paintable))
SSnano.update_uis(src)
update_icon()

/obj/machinery/gear_painter/proc/try_unset_paintable(obj/item/removed)
if(removed.loc == src)
return
// do not move it, this is called when it's already been removed
inserted = null
events_repository.unregister(/decl/observ/moved, removed, src, PROC_REF(try_unset_paintable))

/obj/machinery/gear_painter/attackby(obj/item/held_item, mob/user)
if(!is_type_in_list(held_item, allowed_types))
return ..()
if(inserted)
to_chat(user, SPAN_WARNING("The machine is full."))
return TRUE
if(inoperable())
return TRUE
insert_paintable(held_item, user)
return TRUE

/obj/machinery/gear_painter/interface_interact(mob/user)
ui_interact(user)
return TRUE

/obj/machinery/gear_painter/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
. = ..()
var/list/data = list()
if(inserted)
data["item"] = inserted.name
data["item_color"] = inserted.paint_color
data["painting_color"] = painting_color
ui = SSnano.try_update_ui(user, src, ui_key, ui, data, force_open)
if(!ui)
ui = new(user, src, name, "gear_painter.tmpl", name)
ui.set_initial_data(data)
ui.open()

/obj/machinery/gear_painter/OnTopic(mob/user, href_list, datum/topic_state/state)
. = ..()
if(.)
return .

add_fingerprint(usr)

if(href_list["select"])
var/newcolor = input(usr, "Choose a color.", "[name] color picking", painting_color) as color|null
if(newcolor)
painting_color = newcolor
return TOPIC_REFRESH

if(href_list["paint"])
inserted.set_color(painting_color)
playsound(src, 'sound/effects/spray3.ogg', 50, TRUE)
return TOPIC_REFRESH

if(href_list["clear"])
inserted.set_color(null) // COLOR_WHITE works too, but null is clearer that we're unsetting
playsound(src, 'sound/effects/spray3.ogg', 50, TRUE)
return TOPIC_REFRESH

if(href_list["eject"])
dump_contents() // removes inserted, handled by try_unset_paintable
return TOPIC_REFRESH
Binary file added icons/obj/machines/gear_painter.dmi
Binary file not shown.
31 changes: 31 additions & 0 deletions nano/templates/gear_painter.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div class="item">
<div class="itemLabelNarrow">
<b>Item</b>:
</div>
<div class="itemContent">
{{if data.item}}
<b>{{:data.item}}</b>
{{else}}
<b>None</b>
{{/if}}
</div>
</div>
<div class="item">
<div class="itemLabelNarrow">
<b>Color</b>:
</div>
<div class="itemContentWide">
<span style='font-family: fixedsys; font-size: 14px; background-color: {{:data.painting_color}}; color: {{:data.painting_color}}'>___</span>
&nbsp;&nbsp;{{:helper.link('Select Color', 'pencil', {'select' : 1})}}
</div>
</div>
<div class="item">
<div class="itemLabelNarrow">
<b>Actions</b>:
</div>
<div class="itemContentWide">
{{:helper.link('Paint', 'gear', {'paint' : 1}, data.item ? null : 'disabled')}}
{{:helper.link('Remove Paint', 'cancel', {'clear' : 1}, (!data.item || !data.item_color) ? 'disabled' : null)}}
{{:helper.link('Eject', 'eject', {'eject' : 1}, data.item ? null : 'disabled')}}
</div>
</div>
1 change: 1 addition & 0 deletions nebula.dme
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@
#include "code\game\machinery\floodlight.dm"
#include "code\game\machinery\floor_light.dm"
#include "code\game\machinery\floorlayer.dm"
#include "code\game\machinery\gear_painter.dm"
#include "code\game\machinery\hologram.dm"
#include "code\game\machinery\holosign.dm"
#include "code\game\machinery\igniter.dm"
Expand Down

0 comments on commit c3c6fa7

Please sign in to comment.