Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update maptext #6867

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "code\__DEFINES\chat.dm"
#include "code\__DEFINES\chemistry.dm"
#include "code\__DEFINES\coloration.dm"
#include "code\__DEFINES\colors.dm"
#include "code\__DEFINES\configuration.dm"
#include "code\__DEFINES\construction.dm"
#include "code\__DEFINES\damage_organs.dm"
Expand Down Expand Up @@ -371,6 +372,7 @@
#include "code\__HELPERS\atom_movables.dm"
#include "code\__HELPERS\chat.dm"
#include "code\__HELPERS\coloration.dm"
#include "code\__HELPERS\colors.dm"
#include "code\__HELPERS\datum.dm"
#include "code\__HELPERS\debugging.dm"
#include "code\__HELPERS\do_after.dm"
Expand Down Expand Up @@ -595,6 +597,7 @@
#include "code\controllers\subsystem\preferences.dm"
#include "code\controllers\subsystem\radiation.dm"
#include "code\controllers\subsystem\repository.dm"
#include "code\controllers\subsystem\runechat.dm"
#include "code\controllers\subsystem\server_maint.dm"
#include "code\controllers\subsystem\shuttles.dm"
#include "code\controllers\subsystem\simple_networks.dm"
Expand Down Expand Up @@ -691,6 +694,7 @@
#include "code\datums\category.dm"
#include "code\datums\changelog.dm"
#include "code\datums\character_profile.dm"
#include "code\datums\chatmessage.dm"
#include "code\datums\computerfiles.dm"
#include "code\datums\datacore.dm"
#include "code\datums\datum.dm"
Expand Down Expand Up @@ -5324,6 +5328,12 @@
#include "interface\interface.dm"
#include "interface\stylesheet.dm"
#include "interface\skin.dmf"
#include "interface\fonts\fonts_datum.dm"
#include "interface\fonts\grand_9k.dm"
#include "interface\fonts\pixellari.dm"
#include "interface\fonts\spess_font.dm"
#include "interface\fonts\tiny_unicode.dm"
#include "interface\fonts\vcr_osd_mono.dm"
#include "interface\menus\_menus.dm"
#include "interface\menus\main.dm"
#include "maps\endeavour\endeavour-areas.dm"
Expand Down
6 changes: 6 additions & 0 deletions code/__DEFINES/_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
#define LAZYLEN(L) length(L)
///Sets a list to null
#define LAZYNULL(L) L = null
///Adds to the item K the value V, if the list is null it will initialize it
#define LAZYADDASSOC(L, K, V) if(!L) { L = list(); } L[K] += V;
///This is used to add onto lazy assoc list when the value you're adding is a /list/. This one has extra safety over lazyaddassoc because the value could be null (and thus cant be used to += objects)
#define LAZYADDASSOCLIST(L, K, V) if(!L) { L = list(); } L[K] += list(V);
///Removes the value V from the item K, if the item K is empty will remove it from the list, if the list is empty will set the list to null
#define LAZYREMOVEASSOC(L, K, V) if(L) { if(L[K]) { L[K] -= V; if(!length(L[K])) L -= K; } if(!length(L)) L = null; }
/// Null-safe L.Cut()
#define LAZYCLEARLIST(L) if(L) L.Cut()
/// Null-safe L.Copy()
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/_tick.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
/// runs stoplag if tick_usage is above the limit
#define CHECK_TICK ( TICK_CHECK ? stoplag() : 0 )

/// Checks if a sleeping proc is running before or after the master controller
#define RUNNING_BEFORE_MASTER ( Master.last_run != null && Master.last_run != world.time )
/// Returns true if a verb ought to yield to the MC (IE: queue up to be processed by a subsystem)
#define VERB_SHOULD_YIELD ( TICK_CHECK || RUNNING_BEFORE_MASTER )

/// Returns true if tick usage is above 95, for high priority usage
///
/// * Use for admin functions so they stay responsive and functional during lag.
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/colors.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

#define CM_COLOR_SAT_MIN 0.6
#define CM_COLOR_SAT_MAX 0.7
#define CM_COLOR_LUM_MIN 0.65
#define CM_COLOR_LUM_MAX 0.75
3 changes: 2 additions & 1 deletion code/__DEFINES/controllers/_subsystem-priority.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
#define FIRE_PRIORITY_OVERLAYS 100
#define FIRE_PRIORITY_SMOOTHING 100
#define FIRE_PRIORITY_CHAT 100
#define FIRE_PRIORITY_INPUT 100
#define FIRE_PRIORITY_RUNECHAT 100
#define FIRE_PRIORITY_INPUT 1000 // we dont want to drop user input right?

