Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
MosleyTheMalO committed Dec 9, 2023
2 parents 3c2101c + ae873bd commit 700fd57
Show file tree
Hide file tree
Showing 72 changed files with 906 additions and 619 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/vv.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define VV_NULL "NULL"
#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"
Expand Down Expand Up @@ -73,6 +74,7 @@
#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"
#define VV_HK_VIEW_REFERENCES "viewreferences"
Expand Down
8 changes: 8 additions & 0 deletions code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -828,3 +828,11 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
if(prob(15))
corrupted_text += pick(corruption_options)
return corrupted_text

/proc/format_text(text)
return replacetext(replacetext(text,"\proper ",""),"\improper ","")

/// Removes all non-alphanumerics from the text, keep in mind this can lead to id conflicts
/proc/sanitize_css_class_name(name)
var/static/regex/regex = new(@"[^a-zA-Z0-9]","g")
return replacetext(name, regex, "")
3 changes: 0 additions & 3 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -764,9 +764,6 @@ GLOBAL_LIST_INIT(WALLITEMS_INVERSE, typecacheof(list(
return 1
return 0

/proc/format_text(text)
return replacetext(replacetext(text,"\proper ",""),"\improper ","")

/proc/check_target_facings(mob/living/initator, mob/living/target)
/*This can be used to add additional effects on interactions between mobs depending on how the mobs are facing each other, such as adding a crit damage to blows to the back of a guy's head.
Given how click code currently works (Nov '13), the initiating mob will be facing the target mob most of the time
Expand Down
13 changes: 12 additions & 1 deletion code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@
if(modifiers["shift"] && modifiers["ctrl"])
return CtrlShiftClickOn(A)
if(modifiers["middle"])
return MiddleClickOn(A)
if(modifiers["ctrl"])
return CtrlMiddleClickOn(A)
else
return MiddleClickOn(A)
if(modifiers["shift"] && (client && client.show_popup_menus || modifiers["right"])) //CIT CHANGE - makes shift-click examine use right click instead of left click in combat mode
return ShiftClickOn(A)
if(modifiers["alt"]) // alt and alt-gr (rightalt)
Expand Down Expand Up @@ -356,6 +359,14 @@
return TRUE
else
return ..()

/mob/proc/CtrlMiddleClickOn(atom/A)
if(check_rights_for(client, R_ADMIN))
client.toggle_tag_datum(A)
else
A.CtrlClick(src)
return

/*
Alt click
Used as an alternate way to interact with things.
Expand Down
5 changes: 4 additions & 1 deletion code/_onclick/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
CtrlShiftClickOn(A)
return
if(modifiers["middle"])
MiddleClickOn(A)
if(modifiers["ctrl"])
CtrlMiddleClickOn(A)
else
MiddleClickOn(A)
return
if(modifiers["shift"])
ShiftClickOn(A)
Expand Down
1 change: 1 addition & 0 deletions code/datums/datumvars.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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")
Expand Down
4 changes: 3 additions & 1 deletion code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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/debugstatpanel,
/client/proc/fix_air /*resets air in designated radius to its default atmos composition*/
)
Expand Down Expand Up @@ -92,7 +93,8 @@ GLOBAL_PROTECT(admin_verbs_admin)
/client/proc/addvpnbypass, //SPLURT
/client/proc/revokevpnbypass, //SPLURT
/datum/admins/proc/open_borgopanel,
/datum/admins/proc/change_laws //change AI laws
/datum/admins/proc/change_laws, //change AI laws
/datum/admins/proc/display_tags,
)
GLOBAL_LIST_INIT(admin_verbs_ban, list(/client/proc/unban_panel, /client/proc/DB_ban_panel, /client/proc/stickybanpanel))
GLOBAL_PROTECT(admin_verbs_ban)
Expand Down
6 changes: 3 additions & 3 deletions code/modules/admin/callproc/callproc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ GLOBAL_PROTECT(LastAdminCalledProc)
//adv proc call this, ya nerds
/world/proc/WrapAdminProcCall(datum/target, procname, list/arguments)
if(target == GLOBAL_PROC)
return text2path("/proc/[procname]")? call("/proc/[procname]")(arglist(arguments)) : null
else if(target != world && istype(target, /datum)) // isdatum check incase someone manages to call WrapAdminProcCall(global) which would otherwise crash the process entirely
return hascall(target, procname)? call(target, procname)(arglist(arguments)) : null
return call("/proc/[procname]")(arglist(arguments))
else if(target != world)
return call(target, procname)(arglist(arguments))
else
log_admin("[key_name(usr)] attempted to call world/proc/[procname] with arguments: [english_list(arguments)]")

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 @@ -30,6 +30,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/CanProcCall(procname)
. = ..()
if(!check_rights(R_SENSITIVE))
Expand Down
132 changes: 132 additions & 0 deletions code/modules/admin/tag.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/**
* Inserts the target_datum into [/datum/admins/var/tagged_datums], for later reference.
*
* Arguments:
* * target_datum - The datum you want to create a tag for
*/
/datum/admins/proc/add_tagged_datum(datum/target_datum)
if(LAZYFIND(tagged_datums, target_datum))
to_chat(owner, span_warning("[target_datum] is already tagged!"))
return

LAZYADD(tagged_datums, target_datum)
RegisterSignal(target_datum, COMSIG_PARENT_QDELETING, .proc/handle_tagged_del, override = TRUE)
to_chat(owner, span_notice("[target_datum] has been tagged."))

/// Get ahead of the curve with deleting
/datum/admins/proc/handle_tagged_del(datum/source)
SIGNAL_HANDLER

// No point, we don't even care about it anymore.
if(!LAZYFIND(tagged_datums, source))
return

if(owner)
to_chat(owner, span_boldnotice("Tagged datum [source] ([source.type]) has been deleted."))
remove_tagged_datum(source, silent = TRUE)

/**
* Attempts to remove the specified datum from [/datum/admins/var/tagged_datums] if it exists
*
* Arguments:
* * target_datum - The datum you want to remove from the tagged_datums list
* * silent - If TRUE, won't print messages to the owner's chat
*/
/datum/admins/proc/remove_tagged_datum(datum/target_datum, silent=FALSE)
if(!istype(target_datum))
return

if(LAZYFIND(tagged_datums, target_datum))
LAZYREMOVE(tagged_datums, target_datum)
if(!silent)
to_chat(owner, span_notice("[target_datum] has been untagged."))
else if(!silent)
to_chat(owner, span_warning("[target_datum] was not already tagged."))

/// Quick define for readability
#define TAGS_REFRESH "<A href='?src=[REF(src)];[HrefToken(TRUE)];show_tags=1'>Refresh</a>"
#define TAGS_CLEAR "<A href='?src=[REF(src)];[HrefToken(TRUE)];clear_tags=1'>Untag all</a>"

#define TAG_DEL(X) "<b>(<A href='?src=[REF(src)];[HrefToken(TRUE)];del_tag=[REF(X)]'>UNTAG</a>)</b>"
#define TAG_MARK(X) "<b>(<A href='?src=[REF(src)];[HrefToken(TRUE)];mark_datum=[REF(X)]'>MARK</a>)</b>"
#define TAG_SIMPLE_HEALTH(X) "<font color='#ff0000'><b>Health: [X.health]</b></font>"
#define TAG_CARBON_HEALTH(X) "<font color='#ff0000'><b>Health: [X.health]</b></font> (\
<font color='#ff3333'>[X.getBruteLoss()]</font> \
<font color='#ff9933'>[X.getFireLoss()]</font> \
<font color='#00cc66'>[X.getToxLoss()]</font> \
<font color='#00cccc'>[X.getOxyLoss()]</font>\
[X.getCloneLoss() ? " <font color='#1c3ac4'>[X.getCloneLoss()]</font>" : ""])"

