train display/icons
This commit is contained in:
parent
2035803541
commit
5dcac0c320
@ -51,6 +51,9 @@ function send_stats()
|
|||||||
--print(dump(train))--XXX
|
--print(dump(train))--XXX
|
||||||
|
|
||||||
local t = {
|
local t = {
|
||||||
|
text_outside = train.text_outside,
|
||||||
|
text_inside = train.text_inside,
|
||||||
|
line = train.line,
|
||||||
pos = train.last_pos,
|
pos = train.last_pos,
|
||||||
velocity = train.velocity,
|
velocity = train.velocity,
|
||||||
off_track = train.off_track,
|
off_track = train.off_track,
|
||||||
|
BIN
pics/trains.png
Normal file
BIN
pics/trains.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
pics/trains2.png
Normal file
BIN
pics/trains2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
@ -42,6 +42,7 @@ type MapObjectConfig struct {
|
|||||||
Smartshop bool `json:"smartshop"`
|
Smartshop bool `json:"smartshop"`
|
||||||
Fancyvend bool `json:"fancyvend"`
|
Fancyvend bool `json:"fancyvend"`
|
||||||
ATM bool `json:"atm"`
|
ATM bool `json:"atm"`
|
||||||
|
Train bool `json:"train"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebApiConfig struct {
|
type WebApiConfig struct {
|
||||||
@ -110,6 +111,7 @@ func ParseConfig(filename string) (*Config, error) {
|
|||||||
Smartshop: true,
|
Smartshop: true,
|
||||||
Fancyvend: true,
|
Fancyvend: true,
|
||||||
ATM: true,
|
ATM: true,
|
||||||
|
Train: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
mapblockaccessor := MapBlockAccessorConfig{
|
mapblockaccessor := MapBlockAccessorConfig{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html style="height: 100%">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||||
@ -36,6 +36,7 @@
|
|||||||
<script src="js/overlays/PoiOverlay.js"></script>
|
<script src="js/overlays/PoiOverlay.js"></script>
|
||||||
<script src="js/overlays/LabelOverlay.js"></script>
|
<script src="js/overlays/LabelOverlay.js"></script>
|
||||||
<script src="js/overlays/PlayerOverlay.js"></script>
|
<script src="js/overlays/PlayerOverlay.js"></script>
|
||||||
|
<script src="js/overlays/TrainOverlay.js"></script>
|
||||||
<script src="js/overlays/ProtectorOverlay.js"></script>
|
<script src="js/overlays/ProtectorOverlay.js"></script>
|
||||||
<script src="js/overlays/BonesOverlay.js"></script>
|
<script src="js/overlays/BonesOverlay.js"></script>
|
||||||
<script src="js/overlays/LcdOverlay.js"></script>
|
<script src="js/overlays/LcdOverlay.js"></script>
|
||||||
|
@ -45,4 +45,8 @@ function Overlaysetup(cfg, map, overlays, wsChannel, layerMgr){
|
|||||||
if (cfg.mapobjects.mission) {
|
if (cfg.mapobjects.mission) {
|
||||||
overlays["Missions"] = new MissionOverlay(wsChannel, layerMgr);
|
overlays["Missions"] = new MissionOverlay(wsChannel, layerMgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cfg.mapobjects.train) {
|
||||||
|
overlays["Trains"] = new TrainOverlay(wsChannel, layerMgr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,24 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
//TODO
|
function getTrainImageUrlForType(type){
|
||||||
var TrainIcon = L.icon({
|
switch(type){
|
||||||
iconUrl: 'pics/sam.png',
|
case "advtrains:subway_wagon":
|
||||||
|
return "pics/advtrains/advtrains_subway_wagon_inv.png";
|
||||||
iconSize: [16, 32],
|
case "advtrains:engine_japan":
|
||||||
iconAnchor: [8, 16],
|
return "pics/advtrains/advtrains_engine_japan_inv.png";
|
||||||
popupAnchor: [0, -16]
|
case "advtrains:engine_steam":
|
||||||
});
|
return "pics/advtrains/advtrains_engine_steam_inv.png";
|
||||||
|
case "advtrains:engine_industrial":
|
||||||
|
return "pics/advtrains/advtrains_engine_industrial_inv.png";
|
||||||
|
case "advtrains:wagon_wood":
|
||||||
|
return "pics/advtrains/advtrains_wagon_wood_inv.png";
|
||||||
|
case "advtrains:wagon_box":
|
||||||
|
return "pics/advtrains/advtrains_wagon_box_inv.png";
|
||||||
|
default:
|
||||||
|
//TODO: fallback image
|
||||||
|
return "pics/advtrains/advtrains_subway_wagon_inv.png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var TrainOverlay = L.LayerGroup.extend({
|
var TrainOverlay = L.LayerGroup.extend({
|
||||||
initialize: function(wsChannel, layerMgr) {
|
initialize: function(wsChannel, layerMgr) {
|
||||||
@ -29,8 +40,40 @@ var TrainOverlay = L.LayerGroup.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
createMarker: function(train){
|
createMarker: function(train){
|
||||||
var marker = L.marker([train.pos.z, train.pos.x], {icon: TrainIcon});
|
|
||||||
marker.bindPopup("Train");
|
//search for wagin in front (whatever "front" is...)
|
||||||
|
var type;
|
||||||
|
var lowest_pos = 100;
|
||||||
|
train.wagons.forEach(function(w){
|
||||||
|
if (w.pos_in_train < lowest_pos){
|
||||||
|
lowest_pos = w.pos_in_train;
|
||||||
|
type = w.type;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var Icon = L.icon({
|
||||||
|
iconUrl: getTrainImageUrlForType(type),
|
||||||
|
|
||||||
|
iconSize: [16, 16],
|
||||||
|
iconAnchor: [8, 8],
|
||||||
|
popupAnchor: [0, -16]
|
||||||
|
});
|
||||||
|
|
||||||
|
var marker = L.marker([train.pos.z, train.pos.x], {icon: Icon});
|
||||||
|
|
||||||
|
var html = "<b>Train</b><hr>";
|
||||||
|
|
||||||
|
html += "<b>Name:</b> " + train.text_outside + "<br>";
|
||||||
|
html += "<b>Line:</b> " + train.line + "<br>";
|
||||||
|
html += "<b>Velocity:</b> "+ Math.floor(train.velocity*10)/10 + "<br>";
|
||||||
|
|
||||||
|
html += "<b>Composition: </b>";
|
||||||
|
train.wagons.forEach(function(w){
|
||||||
|
var iconUrl = getTrainImageUrlForType(w.type);
|
||||||
|
html += "<img src='"+iconUrl+"'>";
|
||||||
|
});
|
||||||
|
|
||||||
|
marker.bindPopup(html);
|
||||||
|
|
||||||
return marker;
|
return marker;
|
||||||
},
|
},
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 900 B After Width: | Height: | Size: 1.1 KiB |
@ -21,11 +21,14 @@ type Wagon struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Train struct {
|
type Train struct {
|
||||||
Pos GenericPos `json:"pos"`
|
Pos GenericPos `json:"pos"`
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Wagons []*Wagon `json:"wagons"`
|
Wagons []*Wagon `json:"wagons"`
|
||||||
OffTrack bool `json:"off_track"`
|
OffTrack bool `json:"off_track"`
|
||||||
Velocity float64 `json:"velocity"`
|
Velocity float64 `json:"velocity"`
|
||||||
|
Line string `json:"line"`
|
||||||
|
TextOutside string `json:"text_outside"`
|
||||||
|
TextInside string `json:"text_inside"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Player struct {
|
type Player struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user