Skip to content

Commit

Permalink
Port VV expansion from Upstream Bee
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilDragonfiend authored Nov 21, 2024
1 parent 48a4882 commit df319de
Show file tree
Hide file tree
Showing 28 changed files with 752 additions and 140 deletions.
5 changes: 5 additions & 0 deletions code/__DEFINES/_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
//Returns an integer given a hex input, supports negative values "-ff"
//skips preceding invalid characters
#define hex2num(X) text2num(X, 16)

// Refs contain a type id within their string that can be used to identify byond types.
// Custom types that we define don't get a unique id, but this is useful for identifying
// types that don't normally have a way to run istype() on them.
#define TYPEID(thing) copytext(REF(thing), 4, 6)
9 changes: 9 additions & 0 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@

#define isweakref(D) (istype(D, /datum/weakref))

#define isimage(thing) (istype(thing, /image))

GLOBAL_VAR_INIT(magic_appearance_detecting_image, new /image) // appearances are awful to detect safely, but this seems to be the best way ~ninjanomnom
#define isappearance(thing) (!isimage(thing) && !ispath(thing) && istype(GLOB.magic_appearance_detecting_image, thing))

// The filters list has the same ref type id as a filter, but isnt one and also isnt a list, so we have to check if the thing has Cut() instead
GLOBAL_VAR_INIT(refid_filter, TYPEID(filter(type="angular_blur")))
#define isfilter(thing) (hascall(thing, "Cut") && TYPEID(thing) == GLOB.refid_filter)

// simple check whether or not a player is a guest using their key
#define IS_GUEST_KEY(key) (findtextEx(key, "Guest-", 1, 7))

Expand Down
1 change: 1 addition & 0 deletions code/__DEFINES/keybinding.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define COMSIG_KB_ADMIN_AGHOST_DOWN "keybinding_admin_aghost_down"
#define COMSIG_KB_ADMIN_PLAYERPANEL_DOWN "keybinding_admin_playerpanelnew_down"
#define COMSIG_KB_ADMIN_INVISIMINTOGGLE_DOWN "keybinding_admin_invisimintoggle_down"
#define COMSIG_KB_ADMIN_VIEWTAGS_DOWN "keybinding_admin_viewtags_down"

//Carbon
#define COMSIG_KB_CARBON_TOGGLETHROWMODE_DOWN "keybinding_carbon_togglethrowmode_down"
Expand Down
4 changes: 2 additions & 2 deletions code/__DEFINES/typeids.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#define TYPEID_NORMAL_LIST "f"
//helper macros
#define GET_TYPEID(ref) ( ( (length(ref) <= 10) ? "TYPEID_NULL" : copytext(ref, 4, -7) ) )
// Only allowed raw ref, since this is for lists explicitly and they will get no use from it
// Also it tends to be used in a hot context so let's be nice yes?
#define IS_NORMAL_LIST(L) (GET_TYPEID("\ref[L]") == TYPEID_NORMAL_LIST)


16 changes: 16 additions & 0 deletions code/__DEFINES/vv.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#define VV_TEXT "Text"
#define VV_MESSAGE "Mutiline Text"
#define VV_ICON "Icon"
#define VV_COLOR "Color"
#define VV_COLOR_MATRIX "Color Matrix"
#define VV_ATOM_REFERENCE "Atom Reference"
#define VV_DATUM_REFERENCE "Datum Reference"
#define VV_MOB_REFERENCE "Mob Reference"
Expand All @@ -16,13 +18,17 @@
#define VV_NEW_TYPE "New Custom Typepath"
#define VV_NEW_LIST "New List"
#define VV_NULL "NULL"
#define VV_INFINITY "Infinity"
#define VV_RESTORE_DEFAULT "Restore to Default"
#define VV_MARKED_DATUM "Marked Datum"
#define VV_TAGGED_DATUM "Tagged Datum"
#define VV_BITFIELD "Bitfield"
#define VV_TEXT_LOCATE "Custom Reference Locate"
#define VV_PROCCALL_RETVAL "Return Value of Proccall"
#define VV_WEAKREF "Weak Reference Datum"

