mirror of
https://github.com/fulpstation/fulpstation.git
synced 2025-12-10 18:11:47 +00:00
* Update beefman.dm * Update beefman.dm * xsaxsfvvvvvvvv * Update shaded_bloodsucker.dm * yeah that thing * FUCK you * Update hunting_contract.dm * dd * vdvdfv * Update monsterhunter_weapons.dm * Update whiterabbit.dm * onokkn * Update monsterhunter_weapons.dm * Update monsterhunter_weapons.dm * efe * Update whiterabbit.dm * yeaywa * Update red_rabbit.dmi * oihop * Update HunterContract.js * wonderland.dm * gs * dcd * Update rabbit.dmi * ass * fvd * Update paradox_rabbit.dm * f * Update tgstation.dme * Delete heartbeatmoon.dmi * shtntb * sed * sfe * Update monsterhunter_weapons.dm * cdc * Update wonderland.dm * dgrd * wef * b * pipkk * Update hunting_contract.dm * Update paradox_rabbit.dm * wr * Update worn_mask.dmi * some documenting * Update areas.dm * eg * Update white_rabbit.dm * Update HunterContract.js * s * Update weapons.dmi * Update weapons.dmi * Jack in the bomb * some signals * ui * h * y * music * Update wonderlandmusic.ogg * f * v * cleanups * g * a * t * y * g * a * o * first commit * Adding our stuff back in * k * Before procs * proc refs * carps * Fixes * shuttles * dumb dumb names * I hate windows I hate windows * I hate windows I hate windows * h * Selenestation has issues * Update monsterhunter_weapons.dm * eretics * Update weapons.dmi * Update monsterhunter_weapons.dm * g * kpop * r * m * grgr * Update simple_animal_freeze.dm * Update wonderland_apocalypse.dm * Update wonderland_apocalypse.dm * d * Update fulp_defines.dm * ff * Update wonderland.dmm * Update tgstation.dme * Update infil_objectives.dm * Update infil_objectives.dm * Update monsterhunter_weapons.dm * Update monsterhunter_event.dm * Update monsterhunter_event.dm * Update areas.dm * Update monsterhunter_event.dm * Update monsterhunter_weapons.dm * Step 0, version 2 * step 0.5 - version 2 * step 1 - version 2 * 2.5 version 2 * fix * Mapping * okay fine * more mapping * uuuuu hhhh * fixes * help me * hurry * I'm killing the mf that did access helpers on this map * Welp, we lost. * Or did we? --------- Co-authored-by: SmoSmoSmoSmok <95004236+SmoSmoSmoSmok@users.noreply.github.com> Co-authored-by: Pepsilawn <reisenrui@gmail.com> Co-authored-by: SgtHunk <68669754+SgtHunk@users.noreply.github.com>
129 lines
3.5 KiB
Plaintext
129 lines
3.5 KiB
Plaintext
/*
|
|
Usage:
|
|
- Define mouse event procs on your (probably HUD) object and simply call the show and hide procs respectively:
|
|
/atom/movable/screen/hud
|
|
MouseEntered(location, control, params)
|
|
usr.client.tooltip.show(params, title = src.name, content = src.desc)
|
|
|
|
MouseExited()
|
|
usr.client.tooltip.hide()
|
|
|
|
Customization:
|
|
- Theming can be done by passing the theme var to show() and using css in the html file to change the look
|
|
- For your convenience some pre-made themes are included
|
|
|
|
Notes:
|
|
- You may have noticed 90% of the work is done via javascript on the client. Gotta save those cycles man.
|
|
*/
|
|
|
|
|
|
/datum/tooltip
|
|
var/client/owner
|
|
var/control = "mainwindow.tooltip"
|
|
var/showing = 0
|
|
var/queueHide = 0
|
|
var/init = 0
|
|
var/atom/last_target
|
|
|
|
|
|
/datum/tooltip/New(client/C)
|
|
if (C)
|
|
owner = C
|
|
var/datum/asset/stuff = get_asset_datum(/datum/asset/simple/jquery)
|
|
stuff.send(owner)
|
|
owner << browse(file2text('code/modules/tooltip/tooltip.html'), "window=[control]")
|
|
|
|
..()
|
|
|
|
|
|
/datum/tooltip/proc/show(atom/movable/thing, params = null, title = null, content = null, theme = "default", special = "none")
|
|
if (!thing || !params || (!title && !content) || !owner || !isnum(world.icon_size))
|
|
return FALSE
|
|
|
|
if (!isnull(last_target))
|
|
UnregisterSignal(last_target, COMSIG_PARENT_QDELETING)
|
|
|
|
RegisterSignal(thing, COMSIG_PARENT_QDELETING, PROC_REF(on_target_qdel))
|
|
|
|
last_target = thing
|
|
|
|
if (!init)
|
|
//Initialize some vars
|
|
init = 1
|
|
owner << output(list2params(list(world.icon_size, control)), "[control]:tooltip.init")
|
|
|
|
showing = 1
|
|
|
|
if (title && content)
|
|
title = "<h1>[title]</h1>"
|
|
content = "<p>[content]</p>"
|
|
else if (title && !content)
|
|
title = "<p>[title]</p>"
|
|
else if (!title && content)
|
|
content = "<p>[content]</p>"
|
|
|
|
// Strip macros from item names
|
|
title = replacetext(title, "\proper", "")
|
|
title = replacetext(title, "\improper", "")
|
|
|
|
//Make our dumb param object
|
|
params = {"{ "cursor": "[params]", "screenLoc": "[thing.screen_loc]" }"}
|
|
|
|
//Send stuff to the tooltip
|
|
var/view_size = getviewsize(owner.view)
|
|
owner << output(list2params(list(params, view_size[1] , view_size[2], "[title][content]", theme, special)), "[control]:tooltip.update")
|
|
|
|
//If a hide() was hit while we were showing, run hide() again to avoid stuck tooltips
|
|
showing = 0
|
|
if (queueHide)
|
|
hide()
|
|
|
|
return TRUE
|
|
|
|
|
|
/datum/tooltip/proc/hide()
|
|
queueHide = showing ? TRUE : FALSE
|
|
|
|
if (queueHide)
|
|
addtimer(CALLBACK(src, PROC_REF(do_hide)), 1)
|
|
else
|
|
do_hide()
|
|
|
|
return TRUE
|
|
|
|
/datum/tooltip/proc/on_target_qdel()
|
|
SIGNAL_HANDLER
|
|
|
|
INVOKE_ASYNC(src, PROC_REF(hide))
|
|
last_target = null
|
|
|
|
/datum/tooltip/proc/do_hide()
|
|
winshow(owner, control, FALSE)
|
|
|
|
/datum/tooltip/Destroy(force, ...)
|
|
last_target = null
|
|
return ..()
|
|
|
|
//Open a tooltip for user, at a location based on params
|
|
//Theme is a CSS class in tooltip.html, by default this wrapper chooses a CSS class based on the user's UI_style (Midnight, Plasmafire, Retro, etc)
|
|
//Includes sanity.checks
|
|
/proc/openToolTip(mob/user = null, atom/movable/tip_src = null, params = null,title = "",content = "",theme = "")
|
|
if(istype(user))
|
|
if(user.client && user.client.tooltips)
|
|
var/ui_style = user.client?.prefs?.read_preference(/datum/preference/choiced/ui_style)
|
|
if(!theme && ui_style)
|
|
theme = lowertext(ui_style)
|
|
if(!theme)
|
|
theme = "default"
|
|
user.client.tooltips.show(tip_src, params,title,content,theme)
|
|
|
|
|
|
//Arbitrarily close a user's tooltip
|
|
//Includes sanity checks.
|
|
/proc/closeToolTip(mob/user)
|
|
if(istype(user))
|
|
if(user.client && user.client.tooltips)
|
|
user.client.tooltips.hide()
|
|
|
|
|