Skip to content
This repository has been archived by the owner on Oct 15, 2023. It is now read-only.

feat (port): Screentips #161

Merged
merged 4 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions SQL/paradise_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ CREATE TABLE `player` (
`discord_name` varchar(32) NULL DEFAULT NULL,
`keybindings` longtext COLLATE 'utf8mb4_unicode_ci' DEFAULT NULL,
`viewrange` VARCHAR(5) NOT NULL DEFAULT '19x15' COLLATE 'utf8mb4_general_ci',
`screentip_mode` tinyint(1) DEFAULT '8',
`screentip_color` varchar(7) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '#ffd391',
PRIMARY KEY (`id`),
UNIQUE KEY `ckey` (`ckey`),
KEY `lastseen` (`lastseen`),
Expand Down
4 changes: 4 additions & 0 deletions SQL/updates/30-31.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Updates DB from 30 to 31 -S34N_W
# Adds support for screentips
ALTER TABLE `player` ADD COLUMN `screentip_mode` tinyint(1) DEFAULT '8';
ALTER TABLE `player` ADD COLUMN `screentip_color` varchar(7) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '#ffd391'
2 changes: 1 addition & 1 deletion _maps/map_files/generic/CentComm.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -9197,7 +9197,7 @@
},
/area/syndicate_mothership)
"eNQ" = (
/turf/simulated/wall/indestructible/splashcreen,
/turf/simulated/wall/indestructible/splashscreen,
/area/start)
"eNU" = (
/obj/structure/chair/sofa/left{
Expand Down
2 changes: 1 addition & 1 deletion _maps/map_files/generic/z2_old.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -11365,7 +11365,7 @@
/turf/simulated/wall/shuttle,
/area/shuttle/gamma/space)
"iBH" = (
/turf/simulated/wall/indestructible/splashcreen,
/turf/simulated/wall/indestructible/splashscreen,
/area/start)
"iBQ" = (
/obj/structure/table/wood,
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#define NO_PIXEL_RANDOM_DROP 131072 // If dropped, it wont have a randomized pixel_x/pixel_y

///Whether or not this atom shows screentips when hovered over
#define NO_SCREENTIPS 262144

/* Secondary atom flags, for the flags_2 var, denoted with a _2 */

Expand Down
12 changes: 11 additions & 1 deletion code/__DEFINES/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
#define EXPLOSION_BLOCK_PROC -1

// The SQL version required by this version of the code
#define SQL_VERSION 30
#define SQL_VERSION 31

// Vending machine stuff
#define CAT_NORMAL 1
Expand Down Expand Up @@ -522,3 +522,13 @@

// This isnt in client_defines due to scoping issues
#define DEFAULT_CLIENT_VIEWSIZE "19x15"

/proc/client_from_var(I)
if(ismob(I))
var/mob/A = I
return A.client
if(isclient(I))
return I
if(istype(I, /datum/mind))
var/datum/mind/B = I
return B.current.client
1 change: 1 addition & 0 deletions code/_onclick/hud/action_button.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
overlays += img

/obj/screen/movable/action_button/MouseEntered(location, control, params)
. = ..()
if(!QDELETED(src))
openToolTip(usr, src, params, title = name, content = desc, theme = actiontooltipstyle)

Expand Down
1 change: 1 addition & 0 deletions code/_onclick/hud/alert.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
var/override_alerts = FALSE //If it is overriding other alerts of the same type

/obj/screen/alert/MouseEntered(location,control,params)
. = ..()
openToolTip(usr, src, params, title = name, content = desc, theme = alerttooltipstyle)


Expand Down
1 change: 1 addition & 0 deletions code/_onclick/hud/blob_overmind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
icon = 'icons/mob/blob.dmi'

/obj/screen/blob/MouseEntered(location,control,params)
. = ..()
openToolTip(usr,src,params,title = name,content = desc, theme = "blob")

/obj/screen/blob/MouseExited()
Expand Down
1 change: 1 addition & 0 deletions code/_onclick/hud/ghost.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
icon = 'icons/mob/screen_ghost.dmi'

/obj/screen/ghost/MouseEntered()
. = ..()
flick(icon_state + "_anim", src)

/obj/screen/ghost/jumptomob
Expand Down
6 changes: 6 additions & 0 deletions code/_onclick/hud/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
var/action_buttons_hidden = FALSE

var/list/obj/screen/plane_master/plane_masters = list() // see "appearance_flags" in the ref, assoc list of "[plane]" = object
///UI for screentips that appear when you mouse over things
var/obj/screen/screentip/screentip_text

/mob/proc/create_mob_hud()
if(client && !hud_used)
Expand All @@ -58,6 +60,9 @@
plane_masters["[instance.plane]"] = instance
instance.backdrop(mymob)

screentip_text = new(null, src)
static_inventory += screentip_text

/datum/hud/Destroy()
if(mymob.hud_used == src)
mymob.hud_used = null
Expand Down Expand Up @@ -100,6 +105,7 @@
QDEL_LIST_ASSOC_VAL(plane_masters)

mymob = null
QDEL_NULL(screentip_text)
return ..()

/datum/hud/proc/show_hud(version = 0)
Expand Down
3 changes: 2 additions & 1 deletion code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
return set_selected_zone(choice, usr)

/obj/screen/zone_sel/MouseEntered(location, control, params)
. = ..()
MouseMove(location, control, params)

/obj/screen/zone_sel/MouseMove(location, control, params)
Expand Down Expand Up @@ -401,7 +402,7 @@
var/image/object_overlay

/obj/screen/inventory/MouseEntered()
..()
. = ..()
add_overlays()

/obj/screen/inventory/MouseExited()
Expand Down
17 changes: 17 additions & 0 deletions code/_onclick/hud/screentip.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/obj/screen/screentip
icon = null
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
screen_loc = "TOP,LEFT"
maptext_height = 480
maptext_width = 480
maptext = ""

/obj/screen/screentip/Initialize(mapload, _hud)
. = ..()
hud = _hud
update_view()

/obj/screen/screentip/proc/update_view(datum/source)
if(!hud) //Might not have been initialized by now
return
maptext_width = getviewsize(hud.mymob.client.view)[1] * world.icon_size
2 changes: 1 addition & 1 deletion code/controllers/subsystem/titlescreen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SUBSYSTEM_DEF(title)

var/icon/icon = new(fcopy_rsc(file_path))

for(var/turf/simulated/wall/indestructible/splashcreen/splash in world)
for(var/turf/simulated/wall/indestructible/splashscreen/splash in world)
splash.icon = icon

return ..()
16 changes: 16 additions & 0 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,22 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons)
name = "[prefix][t]"
return t

//Update the screentip to reflect what we're hovering over
/atom/MouseEntered(location, control, params)
if(!usr || !usr.client)
return
var/datum/hud/active_hud = usr.hud_used
if(!active_hud)
return
var/screentip_mode = usr.client.prefs.screentip_mode
if(screentip_mode == 0 || (flags & NO_SCREENTIPS))
active_hud.screentip_text.maptext = ""
return
//We inline a MAPTEXT() here, because there's no good way to statically add to a string like this
var/screentip_color = usr.client.prefs.screentip_color
active_hud.screentip_text.maptext = "<span class='maptext' style='font-family: sans-serif; text-align: center; font-size: [screentip_mode]px; color: [screentip_color]'>[name]</span>"


/*
Setter for the `density` variable.
Arguments:
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/g


/obj/item/MouseEntered(location, control, params)
. = ..()
if(in_inventory || in_storage)
var/timedelay = 8
var/mob/user = usr
Expand Down
1 change: 1 addition & 0 deletions code/game/turfs/simulated/floor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ GLOBAL_LIST_INIT(icons_to_ignore_at_floor_init, list("damaged1","damaged2","dama
var/icon_plating = "plating"
thermal_conductivity = 0.040
heat_capacity = 10000
flags = NO_SCREENTIPS
var/lava = 0
var/broken = 0
var/burnt = 0
Expand Down
3 changes: 2 additions & 1 deletion code/game/turfs/simulated/walls_indestructible.dm
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,12 @@
canSmoothWith = list(/turf/simulated/wall/indestructible/abductor)
smooth = SMOOTH_TRUE

/turf/simulated/wall/indestructible/splashcreen
/turf/simulated/wall/indestructible/splashscreen
name = "Space Station 13"
icon = 'config/title_screens/images/blank.png'
icon_state = ""
layer = FLY_LAYER
flags = NO_SCREENTIPS

/turf/simulated/wall/indestructible/sandstone
name = "sandstone wall"
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/space/space.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
thermal_conductivity = OPEN_HEAT_TRANSFER_COEFFICIENT
heat_capacity = HEAT_CAPACITY_VACUUM

plane = PLANE_SPACE
layer = SPACE_LAYER
light_power = 0.25
dynamic_lighting = DYNAMIC_LIGHTING_DISABLED
Expand All @@ -17,6 +16,7 @@
var/destination_x
var/destination_y
plane = PLANE_SPACE
flags = NO_SCREENTIPS
footstep = null
barefootstep = null
clawfootstep = null
Expand Down
16 changes: 8 additions & 8 deletions code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -979,9 +979,9 @@
winset(src, "rpane.forumb", "background-color=#40628a;text-color=#FFFFFF")
winset(src, "rpane.rulesb", "background-color=#40628a;text-color=#FFFFFF")
winset(src, "rpane.githubb", "background-color=#40628a;text-color=#FFFFFF")
/* Mainwindow */
winset(src, "mainwindow.saybutton", "background-color=#40628a;text-color=#FFFFFF")
winset(src, "mainwindow.mebutton", "background-color=#40628a;text-color=#FFFFFF")
/* Outputwindow */
winset(src, "outputwindow.saybutton", "background-color=#40628a;text-color=#FFFFFF")
winset(src, "outputwindow.mebutton", "background-color=#40628a;text-color=#FFFFFF")
///// UI ELEMENTS /////
/* Mainwindow */
winset(src, "mainwindow", "background-color=#272727")
Expand All @@ -996,8 +996,8 @@
winset(src, "browserwindow", "background-color=#272727")
winset(src, "browserwindow.browser", "background-color=#272727")
/* Infowindow */
winset(src, "infowindow", "background-color=#272727;text-color=#FFFFFF")
winset(src, "infowindow.info", "background-color=#272727;text-color=#FFFFFF;highlight-color=#009900;tab-text-color=#FFFFFF;tab-background-color=#272727")
winset(src, "infowindow", "background-color=#202020;text-color=#a4bad6")
winset(src, "infowindow.info", "background-color=#171717;text-color=#a4bad6;highlight-color=#009900;tab-text-color=#a4bad6;tab-background-color=#202020")
// NOTIFY USER
to_chat(src, "<span class='notice'>Darkmode Enabled</span>")

Expand All @@ -1011,9 +1011,9 @@
winset(src, "rpane.forumb", "background-color=none;text-color=#000000")
winset(src, "rpane.rulesb", "background-color=none;text-color=#000000")
winset(src, "rpane.githubb", "background-color=none;text-color=#000000")
/* Mainwindow */
winset(src, "mainwindow.saybutton", "background-color=none;text-color=#000000")
winset(src, "mainwindow.mebutton", "background-color=none;text-color=#000000")
/* Outputwindow */
winset(src, "outputwindow.saybutton", "background-color=none;text-color=#000000")
winset(src, "outputwindow.mebutton", "background-color=none;text-color=#000000")
///// UI ELEMENTS /////
/* Mainwindow */
winset(src, "mainwindow", "background-color=none")
Expand Down
16 changes: 16 additions & 0 deletions code/modules/client/preference/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
var/list/keybindings_overrides = null
/// View range preference for this client
var/viewrange = DEFAULT_CLIENT_VIEWSIZE
///Screentip Mode, in pixels. 8 is small, 15 is mega big, 0 is off.
var/screentip_mode = 8
///Color of screentips at top of screen
var/screentip_color = "#ffd391"

/datum/preferences/New(client/C)
parent = C
Expand Down Expand Up @@ -543,6 +547,8 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
dat += "<b>Randomized Character Slot:</b> <a href='?_src_=prefs;preference=randomslot'><b>[toggles2 & PREFTOGGLE_2_RANDOMSLOT ? "Yes" : "No"]</b></a><br>"
dat += "<b>Window Flashing:</b> <a href='?_src_=prefs;preference=winflash'>[(toggles2 & PREFTOGGLE_2_WINDOWFLASHING) ? "Yes" : "No"]</a><br>"
dat += "<b>View Range:</b> <a href='?_src_=prefs;preference=setviewrange'>[viewrange]</a><br>"
dat += "<b>Set screentip mode:</b> <a href='?_src_=prefs;preference=screentip_mode'>[(screentip_mode == 0) ? "Disabled" : "[screentip_mode]px"]</a><br>"
dat += "<b>Screentip color:</b> <span style='border: 1px solid #161616; background-color: [screentip_color];'>&nbsp;&nbsp;&nbsp;</span> <a href='?_src_=prefs;preference=screentip_color'><b>Change</b></a><br>"
// RIGHT SIDE OF THE PAGE
dat += "</td><td width='300px' height='300px' valign='top'>"
dat += "<h2>Special Role Settings</h2>"
Expand Down Expand Up @@ -2254,6 +2260,16 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
var/list/actualview = getviewsize(parent.view)
parent.void.UpdateGreed(actualview[1],actualview[2])

if("screentip_mode")
var/desired_screentip_mode = clamp(input(user, "Pick a screentip size, pick 0 to disable screentips. (We suggest a number between 8 and 15):", "Screentip Size") as null|num, 0, 20)
if(!isnull(desired_screentip_mode))
screentip_mode = desired_screentip_mode

if("screentip_color")
var/screentip_color_new = input(user, "Choose your screentip color", screentip_color) as color|null
if(screentip_color_new)
screentip_color = screentip_color_new

if("afk_watch")
if(!(toggles2 & PREFTOGGLE_2_AFKWATCH))
to_chat(user, "<span class='info'>You will now get put into cryo dorms after [config.auto_cryo_afk] minutes. \
Expand Down
14 changes: 12 additions & 2 deletions code/modules/client/preference/preferences_mysql.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
discord_id,
discord_name,
keybindings,
viewrange
viewrange,
screentip_mode,
screentip_color
FROM [format_table_name("player")]
WHERE ckey=:ckey"}, list(
"ckey" = C.ckey
Expand Down Expand Up @@ -53,6 +55,8 @@
discord_name = query.item[18]
keybindings = init_keybindings(raw = query.item[19])
viewrange = query.item[20]
screentip_mode = query.item[21]
screentip_color = query.item[22]

qdel(query)

Expand All @@ -73,6 +77,8 @@
parallax = sanitize_integer(parallax, 0, 16, initial(parallax))
discord_id = sanitize_text(discord_id, initial(discord_id))
discord_name = sanitize_text(discord_name, initial(discord_name))
screentip_mode = sanitize_integer(screentip_mode, 0, 20, initial(screentip_mode))
screentip_color = sanitize_hexcolor(screentip_color, initial(screentip_color))
return 1

/datum/preferences/proc/save_preferences(client/C)
Expand Down Expand Up @@ -105,7 +111,9 @@
clientfps=:clientfps,
parallax=:parallax,
keybindings=:keybindings,
viewrange=:viewrange
viewrange=:viewrange,
screentip_mode=:screentip_mode,
screentip_color=:screentip_color
WHERE ckey=:ckey"}, list(
// OH GOD THE PARAMETERS
"ooccolour" = ooccolor,
Expand All @@ -125,6 +133,8 @@
"parallax" = parallax,
"keybindings" = json_encode(keybindings_overrides),
"viewrange" = viewrange,
"screentip_mode" = screentip_mode,
"screentip_color" = screentip_color,
"ckey" = C.ckey
)
)
Expand Down
2 changes: 1 addition & 1 deletion config/example/dbconfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## This value must be set to the version of the paradise schema in use.
## If this value does not match, the SQL database will not be loaded and an error will be generated.
## Roundstart will be delayed.
DB_VERSION 30
DB_VERSION 31

## Server the MySQL database can be found at.
# Examples: localhost, 200.135.5.43, www.mysqldb.com, etc.
Expand Down
Loading