#define VV_MSG_MARKED "<br><font size='1' color='red'><b>Marked Object</b></font>"
#define VV_MSG_TAGGED(num) "<br><font size='1' color='red'><b>Tagged Datum #[num]</b></font>"
#define VV_MSG_EDITED "<br><font size='1' color='red'><b>Var Edited</b></font>"
#define VV_MSG_DELETED "<br><font size='1' color='red'><b>Deleted</b></font>"

Expand Down Expand Up @@ -73,12 +79,16 @@
#define VV_HK_EXPOSE "expose"
#define VV_HK_CALLPROC "proc_call"
#define VV_HK_MARK "mark"
#define VV_HK_TAG "tag"
#define VV_HK_ADDCOMPONENT "addcomponent"
#define VV_HK_MODIFY_TRAITS "modtraits"
#ifdef REFERENCE_TRACKING
#define VV_HK_VIEW_REFERENCES "viewreferences"
#endif

// /datum/weakref
#define VV_HK_WEAKREF_RESOLVE "weakref_resolve"

// /atom
#define VV_HK_MODIFY_TRANSFORM "atom_transform"
#define VV_HK_MODIFY_GREYSCALE "modify_greyscale"
Expand All @@ -87,6 +97,7 @@
#define VV_HK_TRIGGER_EXPLOSION "explode"
#define VV_HK_AUTO_RENAME "auto_rename"
#define VV_HK_EDIT_FILTERS "edit_filters"
#define VV_HK_EDIT_COLOR_MATRIX "edit_color_matrix"
#define VV_HK_ADD_AI "add_ai"

// /datum/gas_mixture
Expand Down Expand Up @@ -143,3 +154,8 @@

// paintings
#define VV_HK_REMOVE_PAINTING "remove_painting"

// Flags for debug_variable() that do little things to what we end up rendering

/// ALWAYS render a reduced list, useful for fuckoff big datums that need to be condensed for the sake of client load
#define VV_ALWAYS_CONTRACT_LIST (1<<0)
15 changes: 12 additions & 3 deletions code/__HELPERS/_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
* Misc
*/

// Generic listoflist safe add and removal macros:
///If value is a list, wrap it in a list so it can be used with list add/remove operations
#define LIST_VALUE_WRAP_LISTS(value) (islist(value) ? list(value) : value)
///Add an untyped item to a list, taking care to handle list items by wrapping them in a list to remove the footgun
#define UNTYPED_LIST_ADD(list, item) (list += LIST_VALUE_WRAP_LISTS(item))
///Remove an untyped item to a list, taking care to handle list items by wrapping them in a list to remove the footgun
#define UNTYPED_LIST_REMOVE(list, item) (list -= LIST_VALUE_WRAP_LISTS(item))

// Lazylist macros
#define LAZYINITLIST(L) if (!L) { L = list(); }
#define UNSETEMPTY(L) if (L && !length(L)) L = null
#define ASSOC_UNSETEMPTY(L, K) if (!length(L[K])) L -= K; //NSV13
Expand Down Expand Up @@ -251,8 +260,8 @@
var/list/result = new
if(skiprep)
for(var/e in first)
if(!(e in result) && !(e in second))
result += e
if(!(e in result) && !(e in second))f
UNTYPED_LIST_ADD(result, e)
else
result = first - second
return result
Expand Down Expand Up @@ -685,4 +694,4 @@
. = list()
for(var/i in L)
if(condition.Invoke(i))
. |= i
. |= LIST_VALUE_WRAP_LISTS(i)
17 changes: 17 additions & 0 deletions code/_globalvars/lists/vv.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// A list of all the special byond lists that need to be handled different by vv
GLOBAL_LIST_INIT(vv_special_lists, init_special_list_names())

