mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
[MIRROR] Add a type annotation to represent proc paths (#4799)
* Merge pull request #43029 from AutomaticFrenzy/patch/procpath Add a type annotation to represent proc paths * Add a type annotation to represent proc paths * Update yogstation.dme
This commit is contained in:
committed by
monster860
parent
79533c702b
commit
95aef41edb
24
code/__DEFINES/procpath.dm
Normal file
24
code/__DEFINES/procpath.dm
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/// Represents a proc or verb path.
|
||||||
|
///
|
||||||
|
/// Despite having no DM-defined static type, proc paths have some variables,
|
||||||
|
/// listed below. These are not modifiable, but for a given procpath P,
|
||||||
|
/// `new P(null, "Name", "Desc")` can be used to create a new procpath with the
|
||||||
|
/// same code but new `name` and `desc` values. The other variables cannot be
|
||||||
|
/// changed in this way.
|
||||||
|
///
|
||||||
|
/// This type exists only to act as an annotation, providing reasonable static
|
||||||
|
/// typing for procpaths. Previously, types like `/atom/verb` were used, with
|
||||||
|
/// the `name` and `desc` vars of `/atom` thus being accessible. Proc and verb
|
||||||
|
/// paths will fail `istype` and `ispath` checks against `/procpath`.
|
||||||
|
/procpath
|
||||||
|
// Although these variables are effectively const, if they are marked const
|
||||||
|
// below, their accesses are optimized away.
|
||||||
|
|
||||||
|
/// A text string of the verb's name.
|
||||||
|
var/name as text
|
||||||
|
/// The verb's help text or description.
|
||||||
|
var/desc as text
|
||||||
|
/// The category or tab the verb will appear in.
|
||||||
|
var/category as text
|
||||||
|
/// Only clients/mobs with `see_invisibility` higher can use the verb.
|
||||||
|
var/invisibility as num
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
//do things for each entry in Generate_list
|
//do things for each entry in Generate_list
|
||||||
//return value sets Generate_list[verbpath]
|
//return value sets Generate_list[verbpath]
|
||||||
/datum/verbs/proc/HandleVerb(list/entry, atom/verb/verbpath, ...)
|
/datum/verbs/proc/HandleVerb(list/entry, procpath/verbpath, ...)
|
||||||
return entry
|
return entry
|
||||||
|
|
||||||
/datum/verbs/New()
|
/datum/verbs/New()
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
. += childlist
|
. += childlist
|
||||||
|
|
||||||
for (var/thing in verblist)
|
for (var/thing in verblist)
|
||||||
var/atom/verb/verbpath = thing
|
var/procpath/verbpath = thing
|
||||||
if (!verbpath)
|
if (!verbpath)
|
||||||
stack_trace("Bad VERB in [type] verblist: [english_list(verblist)]")
|
stack_trace("Bad VERB in [type] verblist: [english_list(verblist)]")
|
||||||
var/list/entry = list()
|
var/list/entry = list()
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
|
|||||||
for (var/child in entries)
|
for (var/child in entries)
|
||||||
winset(src, "[child]", "[entries[child]]")
|
winset(src, "[child]", "[entries[child]]")
|
||||||
if (!ispath(child, /datum/verbs/menu))
|
if (!ispath(child, /datum/verbs/menu))
|
||||||
var/atom/verb/verbpath = child
|
var/procpath/verbpath = child
|
||||||
if (copytext(verbpath.name,1,2) != "@")
|
if (copytext(verbpath.name,1,2) != "@")
|
||||||
new child(src)
|
new child(src)
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ GLOBAL_LIST_EMPTY(menulist)
|
|||||||
|
|
||||||
|
|
||||||
/datum/verbs/menu/Icon/Load_checked(client/C) //So we can be lazy, we invoke the "checked" menu item on menu load.
|
/datum/verbs/menu/Icon/Load_checked(client/C) //So we can be lazy, we invoke the "checked" menu item on menu load.
|
||||||
var/atom/verb/verbpath = Get_checked(C)
|
var/procpath/verbpath = Get_checked(C)
|
||||||
if (!verbpath || !(verbpath in typesof("[type]/verb")))
|
if (!verbpath || !(verbpath in typesof("[type]/verb")))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,7 @@
|
|||||||
#include "code\__DEFINES\pinpointers.dm"
|
#include "code\__DEFINES\pinpointers.dm"
|
||||||
#include "code\__DEFINES\pipe_construction.dm"
|
#include "code\__DEFINES\pipe_construction.dm"
|
||||||
#include "code\__DEFINES\preferences.dm"
|
#include "code\__DEFINES\preferences.dm"
|
||||||
|
#include "code\__DEFINES\procpath.dm"
|
||||||
#include "code\__DEFINES\profile.dm"
|
#include "code\__DEFINES\profile.dm"
|
||||||
#include "code\__DEFINES\qdel.dm"
|
#include "code\__DEFINES\qdel.dm"
|
||||||
#include "code\__DEFINES\radiation.dm"
|
#include "code\__DEFINES\radiation.dm"
|
||||||
|
|||||||
@@ -74,6 +74,7 @@
|
|||||||
#include "code\__DEFINES\pinpointers.dm"
|
#include "code\__DEFINES\pinpointers.dm"
|
||||||
#include "code\__DEFINES\pipe_construction.dm"
|
#include "code\__DEFINES\pipe_construction.dm"
|
||||||
#include "code\__DEFINES\preferences.dm"
|
#include "code\__DEFINES\preferences.dm"
|
||||||
|
#include "code\__DEFINES\procpath.dm"
|
||||||
#include "code\__DEFINES\profile.dm"
|
#include "code\__DEFINES\profile.dm"
|
||||||
#include "code\__DEFINES\qdel.dm"
|
#include "code\__DEFINES\qdel.dm"
|
||||||
#include "code\__DEFINES\radiation.dm"
|
#include "code\__DEFINES\radiation.dm"
|
||||||
|
|||||||
Reference in New Issue
Block a user