Improved VV and callproc implementation

This commit is contained in:
GinjaNinja32
2015-07-02 09:26:10 +01:00
parent a006089b2a
commit 4e6b316a9e
8 changed files with 454 additions and 534 deletions

View File

@@ -144,7 +144,6 @@
#include "code\datums\browser.dm"
#include "code\datums\computerfiles.dm"
#include "code\datums\datacore.dm"
#include "code\datums\datumvars.dm"
#include "code\datums\disease.dm"
#include "code\datums\mind.dm"
#include "code\datums\mixed.dm"
@@ -832,6 +831,7 @@
#include "code\modules\admin\player_panel.dm"
#include "code\modules\admin\topic.dm"
#include "code\modules\admin\ToRban.dm"
#include "code\modules\admin\callproc\callproc.dm"
#include "code\modules\admin\DB ban\functions.dm"
#include "code\modules\admin\permissionverbs\permissionedit.dm"
#include "code\modules\admin\verbs\adminhelp.dm"
@@ -864,6 +864,9 @@
#include "code\modules\admin\verbs\striketeam.dm"
#include "code\modules\admin\verbs\ticklag.dm"
#include "code\modules\admin\verbs\tripAI.dm"
#include "code\modules\admin\view_variables\helpers.dm"
#include "code\modules\admin\view_variables\topic.dm"
#include "code\modules\admin\view_variables\view_variables.dm"
#include "code\modules\alarm\alarm.dm"
#include "code\modules\alarm\alarm_handler.dm"
#include "code\modules\alarm\atmosphere_alarm.dm"

33
code/js/view_variables.js Normal file
View File

@@ -0,0 +1,33 @@
function updateSearch() {
var filter_text = document.getElementById('filter');
var filter = filter_text.value.toLowerCase();
var vars_ol = document.getElementById('vars');
var lis = vars_ol.children;
// the above line can be changed to vars_ol.getElementsByTagName("li") to filter child lists too
// potential todo: implement a per-admin toggle for this
for(var i = 0; i < lis.length; i++) {
var li = lis[i];
if(filter == "" || li.innerText.toLowerCase().indexOf(filter) != -1) {
li.style.display = "block";
} else {
li.style.display = "none";
}
}
}
function selectTextField() {
var filter_text = document.getElementById('filter');
filter_text.focus();
filter_text.select();
}
function loadPage(list) {
if(list.options[list.selectedIndex].value == "") {
return;
}
location.href=list.options[list.selectedIndex].value;
list.selectedIndex = 0;
}

View File

