Skip to content

Commit

Permalink
3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NyboTV committed Jul 7, 2023
1 parent a86fde9 commit 8372f1b
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tp_ets2_plugin",
"version": "3.2.9",
"version": "3.3.0",
"description": "Euro Truck Simulator 2 Plugin for TouchPortal",
"main": "src/bin/plugin.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/bin/config/cfg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.2.9",
"version": "3.3.0",
"refreshInterval": 500,
"debug": false,
"firstInstall": false,
Expand Down
22 changes: 11 additions & 11 deletions src/bin/modules/script/autoupdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const autoupdate = async (UpdateCheck, PreReleaseAllowed, lastVersion, logIt, sh
let Downloads_Path = process.env.USERPROFILE + "\\Downloads\\ETS2_Dashboard_autoupdate"
let TP_path = process.env.APPDATA + `/TouchPortal/plugins/ETS2_Dashboard`

UpdateQuestion = await showDialog("warning", ["Yes", "No"], "ETS2 Dashboard", "Do you want to Update your Plugin?")
UpdateQuestion = await showDialog("warning", ["Yes", "No"], "Do you want to Update your Plugin?")

if (UpdateQuestion === 0) {

Expand Down Expand Up @@ -215,7 +215,7 @@ const autoupdate = async (UpdateCheck, PreReleaseAllowed, lastVersion, logIt, sh
break
} else {
logIt("AUTOUPDATE", "INFO", "TP Still running...")
await showDialog("warning", ["Done"], "ETS2 Dashboard", "Please fully Close TouchPortal! Remember: Its getting minimized in your System-Tray!")
await showDialog("warning", ["Done"], "Please fully Close TouchPortal! Remember: Its getting minimized in your System-Tray!")
await timeout(500)
}
}
Expand Down Expand Up @@ -280,13 +280,13 @@ const autoupdate = async (UpdateCheck, PreReleaseAllowed, lastVersion, logIt, sh
progressBar.detail = "Done."

logIt("AUTOUPDATE", "INFO", "Done.")
showDialog("info", ["Ok"], "ETS2 Dashboard", "Update Done! You can start TouchPortal again and delete this Folder")
showDialog("info", ["Ok"], "Update Done! You can start TouchPortal again and delete this Folder")
await timeout(5000)
exit()
})

} else if (UpdateQuestion === 1) {
await showDialog("info", ["Ok"], "ETS2 Dashboard", "Alright. Plugin is closing, due to execute in Downloads Folder!")
await showDialog("info", ["Ok"], "Alright. Plugin is closing, due to execute in Downloads Folder!")
exit()
}

