Skip to content

Commit

Permalink
New window title. Map length cap increased. Reset button resets map. …
Browse files Browse the repository at this point in the history
…Map resets at start of new race automatically.
  • Loading branch information
Austin Baccus committed Oct 11, 2021
1 parent 510127c commit bd15f47
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Forza Data</title>
<title>Forza Telemetry</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"/>
<link
rel="stylesheet"
Expand Down
42 changes: 31 additions & 11 deletions dist/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7941,12 +7941,6 @@ var mainHudBottomStyle = {
borderRadius: '5px',
marginTop: '60px'
};
var dataRowStyle = {
height: '25%',
textAlign: 'left',
margin: '-2px 0px 0px 30px',
fontFamily: 'Roboto'
};
var dataValueStyle = {
color: '#C54242',
fontSize: '24px'
Expand Down Expand Up @@ -8045,11 +8039,20 @@ var Dashboard = function Dashboard() {
electron__WEBPACK_IMPORTED_MODULE_1__.ipcRenderer.on('new-data-for-dashboard', function (event, message) {
setData(message);
dataCount = dataCount + 1; // update map
// only update the map every 10 ticks to avoid running into performance issues

if (dataCount % 5 == 0) {
if (dataCount % 10 == 0) {
var c = lapCoords;
c.push([message.PositionX, -message.PositionZ]);
setLapCoords(c);
setLapCoords(c); // If the map path is more than 6500 segments long, then start deleting the oldest segment every time you add a new segment.
// This prevents the app from running into performance issues because of the map path becoming too long.
// 6500 is a guesstimated value. It was chosen after testing the number of segments required for
// one of FM7's slowest cars, the Toyota Arctic Truck, to draw a complete path around the Nurburgring Nordschleife + GP circuit.
// The number required is roughly 6500 segments.

if (c.length > 6500) {
c.shift();
}
} // update MPG


Expand All @@ -8060,7 +8063,10 @@ var Dashboard = function Dashboard() {
var z1 = message.PositionZ;
var x2 = previousCoords[0];
var y2 = previousCoords[1];
var z2 = previousCoords[2];
var z2 = previousCoords[2]; // do not use the game's calculation of distance travelled. if you do, the player
// can simply go backwardss during a race and the games' distance travelled number will actually decrease
// this would, of course, throw off the MPG calculation

var distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2) + Math.pow(z2 - z1, 2));
previousCoords[0] = message.PositionX;
previousCoords[1] = message.PositionY;
Expand All @@ -8070,7 +8076,7 @@ var Dashboard = function Dashboard() {

var fuelUsed = previousFuel - message.Fuel; // convert to gallons

fuelUsed = fuelUsed * 13; // 13 gallons is the typical sized fuel tank for a car
fuelUsed = fuelUsed * 13; // 13 gallons is the typical sized fuel tank for a car. Forza doesn't tell you how many gallons their cars have.

setMpg((distance / fuelUsed).toFixed(0));
}
Expand Down Expand Up @@ -8163,6 +8169,7 @@ var Dashboard = function Dashboard() {
setMpg('0');
setPreviousCoords([0, 0, 0]);
setPreviousFuel(1);
lapCoords.length = 0;
}
}, "Reset"))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("td", {
style: {}
Expand Down Expand Up @@ -8306,7 +8313,8 @@ var Dashboard = function Dashboard() {
Remaining: data ? data.NormalDrivingLine : 0,
X: data ? data.PositionX.toFixed(0) : 0,
Y: data ? data.PositionY.toFixed(0) : 0,
Z: data ? data.PositionZ.toFixed(0) : 0
Z: data ? data.PositionZ.toFixed(0) : 0,
RaceTime: data ? data.CurrentRaceTime : 0
}))));
};

Expand Down Expand Up @@ -8743,6 +8751,18 @@ function Map(props) {
setMapOffset(CalculateMapOffset(minX, minZ));
var widthToHeightRatio = (maxX - minX) / (maxZ - minZ);
setSmush(widthToHeightRatio > 1 ? Math.min(168, widthToHeightRatio * 20) : 0);
} // Reset the map boundaries and variables if a new race has just started
// If the race time is 0 we can assume the user has just started a new race


if (props.RaceTime === 0) {
setMinX(0);
setMaxX(0);
setMinZ(0);
setMaxZ(0);
setMapDimensions([13.44, 10.00]);
setMapOffset([-1, -1]);
setSmush(0);
}
}, [props]); // this doesn't work (it's supposed to place the prev lap path on the map every time a new lap is started)

Expand Down
2 changes: 1 addition & 1 deletion dist/renderer.js.map

Large diffs are not rendered by default.

0 comments on commit bd15f47

Please sign in to comment.