mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 11:13:16 +00:00
Edit variables and view variables combined.
Screenshot: http://www.kamletos.si/view%20vars3.JPG What C and E mean is written on the window itself. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@2178 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
|
||||||
|
// reference: /client/proc/modify_variables(var/atom/O, var/param_var_name = null, var/autodetect_class = 0)
|
||||||
|
|
||||||
client
|
client
|
||||||
proc/debug_variables(datum/D in world)
|
proc/debug_variables(datum/D in world)
|
||||||
set category = "Debug"
|
set category = "Debug"
|
||||||
@@ -19,6 +22,12 @@ client
|
|||||||
#endif
|
#endif
|
||||||
title = "[D] (\ref[D]) = [D.type]"
|
title = "[D] (\ref[D]) = [D.type]"
|
||||||
|
|
||||||
|
body += "<div align='center'><table width='100%'><tr><td width='50%'><div align='center'><b>[D]<br><font size='1'>[D.type]</font></b></div></td>"
|
||||||
|
|
||||||
|
body += "<td width='50%'><div align='center'><a href='byond://?src=\ref[src];datumrefresh=\ref[D];refresh=1'>Refresh</a></div></td></tr></table></div><hr>"
|
||||||
|
|
||||||
|
body += "<font size='1'><b>E</b> - Edit, tries to determine the variable type by itself.<br>"
|
||||||
|
body += "<b>C</b> - Change, asks you for the var type first.</font>"
|
||||||
|
|
||||||
body += "<ol>"
|
body += "<ol>"
|
||||||
|
|
||||||
@@ -29,7 +38,7 @@ client
|
|||||||
names = sortList(names)
|
names = sortList(names)
|
||||||
|
|
||||||
for (var/V in names)
|
for (var/V in names)
|
||||||
body += debug_variable(V, D.vars[V], 0)
|
body += debug_variable(V, D.vars[V], 0, D)
|
||||||
|
|
||||||
body += "</ol>"
|
body += "</ol>"
|
||||||
|
|
||||||
@@ -56,12 +65,12 @@ client
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
proc/debug_variable(name, value, level, var/datum/DA = null)
|
||||||
|
|
||||||
|
|
||||||
proc/debug_variable(name, value, level)
|
|
||||||
var/html = ""
|
var/html = ""
|
||||||
|
|
||||||
|
if(DA)
|
||||||
|
html += "<li>(<a href='byond://?src=\ref[src];datumedit=\ref[DA];varnameedit=[name]'>E</a>) (<a href='byond://?src=\ref[src];datumchange=\ref[DA];varnamechange=[name]'>C</a>) "
|
||||||
|
else
|
||||||
html += "<li>"
|
html += "<li>"
|
||||||
|
|
||||||
if (isnull(value))
|
if (isnull(value))
|
||||||
@@ -130,6 +139,39 @@ client
|
|||||||
|
|
||||||
if (href_list["Vars"])
|
if (href_list["Vars"])
|
||||||
debug_variables(locate(href_list["Vars"]))
|
debug_variables(locate(href_list["Vars"]))
|
||||||
|
else if (href_list["varnameedit"])
|
||||||
|
if(!href_list["datumedit"] || !href_list["varnameedit"])
|
||||||
|
usr << "Varedit error: Not all information has been sent Contact a coder."
|
||||||
|
return
|
||||||
|
var/datum/DAT = locate(href_list["datumedit"])
|
||||||
|
if(!DAT)
|
||||||
|
usr << "Item not found"
|
||||||
|
return
|
||||||
|
if(!istype(DAT,/datum))
|
||||||
|
usr << "Can't edit an item of this type. Type must be /datum, so anything except simple variables. [DAT]"
|
||||||
|
return
|
||||||
|
modify_variables(DAT, href_list["varnameedit"], 1)
|
||||||
|
else if (href_list["varnamechange"])
|
||||||
|
if(!href_list["datumchange"] || !href_list["varnamechange"])
|
||||||
|
usr << "Varedit error: Not all information has been sent. Contact a coder."
|
||||||
|
return
|
||||||
|
var/datum/DAT = locate(href_list["datumchange"])
|
||||||
|
if(!DAT)
|
||||||
|
usr << "Item not found"
|
||||||
|
return
|
||||||
|
if(!istype(DAT,/datum))
|
||||||
|
usr << "Can't edit an item of this type. Type must be /datum, so anything except simple variables. [DAT]"
|
||||||
|
return
|
||||||
|
modify_variables(DAT, href_list["varnamechange"], 0)
|
||||||
|
else if (href_list["refresh"])
|
||||||
|
if(!href_list["datumrefresh"])
|
||||||
|
return
|
||||||
|
var/datum/DAT = locate(href_list["datumrefresh"])
|
||||||
|
if(!DAT)
|
||||||
|
return
|
||||||
|
if(!istype(DAT,/datum))
|
||||||
|
return
|
||||||
|
src.debug_variables(DAT)
|
||||||
else
|
else
|
||||||
..()
|
..()
|
||||||
|
|
||||||
|
|||||||
@@ -227,26 +227,85 @@
|
|||||||
variable = input("Pick icon:","Icon",variable) \
|
variable = input("Pick icon:","Icon",variable) \
|
||||||
as icon
|
as icon
|
||||||
|
|
||||||
|
/client/proc/modify_variables(var/atom/O, var/param_var_name = null, var/autodetect_class = 0)
|
||||||
/client/proc/modify_variables(var/atom/O)
|
|
||||||
var/list/locked = list("vars", "key", "ckey", "client", "firemut", "ishulk", "telekinesis", "xray", "virus", "cuffed", "ka", "last_eaten", "urine", "poo", "icon", "icon_state")
|
var/list/locked = list("vars", "key", "ckey", "client", "firemut", "ishulk", "telekinesis", "xray", "virus", "cuffed", "ka", "last_eaten", "urine", "poo", "icon", "icon_state")
|
||||||
|
|
||||||
if(!src.authenticated || !src.holder)
|
if(!src.authenticated || !src.holder)
|
||||||
src << "Only administrators may use this command."
|
src << "Only administrators may use this command."
|
||||||
return
|
return
|
||||||
|
|
||||||
|
var/class
|
||||||
|
var/variable
|
||||||
|
var/var_value
|
||||||
|
|
||||||
|
if(param_var_name)
|
||||||
|
if(!param_var_name in O.vars)
|
||||||
|
src << "A variable with this name ([param_var_name]) doesn't exist in this atom ([O])"
|
||||||
|
return
|
||||||
|
|
||||||
|
if (param_var_name == "holder" && holder.rank != "Game Master")
|
||||||
|
src << "No. Stop being stupid."
|
||||||
|
return
|
||||||
|
|
||||||
|
if (locked.Find(param_var_name) && !(src.holder.rank in list("Game Master", "Game Admin")))
|
||||||
|
src << "Editing this variable requires you to be a game master or game admin."
|
||||||
|
return
|
||||||
|
|
||||||
|
variable = param_var_name
|
||||||
|
|
||||||
|
var_value = O.vars[variable]
|
||||||
|
|
||||||
|
if(autodetect_class)
|
||||||
|
if(isnull(var_value))
|
||||||
|
usr << "Unable to determine variable type."
|
||||||
|
class = null
|
||||||
|
autodetect_class = null
|
||||||
|
else if(isnum(var_value))
|
||||||
|
usr << "Variable appears to be <b>NUM</b>."
|
||||||
|
class = "num"
|
||||||
|
dir = 1
|
||||||
|
|
||||||
|
else if(istext(var_value))
|
||||||
|
usr << "Variable appears to be <b>TEXT</b>."
|
||||||
|
class = "text"
|
||||||
|
|
||||||
|
else if(isloc(var_value))
|
||||||
|
usr << "Variable appears to be <b>REFERENCE</b>."
|
||||||
|
class = "reference"
|
||||||
|
|
||||||
|
else if(isicon(var_value))
|
||||||
|
usr << "Variable appears to be <b>ICON</b>."
|
||||||
|
var_value = "\icon[var_value]"
|
||||||
|
class = "icon"
|
||||||
|
|
||||||
|
else if(istype(var_value,/atom) || istype(var_value,/datum))
|
||||||
|
usr << "Variable appears to be <b>TYPE</b>."
|
||||||
|
class = "type"
|
||||||
|
|
||||||
|
else if(istype(var_value,/list))
|
||||||
|
usr << "Variable appears to be <b>LIST</b>."
|
||||||
|
class = "list"
|
||||||
|
|
||||||
|
else if(istype(var_value,/client))
|
||||||
|
usr << "Variable appears to be <b>CLIENT</b>."
|
||||||
|
class = "cancel"
|
||||||
|
|
||||||
|
else
|
||||||
|
usr << "Variable appears to be <b>FILE</b>."
|
||||||
|
class = "file"
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
var/list/names = list()
|
var/list/names = list()
|
||||||
for (var/V in O.vars)
|
for (var/V in O.vars)
|
||||||
names += V
|
names += V
|
||||||
|
|
||||||
names = sortList(names)
|
names = sortList(names)
|
||||||
|
|
||||||
var/variable = input("Which var?","Var") as null|anything in names
|
variable = input("Which var?","Var") as null|anything in names
|
||||||
if(!variable)
|
if(!variable)
|
||||||
return
|
return
|
||||||
var/default
|
var_value = O.vars[variable]
|
||||||
var/var_value = O.vars[variable]
|
|
||||||
var/dir
|
|
||||||
|
|
||||||
if (locked.Find(variable) && !(src.holder.rank in list("Game Master", "Game Admin")))
|
if (locked.Find(variable) && !(src.holder.rank in list("Game Master", "Game Admin")))
|
||||||
return
|
return
|
||||||
@@ -254,6 +313,10 @@
|
|||||||
if (variable == "holder" && holder.rank != "Game Master") //Hotfix, a bit ugly but that exploit has been there for ages and now somebody just had to go and tell everyone of it bluh bluh - U
|
if (variable == "holder" && holder.rank != "Game Master") //Hotfix, a bit ugly but that exploit has been there for ages and now somebody just had to go and tell everyone of it bluh bluh - U
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if(!autodetect_class)
|
||||||
|
|
||||||
|
var/dir
|
||||||
|
var/default
|
||||||
if(isnull(var_value))
|
if(isnull(var_value))
|
||||||
usr << "Unable to determine variable type."
|
usr << "Unable to determine variable type."
|
||||||
|
|
||||||
@@ -315,7 +378,7 @@
|
|||||||
if(dir)
|
if(dir)
|
||||||
usr << "If a direction, direction is: [dir]"
|
usr << "If a direction, direction is: [dir]"
|
||||||
|
|
||||||
var/class = input("What kind of variable?","Variable Type",default) as null|anything in list("text",
|
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","edit referenced object","restore to default")
|
||||||
|
|
||||||
if(!class)
|
if(!class)
|
||||||
|
|||||||
Reference in New Issue
Block a user