From 616690bf0b519271ececaae39ce997f45eb7169c Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Thu, 2 May 2019 11:09:29 +0200 Subject: [PATCH] colored poi's --- doc/internal/textures.md | 12 +++ doc/license.md | 4 + mapserver_mod/mapserver/depends.txt | 1 + mapserver_mod/mapserver/poi.lua | 92 ++++++++++-------- .../textures/mapserver_gold_block.png | Bin 0 -> 483 bytes .../mapserver/textures/mapserver_poi.png | Bin 313 -> 0 bytes .../mapserver/textures/mapserver_poi_blue.png | Bin 0 -> 900 bytes .../textures/mapserver_poi_green.png | Bin 0 -> 900 bytes .../textures/mapserver_poi_orange.png | Bin 0 -> 900 bytes .../mapserver/textures/mapserver_poi_red.png | Bin 0 -> 900 bytes .../textures/mapserver_poi_violet.png | Bin 0 -> 891 bytes server/mapobject/poi.go | 6 +- server/mapobject/setup.go | 7 +- server/static/js/overlays/PoiOverlay.js | 19 ++-- 14 files changed, 87 insertions(+), 54 deletions(-) create mode 100644 doc/internal/textures.md create mode 100644 mapserver_mod/mapserver/textures/mapserver_gold_block.png delete mode 100644 mapserver_mod/mapserver/textures/mapserver_poi.png create mode 100644 mapserver_mod/mapserver/textures/mapserver_poi_blue.png create mode 100644 mapserver_mod/mapserver/textures/mapserver_poi_green.png create mode 100644 mapserver_mod/mapserver/textures/mapserver_poi_orange.png create mode 100644 mapserver_mod/mapserver/textures/mapserver_poi_red.png create mode 100644 mapserver_mod/mapserver/textures/mapserver_poi_violet.png 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 0000000000000000000000000000000000000000..170d50be8718aa2af0b56b059c3c14dabd206882 GIT binary patch literal 483 zcmV<90UZ8`P)wEcf3h_0uHu)gtT57VOUz{p~yZ-Zl5zF#6vv z{M|0~*e&tWAo0;3=)VW3kpP{C0GovX{o_3M*eCPXA?wBt<+udMt^m5B0Irq*{N_Xa z-#Yu}H1_2$`r=*J1^xCz?60K%vMB7opF0002qNkl5l)%CBHrlqf!+qEFIk0#K?M2)2+Twdc zb_(+88{+$VU~v+R85T|Ri0%_V5MePofcr|qV*loM2CpoKDWpUXh52C^+_GuIZny?U z5LL&bH%vz904Q^}&4nF>=E)JCG=nXtA%dj$PbK!F3|6$R5h7IlF+dGyB4{ zD@F&Jd`r0RIgdu_v`O4H?HTyvg0W<}T&CD*;zVL5<+DqErr)@AsGY(EaQm0IBUPBM ZcmTcw6ofti%Q^r6002ovPDHLkV1nS^^R)l~ literal 0 HcmV?d00001 diff --git a/mapserver_mod/mapserver/textures/mapserver_poi.png b/mapserver_mod/mapserver/textures/mapserver_poi.png deleted file mode 100644 index f2e92b63fe049ecb645ac7dcbc86951ba041962a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 313 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1SJ1Ryj={W*pj^6T^N)ZtQlVXJli(`D8gCb z5n0T@z;_sg8IR|$NC676mw5WRvOi+u<54$zvdBjXD0Ixz#WBR=cydWWK|)$ungaKq zzrUw1kP>5KV~dWCX1mqE%+6=v`1YaTl64mgm=}uu`T1$yF0li=DM#63<&{~OOfsXt+lUe7k2w)JLS)sdOcf#Mga{p zU3AHG;YFaJUhj78#^oRd(~kh1p+8}_$-J}1b57}YZU!1_GXI?M+%vk}TXeg(8qYax zJnMv3!*ZZX(?yp}7hEu$au8^~30NHH5}^4&L7;YnNqe=MR~gMXW-|Xg(02X49Y8HW zS)G=(x*Z#I+BcXjy=J!Ln%Uwj<|}Slth^0G=F4xIF1%#E?1sh4I~J?%g3!u4W=pRF z#VuALM1Ts+mt99va~o(5$Plo4^X0d|vbQZ(0L8CD6a&5a|NsAog}VxX-U}!R@(Tvi zH~=F%8-rr)#?{#(x+nktStrT4w249g$r&-Lw>RV^POaf6`S&GI`qT=pu+R65*r$C< zl|MS2Ltmyjz)c5eAY+oZyG!YctQo(79L@rd$YKTtZeb8+WSBKa0w~B{;_2(k{+N}C zhgp0+=W21FkU(;xUm1`-0mM>3EC<94pWZAi1X7bcT^vI=t|uoXButq!ZDMK?kdZcV za(F;UP+DqoLU>>(H%G|z3r`X*T;k*6Exl`v(Zr%7a>A|+m=TGZvloUKkeDJimNKdP*@Tqu0fKj@LTpj$O0S;2eXMi=QVeEJQq4CUQ$a3PEpd$~Nl7e8wMs5Z1yT$~ z28Ncp2Bx|OMj?gLZ%Bi!JoH9jHW-BI6Q)oM@o3TJSahhV>M1`ns`P>yMX>*nIJ^5oN$Zz~_71<@H z?Z}rjT@lC)ZjecvqZHF8?~*ANSSKA=D`g%gkT69db&gW{d=LT}7&lQqajF8)z})33 zIm=Yi=PAWak`Hf_0WyHffX+yms*tr2AODYF#gCo2FIq%Tm8>XJ*DrIfu)1*jdUF``{AZJtv0QWcXS6P-KlN5Fx7p znp3zAtOaZcPz%Vwb!tFykmA*Nwt>Gy7_a#vJ)C#V!&-aYjr+rJ6KRTU5U#2<0O$TTo zW0JSKOX-TN8NY!X&H|6fVg?3oVGw3ym^DWND9B#o>Fdh=n3ai#S$sa{YH^^DKyspA z8IV2!#8N;k0>lhEVs>5tQj5)*~zex^K3}#MJ%{LrVK`vG;ag8WRNi0dVN-jzTQVd20hL*Yprn&}3A%+H4 u2F6xK#@Yr(Rt5%#j#z=bhtQClpOTqYiCe?wnN1}?4Gf;HelF{r5}E+QZ7uQu literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..33b6fc892ed958c7dd5a80d31a7a3a3bec041eeb GIT binary patch literal 900 zcmeAS@N?(olHy`uVBq!ia0vp^U^WLckhT0Jzd4X%Nq6*hWMJ6X&;2Kn706de_6YK2 zV5m}MU}$J&VEFkTNWWxYC^cYUc$L7wU^Rn*K|Fs_{82Xs2F9cSpAc7|o^*TBOh=KW zsR}PA=v`{mOt2EV(4cv&O8x&KyF2aLM=I2I6{)PvQhGa4?@E)VFfYrt0_FezV^?P? z@^Z4As8-)ms4_i9?oNj`kdbUFGBHxNKU~IAh3jCM8ql;Gtyhn~6h%C@FpcaUMK=Xl$f!r5;y8r+GpLyOi1L(bgk|4ieAdLes zva>NL)^1##Euwq!|DSb|oJ*S+^q-s&vwC|&UgFdmj*@?00;Nx_;0pVE&xn26w^aF~ z(>e5IngiT)fCe%qdAqxmuE?748_3}-@Q5sCVBi)8VMc~ob0mO*>?NMQuI!IlnRuAR z=X0(W2MP%!C;F8E=@URK1;n7V#gN`J!5BzQ@^o>IY~9&a7+ccShd78q9i4;B-JXpC>2OC7#SE^ z>Kd5p8W@Eb8dw<^TNxQ^8yHy`7#uoc1@az3LvDUbW?Cg~4Vz~+l>jv`c)I$ztaD0e F0sufuQOE!Q literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..3dd7c7d48c99e001bbb67a6f6f76634a331e8e2c GIT binary patch literal 900 zcmeAS@N?(olHy`uVBq!ia0vp^U^WLckhT0Jzd4X%Nq6*hWMJ6X&;2Kn706de_6YK2 zV5m}MU}$J&VEFkTNWWxYC^cYUc$L7wU^Rn*K|Fs_{82Xs2F9cSpAc7|o_!Xo`z%xr zTd1A1(l~CVzRz3@NFK9PzhtX<(n=k|269hZYXG@>P1S(xn|9hja)+79QA>3oI$*AL zz(Vzag&NQ(APGc!ER=xaK)paMC%}dPxj-#I?pbS%Gu9eFL7>PX3pF4Ei25|;fZS6c zD>RN+f~){qcgjlRsHGZA9IE)74OIIvE4Uhv2|zP}S|G*(ZGp3a+93$yu=6&WKm;`8 zvaRM7J1rmrdK2iRi?*6q?X<3e5s-1gMiVHGEOOCC6DSB50cr%AbJ-T81tQU{*yCe zR&Q^}OPpH6QS$Fgp!BH~Tw$N@8L?0MmMVXAI)}bYbAX!;&_Ko{Z+Dl{65)*~zex^K3}#MJ z%{LrVK`vG;ag8WRNi0dVN-jzTQVd20hL*Yprn&}3A%+H42F6xK#@Yr(Rt5%#j#z=b ehtQClpOTqYiCe?wnN202fbewnb6Mw<&;$UCqA5irj4$1rdT!qU-Q4iv|^d# z&;bkW`}TXU*zLJ=vQ^V^$H@o1SMBv$HqE*Ph=79I-51sw z<^v4`YCqz$X0`M5xwc(^2Xm ztKGDGvSrgG%f{3Gn}O)0-^TNS+b#y}xDdGGT;R52zU$8gYz1;J1?>bPAmdEH7N9tU z3lTXRu=Q-f7PuOqMxZ$t0=GkCfu;dvfr3C0U=RUK19Fe~uKWN0{|PCH3qbGrl?3?( z18J;)k)4e}v3BF?Y!Tg)|NpF$@>} z6DLlc93GI8nw$_G6!!6RcxdqRgbNpVIC!}DIImtxyKs@0yT7BS>)PdX1B0H<-fn*n z6QeW(LtigHPhW3y(e=G3-L&ypT&+j#cm+0)xMKTmw{w75V=qon8=`z^%> zkD{JD)6-x{G2*DMsH*I4h~Qb2WVi2;gA~KBO368`pH`Lt9j9928c~vxSdwa$T$Bo= z7>o=IEp-h{bq$O{3=OOdjIE4}wGE7{3=9q(u>$!Hp&>UvB{QuOw}#C#n?N=&c)I$z JtaD0e0sz~0U0whH literal 0 HcmV?d00001 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; },