Dunno why i hadn't committed this yet, adds ai click to jump to function on crew monitor comp

This commit is contained in:
D3athrow
2015-07-13 00:47:45 -05:00
parent f18f105ce0
commit 30451d6d26
2 changed files with 34 additions and 5 deletions

View File

@@ -258,6 +258,13 @@ var/global/datum/crewmonitor/crewmonitor = new
spawn(min(30, get_dist(get_turf(C), AI.eyeobj) / 4))
if (AI && AI.eyeobj && current_loc == AI.eyeobj.loc)
AI.switchCamera(C)
if ("crewclick")
var/x = text2num(href_list["x"])
var/y = text2num(href_list["y"])
var/turf/tile = locate(x, y, AI.z)
if(tile)
AI.eyeobj.setLoc(tile)
else if(hclient && hclient.client && hclient.client.mob)
var/mob/living/L = hclient.client.mob
if(!istype(L)) return

View File

@@ -249,7 +249,7 @@
var isAI = null;
var scale_x;
var scale_y;
var defaultzoom = 4;
function disableSelection(){ return false; };
$(window).on("onUpdateContent", function()
@@ -264,17 +264,26 @@ $(window).on("onUpdateContent", function()
$("#switches").append("<div id='zoomcontainer' style='position: static; z-index: 9999; margin-bottom: -75px;'>Zoom: <div id='zoomslider' style='width: 75px; position: relative; top: -31px; right: -50px; z-index: 9999;'><input type=\"range\" onchange=\"setzoom(value);\" value=\"4\" step=\"0.5\" max=\"16\" min=\"0.5\" id=\"zoom\"></div><div id=\"zoomval\" style='position:relative; z-index: 9999; right: -135px; top: -80px; color: white;'>100%</div></div>");
//$("body")[0].onselectstart = disableSelection;
var width = $("#uiMapImage").width();
var width = $("#uiMap").width();
scale_x = width / (maxx * tile_size);
scale_y = width / (maxy * tile_size); // height is assumed to be the same
/*
$("#uiMap").on("click", function(e)
{
var x = ((((e.clientX - 8) / scale_x) / tile_size) + 1).toFixed(0);
var y = ((maxy - (((e.clientY - 8) / scale_y) / tile_size)) + 1).toFixed(0);
window.location.href = "byond://?src=" + hSrc + "&action=select_position&x=" + x + "&y=" + y;
});*/
$("#uiMap").css({ position: 'absolute',
top: '50%',
left: '50%',
margin: '-512px 0 0 -512px',
width: '256px',
height: '256px',
overflow: 'hidden',
zoom: '4'
});
$('#uiMap').drags({handle : '#uiMapImage'});
$('#uiMapTooltip')
@@ -283,6 +292,19 @@ $(window).on("onUpdateContent", function()
event.preventDefault();
$(this).fadeOut(400);
});
$('#uiMap').click(function(ev) {
var el = document.getElementById('uiMap');
var rect = el.getBoundingClientRect();
var tileX = (((ev.clientX - rect.left - el.clientLeft + el.scrollLeft)) / defaultzoom + 7).toFixed(0);
var tileY = (maxy-((ev.clientY - rect.top - el.clientTop + el.scrollTop)) / defaultzoom).toFixed(0);
var xx = ((ev.clientX - rect.left - el.clientLeft + el.scrollLeft) / defaultzoom).toFixed(0);
var yy = ((ev.clientY - rect.top - el.clientTop + el.scrollTop) / defaultzoom).toFixed(0);
//var dot = document.createElement('div');
//dot.setAttribute('style', 'position:absolute; width: 2px; height: 2px; top: '+top+'px; left: '+left+'px; background: red; z-index: 99999999;');
//el.appendChild(dot);
//alert(tileX + ' ' + tileY);
window.location.href = "byond://?src=" + hSrc + "&action=crewclick&x=" + tileX + "&y=" + tileY + "&z=" + z;
});
});
var updateMap = true;
@@ -347,7 +369,7 @@ function switchTo(i)
//$("document").height("800px");
}
}
var defaultzoom = 4;
function changeZoom(offset){
defaultzoom = Math.max(defaultzoom + offset, 1);
var uiMapObject = $('#uiMap');