Files
Bubberstation/code/datums/screentips/screentips.dm
YesterdaysPromise 8eb3b51ad9 /icons/ folder cleansing crusade part 3 (#83420)
## About The Pull Request

In my effort to make the /icons/ folder cleaner and more intuitive
instead of having to rely on recalling names of stuff and looking them
up in code to find them for poor sods such as myself, plus in spurt of
complusion to organize stuff, here goes. I've tracked all changes in
commit descriptions. A lot still to be done, but I know these waves go
over dozens of files making things slow, so went lighter on it.
Destroyed useless impostor files taking up space and cleaned a stray
pixel on my way.

## Why It's Good For The Game

Cleaner /icons/ file means saner spriters, less time spent. Stray pixels
and impostor files (ones which are copies of actually used ones
elsewhere) are not good.

## Changelog

🆑
image: Cleaned a single stray pixel in a single frame of a bite
telegraphing accidentaly found while re-organizing the files.
/🆑
2024-05-25 21:08:08 -07:00

35 lines
1.2 KiB
Plaintext

#define HINT_ICON_FILE 'icons/ui/screentips/cursor_hints.dmi'
/// Stores the cursor hint icons for screentip context.
GLOBAL_LIST_INIT_TYPED(screentip_context_icons, /image, prepare_screentip_context_icons())
/proc/prepare_screentip_context_icons()
var/list/output = list()
for(var/state in icon_states(HINT_ICON_FILE))
output[state] = image(HINT_ICON_FILE, icon_state = state)
return output
/*
* # Compiles a string for this key
* Args:
* - context = list (REQUIRED)
* - Must contain key
* - key = string (REQUIRED)
* - allow_image = boolean (not required)
*/
/proc/build_context(list/context, key, allow_image)
if(!length(context) || !context[key] || !key)
return ""
// Splits key combinations from mouse buttons. e.g. `Ctrl-Shift-LMB` goes in, `Ctrl-Shift-` goes out. Will be empty for single button actions.
var/key_combo = length(key) > 3 ? "[copytext(key, 1, -3)]" : ""
// Grab the mouse button, LMB/RMB
var/button = copytext(key, -3)
if(allow_image)
// Compile into image, if allowed
button = "\icon[GLOB.screentip_context_icons[button]]"
// Voilá, final result
return "[key_combo][button][allow_image ? "" : ":"] [context[key]]"
#undef HINT_ICON_FILE