Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
MosleyTheMalO committed Jul 20, 2023
2 parents c2ce7b8 + 20fb33b commit 650642d
Show file tree
Hide file tree
Showing 26 changed files with 1,428 additions and 203 deletions.
7 changes: 7 additions & 0 deletions code/__DEFINES/fonts.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Font metrics bitfield
/// Include leading A width and trailing C width in GetWidth() or in DrawText()
#define INCLUDE_AC (1<<0)

DEFINE_BITFIELD(font_flags, list(
"INCLUDE_AC" = INCLUDE_AC,
))
30 changes: 0 additions & 30 deletions code/__HELPERS/screentips.dm

This file was deleted.

40 changes: 40 additions & 0 deletions code/datums/screentips/screentips.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#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

/*
* # Builds context with each intent for this key
* Args:
* - context = list (REQUIRED)
* - context[key] = list (REQUIRED)
* - key = string (REQUIRED)
* - allow_image = boolean (not required)
*/
/proc/build_context(list/context, key, allow_image)
if(!(length(context) && length(context[key]) && key))
return ""
var/list/to_add
for(var/intent in context[key])
// 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+intent
var/button = "[copytext(key, -3)]-[intent]"
if(allow_image)
// Compile into image, if allowed
button = "\icon[GLOB.screentip_context_icons[button]]"
LAZYADD(to_add, "[key_combo][button][allow_image ? "" : ":"] [context[key][intent]]")

// Prepare separator for same button but different intent
var/separator = "[allow_image ? " " : " / "]"

// Voilá, final result
return to_add.Join(separator)

#undef HINT_ICON_FILE
183 changes: 91 additions & 92 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1471,99 +1471,98 @@
//Update the screentip to reflect what we're hoverin over
/atom/MouseEntered(location, control, params)
. = ..()
// Screentips

var/mob/user = usr
if(isnull(user) && !user.client)
if(isnull(user))
return
if(!GET_CLIENT(user))
return

// Screentips
var/datum/hud/active_hud = user.hud_used
if(active_hud)
var/screentips_enabled = user.client.prefs.screentip_pref
if(screentips_enabled == SCREENTIP_PREFERENCE_DISABLED || (flags_1 & NO_SCREENTIPS_1))
active_hud.screentip_text.maptext = ""
else
active_hud.screentip_text.maptext_y = 0
var/lmb_rmb_line = ""
var/ctrl_lmb_ctrl_rmb_line = ""
var/alt_lmb_alt_rmb_line = ""
var/shift_lmb_ctrl_shift_lmb_line = ""
var/extra_lines = 0
var/extra_context = ""

if ((isliving(user) || isovermind(user) || isaicamera(user)) && (user.client.prefs.screentip_pref != SCREENTIP_PREFERENCE_NO_CONTEXT))
var/obj/item/held_item = user.get_active_held_item()
var/allow_images = user.client.prefs.screentip_allow_images

if (flags_1 & HAS_CONTEXTUAL_SCREENTIPS_1 || held_item?.item_flags & ITEM_HAS_CONTEXTUAL_SCREENTIPS)
var/list/context = list()

var/contextual_screentip_returns = \
SEND_SIGNAL(src, COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM, context, held_item, user) \
| (held_item && SEND_SIGNAL(held_item, COMSIG_ITEM_REQUESTING_CONTEXT_FOR_TARGET, context, src, user))

if (contextual_screentip_returns & CONTEXTUAL_SCREENTIP_SET)
// LMB and RMB on one line...
var/lmb_text = ""
if((SCREENTIP_CONTEXT_LMB in context) && (length(context[SCREENTIP_CONTEXT_LMB]) > 0))
lmb_text = build_context(context, SCREENTIP_CONTEXT_LMB, allow_images)
var/rmb_text = ""
if((SCREENTIP_CONTEXT_RMB in context) && (length(context[SCREENTIP_CONTEXT_RMB]) > 0))
rmb_text = build_context(context, SCREENTIP_CONTEXT_RMB, allow_images)

if (lmb_text)
lmb_rmb_line = lmb_text
if (rmb_text)
lmb_rmb_line += " | [allow_images ? " " : ""][rmb_text]"
else if (rmb_text)
lmb_rmb_line = rmb_text

// Ctrl-LMB, Ctrl-RMB on one line...
if (lmb_rmb_line != "")
lmb_rmb_line += "<br>"
extra_lines++
if((SCREENTIP_CONTEXT_CTRL_LMB in context) && (length(context[SCREENTIP_CONTEXT_CTRL_LMB]) > 0))
ctrl_lmb_ctrl_rmb_line = build_context(context, SCREENTIP_CONTEXT_CTRL_LMB, allow_images)