Expand Down Expand Up @@ -326,9 +326,9 @@ const autoupdate = async (UpdateCheck, PreReleaseAllowed, lastVersion, logIt, sh
download_path = process.env.USERPROFILE + "/Downloads"

if (response.prerelease === true) {
UpdateQuestion = await showDialog("info", ["Yes", "No"], "ETS2 Dashboard: AutoUpdater", `We found a new Update! Version: PreRelease-${newversion}, Install?`)
UpdateQuestion = await showDialog("info", ["Yes", "No"], `We found a new Update! Version: PreRelease-${newversion}, Install?`)
} else {
UpdateQuestion = await showDialog("info", ["Yes", "No"], "ETS2 Dashboard: AutoUpdater", `We found a new Update! Version: ${newversion}, Install?`)
UpdateQuestion = await showDialog("info", ["Yes", "No"], `We found a new Update! Version: ${newversion}, Install?`)
}

if (UpdateQuestion === 0) {
Expand All @@ -344,7 +344,7 @@ const autoupdate = async (UpdateCheck, PreReleaseAllowed, lastVersion, logIt, sh
try {
fs.rmdirSync(`${download_path}/ETS2_Dashboard_autoupdate`, { recursive: true })
} catch (e) {
await showDialog("warning", ["Done"], "ETS2 Dashboard", "Due to AntiVirus issues we can not delete any Files outside this Plugin. Please delete the 'ETS2_Dashboard_autoupdate' Folder in your Downloads Folder")
await showDialog("warning", ["Done"], "Due to AntiVirus issues we can not delete any Files outside this Plugin. Please delete the 'ETS2_Dashboard_autoupdate' Folder in your Downloads Folder")
logIt("AUTOUPDATE", "ERROR", e)
}
}
Expand All @@ -353,7 +353,7 @@ const autoupdate = async (UpdateCheck, PreReleaseAllowed, lastVersion, logIt, sh
try {
fs.rmSync(`${download_path}/ETS2_Dashboard.tpp`)
} catch (e) {
await showDialog("warning", ["Done"], "ETS2 Dashboard", "Due to AntiVirus issues we can not delete any Files outside this Plugin. Please delete the 'ETS2_Dashboard.tpp' File in your Downloads Folder")
await showDialog("warning", ["Done"], "Due to AntiVirus issues we can not delete any Files outside this Plugin. Please delete the 'ETS2_Dashboard.tpp' File in your Downloads Folder")
logIt("AUTOUPDATE", "ERROR", e)
}
}
Expand Down Expand Up @@ -423,16 +423,16 @@ const autoupdate = async (UpdateCheck, PreReleaseAllowed, lastVersion, logIt, sh

await timeout(200)

//InstallQuestion = await showDialog("info", ["Yes", "No"], "ETS2 Dashboard: AutoUpdater", "Update Downloaded and unzipped! Do you want to install it now?")
//InstallQuestion = await showDialog("info", ["Yes", "No"], "Update Downloaded and unzipped! Do you want to install it now?")
InstallQuestion = 1 // No Fix for ProgressBar Closes full plugin

if (InstallQuestion === 0) {
await showDialog("warning", ["Ok"], "ETS2 Dashboard: AutoUpdater", "Due to AntiVirus Issues you have to execute the File by hand. Just go to your Downloads Folder -> 'ETS2_Dashboard_autoupdate' and execute the 'ETS2_Dashboard.exe'.")
await showDialog("warning", ["Ok"], "Due to AntiVirus Issues you have to execute the File by hand. Just go to your Downloads Folder -> 'ETS2_Dashboard_autoupdate' and execute the 'ETS2_Dashboard.exe'.")
logIt("AUTOUPDATE", "INFO", "Exiting Plugin due to Update...")
exit()

} else if (InstallQuestion === 1) {
await showDialog("info", ["Okay!"], "ETS2 Dashboard: AutoUpdater", "If you want to install it, just go to your Downloads Folder, into 'ETS2_Dashboard' and execute the 'ETS2_Dashboard.exe' File. Plugin is Closing...")
await showDialog("info", ["Okay!"], "If you want to install it, just go to your Downloads Folder, into 'ETS2_Dashboard' and execute the 'ETS2_Dashboard.exe' File. Plugin is Closing...")

progressBar.close()
exit()
Expand Down
8 changes: 4 additions & 4 deletions src/bin/modules/script/firstinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ const firstInstall = async (showDialog, logIt, OfflineMode, timeout) => {

// Telemetry Server first Install
logIt("FIRSTINSTALL", "INFO", "Asking for Telemetry Server...")
telemetryInstall = await showDialog("info", ["No. Let me do the First Steps", "Yes, im good"], "ETS2 Dashboard Plugin: First Install Detected!", "Hi! Did you ever used this Plugin before?")
telemetryInstall = await showDialog("info", ["No. Let me do the First Steps", "Yes, im good"], "Hi! Did you ever used this Plugin before?")
if (telemetryInstall === 0) {
logIt("FIRSTINSTALL", "INFO", "Installing Telemetry Server...")
require('child_process').exec('start "" "%appdata%/TouchPortal/plugins/ETS2_Dashboard/server"');
await timeout(500)
await showDialog("info", ["Okay!"], "ETS2 Dashboard", "To use this Plugin you need to install the Telemetry Server by Hand! \nTo do this, just open the 'Ets2Telemtry.exe' in the Folder we just opend for you and click on Install and follow the Instruction!")
await showDialog("info", ["Okay!"], "To use this Plugin you need to install the Telemetry Server by Hand! \nTo do this, just open the 'Ets2Telemtry.exe' in the Folder we just opend for you and click on Install and follow the Instruction!")
} else {
logIt("FIRSTINSTALL", "INFO", "Telemetry already installed.")
}
Expand All @@ -26,7 +26,7 @@ const firstInstall = async (showDialog, logIt, OfflineMode, timeout) => {
// Default page
if (OfflineMode === false) {
logIt("FIRSTINSTALL", "INFO", "Asking Player for Default Page")
defaultPageChoice = await showDialog("question", ["Yes, the KMH Version.", "Yes, the MPH Version", "No, Thanks"], "ETS2 Dashboard Plugin: First Install Detected!", "We have a Default Page for new Users! Do you want to install it?")
defaultPageChoice = await showDialog("question", ["Yes, the KMH Version.", "Yes, the MPH Version", "No, Thanks"], "We have a Default Page for new Users! Do you want to install it?")
if (defaultPageChoice === 0 || defaultPageChoice === 1) {
logIt("FIRSTINSTALL", "INFO", "Downloading Default Page")

Expand Down Expand Up @@ -55,7 +55,7 @@ const firstInstall = async (showDialog, logIt, OfflineMode, timeout) => {
fs.unlinkSync(`${process.env.APPDATA}/TouchPortal/plugins/ETS2_Dashboard/tmp/${download_File}`)

logIt("FIRSTINSTALL", "INFO", "Install Finished!")
await showDialog("info", ["Okay!", "Restart now! (Not a thing yet!)"], "ETS2 Dashboard Plugin: First Install Detected!", "Please Restart TouchPortal to see the Default Page.")
await showDialog("info", ["Okay!", "Restart (Not a thing yet!)"], "Please Restart TouchPortal to see the Default Page.")
resolve(true)
})
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions src/bin/modules/script/showDialog.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { dialog } = require('electron')

const showDialog = async (type, buttons, title, message) => {
const showDialog = async (type, buttons, message) => {
return new Promise(async (resolve, reject) => {
let data = {
type: type,
buttons: buttons,
title: title,
title: "ETS2 Dashboard",
message: message
}

Expand Down
37 changes: 25 additions & 12 deletions src/bin/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ const truckersmpStates = require(`./modules/states/truckersmp`);
const worldStates = require(`./modules/states/world`);
const telemetry_Server = require('./modules/script/telemetry');

const isRunning = (query, cb) => {
exec('tasklist', (err, stdout, stderr) => {
cb(stdout.toLowerCase().indexOf(query.toLowerCase()) > -1);
});
}

logIt("MAIN", "INFO", "Starting Plugin...")
// Debug Section
const debugMode = process.argv.includes("--debugging")
Expand Down Expand Up @@ -260,7 +254,7 @@ const TouchPortalConnection = async (path, cfg_path, telemetry_path, OfflineMode
}

if(settings_error >= 1) {
showDialog("error", ["Ok"], "ETS2 Dashboard Settings", "Hey! You messed something up in the Settings! Please check them! Meanwhile we are using the Default Settings to prevent Crashes. Read more on Github.")
showDialog("error", ["Ok"], "Hey! You messed something up in the Settings! Please check them! Meanwhile we are using the Default Settings to prevent Crashes. Read more on Github.")
}

});
Expand All @@ -280,11 +274,13 @@ const main = async (path, cfg_path, telemetry_path) => {
if (system_path.basename(process.cwd()) === "ETS2_Dashboard") {
let MissingFiles = await filescheck(path, cfg_path, logIt, timeout)
if(MissingFiles > 0) {
UpdateQuestion = await showDialog("error", ["yes", "no"], "ETS2 Dashboard", `Missing ${MissingFiles} Files/Folders! Continue?`)
UpdateQuestion = await showDialog("error", ["yes", "no"], `Missing ${MissingFiles} Files/Folders! Continue?`)

if (UpdateQuestion === 1) {
exit()
}
} else {
await showDialog("info", "Ok", `Plugin Start aborted! Please send the Log File in Plugins Folder to the Creator on Discord!`)
}
}
}

Expand Down Expand Up @@ -343,16 +339,33 @@ if(Testing) {
}

//Checks for TP exe
function isRunning(win, mac, linux){
return new Promise(function(resolve, reject){
const plat = process.platform
const cmd = plat == 'win32' ? 'tasklist' : (plat == 'darwin' ? 'ps -ax | grep ' + mac : (plat == 'linux' ? 'ps -A' : ''))
const proc = plat == 'win32' ? win : (plat == 'darwin' ? mac : (plat == 'linux' ? linux : ''))
if(cmd === '' || proc === ''){
resolve(false)
}
exec(cmd, function(err, stdout, stderr) {
resolve(stdout.toLowerCase().indexOf(proc.toLowerCase()) > -1)
})
})
}


setInterval(() => {
if(system_path.basename(process.cwd()) === "ETS2_Dashboard") {
isRunning(`TouchPortalServices.exe`, async (status) => {
if(system_path.basename(process.cwd()) === "ETS2_Dashboard" || Testing === true) {

isRunning(`TouchPortalServices.exe`).then( async (status) => {
if(status === false) {
logIt("MAIN", "ERROR", "TouchPortal is not Running anymore.")
exit()
}
})

}
}, 200);
}, 5000);

main(path, cfg_path, telemetry_path)

0 comments on commit 8372f1b

Please sign in to comment.