diff --git a/index.css b/index.css index bec1ad46..1f935c86 100644 --- a/index.css +++ b/index.css @@ -1,3 +1,4 @@ + @font-face { font-family: 'Amatic SC'; font-style: normal; @@ -78,7 +79,6 @@ button, select, a { #rivers { stroke: none; mask: url(#shape); - mask-mode: alpha; cursor: pointer; } @@ -89,7 +89,7 @@ button, select, a { #terrain { mask: url(#shape); - mask-mode: alpha; + mask-mode: alpha; } #hills { @@ -116,7 +116,7 @@ button, select, a { #roads, #trails { mask: url(#shape); - mask-mode: alpha; + mask-mode: alpha; } #swamps { @@ -306,15 +306,11 @@ button.options { } #options input[type="color"], #convertImageDialog input[type="color"] { - width: 38px; - padding: 0; - border: 0; - background: none; - cursor: pointer; -} - -#options input[type="checkbox"] { - cursor: pointer; + width: 38px; + padding: 0; + border: 0; + background: none; + cursor: pointer; } #options input[type="range"] { @@ -323,12 +319,11 @@ button.options { background: #ffffff; top: -2px; position: relative; - -webkit-appearance: none; appearance: none; } -#options input[type="range"]::-webkit-slider-thumb { - -webkit-appearance: none; +#options input[type="range"]::slider-thumb { + appearance: none; border-radius: 15%; width: 10px; height: 10px; @@ -637,22 +632,10 @@ body button.noicon { font-family: monospace; } -.grayscale { - filter: grayscale(1); -} - -.sepia { - filter: sepia(1) saturate(0.8); -} - .tint { filter: sepia(1) hue-rotate(200deg); } -.dingy { - filter: contrast(1) saturate(1.8) sepia(.6); -} - .color-div { width: 32px; height: 12px; @@ -720,12 +703,12 @@ body .ui-dialog-titlebar { background: #e9e9e9; top: -4px; position: relative; - -webkit-appearance: none; + appearance: none; appearance: none; } -.ui-dialog input[type="range"]::-webkit-slider-thumb { - -webkit-appearance: none; +.ui-dialog input[type="range"]::slider-thumb { + appearance: none; border-radius: 15%; width: 10px; height: 10px; @@ -748,7 +731,7 @@ body .ui-dialog-titlebar { opacity: 0.2; } -.ui-dialog .disabled::-webkit-slider-thumb { +.ui-dialog .disabled::slider-thumb { opacity: 0.2; } @@ -793,7 +776,7 @@ div.slider .ui-slider-handle { color: white; } -#activeZoomingLabel { +#layoutCheckboxes { font-style: italic; font-weight: bold; } @@ -1123,4 +1106,31 @@ ul.share-buttons li{ ul.share-buttons img{ width: 16px; +} + +input[type="checkbox"] { + display: none; +} + +.checkbox, .checkbox-label { + margin: 5px; + cursor: pointer; +} + +.checkbox + .checkbox-label:before { + content: ''; + background: #ece6eb; + border-radius: 50%; + display: inline-block; + vertical-align: text-top; + width: 8px; + height: 8px; + padding: 2px; + margin-right: 2px; +} + +.checkbox:checked + .checkbox-label:before { + background: #826473; + border-radius: 50%; + box-shadow: inset 0px 0px 0px 2px #ece6ea; } \ No newline at end of file diff --git a/index.html b/index.html index ce4c455f..c1b81180 100644 --- a/index.html +++ b/index.html @@ -31,8 +31,8 @@ - - + + @@ -40,7 +40,7 @@

Loading...

- + @@ -52,7 +52,19 @@ - + + + + + + + + + + + + + @@ -155,8 +167,12 @@
  • Labels
  • Burgs
  • - - +
    + + + + +

    Select element:

    @@ -249,8 +265,8 @@

    Toggle filters:

    - +
    @@ -763,5 +779,5 @@ Type: no
    - + \ No newline at end of file diff --git a/script.js b/script.js index 5c41d475..0d723eab 100644 --- a/script.js +++ b/script.js @@ -3527,9 +3527,14 @@ function fantasyMap() { for (var i=0; i < compStyle.length; i++) { var key = compStyle[i]; var value = compStyle.getPropertyValue(key); - if (key !== "cursor" && value != defaultStyles.getPropertyValue(key)) { - style += key + ':' + value + ';'; + // Firefox mask hack + if (key === "mask-image" && value !== defaultStyles.getPropertyValue(key)) { + style += "mask-image: url('#shape');"; + continue; } + if (key === "cursor") {continue;} // cursor should be default + if (value === defaultStyles.getPropertyValue(key)) {continue;} + style += key + ':' + value + ';'; } if (style != "") {this.setAttribute('style', style);} }); @@ -3549,7 +3554,6 @@ function fantasyMap() { canvas.width = 3840; // ultraHD canvas.height = rn(3840 * ratio); var img = new Image(); - img.setAttribute('crossOrigin', 'anonymous'); img.src = url; img.onload = function(){ window.URL.revokeObjectURL(url); @@ -3561,7 +3565,7 @@ function fantasyMap() { link.click(); window.setTimeout(function() {window.URL.revokeObjectURL(link.href);}, 5000); }); - canvas.style.opacity = 0; + canvas.style.opacity = 0; canvas.width = mapWidth; canvas.height = mapHeight; } @@ -3571,6 +3575,7 @@ function fantasyMap() { document.body.appendChild(link); link.click(); } + document.body.removeChild(link); console.timeEnd("saveAsImage"); window.setTimeout(function() {window.URL.revokeObjectURL(url);}, 5000); }); @@ -3627,11 +3632,12 @@ function fantasyMap() { // Save in .map format, based on FileSystem API function saveMap() { console.time("saveMap"); - // data convention: 0 - version; 1 - all points; 2 - cells; 3 - manors; 4 - states; 5 - svg; + // data convention: 0 - version; 1 - all points; 2 - cells; 3 - manors; 4 - states; 5 - svg; 6 - options; // size stats: points = 6%, cells = 36%, manors and states = 2%, svg = 56%; var svg_xml = (new XMLSerializer()).serializeToString(svg.node()); var line = "\r\n"; - var data = version + line + JSON.stringify(points) + line + JSON.stringify(cells) + line + JSON.stringify(manors) + line + JSON.stringify(states) + line + svg_xml; + var data = version + line + JSON.stringify(points) + line + JSON.stringify(cells) + line; + data += JSON.stringify(manors) + line + JSON.stringify(states) + line + svg_xml + line + customization; var dataBlob = new Blob([data], {type:"text/plain"}); var dataURL = window.URL.createObjectURL(dataBlob); var link = document.createElement("a"); @@ -3654,7 +3660,7 @@ function fantasyMap() { var dataLoaded = fileLoadedEvent.target.result; var data = dataLoaded.split("\r\n"); - // data convention: 0 - version; 1 - all points; 2 - cells; 3 - manors; 4 - states; 5 - svg; + // data convention: 0 - version; 1 - all points; 2 - cells; 3 - manors; 4 - states; 5 - svg; 6 - options; var mapVersion = data[0]; if (mapVersion !== version) { var message = `The Map version `; @@ -3681,11 +3687,13 @@ function fantasyMap() { svg.remove(); if (mapVersion === "0.52b" || mapVersion === "0.53b") { states = []; // no states data - document.body.insertAdjacentHTML("afterbegin", data[4]); + document.body.insertAdjacentHTML("afterbegin", data[4]); + customization = 0; } else { states = JSON.parse(data[4]); - document.body.insertAdjacentHTML("afterbegin", data[5]); - } + document.body.insertAdjacentHTML("afterbegin", data[5]); + customization = +data[6] || 0; + } svg = d3.select("svg"); // check map size @@ -3701,16 +3709,6 @@ function fantasyMap() { $("#alert").dialog({title: "Map size conflict", buttons: { "Keep": function() { - /* Should not play with scale as it breaks edit, re-save and re-load! - scale = Math.min(mapWidth / nWidth, mapHeight / nHeight); - const difX = (mapWidth - nWidth * scale) / 2; - const difY = (mapHeight - nHeight * scale) / 2; - const transform = d3.zoomIdentity.translate(difX, difY).scale(scale); - svg.transition().duration(2000).call(zoom.transform, transform); - oceanPattern.select("rect").attr("x", -difX).attr("y", -difY).attr("width", mapWidth).attr("height", mapHeight); - oceanLayers.select("rect").attr("x", -difX).attr("y", -difY).attr("width", mapWidth).attr("height", mapHeight); - zoom.scaleExtent([scale, 40]).translateExtent([[-difX, -difY], [mapWidth / scale, mapHeight / scale]]); - */ voronoi = d3.voronoi().extent([[0, 0], [nWidth, nHeight]]); zoom.translateExtent([[0, 0], [nWidth, nHeight]]); applyLoadedData(data); @@ -3787,15 +3785,17 @@ function fantasyMap() { ruler.selectAll(".linear").selectAll("circle.center").call(d3.drag().on("drag", rulerCenterDrag)); // update data - newPoints = [], riversData = [], island = 0, queue = [], customization = 0, elSelected = ""; + newPoints = [], riversData = [], island = 0, queue = [], elSelected = ""; points = JSON.parse(data[1]); cells = JSON.parse(data[2]); land = $.grep(cells, function(e) {return (e.height >= 0.2);}); manors = JSON.parse(data[3]); cells.map(function(e) {newPoints.push(e.data);}); calculateVoronoi(newPoints); - capitalsCount = +$("#regions > path:last").attr("class").slice(6) + 1; - regionsOutput.innerHTML = regionsInput.value = capitalsCount; + if (!customization) { + capitalsCount = +$("#regions > path:last").attr("class").slice(6) + 1; + regionsOutput.innerHTML = regionsInput.value = capitalsCount; + } // restore layers state if (cults.selectAll("path").size() == 0) {$("#toggleCultures").addClass("buttonoff");} else {$("#toggleCultures").removeClass("buttonoff");} @@ -4475,19 +4475,16 @@ function fantasyMap() { }}); } if ($(this).hasClass('radio') && parent === "mapFilters") { - $("svg").removeClass(); + $("svg").attr("filter", ""); if ($(this).hasClass('pressed')) { $("#mapFilters .pressed").removeClass('pressed'); } else { $("#mapFilters .pressed").removeClass('pressed'); $(this).addClass('pressed'); - if (id === "grayscale") {$("svg").addClass("grayscale");} - if (id === "sepia") {$("svg").addClass("sepia");} - if (id === "tint") {$("svg").addClass("tint");} - if (id === "dingy") {$("svg").addClass("dingy");} + $("svg").attr("filter", "url(#filter-" + id + ")"); } return; - } + } if (id === "mapScreenSize") { if ($("body").hasClass("fullscreen")) { mapWidthInput.value = 960; // default width @@ -5840,6 +5837,7 @@ function fantasyMap() { // Options handlers $("input, select").on("input change", function() { var id = this.id; + if (id === "hideLabels") {invokeActiveZooming();} if (id === "styleElementSelect") { var sel = this.value; var el = viewbox.select("#"+sel);