From 3f531d65c042f69e0511a1cb222a753482fc6ebb Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Fri, 8 Feb 2019 15:40:30 +0100 Subject: [PATCH] switching station object --- server/mapobject/setup.go | 1 + server/mapobject/technicswitch.go | 20 +++++++++++++++++ server/static/index.html | 1 + server/static/js/main.js | 1 + .../js/overlays/TechnicSwitchOverlay.js | 22 +++++++++++++++++++ 5 files changed, 45 insertions(+) create mode 100644 server/mapobject/technicswitch.go create mode 100644 server/static/js/overlays/TechnicSwitchOverlay.js diff --git a/server/mapobject/setup.go b/server/mapobject/setup.go index 9dae1a9..d5bab03 100644 --- a/server/mapobject/setup.go +++ b/server/mapobject/setup.go @@ -134,6 +134,7 @@ func Setup(ctx *app.App) { l.AddMapObject("technic:quarry", &QuarryBlock{}) l.AddMapObject("technic:hv_nuclear_reactor_core_active", &NuclearReactorBlock{}) l.AddMapObject("technic:admin_anchor", &TechnicAnchorBlock{}) + l.AddMapObject("technic:switching_station", &TechnicSwitchBlock{}) //digilines l.AddMapObject("digilines:lcd", &DigilineLcdBlock{}) diff --git a/server/mapobject/technicswitch.go b/server/mapobject/technicswitch.go new file mode 100644 index 0000000..deda9c9 --- /dev/null +++ b/server/mapobject/technicswitch.go @@ -0,0 +1,20 @@ +package mapobject + +import ( + "mapserver/mapblockparser" + "mapserver/mapobjectdb" +) + +type TechnicSwitchBlock struct{} + +func (this *TechnicSwitchBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject { + md := block.Metadata.GetMetadata(x, y, z) + + o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "technicswitch") + o.Attributes["active"] = md["active"] + o.Attributes["channel"] = md["channel"] + o.Attributes["supply"] = md["supply"] + o.Attributes["demand"] = md["demand"] + + return o +} diff --git a/server/static/index.html b/server/static/index.html index 8cd86f9..556a0c1 100644 --- a/server/static/index.html +++ b/server/static/index.html @@ -43,6 +43,7 @@ + diff --git a/server/static/js/main.js b/server/static/js/main.js index 00e58a9..0427b77 100644 --- a/server/static/js/main.js +++ b/server/static/js/main.js @@ -39,6 +39,7 @@ api.getConfig().then(function(cfg){ overlays["Lua Controller"] = new LuacontrollerOverlay(wsChannel, layerMgr); overlays["Technic Anchor"] = new TechnicAnchorOverlay(wsChannel, layerMgr); overlays["Technic Quarry"] = new TechnicQuarryOverlay(wsChannel, layerMgr); + overlays["Technic Switching station"] = new TechnicSwitchOverlay(wsChannel, layerMgr); overlays["Protector"] = new ProtectorOverlay(wsChannel, layerMgr); overlays["Missions"] = new MissionOverlay(wsChannel, layerMgr); diff --git a/server/static/js/overlays/TechnicSwitchOverlay.js b/server/static/js/overlays/TechnicSwitchOverlay.js new file mode 100644 index 0000000..ad653d3 --- /dev/null +++ b/server/static/js/overlays/TechnicSwitchOverlay.js @@ -0,0 +1,22 @@ +'use strict'; + +var TechnicSwitchIcon = L.icon({ + iconUrl: 'pics/technic_water_mill_top_active.png.png', + + iconSize: [16, 16], + iconAnchor: [8, 8], + popupAnchor: [0, -16] +}); + +var TechnicSwitchOverlay = AbstractIconOverlay.extend({ + initialize: function(wsChannel, layerMgr) { + AbstractIconOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "technicswitch", TechnicQuarryIcon); + }, + + createPopup: function(sw){ + return "

Active: " + sw.attributes.active + "

" + + "

Channel: " + sw.attributes.channel + "

" + + "

Supply: " + sw.attributes.supply + "

" + + "

Demand: " + sw.attributes.demand + "

"; + } +});