mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
Updates ToolTips system to V1.1, by Wirewraith
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
Tooltips v1.0 - 19/10/15
|
||||
Tooltips v1.1 - 22/10/15
|
||||
Developed by Wire (#goonstation on irc.synirc.net)
|
||||
- Initial release
|
||||
- Added support for screen_loc pixel offsets. Should work. Maybe.
|
||||
- Added init function to more efficiently send base vars
|
||||
|
||||
Configuration:
|
||||
- Set control to the correct skin element (remember to actually place the skin element)
|
||||
@@ -37,21 +38,26 @@ Notes:
|
||||
file = 'code/modules/tooltip/tooltip.html'
|
||||
showing = 0
|
||||
queueHide = 0
|
||||
init = 0
|
||||
|
||||
|
||||
New(client/C)
|
||||
if (C)
|
||||
src.owner = C
|
||||
src.owner << browse(src.file, "window=[src.control]")
|
||||
src.owner << browse(file2text(src.file), "window=[src.control]")
|
||||
|
||||
..()
|
||||
|
||||
|
||||
proc/show(params = null, title = null, content = null, theme = "default")
|
||||
if (!params || (!title && !content) || !src.owner) return 0
|
||||
proc/show(atom/movable/thing, params = null, title = null, content = null, theme = "default", special = "none")
|
||||
if (!thing || !params || (!title && !content) || !src.owner || !isnum(world.icon_size)) return 0
|
||||
if (!src.init)
|
||||
//Initialize some vars
|
||||
src.init = 1
|
||||
src.owner << output(list2params(list(world.icon_size, src.control)), "[src.control]:tooltip.init")
|
||||
|
||||
src.showing = 1
|
||||
|
||||
//Format contents
|
||||
if (title && content)
|
||||
title = "<h1>[title]</h1>"
|
||||
content = "<p>[content]</p>"
|
||||
@@ -60,8 +66,11 @@ Notes:
|
||||
else if (!title && content)
|
||||
content = "<p>[content]</p>"
|
||||
|
||||
//Make our dumb param object
|
||||
params = {"{ "cursor": "[params]", "screenLoc": "[thing.screen_loc]" }"}
|
||||
|
||||
//Send stuff to the tooltip
|
||||
src.owner << output(list2params(list(src.control, params, src.owner.view, "[title][content]", theme)), "[src.control]:tooltip.update")
|
||||
src.owner << output(list2params(list(params, src.owner.view, "[title][content]", theme, special)), "[src.control]:tooltip.update")
|
||||
|
||||
//If a hide() was hit while we were showing, run hide() again to avoid stuck tooltips
|
||||
src.showing = 0
|
||||
@@ -83,21 +92,20 @@ Notes:
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
/* TG SPECIFIC CODE */
|
||||
|
||||
|
||||
//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)
|
||||
//Includes sanity.checks
|
||||
/proc/openToolTip(mob/user = null,params = null,title = "",content = "",theme = "")
|
||||
/proc/openToolTip(mob/user = null, atom/movable/tip_src = null, params = null,title = "",content = "",theme = "")
|
||||
if(istype(user))
|
||||
if(user.client && user.client.tooltips)
|
||||
if(!theme && user.client.prefs && user.client.prefs.UI_style)
|
||||
theme = lowertext(user.client.prefs.UI_style)
|
||||
if(!theme)
|
||||
theme = "default"
|
||||
user.client.tooltips.show(params,title,content,theme)
|
||||
user.client.tooltips.show(tip_src, params,title,content,theme)
|
||||
|
||||
|
||||
//Arbitrarily close a user's tooltip
|
||||
@@ -108,6 +116,3 @@ Notes:
|
||||
user.client.tooltips.hide()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user