/proc/init_special_list_names()
var/list/output = list()
var/obj/sacrifice = new
for(var/varname in sacrifice.vars)
var/value = sacrifice.vars[varname]
if(!islist(value))
if(!isdatum(value) && hascall(value, "Cut"))
output += varname
continue
if(isnull(locate(REF(value))))
output += varname
return output

GLOBAL_LIST_INIT(color_vars, list("color"))
12 changes: 12 additions & 0 deletions code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
CtrlShiftClickOn(A)
return
if(modifiers["middle"])
if(modifiers["ctrl"])
CtrlMiddleClickOn(A) // basically for vv tag datum
return
MiddleClickOn(A)
return
if(modifiers["shift"])
Expand Down Expand Up @@ -344,6 +347,15 @@
H.changeNext_move(CLICK_CD_MELEE)
else
..()

/mob/proc/CtrlMiddleClickOn(atom/A)
// specifically made for admin feature.
if(check_rights_for(client, R_ADMIN))
client.toggle_tag_datum(A)
return
A.CtrlClick(src) // this assumes you did CtrlClick instead of MiddleClick
return

/*
Alt click
Unused except for AI
Expand Down
6 changes: 6 additions & 0 deletions code/controllers/globals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ GLOBAL_REAL(GLOB, /datum/controller/global_vars)
return FALSE
return ..()

/datum/controller/global_vars/vv_get_var(var_name)
switch(var_name)
if (NAMEOF(src, vars))
return debug_variable(var_name, list(), 0, src)
return debug_variable(var_name, vars[var_name], 0, src, display_flags = VV_ALWAYS_CONTRACT_LIST)

/datum/controller/global_vars/can_vv_get(var_name)
if(var_name == "gvars_datum_protected_varlist" || var_name == "gvars_datum_in_built_vars")
return FALSE
Expand Down
17 changes: 12 additions & 5 deletions code/datums/datumvars.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,28 @@
/datum/proc/can_vv_mark()
return TRUE

//please call . = ..() first and append to the result, that way parent items are always at the top and child items are further down
//add separaters by doing . += "---"
/**
* Gets all the dropdown options in the vv menu.
* When overriding, make sure to call . = ..() first and appent to the result, that way parent items are always at the top and child items are further down.
* Add seperators by doing VV_DROPDOWN_OPTION("", "---")
*/
/datum/proc/vv_get_dropdown()
SHOULD_CALL_PARENT(TRUE)
. = list()
VV_DROPDOWN_OPTION("", "---")
VV_DROPDOWN_OPTION(VV_HK_CALLPROC, "Call Proc")
VV_DROPDOWN_OPTION(VV_HK_MARK, "Mark Object")
VV_DROPDOWN_OPTION(VV_HK_TAG, "Tag Datum")
VV_DROPDOWN_OPTION(VV_HK_DELETE, "Delete")
VV_DROPDOWN_OPTION(VV_HK_EXPOSE, "Show VV To Player")
VV_DROPDOWN_OPTION(VV_HK_ADDCOMPONENT, "Add Component/Element")
VV_DROPDOWN_OPTION(VV_HK_MODIFY_TRAITS, "Modify Traits")

//This proc is only called if everything topic-wise is verified. The only verifications that should happen here is things like permission checks!
//href_list is a reference, modifying it in these procs WILL change the rest of the proc in topic.dm of admin/view_variables!
//This proc is for "high level" actions like admin heal/set species/etc/etc. The low level debugging things should go in admin/view_variables/topic_basic.dm incase this runtimes.
/**
* This proc is only called if everything topic-wise is verified. The only verifications that should happen here is things like permission checks!
* href_list is a reference, modifying it in these procs WILL change the rest of the proc in topic.dm of admin/view_variables!
* This proc is for "high level" actions like admin heal/set species/etc/etc. The low level debugging things should go in admin/view_variables/topic_basic.dm incase this runtimes.
*/
/datum/proc/vv_do_topic(list/href_list)
if(!usr || !usr.client || !usr.client.holder || !check_rights(NONE))
return FALSE //This is VV, not to be called by anything else.
Expand Down
13 changes: 13 additions & 0 deletions code/datums/keybinding/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@
user.invisimin()
return TRUE

