';
}
else {
str += '';
}
str += label[i][1] + '';
}
}
this._legendLabel.innerHTML = str;
};
ShowOnMap.combinePins = function(pins, dailyOnly, hasPaths) {
var combined = {};
var coord = null, tmpCoord = null;
var x, y, l;
var nPins = 0;
var getCoord = function(coord, level, tight) {
var x = Math.floor(coord[0]);
var y = Math.floor(coord[1]);
var l = level || 0;
if (!tight) {
if (x % 2 == 1) {
x += 1;
}
if (y % 2 == 1) {
y += 1;
}
}
if (combined[l] === undefined) {
combined[l] = {};
}
if (combined[l][x] === undefined) {
combined[l][x] = {};
}
if (combined[l][x][y] === undefined) {
combined[l][x][y] = [];
}
return [x, y];
}
for (var p = 0; p < pins.length; ++p) {
var pin = pins[p];
if (dailyOnly) {
if (!pin.quests) {
continue;
}
var noDaily = true;
for (var n = 0; n < pin.quests.length; ++n) {
if (pin.quests[n].daily) {
noDaily = false;
break;
}
}
if (noDaily) {
continue;
}
}
else if (hasPaths) {
// Don't combine pins that have paths
coord = getCoord([pin.id, 0], pin.level, true);
x = coord[0]; y = coord[1]; l = pin.level || 0;
var newPin = $WH.dO(pin);
newPin.coord = pin.coords[0];
combined[l][x][y].push(newPin);
nPins++;
continue;
}
if (pin.point == 'start' || pin.point == 'end') {
coord = getCoord(pin.coord, pin.level);
x = coord[0]; y = coord[1]; l = pin.level || 0;
if (combined[l][x][y].length > 3) {
var temp = combined[l][x][y];
combined[l][x][y] = [];
for (var i = 0; i < temp.length; ++i) {
tmpCoord = getCoord(temp[i].coord, pin.level, true);
combined[l][tmpCoord[0]][tmpCoord[1]].push(temp[i]);
}
}
combined[l][x][y].push(pin);
nPins++;
}
else {
for (var c = 0; c < pin.coords.length; ++c) {
coord = getCoord(pin.coords[c], pin.level);
x = coord[0]; y = coord[1]; l = pin.level || 0;
var newPin = $WH.dO(pin);
newPin.coord = pin.coords[c];
if (combined[l][x][y].length > 3) {
var temp = combined[l][x][y];
combined[l][x][y] = [];
for (var i = 0; i < temp.length; ++i) {
tmpCoord = getCoord(temp[i].coord, temp[i].level, true);
combined[temp[i].level || 0][tmpCoord[0]][tmpCoord[1]].push(temp[i]);
}
}
combined[l][x][y].push(newPin);
nPins++;
}
}
}
var complete = [];
for (l in combined) {
for (x in combined[l]) {
for (y in combined[l][x]) {
complete.push({
coord: [combined[l][x][y][0].coord[0], combined[l][x][y][0].coord[1]],
level: l,
list: combined[l][x][y]
});
}
}
}
return [complete, nPins];
};
ShowOnMap.buildTooltip = function(list, dailyOnly) {
var str = '';
var url = '';
var menu = [];
var pinType = -1;
var uniques = {};
var nUniques = 0;
var pointTypes = {};
var objType = 1;
for (var n = 0; n < list.length; ++n) {
var obj = list[n];
url = (g_types[obj.type] && obj.id ? '?' + g_types[obj.type] + '=' + obj.id : '');
var key = url + obj.item;
var pointKey = url + obj.point;
if (!uniques[key]) {
uniques[key] = {
url: url,
obj: obj,
coords: [obj.coord],
all: [obj]
};
nUniques++;
}
else {
if (!pointTypes[pointKey]) {
uniques[key].all.push(obj);
}
uniques[key].coords.push(obj.coord);
}
pointTypes[pointKey] = 1;
}
var n = 0;
for (var key in uniques) {
var url = uniques[key].url;
var all = uniques[key].all;
var obj = uniques[key].obj;
var coords = uniques[key].coords;
if (n > 0) {
str += '
';
}
menu.push([n++, obj.name, url]);
objType = obj.type;
if (!obj.point) {
if ((obj.reacthorde == 1 && obj.reactalliance < 1) || obj.side == 2) {
if (pinType == 2 || pinType == -1) {
pinType = 2;
}
else {
pinType = 0;
}
}
else if ((obj.reactalliance == 1 && obj.reacthorde < 1) || obj.side == 1) {
if (pinType == 3 || pinType == -1) {
pinType = 3;
}
else {
pinType = 0;
}
}
else {
pinType = 0;
}
}
str += '' + obj.name + '';
if (coords.length > 0) {
str += ' (' + coords[0][0] + ', ' + coords[0][1] + ')
';
}
if (obj.quests) {
if (obj.quests.length > 1) {
str += LANG.som_startsquestpl;
}
else {
str += LANG.som_startsquest;
}
str += '';
for (var q = 0; q < obj.quests.length; ++q) {
var quest = obj.quests[q];
if (dailyOnly && !quest.daily) {
continue;
}
str += '[' + quest.level + '] ' + quest.name + ((quest.series && !quest.first) ? '(*)' : '') + ((quest.category < 0 && g_quest_sorts[quest.category]) ? ' ' + g_quest_sorts[quest.category] + '' : '') + '
';
}
str += '
';
}
else if (obj.description) {
str += obj.description + '
';
}
else if (obj.point) {
for (var n = 0; n < all.length; ++n) {
var o = all[n];
switch (o.point) {
case 'start':
str += LANG.mapper_startsquest + '
';
if (pinType == 'end') {
pinType = 'startend';
}
else if (pinType != 'startend') {
pinType = 'start';
}
break;
case 'end':
str += LANG.mapper_endsquest + '
';
if (pinType == 'start') {
pinType = 'startend';
}
else if (pinType != 'startend') {
pinType = 'end';
}
break;
case 'sourcestart':
str += LANG.mapper_sourcestart + '
';
str += '' + o.item + '
';
if (pinType == 'end') {
pinType = 'startend';
}
else if (pinType != 'startend') {
pinType = 'start';
}
break;
case 'sourceend':
str += LANG.mapper_sourceend + '
';
str += '' + o.item + '
';
if (pinType == 'start') {
pinType = 'startend';
}
else if (pinType != 'startend') {
pinType = 'end';
}
break;
case 'requirement':
str += LANG.mapper_requiredquest + '
';
if (pinType == -1) {
pinType = o.objective;
}
break;
case 'sourcerequirement':
str += LANG.mapper_sourcereq + '
';
str += '' + o.item + '
';
if (pinType == -1) {
pinType = o.objective;
}
break;
}
}
}
}
str += '';
if (list.length == 1) {
str += (list[0].type == 1 ? LANG.som_viewnpc : (list[0].type == 2 ? LANG.som_viewobj : ''));
}
else if (nUniques == 1) {
str += (objType == 1 ? LANG.som_viewnpc : (objType == 2 ? LANG.som_viewobj : ''));
}
else {
str += '
' + LANG.som_view;
}
str += '
';
var ret = [];
ret.push(str);
ret.push(pinType);
if (list.length == 1 || nUniques == 1) {
ret.push(url);
ret.push(null);
}
else {
ret.push('javascript:;');
ret.push(menu);
}
return ret;
};