Skip to content

Commit

Permalink
Dashboards
Browse files Browse the repository at this point in the history
  • Loading branch information
cdemetriadis committed Nov 3, 2023
1 parent 5cdf8a5 commit 02e9ad3
Show file tree
Hide file tree
Showing 61 changed files with 13,679 additions and 16,727 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ var purple = '#FFC500CE'
var orange = '#FFFF7400'
var blue = '#FF00BFFF'
var dark_blue = '#FF0000FF'
var transparent = '#00000000'

const json_settings = readtextfile('./JavascriptExtensions/Lovely-Dashboard_settings.json')
const settings = JSON.parse(json_settings);
const settings = JSON.parse(json_settings)

const json_tracks = readtextfile('./DashTemplates/Lovely Dashboard XL/JavascriptExtensions/Lovely-Dashboard_tracks.json')
const ld_tracks = JSON.parse(json_tracks)

function ld_GetPlayerName() {
if ( !settings || !settings.driverName ) {
Expand Down Expand Up @@ -257,7 +261,17 @@ function ld_getAvgValue(getAvgForProp, lapAvg, resetKey) {
root['prop'] = []
}

return ld_getAverage(root['prop'])
return ( Number.isNaN(ld_getAverage(root['prop'])) ) ? '---' : ld_getAverage(root['prop'])

}

function ld_saveValue(value) {

if (!$prop('DataCorePlugin.GamePaused') && !$prop('DataCorePlugin.GameData.IsInPitLane') && !$prop('DataCorePlugin.GameRawData.Graphics.IsSetupMenuVisible') && value != 0) {
root['savedValue'] = value
}

return ( Number.isNaN(root['savedValue']) ) ? '---' : root['savedValue']

}

Expand Down Expand Up @@ -657,6 +671,22 @@ function ld_getSim() {

}

function ld_getTurn() {
var sim = ld_getSim()
var track = eval( "ld_tracks." + sim + "." + $prop('TrackId') )
if ( !track || track == undefined ) { return null }

var trackTurns = eval( "ld_tracks." + sim + "." + $prop('TrackId') + ".turns" )
var currentPosition = drivertrackpositionpercent( getplayerleaderboardposition() ).toFixed(3)
var margin = 0.03
for ( const turn in trackTurns ) {
if ( currentPosition >= (trackTurns[turn] - margin) && currentPosition <= (trackTurns[turn] + margin) ) {
return turn
}
}
return null
}

function ld_formatTime(time) {
if (time > -10 && time < 10) {
return format(time, '0.000', true)
Expand Down Expand Up @@ -689,6 +719,38 @@ function ld_formatTimeVeryShort(time) {
}
}

function ld_formatNumber(time) {
if (time > -10 && time < 10) {
return format(time, '0.000', false)
} else if (time > -100 && time < 100) {
return format(time, '00.00', false)
} else if (time > -1000 && time < 1000) {
return format(time, '000.0', false)
} else {
return format(time, '000', false)
}
}

function ld_formatNumberShort(time) {
if (time > -10 && time < 10) {
return format(time, '0.00', false)
} else if (time > -100 && time < 100) {
return format(time, '00.0', false)
} else {
return format(time, '000', false)
}
}

function ld_formatNumberVeryShort(time) {
if (time > -10 && time < 10) {
return format(time, '0.0', false)
} else if (time > -100 && time < 100) {
return format(time, '00', false)
} else {
return format(time, '00', false)
}
}

function ld_isIncreasing(value) {

if(root['value']==null){
Expand All @@ -703,4 +765,29 @@ function ld_isIncreasing(value) {

return (expect < 0) ? true : false

}

function ld_boardScroll(boardHeight) {
//
// I'm assuming all calculations will start after P3
// boardHeight = Number of rows
var maxScroll = $prop('OpponentsCount')-boardHeight
var currentPos = $prop('Position')
var midPos = Math.round(boardHeight/2 + 3)
var maxPos = Math.round(boardHeight/2)

// maxScroll can't be smaller than 3 (P3)
maxScroll = ( maxScroll < 3 ) ? 3 : maxScroll

if ( currentPos > midPos ) {
if (maxScroll < currentPos - maxPos) {
scrollPos = maxScroll
} else {
scrollPos = currentPos - maxPos
}
} else {
scrollPos = 3 // Start board after P3 ...
}

return scrollPos
}
181 changes: 181 additions & 0 deletions Lovely Dashboard XL/JavascriptExtensions/Lovely-Dashboard_tracks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
{
"ACC": {
"nurburgring": {
"gt3": {
"pitstop": 78,
"sg30": 78,
"dt": 43
},
"turns": {
"1": 0.13,
"2": 0.16,
"3": 0.21,
"4": 0.235,
"5": 0.26,
"6": 0.32,
"7": 0.36,
"8": 0.48,
"9": 0.55,
"10": 0.58,
"11": 0.665,
"12": 0.705,
"13": 0.80,
"14": 0.88,
"15": 0.9,
"16": 0.943
},
"sectors": {
"1": 0.453,
"2": 0.861,
"3": 1
}
},
"Barcelona": {
"gt3": {
"pitstop": 77,
"sg30": 77,
"dt": 42
},
"turns": {
"1": 0.185,
"2": 0.209,
"3": 0.281,
"4": 0.377,
"5": 0.461,
"6": 0.518,
"7": 0.556,
"8": 0.577,
"9": 0.633,
"10": 0.758,
"11": 0.785,
"12": 0.819,
"13": 0.869,
"14": 0.895,
"15": 0.908,
"16": 0.944
},
"sectors": {
"1": 0.350,
"2": 0.733,
"3": 1
}
},
"Zolder": {
"gt3": {
"pitstop": 84,
"sg30": 84,
"dt": 50
},
"turns": {
"1": 0.076,
"2": 0.150,
"3": 0.203,
"4": 0.288,
"5": 0.450,
"6": 0.530,
"7": 0.594,
"8": 0.643,
"9": 0.763,
"10": 0.796,
"11": 0.905
},
"sectors": {
"1": 0.368,
"2": 0.693,
"3": 1
}
},
"Kyalami": {
"gt3": {
"pitstop": 65,
"sg30": 65,
"dt": 29
},
"turns": {
"1": 0.055,
"2": 0.147,
"3": 0.184,
"4": 0.205,
"5": 0.229,
"6": 0.359,
"7": 0.435,
"8": 0.503,
"9": 0.536,
"10": 0.634,
"11": 0.657,
"12": 0.754,
"13": 0.821,
"14": 0.858,
"15": 0.885,
"16": 0.942
},
"sectors": {
"1": 0.323,
"2": 0.717,
"3": 1
}
},
"watkins_glen": {
"gt3": {
"pitstop": 72,
"sg30": 72,
"dt": 36
},
"turns": {
"1": 0.065,
"2": 0.135,
"3": 0.178,
"4": 0.229,
"5": 0.358,
"6": 0.378,
"7": 0.422,
"8": 0.516,
"9": 0.609,
"10": 0.736,
"11": 0.798,
"12": 0.872,
"13": 0.929
},
"sectors": {
"1": 0.334,
"2": 0.637,
"3": 1
}
},
"Imola": {
"gt3": {
"pitstop": 78,
"sg30": 78,
"dt": 43
},
"turns": {
"1": 0.025,
"2": 0.144,
"3": 0.159,
"4": 0.186,
"5": 0.274,
"6": 0.292,
"7": 0.349,
"8": 0.432,
"9": 0.476,
"10": 0.519,
"11": 0.557,
"12": 0.584,
"13": 0.607,
"14": 0.683,
"15": 0.697,
"16": 0.806,
"17": 0.846,
"18": 0.874,
"19": 0.939
},
"sectors": {
"1": 0.258,
"2": 0.557,
"3": 1
}
}
}


}
Loading

0 comments on commit 02e9ad3

Please sign in to comment.