diff --git a/code/__DEFINES/text.dm b/code/__DEFINES/text.dm new file mode 100644 index 000000000000..aae3d1f17449 --- /dev/null +++ b/code/__DEFINES/text.dm @@ -0,0 +1,76 @@ +/// Does 4 spaces. Used as a makeshift tabulator. +#define FOURSPACES "    " + +/// Standard maptext +/// Prepares a text to be used for maptext. Use this so it doesn't look hideous. +#define MAPTEXT(text) {"[##text]"} + +/** + * Pixel-perfect scaled fonts for use in the MAP element as defined in skin.dmf + * + * Four sizes to choose from, use the sizes as mentioned below. + * Between the variations and a step there should be an option that fits your use case. + * BYOND uses pt sizing, different than px used in TGUI. Using px will make it look blurry due to poor antialiasing. + * + * Default sizes are prefilled in the macro for ease of use and a consistent visual look. + * To use a step other than the default in the macro, specify it in a span style. + * For example: MAPTEXT_PIXELLARI("Some large maptext here") + */ +/// Large size (ie: context tooltips) - Size options: 12pt 24pt. +#define MAPTEXT_PIXELLARI(text) {"[##text]"} + +/// Standard size (ie: normal runechat) - Size options: 6pt 12pt 18pt. +#define MAPTEXT_GRAND9K(text) {"[##text]"} + +/// Small size. (ie: context subtooltips, spell delays) - Size options: 12pt 24pt. +#define MAPTEXT_TINY_UNICODE(text) {"[##text]"} + +/// Smallest size. (ie: whisper runechat) - Size options: 6pt 12pt 18pt. +#define MAPTEXT_SPESSFONT(text) {"[##text]"} + +/** + * Prepares a text to be used for maptext, using a variable size font. + * + * More flexible but doesn't scale pixel perfect to BYOND icon resolutions. + * (May be blurry.) Can use any size in pt or px. + * + * You MUST Specify the size when using the macro + * For example: MAPTEXT_VCR_OSD_MONO("Some large maptext here") + */ +/// Prepares a text to be used for maptext, using a variable size font. +/// Variable size font. More flexible but doesn't scale pixel perfect to BYOND icon resolutions. (May be blurry.) Can use any size in pt or px. +#define MAPTEXT_VCR_OSD_MONO(text) {"[##text]"} + +/// Macro from Lummox used to get height from a MeasureText proc. +/// resolves the MeasureText() return value once, then resolves the height, then sets return_var to that. +#define WXH_TO_HEIGHT(measurement, return_var) \ + do { \ + var/_measurement = measurement; \ + return_var = text2num(copytext(_measurement, findtextEx(_measurement, "x") + 1)); \ + } while(FALSE); + +/// Removes characters incompatible with file names. +#define SANITIZE_FILENAME(text) (GLOB.filename_forbidden_chars.Replace(text, "")) + +/// Simply removes the < and > characters, and limits the length of the message. +#define STRIP_HTML_SIMPLE(text, limit) (GLOB.angular_brackets.Replace(copytext(text, 1, limit), "")) + +/// Removes everything enclose in < and > inclusive of the bracket, and limits the length of the message. +#define STRIP_HTML_FULL(text, limit) (GLOB.html_tags.Replace(copytext(text, 1, limit), "")) + +/** + * stuff like `copytext(input, length(input))` will trim the last character of the input, + * because DM does it so it copies until the char BEFORE the `end` arg, so we need to bump `end` by 1 in these cases. + */ +#define PREVENT_CHARACTER_TRIM_LOSS(integer) (integer + 1) + +/// BYOND's string procs don't support being used on datum references (as in it doesn't look for a name for stringification) +/// We just use this macro to ensure that we will only pass strings to this BYOND-level function without developers needing to really worry about it. +#define LOWER_TEXT(thing) lowertext(UNLINT("[thing]")) + +/// Folder directory for strings +#define STRING_DIRECTORY "strings" + +#define ALPHABET list("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z") +#define VOWELS list("a", "e", "i", "o", "u") +#define CONSONANTS (ALPHABET - VOWELS) diff --git a/code/modules/stock_market/articles.dm b/code/modules/stock_market/articles.dm index 4d7a7ab3763f..1f3fa1c1067d 100644 --- a/code/modules/stock_market/articles.dm +++ b/code/modules/stock_market/articles.dm @@ -1,10 +1,3 @@ - -/proc/consonant() - return pick("B","C","D","F","G","H","J","K","L","M","N","P","Q","R","S","T","V","W","X","Y","Z") - -/proc/vowel() - return pick("A", "E", "I", "O", "U") - /proc/ucfirst(S) return "[uppertext(ascii2text(text2ascii(S, 1)))][copytext(S, 2)]" @@ -18,7 +11,7 @@ GLOBAL_LIST_EMPTY(FrozenAccounts) /proc/list_frozen() - for (var/A in GLOB.FrozenAccounts) + for(var/A in GLOB.FrozenAccounts) to_chat(usr, "[A]: [length(GLOB.FrozenAccounts[A])] borrows") /datum/article @@ -95,9 +88,9 @@ GLOBAL_LIST_EMPTY(FrozenAccounts) /datum/article/proc/generateAuthorName() switch(rand(1,3)) if (1) - return "[consonant()]. [pick(GLOB.last_names)]" + return "[CONSONANTS]. [pick(GLOB.last_names)]" if (2) - return "[prob(50) ? pick(GLOB.first_names_male) : pick(GLOB.first_names_female)] [consonant()].[prob(50) ? "[consonant()]. " : null] [pick(GLOB.last_names)]" + return "[prob(50) ? pick(GLOB.first_names_male) : pick(GLOB.first_names_female)] [CONSONANTS].[prob(50) ? "[CONSONANTS]. " : null] [pick(GLOB.last_names)]" if (3) return "[prob(50) ? pick(GLOB.first_names_male) : pick(GLOB.first_names_female)] \"[prob(50) ? pick(GLOB.first_names_male) : pick(GLOB.first_names_female)]\" [pick(GLOB.last_names)]" @@ -105,7 +98,7 @@ GLOBAL_LIST_EMPTY(FrozenAccounts) var/ticksc = round(ticks/100) ticksc = ticksc % 100000 var/ticksp = "[ticksc]" - while (length(ticksp) < 5) + for(var/cycle = 1 to 5) ticksp = "0[ticksp]" spacetime = "[ticksp][time2text(world.realtime, "MM")][time2text(world.realtime, "DD")][text2num(time2text(world.realtime, "YYYY"))+540]" diff --git a/code/modules/stock_market/events.dm b/code/modules/stock_market/events.dm index 7517927453bd..0a1af3fa54d2 100644 --- a/code/modules/stock_market/events.dm +++ b/code/modules/stock_market/events.dm @@ -156,7 +156,7 @@ current_desc = "" female = prob(50) if (prob(50)) - position = "C[prob(20) ? vowel() : consonant()]O" + position = "C[prob(20) ? VOWELS : CONSONANTS]O" else position = ucfirsts(company.industry.detokenize("Lead %industrial% Engineer")) offenses = "" @@ -166,7 +166,7 @@ "dereliction of duty", "spacecraft piracy", "music piracy", "tabletop game piracy", "software piracy", "escaping from space prison", "seniornapping", "clownnapping", "corginapping", "catnapping", "sleeping on the job", "terrorism", "counterterrorism", "drug distribution", "insubordination", "jaywalking", "owning a computer", "owning a cellphone", "owning a PDA", "owning a pAI", "adultery", "committing an unnatural act with another person", "corrupting public morals", "skateboarding without a license", "shitcurity", "erotic roleplay", "accidentally strangling a prostitute") - while (prob(60) && O.len > 2) + if(prob(60) && O.len > 2) var/offense = pick(O) O -= offense offense = "[prob(20) ? "attempted " : (prob(20) ? "being accessory to " : null)][offense][prob(5) ? " of the [pick("first", "second", "third", "fourth", "fifth", "sixth")] degree" : null]" diff --git a/code/modules/stock_market/industries.dm b/code/modules/stock_market/industries.dm index 2fc6bd50f7dc..80d83700ddfa 100644 --- a/code/modules/stock_market/industries.dm +++ b/code/modules/stock_market/industries.dm @@ -77,10 +77,10 @@ "Will %company_name% grow on %industrial% wasteland? Owners of %product_name% may decide", \ "%company_name% looking to reap profits off the %industrial% sector with %product_name%") -/datum/industry/agriculture/generateProductName(var/company_name) +/datum/industry/agriculture/generateProductName(company_name) var/list/products = list("water tank", "cattle prod", "scythe", "plough", "sickle", "cultivator", "loy", "spade", "hoe", "daisy grubber", "cotton gin") var/list/prefix = list("[company_name]'s ", "the [company_name] ", "the fully automatic ", "the full-duplex ", "the semi-automatic ", "the drone-mounted ", "the industry-leading ", "the world-class ") - var/list/suffix = list(" of farming", " multiplex", " +[rand(1,15)]", " [consonant()][rand(1000, 9999)]", " hybrid", " maximus", " extreme") + var/list/suffix = list(" of farming", " multiplex", " +[rand(1,15)]", " [CONSONANTS][rand(1000, 9999)]", " hybrid", " maximus", " extreme") return "[pick(prefix)][pick(products)][pick(suffix)]" @@ -158,7 +158,7 @@ /datum/industry/it/generateProductName(company_name) var/list/products = list("generator", "laptop", "keyboard", "memory card", "display", "operating system", "processor", "graphics card", "nanobots", "power supply", "pAI", "mech", "capacitor", "cell") var/list/prefix = list("the [company_name] ", "the high performance ", "the mobile ", "the portable ", "the professional ", "the extreme ", "the incredible ", "the blazing fast ", "the bleeding edge ", "the bluespace-powered ", null) - var/L = pick(consonant(), "Seed ", "Radiant ", "Robust ", "Pentathon ", "Athlete ", "Phantom ", "Semper Fi ") + var/L = pick(CONSONANTS, "Seed ", "Radiant ", "Robust ", "Pentathon ", "Athlete ", "Phantom ", "Semper Fi ") var/N = rand(1, 99) var/prefix2 = "[L][N][prob(5) ? " " + latin_number(N) : null]" return "[pick(prefix)][prefix2] [pick(products)]" @@ -174,7 +174,7 @@ /datum/industry/communications/generateProductName(company_name) var/list/products = list("mobile phone", "PDA", "tablet computer", "newscaster", "social network") var/list/prefix = list("the [company_name] ", "the high performance ", "the mobile ", "the portable ", "the professional ", "the extreme ", "the incredible ", "the blazing fast ", "the bleeding edge ", null) - var/L = pick("[lowertext(consonant())]Phone ", "Universe ", "Xperience ", "Next ", "Engin Y ", "Cyborg ", "[consonant()]") + var/L = pick("[lowertext(CONSONANTS)]Phone ", "Universe ", "Xperience ", "Next ", "Engin Y ", "Cyborg ", "[CONSONANTS]") var/N = rand(1,99) var/prefix2 = "[L][N][prob(25) ? pick(" Tiny", " Mini", " Micro", " Slim", " Water", " Air", " Fire", " Earth", " Nano", " Pico", " Femto", " Planck") : null]" return "[pick(prefix)][prefix2] [pick(products)]" diff --git a/code/modules/stock_market/stockmarket.dm b/code/modules/stock_market/stockmarket.dm index 5ebcb90d5e4d..3752b8161edd 100644 --- a/code/modules/stock_market/stockmarket.dm +++ b/code/modules/stock_market/stockmarket.dm @@ -70,8 +70,8 @@ var/sname = "" switch (rand(1,6)) if(1) - while (sname == "" || sname == "FAG") // honestly it's a 0.6% chance per round this happens - or once in 166 rounds - so i'm accounting for it before someone yells at me - sname = "[consonant()][vowel()][consonant()]" + if(sname == "" || sname == "FAG") // honestly it's a 0.6% chance per round this happens - or once in 166 rounds - so i'm accounting for it before someone yells at me + sname = "[CONSONANTS][VOWELS][CONSONANTS]" if (2) sname = "[pick(tech_prefix)][pick(tech_short)][prob(20) ? " " + pick(company) : null]" if (3 to 4) diff --git a/lobotomy-corp13.dme b/lobotomy-corp13.dme index df943715034b..170c6d5f0dd7 100644 --- a/lobotomy-corp13.dme +++ b/lobotomy-corp13.dme @@ -139,6 +139,7 @@ #include "code\__DEFINES\storage.dm" #include "code\__DEFINES\subsystems.dm" #include "code\__DEFINES\TeguDefines.dm" +#include "code\__DEFINES\text.dm" #include "code\__DEFINES\tgs.config.dm" #include "code\__DEFINES\tgs.dm" #include "code\__DEFINES\tgui.dm"