From 3123d7ed3ccf7f1e7cbdc20abefb8fbc143cc535 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Mon, 9 Sep 2019 11:27:09 -0700 Subject: [PATCH] vv crap --- code/__HELPERS/_lists.dm | 26 - code/__HELPERS/type2type.dm | 36 ++ code/__defines/_lists.dm | 3 +- code/__defines/flags.dm | 2 + code/__defines/items_clothing.dm | 1 + code/datums/browser.dm | 505 ++++++++++++++++++ code/datums/helper_datums/events.dm | 4 +- code/datums/helper_datums/topic_input.dm | 2 +- code/game/atom_vv.dm | 2 + code/game/mecha/mecha.dm | 2 +- code/game/turfs/change_turf.dm | 4 + code/modules/admin/topic.dm | 2 +- .../{client defines.dm => client_defines.dm} | 0 .../{client procs.dm => client_procs.dm} | 21 + code/modules/mob/mob.dm | 2 +- vorestation.dme | 5 +- 16 files changed, 582 insertions(+), 35 deletions(-) create mode 100644 code/game/turfs/change_turf.dm rename code/modules/client/{client defines.dm => client_defines.dm} (100%) rename code/modules/client/{client procs.dm => client_procs.dm} (96%) diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index ea27f1aa298..999577ae129 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -213,32 +213,6 @@ proc/listclearnulls(list/list) return (result + L.Copy(Li, 0)) return (result + R.Copy(Ri, 0)) -//Converts a bitfield to a list of numbers (or words if a wordlist is provided) -/proc/bitfield2list(bitfield = 0, list/wordlist) - var/list/r = list() - if(istype(wordlist,/list)) - var/max = min(wordlist.len,16) - var/bit = 1 - for(var/i=1, i<=max, i++) - if(bitfield & bit) - r += wordlist[i] - bit = bit << 1 - else - for(var/bit=1, bit<=65535, bit = bit << 1) - if(bitfield & bit) - r += bit - - return r - -// Returns the key based on the index -/proc/get_key_by_index(var/list/L, var/index) - var/i = 1 - for(var/key in L) - if(index == i) - return key - i++ - return null - // Returns the key based on the index /proc/get_key_by_value(var/list/L, var/value) for(var/key in L) diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm index 22d8ffbfc04..179bc2c8237 100644 --- a/code/__HELPERS/type2type.dm +++ b/code/__HELPERS/type2type.dm @@ -278,3 +278,39 @@ return "turf" else //regex everything else (works for /proc too) return lowertext(replacetext("[the_type]", "[type2parent(the_type)]/", "")) + +//This is a weird one: +//It returns a list of all var names found in the string +//These vars must be in the [var_name] format +//It's only a proc because it's used in more than one place + +//Takes a string and a datum +//The string is well, obviously the string being checked +//The datum is used as a source for var names, to check validity +//Otherwise every single word could technically be a variable! +/proc/string2listofvars(var/t_string, var/datum/var_source) + if(!t_string || !var_source) + return list() + + . = list() + + var/var_found = findtext(t_string,"\[") //Not the actual variables, just a generic "should we even bother" check + if(var_found) + //Find var names + + // "A dog said hi [name]!" + // splittext() --> list("A dog said hi ","name]!" + // jointext() --> "A dog said hi name]!" + // splittext() --> list("A","dog","said","hi","name]!") + + t_string = replacetext(t_string,"\[","\[ ")//Necessary to resolve "word[var_name]" scenarios + var/list/list_value = splittext(t_string,"\[") + var/intermediate_stage = jointext(list_value, null) + + list_value = splittext(intermediate_stage," ") + for(var/value in list_value) + if(findtext(value,"]")) + value = splittext(value,"]") //"name]!" --> list("name","!") + for(var/A in value) + if(var_source.vars.Find(A)) + . += A diff --git a/code/__defines/_lists.dm b/code/__defines/_lists.dm index 78a6ada4229..d41183ca889 100644 --- a/code/__defines/_lists.dm +++ b/code/__defines/_lists.dm @@ -27,7 +27,8 @@ #define reverseList(L) reverseRange(L.Copy()) #define SAFEPICK(L) (length(L)? pick(L) : null) -#define SAFEACCESS(L, I) ((isnum(I) && ISINRANGE(I, 1, length(L))? L[I] : null) +#define SAFEACCESS(L, I) (isnum(I)? (SAFEINDEXACCESS(L, I)) : ((I in L)? L[I] : null)) +#define SAFEINDEXACCESS(L, I) (IsInRange(I, 1, length(L))? L[I] : null) // Returns the key based on the index #define KEYBYINDEX(L, index) (((index <= length(L)) && (index > 0)) ? L[index] : null) diff --git a/code/__defines/flags.dm b/code/__defines/flags.dm index 267ff28c82e..54cb8661e02 100644 --- a/code/__defines/flags.dm +++ b/code/__defines/flags.dm @@ -17,3 +17,5 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204 #define DF_VAR_EDITED (1<<0) #define DF_ISPROCESSING (1<<1) #define DF_USE_TAG (1<<2) + +// /atom flags var diff --git a/code/__defines/items_clothing.dm b/code/__defines/items_clothing.dm index 902f27d5542..581270cd587 100644 --- a/code/__defines/items_clothing.dm +++ b/code/__defines/items_clothing.dm @@ -51,6 +51,7 @@ #define PROXMOVE 0x80 // Does this object require proximity checking in Enter()? #define OVERLAY_QUEUED 0x100 // Atom queued to SSoverlay for COMPILE_OVERLAYS #define INITIALIZED 0x200 +#define ADMIN_SPAWNED 0x400 //Flags for items (equipment) - Used in /obj/item/var/item_flags #define THICKMATERIAL 0x1 // Prevents syringes, parapens and hyposprays if equipped to slot_suit or slot_head. diff --git a/code/datums/browser.dm b/code/datums/browser.dm index b094cd57d5c..45f7c8c3a00 100644 --- a/code/datums/browser.dm +++ b/code/datums/browser.dm @@ -189,3 +189,508 @@ //world << "[src] was [src.mob.machine], setting to null" src.mob.unset_machine() return + + +/datum/browser/modal + var/opentime = 0 + var/timeout + var/selectedbutton = 0 + var/stealfocus + +/datum/browser/modal/New(nuser, nwindow_id, ntitle = 0, nwidth = 0, nheight = 0, var/atom/nref = null, StealFocus = 1, Timeout = 6000) + ..() + stealfocus = StealFocus + if (!StealFocus) + window_options += "focus=false;" + timeout = Timeout + + +/datum/browser/modal/close() + .=..() + opentime = 0 + +/datum/browser/modal/open(use_onclose) + set waitfor = 0 + opentime = world.time + + if (stealfocus) + . = ..(use_onclose = 1) + else + var/focusedwindow = winget(user, null, "focus") + . = ..(use_onclose = 1) + + //waits for the window to show up client side before attempting to un-focus it + //winexists sleeps until it gets a reply from the client, so we don't need to bother sleeping + for (var/i in 1 to 10) + if (user && winexists(user, window_id)) + if (focusedwindow) + winset(user, focusedwindow, "focus=true") + else + winset(user, "mapwindow", "focus=true") + break + if (timeout) + addtimer(CALLBACK(src, .proc/close), timeout) + +/datum/browser/modal/proc/wait() + while (opentime && selectedbutton <= 0 && (!timeout || opentime+timeout > world.time)) + stoplag(1) + +/datum/browser/modal/listpicker + var/valueslist = list() + +/datum/browser/modal/listpicker/New(User,Message,Title,Button1="Ok",Button2,Button3,StealFocus = 1, Timeout = FALSE,list/values,inputtype="checkbox", width, height, slidecolor) + if (!User) + return + + var/output = {"