Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit daabe2e

Browse files
committed
Adding wormhole map filter; adding collison detection on the wormhole map.
1 parent d8ce038 commit daabe2e

3 files changed

Lines changed: 95 additions & 14 deletions

File tree

app/js/maps/wormhole_map.js

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,32 @@ var WormholeMap = {
5050
}
5151
return cadb >= 0 && cadb <= a2b2;
5252
},
53+
54+
collide: function(alpha) {
55+
var quadtree = d3.geom.quadtree(WormholeMap.nodes);
56+
return function(d) {
57+
var rb = 20,
58+
nx1 = d.x - rb,
59+
nx2 = d.x + rb,
60+
ny1 = d.y - rb,
61+
ny2 = d.y + rb;
62+
quadtree.visit(function(quad, x1, y1, x2, y2) {
63+
if (quad.point && (quad.point !== d)) {
64+
var x = d.x - quad.point.x,
65+
y = d.y - quad.point.y,
66+
l = Math.sqrt(x * x + y * y);
67+
if (l < rb) {
68+
l = (l - rb) / l * alpha;
69+
d.x -= x *= l;
70+
d.y -= y *= l;
71+
quad.point.x += x;
72+
quad.point.y += y;
73+
}
74+
}
75+
return x1 > nx2 || x2 < nx1 || y1 > ny2 || y2 < ny1;
76+
});
77+
};
78+
},
5379

5480
draw: function() {
5581
// Change this to globally adjust minimum node distance and system [x,y] scale
@@ -63,19 +89,6 @@ var WormholeMap = {
6389
.attr('width', Data.ui.map.width())
6490
.attr('height', Data.ui.map.height())
6591
.append('svg');
66-
67-
// Setup marker types for directed links
68-
var defs = svg.append("svg:defs").selectAll("marker")
69-
.data(["wormhole"])
70-
.enter().append("svg:marker")
71-
.attr("id", String)
72-
.attr("viewBox", "0 -5 10 10")
73-
.attr("refX", 5)
74-
.attr("markerWidth", 3)
75-
.attr("markerHeight", 3)
76-
.attr("orient", "auto")
77-
.append("svg:path")
78-
.attr("d", "M0,-5L10,0L0,5");
7992

8093
var rect_height = 17;
8194
var rect_width = 60;
@@ -86,6 +99,9 @@ var WormholeMap = {
8699
.size([Data.ui.map.width(), Data.ui.map.height()])
87100
.charge(-250 * SCALING_FACTOR)
88101
.linkDistance(link_distance * SCALING_FACTOR)
102+
.on('tick', function() {
103+
WormholeMap.nodes.forEach(WormholeMap.collide(1));
104+
})
89105
.on('end', function(){
90106

91107
var link_groups = link.data( $.grep(WormholeMap.jumps, function(l) { return l.type == 'wormhole'}))
@@ -312,10 +328,48 @@ var WormholeMap = {
312328
.delay(Data.config.alertStay * 3)
313329
.fadeOut(Data.config.uiSpeed);
314330
},
331+
332+
searchNodes: function() {
333+
//find the node
334+
var selectedVal = document.getElementById('search').value;
335+
var node = d3.selectAll(".node");
336+
if (selectedVal == "none") {
337+
node.style("stroke", "white").style("stroke-width", "1");
338+
} else {
339+
var selected = node.filter(function (d, i) {
340+
return (Data.regions[d.system.regionID].name != selectedVal) && (d.system.name != selectedVal);
341+
});
342+
console.log(selected)
343+
selected.style("opacity", "0");
344+
var link = d3.selectAll(".link")
345+
link.style("opacity", "0");
346+
d3.selectAll(".node, .link").transition()
347+
.duration(8000)
348+
.style("opacity", 1);
349+
}
350+
},
315351

316352
init: function() {
317-
log('Initializing System Map...');
353+
log('Initializing Wormhole Map...');
318354
WormholeMap.draw();
355+
$('#search').typeahead({
356+
hint: false,
357+
highlight: true,
358+
minLength: 1
359+
},
360+
{
361+
source: UIPanels.substringMatcher($.merge(
362+
$.map(Data.regions, function(r) { return r.name; }),
363+
$.map(Data.systems, function(s) { return s.name; })
364+
))
365+
});
366+
367+
$('#search').focus().on('keydown', function (event) {
368+
if (event.keyCode == 13) {
369+
WormholeMap.searchNodes();
370+
return false;
371+
}
372+
});
319373
}
320374

321375
};

app/styles/main.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,30 @@ input.log-path {
423423
z-index: 4;
424424
}
425425

426+
#lookup {
427+
position: absolute;
428+
left: 0.5rem;
429+
top: 3rem;
430+
z-index: 4;
431+
width: 150px !important;
432+
}
433+
434+
#lookup input {
435+
font-size: 1rem;
436+
font-family: 'Droid Sans', sans-serif;
437+
background-color: #111;
438+
color: #ffcc2a;
439+
background-color: #333;
440+
font-weight: normal;
441+
text-align: left;
442+
border-top: 0.16rem solid #444;
443+
border-right: 0.16rem solid #999;
444+
border-bottom: 0.16rem solid #999;
445+
border-left: 0.16rem solid #444;
446+
width: 145px;
447+
}
448+
449+
#lookup,
426450
#system-info .jumpbridge-link-details,
427451
#system-info .wormhole-link-details,
428452
#system-info .details {

server/views/overview/index.jade

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ block content
88
span.region Intel Overview
99
span.separator //
1010
span.fleet-name Known Wormholes
11+
#top-menu.sub-bar.right
1112
#content-wrapper
1213
#system-map.main-content.active
14+
#lookup
15+
input#search(placeholder="System or Region Name")
1316
#legend
1417
#system-info
1518
#bottom-bar

0 commit comments

Comments
 (0)