mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-28 15:39:57 +01:00
Radials, Tooltips, RCD and Borg Selection (#8710)
This commit is contained in:
@@ -19,7 +19,8 @@
|
||||
/////////
|
||||
//OTHER//
|
||||
/////////
|
||||
var/datum/preferences/prefs = null
|
||||
var/datum/preferences/prefs
|
||||
var/datum/tooltip/tooltips
|
||||
var/move_delay = 1
|
||||
var/moving = null
|
||||
var/adminobs = null
|
||||
|
||||
@@ -373,10 +373,8 @@
|
||||
prefs.client = src // Safety reasons here.
|
||||
prefs.last_ip = address //these are gonna be used for banning
|
||||
prefs.last_id = computer_id //these are gonna be used for banning
|
||||
#if DM_VERSION >= 511
|
||||
if (byond_version >= 511 && prefs.clientfps)
|
||||
fps = prefs.clientfps
|
||||
#endif // DM_VERSION >= 511
|
||||
if(SStheming)
|
||||
SStheming.apply_theme_from_perfs(src)
|
||||
|
||||
@@ -425,6 +423,9 @@
|
||||
del(src)
|
||||
return 0
|
||||
|
||||
if(!tooltips)
|
||||
tooltips = new /datum/tooltip(src)
|
||||
|
||||
if(holder)
|
||||
add_admin_verbs()
|
||||
|
||||
@@ -575,6 +576,10 @@
|
||||
if(prefs)
|
||||
prefs.ShowChoices(usr)
|
||||
|
||||
/client/proc/apply_fps(var/client_fps)
|
||||
if(world.byond_version >= 511 && byond_version >= 511 && client_fps >= 0 && client_fps <= 1000)
|
||||
vars["fps"] = prefs.clientfps
|
||||
|
||||
//I honestly can't find a good place for this atm.
|
||||
//If the webint interaction gets more features, I'll move it. - Skull132
|
||||
/client/verb/view_linking_requests()
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
"html_UI_style",
|
||||
"skin_theme",
|
||||
"ooccolor",
|
||||
"clientfps"
|
||||
"clientfps",
|
||||
"tooltip_style"
|
||||
),
|
||||
"args" = list("ckey")
|
||||
)
|
||||
@@ -49,6 +50,7 @@
|
||||
"skin_theme",
|
||||
"ooccolor",
|
||||
"clientfps",
|
||||
"tooltip_style",
|
||||
"ckey" = 1
|
||||
)
|
||||
)
|
||||
@@ -62,7 +64,8 @@
|
||||
"html_UI_style" = pref.html_UI_style,
|
||||
"skin_theme" = pref.skin_theme,
|
||||
"ooccolor" = pref.ooccolor,
|
||||
"clientfps" = pref.clientfps
|
||||
"clientfps" = pref.clientfps,
|
||||
"tooltip_style" = pref.tooltip_style
|
||||
)
|
||||
|
||||
/datum/category_item/player_setup_item/player_global/ui/sanitize_preferences()
|
||||
@@ -81,6 +84,7 @@
|
||||
dat += "<b>Custom UI</b> (recommended for White UI):<br>"
|
||||
dat += "-Color: <a href='?src=\ref[src];select_color=1'><b>[pref.UI_style_color]</b></a> [HTML_RECT(pref.UI_style_color)] - <a href='?src=\ref[src];reset=ui'>reset</a><br>"
|
||||
dat += "-Alpha(transparency): <a href='?src=\ref[src];select_alpha=1'><b>[pref.UI_style_alpha]</b></a> - <a href='?src=\ref[src];reset=alpha'>reset</a><br>"
|
||||
dat += "<b>Tooltip Style:</b> <a href='?src=\ref[src];select_tooltip_style=1'><b>[pref.tooltip_style]</b></a><br>"
|
||||
dat += "<b>HTML UI Style:</b> <a href='?src=\ref[src];select_html=1'><b>[pref.html_UI_style]</b></a><br>"
|
||||
dat += "<b>Main UI Style:</b> <a href='?src=\ref[src];select_skin_theme=1'><b>[pref.skin_theme]</b></a><br>"
|
||||
dat += "-FPS: <a href='?src=\ref[src];select_fps=1'><b>[pref.clientfps]</b></a> - <a href='?src=\ref[src];reset=fps'>reset</a><br>"
|
||||
@@ -132,16 +136,27 @@
|
||||
pref.ooccolor = new_ooccolor
|
||||
return TOPIC_REFRESH
|
||||
|
||||
else if ("select_fps")
|
||||
#if DM_VERSION >= 511
|
||||
var/desiredfps = input(user, "Choose your desired fps.\n(0 = synced with server tick rate (currently:[world.fps]))", "Character Preference") as null|num
|
||||
pref.clientfps = sanitize_integer(desiredfps, 0, 1000, initial(pref.clientfps))
|
||||
user.client.fps = pref.clientfps
|
||||
#else
|
||||
to_user_chat("\nThis server does not currently support client side fps. You can set now for when it does.")
|
||||
#endif // DM_VERSION >= 511
|
||||
else if(href_list["select_fps"])
|
||||
var/version_message
|
||||
if (user.client && user.client.byond_version < 511)
|
||||
version_message = "\nYou need to be using byond version 511 or later to take advantage of this feature, your version of [user.client.byond_version] is too low"
|
||||
if (world.byond_version < 511)
|
||||
version_message += "\nThis server does not currently support client side fps. You can set now for when it does."
|
||||
var/new_fps = input(user, "Choose your desired fps.[version_message]\n(0 = synced with server tick rate (currently:[world.fps]))", "Global Preference") as num|null
|
||||
if (isnum(new_fps) && CanUseTopic(user))
|
||||
pref.clientfps = Clamp(new_fps, 0, 1000)
|
||||
|
||||
var/mob/target_mob = preference_mob()
|
||||
if(target_mob && target_mob.client)
|
||||
target_mob.client.apply_fps(pref.clientfps)
|
||||
return TOPIC_REFRESH
|
||||
|
||||
else if(href_list["select_tooltip_style"])
|
||||
var/tooltip_style_new = input(user, "Choose a new tooltip style.", "Global Preference", pref.tooltip_style) as null|anything in all_tooltip_styles
|
||||
if(!tooltip_style_new || !CanUseTopic(user))
|
||||
return TOPIC_NOACTION
|
||||
pref.tooltip_style = tooltip_style_new
|
||||
return TOPIC_REFRESH
|
||||
|
||||
else if(href_list["reset"])
|
||||
switch(href_list["reset"])
|
||||
|
||||
@@ -28,6 +28,8 @@ datum/preferences
|
||||
var/UI_style_alpha = 255
|
||||
var/html_UI_style = "Nano"
|
||||
var/skin_theme = "Light"
|
||||
//Style for popup tooltips
|
||||
var/tooltip_style = "Midnight"
|
||||
var/motd_hash = "" //Hashes for the new server greeting window.
|
||||
var/memo_hash = ""
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
/var/all_ui_styles = list(
|
||||
var/all_ui_styles = list(
|
||||
"Midnight" = 'icons/mob/screen/midnight.dmi',
|
||||
"Orange" = 'icons/mob/screen/orange.dmi',
|
||||
"old" = 'icons/mob/screen/old.dmi',
|
||||
@@ -8,12 +6,20 @@
|
||||
"old-noborder" = 'icons/mob/screen/old-noborder.dmi'
|
||||
)
|
||||
|
||||
var/all_tooltip_styles = list(
|
||||
"Midnight", //Default for everyone is the first one,
|
||||
"Plasmafire",
|
||||
"Retro",
|
||||
"Slimecore",
|
||||
"Operative",
|
||||
"Clockwork"
|
||||
)
|
||||
|
||||
/proc/ui_style2icon(ui_style)
|
||||
if(ui_style in all_ui_styles)
|
||||
return all_ui_styles[ui_style]
|
||||
return all_ui_styles["White"]
|
||||
|
||||
|
||||
/client/verb/change_ui()
|
||||
set name = "Change UI"
|
||||
set category = "Preferences"
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
if(exosuit.emp_damage >= EMP_MOVE_DISRUPT && prob(30))
|
||||
failed = TRUE
|
||||
if(failed)
|
||||
moving_dir = pick(GLOB.cardinal - exosuit.dir)
|
||||
moving_dir = pick(cardinal - exosuit.dir)
|
||||
|
||||
exosuit.get_cell().use(exosuit.legs.power_use * CELLRATE)
|
||||
if(exosuit.dir != moving_dir)
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
|
||||
// Forces synths to select an icon relevant to their module
|
||||
if(module && !icon_selected)
|
||||
choose_icon(icon_selection_tries, module_sprites)
|
||||
choose_icon()
|
||||
@@ -12,7 +12,6 @@
|
||||
var/icontype //Persistent icontype tracking allows for cleaner icon updates
|
||||
var/module_sprites[0] //Used to store the associations between sprite names and sprite index.
|
||||
var/icon_selected = 0 //If icon selection has been completed yet
|
||||
var/icon_selection_tries = -1//Remaining attempts to select icon before a selection is forced
|
||||
var/spawn_sound = 'sound/voice/liveagain.ogg'
|
||||
var/pitch_toggle = TRUE
|
||||
var/datum/effect/effect/system/ion_trail_follow/ion_trail
|
||||
@@ -1072,39 +1071,37 @@
|
||||
/mob/living/silicon/robot/proc/choose_icon()
|
||||
set category = "Robot Commands"
|
||||
set name = "Choose Icon"
|
||||
set waitfor = 0
|
||||
|
||||
if(!length(module_sprites))
|
||||
to_chat(src, SPAN_DANGER("Something is badly wrong with the sprite selection. Harass a coder."))
|
||||
return
|
||||
|
||||
if(icon_selected)
|
||||
verbs -= /mob/living/silicon/robot/proc/choose_icon
|
||||
return
|
||||
|
||||
if(icon_selection_tries == -1)
|
||||
icon_selection_tries = round(module_sprites.len*0.5)
|
||||
|
||||
|
||||
if(length(module_sprites) == 1 || !client)
|
||||
if(!(icontype in module_sprites))
|
||||
icontype = module_sprites[1]
|
||||
if(!client)
|
||||
return
|
||||
else
|
||||
icontype = input(src, "Select an icon! [icon_selection_tries ? "You have [icon_selection_tries] more chance\s." : "This is your last try."]", "Icon Selection") in module_sprites
|
||||
playsound(get_turf(src), 'sound/effects/pop.ogg', 100, TRUE)
|
||||
spark(get_turf(src), 5, alldirs)
|
||||
var/list/options = list()
|
||||
for(var/i in module_sprites)
|
||||
var/image/radial_button = image(icon = src.icon, icon_state = module_sprites[i])
|
||||
radial_button.overlays.Add(image(icon = src.icon, icon_state = "eyes-[module_sprites[i]]-help"))
|
||||
options[i] = radial_button
|
||||
icontype = show_radial_menu(src, src, options, radius = 42, tooltips = TRUE)
|
||||
|
||||
if(!icontype)
|
||||
return
|
||||
|
||||
icon_state = module_sprites[icontype]
|
||||
updateicon()
|
||||
|
||||
if(length(module_sprites) > 1 && icon_selection_tries >= 1 && client)
|
||||
icon_selection_tries--
|
||||
var/choice = input(src, "Look at your icon - is this what you want?", "Icon Confirmation") in list("Yes", "No")
|
||||
if(choice == "No")
|
||||
choose_icon()
|
||||
return
|
||||
|
||||
icon_selected = TRUE
|
||||
icon_selection_tries = 0
|
||||
playsound(get_turf(src), 'sound/effects/pop.ogg', 10, TRUE)
|
||||
spark(get_turf(src), 5, alldirs)
|
||||
verbs -= /mob/living/silicon/robot/proc/choose_icon
|
||||
to_chat(src, SPAN_NOTICE("Your icon has been set. You now require a module reset to change it."))
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@ var/global/list/robot_modules = list(
|
||||
|
||||
R.set_module_sprites(sprites)
|
||||
R.icon_selected = FALSE
|
||||
R.icon_selection_tries = -1
|
||||
R.choose_icon()
|
||||
|
||||
for(var/obj/item/I in modules)
|
||||
@@ -81,7 +80,6 @@ var/global/list/robot_modules = list(
|
||||
R.radio.recalculateChannels()
|
||||
R.set_module_sprites(list("Default" = "robot"))
|
||||
R.icon_selected = FALSE
|
||||
R.icon_selection_tries = -1
|
||||
R.choose_icon()
|
||||
|
||||
/obj/item/robot_module/Destroy()
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
Tooltips v1.1 - 22/10/15
|
||||
Developed by Wire (#goonstation on irc.synirc.net)
|
||||
- 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)
|
||||
- Set file to the correct path for the .html file (remember to actually place the html file)
|
||||
- Attach the datum to the user client on login, e.g.
|
||||
|
||||
/client/New()
|
||||
src.tooltips = new /datum/tooltip(src)
|
||||
|
||||
Usage:
|
||||
- Define mouse event procs on your (probably HUD) object and simply call the show and hide procs respectively:
|
||||
|
||||
/obj/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.
|
||||
- This is entirely untested in any other codebase besides goonstation so I have no idea if it will port nicely. Good luck!
|
||||
- After testing and discussion (Wire, Remie, MrPerson, AnturK) ToolTips are ok and work for /tg/station13
|
||||
*/
|
||||
|
||||
/datum/tooltip
|
||||
var/client/owner
|
||||
var/control = "mainwindow.tooltip"
|
||||
var/showing = FALSE
|
||||
var/queueHide = FALSE
|
||||
var/init = FALSE
|
||||
|
||||
/datum/tooltip/New(client/C)
|
||||
if(C)
|
||||
owner = C
|
||||
show_browser(owner, 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(!init)
|
||||
//Initialize some vars
|
||||
init = TRUE
|
||||
send_output(owner, list2params(list(world.icon_size, control)), "[control]:tooltip.init")
|
||||
|
||||
showing = TRUE
|
||||
|
||||
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
|
||||
if(params[1] != "i") //Byond Bug: http://www.byond.com/forum/?post=2352648
|
||||
params = "icon-x=16;icon-y=16;[params]" //Put in some placeholders
|
||||
params = {"{ "cursor": "[params]", "screenLoc": "[thing.screen_loc]" }"}
|
||||
|
||||
//Send stuff to the tooltip
|
||||
var/view_size = getviewsize(owner.view)
|
||||
send_output(owner, list2params(list(params, view_size[1] , view_size[2], "[title][content]", theme, special)), "[control]:tooltip.update")
|
||||
|
||||
//ifa hide() was hit while we were showing, run hide() again to avoid stuck tooltips
|
||||
showing = FALSE
|
||||
if(queueHide)
|
||||
hide()
|
||||
|
||||
return TRUE
|
||||
|
||||
/datum/tooltip/proc/hide()
|
||||
if(queueHide)
|
||||
addtimer(CALLBACK(src, .proc/do_hide), 1)
|
||||
else
|
||||
do_hide()
|
||||
|
||||
queueHide = showing ? TRUE : FALSE
|
||||
|
||||
return TRUE
|
||||
|
||||
/datum/tooltip/proc/do_hide()
|
||||
winshow(owner, control, FALSE)
|
||||
|
||||
/* 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, 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)
|
||||
if(!theme && user.client.prefs && user.client.prefs.tooltip_style)
|
||||
theme = lowertext(user.client.prefs.tooltip_style)
|
||||
if(!theme)
|
||||
theme = "midnight"
|
||||
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()
|
||||
@@ -0,0 +1,249 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Tooltip</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<style type="text/css">
|
||||
body, html {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wrap {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
max-width: 298px;
|
||||
border: 2px solid #1B2967;
|
||||
}
|
||||
|
||||
.content {
|
||||
font: bold 12px Arial, 'Helvetica Neue', Helvetica, sans-serif;
|
||||
color: #ffffff;
|
||||
padding: 8px;
|
||||
border: 2px solid #0033CC;
|
||||
background: #005CB8;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: -5px 0 2px 0;
|
||||
font-size: 1.2em;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
/* Custom Themes */
|
||||
.blob .wrap {border-color: #2E2E2E;}
|
||||
.blob .content {color: #82ED00; border-color: #4E4C4A; background-color: #191918;}
|
||||
|
||||
.parasite .wrap {border-color: #88868D;}
|
||||
.parasite .content {color: #EFEEEF; border-color: #35333A; background-color: #636169;}
|
||||
|
||||
.alien .wrap {border-color: #33165B;}
|
||||
.alien .content {color: #25004A; border-color: #5A3076; background-color: #6D3A8E;}
|
||||
|
||||
.wraith .wrap {border-color: #492136;}
|
||||
.wraith .content {border-color: #331726; background-color: #471962;}
|
||||
|
||||
.cult .wrap {border-color: #292222;}
|
||||
.cult .content {color: #FF0000; border-color: #4C4343; background-color: #3C3434;}
|
||||
|
||||
.clockcult .wrap {border-color: #170800;}
|
||||
.clockcult .content {color: #B18B25; border-color: #000000; background-color: #5F380E;}
|
||||
|
||||
.pod .wrap {border-color: #052401;}
|
||||
.pod .content {border-color: #326D29; background-color: #569F4B;}
|
||||
|
||||
.colo-pod .wrap {border-color: #256fb9;}
|
||||
.colo-pod .content {border-color: #000000; background-color: #000000;}
|
||||
|
||||
.hisgrace .wrap {border-color: #7C1414;}
|
||||
.hisgrace .content {color: #15D512; border-color: #9D1414; background-color: #861414;}
|
||||
|
||||
/* TG: Themes */
|
||||
/* ScreenUI */
|
||||
.midnight .wrap {border-color: #2B2B33;}
|
||||
.midnight .content {color: #6087A0; border-color: #2B2B33; background-color: #36363C;}
|
||||
|
||||
.plasmafire .wrap {border-color: #21213D;}
|
||||
.plasmafire .content {color: #FFA800 ; border-color: #21213D; background-color:#1D1D36;}
|
||||
|
||||
.retro .wrap {border-color: #005E00;}
|
||||
.retro .content {color: #003366; border-color: #005E00; background-color: #00BD00;}
|
||||
|
||||
.slimecore .wrap {border-color: #18640E;}
|
||||
.slimecore .content {color: #6EA161; border-color: #11450B; background-color: #354E35;}
|
||||
|
||||
.operative .wrap {border-color: #1E0101;}
|
||||
.operative .content {color: #FFFFFF; border-color: #750000; background-color: #350000;}
|
||||
|
||||
.clockwork .wrap {border-color: #170800;}
|
||||
.clockwork .content {color: #B18B25; border-color: #000000; background-color: #5F380E;}
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrap" class="wrap">
|
||||
<div id="content" class="content"></div>
|
||||
</div>
|
||||
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var tooltip = {
|
||||
'tileSize': 32,
|
||||
'control': '',
|
||||
'params': {},
|
||||
'client_view_w': 0,
|
||||
'client_view_h': 0,
|
||||
'text': '',
|
||||
'theme': '',
|
||||
'padding': 2,
|
||||
init: function(tileSize, control) {
|
||||
tooltip.tileSize = parseInt(tileSize);
|
||||
tooltip.control = control;
|
||||
},
|
||||
hide: function() {
|
||||
window.location = 'byond://winset?id='+tooltip.control+';is-visible=false';
|
||||
},
|
||||
updateCallback: function(map) {
|
||||
if (typeof map === 'undefined' || !map) {return false;}
|
||||
|
||||
//alert(tooltip.params+' | '+tooltip.clientView+' | '+tooltip.text+' | '+tooltip.theme); //DEBUG
|
||||
|
||||
//Some reset stuff to avoid fringe issues with sizing
|
||||
window.location = 'byond://winset?id='+tooltip.control+';anchor1=0,0;size=999x999';
|
||||
|
||||
//Get the real icon size according to the client view
|
||||
var mapWidth = map['view-size'].x,
|
||||
mapHeight = map['view-size'].y,
|
||||
tilesShown = tooltip.client_view_w
|
||||
realIconSize = mapWidth / tilesShown,
|
||||
resizeRatio = realIconSize / tooltip.tileSize,
|
||||
//Calculate letterboxing offsets
|
||||
leftOffset = (map.size.x - mapWidth) / 2,
|
||||
topOffset = (map.size.y - mapHeight) / 2;
|
||||
|
||||
//alert(realIconSize + ' | ' +tooltip.tileSize + ' | ' + resizeRatio); //DEBUG
|
||||
|
||||
//Parse out the tile and cursor locations from params (e.g. "icon-x=32;icon-y=29;screen-loc=3:10,15:29")
|
||||
var paramsA = tooltip.params.cursor.split(';');
|
||||
if (paramsA.length < 3) {return false;} //Sometimes screen-loc is never sent ahaha fuck you byond
|
||||
//icon-x
|
||||
var iconX = paramsA[0];
|
||||
iconX = iconX.split('=');
|
||||
iconX = parseInt(iconX[1]);
|
||||
//icon-y
|
||||
var iconY = paramsA[1];
|
||||
iconY = iconY.split('=');
|
||||
iconY = parseInt(iconY[1]);
|
||||
//screen-loc
|
||||
var screenLoc = paramsA[2];
|
||||
screenLoc = screenLoc.split('=');
|
||||
screenLoc = screenLoc[1].split(',');
|
||||
if (screenLoc.length < 2) {return false;}
|
||||
var left = screenLoc[0];
|
||||
var top = screenLoc[1];
|
||||
if (!left || !top) {return false;}
|
||||
screenLoc = left.split(':');
|
||||
left = parseInt(screenLoc[0]);
|
||||
var enteredX = parseInt(screenLoc[1]);
|
||||
screenLoc = top.split(':');
|
||||
top = parseInt(screenLoc[0]);
|
||||
var enteredY = parseInt(screenLoc[1]);
|
||||
|
||||
//Screen loc offsets on objects (e.g. "WEST+0:6,NORTH-1:26") can royally mess with positioning depending on where the cursor enters
|
||||
//This is a giant bitch to parse. Note that it only expects screen_loc in the format <west>,<north>.
|
||||
var oScreenLoc = tooltip.params.screenLoc.split(','); //o for original ok
|
||||
|
||||
var west = oScreenLoc[0].split(':');
|
||||
if (west.length > 1) { //Only if west has a pixel offset
|
||||
var westOffset = parseInt(west[1]);
|
||||
if (westOffset !== 0) {
|
||||
if ((iconX + westOffset) !== enteredX) { //Cursor entered on the offset tile
|
||||
left = left + (westOffset < 0 ? 1 : -1);
|
||||
}
|
||||
leftOffset = leftOffset + (westOffset * resizeRatio);
|
||||
}
|
||||
}
|
||||
|
||||
if (oScreenLoc.length > 1) { //If north is given
|
||||
var north = oScreenLoc[1].split(':');
|
||||
if (north.length > 1) { //Only if north has a pixel offset
|
||||
var northOffset = parseInt(north[1]);
|
||||
if (northOffset !== 0) {
|
||||
if ((iconY + northOffset) === enteredY) { //Cursor entered on the original tile
|
||||
top--;
|
||||
topOffset = topOffset - ((tooltip.tileSize + northOffset) * resizeRatio);
|
||||
} else { //Cursor entered on the offset tile
|
||||
if (northOffset < 0) { //Offset southwards
|
||||
topOffset = topOffset - ((tooltip.tileSize + northOffset) * resizeRatio);
|
||||
} else { //Offset northwards
|
||||
top--;
|
||||
topOffset = topOffset - (northOffset * resizeRatio);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Handle special cases (for fuck sake)
|
||||
if (tooltip.special !== 'none') {
|
||||
//Put yo special cases here
|
||||
}
|
||||
|
||||
//Clamp values
|
||||
left = (left < 0 ? 0 : (left > tilesShown ? tilesShown : left));
|
||||
top = (top < 0 ? 0 : (top > tilesShown ? tilesShown : top));
|
||||
|
||||
//Calculate where on the screen the popup should appear (below the hovered tile)
|
||||
var posX = Math.round(((left - 1) * realIconSize) + leftOffset + tooltip.padding); //-1 to position at the left of the target tile
|
||||
var posY = Math.round(((tilesShown - top + 1) * realIconSize) + topOffset + tooltip.padding); //+1 to position at the bottom of the target tile
|
||||
|
||||
//alert(mapWidth+' | '+mapHeight+' | '+tilesShown+' | '+realIconSize+' | '+leftOffset+' | '+topOffset+' | '+left+' | '+top+' | '+posX+' | '+posY); //DEBUG
|
||||
|
||||
$('body').attr('class', tooltip.theme);
|
||||
|
||||
var $content = $('#content'),
|
||||
$wrap = $('#wrap');
|
||||
$wrap.attr('style', '');
|
||||
$content.off('mouseover');
|
||||
$content.html(tooltip.text);
|
||||
|
||||
$wrap.width($wrap.width() + 2); //Dumb hack to fix a bizarre sizing bug
|
||||
|
||||
var docWidth = $wrap.outerWidth(),
|
||||
docHeight = $wrap.outerHeight();
|
||||
|
||||
if (posY + docHeight > map.size.y) { //Is the bottom edge below the window? Snap it up if so
|
||||
posY = (posY - docHeight) - realIconSize - tooltip.padding;
|
||||
}
|
||||
|
||||
//Actually size, move and show the tooltip box
|
||||
window.location = 'byond://winset?id='+tooltip.control+';size='+docWidth+'x'+docHeight+';pos='+posX+','+posY+';is-visible=true';
|
||||
|
||||
$content.on('mouseover', function() {
|
||||
tooltip.hide();
|
||||
});
|
||||
},
|
||||
update: function(params, client_vw , clien_vh , text, theme, special) {
|
||||
//Assign our global object
|
||||
tooltip.params = $.parseJSON(params);
|
||||
tooltip.client_view_w = parseInt(client_vw);
|
||||
tooltip.client_view_h = parseInt(clien_vh);
|
||||
tooltip.text = text;
|
||||
tooltip.theme = theme;
|
||||
tooltip.special = special;
|
||||
|
||||
//Go get the map details
|
||||
window.location = 'byond://winget?callback=tooltip.updateCallback;id=mapwindow.map;property=size,view-size';
|
||||
},
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user