if((SCREENTIP_CONTEXT_CTRL_RMB in context) && (length(context[SCREENTIP_CONTEXT_CTRL_RMB]) > 0))
if (ctrl_lmb_ctrl_rmb_line != "")
ctrl_lmb_ctrl_rmb_line += " | [allow_images ? " " : ""]"
ctrl_lmb_ctrl_rmb_line += "[SCREENTIP_CONTEXT_CTRL_RMB]: [context[SCREENTIP_CONTEXT_CTRL_RMB]]"
ctrl_lmb_ctrl_rmb_line = build_context(context, SCREENTIP_CONTEXT_CTRL_RMB, allow_images)

// Alt-LMB, Alt-RMB on one line...
if (ctrl_lmb_ctrl_rmb_line != "")
ctrl_lmb_ctrl_rmb_line += "<br>"
extra_lines++
if((SCREENTIP_CONTEXT_ALT_LMB in context) && (length(context[SCREENTIP_CONTEXT_ALT_LMB]) > 0))
alt_lmb_alt_rmb_line = build_context(context, SCREENTIP_CONTEXT_ALT_LMB, allow_images)
if((SCREENTIP_CONTEXT_ALT_RMB in context) && (length(context[SCREENTIP_CONTEXT_ALT_RMB]) > 0))
if (alt_lmb_alt_rmb_line != "")
alt_lmb_alt_rmb_line += " | [allow_images ? " " : ""]"
alt_lmb_alt_rmb_line = build_context(context, SCREENTIP_CONTEXT_ALT_RMB, allow_images)

// Shift-LMB, Ctrl-Shift-LMB on one line...
if (alt_lmb_alt_rmb_line != "")
alt_lmb_alt_rmb_line += "<br>"
extra_lines++
if((SCREENTIP_CONTEXT_SHIFT_LMB in context) && (length(context[SCREENTIP_CONTEXT_SHIFT_LMB]) > 0))
shift_lmb_ctrl_shift_lmb_line = build_context(context, SCREENTIP_CONTEXT_SHIFT_LMB, allow_images)

if((SCREENTIP_CONTEXT_CTRL_SHIFT_LMB in context) && (length(context[SCREENTIP_CONTEXT_CTRL_SHIFT_LMB]) > 0))
if (shift_lmb_ctrl_shift_lmb_line != "")
shift_lmb_ctrl_shift_lmb_line += " | [allow_images ? " " : ""]"
shift_lmb_ctrl_shift_lmb_line += "[SCREENTIP_CONTEXT_CTRL_SHIFT_LMB]: [context[SCREENTIP_CONTEXT_CTRL_SHIFT_LMB]]"
shift_lmb_ctrl_shift_lmb_line = build_context(context, SCREENTIP_CONTEXT_CTRL_SHIFT_LMB, allow_images)

if (shift_lmb_ctrl_shift_lmb_line != "")
extra_lines++

if(extra_lines)
extra_context = "<br><span style='font-size: 7px'>[lmb_rmb_line][ctrl_lmb_ctrl_rmb_line][alt_lmb_alt_rmb_line][shift_lmb_ctrl_shift_lmb_line]</span>"
//first extra line pushes atom name line up 10px, subsequent lines push it up 9px, this offsets that and keeps the first line in the same place
active_hud.screentip_text.maptext_y = -10 + (extra_lines - 1) * -9

if (screentips_enabled == SCREENTIP_PREFERENCE_CONTEXT_ONLY && extra_context == "")
active_hud.screentip_text.maptext = ""
else
//We inline a MAPTEXT() here, because there's no good way to statically add to a string like this
active_hud.screentip_text.maptext = "<span class='maptext' style='text-align: center; font-size: 32px; color: [user.client.prefs.screentip_color]'>[name][extra_context]</span>"
if(!active_hud)
return

var/screentips_enabled = user.client.prefs.screentip_pref
if(screentips_enabled == SCREENTIP_PREFERENCE_DISABLED || (flags_1 & NO_SCREENTIPS_1))
active_hud.screentip_text.maptext = ""
return

active_hud.screentip_text.maptext_y = 10 // 10px lines us up with the action buttons top left corner
var/lmb_rmb_line = ""
var/ctrl_lmb_ctrl_rmb_line = ""
var/alt_lmb_alt_rmb_line = ""
var/shift_lmb_ctrl_shift_lmb_line = ""
var/extra_lines = 0
var/extra_context = ""

if ((isliving(user) || isovermind(user) || isaicamera(user)) && (user.client.prefs.screentip_pref != SCREENTIP_PREFERENCE_NO_CONTEXT))
var/obj/item/held_item = user.get_active_held_item()

