Files
Bubberstation/code/datums/screentips/screentips.dm
SkyratBot 6fb6f553bb [MIRROR] Screentip images [MDB IGNORE] (#22899)
* Screentip images (#76889)

## About The Pull Request
Adds some nice little mouse button indicators (optional), this is a port
of my version at
[Citadel-Station-13/15973](https://github.com/Citadel-Station-13/Citadel-Station-13/pull/15973).

**There is no more intent coloring**

## Why It's Good For The Game
Quick identification of what to do. Eh, i dunno if it's getting
accepted, mothblocks asked me to port it over.
## Changelog
🆑
image: Changed screentips icons to something a lot fancier unified with
the LMB / RMB text.
qol: There are accessibility preferences to disable this! Look for
"Screentip context with images" beside the other screentip preferences.
/🆑

---------

Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@ users.noreply.github.com>

* Screentip images

---------

Co-authored-by: SandPoot <43283559+SandPoot@users.noreply.github.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@ users.noreply.github.com>
2023-08-06 02:58:10 -04:00

35 lines
1.2 KiB
Plaintext

#define HINT_ICON_FILE 'icons/ui_icons/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