April sync (#360)
* Maps and things no code/icons * helpers defines globalvars * Onclick world.dm orphaned_procs * subsystems Round vote and shuttle autocall done here too * datums * Game folder * Admin - chatter modules * clothing - mining * modular computers - zambies * client * mob level 1 * mob stage 2 + simple_animal * silicons n brains * mob stage 3 + Alien/Monkey * human mobs * icons updated * some sounds * emitter y u no commit * update tgstation.dme * compile fixes * travis fixes Also removes Fast digest mode, because reasons. * tweaks for travis Mentors are broke again Also fixes Sizeray guns * oxygen loss fix for vore code. * removes unused code * some code updates * bulk fixes * further fixes * outside things * whoops. * Maint bar ported * GLOBs.
This commit is contained in:
@@ -2,15 +2,15 @@
|
||||
#define pick_list_replacements(FILE, KEY) (strings_replacement(FILE, KEY))
|
||||
#define json_load(FILE) (json_decode(file2text(FILE)))
|
||||
|
||||
var/global/list/string_cache
|
||||
var/global/string_filename_current_key
|
||||
GLOBAL_LIST(string_cache)
|
||||
GLOBAL_VAR(string_filename_current_key)
|
||||
|
||||
|
||||
/proc/strings_replacement(filename, key)
|
||||
load_strings_file(filename)
|
||||
|
||||
if((filename in string_cache) && (key in string_cache[filename]))
|
||||
var/response = pick(string_cache[filename][key])
|
||||
if((filename in GLOB.string_cache) && (key in GLOB.string_cache[filename]))
|
||||
var/response = pick(GLOB.string_cache[filename][key])
|
||||
var/regex/r = regex("@pick\\((\\D+?)\\)", "g")
|
||||
response = r.Replace(response, /proc/strings_subkey_lookup)
|
||||
return response
|
||||
@@ -19,23 +19,23 @@ var/global/string_filename_current_key
|
||||
|
||||
/proc/strings(filename as text, key as text)
|
||||
load_strings_file(filename)
|
||||
if((filename in string_cache) && (key in string_cache[filename]))
|
||||
return string_cache[filename][key]
|
||||
if((filename in GLOB.string_cache) && (key in GLOB.string_cache[filename]))
|
||||
return GLOB.string_cache[filename][key]
|
||||
else
|
||||
CRASH("strings list not found: strings/[filename], index=[key]")
|
||||
|
||||
/proc/strings_subkey_lookup(match, group1)
|
||||
return pick_list(string_filename_current_key, group1)
|
||||
return pick_list(GLOB.string_filename_current_key, group1)
|
||||
|
||||
/proc/load_strings_file(filename)
|
||||
string_filename_current_key = filename
|
||||
if(filename in string_cache)
|
||||
GLOB.string_filename_current_key = filename
|
||||
if(filename in GLOB.string_cache)
|
||||
return //no work to do
|
||||
|
||||
if(!string_cache)
|
||||
string_cache = new
|
||||
if(!GLOB.string_cache)
|
||||
GLOB.string_cache = new
|
||||
|
||||
if(fexists("strings/[filename]"))
|
||||
string_cache[filename] = json_load("strings/[filename]")
|
||||
GLOB.string_cache[filename] = json_load("strings/[filename]")
|
||||
else
|
||||
CRASH("file not found: strings/[filename]")
|
||||
|
||||
Reference in New Issue
Block a user