mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 18:11:24 +01:00
0.555b
Hotfix for Countries Editor
This commit is contained in:
parent
c57a6a883a
commit
5b008d8e13
3 changed files with 29 additions and 15 deletions
BIN
index.css
BIN
index.css
Binary file not shown.
|
|
@ -21,8 +21,8 @@
|
||||||
<script src="libs/polylabel.js"></script>
|
<script src="libs/polylabel.js"></script>
|
||||||
<script src="libs/quantize.js" defer></script>
|
<script src="libs/quantize.js" defer></script>
|
||||||
<script src="libs/d3-hexbin.v0.2.min.js" defer></script>
|
<script src="libs/d3-hexbin.v0.2.min.js" defer></script>
|
||||||
<link rel="stylesheet" type="text/css" href="index.css?version=0.554b"/>
|
<link rel="stylesheet" type="text/css" href="index.css?version=0.555b"/>
|
||||||
<link rel="stylesheet" type="text/css" href="icons.css?version=0.554b"/>
|
<link rel="stylesheet" type="text/css" href="icons.css?version=0.555b"/>
|
||||||
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/>
|
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/>
|
||||||
</head>
|
</head>
|
||||||
<body class="fullscreen">
|
<body class="fullscreen">
|
||||||
|
|
@ -753,5 +753,5 @@
|
||||||
Type: <span id="feature">no</span>
|
Type: <span id="feature">no</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript" src="script.js?version=0.554b"></script>
|
<script type="text/javascript" src="script.js?version=0.555b"></script>
|
||||||
</body>
|
</body>
|
||||||
38
script.js
38
script.js
|
|
@ -2416,7 +2416,6 @@ function fantasyMap() {
|
||||||
// calculate Markov's chain from real data
|
// calculate Markov's chain from real data
|
||||||
function calculateChains() {
|
function calculateChains() {
|
||||||
var vowels = "aeiouy";
|
var vowels = "aeiouy";
|
||||||
//var digraphs = ["ai","ay","ea","ee","ei","ey","ie","oa","oo","ow","ue","ch","ng","ph","sh","th","wh"];
|
|
||||||
for (var l = 0; l < cultures.length; l++) {
|
for (var l = 0; l < cultures.length; l++) {
|
||||||
var probs = []; // Coleshill -> co les hil l-com
|
var probs = []; // Coleshill -> co les hil l-com
|
||||||
var inline = manorNames[l].join(" ").toLowerCase();
|
var inline = manorNames[l].join(" ").toLowerCase();
|
||||||
|
|
@ -3001,8 +3000,9 @@ function fantasyMap() {
|
||||||
console.error("There is already a burg in this cell. Select a free cell");
|
console.error("There is already a burg in this cell. Select a free cell");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
burgs.append("circle").attr("r", .5).attr("stroke-width", .12).attr("cx", x).attr("cy", y).call(d3.drag().on("start", elementDrag));
|
var i = manors.length;
|
||||||
labels.select("#towns").append("text").attr("x", x).attr("y", y).attr("dy", -0.7).text(name).on("click", editLabel);
|
burgs.append("circle").attr("id", "manorIcon"+i).attr("r", .5).attr("stroke-width", .12).attr("cx", x).attr("cy", y).call(d3.drag().on("start", elementDrag));
|
||||||
|
labels.select("#towns").append("text").attr("id", "manorLabel"+i).attr("x", x).attr("y", y).attr("dy", -0.7).text(name).on("click", editLabel);
|
||||||
var region, state;
|
var region, state;
|
||||||
if ($("#burgAdd").hasClass("pressed")) {
|
if ($("#burgAdd").hasClass("pressed")) {
|
||||||
state = +$("#burgsEditor").attr("data-state");
|
state = +$("#burgsEditor").attr("data-state");
|
||||||
|
|
@ -3016,7 +3016,6 @@ function fantasyMap() {
|
||||||
region = cells[cell].region;
|
region = cells[cell].region;
|
||||||
state = region === "neutral" ? states.length - 1 : region;
|
state = region === "neutral" ? states.length - 1 : region;
|
||||||
}
|
}
|
||||||
var i = manors.length;
|
|
||||||
cells[cell].manor = i;
|
cells[cell].manor = i;
|
||||||
var score = cells[cell].score;
|
var score = cells[cell].score;
|
||||||
if (score <= 0) {score = rn(Math.random(), 2);}
|
if (score <= 0) {score = rn(Math.random(), 2);}
|
||||||
|
|
@ -3030,6 +3029,7 @@ function fantasyMap() {
|
||||||
if (!shift) {
|
if (!shift) {
|
||||||
$("#"+brush).removeClass("pressed");
|
$("#"+brush).removeClass("pressed");
|
||||||
$("#burgAdd").removeClass("pressed");
|
$("#burgAdd").removeClass("pressed");
|
||||||
|
viewbox.style("cursor", "default");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (brush.includes("selectCapital")) {
|
if (brush.includes("selectCapital")) {
|
||||||
|
|
@ -3067,8 +3067,8 @@ function fantasyMap() {
|
||||||
if (cells[cell].port) {score *= 3;} // port-capital
|
if (cells[cell].port) {score *= 3;} // port-capital
|
||||||
var population = rn(score, 1);
|
var population = rn(score, 1);
|
||||||
manors.push({i, cell, x, y, region: state, culture, name, population});
|
manors.push({i, cell, x, y, region: state, culture, name, population});
|
||||||
burgs.append("circle").attr("r", 1).attr("stroke-width", .24).attr("cx", x).attr("cy", y).call(d3.drag().on("start", elementDrag));
|
burgs.append("circle").attr("id", "manorIcon"+i).attr("r", 1).attr("stroke-width", .24).attr("cx", x).attr("cy", y).call(d3.drag().on("start", elementDrag));
|
||||||
capitals.append("text").attr("id", "manorLabel"+i).attr("x", x).attr("y", y).attr("dy", -1.3).text(name).on("click", editLabel);
|
capitals.append("text").attr("id", "manorLabel"+i).attr("id", "manorLabel"+i).attr("x", x).attr("y", y).attr("dy", -1.3).text(name).on("click", editLabel);
|
||||||
}
|
}
|
||||||
cells[cell].region = state;
|
cells[cell].region = state;
|
||||||
cells[cell].neighbors.map(function(n) {
|
cells[cell].neighbors.map(function(n) {
|
||||||
|
|
@ -3833,7 +3833,7 @@ function fantasyMap() {
|
||||||
|
|
||||||
// Hotkeys
|
// Hotkeys
|
||||||
d3.select("body").on("keydown", function() {
|
d3.select("body").on("keydown", function() {
|
||||||
if ($(".ui-dialog").is(":visible")) {return;}
|
//if ($(".ui-dialog").is(":visible")) {return;}
|
||||||
switch(d3.event.keyCode) {
|
switch(d3.event.keyCode) {
|
||||||
case 16: // Shift - hold to continue adding elements on click
|
case 16: // Shift - hold to continue adding elements on click
|
||||||
shift = true;
|
shift = true;
|
||||||
|
|
@ -4033,6 +4033,11 @@ function fantasyMap() {
|
||||||
if (s === "neutral") {s = states.length - 1;}
|
if (s === "neutral") {s = states.length - 1;}
|
||||||
recalculateStateData(s);
|
recalculateStateData(s);
|
||||||
});
|
});
|
||||||
|
var last = states.length - 1;
|
||||||
|
if (states[last].color === "neutral" && states[last].cells === 0) {
|
||||||
|
$("#state" + last).remove();
|
||||||
|
states.splice(-1);
|
||||||
|
}
|
||||||
$("#countriesManuallyCancel").click();
|
$("#countriesManuallyCancel").click();
|
||||||
if (changedStates.length) {editCountries();}
|
if (changedStates.length) {editCountries();}
|
||||||
}
|
}
|
||||||
|
|
@ -4183,7 +4188,14 @@ function fantasyMap() {
|
||||||
}})
|
}})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (id === "changeCapital") {$(this).toggleClass("pressed");}
|
if (id === "changeCapital") {
|
||||||
|
if ($(this).hasClass("pressed")) {
|
||||||
|
$(this).removeClass("pressed")
|
||||||
|
} else {
|
||||||
|
$(".pressed").removeClass("pressed");
|
||||||
|
$(this).addClass("pressed");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (id === "regenerateBurgNames") {
|
if (id === "regenerateBurgNames") {
|
||||||
var s = +$("#burgsEditor").attr("data-state");
|
var s = +$("#burgsEditor").attr("data-state");
|
||||||
$(".burgName").each(function(e, i) {
|
$(".burgName").each(function(e, i) {
|
||||||
|
|
@ -4201,7 +4213,7 @@ function fantasyMap() {
|
||||||
$("#state"+s+" > .stateCapital").val(manors[c].name);
|
$("#state"+s+" > .stateCapital").val(manors[c].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (id === "burgAdd") {$("#addBurg").click(); $(this).toggleClass("pressed");}
|
if (id === "burgAdd") {$("#addBurg").click();}
|
||||||
if (id === "toggleScaleBar") {$("#scaleBar").toggleClass("hidden");}
|
if (id === "toggleScaleBar") {$("#scaleBar").toggleClass("hidden");}
|
||||||
if (id === "addRuler") {
|
if (id === "addRuler") {
|
||||||
$("#ruler").show();
|
$("#ruler").show();
|
||||||
|
|
@ -4369,13 +4381,15 @@ function fantasyMap() {
|
||||||
}
|
}
|
||||||
if ($(this).hasClass('radio') && (parent === "addFeature" || parent === "brushesButtons")) {
|
if ($(this).hasClass('radio') && (parent === "addFeature" || parent === "brushesButtons")) {
|
||||||
if ($(this).hasClass('pressed')) {
|
if ($(this).hasClass('pressed')) {
|
||||||
$(".pressed").removeClass('pressed');
|
$(this).removeClass('pressed');
|
||||||
viewbox.style("cursor", "default").on(".drag", null);;
|
viewbox.style("cursor", "default").on(".drag", null);;
|
||||||
$("#brushRadiusLabel, #brushRadius").attr("disabled", true).addClass("disabled");
|
$("#brushRadiusLabel, #brushRadius").attr("disabled", true).addClass("disabled");
|
||||||
|
if (id === "addBurg") {$("#burgAdd").removeClass("pressed");}
|
||||||
} else {
|
} else {
|
||||||
$(".pressed").removeClass('pressed');
|
$(".pressed").removeClass('pressed');
|
||||||
$(this).addClass('pressed');
|
$(this).addClass('pressed');
|
||||||
viewbox.style("cursor", "crosshair");
|
viewbox.style("cursor", "crosshair");
|
||||||
|
if (id === "addBurg") {$("#burgAdd").addClass("pressed");}
|
||||||
if (id.slice(0,5) === "brush" && id !== "brushRange" && id !== "brushTrough") {
|
if (id.slice(0,5) === "brush" && id !== "brushRange" && id !== "brushTrough") {
|
||||||
viewbox.call(drag);
|
viewbox.call(drag);
|
||||||
}
|
}
|
||||||
|
|
@ -5305,15 +5319,15 @@ function fantasyMap() {
|
||||||
if (b.i !== capital) {el.append('<span title="Remove burg" class="icon-trash-empty"></span>');}
|
if (b.i !== capital) {el.append('<span title="Remove burg" class="icon-trash-empty"></span>');}
|
||||||
el.attr("data-burg", b.name).attr("data-culture", cultures[b.culture]).attr("data-population", b.population).attr("data-type", type);
|
el.attr("data-burg", b.name).attr("data-culture", cultures[b.culture]).attr("data-population", b.population).attr("data-type", type);
|
||||||
});
|
});
|
||||||
var color = '<input title="Country color. Click to change" type="color" class="stateColor" value="' + states[s].color + '"/>';
|
|
||||||
if (!$("#burgsEditor").is(":visible")) {
|
if (!$("#burgsEditor").is(":visible")) {
|
||||||
$("#burgsEditor").dialog({
|
$("#burgsEditor").dialog({
|
||||||
title: "Burgs of " + states[s].name,
|
title: "Burgs of " + states[s].name,
|
||||||
minHeight: "auto", width: "auto",
|
minHeight: "auto", width: "auto",
|
||||||
position: {my: "right bottom", at: "right-10 bottom-10", of: "svg"}
|
position: {my: "right bottom", at: "right-10 bottom-10", of: "svg"}
|
||||||
});
|
});
|
||||||
|
var color = '<input title="Country color. Click to change" type="color" class="stateColor" value="' + states[s].color + '"/>';
|
||||||
|
if (region !== "neutral") {$("div[aria-describedby='burgsEditor'] .ui-dialog-title").prepend(color);}
|
||||||
}
|
}
|
||||||
if (region !== "neutral") {$("div[aria-describedby='burgsEditor'] .ui-dialog-title").prepend(color);}
|
|
||||||
// populate total line on footer
|
// populate total line on footer
|
||||||
burgsFooterBurgs.innerHTML = burgs.length;
|
burgsFooterBurgs.innerHTML = burgs.length;
|
||||||
burgsFooterCulture.innerHTML = $("#burgsBody div:first-child .burgCulture").text();
|
burgsFooterCulture.innerHTML = $("#burgsBody div:first-child .burgCulture").text();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue