diff --git a/code/_onclick/hud/action.dm b/code/_onclick/hud/action.dm index ee081baaa0e..ad2294433f2 100644 --- a/code/_onclick/hud/action.dm +++ b/code/_onclick/hud/action.dm @@ -187,7 +187,7 @@ /obj/screen/movable/action_button/MouseEntered(location,control,params) - openToolTip(usr,params,title = name,content = desc) + openToolTip(usr,src,params,title = name,content = desc) /obj/screen/movable/action_button/MouseExited() diff --git a/code/_onclick/hud/alert.dm b/code/_onclick/hud/alert.dm index 145296d6852..1e8ceb9ad00 100644 --- a/code/_onclick/hud/alert.dm +++ b/code/_onclick/hud/alert.dm @@ -86,7 +86,7 @@ /obj/screen/alert/MouseEntered(location,control,params) - openToolTip(usr,params,title = name,content = desc) + openToolTip(usr,src,params,title = name,content = desc) /obj/screen/alert/MouseExited() diff --git a/code/modules/tooltip/tooltip.dm b/code/modules/tooltip/tooltip.dm index 718e98856b9..eb306655402 100644 --- a/code/modules/tooltip/tooltip.dm +++ b/code/modules/tooltip/tooltip.dm @@ -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 = "
[content]
" @@ -60,8 +66,11 @@ Notes: else if (!title && content) content = "[content]
" + //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() - - - diff --git a/code/modules/tooltip/tooltip.html b/code/modules/tooltip/tooltip.html index b5df51603f0..04a471d4559 100644 --- a/code/modules/tooltip/tooltip.html +++ b/code/modules/tooltip/tooltip.html @@ -51,7 +51,6 @@ .colo-pod .wrap {border-color: #256fb9;} .colo-pod .content {border-color: #000000; background-color: #000000;} - /* TG: Themes */ /* ScreenUI */ .midnight .wrap {border-color: #2B2B33;} @@ -63,8 +62,7 @@ .retro .wrap {border-color: #005E00;} .retro .content {color: #003366; border-color: #005E00; background-color: #00BD00;} - - + @@ -74,33 +72,52 @@