//? Ticker Subsystems - Highest priority
// Any subsystem flagged with SS_TICKER is here!
Expand Down
13 changes: 12 additions & 1 deletion code/__DEFINES/controllers/_subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,24 @@
}\
/datum/controller/subsystem/##X

/**
* Defines a timer subsystem.
*/
#define TIMER_SUBSYSTEM_DEF(X) GLOBAL_REAL(SS##X, /datum/controller/subsystem/timer/##X);\
/datum/controller/subsystem/timer/##X/New(){\
NEW_SS_GLOBAL(SS##X);\
}\
/datum/controller/subsystem/timer/##X/fire() {..() /*just so it shows up on the profiler*/} \
/datum/controller/subsystem/timer/##X

/**
* Defines a processing subsystem.
*/
#define PROCESSING_SUBSYSTEM_DEF(X) GLOBAL_REAL(SS##X, /datum/controller/subsystem/processing/##X);\
/datum/controller/subsystem/processing/##X/New(){\
NEW_SS_GLOBAL(SS##X);\
NEW_SS_GLOBAL(SS##X);\
}\
/datum/controller/subsystem/processing/##X/fire() {..() /*just so it shows up on the profiler*/} \
/datum/controller/subsystem/processing/##X

//* Subsystem flags *//
Expand Down
4 changes: 4 additions & 0 deletions code/__DEFINES/fonts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@
/// Emoji icon set
#define EMOJI_SET 'icons/ui_icons/emoji/emoji.dmi'
#define EMOJI32_SET 'icons/ui_icons/emoji/emoji32.dmi'

// Font metrics bitfield
/// Include leading A width and trailing C width in GetWidth() or in DrawText()
#define INCLUDE_AC (1<<0)
11 changes: 11 additions & 0 deletions code/__DEFINES/machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,14 @@ if (!(DATUM.datum_flags & DF_ISPROCESSING)) {\
#define ORION_GAMER_PAMPHLET -1
//game begins to have a chance to warn sec and med
#define ORION_GAMER_REPORT_THRESHOLD 2

/// Blank Status Display
#define SD_BLANK 0
/// Shows the emergency shuttle timer
#define SD_EMERGENCY 1
/// Shows an arbitrary message, user-set
#define SD_MESSAGE 2
/// Shows an alert picture (e.g. red alert, radiation, etc.)
#define SD_PICTURE 3
/// Shows the current station time
#define SD_TIME 4
60 changes: 52 additions & 8 deletions code/__DEFINES/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,58 @@

/// Removes characters incompatible with file names.
#define SANITIZE_FILENAME(text) (GLOB.filename_forbidden_chars.Replace(text, ""))

//! Maptext
/// Standard maptext
/// Prepares a text to be used for maptext. Use this so it doesn't look hideous.
#define MAPTEXT(text) {"<span class='maptext'>[##text]</span>"}
/// Prepares a text to be used for maptext. Use this so it doesn't look hideous.
#define MAPTEXT_CENTER(text) {"<span class='maptext center'>[##text]</span>"}

/**
* 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("<span style='font-size: 24pt'>Some large maptext here</span>")
*/
/// Large size (ie: context tooltips) - Size options: 12pt 24pt.
#define MAPTEXT_PIXELLARI(text) {"<span style='font-family: \"Pixellari\"; font-size: 12pt; -dm-text-outline: 1px black'>[##text]</span>"}

/// Standard size (ie: normal runechat) - Size options: 6pt 12pt 18pt.
#define MAPTEXT_GRAND9K(text) {"<span style='font-family: \"Grand9K Pixel\"; font-size: 6pt; -dm-text-outline: 1px black'>[##text]</span>"}

/// Small size. (ie: context subtooltips, spell delays) - Size options: 12pt 24pt.
#define MAPTEXT_TINY_UNICODE(text) {"<span style='font-family: \"TinyUnicode\"; font-size: 12pt; line-height: 0.75; -dm-text-outline: 1px black'>[##text]</span>"}

/// Smallest size. (ie: whisper runechat) - Size options: 6pt 12pt 18pt.
#define MAPTEXT_SPESSFONT(text) {"<span style='font-family: \"Spess Font\"; font-size: 6pt; line-height: 1.4; -dm-text-outline: 1px black'>[##text]</span>"}

/**
* 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("<span style='font-size: 24pt'>Some large maptext here</span>")
*/
/// 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) {"<span style='font-family: \"VCR OSD Mono\"'>[##text]</span>"}

/// 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);

/*
/// 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), ""))
Expand Down Expand Up @@ -54,11 +106,3 @@
/// File location for cult shuttle curse descriptions
#define CULT_SHUTTLE_CURSE "cult_shuttle_curse.json"
*/

//! Maptext
/// Prepares a text to be used for maptext. Use this so it doesn't look hideous.
#define MAPTEXT(text) {"<span class='maptext'>[##text]</span>"}
/// Prepares a text to be used for maptext. Use this so it doesn't look hideous.
#define MAPTEXT_CENTER(text) {"<span class='maptext center'>[##text]</span>"}
/// Macro from Lummox used to get height from a MeasureText proc
#define WXH_TO_HEIGHT(x) text2num(copytext(x, findtextEx(x, "x") + 1))
48 changes: 48 additions & 0 deletions code/__HELPERS/colors.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

/**
* Gets a color for a name, will return the same color for a given string consistently within a round.atom
*
* Note that this proc aims to produce pastel-ish colors using the HSL colorspace. These seem to be favorable for displaying on the map.
*
* Arguments:
* * name - The name to generate a color for
* * sat_shift - A value between 0 and 1 that will be multiplied against the saturation
* * lum_shift - A value between 0 and 1 that will be multiplied against the luminescence
*/
/proc/colorize_string(name, sat_shift = 1, lum_shift = 1)
// seed to help randomness
var/static/rseed = rand(1,26)

// get hsl using the selected 6 characters of the md5 hash
var/hash = copytext(md5(name + GLOB.round_id), rseed, rseed + 6)
var/h = hex2num(copytext(hash, 1, 3)) * (360 / 255)
var/s = (hex2num(copytext(hash, 3, 5)) >> 2) * ((CM_COLOR_SAT_MAX - CM_COLOR_SAT_MIN) / 63) + CM_COLOR_SAT_MIN
var/l = (hex2num(copytext(hash, 5, 7)) >> 2) * ((CM_COLOR_LUM_MAX - CM_COLOR_LUM_MIN) / 63) + CM_COLOR_LUM_MIN

// adjust for shifts
s = clamp(s * sat_shift, 0, 1)
l = clamp(l * lum_shift, 0, 1)

// convert to rgb
var/h_int = round(h/60) // mapping each section of H to 60 degree sections
var/c = (1 - abs(2 * l - 1)) * s
var/x = c * (1 - abs((h / 60) % 2 - 1))
var/m = l - c * 0.5
x = (x + m) * 255
c = (c + m) * 255
m *= 255
switch(h_int)
if(0)
return "#[num2hex(c, 2)][num2hex(x, 2)][num2hex(m, 2)]"
if(1)
return "#[num2hex(x, 2)][num2hex(c, 2)][num2hex(m, 2)]"
if(2)
return "#[num2hex(m, 2)][num2hex(c, 2)][num2hex(x, 2)]"
if(3)
return "#[num2hex(m, 2)][num2hex(x, 2)][num2hex(c, 2)]"
if(4)
return "#[num2hex(x, 2)][num2hex(m, 2)][num2hex(c, 2)]"
if(5)
return "#[num2hex(c, 2)][num2hex(m, 2)][num2hex(x, 2)]"

#define RANDOM_COLOUR (rgb(rand(0,255),rand(0,255),rand(0,255)))
2 changes: 1 addition & 1 deletion code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ ColorTone(rgb, tone)
letter = lowertext(letter)

var/image/text_image = new(loc = A)
text_image.maptext = "<font size = 4>[letter]</font>"
text_image.maptext = MAPTEXT("<span style='font-size: 24pt'>[letter]</span>")
text_image.pixel_x = 7
text_image.pixel_y = 5
qdel(atom_icon)
Expand Down
14 changes: 14 additions & 0 deletions code/controllers/subsystem/runechat.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
TIMER_SUBSYSTEM_DEF(runechat)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lohikar will remember this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runechat uses its own timer for qdel callback

name = "Runechat"
priority = FIRE_PRIORITY_RUNECHAT

var/list/datum/callback/message_queue = list()

/datum/controller/subsystem/timer/runechat/fire(resumed)
. = ..() //poggers
while(message_queue.len)
var/datum/callback/queued_message = message_queue[message_queue.len]
queued_message.Invoke()
message_queue.len--
if(MC_TICK_CHECK)
return
Loading
Loading