/datum/keybinding/admin/view_tags
key = "F9"
name = "view_tags"
full_name = "View Tags"
description = "Open the View-Tags menu"
keybind_signal = COMSIG_KB_ADMIN_VIEWTAGS_DOWN

/datum/keybinding/admin/view_tags/down(client/user)
. = ..()
if(.)
return
user.holder?.display_tags()
return TRUE

/datum/keybinding/admin/dead_say
key = "F10"
Expand Down
16 changes: 16 additions & 0 deletions code/datums/weakrefs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,19 @@
var/datum/D = locate(reference)
return (!QDELETED(D) && D.weak_reference == src) ? D : null

/datum/weakref/vv_get_dropdown()
. = ..()
VV_DROPDOWN_OPTION(VV_HK_WEAKREF_RESOLVE, "Go to reference")

/datum/weakref/vv_do_topic(list/href_list)
. = ..()

if(!.)
return

if(href_list[VV_HK_WEAKREF_RESOLVE])
if(!check_rights(NONE))
return
var/datum/R = resolve()
if(R)
usr.client.debug_variables(R)
5 changes: 5 additions & 0 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,7 @@
VV_DROPDOWN_OPTION(VV_HK_TRIGGER_EMP, "EMP Pulse")
VV_DROPDOWN_OPTION(VV_HK_TRIGGER_EXPLOSION, "Explosion")
VV_DROPDOWN_OPTION(VV_HK_EDIT_FILTERS, "Edit Filters")
VV_DROPDOWN_OPTION(VV_HK_EDIT_COLOR_MATRIX, "Edit Color as Matrix")
VV_DROPDOWN_OPTION(VV_HK_ADD_AI, "Add AI controller")
if(greyscale_colors)
VV_DROPDOWN_OPTION(VV_HK_MODIFY_GREYSCALE, "Modify greyscale colors")
Expand Down Expand Up @@ -1211,6 +1212,10 @@
var/client/C = usr.client
C?.open_filter_editor(src)

if(href_list[VV_HK_EDIT_COLOR_MATRIX] && check_rights(R_VAREDIT))
var/client/C = usr.client
C?.open_color_matrix_editor(src)

/atom/vv_get_header()
. = ..()
var/refid = REF(src)
Expand Down
2 changes: 2 additions & 0 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ GLOBAL_PROTECT(admin_verbs_default)
/client/proc/cmd_admin_pm_panel, /*admin-pm list*/
/client/proc/stop_sounds,
/client/proc/mark_datum_mapview,
/client/proc/tag_datum_mapview,
/client/proc/requests,
/client/proc/fax_manager
)
Expand Down Expand Up @@ -83,6 +84,7 @@ GLOBAL_PROTECT(admin_verbs_admin)
/client/proc/battle_royale,
/client/proc/delete_book,
/client/proc/cmd_admin_send_pda_msg,
/datum/admins/proc/display_tags,
/client/proc/changeranks, //NSV13 - verb to change rank structure
/client/proc/system_manager, //Nsv13 - Fleet + starsystem management
/client/proc/instance_overmap_menu, //Nsv13 - Midround ship creation.
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/callproc/callproc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ GLOBAL_PROTECT(LastAdminCalledProc)
if(named_arg)
named_args[named_arg] = value["value"]
else
. += value["value"]
. += LIST_VALUE_WRAP_LISTS(value["value"])
if(LAZYLEN(named_args))
. += named_args

Expand Down
3 changes: 3 additions & 0 deletions code/modules/admin/holder2.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ GLOBAL_PROTECT(href_token)

var/datum/filter_editor/filteriffic

/// A lazylist of tagged datums, for quick reference with the View Tags verb
var/list/tagged_datums

/datum/admins/New(datum/admin_rank/R, ckey, force_active = FALSE, protected)
if(IsAdminAdvancedProcCall())
var/msg = " has tried to elevate permissions!"
Expand Down
Loading

0 comments on commit df319de

Please sign in to comment.