diff --git a/doc/internal/textures.md b/doc/internal/textures.md new file mode 100644 index 0000000..03ba15f --- /dev/null +++ b/doc/internal/textures.md @@ -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 +``` diff --git a/doc/license.md b/doc/license.md index ecd8ee7..8126d51 100644 --- a/doc/license.md +++ b/doc/license.md @@ -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) diff --git a/mapserver_mod/mapserver/depends.txt b/mapserver_mod/mapserver/depends.txt index 55e2cc4..110cdd8 100644 --- a/mapserver_mod/mapserver/depends.txt +++ b/mapserver_mod/mapserver/depends.txt @@ -1,3 +1,4 @@ default +dye advtrains? minecart? diff --git a/mapserver_mod/mapserver/poi.lua b/mapserver_mod/mapserver/poi.lua index 7a1a5d4..c6df8d6 100644 --- a/mapserver_mod/mapserver/poi.lua +++ b/mapserver_mod/mapserver/poi.lua @@ -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", "") + meta:set_string("category", "main") + meta:set_string("url", "") - meta:set_string("name", "") - 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") diff --git a/mapserver_mod/mapserver/textures/mapserver_gold_block.png b/mapserver_mod/mapserver/textures/mapserver_gold_block.png new file mode 100644 index 0000000..170d50b Binary files /dev/null and b/mapserver_mod/mapserver/textures/mapserver_gold_block.png differ diff --git a/mapserver_mod/mapserver/textures/mapserver_poi.png b/mapserver_mod/mapserver/textures/mapserver_poi.png deleted file mode 100644 index f2e92b6..0000000 Binary files a/mapserver_mod/mapserver/textures/mapserver_poi.png and /dev/null differ diff --git a/mapserver_mod/mapserver/textures/mapserver_poi_blue.png b/mapserver_mod/mapserver/textures/mapserver_poi_blue.png new file mode 100644 index 0000000..cbc0d2c Binary files /dev/null and b/mapserver_mod/mapserver/textures/mapserver_poi_blue.png differ diff --git a/mapserver_mod/mapserver/textures/mapserver_poi_green.png b/mapserver_mod/mapserver/textures/mapserver_poi_green.png new file mode 100644 index 0000000..48421c8 Binary files /dev/null and b/mapserver_mod/mapserver/textures/mapserver_poi_green.png differ diff --git a/mapserver_mod/mapserver/textures/mapserver_poi_orange.png b/mapserver_mod/mapserver/textures/mapserver_poi_orange.png new file mode 100644 index 0000000..33b6fc8 Binary files /dev/null and b/mapserver_mod/mapserver/textures/mapserver_poi_orange.png differ diff --git a/mapserver_mod/mapserver/textures/mapserver_poi_red.png b/mapserver_mod/mapserver/textures/mapserver_poi_red.png new file mode 100644 index 0000000..3dd7c7d Binary files /dev/null and b/mapserver_mod/mapserver/textures/mapserver_poi_red.png differ diff --git a/mapserver_mod/mapserver/textures/mapserver_poi_violet.png b/mapserver_mod/mapserver/textures/mapserver_poi_violet.png new file mode 100644 index 0000000..2c94eee Binary files /dev/null and b/mapserver_mod/mapserver/textures/mapserver_poi_violet.png differ diff --git a/server/mapobject/poi.go b/server/mapobject/poi.go index 259bc61..666eb30 100644 --- a/server/mapobject/poi.go +++ b/server/mapobject/poi.go @@ -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 } diff --git a/server/mapobject/setup.go b/server/mapobject/setup.go index ddf016f..ab1da40 100644 --- a/server/mapobject/setup.go +++ b/server/mapobject/setup.go @@ -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 { diff --git a/server/static/js/overlays/PoiOverlay.js b/server/static/js/overlays/PoiOverlay.js index 853733c..1f5146d 100644 --- a/server/static/js/overlays/PoiOverlay.js +++ b/server/static/js/overlays/PoiOverlay.js @@ -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; },