/// Display all of the tagged datums
/datum/admins/proc/display_tags()
set category = "Admin.Game"
set name = "View Tags"

if (!istype(src, /datum/admins))
src = usr.client.holder
if (!istype(src, /datum/admins))
to_chat(usr, "Error: you are not an admin!", confidential = TRUE)
return

var/index = 0
var/list/dat = list("<center><B>Tag Menu</B></center><hr>")

dat += "<br>[TAGS_REFRESH] | [TAGS_CLEAR]<br>"
if(LAZYLEN(tagged_datums))
for(var/datum/iter_datum as anything in tagged_datums)
index++
var/specific_info

if(isnull(iter_datum))
dat += "\t[index]: Null reference - Check runtime logs!"
stack_trace("Null datum found in tagged datum menu! User: [usr]")
continue
else if(iscarbon(iter_datum))
var/mob/living/carbon/resolved_carbon = iter_datum
specific_info = "[TAG_CARBON_HEALTH(resolved_carbon)] | [AREACOORD(resolved_carbon)] [ADMIN_PP(iter_datum)] [ADMIN_FLW(iter_datum)]"
else if(isliving(iter_datum))
var/mob/living/resolved_living = iter_datum
specific_info = "[TAG_SIMPLE_HEALTH(resolved_living)] | [AREACOORD(resolved_living)] [ADMIN_PP(iter_datum)] [ADMIN_FLW(iter_datum)]"
else if(ismob(iter_datum))
var/atom/resolved_atom = iter_datum // needed for ADMIN_JMP
specific_info = "[AREACOORD(resolved_atom)] [ADMIN_PP(iter_datum)] [ADMIN_FLW(iter_datum)]"
else if(ismovable(iter_datum))
var/atom/resolved_atom = iter_datum // needed for ADMIN_JMP
specific_info = "[AREACOORD(resolved_atom)] [ADMIN_FLW(iter_datum)]"
else if(isatom(iter_datum))
var/atom/resolved_atom = iter_datum // needed for ADMIN_JMP
specific_info = "[AREACOORD(resolved_atom)] [ADMIN_JMP(resolved_atom)]"
else if(istype(iter_datum, /datum/controller/subsystem))
var/datum/controller/subsystem/resolved_subsystem = iter_datum
specific_info = "[resolved_subsystem.stat_entry()]"
// else, it's just a /datum