if (flags_1 & HAS_CONTEXTUAL_SCREENTIPS_1 || held_item?.item_flags & ITEM_HAS_CONTEXTUAL_SCREENTIPS)
var/list/context = list()

var/contextual_screentip_returns = \
SEND_SIGNAL(src, COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM, context, held_item, user) \
| (held_item && SEND_SIGNAL(held_item, COMSIG_ITEM_REQUESTING_CONTEXT_FOR_TARGET, context, src, user))

if (contextual_screentip_returns & CONTEXTUAL_SCREENTIP_SET)
var/screentip_images = user.client.prefs.screentip_images
// LMB and RMB on one line...
var/lmb_text = build_context(context, SCREENTIP_CONTEXT_LMB, screentip_images)
var/rmb_text = build_context(context, SCREENTIP_CONTEXT_RMB, screentip_images)

if (lmb_text != "")
lmb_rmb_line = lmb_text
if (rmb_text != "")
lmb_rmb_line += " | [rmb_text]"
else if (rmb_text != "")
lmb_rmb_line = rmb_text

// Ctrl-LMB, Ctrl-RMB on one line...
if (lmb_rmb_line != "")
lmb_rmb_line += "<br>"
extra_lines++
if (SCREENTIP_CONTEXT_CTRL_LMB in context)
ctrl_lmb_ctrl_rmb_line += build_context(context, SCREENTIP_CONTEXT_CTRL_LMB, screentip_images)

if (SCREENTIP_CONTEXT_CTRL_RMB in context)
if (ctrl_lmb_ctrl_rmb_line != "")
ctrl_lmb_ctrl_rmb_line += " | "
ctrl_lmb_ctrl_rmb_line += build_context(context, SCREENTIP_CONTEXT_CTRL_RMB, screentip_images)

// Alt-LMB, Alt-RMB on one line...
if (ctrl_lmb_ctrl_rmb_line != "")
ctrl_lmb_ctrl_rmb_line += "<br>"
extra_lines++
if (SCREENTIP_CONTEXT_ALT_LMB in context)
alt_lmb_alt_rmb_line += build_context(context, SCREENTIP_CONTEXT_ALT_LMB, screentip_images)
if (SCREENTIP_CONTEXT_ALT_RMB in context)
if (alt_lmb_alt_rmb_line != "")
alt_lmb_alt_rmb_line += " | "
alt_lmb_alt_rmb_line += build_context(context, SCREENTIP_CONTEXT_ALT_RMB, screentip_images)

// Shift-LMB, Ctrl-Shift-LMB on one line...
if (alt_lmb_alt_rmb_line != "")
alt_lmb_alt_rmb_line += "<br>"
extra_lines++
if (SCREENTIP_CONTEXT_SHIFT_LMB in context)
shift_lmb_ctrl_shift_lmb_line += build_context(context, SCREENTIP_CONTEXT_SHIFT_LMB, screentip_images)
if (SCREENTIP_CONTEXT_CTRL_SHIFT_LMB in context)
if (shift_lmb_ctrl_shift_lmb_line != "")
shift_lmb_ctrl_shift_lmb_line += " | "
shift_lmb_ctrl_shift_lmb_line += build_context(context, SCREENTIP_CONTEXT_CTRL_SHIFT_LMB, screentip_images)

if (shift_lmb_ctrl_shift_lmb_line != "")
extra_lines++

if(extra_lines)
extra_context = "<br><span class='subcontext'>[lmb_rmb_line][ctrl_lmb_ctrl_rmb_line][alt_lmb_alt_rmb_line][shift_lmb_ctrl_shift_lmb_line]</span>"
//first extra line pushes atom name line up 10px, subsequent lines push it up 9px, this offsets that and keeps the first line in the same place
active_hud.screentip_text.maptext_y = -1 + (extra_lines - 1) * -9

if (screentips_enabled == SCREENTIP_PREFERENCE_CONTEXT_ONLY && extra_context == "")
active_hud.screentip_text.maptext = ""
else
//We inline a MAPTEXT() here, because there's no good way to statically add to a string like this
active_hud.screentip_text.maptext = "<span class='context' style='text-align: center; color: [user.client.prefs.screentip_color]'>[name][extra_context]</span>"
8 changes: 4 additions & 4 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/outline_color = COLOR_THEME_MIDNIGHT
var/screentip_pref = SCREENTIP_PREFERENCE_ENABLED
var/screentip_color = "#ffd391"
var/screentip_allow_images = FALSE
var/screentip_images = TRUE
var/buttons_locked = FALSE
var/hotkeys = FALSE

