From e8a7bd566fee459831fe9b2a261e66a54eb0dd03 Mon Sep 17 00:00:00 2001 From: Qustinnus Date: Wed, 17 Feb 2021 03:57:34 +0100 Subject: [PATCH] Hovering your mouse over things now shows their name on the top of the screen (#56729) Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> --- code/__DEFINES/flags.dm | 2 ++ code/__DEFINES/preferences.dm | 6 ++++++ code/_onclick/hud/hud.dm | 8 ++++++++ code/_onclick/hud/screentip.dm | 21 +++++++++++++++++++++ code/game/atoms.dm | 8 ++++++++ code/game/objects/items.dm | 1 + code/game/turfs/open/floor.dm | 1 + code/game/turfs/open/openspace.dm | 2 +- code/modules/client/client_procs.dm | 1 + code/modules/client/preferences.dm | 17 +++++++++++++++++ code/modules/client/preferences_savefile.dm | 10 ++++++++-- tgstation.dme | 1 + 12 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 code/_onclick/hud/screentip.dm diff --git a/code/__DEFINES/flags.dm b/code/__DEFINES/flags.dm index 2cb7e78c862..aece8199dc7 100644 --- a/code/__DEFINES/flags.dm +++ b/code/__DEFINES/flags.dm @@ -35,6 +35,8 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204 #define OVERLAY_QUEUED_1 (1<<8) /// item has priority to check when entering or leaving #define ON_BORDER_1 (1<<9) +///Whether or not this atom shows screentips when hovered over +#define NO_SCREENTIPS_1 (1 << 10) /// Prevent clicking things below it on the same turf eg. doors/ fulltile windows #define PREVENT_CLICK_UNDER_1 (1<<11) #define HOLOGRAM_1 (1<<12) diff --git a/code/__DEFINES/preferences.dm b/code/__DEFINES/preferences.dm index e4218e149c4..2c389806567 100644 --- a/code/__DEFINES/preferences.dm +++ b/code/__DEFINES/preferences.dm @@ -86,6 +86,12 @@ #define EXP_TYPE_GHOST "Ghost" #define EXP_TYPE_ADMIN "Admin" +///Screentip settings +#define SCREENTIP_OFF 0 +#define SCREENTIP_SMALL 1 +#define SCREENTIP_MEDIUM 1 +#define SCREENTIP_BIG 1 + //Flags in the players table in the db #define DB_FLAG_EXEMPT 1 diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index 50a2e1e042d..0afa9538cc9 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -55,6 +55,9 @@ GLOBAL_LIST_INIT(available_ui_styles, list( var/list/atom/movable/plane_master_controller/plane_master_controllers = list() + ///UI for screentips that appear when you mouse over things + var/atom/movable/screen/screentip/screentip_text + var/atom/movable/screen/movable/action_button/hide_toggle/hide_actions_toggle var/action_buttons_hidden = FALSE @@ -85,6 +88,9 @@ GLOBAL_LIST_INIT(available_ui_styles, list( plane_masters["[instance.plane]"] = instance instance.backdrop(mymob) + screentip_text = new(null, src) + static_inventory += screentip_text + for(var/mytype in subtypesof(/atom/movable/plane_master_controller)) var/atom/movable/plane_master_controller/controller_instance = new mytype(src) plane_master_controllers[controller_instance.name] = controller_instance @@ -126,6 +132,8 @@ GLOBAL_LIST_INIT(available_ui_styles, list( QDEL_LIST(screenoverlays) mymob = null + QDEL_NULL(screentip_text) + return ..() /mob/proc/create_mob_hud() diff --git a/code/_onclick/hud/screentip.dm b/code/_onclick/hud/screentip.dm new file mode 100644 index 00000000000..36159ec0086 --- /dev/null +++ b/code/_onclick/hud/screentip.dm @@ -0,0 +1,21 @@ +/atom/movable/screen/screentip + icon = null + icon_state = null + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + screen_loc = "TOP,LEFT" + maptext_height = 480 + maptext_width = 480 + maptext = "" + +/atom/movable/screen/screentip/Initialize(mapload, _hud) + . = ..() + hud = _hud + update_view() + +/atom/movable/screen/screentip/proc/update_view(datum/source) + SIGNAL_HANDLER + if(!hud || !hud.mymob.client.view_size) //Might not have been initialized by now + return + maptext_width = getviewsize(hud.mymob.client.view_size.getView())[1] * world.icon_size + + diff --git a/code/game/atoms.dm b/code/game/atoms.dm index b02fa3c5ce4..6fe26231bdb 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -1872,3 +1872,11 @@ animate(visual, pixel_x = (tile.x - our_tile.x) * world.icon_size + A.pixel_x, pixel_y = (tile.y - our_tile.y) * world.icon_size + A.pixel_y, time = 1.7, easing = EASE_OUT) return TRUE + +//Update the screentip to reflect what we're hoverin over +/atom/MouseEntered(location, control, params) + . = ..() + if(flags_1 & NO_SCREENTIPS_1 || !usr?.client?.prefs.screentip_pref) + usr.hud_used.screentip_text.maptext = "" + return + usr.hud_used.screentip_text.maptext = MAPTEXT("[name]") diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index d00864b50fd..971baf75824 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -824,6 +824,7 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb openToolTip(user,src,params,title = name,content = "[desc]
Force: [force_string]",theme = "") /obj/item/MouseEntered(location, control, params) + . = ..() if((item_flags & IN_INVENTORY || item_flags & IN_STORAGE) && usr.client.prefs.enable_tips && !QDELETED(src)) var/timedelay = usr.client.prefs.tip_delay/100 var/user = usr diff --git a/code/game/turfs/open/floor.dm b/code/game/turfs/open/floor.dm index 17c24b35350..158f222806e 100644 --- a/code/game/turfs/open/floor.dm +++ b/code/game/turfs/open/floor.dm @@ -11,6 +11,7 @@ barefootstep = FOOTSTEP_HARD_BAREFOOT clawfootstep = FOOTSTEP_HARD_CLAW heavyfootstep = FOOTSTEP_GENERIC_HEAVY + flags_1 = CAN_BE_DIRTY_1 | NO_SCREENTIPS_1 smoothing_groups = list(SMOOTH_GROUP_TURF_OPEN, SMOOTH_GROUP_OPEN_FLOOR) canSmoothWith = list(SMOOTH_GROUP_OPEN_FLOOR, SMOOTH_GROUP_TURF_OPEN) diff --git a/code/game/turfs/open/openspace.dm b/code/game/turfs/open/openspace.dm index 3d7620a76bc..1d52fee6a95 100644 --- a/code/game/turfs/open/openspace.dm +++ b/code/game/turfs/open/openspace.dm @@ -21,7 +21,7 @@ GLOBAL_DATUM_INIT(openspace_backdrop_one_for_all, /atom/movable/openspace_backdr CanAtmosPassVertical = ATMOS_PASS_YES baseturfs = /turf/open/openspace intact = FALSE //this means wires go on top - //mouse_opacity = MOUSE_OPACITY_TRANSPARENT + mouse_opacity = MOUSE_OPACITY_TRANSPARENT var/can_cover_up = TRUE var/can_build_on = TRUE diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index d00149d93f4..eb4dab29fb7 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -972,6 +972,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( CRASH("change_view called without argument.") view = new_size + mob.hud_used.screentip_text.update_view() apply_clickcatcher() mob.reload_fullscreen() if (isliving(mob)) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 53b7eeff771..d83fb54d5ce 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -108,6 +108,11 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/parallax + ///Do we show screentips, if so, how big? + var/screentip_pref = TRUE + ///Color of screentips at top of screen + var/screentip_color = "#ffd391" + var/ambientocclusion = TRUE ///Should we automatically fit the viewport? var/auto_fit_viewport = FALSE @@ -635,6 +640,10 @@ GLOBAL_LIST_EMPTY(preferences_datums) dat += "High" dat += "
" + dat += "Set screentip mode: [screentip_pref ? "Enabled" : "Disabled"]
" + dat += "Screentip color:    Change
" + + dat += "Ambient Occlusion: [ambientocclusion ? "Enabled" : "Disabled"]
" dat += "Fit Viewport: [auto_fit_viewport ? "Auto" : "Manual"]
" if (CONFIG_GET(string/default_view) != CONFIG_GET(string/default_view_square)) @@ -1826,6 +1835,14 @@ GLOBAL_LIST_EMPTY(preferences_datums) if (parent && parent.mob && parent.mob.hud_used) parent.mob.hud_used.update_parallax_pref(parent.mob) + if("screentipmode") + screentip_pref = !screentip_pref + + if("screentipcolor") + var/new_screentipcolor = input(user, "Choose your screentip color:", "Character Preference", screentip_color) as color|null + if(new_screentipcolor) + screentip_color = sanitize_ooccolor(new_screentipcolor) + if("ambientocclusion") ambientocclusion = !ambientocclusion if(parent?.screen && parent.screen.len) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index af884cdd31b..22bae9318ec 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -161,6 +161,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car READ_FILE(S["asaycolor"], asaycolor) READ_FILE(S["brief_outfit"], brief_outfit) READ_FILE(S["ooccolor"], ooccolor) + READ_FILE(S["screentip_color"], screentip_color) READ_FILE(S["lastchangelog"], lastchangelog) READ_FILE(S["UI_style"], UI_style) READ_FILE(S["hotkeys"], hotkeys) @@ -192,6 +193,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car READ_FILE(S["clientfps"], clientfps) READ_FILE(S["parallax"], parallax) READ_FILE(S["ambientocclusion"], ambientocclusion) + READ_FILE(S["screentip_pref"], screentip_pref) READ_FILE(S["auto_fit_viewport"], auto_fit_viewport) READ_FILE(S["widescreenpref"], widescreenpref) READ_FILE(S["pixel_size"], pixel_size) @@ -223,6 +225,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car //Sanitize asaycolor = sanitize_ooccolor(sanitize_hexcolor(asaycolor, 6, 1, initial(asaycolor))) ooccolor = sanitize_ooccolor(sanitize_hexcolor(ooccolor, 6, 1, initial(ooccolor))) + screentip_color = sanitize_ooccolor(sanitize_hexcolor(screentip_color, 6, 1, initial(screentip_color))) lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog)) UI_style = sanitize_inlist(UI_style, GLOB.available_ui_styles, GLOB.available_ui_styles[1]) hotkeys = sanitize_integer(hotkeys, FALSE, TRUE, initial(hotkeys)) @@ -239,8 +242,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car toggles = sanitize_integer(toggles, 0, (2**24)-1, initial(toggles)) clientfps = sanitize_integer(clientfps, -1, 1000, 0) parallax = sanitize_integer(parallax, PARALLAX_INSANE, PARALLAX_DISABLE, null) - ambientocclusion = sanitize_integer(ambientocclusion, FALSE, TRUE, initial(ambientocclusion)) - auto_fit_viewport = sanitize_integer(auto_fit_viewport, FALSE, TRUE, initial(auto_fit_viewport)) + ambientocclusion = sanitize_integer(ambientocclusion, FALSE, TRUE, initial(ambientocclusion)) + screentip_pref = sanitize_integer(screentip_pref, FALSE, TRUE, initial(screentip_pref)) + auto_fit_viewport = sanitize_integer(auto_fit_viewport, FALSE, TRUE, initial(auto_fit_viewport)) widescreenpref = sanitize_integer(widescreenpref, FALSE, TRUE, initial(widescreenpref)) pixel_size = sanitize_float(pixel_size, PIXEL_SCALING_AUTO, PIXEL_SCALING_3X, 0.5, initial(pixel_size)) scaling_method = sanitize_text(scaling_method, initial(scaling_method)) @@ -289,6 +293,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car WRITE_FILE(S["asaycolor"], asaycolor) WRITE_FILE(S["brief_outfit"], brief_outfit) WRITE_FILE(S["ooccolor"], ooccolor) + WRITE_FILE(S["screentip_color"], screentip_color) WRITE_FILE(S["lastchangelog"], lastchangelog) WRITE_FILE(S["UI_style"], UI_style) WRITE_FILE(S["hotkeys"], hotkeys) @@ -317,6 +322,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car WRITE_FILE(S["clientfps"], clientfps) WRITE_FILE(S["parallax"], parallax) WRITE_FILE(S["ambientocclusion"], ambientocclusion) + WRITE_FILE(S["screentip_pref"], screentip_pref) WRITE_FILE(S["auto_fit_viewport"], auto_fit_viewport) WRITE_FILE(S["widescreenpref"], widescreenpref) WRITE_FILE(S["pixel_size"], pixel_size) diff --git a/tgstation.dme b/tgstation.dme index eef1e3709d6..9c58f0cfca1 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -261,6 +261,7 @@ #include "code\_onclick\hud\revenanthud.dm" #include "code\_onclick\hud\robot.dm" #include "code\_onclick\hud\screen_objects.dm" +#include "code\_onclick\hud\screentip.dm" #include "code\_onclick\hud\swarmer.dm" #include "code\controllers\admin.dm" #include "code\controllers\controller.dm"