Files
Paradise/code/modules/tooltip/tooltip.html
Tigercat2000 aa3b7ac678 -tg- screen alerts
A lot has changed.

Major points:
 - All mobs now use the -tg- thrown alerts system. This is a system where
   a maximum of 5 "alerts" (which take the apperance of HUD icons like the
   inventory and modular action buttons) on their HUD.
 - Alerts are defined as a subtype of /obj/screen/alert.
   - Alerts are "thrown", or activated on the mob with the proc
     `mob.throw_alert("alert_id", /obj/screen/alert/path, severity
     (optional), new_master (optional, overlays the referenced "obj" on the
     button))`
   - Alerts are cleared by calling `mob.clear_alert("alert_id")` or by the
     /obj/screen/alert containing a `timeout` setting, which will
     automatically clear itself after that period of deciseconds.
   - Alerts may have functionality beyond appearance: Mousing over them
     will use the WireWraith tooltip system to generate a themed tooltip,
     and clicking them may have a function defined on the
     /obj/screen/alert object.
   - Shift-clicking an alert will give you it's name and status, in case
     the tooltips fail to work.

 - Hunger/Oxygen/Toxin/Nitrogen/Pressure/Etc warnings are now handled via
   the -tg- thrown alerts system.
   - Failing to breathe anything will display as an "No O2" warning.
   - Species breathing has been refactored to accomodate this. Vox are
     able to breathe the station air without instantly dying, but will be
     poisoned every time they breathe by the oxygen in the air. Any
     species with a unique gas breathing type will also display the
     correct "Choking (no X gas)" instead of just "oxygen". (Unless they
     have not breathed anything in, it's a quirk.)
   - Robot cell/temperature alerts also use this.
   - Aliens, though not harmed by toxins, will have an alert if they
     breathe in toxins, notifying them that "You'll be toast if this
     lights up."

 - More alerts have been added
   - Buckling
     - Activated on: Being buckled to an object.
     - Cleared on: Being unbuckled.
     - Click functionality: Calls resist(); Will unbuckle from chair
       instantly if unrestrained, otherwise, there is a delay period.
   - Hand/Leg cuffs
     - Activated on: Being handcuffed.
     - Cleared on: Being unhandcuffed.
     - Click functionality: Calls resist(); Will attempt to either get out
       of the handcuffs, or, if you are a xenomorph or hulk, break the
       handcuffs in 5 seconds.
   - Blind/High
     - Activated on: Becoming blinded/becoming high on LSD.
     - Cleared on: Becoming unblinded/the high wearing off.
     - Click functionality: None.
   - Asleep
     - Activated on: Life() tick detecting sleeping.
     - Deactivated on: Sleeping being 0 or less.
     - Click functionality: None.
   - Weightless
     - Activated on: Losing gravity.
     - Deactivated on: Moving back into an area with gravity.
     - Click functionality: None.
   - On Fire
     - Activated on: Catching fire.
     - Deactivated on: Being extinguished.
     - Click functionality: Calls resist(); Causes you to stop, drop, and
       roll, which will reduce firestacks and possibly extinguish you.
   - Law update (BORG ONLY)
     - Activated on: Laws being changed.
     - Deactivated on: Timer, 300 deciseconds.
     - Click functionality: None.
   - Hacked (BORG ONLY)
     - Activated on: Being emagged/given malf tools by the malf AI.
     - Deactivated on: Emagged status being removed.
     - Click functionality: None.
   - Locked (BORG ONLY)
     - Activated on: Lockdown being set (by emag law rewriting/robotics
       console/wire being destroyed)
     - Deactivated on: Movement being unlocked.
     - Click functionality: None.
   - Notify Cloning (GHOST ONLY)
     - Activated on: A human's body being placed in a DNA scanner.
     - Deactivated on: Timer, 300 deciseconds.
     - Click functionality: Reenters body.
   - Notify Jump (MULTIPURPOSE) (GHOST ONLY)
     - Activated on: Any sort of chance to become a mob (ie, golem rune).
     - Deactivated on: Timer, 300 deciseconds.
     - Click functionality: Varies.
2016-04-16 14:27:03 -07:00

239 lines
8.0 KiB
HTML

<!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: #610002;}
.cult .content {color: #0F0B0C; border-color: #A10000; background-color: #4A363B;}
.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;}
/* 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;}
</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': {},
'clientView': 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.clientView * 2) + 1,
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, clientView, text, theme, special) {
//Assign our global object
tooltip.params = $.parseJSON(params);
tooltip.clientView = parseInt(clientView);
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>