Added support for custom map links in Burgs

+ Added field under "Burg Features"
+ Added property "link" to burg objects with handling for undefined
+ Added support for "Generate", "Generated", "Default", and "" to behave
as the current MFCG behavior while anything else is treated as a custom
link
+ Added tips for the new field
This commit is contained in:
aetherwalker 2018-12-03 07:18:22 -05:00
parent 168cb3cdab
commit 41b998af0a
2 changed files with 37 additions and 16 deletions

View file

@ -984,6 +984,8 @@
<div id="burgFeaturesSection" style="display: none">
<button id="burgToggleCapital" onmouseover="tip('Mark the Burg as country capital. Neutral burg cannot be a capital')" class="icon-star"></button>
<button id="burgTogglePort" onmouseover="tip('Mark the Burg as port (toggle anchor icon)')" class="icon-anchor"></button>
<i onmouseover="tip('Set Burg custom map link')" class="icon-link"></i>
<input id="burgLink" onmouseover="tip('Set Burg custom map link or specify Generated to use the default')" type="text" style="width: 200px;" />
<i onmouseover="tip('Set Burg population')" class="icon-users"></i>
<input id="burgPopulation" onmouseover="tip('Set Burg population (in population points)')" type="number" value="1" min="0" step="1" style="width: 40px;"></select>
<output id="burgPopulationFriendly" onmouseover="tip('Burg population (in people)')">1000</output>

View file

@ -3628,6 +3628,7 @@ function fantasyMap() {
}
d3.select("#burgTogglePort").classed("pressed", cell.port !== undefined);
burgPopulation.value = manors[id].population;
burgMFCGLink.value = manors[id].link || "Generate";
burgPopulationFriendly.value = rn(manors[id].population * urbanization.value * populationRate.value * 1000);
$("#burgEditor").dialog({
@ -3914,6 +3915,11 @@ function fantasyMap() {
manors[id].population = +this.value;
});
$("#burgMFCGLink").on("input", function() {
const id = +elSelected.attr("data-id");
manors[id].link = this.value;
});
$("#burgRelocate").click(function() {
if ($(this).hasClass('pressed')) {
$(".pressed").removeClass('pressed');
@ -3993,22 +3999,35 @@ function fantasyMap() {
// open in MFCG
$("#burgSeeInMFCG").click(function() {
const id = +elSelected.attr("data-id");
const name = manors[id].name;
const cell = manors[id].cell;
const pop = rn(manors[id].population);
const size = pop > 65 ? 65 : pop < 6 ? 6 : pop;
const s = seed + "" + id;
const hub = cells[cell].crossroad > 2 ? 1 : 0;
const river = cells[cell].river ? 1 : 0;
const coast = cells[cell].port !== undefined ? 1 : 0;
const sec = pop > 40 ? 1 : Math.random() < pop / 100 ? 1 : 0;
const thr = sec && Math.random() < 0.8 ? 1 : 0;
const url = "http://fantasycities.watabou.ru/";
let params = `?name=${name}&size=${size}&seed=${s}&hub=${hub}&random=0&continuous=0`;
params += `&river=${river}&coast=${coast}&citadel=${id&1}&plaza=${sec}&temple=${thr}&walls=${sec}&shantytown=${sec}`;
const win = window.open(url+params, '_blank');
win.focus();
var win;
switch(burgLink.value.toLowerCase()) {
case("default"):
case("generate"):
case("generated"):
case("undefined"):
case(""):
const id = +elSelected.attr("data-id");
const name = manors[id].name;
const cell = manors[id].cell;
const pop = rn(manors[id].population);
const size = pop > 65 ? 65 : pop < 6 ? 6 : pop;
const s = seed + "" + id;
const hub = cells[cell].crossroad > 2 ? 1 : 0;
const river = cells[cell].river ? 1 : 0;
const coast = cells[cell].port !== undefined ? 1 : 0;
const sec = pop > 40 ? 1 : Math.random() < pop / 100 ? 1 : 0;
const thr = sec && Math.random() < 0.8 ? 1 : 0;
const url = "http://fantasycities.watabou.ru/";
let params = `?name=${name}&size=${size}&seed=${s}&hub=${hub}&random=0&continuous=0`;
params += `&river=${river}&coast=${coast}&citadel=${id&1}&plaza=${sec}&temple=${thr}&walls=${sec}&shantytown=${sec}`;
win = window.open(url+params, '_blank');
win.focus();
break;
default:
win = window.open(burgLink.value, '_blank');
win.focus();
break;
}
});
$("#burgAddfromEditor").click(function() {