dat += "\t[index]: [iter_datum] | [specific_info] | [ADMIN_VV(iter_datum)]| [TAG_DEL(iter_datum)] | [iter_datum == marked_datum ? "<b>Marked</b>" : TAG_MARK(iter_datum)] "
dat += "\t(<b><font size='2'>[iter_datum.type])</font></b>"
else
dat += "No datums tagged :("

dat = dat.Join("<br>")
usr << browse(dat, "window=tag;size=800x480")

/**
* Clears tagged datums
*/
/datum/admins/proc/clear_tags()
var/amount_of_tags = LAZYLEN(tagged_datums)
if(!amount_of_tags)
to_chat(owner, span_warning("There are no tagged datums to clear."))
return
var/confirmation = alert(usr, "Clear your tagged datums? ([amount_of_tags])", "Confirmation", "Yes", "No")
if(confirmation != "Yes")
return
LAZYNULL(tagged_datums)
to_chat(owner, span_notice("Tagged datums have been cleared, [amount_of_tags] item\s removed."))

#undef TAGS_REFRESH
#undef TAGS_CLEAR

#undef TAG_DEL
#undef TAG_MARK
#undef TAG_SIMPLE_HEALTH
#undef TAG_CARBON_HEALTH
25 changes: 25 additions & 0 deletions code/modules/admin/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2726,6 +2726,31 @@
log_query_debug("[usr.key] | [response]")
else if(answer == "no")
log_query_debug("[usr.key] | Reported no server hang")
else if(href_list["del_tag"])
if(!check_rights(R_ADMIN))
return
var/datum/datum_to_remove = locate(href_list["del_tag"])
if(!datum_to_remove)
return
return remove_tagged_datum(datum_to_remove)

else if(href_list["show_tags"])
if(!check_rights(R_ADMIN))
return
return display_tags()

else if(href_list["clear_tags"])
if(!check_rights(R_ADMIN))
return
return clear_tags()

else if(href_list["mark_datum"])
if(!check_rights(R_ADMIN))
return
var/datum/datum_to_mark = locate(href_list["mark_datum"])
if(!datum_to_mark)
return
return usr.client?.mark_datum(datum_to_mark)

/datum/admins/proc/HandleCMode()
if(!check_rights(R_ADMIN))
Expand Down
19 changes: 19 additions & 0 deletions code/modules/admin/view_variables/get_variables.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@
markstring = "[VV_MARKED_DATUM] (CURRENT: [(istype(holder) && istype(holder.marked_datum))? holder.marked_datum.type : "NULL"])"
classes += markstring

var/list/tagstrings = new
if(!(VV_TAGGED_DATUM in restricted_classes) && holder && LAZYLEN(holder.tagged_datums))
var/i = 0
for(var/datum/iter_tagged_datum as anything in holder.tagged_datums)
i++
var/new_tagstring = "[VV_TAGGED_DATUM] #[i]: [iter_tagged_datum.type])"
tagstrings[new_tagstring] = iter_tagged_datum
classes += new_tagstring

if(restricted_classes)
classes -= restricted_classes

Expand All @@ -87,6 +96,11 @@
if(holder && holder.marked_datum && .["class"] == markstring)
.["class"] = VV_MARKED_DATUM

if(holder && tagstrings[.["class"]])
var/datum/chosen_datum = tagstrings[.["class"]]
.["value"] = chosen_datum
.["class"] = VV_TAGGED_DATUM

switch(.["class"])
if(VV_TEXT)
.["value"] = input("Enter new text:", "Text", current_value) as null|text
Expand Down Expand Up @@ -202,6 +216,11 @@
.["class"] = null
return

if(VV_TAGGED_DATUM)
if(.["value"] == null)
.["class"] = null
return

if(VV_PROCCALL_RETVAL)
var/list/get_retval = list()
callproc_blocking(get_retval)
Expand Down
18 changes: 18 additions & 0 deletions code/modules/admin/view_variables/tag_datum.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/client/proc/tag_datum(datum/target_datum)
if(!holder || QDELETED(target_datum))
return
holder.add_tagged_datum(target_datum)

/client/proc/toggle_tag_datum(datum/target_datum)
if(!holder || !target_datum)
return

if(LAZYFIND(holder.tagged_datums, target_datum))
holder.remove_tagged_datum(target_datum)
else
holder.add_tagged_datum(target_datum)

/client/proc/tag_datum_mapview(datum/target_datum as mob|obj|turf|area in view(view))
set category = "Debug"
set name = "Tag Datum"
tag_datum(target_datum)
2 changes: 2 additions & 0 deletions code/modules/admin/view_variables/topic_basic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@

if(href_list[VV_HK_MARK])
usr.client.mark_datum(target)
if(href_list[VV_HK_TAG])
usr.client.tag_datum(target)
if(href_list[VV_HK_ADDCOMPONENT])
if(!check_rights(NONE))
return
Expand Down
Loading

0 comments on commit 700fd57

Please sign in to comment.