mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
Allows admins to edit transform matrices. (#11226)
* Allows admins to edit transform matrices. * Manual and reset. * Fix non-numbers.
This commit is contained in:
@@ -133,6 +133,8 @@
|
||||
|
||||
#define isatom(A) (istype(A, /atom))
|
||||
|
||||
#define ismatrix(A) (istype(A, /matrix))
|
||||
|
||||
//Macros for antags
|
||||
|
||||
#define isvampire(H) ((H.mind in ticker.mode.vampires) || H.mind.vampire)
|
||||
|
||||
@@ -262,6 +262,9 @@
|
||||
if(istype(D,/atom))
|
||||
body += "<option value='?_src_=vars;teleport_to=\ref[D]'>Teleport To</option>"
|
||||
|
||||
if (hasvar(D, "transform"))
|
||||
body += "<option value='?_src_=vars;edit_transform=\ref[D]'>Edit Transform Matrix</option>"
|
||||
|
||||
body += "<option value='?_src_=vars;proc_call=\ref[D]'>Proc call</option>"
|
||||
|
||||
body += "<option value>---</option>"
|
||||
@@ -1021,4 +1024,19 @@ body
|
||||
|
||||
callatomproc(DAT) //Yes it could be a datum, technically but eh
|
||||
|
||||
else if (href_list["edit_transform"])
|
||||
if (!check_rights(R_DEBUG))
|
||||
return
|
||||
|
||||
var/datum/DAT = locate(href_list["edit_transform"])
|
||||
if (!hasvar(DAT, "transform"))
|
||||
to_chat(src, "This object does not have a transform variable to edit!")
|
||||
return
|
||||
|
||||
var/matrix/M = DAT.vars["transform"] // It's like using a colon but without the colon!
|
||||
|
||||
if (!istype(M))
|
||||
to_chat(src, "Transform is not set to a /matrix.")
|
||||
return
|
||||
|
||||
DAT.vars["transform"] = modify_matrix_menu(M)
|
||||
|
||||
@@ -76,6 +76,10 @@
|
||||
var_value = "[bicon(var_value)]"
|
||||
default = "icon"
|
||||
|
||||
else if(ismatrix(var_value))
|
||||
to_chat(usr, "Variable appears to be <b>MATRIX</b>.")
|
||||
default = "matrix"
|
||||
|
||||
else if(istype(var_value,/atom) || istype(var_value,/datum))
|
||||
to_chat(usr, "Variable appears to be <b>TYPE</b>.")
|
||||
default = "type"
|
||||
@@ -117,7 +121,7 @@
|
||||
to_chat(usr, "If a direction, direction is: [dir]")
|
||||
|
||||
var/class = input("What kind of variable?","Variable Type",default) as null|anything in list("text",
|
||||
"num","type","icon","file","edit referenced object","restore to default")
|
||||
"num","type","icon","file","matrix", "edit referenced object","restore to default")
|
||||
|
||||
if(!class)
|
||||
return
|
||||
@@ -441,5 +445,48 @@
|
||||
if (A.type == O.type)
|
||||
A.vars[variable] = O.vars[variable]
|
||||
|
||||
if ("matrix")
|
||||
var/matrix/new_value = modify_matrix_menu(O.vars[variable], verbose = FALSE)
|
||||
if (!new_value)
|
||||
return
|
||||
|
||||
O.vars[variable] = new_value
|
||||
if(method)
|
||||
if(istype(O, /mob))
|
||||
for(var/mob/M in mob_list)
|
||||
if ( istype(M , O.type) )
|
||||
M.vars[variable] = O.vars[variable]
|
||||
|
||||
else if(istype(O, /obj))
|
||||
for(var/obj/A in world)
|
||||
if ( istype(A , O.type) )
|
||||
A.vars[variable] = O.vars[variable]
|
||||
|
||||
else if(istype(O, /turf))
|
||||
var/count = 0
|
||||
for(var/turf/A in turfs)
|
||||
count++
|
||||
if(!(count % 50000)) sleep(world.tick_lag)
|
||||
if ( istype(A , O.type) )
|
||||
A.vars[variable] = O.vars[variable]
|
||||
else
|
||||
if(istype(O, /mob))
|
||||
for(var/mob/M in mob_list)
|
||||
if (M.type == O.type)
|
||||
M.vars[variable] = O.vars[variable]
|
||||
|
||||
else if(istype(O, /obj))
|
||||
for(var/obj/A in world)
|
||||
if (A.type == O.type)
|
||||
A.vars[variable] = O.vars[variable]
|
||||
|
||||
else if(istype(O, /turf))
|
||||
var/count = 0
|
||||
for(var/turf/A in turfs)
|
||||
count++
|
||||
if(!(count % 50000)) sleep(world.tick_lag)
|
||||
if (A.type == O.type)
|
||||
A.vars[variable] = O.vars[variable]
|
||||
|
||||
log_admin("[key_name(src)] mass modified [original_name]'s [variable] to [O.vars[variable]]")
|
||||
message_admins("[key_name_admin(src)] mass modified [original_name]'s [variable] to [O.vars[variable]]", 1)
|
||||
@@ -367,6 +367,10 @@ var/list/forbidden_varedit_object_types = list(
|
||||
var_value = "[bicon(var_value)]"
|
||||
class = "icon"
|
||||
|
||||
else if(ismatrix(var_value))
|
||||
to_chat(usr, "Variable appears to be <b>MATRIX</b>.")
|
||||
class = "matrix"
|
||||
|
||||
else if(istype(var_value,/atom) || istype(var_value,/datum))
|
||||
to_chat(usr, "Variable appears to be <b>TYPE</b>.")
|
||||
class = "type"
|
||||
@@ -423,6 +427,10 @@ var/list/forbidden_varedit_object_types = list(
|
||||
var_value = "[bicon(var_value)]"
|
||||
default = "icon"
|
||||
|
||||
else if(ismatrix(var_value))
|
||||
to_chat(usr, "Variable appears to be <b>MATRIX</b>.")
|
||||
default = "matrix"
|
||||
|
||||
else if(istype(var_value,/atom) || istype(var_value,/datum))
|
||||
to_chat(usr, "Variable appears to be <b>TYPE</b>.")
|
||||
default = "type"
|
||||
@@ -465,10 +473,10 @@ var/list/forbidden_varedit_object_types = list(
|
||||
|
||||
if(src.holder && src.holder.marked_datum)
|
||||
class = input("What kind of variable?","Variable Type",default) as null|anything in list("text",
|
||||
"num","type","reference","mob reference", "icon","file","list","edit referenced object","restore to default","marked datum ([holder.marked_datum.type])")
|
||||
"num","type","reference","mob reference", "icon","file","list","matrix","edit referenced object","restore to default","marked datum ([holder.marked_datum.type])")
|
||||
else
|
||||
class = input("What kind of variable?","Variable Type",default) as null|anything in list("text",
|
||||
"num","type","reference","mob reference", "icon","file","list","edit referenced object","restore to default")
|
||||
"num","type","reference","mob reference", "icon","file","list","matrix","edit referenced object","restore to default")
|
||||
|
||||
if(!class)
|
||||
return
|
||||
@@ -560,7 +568,60 @@ var/list/forbidden_varedit_object_types = list(
|
||||
if("marked datum")
|
||||
O.vars[variable] = holder.marked_datum
|
||||
|
||||
if("matrix")
|
||||
var/matrix/var_new = modify_matrix_menu(O.vars[variable])
|
||||
if (!var_new)
|
||||
return
|
||||
|
||||
O.vars[variable] = var_new
|
||||
|
||||
world.log << "### VarEdit by [src]: [O.type] [variable]=[html_encode("[O.vars[variable]]")]"
|
||||
log_admin("[key_name(src)] modified [original_name]'s [variable] to [O.vars[variable]]")
|
||||
message_admins("[key_name_admin(src)] modified [original_name]'s [variable] to [O.vars[variable]]", 1)
|
||||
|
||||
/client/proc/modify_matrix_menu(var/matrix/M = matrix(), var/verbose = TRUE)
|
||||
if (verbose)
|
||||
to_chat(src, "Current matrix: a: [M.a], b: [M.b], c: [M.c], d: [M.d], e: [M.e], f: [M.f].")
|
||||
|
||||
var/input = input("Which action do you want to apply to this matrix?") as null|anything in list("Scale", "Translate", "Turn", "Manual","Reset")
|
||||
if (!input)
|
||||
return
|
||||
|
||||
switch (input)
|
||||
if ("Scale")
|
||||
var/x = input("X scale") as num
|
||||
var/y = input("Y scale") as num
|
||||
|
||||
M.Scale(x, y)
|
||||
|
||||
if ("Translate")
|
||||
var/x = input("X amount") as num
|
||||
var/y = input("Y amount") as num
|
||||
|
||||
M.Translate(x, y)
|
||||
|
||||
if ("Turn")
|
||||
var/angle = input("Angle (clockwise)") as num
|
||||
|
||||
M.Turn(angle)
|
||||
|
||||
if ("Reset")
|
||||
M = matrix()
|
||||
|
||||
if ("Manual")
|
||||
var/list/numbers = splittext(input("Enter the matrix components as a comma separated list.") as text|null, ",")
|
||||
if (!numbers || numbers.len != 6)
|
||||
to_chat(src, "Cancelled or not enough arguments provided.")
|
||||
|
||||
else
|
||||
var/list/newnumbers = list()
|
||||
for (var/number in numbers)
|
||||
number = text2num(number) || 0
|
||||
newnumbers += number
|
||||
|
||||
M = matrix(newnumbers[1], newnumbers[2], newnumbers[3], newnumbers[4], newnumbers[5], newnumbers[6])
|
||||
|
||||
if (verbose)
|
||||
to_chat(src, "New matrix: a: [M.a], b: [M.b], c: [M.c], d: [M.d], e: [M.e], f: [M.f].")
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user