From 5d7ba84d2cffbab86a4d61688f6fc4a25040b786 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Tue, 14 May 2019 09:01:52 +0200 Subject: [PATCH] atm overlay --- doc/license.md | 43 ++++++++++++++---------- server/mapobject/atm.go | 20 ++++++++++- server/mapobject/setup.go | 6 +++- server/static/js/Overlaysetup.js | 7 ++++ server/static/js/overlays/ATMOverlay.js | 40 ++++++++++++++++++++++ server/static/manifest.js | 1 + server/static/pics/atm2_front.png | Bin 0 -> 235 bytes server/static/pics/atm3_front.png | Bin 0 -> 222 bytes server/static/pics/atm_front.png | Bin 0 -> 272 bytes server/static/pics/atm_front_wt.png | Bin 0 -> 356 bytes 10 files changed, 97 insertions(+), 20 deletions(-) create mode 100644 server/static/js/overlays/ATMOverlay.js create mode 100644 server/static/pics/atm2_front.png create mode 100644 server/static/pics/atm3_front.png create mode 100644 server/static/pics/atm_front.png create mode 100644 server/static/pics/atm_front_wt.png diff --git a/doc/license.md b/doc/license.md index 8126d51..ea1fb14 100644 --- a/doc/license.md +++ b/doc/license.md @@ -11,31 +11,31 @@ * sam.png * heart.png * default_tool_mesepick.png -** License: CC BY-SA 3.0 -** Source: [minetest_game](https://github.com/minetest/minetest_game) + * License: CC BY-SA 3.0 + * Source: [minetest_game](https://github.com/minetest/minetest_game) * travelnet_inv.png -** License: CC BY-SA 3.0 -** Source: [travelnet](https://github.com/Sokomine/travelnet) + * License: CC BY-SA 3.0 + * Source: [travelnet](https://github.com/Sokomine/travelnet) * technic_admin_anchor.png * technic_hv_nuclear_reactor_core.png * technic_water_mill_top_active.png -** LGPL, V2 -** Source: [technic](https://github.com/minetest-mods/technic) + * LGPL, V2 + * Source: [technic](https://github.com/minetest-mods/technic) * lcd_lcd.png -** WTFPL -** Source: [digilines](https://github.com/minetest-mods/digilines) + * WTFPL + * Source: [digilines](https://github.com/minetest-mods/digilines) * jeija_luacontroller_top.png * jeija_luacontroller_burnt_top.png -** CC-BY-SA-3.0 -** Source [mesecons](https://github.com/minetest-mods/mesecons) + * CC-BY-SA-3.0 + * Source [mesecons](https://github.com/minetest-mods/mesecons) * digiterms_beige_front.png -** License: CC BY-SA 3.0 -** Source [digiterms](https://github.com/Pyrollo/digiterms) + * License: CC BY-SA 3.0 + * Source [digiterms](https://github.com/Pyrollo/digiterms) * advtrains_detailed_engine_steam_inv.png @@ -48,13 +48,20 @@ * advtrains_wagon_japan_inv.png * advtrains_wagon_tank_inv.png * advtrains_wagon_wood_inv.png -** License: CC BY-SA 3.0 -** Source [advtrains](http://advtrains.bleipb.de/) + * License: CC BY-SA 3.0 + * Source [advtrains](http://advtrains.bleipb.de/) * minecart_logo.png -** License: CC0 -** Source [minecart](https://github.com/joe7575/minecart) + * 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) + * License: CC BY-SA 3.0 + * Source [minetest_game](https://github.com/minetest/minetest_game) + +* atm_front_wt.png +* atm_front.png +* atm2_front.png +* atm3_front.png + * WTFPL + * Source: http://git.gpcf.eu/?p=atm.git;a=summary diff --git a/server/mapobject/atm.go b/server/mapobject/atm.go index 031a3e7..2c02458 100644 --- a/server/mapobject/atm.go +++ b/server/mapobject/atm.go @@ -8,5 +8,23 @@ import ( type ATM struct{} func (this *ATM) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject { - return mapobjectdb.NewMapObject(block.Pos, x, y, z, "atm") + nodename := block.GetNodeName(x, y, z) + + o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "atm") + + if nodename == "atm:wtt" { + o.Attributes["type"] = "wiretransfer" + + } else if nodename == "atm:atm2" { + o.Attributes["type"] = "atm2" + + } else if nodename == "atm:atm3" { + o.Attributes["type"] = "atm3" + + } else { + o.Attributes["type"] = "atm" + + } + + return o } diff --git a/server/mapobject/setup.go b/server/mapobject/setup.go index 5e4a5cd..dc98f99 100644 --- a/server/mapobject/setup.go +++ b/server/mapobject/setup.go @@ -147,7 +147,11 @@ func Setup(ctx *app.App) { } if ctx.Config.MapObjects.ATM { - l.AddMapObject("atm:atm", &ATM{}) + atm := &ATM{} + l.AddMapObject("atm:atm", atm) + l.AddMapObject("atm:atm2", atm) + l.AddMapObject("atm:atm3", atm) + l.AddMapObject("atm:wtt", atm) } //locator diff --git a/server/static/js/Overlaysetup.js b/server/static/js/Overlaysetup.js index c0013d8..4de1aa1 100644 --- a/server/static/js/Overlaysetup.js +++ b/server/static/js/Overlaysetup.js @@ -142,4 +142,11 @@ function Overlaysetup(cfg, map, overlays, wsChannel, layerMgr){ map.addLayer(overlays.Minecart); } } + + if (cfg.mapobjects.atm) { + overlays.ATM = new ATMOverlay(wsChannel, layerMgr); + if (cfg.defaultoverlays.indexOf("atm") >= 0) { + map.addLayer(overlays.ATM); + } + } } diff --git a/server/static/js/overlays/ATMOverlay.js b/server/static/js/overlays/ATMOverlay.js new file mode 100644 index 0000000..20f175d --- /dev/null +++ b/server/static/js/overlays/ATMOverlay.js @@ -0,0 +1,40 @@ +/* exported ATMOverlay */ +/* globals AbstractIconOverlay: true */ + + +var ATMOverlay = AbstractIconOverlay.extend({ + initialize: function(wsChannel, layerMgr) { + AbstractIconOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "atm"); + }, + + getMaxDisplayedZoom: function(){ + return 10; + }, + + getIcon: function(obj){ + var img = "pics/atm_front.png" + + if (obj.attributes.type == "wiretransfer") + img = "pics/atm_front.png"; + else if (obj.attributes.type == "atm2") + img = "pics/atm2_front.png"; + else if (obj.attributes.type == "atm3") + img = "pics/atm3_front.png"; + + L.icon({ + iconUrl: img, + iconSize: [16, 16], + iconAnchor: [8, 8], + popupAnchor: [0, -8] + }); + }, + + createPopup: function(obj){ + var title = "ATM"; + + if (obj.attributes.type == "wiretransfer") + title = "Wiretransfer"; + + return "

" + title + "

"; + } +}); diff --git a/server/static/manifest.js b/server/static/manifest.js index 2e5e0bc..59b5d26 100644 --- a/server/static/manifest.js +++ b/server/static/manifest.js @@ -20,6 +20,7 @@ "/js/search/SearchInput.js", "/js/overlays/AbstractIconOverlay.js", "/js/overlays/AbstractGeoJsonOverlay.js", + "/js/overlays/ATMOverlay.js", "/js/overlays/TravelnetOverlay.js", "/js/overlays/ShopOverlay.js", "/js/overlays/PoiOverlay.js", diff --git a/server/static/pics/atm2_front.png b/server/static/pics/atm2_front.png new file mode 100644 index 0000000000000000000000000000000000000000..6675aef236ecebbc543d8934d198a5a68decee4e GIT binary patch literal 235 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPE^3h)VW1=31NN~g5=Piei8ny>l) z|Np((EEPae#w2fd7lsa2Sq~tGv%n*=n1O*?7=#%aX3dcR3bL1Y`ns||hT|;+&tGo0?a`;9QiNSdyBeP@Y+mq2TW68xY>eCk|9(<>}%W!f`#hppl79 zT#Q{ItuV2mfWfGdg*oO_BO^zILr;K$Ln;eb*Q`wzD;2s~k~$JrG)i`CkmX`HbW{5N UKZmDGKvNhzUHx3vIVCg!002HeHUIzs literal 0 HcmV?d00001 diff --git a/server/static/pics/atm3_front.png b/server/static/pics/atm3_front.png new file mode 100644 index 0000000000000000000000000000000000000000..af81ec9df33f35fffc2b3932dc8ca6cf51b22f14 GIT binary patch literal 222 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPE^3h)VW1=31NN~g5=PiejR|CZtZ z|Nl$7?t)}F3p^r=85p>QL70(Y)*K0-AbW|YuPggQ9)1A}BY(q-w}C>EC9V-A&iT2y zsd*&~&PAz-C8;S2<(VZJ3hti10pX2&;y^`Ko-U3d9M_Wz8kyL{#n=_n3KI(o7>pWO zm}5>gGIB&X^aLn4q_S{z&DvzKQlXnAsUu-Uqh!YhSuTb{H>L0Yb9l-GG=;&_)z4*} HQ$iB}3lKi> literal 0 HcmV?d00001 diff --git a/server/static/pics/atm_front.png b/server/static/pics/atm_front.png new file mode 100644 index 0000000000000000000000000000000000000000..8aac1882fcf01472f987df07c5d95cc0bb7bde2c GIT binary patch literal 272 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#0h<^fo1oaWXZwLdk|nMYCC>S|xv6<249-QVi6yBi3gww484B*6z5(HleBwYw zU7jwEAsXkCb22g#6j%)$HFj)clW-7oHx!BFSSK>GQSG$Hs>u--a*r@%Y|;^U_5c6> zh)`oAqonU9nSM6y?pEaS#hFm-4$zJr6(lZ5DPoew1(rRO3GD%r7!%N zZY)@{h9_~(wYueU)%j|i1WKlt`wQ{%U~goC2@b}%TJm!(zLb_v`~Q7=YG7!x+Nmv%w$^WRPEQEF`n7LW*6QN4 zYZr`P`nZ)8>|Mp@&vxxP&(E)1!H*W5i~O;?#?@Gac`ai@q)kUh&k<(k`pNlPN_#6c z*gTvX&l^MrK7XU9-muS2*eCXVnFU{#N#pz@iarz0{B6C+^4-_jqCNYf`3<{iN1mNz tNsao-FY$OeOA@bG-FZuoe}c?=7`b=MQOV