Expand Down Expand Up @@ -1278,7 +1278,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
dat += "<b>Screentip Color:</b> <span style='border:1px solid #161616; background-color: [screentip_color];'><font color='[color_hex2num(screentip_color) < 200 ? "FFFFFF" : "000000"]'>[screentip_color]</font></span> <a href='?_src_=prefs;preference=screentip_color'>Change</a><BR>"
dat += "<font style='border-bottom:2px dotted white; cursor:help;'\
title=\"This is an accessibility preference, if disabled, fallbacks to only text which colorblind people can understand better\">\
<b>Screentip context with images:</b></font> <a href='?_src_=prefs;preference=screentip_allow_images'>[screentip_allow_images ? "Allowed" : "Disallowed"]</a><br>"
<b>Screentip context with images:</b></font> <a href='?_src_=prefs;preference=screentip_images'>[screentip_images ? "Allowed" : "Disallowed"]</a><br>"
dat += "<b>tgui Monitors:</b> <a href='?_src_=prefs;preference=tgui_lock'>[(tgui_lock) ? "Primary" : "All"]</a><br>"
dat += "<b>tgui Style:</b> <a href='?_src_=prefs;preference=tgui_fancy'>[(tgui_fancy) ? "Fancy" : "No Frills"]</a><br>"
dat += "<b>Show Runechat Chat Bubbles:</b> <a href='?_src_=prefs;preference=chat_on_map'>[chat_on_map ? "Enabled" : "Disabled"]</a><br>"
Expand Down Expand Up @@ -3654,8 +3654,8 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/pickedScreentipColor = input(user, "Choose your screentip color.", "General Preference", screentip_color) as color|null
if(pickedScreentipColor)
screentip_color = pickedScreentipColor
if("screentip_allow_images")
screentip_allow_images = !screentip_allow_images
if("screentip_images")
screentip_images = !screentip_images
if("tgui_lock")
tgui_lock = !tgui_lock
if("winflash")
Expand Down
11 changes: 8 additions & 3 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// You do not need to raise this if you are adding new values that have sane defaults.
// Only raise this value when changing the meaning/format/name/layout of an existing value
// where you would want the updater procs below to run
#define SAVEFILE_VERSION_MAX 57.01
#define SAVEFILE_VERSION_MAX 58

/*
SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn
Expand Down Expand Up @@ -382,6 +382,11 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
else
S["all_quirks"] = list("Dullahan")

// So, we're already on 57 even though we were meant to be on like, 56? i'm gonna try to correct this,
// And i'm so sorry for this.
if(current_version < 58)
S["screentip_images"] = TRUE // This was meant to default active, i'm so sorry. Turn it off if you must.

/datum/preferences/proc/load_path(ckey,filename="preferences.sav")
if(!ckey)
return
Expand Down Expand Up @@ -423,7 +428,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
S["outline_enabled"] >> outline_enabled
S["screentip_pref"] >> screentip_pref
S["screentip_color"] >> screentip_color
S["screentip_allow_images"] >> screentip_allow_images
S["screentip_images"] >> screentip_images
S["hotkeys"] >> hotkeys
S["chat_on_map"] >> chat_on_map
S["max_chat_length"] >> max_chat_length
Expand Down Expand Up @@ -639,7 +644,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
WRITE_FILE(S["outline_color"], outline_color)
WRITE_FILE(S["screentip_pref"], screentip_pref)
WRITE_FILE(S["screentip_color"], screentip_color)
WRITE_FILE(S["screentip_allow_images"], screentip_allow_images)
WRITE_FILE(S["screentip_images"], screentip_images)
WRITE_FILE(S["hotkeys"], hotkeys)
WRITE_FILE(S["chat_on_map"], chat_on_map)
WRITE_FILE(S["max_chat_length"], max_chat_length)
Expand Down
3 changes: 3 additions & 0 deletions html/changelogs/archive/2023-07.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@
Vhariik:
- rscadd: Layenia Station and it's contents (walls, floors and decals)
- tweak: Fixed firing pins
2023-07-19:
SandPoot:
- rscadd: You can milk other people using the interaction menu.
Binary file added interface/fonts/Grand9K_Pixel.ttf
Binary file not shown.
Binary file added interface/fonts/Pixellari.ttf
Binary file not shown.
Binary file added interface/fonts/SpessFont.ttf
Binary file not shown.
Binary file added interface/fonts/TinyUnicode.ttf
Binary file not shown.
Binary file added interface/fonts/VCR_OSD_Mono.ttf
Binary file not shown.
Loading

0 comments on commit 650642d

Please sign in to comment.