Skip to content

Commit

Permalink
✨ [feat/maps] #3 get map tiles from local file
Browse files Browse the repository at this point in the history
  • Loading branch information
JAGFx committed Jan 6, 2021
1 parent 413e623 commit 6e344e7
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 159 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ build
bundle

public/icons/*
maps/

# local env files
.env.local
Expand Down
1 change: 1 addition & 0 deletions maps
Empty file removed public/maps/.gitkeep
Empty file.
14 changes: 14 additions & 0 deletions server.dev/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions server.dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"http": "0.0.1-security",
"socket.io": "^2.3.0"
"cors" : "^2.8.5",
"express" : "^4.17.1",
"http" : "0.0.1-security",
"socket.io" : "^2.3.0"
}
}
68 changes: 55 additions & 13 deletions server.dev/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ const path = require( 'path' );
const fs = require( 'fs' );
const socketio = require( 'socket.io' );

const express = require( 'express' );
const http = require( 'http' );
const bodyParser = require( 'body-parser' );
const cors = require( 'cors' );


const options = { /* ... */ };
const io = socketio( options );
const dateFilename = path.resolve( process.cwd(), '../src/data/scs_sdk_plugin_parsed_data.json' );
Expand All @@ -24,24 +30,60 @@ const interval = () => {
: 15;
}; // Milisecond

io.listen( port, () => {
const url = `localhost:${ port }`;
const data = {
// ---

let app = express();
let server = http.createServer( app );

app.use( bodyParser.json() );
app.use( cors( {
origin: /http:\/\/localhost:\d+/,
credentials: true
} ) );
app.use( '/maps', express.static( path.resolve( __dirname, '../../maps' ) ) );

// ---

//io.listen( port, () => {
// const url = `localhost:${ port }`;
// const data = {
// url: url,
// port: port
// };
// const eventName = 'server.listen';
// const txt = `Euro Truck Simulator 2 dashboard is running at http://${ url }/`;
// io.emit( 'log', {
// eventName: eventName,
// rawData: data
// } );
// console.log( `[${ eventName }] ${ txt }` );
//} );

io.on( 'connection', socket => {
const data = fs.readFileSync( dateFilename );
console.log( 'Update' );
setInterval( () => io.emit( 'update', JSON.parse( data.toString() ) ), interval() );
//io.emit( 'update', JSON.parse( data.toString() ) );
} );

server.listen( port, () => {
const url = `localhost:${ port }`;
const data = {
url: url,
port: port
};

// const url = `localhost:${ port }`;
// const data = {
// url: url,
// port: port
// };
const eventName = 'server.listen';
const txt = `Euro Truck Simulator 2 dashboard is running at http://${ url }/`;
//const txt = `Euro Truck Simulator 2 dashboard is running at http://${ url }/`;
io.emit( 'log', {
eventName: eventName,
rawData: data
} );
console.log( `[${ eventName }] ${ txt }` );
} );

io.on( 'connection', socket => {
const data = fs.readFileSync( dateFilename );
console.log( 'Update' );
setInterval( () => io.emit( 'update', JSON.parse( data.toString() ) ), interval() );
//io.emit( 'update', JSON.parse( data.toString() ) );
} );

console.log( 'server.listen', data, `Euro Truck Simulator 2 dashboard is running at http://${ url }/` );
} );
14 changes: 8 additions & 6 deletions src/dashboards/maps/components/DashMaps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default {
};
},
mounted() {
_maps.init();
_maps.init( this.telemetry.game.game.name );
EventBus.$on( 'tmp-update', dataIn => {
_maps.updatePlayerPositionAndRotation(
Expand All @@ -91,11 +91,13 @@ export default {
// --- Dev
if ( _app.isOnDevEnvironment )
_maps.updatePlayerPositionAndRotation(
this.telemetry.truck.position.X,
this.telemetry.truck.position.Z,
this.telemetry.truck.orientation.heading,
this.telemetry.truck.speed.kph );
setTimeout( () => {
_maps.updatePlayerPositionAndRotation(
this.telemetry.truck.position.X,
this.telemetry.truck.position.Z,
this.telemetry.truck.orientation.heading,
this.telemetry.truck.speed.kph );
}, 1000 );
// --- ./Dev
},
methods: {
Expand Down
94 changes: 0 additions & 94 deletions src/dashboards/maps/components/DashMaps.vue.bck

This file was deleted.

46 changes: 23 additions & 23 deletions src/data/ets2-dashboard-skin.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@
"events_truck.electric" : true,
"events_truck.emergency" : true,
"events_truck.warning" : true,
"events_truck.cruise-control-decrease" : true,
"events_truck.cruise-control-increase" : true,
"events_truck.cruise-control" : true,
"events_trailers.damage" : true,
"events_trailers.coupling" : true,
"events_navigation.speed-limit" : true,
"events_job.started" : true,
"events_job.finished" : true,
"events_job.delivered" : true,
"events_job.cancelled" : true,
"events_game.refuel-payed" : true,
"events_game.train" : true,
"events_game.ferry" : true,
"events_game.tollgate" : true,
"events_game.fine" : true,
"events_game.pause" : true,
"maps_elements_eta" : true,
"maps_elements_speedAndGear" : true,
"maps_elements_mapControls" : true,
"maps_elements_speedLimit" : true,
"maps_map_tilesLocations" : "remote",
"maps_map_activeMap" : "vanilla",
"maps_map_navigationRemaining" : "remaining_date"
"events_truck.cruise-control-decrease" : true,
"events_truck.cruise-control-increase" : true,
"events_truck.cruise-control" : true,
"events_trailers.damage" : true,
"events_trailers.coupling" : true,
"events_navigation.speed-limit" : true,
"events_job.started" : true,
"events_job.finished" : true,
"events_job.delivered" : true,
"events_job.cancelled" : true,
"events_game.refuel-payed" : true,
"events_game.train" : true,
"events_game.ferry" : true,
"events_game.tollgate" : true,
"events_game.fine" : true,
"events_game.pause" : true,
"maps_elements_eta" : true,
"maps_elements_speedAndGear" : true,
"maps_elements_mapControls" : true,
"maps_elements_speedLimit" : true,
"maps_map_tilesLocations" : "local",
"maps_map_activeMap" : "vanilla",
"maps_map_navigationRemaining" : "remaining_date"
}
Loading

0 comments on commit 6e344e7

Please sign in to comment.