@@ -174,6 +174,7 @@ var/list/admin_verbs_debug = list(
/client/proc/show_plant_genes,
/client/proc/enable_debug_verbs,
/client/proc/callproc,
/client/proc/callproc_target,
/client/proc/toggledebuglogs,
/client/proc/SDQL_query,
/client/proc/SDQL2_query,
@@ -181,6 +182,7 @@ var/list/admin_verbs_debug = list(
var/list/admin_verbs_paranoid_debug = list(
/client/proc/callproc,
/client/proc/callproc_target,
/client/proc/debug_controller
)
@@ -250,6 +252,7 @@ var/list/admin_verbs_hideable = list(
/client/proc/restart_controller,
/client/proc/cmd_admin_list_open_jobs,
/client/proc/callproc,
/client/proc/callproc_target,
/client/proc/Debug2,
/client/proc/reload_admins,
/client/proc/kill_air,

View File

@@ -0,0 +1,152 @@
/client/proc/callproc()
set category = "Debug"
set name = "Advanced ProcCall"
if(!check_rights(R_DEBUG)) return
if(config.debugparanoid && !check_rights(R_ADMIN)) return
var/target = null
var/targetselected = 0
switch(alert("Proc owned by something?",, "Yes", "No", "Cancel"))
if("Yes")
targetselected=1
switch(input("Proc owned by...", "Owner", null) as null|anything in list("Obj", "Mob", "Area or Turf", "Client"))
if("Obj")
target = input("Select target:", "Target") as null|obj in world
if("Mob")
target = input("Select target:", "Target", usr) as null|mob in world
if("Area or Turf")
target = input("Select target:", "Target", get_turf(usr)) as null|area|turf in world
if("Client")
target = input("Select target:", "Target", usr.client) as null|anything in clients
else
return
if(!target)
usr << "Proc call cancelled."
return
if("Cancel")
return
if("No")
; // BYOND apparently doesn't have 'break' in switch statements.
callproc_targetpicked(targetselected, target)
/client/proc/callproc_target(atom/A in world)
set category = "Debug"
set name = "Advanced ProcCall Target"
if(!check_rights(R_DEBUG)) return
if(config.debugparanoid && !check_rights(R_ADMIN)) return
callproc_targetpicked(1, A)
/client/proc/callproc_targetpicked(hastarget, datum/target)
// this needs checking again here because VV's 'Call Proc' option directly calls this proc with the target datum
if(!check_rights(R_DEBUG)) return
if(config.debugparanoid && !check_rights(R_ADMIN)) return
var/returnval = null
var/procname = input("Proc name", "Proc") as null|text
if(!procname) return
if(hastarget)
if(!target)
usr << "Your callproc target no longer exists."
return
if(!hascall(target, procname))
usr << "\The [target] has no call [procname]()"
return
var/list/arguments = list()
var/done = 0
var/current = null
while(!done)
if(hastarget && !target)
usr << "Your callproc target no longer exists."
return
switch(input("Type of [arguments.len+1]\th variable", "argument [arguments.len+1]") as null|anything in list(
"finished", "null", "text", "num", "type", "obj reference", "mob reference",
"area/turf reference", "icon", "file", "client", "mob's area", "marked datum"))
if(null)
return
if("finished")
done = 1
if("null")
current = null
if("text")
current = input("Enter text for [arguments.len+1]\th argument") as null|text
if(isnull(current)) return
if("num")
current = input("Enter number for [arguments.len+1]\th argument") as null|num
if(isnull(current)) return
if("type")
current = input("Select type for [arguments.len+1]\th argument") as null|anything in typesof(/obj, /mob, /area, /turf)
if(isnull(current)) return
if("obj reference")
current = input("Select object for [arguments.len+1]\th argument") as null|obj in world
if(isnull(current)) return
if("mob reference")
current = input("Select mob for [arguments.len+1]\th argument") as null|mob in world
if(isnull(current)) return
if("area/turf reference")
current = input("Select area/turf for [arguments.len+1]\th argument") as null|area|turf in world
if(isnull(current)) return
if("icon")
current = input("Provide icon for [arguments.len+1]\th argument") as null|icon
if(isnull(current)) return
if("client")
current = input("Select client for [arguments.len+1]\th argument") as null|anything in clients
if(isnull(current)) return
if("mob's area")
var/mob/M = input("Select mob to take area for [arguments.len+1]\th argument") as null|mob in world
if(!M) return
current = get_area(M)
if(!current)
switch(alert("\The [M] appears to not have an area; do you want to pass null instead?",, "Yes", "Cancel"))
if("Yes")
;
if("Cancel")
return
if("marked datum")
current = holder.marked_datum
if(!current)
switch(alert("You do not currently have a marked datum; do you want to pass null instead?",, "Yes", "Cancel"))
if("Yes")
;
if("Cancel")
return
if(!done)
arguments += current
if(hastarget)
if(!target)
usr << "Your callproc target no longer exists."
return
log_admin("[key_name(src)] called [target]'s [procname]() with [arguments.len ? "the arguments [list2params(arguments)]" : "no arguments"].")
if(arguments.len)
returnval = call(target, procname)(arglist(arguments))
else
returnval = call(target, procname)()
else
log_admin("[key_name(src)] called [procname]() with [arguments.len ? "the arguments [list2params(arguments)]" : "no arguments"].")
returnval = call(procname)(arglist(arguments))
usr << "<span class='info'>[procname]() returned: [isnull(returnval) ? "null" : returnval]</span>"
feedback_add_details("admin_verb","APC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

View File

@@ -14,121 +14,7 @@
feedback_add_details("admin_verb","DG2") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/* 21st Sept 2010
Updated by Skie -- Still not perfect but better!
Stuff you can't do:
Call proc /mob/proc/make_dizzy() for some player
Because if you select a player mob as owner it tries to do the proc for
/mob/living/carbon/human/ instead. And that gives a run-time error.
But you can call procs that are of type /mob/living/carbon/human/proc/ for that player.
*/
/client/proc/callproc()
set category = "Debug"
set name = "Advanced ProcCall"
if(!check_rights(R_DEBUG)) return
if(config.debugparanoid && !check_rights(R_ADMIN)) return
spawn(0)
var/target = null
var/targetselected = 0
var/lst[] // List reference
lst = new/list() // Make the list
var/returnval = null
var/class = null
switch(alert("Proc owned by something?",,"Yes","No"))
if("Yes")
targetselected = 1
class = input("Proc owned by...","Owner",null) as null|anything in list("Obj","Mob","Area or Turf","Client")
switch(class)
if("Obj")
target = input("Enter target:","Target",usr) as obj in world
if("Mob")
target = input("Enter target:","Target",usr) as mob in world
if("Area or Turf")
target = input("Enter target:","Target",usr.loc) as area|turf in world
if("Client")
var/list/keys = list()
for(var/client/C)
keys += C
target = input("Please, select a player!", "Selection", null, null) as null|anything in keys
else
return
if("No")
target = null
targetselected = 0
var/procname = input("Proc path, eg: /proc/fake_blood","Path:", null) as text|null
if(!procname) return
var/argnum = input("Number of arguments","Number:",0) as num|null
if(!argnum && (argnum!=0)) return
lst.len = argnum // Expand to right length
//TODO: make a list to store whether each argument was initialised as null.
//Reason: So we can abort the proccall if say, one of our arguments was a mob which no longer exists
//this will protect us from a fair few errors ~Carn
var/i
for(i=1, i<argnum+1, i++) // Lists indexed from 1 forwards in byond
// Make a list with each index containing one variable, to be given to the proc
class = input("What kind of variable?","Variable Type") in list("text","num","type","reference","mob reference","icon","file","client","mob's area","CANCEL")
switch(class)
if("CANCEL")
return
if("text")
lst[i] = input("Enter new text:","Text",null) as text
if("num")
lst[i] = input("Enter new number:","Num",0) as num
if("type")
lst[i] = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf)
if("reference")
lst[i] = input("Select reference:","Reference",src) as mob|obj|turf|area in world
if("mob reference")
lst[i] = input("Select reference:","Reference",usr) as mob in world
if("file")
lst[i] = input("Pick file:","File") as file
if("icon")
lst[i] = input("Pick icon:","Icon") as icon
if("client")
var/list/keys = list()
for(var/mob/M in world)
keys += M.client
lst[i] = input("Please, select a player!", "Selection", null, null) as null|anything in keys
if("mob's area")
var/mob/temp = input("Select mob", "Selection", usr) as mob in world
lst[i] = temp.loc
if(targetselected)
if(!target)
usr << "<font color='red'>Error: callproc(): owner of proc no longer exists.</font>"
return
if(!hascall(target,procname))
usr << "<font color='red'>Error: callproc(): target has no such call [procname].</font>"
return
log_admin("[key_name(src)] called [target]'s [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].")
returnval = call(target,procname)(arglist(lst)) // Pass the lst as an argument list to the proc
else
//this currently has no hascall protection. wasn't able to get it working.
log_admin("[key_name(src)] called [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].")
returnval = call(procname)(arglist(lst)) // Pass the lst as an argument list to the proc
usr << "<font color='blue'>[procname] returned: [returnval ? returnval : "null"]</font>"
feedback_add_details("admin_verb","APC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
// callproc moved to code/modules/admin/callproc
/client/proc/Cell()
set category = "Debug"

View File

@@ -0,0 +1,93 @@
// Keep these two together, they *must* be defined on both
// If /client ever becomes /datum/client or similar, they can be merged
/client/proc/get_view_variables_header()
return "<b>[src]</b>"
/datum/proc/get_view_variables_header()
return "<b>[src]</b>"
/atom/get_view_variables_header()
return {"
<a href='?_src_=vars;datumedit=\ref[src];varnameedit=name'><b>[src]</b></a>
<br><font size='1'>
<a href='?_src_=vars;rotatedatum=\ref[src];rotatedir=left'><<</a>
<a href='?_src_=vars;datumedit=\ref[src];varnameedit=dir'>[dir2text(dir)]</a>
<a href='?_src_=vars;rotatedatum=\ref[src];rotatedir=right'>>></a>
</font>
"}
/mob/living/get_view_variables_header()
return {"
<a href='?_src_=vars;rename=\ref[src]'><b>[src]</b></a><font size='1'>
<br><a href='?_src_=vars;rotatedatum=\ref[src];rotatedir=left'><<</a> <a href='?_src_=vars;datumedit=\ref[src];varnameedit=dir'>[dir2text(dir)]</a> <a href='?_src_=vars;rotatedatum=\ref[src];rotatedir=right'>>></a>
<br><a href='?_src_=vars;datumedit=\ref[src];varnameedit=ckey'>[ckey ? ckey : "No ckey"]</a> / <a href='?_src_=vars;datumedit=\ref[src];varnameedit=real_name'>[real_name ? real_name : "No real name"]</a>
<br>
BRUTE:<a href='?_src_=vars;mobToDamage=\ref[src];adjustDamage=brute'>[getBruteLoss()]</a>
FIRE:<a href='?_src_=vars;mobToDamage=\ref[src];adjustDamage=fire'>[getFireLoss()]</a>
TOXIN:<a href='?_src_=vars;mobToDamage=\ref[src];adjustDamage=toxin'>[getToxLoss()]</a>
OXY:<a href='?_src_=vars;mobToDamage=\ref[src];adjustDamage=oxygen'>[getOxyLoss()]</a>
CLONE:<a href='?_src_=vars;mobToDamage=\ref[src];adjustDamage=clone'>[getCloneLoss()]</a>
BRAIN:<a href='?_src_=vars;mobToDamage=\ref[src];adjustDamage=brain'>[getBrainLoss()]</a>
</font>
"}
// Same for these as for get_view_variables_header() above
/client/proc/get_view_variables_options()
return ""
/datum/proc/get_view_variables_options()
return ""
/mob/get_view_variables_options()
return ..() + {"
<option value='?_src_=vars;mob_player_panel=\ref[src]'>Show player panel</option>
<option>---</option>
<option value='?_src_=vars;give_spell=\ref[src]'>Give Spell</option>
<option value='?_src_=vars;give_disease2=\ref[src]'>Give Disease</option>
<option value='?_src_=vars;give_disease=\ref[src]'>Give TG-style Disease</option>
<option value='?_src_=vars;godmode=\ref[src]'>Toggle Godmode</option>
<option value='?_src_=vars;build_mode=\ref[src]'>Toggle Build Mode</option>
<option value='?_src_=vars;ninja=\ref[src]'>Make Space Ninja</option>
<option value='?_src_=vars;make_skeleton=\ref[src]'>Make 2spooky</option>
<option value='?_src_=vars;direct_control=\ref[src]'>Assume Direct Control</option>
<option value='?_src_=vars;drop_everything=\ref[src]'>Drop Everything</option>
<option value='?_src_=vars;regenerateicons=\ref[src]'>Regenerate Icons</option>
<option value='?_src_=vars;addlanguage=\ref[src]'>Add Language</option>
<option value='?_src_=vars;remlanguage=\ref[src]'>Remove Language</option>
<option value='?_src_=vars;addorgan=\ref[src]'>Add Organ</option>
<option value='?_src_=vars;remorgan=\ref[src]'>Remove Organ</option>
<option value='?_src_=vars;fix_nano=\ref[src]'>Fix NanoUI</option>
<option value='?_src_=vars;addverb=\ref[src]'>Add Verb</option>
<option value='?_src_=vars;remverb=\ref[src]'>Remove Verb</option>
<option value>---</option>
<option value='?_src_=vars;gib=\ref[src]'>Gib</option>
<option value='?_src_=vars;explode=\ref[src]'>Trigger explosion</option>
<option value='?_src_=vars;emp=\ref[src]'>Trigger EM pulse</option>
"}
/mob/living/carbon/human/get_view_variables_options()
return ..() + {"
<option value='?_src_=vars;setspecies=\ref[src]'>Set Species</option>
<option value='?_src_=vars;makeai=\ref[src]'>Make AI</option>
<option value='?_src_=vars;makerobot=\ref[src]'>Make cyborg</option>
<option value='?_src_=vars;makemonkey=\ref[src]'>Make monkey</option>
<option value='?_src_=vars;makealien=\ref[src]'>Make alien</option>
<option value='?_src_=vars;makeslime=\ref[src]'>Make slime</option>
"}
/obj/get_view_variables_options()
return ..() + {"
<option value='?_src_=vars;delall=\ref[src]'>Delete all of type</option>
<option value='?_src_=vars;explode=\ref[src]'>Trigger explosion</option>
<option value='?_src_=vars;emp=\ref[src]'>Trigger EM pulse</option>
"}
/turf/get_view_variables_options()
return ..() + {"
<option value='?_src_=vars;explode=\ref[src]'>Trigger explosion</option>
<option value='?_src_=vars;emp=\ref[src]'>Trigger EM pulse</option>
"}

View File

@@ -1,416 +1,3 @@
// reference: /client/proc/modify_variables(var/atom/O, var/param_var_name = null, var/autodetect_class = 0)
client
proc/debug_variables(datum/D in world)
set category = "Debug"
set name = "View Variables"
//set src in world
if(!usr.client || !usr.client.holder)
usr << "<span class='warning'>You need to be an administrator to access this.</span>"
return
var/title = ""
var/body = ""
if(!D) return
if(istype(D, /atom))
var/atom/A = D
title = "[A.name] (\ref[A]) = [A.type]"
#ifdef VARSICON
if (A.icon)
body += debug_variable("icon", new/icon(A.icon, A.icon_state, A.dir), 0)
#endif
var/icon/sprite
if(istype(D,/atom))
var/atom/AT = D
if(AT.icon && AT.icon_state)
sprite = new /icon(AT.icon, AT.icon_state)
usr << browse_rsc(sprite, "view_vars_sprite.png")
title = "[D] (\ref[D]) = [D.type]"
body += {"<script type="text/javascript">
function updateSearch(){
var filter_text = document.getElementById('filter');
var filter = filter_text.value.toLowerCase();
if(event.keyCode == 13){ //Enter / return
var vars_ol = document.getElementById('vars');
var lis = vars_ol.getElementsByTagName("li");
for ( var i = 0; i < lis.length; ++i )
{
try{
var li = lis\[i\];
if ( li.style.backgroundColor == "#ffee88" )
{
alist = lis\[i\].getElementsByTagName("a")
if(alist.length > 0){
location.href=alist\[0\].href;
}
}
}catch(err) { }
}
return
}
if(event.keyCode == 38){ //Up arrow
var vars_ol = document.getElementById('vars');
var lis = vars_ol.getElementsByTagName("li");
for ( var i = 0; i < lis.length; ++i )
{
try{
var li = lis\[i\];
if ( li.style.backgroundColor == "#ffee88" )
{
if( (i-1) >= 0){
var li_new = lis\[i-1\];
li.style.backgroundColor = "white";
li_new.style.backgroundColor = "#ffee88";
return
}
}
}catch(err) { }
}
return
}
if(event.keyCode == 40){ //Down arrow
var vars_ol = document.getElementById('vars');
var lis = vars_ol.getElementsByTagName("li");
for ( var i = 0; i < lis.length; ++i )
{
try{
var li = lis\[i\];
if ( li.style.backgroundColor == "#ffee88" )
{
if( (i+1) < lis.length){
var li_new = lis\[i+1\];
li.style.backgroundColor = "white";
li_new.style.backgroundColor = "#ffee88";
return
}
}
}catch(err) { }
}
return
}
//This part here resets everything to how it was at the start so the filter is applied to the complete list. Screw efficiency, it's client-side anyway and it only looks through 200 or so variables at maximum anyway (mobs).
if(complete_list != null && complete_list != ""){
var vars_ol1 = document.getElementById("vars");
vars_ol1.innerHTML = complete_list
}
if(filter.value == ""){
return;
}else{
var vars_ol = document.getElementById('vars');
var lis = vars_ol.getElementsByTagName("li");
for ( var i = 0; i < lis.length; ++i )
{
try{
var li = lis\[i\];
if ( li.innerText.toLowerCase().indexOf(filter) == -1 )
{
vars_ol.removeChild(li);
i--;
}
}catch(err) { }
}
}
var lis_new = vars_ol.getElementsByTagName("li");
for ( var j = 0; j < lis_new.length; ++j )
{
var li1 = lis\[j\];
if (j == 0){
li1.style.backgroundColor = "#ffee88";
}else{
li1.style.backgroundColor = "white";
}
}
}
function selectTextField(){
var filter_text = document.getElementById('filter');
filter_text.focus();
filter_text.select();
}
function loadPage(list) {
if(list.options\[list.selectedIndex\].value == ""){
return;
}
location.href=list.options\[list.selectedIndex\].value;
}
</script> "}
body += "<body onload='selectTextField(); updateSearch()' onkeyup='updateSearch()'>"
body += "<div align='center'><table width='100%'><tr><td width='50%'>"
if(sprite)
body += "<table align='center' width='100%'><tr><td><img src='view_vars_sprite.png'></td><td>"
else
body += "<table align='center' width='100%'><tr><td>"
body += "<div align='center'>"
if(istype(D,/atom))
var/atom/A = D
if(isliving(A))
body += "<a href='?_src_=vars;rename=\ref[D]'><b>[D]</b></a>"
if(A.dir)
body += "<br><font size='1'><a href='?_src_=vars;rotatedatum=\ref[D];rotatedir=left'><<</a> <a href='?_src_=vars;datumedit=\ref[D];varnameedit=dir'>[dir2text(A.dir)]</a> <a href='?_src_=vars;rotatedatum=\ref[D];rotatedir=right'>>></a></font>"
var/mob/living/M = A
body += "<br><font size='1'><a href='?_src_=vars;datumedit=\ref[D];varnameedit=ckey'>[M.ckey ? M.ckey : "No ckey"]</a> / <a href='?_src_=vars;datumedit=\ref[D];varnameedit=real_name'>[M.real_name ? M.real_name : "No real name"]</a></font>"
body += {"
<br><font size='1'>
BRUTE:<font size='1'><a href='?_src_=vars;mobToDamage=\ref[D];adjustDamage=brute'>[M.getBruteLoss()]</a>
FIRE:<font size='1'><a href='?_src_=vars;mobToDamage=\ref[D];adjustDamage=fire'>[M.getFireLoss()]</a>
TOXIN:<font size='1'><a href='?_src_=vars;mobToDamage=\ref[D];adjustDamage=toxin'>[M.getToxLoss()]</a>
OXY:<font size='1'><a href='?_src_=vars;mobToDamage=\ref[D];adjustDamage=oxygen'>[M.getOxyLoss()]</a>
CLONE:<font size='1'><a href='?_src_=vars;mobToDamage=\ref[D];adjustDamage=clone'>[M.getCloneLoss()]</a>
BRAIN:<font size='1'><a href='?_src_=vars;mobToDamage=\ref[D];adjustDamage=brain'>[M.getBrainLoss()]</a>
</font>
"}
else
body += "<a href='?_src_=vars;datumedit=\ref[D];varnameedit=name'><b>[D]</b></a>"
if(A.dir)
body += "<br><font size='1'><a href='?_src_=vars;rotatedatum=\ref[D];rotatedir=left'><<</a> <a href='?_src_=vars;datumedit=\ref[D];varnameedit=dir'>[dir2text(A.dir)]</a> <a href='?_src_=vars;rotatedatum=\ref[D];rotatedir=right'>>></a></font>"
else
body += "<b>[D]</b>"
body += "</div>"
body += "</tr></td></table>"
var/formatted_type = text("[D.type]")
if(length(formatted_type) > 25)
var/middle_point = length(formatted_type) / 2
var/splitpoint = findtext(formatted_type,"/",middle_point)
if(splitpoint)
formatted_type = "[copytext(formatted_type,1,splitpoint)]<br>[copytext(formatted_type,splitpoint)]"
else
formatted_type = "Type too long" //No suitable splitpoint (/) found.
body += "<div align='center'><b><font size='1'>[formatted_type]</font></b>"
if(src.holder && src.holder.marked_datum && src.holder.marked_datum == D)
body += "<br><font size='1' color='red'><b>Marked Object</b></font>"
body += "</div>"
body += "</div></td>"
body += "<td width='50%'><div align='center'><a href='?_src_=vars;datumrefresh=\ref[D]'>Refresh</a>"
//if(ismob(D))
// body += "<br><a href='?_src_=vars;mob_player_panel=\ref[D]'>Show player panel</a></div></td></tr></table></div><hr>"
body += {" <form>
<select name="file" size="1"
onchange="loadPage(this.form.elements\[0\])"
target="_parent._top"
onmouseclick="this.focus()"
style="background-color:#ffffff">
"}
body += {" <option value>Select option</option>
<option value> </option>
"}
body += "<option value='?_src_=vars;mark_object=\ref[D]'>Mark Object</option>"
if(ismob(D))
body += "<option value='?_src_=vars;mob_player_panel=\ref[D]'>Show player panel</option>"
body += "<option value>---</option>"
if(ismob(D))
body += "<option value='?_src_=vars;give_spell=\ref[D]'>Give Spell</option>"
body += "<option value='?_src_=vars;give_disease2=\ref[D]'>Give Disease</option>"
body += "<option value='?_src_=vars;give_disease=\ref[D]'>Give TG-style Disease</option>"
body += "<option value='?_src_=vars;godmode=\ref[D]'>Toggle Godmode</option>"
body += "<option value='?_src_=vars;build_mode=\ref[D]'>Toggle Build Mode</option>"
body += "<option value='?_src_=vars;ninja=\ref[D]'>Make Space Ninja</option>"
body += "<option value='?_src_=vars;make_skeleton=\ref[D]'>Make 2spooky</option>"
body += "<option value='?_src_=vars;direct_control=\ref[D]'>Assume Direct Control</option>"
body += "<option value='?_src_=vars;drop_everything=\ref[D]'>Drop Everything</option>"
body += "<option value='?_src_=vars;regenerateicons=\ref[D]'>Regenerate Icons</option>"
body += "<option value='?_src_=vars;addlanguage=\ref[D]'>Add Language</option>"
body += "<option value='?_src_=vars;remlanguage=\ref[D]'>Remove Language</option>"
body += "<option value='?_src_=vars;addorgan=\ref[D]'>Add Organ</option>"
body += "<option value='?_src_=vars;remorgan=\ref[D]'>Remove Organ</option>"
body += "<option value='?_src_=vars;fix_nano=\ref[D]'>Fix NanoUI</option>"
body += "<option value='?_src_=vars;addverb=\ref[D]'>Add Verb</option>"
body += "<option value='?_src_=vars;remverb=\ref[D]'>Remove Verb</option>"
if(ishuman(D))
body += "<option value>---</option>"
body += "<option value='?_src_=vars;setspecies=\ref[D]'>Set Species</option>"
body += "<option value='?_src_=vars;makeai=\ref[D]'>Make AI</option>"
body += "<option value='?_src_=vars;makerobot=\ref[D]'>Make cyborg</option>"
body += "<option value='?_src_=vars;makemonkey=\ref[D]'>Make monkey</option>"
body += "<option value='?_src_=vars;makealien=\ref[D]'>Make alien</option>"
body += "<option value='?_src_=vars;makeslime=\ref[D]'>Make slime</option>"
body += "<option value>---</option>"
body += "<option value='?_src_=vars;gib=\ref[D]'>Gib</option>"
if(isobj(D))
body += "<option value='?_src_=vars;delall=\ref[D]'>Delete all of type</option>"
if(isobj(D) || ismob(D) || isturf(D))
body += "<option value='?_src_=vars;explode=\ref[D]'>Trigger explosion</option>"
body += "<option value='?_src_=vars;emp=\ref[D]'>Trigger EM pulse</option>"
body += "</select></form>"
body += "</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.<br>"
body += "<b>M</b> - Mass modify: changes this variable for all objects of this type.</font><br>"
body += "<hr><table width='100%'><tr><td width='20%'><div align='center'><b>Search:</b></div></td><td width='80%'><input type='text' id='filter' name='filter_text' value='' style='width:100%;'></td></tr></table><hr>"
body += "<ol id='vars'>"
var/list/names = list()
for (var/V in D.vars)
names += V
names = sortList(names)
for (var/V in names)
body += debug_variable(V, D.vars[V], 0, D)
body += "</ol>"
var/html = "<html><head>"
if (title)
html += "<title>[title]</title>"
html += {"<style>
body
{
font-family: Verdana, sans-serif;
font-size: 9pt;
}
.value
{
font-family: "Courier New", monospace;
font-size: 8pt;
}
</style>"}
html += "</head><body>"
html += body
html += {"
<script type='text/javascript'>
var vars_ol = document.getElementById("vars");
var complete_list = vars_ol.innerHTML;
</script>
"}
html += "</body></html>"
usr << browse(html, "window=variables\ref[D];size=475x650")
return
proc/debug_variable(name, value, level, var/datum/DA = null)
var/html = ""
if(DA)
html += "<li style='backgroundColor:white'>(<a href='?_src_=vars;datumedit=\ref[DA];varnameedit=[name]'>E</a>) (<a href='?_src_=vars;datumchange=\ref[DA];varnamechange=[name]'>C</a>) (<a href='?_src_=vars;datummass=\ref[DA];varnamemass=[name]'>M</a>) "
else
html += "<li>"
if (isnull(value))
html += "[name] = <span class='value'>null</span>"
else if (istext(value))
html += "[name] = <span class='value'>\"[value]\"</span>"
else if (isicon(value))
#ifdef VARSICON
var/icon/I = new/icon(value)
var/rnd = rand(1,10000)
var/rname = "tmp\ref[I][rnd].png"
usr << browse_rsc(I, rname)
html += "[name] = (<span class='value'>[value]</span>) <img class=icon src=\"[rname]\">"
#else
html += "[name] = /icon (<span class='value'>[value]</span>)"
#endif
/* else if (istype(value, /image))
#ifdef VARSICON
var/rnd = rand(1, 10000)
var/image/I = value
src << browse_rsc(I.icon, "tmp\ref[value][rnd].png")
html += "[name] = <img src=\"tmp\ref[value][rnd].png\">"
#else
html += "[name] = /image (<span class='value'>[value]</span>)"
#endif
*/
else if (isfile(value))
html += "[name] = <span class='value'>'[value]'</span>"
else if (istype(value, /datum))
var/datum/D = value
html += "<a href='?_src_=vars;Vars=\ref[value]'>[name] \ref[value]</a> = [D.type]"
else if (istype(value, /client))
var/client/C = value
html += "<a href='?_src_=vars;Vars=\ref[value]'>[name] \ref[value]</a> = [C] [C.type]"
//
else if (istype(value, /list))
var/list/L = value
html += "[name] = /list ([L.len])"
if (L.len > 0 && !(name == "underlays" || name == "overlays" || name == "vars" || L.len > 500))
// not sure if this is completely right...
if(0) //(L.vars.len > 0)
html += "<ol>"
html += "</ol>"
else
html += "<ul>"
var/index = 1
for (var/entry in L)
if(istext(entry))
html += debug_variable(entry, L[entry], level + 1)
//html += debug_variable("[index]", L[index], level + 1)
else
html += debug_variable(index, L[index], level + 1)
index++
html += "</ul>"
else
html += "[name] = <span class='value'>[value]</span>"
html += "</li>"
return html
/client/proc/view_var_Topic(href, href_list, hsrc)
//This should all be moved over to datum/admins/Topic() or something ~Carn
if( (usr.client != src) || !src.holder )
@@ -866,7 +453,7 @@ client
return
new new_organ(M)
else if(href_list["remorgan"])
if(!check_rights(R_SPAWN)) return
@@ -945,11 +532,14 @@ client
message_admins("<span class='notice'>[key_name(usr)] dealt [amount] amount of [Text] damage to [L]</span>")
href_list["datumrefresh"] = href_list["mobToDamage"]
else if(href_list["call_proc"])
var/datum/D = locate(href_list["call_proc"])
if(istype(D) || istype(D, /client)) // can call on clients too, not just datums
callproc_targetpicked(1, D)
if(href_list["datumrefresh"])
var/datum/DAT = locate(href_list["datumrefresh"])
if(!istype(DAT, /datum))
return
src.debug_variables(DAT)
if(istype(DAT, /datum) || istype(DAT, /client))
debug_variables(DAT)
return

View File

@@ -0,0 +1,160 @@
// Variables to not even show in the list.
// step_* and bound_* are here because they literally break the game and do nothing else.
// parent_type is here because it's pointless to show in VV.
/var/list/view_variables_hide_vars = list("bound_x", "bound_y", "bound_height", "bound_width", "bounds", "parent_type", "step_x", "step_y", "step_size")
// Variables not to expand the lists of. Vars is pointless to expand, and overlays/underlays cannot be expanded.
/var/list/view_variables_dont_expand = list("overlays", "underlays", "vars")
/client/proc/debug_variables(datum/D in world)
set category = "Debug"
set name = "View Variables"
if(!check_rights(0))
return
if(!D)
return
var/icon/sprite
if(istype(D, /atom))
var/atom/A = D
if(A.icon && A.icon_state)
sprite = icon(A.icon, A.icon_state)
usr << browse_rsc(sprite, "view_vars_sprite.png")
usr << browse_rsc('code/js/view_variables.js', "view_variables.js")
var/html = {"
<html>
<head>
<script src='view_variables.js'></script>
<title>[D] (\ref[D] - [D.type])</title>
<style>
body { font-family: Verdana, sans-serif; font-size: 9pt; }
.value { font-family: "Courier New", monospace; font-size: 8pt; }
</style>
</head>
<body onload='selectTextField(); updateSearch()'; onkeyup='updateSearch()'>
<div align='center'>
<table width='100%'><tr>
<td width='50%'>
<table align='center' width='100%'><tr>
[sprite ? "<td><img src='view_vars_sprite.png'></td>" : ""]
<td><div align='center'>[D.get_view_variables_header()]</div></td>
</tr></table>
<div align='center'>
<b><font size='1'>[replacetext("[D.type]", "/", "/<wbr>")]</font></b>
[holder.marked_datum == D ? "<br/><font size='1' color='red'><b>Marked Object</b></font>" : ""]
</div>
</td>
<td width='50%'>
<div align='center'>
<a href='?_src_=vars;datumrefresh=\ref[D]'>Refresh</a>
<form>
<select name='file'
size='1'
onchange='loadPage(this.form.elements\[0\])'
target='_parent._top'
onmouseclick='this.focus()'
style='background-color:#ffffff'>
<option>Select option</option>
<option />
<option value='?_src_=vars;mark_object=\ref[D]'>Mark Object</option>
<option value='?_src_=vars;call_proc=\ref[D]'>Call Proc</option>
[D.get_view_variables_options()]
</select>
</form>
</div>
</td>
</tr></table>
</div>
<hr/>
<font size='1'>
<b>E</b> - Edit, tries to determine the variable type by itself.<br/>
<b>C</b> - Change, asks you for the var type first.<br/>
<b>M</b> - Mass modify: changes this variable for all objects of this type.<br/>
</font>
<hr/>
<table width='100%'><tr>
<td width='20%'>
<div align='center'>
<b>Search:</b>
</div>
</td>
<td width='80%'>
<input type='text'
id='filter'
name='filter_text'
value=''
style='width:100%;' />
</td>
</tr></table>
<hr/>
<ol id='vars'>
[make_view_variables_var_list(D)]
</ol>
</body>
</html>
"}
usr << browse(html, "window=variables\ref[D];size=475x650")
/proc/make_view_variables_var_list(datum/D)
. = ""
var/list/variables = list()
for(var/x in D.vars)
if(x in view_variables_hide_vars)
continue
variables += x
variables = sortList(variables)
for(var/x in variables)
. += make_view_variables_var_entry(D, x, D.vars[x])
/proc/make_view_variables_var_entry(datum/D, varname, value, level=0)
var/ecm = null
var/vtext = null
var/extra = null
if(D)
ecm = {"
(<a href='?_src_=vars;datumedit=\ref[D];varnameedit=[varname]'>E</a>)
(<a href='?_src_=vars;datumchange=\ref[D];varnamechange=[varname]'>C</a>)
(<a href='?_src_=vars;datummass=\ref[D];varnamemass=[varname]'>M</a>)
"}
if(isnull(value))
vtext = "null"
else if(istext(value))
vtext = "\"[value]\""
else if(isicon(value))
vtext = "[value]"
else if(isfile(value))
vtext = "'[value]'"
else if(istype(value, /datum))
var/datum/DA = value
if("[DA]" == "[DA.type]" || !"[DA]")
vtext = "<a href='?_src_=vars;Vars=\ref[DA]'>\ref[DA]</a> - [DA.type]"
else
vtext = "<a href='?_src_=vars;Vars=\ref[DA]'>\ref[DA]</a> - [DA] ([DA.type])"
else if(istype(value, /client))
var/client/C = value
vtext = "<a href='?_src_=vars;Vars=\ref[C]'>\ref[C]</a> - [C] ([C.type])"
else if(islist(value))
var/list/L = value
vtext = "/list ([L.len])"
if(!(varname in view_variables_dont_expand) && L.len > 0 && L.len < 100)
extra = "<ul>"
var/index = 1
for (var/entry in L)
if(istext(entry))
extra += make_view_variables_var_entry(null, entry, L[entry], level+1)
else
extra += make_view_variables_var_entry(null, index, L[index], level+1)
index++
extra += "</ul>"
else
vtext = "[value]"
return "<li>[ecm][varname] = <span class='value'>[vtext]</span>[extra]</li>"