forked from MTSR/mapserver
Support Phonographs (#376)
* Support Phonographs * Fix comment * Add missing import * Fix variable name
This commit is contained in:
parent
cbf58dfbf8
commit
2c0edb328f
@ -88,6 +88,7 @@ func ParseConfig(filename string) (*Config, error) {
|
||||
Locator: false,
|
||||
Signs: true,
|
||||
MapserverAirutils: true,
|
||||
Phonograph: true,
|
||||
}
|
||||
|
||||
mapblockaccessor := MapBlockAccessorConfig{
|
||||
|
@ -64,6 +64,7 @@ type MapObjectConfig struct {
|
||||
Locator bool `json:"locator"`
|
||||
Signs bool `json:"signs"`
|
||||
MapserverAirutils bool `json:"mapserver_airutils"`
|
||||
Phonograph bool `json:"phonograph"`
|
||||
}
|
||||
|
||||
type WebApiConfig struct {
|
||||
|
@ -72,3 +72,7 @@
|
||||
* unifieddyes_palette_extended.png
|
||||
* GPL 2.0
|
||||
* Source: https://gitlab.com/VanessaE/unifieddyes
|
||||
|
||||
* phonograph_node_temp.png
|
||||
* License: CC By-SA 4.0
|
||||
* Source: [phonograph](https://github.com/C-C-Minetest-Server/phonograph/)
|
||||
|
24
mapobject/phonograph.go
Normal file
24
mapobject/phonograph.go
Normal file
@ -0,0 +1,24 @@
|
||||
package mapobject
|
||||
|
||||
import (
|
||||
"mapserver/mapobjectdb"
|
||||
"mapserver/types"
|
||||
|
||||
"github.com/minetest-go/mapparser"
|
||||
)
|
||||
|
||||
type Phonograph struct{}
|
||||
|
||||
func (this *Phonograph) onMapObject(mbpos *types.MapBlockCoords, x, y, z int, block *mapparser.MapBlock) *mapobjectdb.MapObject {
|
||||
md := block.Metadata.GetMetadata(x, y, z)
|
||||
|
||||
if _, ok := md["song_title"]; !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
o := mapobjectdb.NewMapObject(mbpos, x, y, z, "phonograph")
|
||||
o.Attributes["song_title"] = md["song_title"]
|
||||
o.Attributes["song_artist"] = md["song_artist"]
|
||||
|
||||
return o
|
||||
}
|
@ -192,5 +192,10 @@ func Setup(ctx *app.App) {
|
||||
l.AddMapObject("default:sign_wall_steel", &SignBlock{Material: "steel"})
|
||||
}
|
||||
|
||||
//Phonograph
|
||||
if ctx.Config.MapObjects.Phonograph {
|
||||
l.AddMapObject("phonograph:phonograph", &Phonograph{})
|
||||
}
|
||||
|
||||
ctx.MapBlockAccessor.Eventbus.AddListener(&l)
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import TrainOverlay from './overlays/TrainOverlay.js';
|
||||
import TrainsignalOverlay from './overlays/TrainsignalOverlay.js';
|
||||
import SignOverlay from './overlays/SignOverlay.js';
|
||||
import AirUtilsPlanesOverlay from "./overlays/AirUtilsPlanesOverlay.js";
|
||||
import PhonographOverlay from "./overlays/PhonographOverlay.js";
|
||||
|
||||
export default function(cfg, map, overlays, wsChannel){
|
||||
|
||||
@ -207,4 +208,10 @@ export default function(cfg, map, overlays, wsChannel){
|
||||
}
|
||||
}
|
||||
|
||||
if (cfg.mapobjects.phonograph) {
|
||||
overlays.Phonographs = new PhonographOverlay();
|
||||
if (isDefault("phonograph")) {
|
||||
map.addLayer(overlays.Phonographs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
22
public/js/map/overlays/PhonographOverlay.js
Normal file
22
public/js/map/overlays/PhonographOverlay.js
Normal file
@ -0,0 +1,22 @@
|
||||
import AbstractIconOverlay from './AbstractIconOverlay.js';
|
||||
import {HtmlSanitizer} from '../../lib/HtmlSanitizer.js';
|
||||
|
||||
var PhonographIcon = L.icon({
|
||||
iconUrl: 'pics/phonograph_node_temp.png',
|
||||
|
||||
iconSize: [16, 16],
|
||||
iconAnchor: [8, 8],
|
||||
popupAnchor: [0, -16]
|
||||
});
|
||||
|
||||
export default AbstractIconOverlay.extend({
|
||||
initialize: function() {
|
||||
AbstractIconOverlay.prototype.initialize.call(this, "phonograph", PhonographIcon);
|
||||
},
|
||||
|
||||
createPopup: function(obj){
|
||||
return "<h4>Phonograph</h4><br>" +
|
||||
"<b>Now playing:</b> <i>" + HtmlSanitizer.SanitizeHtml(obj.attributes.song_title) + "</i> by " +
|
||||
HtmlSanitizer.SanitizeHtml(obj.attributes.song_artist);
|
||||
}
|
||||
});
|
BIN
public/pics/phonograph_node_temp.png
Normal file
BIN
public/pics/phonograph_node_temp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 102 B |
Loading…
Reference in New Issue
Block a user