1
0
forked from MTSR/mapserver

colored poi's

This commit is contained in:
NatureFreshMilk 2019-05-02 11:09:29 +02:00
parent d45e1d821b
commit 616690bf0b
14 changed files with 87 additions and 54 deletions

12
doc/internal/textures.md Normal file
View File

@ -0,0 +1,12 @@
# convert
```sh
sudo apt install imagemagick
convert markers-soft.png -crop 36x46+0+0 -resize 28% mapserver_poi_red.png
convert markers-soft.png -crop 36x46+36+0 -resize 28% mapserver_poi_orange.png
convert markers-soft.png -crop 36x46+72+0 -resize 28% mapserver_poi_green.png
convert markers-soft.png -crop 36x46+108+0 -resize 28% mapserver_poi_blue.png
convert markers-soft.png -crop 36x46+144+0 -resize 28% mapserver_poi_violet.png
convert markers-soft.png -crop 36x46+180+0 -resize 28% mapserver_poi_brown.png
```

View File

@ -54,3 +54,7 @@
* minecart_logo.png
** License: CC0
** Source [minecart](https://github.com/joe7575/minecart)
* mapserver_gold_block.png
** License: CC BY-SA 3.0
** Source [minetest_game](https://github.com/minetest/minetest_game)

View File

@ -1,3 +1,4 @@
default
dye
advtrains?
minecart?

View File

@ -20,53 +20,63 @@ local update_formspec = function(meta)
end
local register_poi = function(color)
minetest.register_node("mapserver:poi:" .. color, {
description = "Mapserver POI (" .. color .. ")",
tiles = {
"[combine:16x16:0,0=mapserver_gold_block.png:3,2=mapserver_poi_" .. color .. ".png"
},
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
can_dig = mapserver.can_dig,
after_place_node = mapserver.after_place_node,
minetest.register_node("mapserver:poi", {
description = "Mapserver POI",
tiles = {
"mapserver_poi.png"
},
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
can_dig = mapserver.can_dig,
after_place_node = mapserver.after_place_node,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("name", "<unconfigured>")
meta:set_string("category", "main")
meta:set_string("url", "")
meta:set_string("name", "<unconfigured>")
meta:set_string("category", "main")
meta:set_string("url", "")
update_formspec(meta)
end,
update_formspec(meta)
end,
on_receive_fields = function(pos, formname, fields, sender)
on_receive_fields = function(pos, formname, fields, sender)
if not mapserver.can_interact(pos, sender) then
return
end
if not mapserver.can_interact(pos, sender) then
return
local meta = minetest.get_meta(pos)
if fields.save then
meta:set_string("name", fields.name)
meta:set_string("url", fields.url)
meta:set_string("category", fields.category)
end
update_formspec(meta)
end
local meta = minetest.get_meta(pos)
if fields.save then
meta:set_string("name", fields.name)
meta:set_string("url", fields.url)
meta:set_string("category", fields.category)
end
update_formspec(meta)
end
})
if mapserver.enable_crafting then
minetest.register_craft({
output = 'mapserver:poi',
recipe = {
{"", "dye:blue", ""},
{"default:paper", "default:goldblock", "default:paper"},
{"", "default:glass", ""}
}
})
if mapserver.enable_crafting then
minetest.register_craft({
output = 'mapserver:poi_' .. color,
recipe = {
{"", "dye:" .. color, ""},
{"default:paper", "default:goldblock", "default:paper"},
{"", "default:glass", ""}
}
})
end
end
register_poi("blue")
register_poi("green")
register_poi("orange")
register_poi("red")
register_poi("purple")
-- default poi was always blue
minetest.register_alias("mapserver:poi", "mapserver:poi_blue")

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

View File

@ -5,7 +5,9 @@ import (
"mapserver/mapobjectdb"
)
type PoiBlock struct{}
type PoiBlock struct {
Color string
}
func (this *PoiBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
md := block.Metadata.GetMetadata(x, y, z)
@ -15,6 +17,8 @@ func (this *PoiBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *
o.Attributes["category"] = md["category"]
o.Attributes["url"] = md["url"]
o.Attributes["owner"] = md["owner"]
o.Attributes["icon"] = md["icon"]
o.Attributes["color"] = this.Color
return o
}

View File

@ -13,7 +13,12 @@ func Setup(ctx *app.App) {
//mapserver stuff
if ctx.Config.MapObjects.MapserverPOI {
l.AddMapObject("mapserver:poi", &PoiBlock{})
l.AddMapObject("mapserver:poi", &PoiBlock{Color: "blue"})
l.AddMapObject("mapserver:poi_blue", &PoiBlock{Color: "blue"})
l.AddMapObject("mapserver:poi_green", &PoiBlock{Color: "green"})
l.AddMapObject("mapserver:poi_orange", &PoiBlock{Color: "orange"})
l.AddMapObject("mapserver:poi_red", &PoiBlock{Color: "red"})
l.AddMapObject("mapserver:poi_purple", &PoiBlock{Color: "purple"})
}
if ctx.Config.MapObjects.MapserverTrainline {

View File

@ -1,22 +1,19 @@
/* exported PoiOverlay */
/* globals AbstractIconOverlay: true */
var PoiIcon = L.icon({
iconUrl: 'css/images/marker-icon.png',
shadowUrl: 'css/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
tooltipAnchor: [16, -28],
shadowSize: [41, 41]
});
var PoiOverlay = AbstractIconOverlay.extend({
initialize: function(wsChannel, layerMgr) {
AbstractIconOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "poi", PoiIcon);
},
getIcon: function(obj){
return L.AwesomeMarkers.icon({
icon: obj.attributes.icon || "home",
prefix: "fa",
markerColor: obj.attributes.color || "blue"
});
},
getMaxDisplayedZoom: function(){
return 5;
},