Graffiti centers on where you click. (#9255)

* Graffiti centers on where you click.

* Oversights, and pixelshifted engravings.

* Better returns
This commit is contained in:
Mechoid
2023-12-27 21:41:07 -08:00
committed by GitHub
parent 14c681720d
commit e976eaba4e
10 changed files with 122 additions and 22 deletions
+13 -1
View File
@@ -16,10 +16,20 @@
return FALSE
return TRUE
/datum/persistent/graffiti/CheckTokenSanity(var/list/token)
// byond's json implementation is "questionable", and uses types as keys and values without quotes sometimes even though they aren't valid json
token["pixel_x"] = istext(token["pixel_x"]) ? text2num(token["pixel_x"]) : token["pixel_x"]
token["pixel_y"] = istext(token["pixel_y"]) ? text2num(token["pixel_y"]) : token["pixel_y"]
return ..() && isnum(token["pixel_x"]) && isnum(token["pixel_y"])
/datum/persistent/graffiti/CreateEntryInstance(var/turf/creating, var/list/token)
var/obj/effect/decal/writing/inst = new /obj/effect/decal/writing(creating, token["age"]+1, token["message"], token["author"])
if(token["icon_state"])
inst.icon_state = token["icon_state"]
if(token["pixel_x"])
inst.pixel_x = token["pixel_x"]
if(token["pixel_y"])
inst.pixel_y = token["pixel_y"]
/datum/persistent/graffiti/IsValidEntry(var/atom/entry)
. = ..()
@@ -37,10 +47,12 @@
LAZYADDASSOC(., "author", "[save_graffiti.author ? save_graffiti.author : "unknown"]")
LAZYADDASSOC(., "message", "[save_graffiti.message]")
LAZYADDASSOC(., "icon_state", "[save_graffiti.icon_state]")
LAZYADDASSOC(., "pixel_x", "[save_graffiti.pixel_x]")
LAZYADDASSOC(., "pixel_y", "[save_graffiti.pixel_y]")
/datum/persistent/graffiti/GetAdminDataStringFor(var/thing, var/can_modify, var/mob/user)
var/obj/effect/decal/writing/save_graffiti = thing
if(can_modify)
. = "<td colspan = 2>[save_graffiti.message]</td><td>[save_graffiti.author]</td><td><a href='byond://?src=\ref[src];caller=\ref[user];remove_entry=\ref[thing]'>Destroy</a></td>"
else
. = "<td colspan = 3>[save_graffiti.message]</td><td>[save_graffiti.author]</td>"
. = "<td colspan = 3>[save_graffiti.message]</td><td>[save_graffiti.author]</td>"