1
0
forked from MTSR/mapserver

label wip

This commit is contained in:
Thomas Rudin 2019-04-04 21:19:25 +02:00
parent 40bde3790a
commit fb782ffbaf
3 changed files with 21 additions and 10 deletions

View File

@ -1,6 +1,6 @@
mapserver.can_dig = function(pos, player)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
return player and player:get_player_name() == owner

View File

@ -41,7 +41,7 @@ minetest.register_node("mapserver:label", {
meta:set_string("text", "")
meta:set_string("direction", "0")
meta:set_string("size", "1")
meta:set_string("size", "20")
meta:set_string("color", "rgb(0,0,0)")
update_formspec(meta)

View File

@ -11,6 +11,10 @@ var LabelIcon = L.Icon.extend({
options = this.options;
div.innerHTML = options.html || "";
div.style.width = "200px";
div.style.height = "200px";
div.style.marginLeft = "-100px";
div.style.marginTop = "-175px";
return div;
}
@ -23,20 +27,27 @@ var LabelOverlay = AbstractIconOverlay.extend({
getIcon: function(lbl){
var height = 200;
var width = 200;
var fontSize = Math.min(lbl.attributes.size, 20);
const html = `
<svg height='30' width='100'>
<text x='0' y='15'>${lbl.attributes.text}</text>
<svg height='${height}' width='${width}' text-anchor='middle' font-size='${fontSize}px'>
<text x='${width/2}' y='${height/2}'
fill='${lbl.attributes.color}'
dominant-baseline="central"
transform="rotate(${lbl.attributes.direction}, 100, 100)">
${lbl.attributes.text}
</text>
</svg>
`;
return new LabelIcon({
iconAnchor: [15, 50],
iconSize: [30, 100],
html: html
html: html,
height: height,
width: width
});
},
createPopup: function(lbl){
return "<p>" + lbl.attributes.text + "</p>";
}
createPopup: function(lbl){}
});