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

Commit 9a0bb61

Browse files
committed
Fixing wormhole links to be bidirectional updates.
1 parent ba9dbfe commit 9a0bb61

16 files changed

Lines changed: 248 additions & 140 deletions

File tree

‎app/js/app.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,14 @@ function reportAdvisory(button, systemId, type) {
261261
}
262262

263263
function updateWormholeLink(button, from, to, data) {
264-
var state = ! $( button ).hasClass('present');
265264
var payload = {};
266265

267266
if (!data) {
268-
payload.info = $('#wormhole-info-text').val();
269-
payload.signature_id = $('#signature').val();
270-
payload.code = $('#wormhole-code-text').val();
267+
payload.sig_a = $('#sig-a').val();
268+
payload.sig_b = $('#sig-b').val();
269+
payload.type_a = $('#type-a').val();
270+
payload.type_b = $('#type-b').val();
271+
payload.info = $('#wormhole-info').val();
271272
UIPanels.hidePanel();
272273
} else {
273274
payload.info = data;

‎app/js/core/data.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ var Data = {
119119
scan: Templates.scan,
120120
start: Templates.start,
121121
system_info: Templates.system_info,
122-
wormhole_link_info: Templates.wormhole_link_info
122+
wormhole_link_info: Templates.wormhole_link_info,
123+
wormhole_update_panel: Templates.wormhole_update_panel
123124
},
124125

125126
ships: {},

‎app/js/core/ui.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,16 @@ var UI = {
144144
"EFT warrioring",
145145
"Smacktalking",
146146
"Shitpoasting",
147-
"Lemming'ing",
148147
"Clicking jump instead of bridge",
149148
"Overheating guns",
150149
"Bumping the titan",
151150
"Fitting a windicator",
152151
"Burning point",
153152
"Posting gudfites",
153+
"o7 m8 m8 m8",
154+
"7o 8m 8m 8m",
155+
"HAT GONS",
156+
"Gevlon Goblin will rule the world",
154157
"Z0r",
155158
"Whoring on the pod"
156159
];
@@ -238,6 +241,7 @@ Handlebars.registerHelper('ui_icon', function(icon) {
238241
if (icon == 'sourcedHostile') return 'crosshairs';
239242
if (icon == 'updateHostile') return 'crosshairs';
240243
if (icon == 'updateSystemMap') return 'sitemap';
244+
if (icon == 'wormhole') return 'chevron-circle-right';
241245
if (icon == 'youJoined') return 'user';
242246

243247
if (icon == 'Wormhole Detected') return 'chevron-circle-right';

‎app/js/core/ui_panels.js‎

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,16 @@ var UIPanels = {
147147
var to_system = Data.systems[ to_id ];
148148

149149
var panel = {
150-
type: 'info',
151-
icon: 'info',
152-
title: from_system.name + ' -> ' + to_system.name,
153-
formitems: [
154-
{input: {legend: 'Signature ID', id: 'signature'}},
155-
{input: {legend: 'Wormhole Code', max: 4, id: 'wormhole-code-text'}},
156-
{textinput: {legend: 'Paste Wormhole Info Text', id: 'wormhole-info-text', class: 'status-data'}},
157-
{submit: {text: 'Update Jump Link', onClick: 'updateWormholeLink(this,' + from_id + ',' + to_id +')'}}
158-
],
150+
type: 'wormhole-update',
151+
icon: 'wormhole',
152+
from: from_system,
153+
to: to_system,
159154
closeable: true
160155
};
161156

162157
UIPanels.showPanel(panel);
163158

164-
$('#wormhole-code-text').typeahead({
159+
$('#type-a').typeahead({
165160
hint: true,
166161
highlight: true,
167162
minLength: 1
@@ -170,6 +165,18 @@ var UIPanels = {
170165
displayKey: 'value',
171166
source: UIPanels.substringMatcher($.map(Data.wormhole_types, function(t) { return t.code; }))
172167
});
168+
169+
$('#type-b').typeahead({
170+
hint: true,
171+
highlight: true,
172+
minLength: 1
173+
},
174+
{
175+
displayKey: 'value',
176+
source: UIPanels.substringMatcher($.map(Data.wormhole_types, function(t) { return t.code; }))
177+
});
178+
179+
$("#sig-a").focus();
173180
},
174181

175182
showStatusPanel: function (callback) {
@@ -227,7 +234,8 @@ var UIPanels = {
227234

228235
showPanel: function (params, callback) {
229236
var compiledPanel = (params.type === 'start') ? $(Data.templates.start(params)) : $(Data.templates.panel(params));
230-
237+
if (params.type === 'wormhole-update') compiledPanel = $(Data.templates.wormhole_update_panel(params));
238+
231239
if (Data.ui.dim.children().length) {
232240

233241
Data.ui.dim.children().remove();

‎app/js/maps/system_map.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ var SystemMap = {
158158

159159
SystemMap.updateHud( system );
160160

161-
var link_groups = link.data( $.grep(SystemMap.jumps, function(l) { return l.type != 'wormhole'}))
161+
var link_groups = link.data( $.grep(SystemMap.jumps, function(l) { return l.type != 'jumpbridge'}))
162162
.enter().append('g')
163163
.attr('class', function(j) { return 'link ' + j.type; })
164164
.append('line');
165165

166-
var path_groups = link.data( $.grep(SystemMap.jumps, function(l) { return l.type == 'wormhole'}))
166+
var path_groups = link.data( $.grep(SystemMap.jumps, function(l) { return l.type == 'jumpbridge'}))
167167
.enter().append('g')
168168
.attr('class', function(j) { return 'link ' + j.type; })
169169
.append('path')
@@ -290,7 +290,7 @@ var SystemMap = {
290290
.attr('x2', function(d) {return d.target.x;})
291291
.attr('y2', function(d) {return d.target.y;});
292292

293-
path_groups.filter(function(l) { return l.type == 'wormhole'; }).on('click', function(l) {
293+
link_groups.filter(function(l) { return l.type == 'wormhole'; }).on('click', function(l) {
294294
SystemMap.updateWormholeJump( l );
295295
});
296296

‎app/js/maps/wormhole_map.js‎

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,10 @@ var WormholeMap = {
8888
.linkDistance(link_distance * SCALING_FACTOR)
8989
.on('end', function(){
9090

91-
var link_groups = link.data( $.grep(WormholeMap.jumps, function(l) { return l.type != 'wormhole'}))
91+
var link_groups = link.data( $.grep(WormholeMap.jumps, function(l) { return l.type == 'wormhole'}))
9292
.enter().append('g')
9393
.attr('class', function(j) { return 'link ' + j.type; })
9494
.append('line');
95-
96-
var path_groups = link.data( $.grep(WormholeMap.jumps, function(l) { return l.type == 'wormhole'}))
97-
.enter().append('g')
98-
.attr('class', function(j) { return 'link ' + j.type; })
99-
.append('path')
100-
.attr('marker-mid', 'url(#wormhole)');
10195

10296
var node_groups = node.data(WormholeMap.systems)
10397
.enter().append('g')
@@ -158,27 +152,9 @@ var WormholeMap = {
158152
.attr('x2', function(d) {return d.target.x;})
159153
.attr('y2', function(d) {return d.target.y;});
160154

161-
path_groups.filter(function(l) { return l.type == 'wormhole'; }).on('click', function(l) {
155+
link_groups.filter(function(l) { return l.type == 'wormhole'; }).on('click', function(l) {
162156
WormholeMap.updateWormholeJump( l );
163157
});
164-
165-
path_groups.attr('d', function(d) {
166-
var dx = d.target.x - d.source.x,
167-
dy = d.target.y - d.source.y,
168-
dr = Math.sqrt(dx * dx + dy * dy) / 1.45,
169-
mx = d.source.x + dx,
170-
my = d.source.y + dy;
171-
172-
return [
173-
"M",d.source.x,d.source.y,
174-
"A",dr,dr,0,0,1,mx,my,
175-
"A",dr,dr,0,0,1,d.target.x,d.target.y
176-
].join(" ");
177-
});
178-
179-
path_groups.filter(function(l) { return l.wormhole_data.signature; })
180-
.append('title')
181-
.text(function(d) { return d.wormhole_data.signature; });
182158

183159
node_groups.attr('transform', function(d) {
184160
return 'translate(' + (d.x - rect_width / 2) + ',' + (d.y - rect_height / 2) + ')';
@@ -287,6 +263,17 @@ var WormholeMap = {
287263
WormholeMap.zoom.translate([(Data.ui.map.width() / 2 - nodes[system.id].x * scale), (Data.ui.map.height() / 2 - nodes[system.id].y * scale)]);
288264
WormholeMap.zoom.event(root);
289265
},
266+
267+
updateWormholeJump: function(link) {
268+
link.permitted_ships = Handlebars.helpers.jump_permitted_ships(link.wormhole_data.mass_total);
269+
link.read_only = true;
270+
271+
Data.ui.mapInfo.html( $(Data.templates.wormhole_link_info(link)) );
272+
Data.ui.mapInfo.children('div.wormhole-link-details')
273+
.fadeIn(Data.config.uiSpeed)
274+
.delay(Data.config.alertStay * 3)
275+
.fadeOut(Data.config.uiSpeed);
276+
},
290277

291278
init: function() {
292279
log('Initializing System Map...');

0 commit comments

Comments
 (0)