From 2bfbcea4e04c2fb9d828221f420a2a502917aea1 Mon Sep 17 00:00:00 2001 From: Marc Arndt Date: Sat, 15 Jun 2019 12:52:13 +0200 Subject: [PATCH] - refactor the quick script implementations with the new JS class syntax and the const and let keywords --- .../Custom Installer Script/script.js | 20 +- Engines/Wine/QuickScript/GoG Script/script.js | 207 +++++++------ .../QuickScript/Installer Script/script.js | 139 +++++---- .../Local Installer Script/script.js | 48 +-- .../Online Installer Script/script.js | 76 +++-- .../Wine/QuickScript/Origin Script/script.js | 94 +++--- .../Wine/QuickScript/Quick Script/script.js | 254 ++++++++-------- .../Wine/QuickScript/Steam Script/script.js | 278 +++++++++--------- .../Wine/QuickScript/Uplay Script/script.js | 126 ++++---- Engines/Wine/QuickScript/Zip Script/script.js | 105 ++++--- 10 files changed, 665 insertions(+), 682 deletions(-) diff --git a/Engines/Wine/QuickScript/Custom Installer Script/script.js b/Engines/Wine/QuickScript/Custom Installer Script/script.js index 28eab3919c..49b2d38081 100644 --- a/Engines/Wine/QuickScript/Custom Installer Script/script.js +++ b/Engines/Wine/QuickScript/Custom Installer Script/script.js @@ -1,14 +1,12 @@ include("engines.wine.quick_script.installer_script"); -function CustomInstallerScript() { - InstallerScript.call(this); +class CustomInstallerScript extends InstallerScript { + constructor() { + super(); + } + + installationCommand(installationCommand) { + this._installationCommand = installationCommand; + return this; + } } - -CustomInstallerScript.prototype = Object.create(InstallerScript.prototype); - -CustomInstallerScript.prototype.constructor = CustomInstallerScript; - -CustomInstallerScript.prototype.installationCommand = function (installationCommand) { - this._installationCommand = installationCommand; - return this; -}; diff --git a/Engines/Wine/QuickScript/GoG Script/script.js b/Engines/Wine/QuickScript/GoG Script/script.js index bb5a5ecc52..4cbd12e7b8 100644 --- a/Engines/Wine/QuickScript/GoG Script/script.js +++ b/Engines/Wine/QuickScript/GoG Script/script.js @@ -3,108 +3,107 @@ include("utils.functions.net.download"); include("engines.wine.engine.object"); include("engines.wine.verbs.gdiplus"); -function GogScript() { - QuickScript.call(this); -} - -GogScript.prototype = Object.create(QuickScript.prototype); - -GogScript.prototype.constructor = GogScript; - -/** - * Sets one setup file name so that the script can fetch it from gog.com - * @param {string} setupFileName The setup file name - * @returns {GogScript} This - */ -GogScript.prototype.gogSetupFileName = function (setupFileName) { - this._setupFileNames = [setupFileName]; - return this; -} - -/** - * Sets the setup file(s) name so that the script can fetch it from gog.com - * @param {string[]} setupFileNames The setup file name(s) - * @returns {GogScript} This - */ -GogScript.prototype.gogSetupFileNames = function (setupFileNames) { - this._setupFileNames = setupFileNames; - return this; -} - -/** - * Presents a Gog.com login window to the user, login to its account and return a token that can be used later. - * Stores the tocken in a parameter - * @param {SetupWizard} setupWizard The setupWizard to use - * @returns {GogScript} This - */ -GogScript.prototype.loginToGog = function (setupWizard) { - var browserWindow = setupWizard.createBrowser(tr("Please login to your GoG.com account so that we can download the game for you:")); - browserWindow.goToUrl("https://auth.gog.com/auth?client_id=46899977096215655&redirect_uri=https%3A%2F%2Fembed.gog.com%2Fon_login_success%3Forigin%3Dclient&response_type=code&layout=client2"); - browserWindow.waitForUrl("https://embed.gog.com/*"); - var currentUrl = browserWindow.getCurrentUrl(); - var code = currentUrl.split("code=")[1].split("&")[0]; - - var tokenUrl = "https://auth.gog.com/token?client_id=46899977096215655&client_secret=9d85c43b1482497dbbce61f6e4aa173a433796eeae2ca8c5f6129f2dc4de46d9&grant_type=authorization_code&code=" + code + "&redirect_uri=https%3A%2F%2Fembed.gog.com%2Fon_login_success%3Forigin%3Dclient"; - this._token = new Downloader().url(tokenUrl).json(); - return this; -} - -GogScript.prototype._downloadSetupFile = function (setupWizard, setupFileName, tmpDirectory) { - var url = "https://www.gog.com/downloads/" + setupFileName; - - // We set a user agent so that GoG sends the filename of the executable - return new Downloader() - .url(url) - .wizard(setupWizard) - .to(tmpDirectory) - .headers({ - "Authorization": "Bearer " + this._token["access_token"], - "User-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:64.0) Gecko/20100101 Firefox/64.0" - }) - .get(); -} - -/** - * Download the setup resources in the same directory, and returns the path of the .exe - * @param {SetupWizard} setupWizard The setup wizard - * @returns {String} The .exe file entry that can be used to continue the installation - */ -GogScript.prototype.download = function (setupWizard) { - var setupDirectory = createTempDir(); - var that = this; - var foundExecutable = null; - this._setupFileNames.forEach(function (setupFileName) { - var downloadedFile = that._downloadSetupFile(setupWizard, setupFileName, setupDirectory); - if (downloadedFile.endsWith(".exe")) { - foundExecutable = downloadedFile; - } - }); - - return foundExecutable; -} - -GogScript.prototype.go = function () { - var setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature()); - - setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author); - - this.loginToGog(setupWizard); - var setupFile = this.download(setupWizard); - - var wine = new Wine() - .wizard(setupWizard) - .prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion) - .create() - .wait(); - - this._preInstall(wine, setupWizard); - - wine.gdiplus(); - wine.run(setupFile, [], wine.prefixDirectory() + "/drive_c/", true, true); - - this._postInstall(wine, setupWizard); - - this._createShortcut(wine.prefix()); - - setupWizard.close(); +class GogScript extends QuickScript { + constructor() { + super(); + } + + /** + * Sets one setup file name so that the script can fetch it from gog.com + * @param {string} setupFileName The setup file name + * @returns {GogScript} This + */ + gogSetupFileName(setupFileName) { + this._setupFileNames = [setupFileName]; + return this; + } + + /** + * Sets the setup file(s) name so that the script can fetch it from gog.com + * @param {string[]} setupFileNames The setup file name(s) + * @returns {GogScript} This + */ + gogSetupFileNames(setupFileNames) { + this._setupFileNames = setupFileNames; + return this; + } + + /** + * Presents a Gog.com login window to the user, login to its account and return a token that can be used later. + * Stores the tocken in a parameter + * @param {SetupWizard} setupWizard The setupWizard to use + * @returns {GogScript} This + */ + loginToGog(setupWizard) { + const browserWindow = setupWizard.createBrowser(tr("Please login to your GoG.com account so that we can download the game for you:")); + browserWindow.goToUrl("https://auth.gog.com/auth?client_id=46899977096215655&redirect_uri=https%3A%2F%2Fembed.gog.com%2Fon_login_success%3Forigin%3Dclient&response_type=code&layout=client2"); + browserWindow.waitForUrl("https://embed.gog.com/*"); + + const currentUrl = browserWindow.getCurrentUrl(); + const code = currentUrl.split("code=")[1].split("&")[0]; + + const tokenUrl = "https://auth.gog.com/token?client_id=46899977096215655&client_secret=9d85c43b1482497dbbce61f6e4aa173a433796eeae2ca8c5f6129f2dc4de46d9&grant_type=authorization_code&code=" + code + "&redirect_uri=https%3A%2F%2Fembed.gog.com%2Fon_login_success%3Forigin%3Dclient"; + this._token = new Downloader().url(tokenUrl).json(); + return this; + } + + _downloadSetupFile(setupWizard, setupFileName, tmpDirectory) { + const url = "https://www.gog.com/downloads/" + setupFileName; + + // We set a user agent so that GoG sends the filename of the executable + return new Downloader() + .url(url) + .wizard(setupWizard) + .to(tmpDirectory) + .headers({ + "Authorization": "Bearer " + this._token["access_token"], + "User-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:64.0) Gecko/20100101 Firefox/64.0" + }) + .get(); + } + + /** + * Download the setup resources in the same directory, and returns the path of the .exe + * @param {SetupWizard} setupWizard The setup wizard + * @returns {String} The .exe file entry that can be used to continue the installation + */ + download(setupWizard) { + const setupDirectory = createTempDir(); + var that = this; + let foundExecutable = null; + this._setupFileNames.forEach(function (setupFileName) { + var downloadedFile = that._downloadSetupFile(setupWizard, setupFileName, setupDirectory); + if (downloadedFile.endsWith(".exe")) { + foundExecutable = downloadedFile; + } + }); + + return foundExecutable; + } + + go() { + const setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature()); + + setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author); + + this.loginToGog(setupWizard); + const setupFile = this.download(setupWizard); + + const wine = new Wine() + .wizard(setupWizard) + .prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion) + .create() + .wait(); + + this._preInstall(wine, setupWizard); + + wine.gdiplus(); + wine.run(setupFile, [], wine.prefixDirectory() + "/drive_c/", true, true); + + this._postInstall(wine, setupWizard); + + this._createShortcut(wine.prefix()); + + setupWizard.close(); + } } diff --git a/Engines/Wine/QuickScript/Installer Script/script.js b/Engines/Wine/QuickScript/Installer Script/script.js index d18dc24878..213191cd73 100644 --- a/Engines/Wine/QuickScript/Installer Script/script.js +++ b/Engines/Wine/QuickScript/Installer Script/script.js @@ -4,91 +4,88 @@ include("utils.functions.filesystem.extract"); include("utils.functions.filesystem.files"); include("engines.wine.verbs.luna"); - -function InstallerScript() { - QuickScript.call(this); -} - -InstallerScript.prototype = Object.create(QuickScript.prototype); - -InstallerScript.prototype.constructor = InstallerScript; - -InstallerScript.prototype.go = function () { - this._name = this._name || "Custom Installer"; - - var setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature()); - - // if no name given, ask user - if (this._name == "Custom Installer") { - this._name = setupWizard.textbox(tr("Please enter the name of your application.")); +class InstallerScript extends QuickScript { + constructor() { + super(); } - setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author); - - // get installation file from concrete InstallerScript implementation - var installationCommand = this._installationCommand(setupWizard); - - var wine = new Wine() - .wizard(setupWizard); + go() { + this._name = this._name || "Custom Installer"; - // let user select wine settings if desired - if (this._wineUserSettings) { - var architectures = ["x86", "amd64"]; - var shownArchitectures = ["x86 (recommended)", "amd64"]; - var selectedArchitecture = setupWizard.menu(tr("Please select the wine architecture."), shownArchitectures, "x86 (recommended)"); - this._wineArchitecture = architectures[selectedArchitecture.index]; + const setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature()); - var distributions = wine.availableDistributions(this._wineArchitecture); - var shownDistributions = []; - for (var distributionIdx in distributions) { - if (distributions[distributionIdx] == "upstream") { - shownDistributions.push("upstream (recommended)"); - } - else { - shownDistributions.push(distributions[distributionIdx]); - } + // if no name given, ask user + if (this._name == "Custom Installer") { + this._name = setupWizard.textbox(tr("Please enter the name of your application.")); } - var selectedDistribution = setupWizard.menu(tr("Please select the wine distribution."), shownDistributions, "upstream (recommended)"); - this._wineDistribution = distributions[selectedDistribution.index]; - - var operatingSystemFetcher = Bean("operatingSystemFetcher"); - var operatingSystem = operatingSystemFetcher.fetchCurrentOperationSystem().getWinePackage(); - var versions = wine.availableVersions(this._wineDistribution + "-" + operatingSystem + "-" + this._wineArchitecture); - var shownVersions = []; - for (var versionIdx in versions) { - if (versions[versionIdx] == LATEST_STABLE_VERSION) { - shownVersions.push(versions[versionIdx] + " (recommended)"); + + setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author); + + // get installation file from concrete InstallerScript implementation + var installationCommand = this._installationCommand(setupWizard); + + var wine = new Wine() + .wizard(setupWizard); + + // let user select wine settings if desired + if (this._wineUserSettings) { + var architectures = ["x86", "amd64"]; + var shownArchitectures = ["x86 (recommended)", "amd64"]; + var selectedArchitecture = setupWizard.menu(tr("Please select the wine architecture."), shownArchitectures, "x86 (recommended)"); + this._wineArchitecture = architectures[selectedArchitecture.index]; + + var distributions = wine.availableDistributions(this._wineArchitecture); + var shownDistributions = []; + for (var distributionIdx in distributions) { + if (distributions[distributionIdx] == "upstream") { + shownDistributions.push("upstream (recommended)"); + } + else { + shownDistributions.push(distributions[distributionIdx]); + } } - else { - shownVersions.push(versions[versionIdx]); + var selectedDistribution = setupWizard.menu(tr("Please select the wine distribution."), shownDistributions, "upstream (recommended)"); + this._wineDistribution = distributions[selectedDistribution.index]; + + var operatingSystemFetcher = Bean("operatingSystemFetcher"); + var operatingSystem = operatingSystemFetcher.fetchCurrentOperationSystem().getWinePackage(); + var versions = wine.availableVersions(this._wineDistribution + "-" + operatingSystem + "-" + this._wineArchitecture); + var shownVersions = []; + for (var versionIdx in versions) { + if (versions[versionIdx] == LATEST_STABLE_VERSION) { + shownVersions.push(versions[versionIdx] + " (recommended)"); + } + else { + shownVersions.push(versions[versionIdx]); + } } + var selectedVersion = setupWizard.menu(tr("Please select the wine version."), shownVersions, LATEST_STABLE_VERSION + " (recommended)"); + this._wineVersion = versions[selectedVersion.index]; } - var selectedVersion = setupWizard.menu(tr("Please select the wine version."), shownVersions, LATEST_STABLE_VERSION + " (recommended)"); - this._wineVersion = versions[selectedVersion.index]; - } - // setup the prefix - wine.prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion) - .luna(); + // setup the prefix + wine.prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion) + .luna(); - this._preInstall(wine, setupWizard); + this._preInstall(wine, setupWizard); - // back to generic wait (might have been changed in preInstall) - setupWizard.wait(tr("Please wait...")); + // back to generic wait (might have been changed in preInstall) + setupWizard.wait(tr("Please wait...")); - wine.run(installationCommand.command, installationCommand.args, false, true); + wine.run(installationCommand.command, installationCommand.args, false, true); - // if no executable given, ask user - if (!this._executable) { - this._executable = fileName(setupWizard.browse(tr("Please select the executable."), wine.prefixDirectory(), ["exe"])); - } + // if no executable given, ask user + if (!this._executable) { + this._executable = fileName(setupWizard.browse(tr("Please select the executable."), wine.prefixDirectory(), ["exe"])); + } - this._createShortcut(wine.prefix()); + this._createShortcut(wine.prefix()); - this._postInstall(wine, setupWizard); + this._postInstall(wine, setupWizard); - // back to generic wait (might have been changed in postInstall) - setupWizard.wait(tr("Please wait...")); + // back to generic wait (might have been changed in postInstall) + setupWizard.wait(tr("Please wait...")); - setupWizard.close(); -}; + setupWizard.close(); + } +} diff --git a/Engines/Wine/QuickScript/Local Installer Script/script.js b/Engines/Wine/QuickScript/Local Installer Script/script.js index de5e98faca..321054147f 100644 --- a/Engines/Wine/QuickScript/Local Installer Script/script.js +++ b/Engines/Wine/QuickScript/Local Installer Script/script.js @@ -1,31 +1,33 @@ include("engines.wine.quick_script.installer_script"); -function LocalInstallerScript() { - InstallerScript.call(this); - this._installationArgs = []; -} - -LocalInstallerScript.prototype = Object.create(InstallerScript.prototype); +class LocalInstallerScript extends InstallerScript { + constructor() { + super(); -LocalInstallerScript.prototype.constructor = LocalInstallerScript; + this._installationArgs = []; + } -LocalInstallerScript.prototype.installationArgs = function (installationArgs) { - if (typeof installationArgs === 'string' || installationArgs instanceof String) { - this._installationArgs = [installationArgs]; - } else { - this._installationArgs = installationArgs; + installationArgs(installationArgs) { + if (typeof installationArgs === 'string' || installationArgs instanceof String) { + this._installationArgs = [installationArgs]; + } else { + this._installationArgs = installationArgs; + } + return this; } - return this; -}; -LocalInstallerScript.prototype.browseMessage = function (browseMessage) { - this._browseMessage = browseMessage; - return this; -}; + browseMessage(browseMessage) { + this._browseMessage = browseMessage; + return this; + } -LocalInstallerScript.prototype._installationCommand = function (wizard) { - var browseMessage = this._browseMessage || tr("Please select the installation file."); - var installationFile = wizard.browse(browseMessage); + _installationCommand(wizard) { + const browseMessage = this._browseMessage || tr("Please select the installation file."); + const installationFile = wizard.browse(browseMessage); - return {command: installationFile, args: this._installationArgs}; -}; + return { + command: installationFile, + args: this._installationArgs + }; + } +} diff --git a/Engines/Wine/QuickScript/Online Installer Script/script.js b/Engines/Wine/QuickScript/Online Installer Script/script.js index a7af0bd5b4..cb4a4ebd7c 100644 --- a/Engines/Wine/QuickScript/Online Installer Script/script.js +++ b/Engines/Wine/QuickScript/Online Installer Script/script.js @@ -1,51 +1,49 @@ include("engines.wine.quick_script.installer_script"); include("utils.functions.net.download"); +class OnlineInstallerScript extends InstallerScript { + constructor() { + super(); -function OnlineInstallerScript() { - InstallerScript.call(this); - this._installationArgs = []; -} - -OnlineInstallerScript.prototype = Object.create(InstallerScript.prototype); - -OnlineInstallerScript.prototype.constructor = OnlineInstallerScript; - -OnlineInstallerScript.prototype.url = function (url) { - this._url = url; - return this; -}; + this._installationArgs = []; + } -OnlineInstallerScript.prototype.checksum = function (checksum) { - this._checksum = checksum; - return this; -}; + url(url) { + this._url = url; + return this; + } -OnlineInstallerScript.prototype.installationArgs = function (installationArgs) { - if (typeof installationArgs === 'string' || installationArgs instanceof String) { - this._installationArgs = [installationArgs]; - } else { - this._installationArgs = installationArgs; + checksum(checksum) { + this._checksum = checksum; + return this; } - return this; -}; -OnlineInstallerScript.prototype._installationCommand = function (wizard) { - // if no URL given, ask user - if (!this._url) { - this._url = wizard.textbox(tr("Please select the download URL.")); + installationArgs(installationArgs) { + if (typeof installationArgs === 'string' || installationArgs instanceof String) { + this._installationArgs = [installationArgs]; + } else { + this._installationArgs = installationArgs; + } + return this; } - // get correct extension depending on URL - var extension = this._url.split('.').pop(); - var installationFile = createTempFile(extension); + _installationCommand(wizard) { + // if no URL given, ask user + if (!this._url) { + this._url = wizard.textbox(tr("Please select the download URL.")); + } + + // get correct extension depending on URL + var extension = this._url.split('.').pop(); + var installationFile = createTempFile(extension); - new Downloader() - .wizard(wizard) - .url(this._url) - .checksum(this._checksum) - .to(installationFile) - .get(); + new Downloader() + .wizard(wizard) + .url(this._url) + .checksum(this._checksum) + .to(installationFile) + .get(); - return {command: installationFile, args: this._installationArgs}; -}; + return { command: installationFile, args: this._installationArgs }; + } +} diff --git a/Engines/Wine/QuickScript/Origin Script/script.js b/Engines/Wine/QuickScript/Origin Script/script.js index 0955ff9e59..58d4d265da 100644 --- a/Engines/Wine/QuickScript/Origin Script/script.js +++ b/Engines/Wine/QuickScript/Origin Script/script.js @@ -4,69 +4,65 @@ include("engines.wine.engine.object"); include("utils.functions.filesystem.files"); include("engines.wine.verbs.luna"); +class OriginScript extends QuickScript { + constructor() { + super(); -function OriginScript() { - QuickScript.call(this); - - this._executable = "Origin.exe"; - this._category = "Games"; -} - -OriginScript.prototype = Object.create(QuickScript.prototype); - -OriginScript.prototype.constructor = OriginScript; - -OriginScript.prototype.appId = function (appId) { - this._appId = appId; - return this; -}; - -OriginScript.prototype.go = function () { + this._executable = "Origin.exe"; + this._category = "Games"; + } - // default executable args if not specified - if (!this._executableArgs) { - this._executableArgs = ["origin://launchgame/" + this._appId]; + appId(appId) { + this._appId = appId; + return this; } - var setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature()); + go() { + // default executable args if not specified + if (!this._executableArgs) { + this._executableArgs = ["origin://launchgame/" + this._appId]; + } + + const setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature()); - setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author); + setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author); - var tempFile = createTempFile("exe"); + const tempFile = createTempFile("exe"); - new Downloader() - .wizard(setupWizard) - .url("https://origin-a.akamaihd.net/Origin-Client-Download/origin/live/OriginThinSetup.exe") - .to(tempFile) - .get(); + new Downloader() + .wizard(setupWizard) + .url("https://origin-a.akamaihd.net/Origin-Client-Download/origin/live/OriginThinSetup.exe") + .to(tempFile) + .get(); - var wine = new Wine() - .wizard(setupWizard) - .prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion) - .luna(); + const wine = new Wine() + .wizard(setupWizard) + .prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion) + .luna(); - //Origin does not have an install command - setupWizard.message(tr("Download \"{0}\" in Origin and shut it down once \"{0}\" is installed", this._name)); - wine.run(tempFile, [], null, false, true); + //Origin does not have an install command + setupWizard.message(tr("Download \"{0}\" in Origin and shut it down once \"{0}\" is installed", this._name)); + wine.run(tempFile, [], null, false, true); - // wait until Origin and Wine are closed - wine.wait(); + // wait until Origin and Wine are closed + wine.wait(); - // Origin installation has finished - setupWizard.wait(tr("Please wait...")); + // Origin installation has finished + setupWizard.wait(tr("Please wait...")); - this._preInstall(wine, setupWizard); + this._preInstall(wine, setupWizard); - // back to generic wait (might have been changed in preInstall) - setupWizard.wait(tr("Please wait...")); + // back to generic wait (might have been changed in preInstall) + setupWizard.wait(tr("Please wait...")); - this._postInstall(wine, setupWizard); + this._postInstall(wine, setupWizard); - // create shortcut after installation (if executable is specified, it does not exist earlier) - this._createShortcut(wine.prefix()); + // create shortcut after installation (if executable is specified, it does not exist earlier) + this._createShortcut(wine.prefix()); - // back to generic wait (might have been changed in postInstall) - setupWizard.wait(tr("Please wait...")); + // back to generic wait (might have been changed in postInstall) + setupWizard.wait(tr("Please wait...")); - setupWizard.close(); -}; + setupWizard.close(); + } +} diff --git a/Engines/Wine/QuickScript/Quick Script/script.js b/Engines/Wine/QuickScript/Quick Script/script.js index 87e773c347..7002741e00 100644 --- a/Engines/Wine/QuickScript/Quick Script/script.js +++ b/Engines/Wine/QuickScript/Quick Script/script.js @@ -1,132 +1,136 @@ include("engines.wine.shortcuts.wine"); -function QuickScript() { - this._wineVersion = LATEST_STABLE_VERSION; - this._wineArchitecture = "x86"; - this._wineDistribution = "upstream"; +class QuickScript { + constructor() { + this._wineVersion = LATEST_STABLE_VERSION; + this._wineArchitecture = "x86"; + this._wineDistribution = "upstream"; + this._wineUserSettings = false; + + this._type = "Applications"; + + // by default do nothing in post install + this._postInstall = function () { }; + this._preInstall = function () { }; + + const appsManager = Bean("repositoryManager"); + const application = appsManager.getApplication([TYPE_ID, CATEGORY_ID, APPLICATION_ID]); + + this._miniature = java.util.Optional.empty(); + if (application) { + this._miniature = application.getMainMiniature(); + } + } - this._type = "Applications"; + name(name) { + this._name = name; + return this; + } - // by default do nothing in post install - this._postInstall = function () {}; - this._preInstall = function () {}; - this._wineUserSettings = false; + editor(editor) { + this._editor = editor; + return this; + } - var appsManager = Bean("repositoryManager"); - var application = appsManager.getApplication([TYPE_ID, CATEGORY_ID, APPLICATION_ID]); - this._miniature = java.util.Optional.empty(); - if (application) { - this._miniature = application.getMainMiniature(); + applicationHomepage(applicationHomepage) { + this._applicationHomepage = applicationHomepage; + return this; + } + + author(author) { + this._author = author; + return this; + } + + type(type) { + this._type = type; + return this; } -} -QuickScript.prototype.name = function (name) { - this._name = name; - return this; -}; - -QuickScript.prototype.editor = function (editor) { - this._editor = editor; - return this; -}; - -QuickScript.prototype.applicationHomepage = function (applicationHomepage) { - this._applicationHomepage = applicationHomepage; - return this; -}; - -QuickScript.prototype.author = function (author) { - this._author = author; - return this; -}; - -QuickScript.prototype.type = function (type) { - this._type = type; - return this; -}; - -QuickScript.prototype.category = function (category) { - this._category = category; - return this; -}; - -/** - * get/set miniature (for the installation and the shortcut) - * @param {URI} [miniature] path to the miniature file - */ -QuickScript.prototype.miniature = function (miniature) { - // get - if (arguments.length == 0) { - return this._miniature; - } - - // set - this._miniature = java.util.Optional.of(miniature); - return this; -}; - -/** - * set executable - * @param executable executable without path (e.g. "Steam.exe") - * @param args use array (e.g. ["-applaunch", 409160]) - */ -QuickScript.prototype.executable = function (executable, args) { - this._executable = executable; - this._executableArgs = typeof args !== 'undefined' ? args : ""; - return this; -}; - -QuickScript.prototype.wineArchitecture = function (wineArchitecture) { - this._wineArchitecture = wineArchitecture; - return this; -}; - -QuickScript.prototype.wineDistribution = function (wineDistribution) { - this._wineDistribution = wineDistribution; - return this; -}; - -QuickScript.prototype.wineVersion = function (wineVersion) { - this._wineVersion = wineVersion; - return this; -}; - -QuickScript.prototype.wineUserSettings = function (wineUserSettings) { - // get - if (arguments.length == 0) { - return this._wineUserSettings; - } - - // set - this._wineUserSettings = wineUserSettings; - return this; -}; - -QuickScript.prototype.postInstall = function (postInstall) { - this._postInstall = postInstall; - return this; -}; - -QuickScript.prototype.preInstall = function (preInstall) { - this._preInstall = preInstall; - return this; -}; - -/** - * creates shortcut - * @param {string} [prefix] prefix name - */ -QuickScript.prototype._createShortcut = function (prefix) { - var shortcut = new WineShortcut() - .name(this._name) - .type(this._type) - .category(this._category) - .prefix(prefix) - .search(this._executable) - .arguments(this._executableArgs); - - if (this.miniature().isPresent()) { - shortcut.miniature(this.miniature().get()) - } - shortcut.create(); -}; + category(category) { + this._category = category; + return this; + } + + /** + * get/set miniature (for the installation and the shortcut) + * @param {URI} [miniature] path to the miniature file + */ + miniature(miniature) { + // get + if (arguments.length == 0) { + return this._miniature; + } + + // set + this._miniature = java.util.Optional.of(miniature); + return this; + } + + /** + * set executable + * @param executable executable without path (e.g. "Steam.exe") + * @param args use array (e.g. ["-applaunch", 409160]) + */ + executable(executable, args) { + this._executable = executable; + this._executableArgs = typeof args !== 'undefined' ? args : ""; + return this; + } + + wineArchitecture(wineArchitecture) { + this._wineArchitecture = wineArchitecture; + return this; + } + + wineDistribution(wineDistribution) { + this._wineDistribution = wineDistribution; + return this; + } + + wineVersion(wineVersion) { + this._wineVersion = wineVersion; + return this; + } + + wineUserSettings(wineUserSettings) { + // get + if (arguments.length == 0) { + return this._wineUserSettings; + } + + // set + this._wineUserSettings = wineUserSettings; + return this; + } + + postInstall(postInstall) { + this._postInstall = postInstall; + return this; + } + + preInstall(preInstall) { + this._preInstall = preInstall; + return this; + } + + /** + * creates shortcut + * @param {string} [prefix] prefix name + */ + _createShortcut(prefix) { + const shortcut = new WineShortcut() + .name(this._name) + .type(this._type) + .category(this._category) + .prefix(prefix) + .search(this._executable) + .arguments(this._executableArgs); + + if (this.miniature().isPresent()) { + shortcut.miniature(this.miniature().get()) + } + + shortcut.create(); + } +} diff --git a/Engines/Wine/QuickScript/Steam Script/script.js b/Engines/Wine/QuickScript/Steam Script/script.js index 6b44dec29b..9ba8df5657 100644 --- a/Engines/Wine/QuickScript/Steam Script/script.js +++ b/Engines/Wine/QuickScript/Steam Script/script.js @@ -8,185 +8,179 @@ include("engines.wine.verbs.luna"); include("engines.wine.verbs.corefonts"); include("engines.wine.plugins.windows_version"); +class SteamScript extends QuickScript { + constructor() { + super(); -function SteamScript() { - QuickScript.call(this); - - this._executable = "Steam.exe"; - this._category = "Games"; - this._gameOverlay = true; -} - -SteamScript.prototype = Object.create(QuickScript.prototype); - -SteamScript.prototype.constructor = SteamScript; - -SteamScript.prototype.appId = function (appId) { - this._appId = appId; - return this; -}; + this._executable = "Steam.exe"; + this._category = "Games"; + this._gameOverlay = true; + } -SteamScript.prototype.gameOverlay = function (gameOverlay) { - // get - if (arguments.length == 0) { - return this._gameOverlay; + appId(appId) { + this._appId = appId; + return this; } - // set - this._gameOverlay = gameOverlay; - return this; -}; + gameOverlay(gameOverlay) { + // get + if (arguments.length == 0) { + return this._gameOverlay; + } -SteamScript.prototype.manifest = function (wine) { - if (!this._manifest) { - // cache manifest path (will not change during the installation) - this._manifest = wine.prefixDirectory() + "/drive_c/" + wine.programFiles() + "/Steam/steamapps/appmanifest_" + this._appId + ".acf"; - } - return this._manifest; -}; - -SteamScript.prototype.downloadStarted = function (wine) { - if (fileExists(this.manifest(wine))) - { - var manifest = cat(this.manifest(wine)); - var state = Number(manifest.match(/\"StateFlags\"\s+\"(\d+)\"/)[1]); - return state == 1026 || state == 1042 || state == 1062 || state == 1030; - } - else - { - return false; + // set + this._gameOverlay = gameOverlay; + return this; } -}; - -SteamScript.prototype.downloadFinished = function (wine) { - // check if download already finished (download folder has been deleted) - if (fileExists(this.manifest(wine))) - { - var manifest = cat(this.manifest(wine)); - var state = Number(manifest.match(/\"StateFlags\"\s+\"(\d+)\"/)[1]); - return state != 1026 && state != 1042 && state != 1062 && state != 1030; + + manifest(wine) { + if (!this._manifest) { + // cache manifest path (will not change during the installation) + this._manifest = wine.prefixDirectory() + "/drive_c/" + wine.programFiles() + "/Steam/steamapps/appmanifest_" + this._appId + ".acf"; + } + return this._manifest; } - else - { - return false; + + downloadStarted(wine) { + if (fileExists(this.manifest(wine))) { + const manifest = cat(this.manifest(wine)); + const state = Number(manifest.match(/\"StateFlags\"\s+\"(\d+)\"/)[1]); + return state == 1026 || state == 1042 || state == 1062 || state == 1030; + } + else { + return false; + } } -}; -SteamScript.prototype.configVdf = function (wine) { - if (!this._configVdf) { - // cache config.vdf path (will not change during the installation) - this._configVdf = wine.prefixDirectory() + "/drive_c/" + wine.programFiles() + "/Steam/config/config.vdf"; + downloadFinished(wine) { + // check if download already finished (download folder has been deleted) + if (fileExists(this.manifest(wine))) { + const manifest = cat(this.manifest(wine)); + const state = Number(manifest.match(/\"StateFlags\"\s+\"(\d+)\"/)[1]); + return state != 1026 && state != 1042 && state != 1062 && state != 1030; + } + else { + return false; + } } - return this._configVdf; -}; - -// Fix for the "content server unavailable" error (Wine bug 45329) -SteamScript.prototype.fixCertificateIssue = function (wine){ - var steamConfigFile = this.configVdf(wine); - var steamConfig = cat(steamConfigFile); - var cmPos = steamConfig.indexOf("\"CM\""); - var csConfig = "\"CS\" \"valve511.steamcontent.com;valve501.steamcontent.com;valve517.steamcontent.com;valve557.steamcontent.com;valve513.steamcontent.com;valve535.steamcontent.com;valve546.steamcontent.com;valve538.steamcontent.com;valve536.steamcontent.com;valve530.steamcontent.com;valve559.steamcontent.com;valve545.steamcontent.com;valve518.steamcontent.com;valve548.steamcontent.com;valve555.steamcontent.com;valve556.steamcontent.com;valve506.steamcontent.com;valve544.steamcontent.com;valve525.steamcontent.com;valve567.steamcontent.com;valve521.steamcontent.com;valve510.steamcontent.com;valve542.steamcontent.com;valve519.steamcontent.com;valve526.steamcontent.com;valve504.steamcontent.com;valve500.steamcontent.com;valve554.steamcontent.com;valve562.steamcontent.com;valve524.steamcontent.com;valve502.steamcontent.com;valve505.steamcontent.com;valve547.steamcontent.com;valve560.steamcontent.com;valve503.steamcontent.com;valve507.steamcontent.com;valve553.steamcontent.com;valve520.steamcontent.com;valve550.steamcontent.com;valve531.steamcontent.com;valve558.steamcontent.com;valve552.steamcontent.com;valve563.steamcontent.com;valve540.steamcontent.com;valve541.steamcontent.com;valve537.steamcontent.com;valve528.steamcontent.com;valve523.steamcontent.com;valve512.steamcontent.com;valve532.steamcontent.com;valve561.steamcontent.com;valve549.steamcontent.com;valve522.steamcontent.com;valve514.steamcontent.com;valve551.steamcontent.com;valve564.steamcontent.com;valve543.steamcontent.com;valve565.steamcontent.com;valve529.steamcontent.com;valve539.steamcontent.com;valve566.steamcontent.com;valve165.steamcontent.com;valve959.steamcontent.com;valve164.steamcontent.com;valve1611.steamcontent.com;valve1601.steamcontent.com;valve1617.steamcontent.com;valve1603.steamcontent.com;valve1602.steamcontent.com;valve1610.steamcontent.com;valve1615.steamcontent.com;valve909.steamcontent.com;valve900.steamcontent.com;valve905.steamcontent.com;valve954.steamcontent.com;valve955.steamcontent.com;valve1612.steamcontent.com;valve1607.steamcontent.com;valve1608.steamcontent.com;valve1618.steamcontent.com;valve1619.steamcontent.com;valve1606.steamcontent.com;valve1605.steamcontent.com;valve1609.steamcontent.com;valve907.steamcontent.com;valve901.steamcontent.com;valve902.steamcontent.com;valve1604.steamcontent.com;valve908.steamcontent.com;valve950.steamcontent.com;valve957.steamcontent.com;valve903.steamcontent.com;valve1614.steamcontent.com;valve904.steamcontent.com;valve952.steamcontent.com;valve1616.steamcontent.com;valve1613.steamcontent.com;valve958.steamcontent.com;valve956.steamcontent.com;valve906.steamcontent.com\"\n"; - var newSteamConfig = steamConfig.slice(0, cmPos) + csConfig + steamConfig.slice(cmPos); - writeToFile(steamConfigFile, newSteamConfig) -} -SteamScript.prototype.go = function () { - // default application homepage if not specified - if (!this._applicationHomepage) { - this._applicationHomepage = "https://store.steampowered.com/app/" + this._appId; + configVdf(wine) { + if (!this._configVdf) { + // cache config.vdf path (will not change during the installation) + this._configVdf = wine.prefixDirectory() + "/drive_c/" + wine.programFiles() + "/Steam/config/config.vdf"; + } + return this._configVdf; } - // default executable args if not specified - if (!this._executableArgs) { - this._executableArgs = ["-no-cef-sandbox", "-silent", "-applaunch", this._appId]; + // Fix for the "content server unavailable" error (Wine bug 45329) + fixCertificateIssue(wine) { + const steamConfigFile = this.configVdf(wine); + const steamConfig = cat(steamConfigFile); + const cmPos = steamConfig.indexOf("\"CM\""); + const csConfig = "\"CS\" \"valve511.steamcontent.com;valve501.steamcontent.com;valve517.steamcontent.com;valve557.steamcontent.com;valve513.steamcontent.com;valve535.steamcontent.com;valve546.steamcontent.com;valve538.steamcontent.com;valve536.steamcontent.com;valve530.steamcontent.com;valve559.steamcontent.com;valve545.steamcontent.com;valve518.steamcontent.com;valve548.steamcontent.com;valve555.steamcontent.com;valve556.steamcontent.com;valve506.steamcontent.com;valve544.steamcontent.com;valve525.steamcontent.com;valve567.steamcontent.com;valve521.steamcontent.com;valve510.steamcontent.com;valve542.steamcontent.com;valve519.steamcontent.com;valve526.steamcontent.com;valve504.steamcontent.com;valve500.steamcontent.com;valve554.steamcontent.com;valve562.steamcontent.com;valve524.steamcontent.com;valve502.steamcontent.com;valve505.steamcontent.com;valve547.steamcontent.com;valve560.steamcontent.com;valve503.steamcontent.com;valve507.steamcontent.com;valve553.steamcontent.com;valve520.steamcontent.com;valve550.steamcontent.com;valve531.steamcontent.com;valve558.steamcontent.com;valve552.steamcontent.com;valve563.steamcontent.com;valve540.steamcontent.com;valve541.steamcontent.com;valve537.steamcontent.com;valve528.steamcontent.com;valve523.steamcontent.com;valve512.steamcontent.com;valve532.steamcontent.com;valve561.steamcontent.com;valve549.steamcontent.com;valve522.steamcontent.com;valve514.steamcontent.com;valve551.steamcontent.com;valve564.steamcontent.com;valve543.steamcontent.com;valve565.steamcontent.com;valve529.steamcontent.com;valve539.steamcontent.com;valve566.steamcontent.com;valve165.steamcontent.com;valve959.steamcontent.com;valve164.steamcontent.com;valve1611.steamcontent.com;valve1601.steamcontent.com;valve1617.steamcontent.com;valve1603.steamcontent.com;valve1602.steamcontent.com;valve1610.steamcontent.com;valve1615.steamcontent.com;valve909.steamcontent.com;valve900.steamcontent.com;valve905.steamcontent.com;valve954.steamcontent.com;valve955.steamcontent.com;valve1612.steamcontent.com;valve1607.steamcontent.com;valve1608.steamcontent.com;valve1618.steamcontent.com;valve1619.steamcontent.com;valve1606.steamcontent.com;valve1605.steamcontent.com;valve1609.steamcontent.com;valve907.steamcontent.com;valve901.steamcontent.com;valve902.steamcontent.com;valve1604.steamcontent.com;valve908.steamcontent.com;valve950.steamcontent.com;valve957.steamcontent.com;valve903.steamcontent.com;valve1614.steamcontent.com;valve904.steamcontent.com;valve952.steamcontent.com;valve1616.steamcontent.com;valve1613.steamcontent.com;valve958.steamcontent.com;valve956.steamcontent.com;valve906.steamcontent.com\"\n"; + const newSteamConfig = steamConfig.slice(0, cmPos) + csConfig + steamConfig.slice(cmPos); + writeToFile(steamConfigFile, newSteamConfig) } - var setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature()); + go() { + // default application homepage if not specified + if (!this._applicationHomepage) { + this._applicationHomepage = "https://store.steampowered.com/app/" + this._appId; + } - setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author); + // default executable args if not specified + if (!this._executableArgs) { + this._executableArgs = ["-no-cef-sandbox", "-silent", "-applaunch", this._appId]; + } - var tempFile = createTempFile("exe"); + const setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature()); - new Downloader() - .wizard(setupWizard) - .url("https://steamcdn-a.akamaihd.net/client/installer/SteamSetup.exe") - .checksum("4b1b85ec2499a4ce07c89609b256923a4fc479e5") - .to(tempFile) - .get(); + setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author); - var wine = new Wine() - .wizard(setupWizard) - .prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion) - .luna(); - wine.corefonts(); + const tempFile = createTempFile("exe"); - // Steam must be started once such that config.vdf is created (see fixCertificateIssue()) - setupWizard.wait(tr("Please follow the steps of the Steam setup. Then, wait until Steam is updated, log in and finally close Steam completely so the installation of \"{0}\" can continue.", this._name)); - wine.run(tempFile, [], null, false, true); + new Downloader() + .wizard(setupWizard) + .url("https://steamcdn-a.akamaihd.net/client/installer/SteamSetup.exe") + .checksum("4b1b85ec2499a4ce07c89609b256923a4fc479e5") + .to(tempFile) + .get(); - // Set windows environment for executable that needs it - wine.setOsForApplication().set("steam.exe", "winxp").do(); - wine.setOsForApplication().set("steamwebhelper.exe", "winxp").do(); + const wine = new Wine() + .wizard(setupWizard) + .prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion) + .luna(); - // Fix for Uplay games that are executed on steam - wine.setOsForApplication().set("upc.exe", "winvista").do(); - wine.setOsForApplication().set("UbisoftGameLauncher.exe", "winvista").do(); + wine.corefonts(); - // ensure that Steam is running (user might have unchecked "run Steam after installation finished") - wine.runInsidePrefix(wine.programFiles() + "/Steam/Steam.exe", ["steam://nav/games"], false); + // Steam must be started once such that config.vdf is created (see fixCertificateIssue()) + setupWizard.wait(tr("Please follow the steps of the Steam setup. Then, wait until Steam is updated, log in and finally close Steam completely so the installation of \"{0}\" can continue.", this._name)); + wine.run(tempFile, [], null, false, true); - // wait until config.vdf exists - while (!fileExists(this.configVdf(wine))) { - java.lang.Thread.sleep(1000); - } + // Set windows environment for executable that needs it + wine.setOsForApplication().set("steam.exe", "winxp").do(); + wine.setOsForApplication().set("steamwebhelper.exe", "winxp").do(); - // wait until Steam and Wine are closed - wine.wait(); + // Fix for Uplay games that are executed on steam + wine.setOsForApplication().set("upc.exe", "winvista").do(); + wine.setOsForApplication().set("UbisoftGameLauncher.exe", "winvista").do(); - this.fixCertificateIssue(wine); + // ensure that Steam is running (user might have unchecked "run Steam after installation finished") + wine.runInsidePrefix(wine.programFiles() + "/Steam/Steam.exe", ["steam://nav/games"], false); - // Steam installation has finished - setupWizard.wait(tr("Please wait...")); + // wait until config.vdf exists + while (!fileExists(this.configVdf(wine))) { + java.lang.Thread.sleep(1000); + } - this._preInstall(wine, setupWizard); + // wait until Steam and Wine are closed + wine.wait(); - // back to generic wait (might have been changed in preInstall) - setupWizard.wait(tr("Please wait...")); + this.fixCertificateIssue(wine); - wine.runInsidePrefix(wine.programFiles() + "/Steam/Steam.exe", ["steam://install/" + this._appId], false); + // Steam installation has finished + setupWizard.wait(tr("Please wait...")); - setupWizard.wait(tr("Please wait until Steam has finished the download...")); + this._preInstall(wine, setupWizard); - // wait until download started - while (!this.downloadStarted(wine)) { - java.lang.Thread.sleep(100); - } + // back to generic wait (might have been changed in preInstall) + setupWizard.wait(tr("Please wait...")); - // make sure download is finished - while (!this.downloadFinished(wine)) { - java.lang.Thread.sleep(1000); - } + wine.runInsidePrefix(wine.programFiles() + "/Steam/Steam.exe", ["steam://install/" + this._appId], false); - // close Steam - wine.runInsidePrefix(wine.programFiles() + "/Steam/Steam.exe", "-shutdown", true); + setupWizard.wait(tr("Please wait until Steam has finished the download...")); - // back to generic wait - setupWizard.wait(tr("Please wait...")); + // wait until download started + while (!this.downloadStarted(wine)) { + java.lang.Thread.sleep(100); + } - // create shortcut after installation (if executable is specified, it does not exist earlier) - this._createShortcut(wine.prefix()); + // make sure download is finished + while (!this.downloadFinished(wine)) { + java.lang.Thread.sleep(1000); + } - this._postInstall(wine, setupWizard); + // close Steam + wine.runInsidePrefix(wine.programFiles() + "/Steam/Steam.exe", "-shutdown", true); - // deactivate game overlay if desired - if (!this._gameOverlay) { - wine.overrideDLL() - .set("", ["gameoverlayrenderer"]) - .do(); - } + // back to generic wait + setupWizard.wait(tr("Please wait...")); - // back to generic wait (might have been changed in postInstall) - setupWizard.wait(tr("Please wait...")); + // create shortcut after installation (if executable is specified, it does not exist earlier) + this._createShortcut(wine.prefix()); - setupWizard.close(); -}; + this._postInstall(wine, setupWizard); + + // deactivate game overlay if desired + if (!this._gameOverlay) { + wine.overrideDLL() + .set("", ["gameoverlayrenderer"]) + .do(); + } + + // back to generic wait (might have been changed in postInstall) + setupWizard.wait(tr("Please wait...")); + + setupWizard.close(); + } +} diff --git a/Engines/Wine/QuickScript/Uplay Script/script.js b/Engines/Wine/QuickScript/Uplay Script/script.js index 8aac8932a9..b27e94ffba 100644 --- a/Engines/Wine/QuickScript/Uplay Script/script.js +++ b/Engines/Wine/QuickScript/Uplay Script/script.js @@ -7,90 +7,88 @@ include("engines.wine.verbs.luna"); include("engines.wine.verbs.corefonts"); include("engines.wine.plugins.windows_version"); -function UplayScript() { - QuickScript.call(this); +class UplayScript extends QuickScript { + constructor() { + super(); - this._executable = "Uplay.exe"; - this._category = "Games"; - this._gameOverlay = true; -} - -UplayScript.prototype = Object.create(QuickScript.prototype); - -UplayScript.prototype.constructor = UplayScript; - -UplayScript.prototype.appId = function (appId) { - this._appId = appId; - return this; -}; + this._executable = "Uplay.exe"; + this._category = "Games"; + this._gameOverlay = true; + } -UplayScript.prototype.downloadStarted = function (wine) { - return fileExists(wine.prefixDirectory() + "/drive_c/" + wine.programFiles() + "/Ubisoft/Ubisoft Game Launcher/data/" + this._appId + "/manifests"); -}; + appId(appId) { + this._appId = appId; + return this; + } -UplayScript.prototype.downloadFinished = function (wine) { - return !fileExists(wine.prefixDirectory() + "/drive_c/" + wine.programFiles() + "/Ubisoft/Ubisoft Game Launcher/data/" + this._appId + "/manifests"); -}; + downloadStarted(wine) { + return fileExists(wine.prefixDirectory() + "/drive_c/" + wine.programFiles() + "/Ubisoft/Ubisoft Game Launcher/data/" + this._appId + "/manifests"); + } -UplayScript.prototype.go = function () { - // default executable args if not specified - if (!this._executableArgs) { - this._executableArgs = ["uplay://launch/" + this._appId + "/0"]; + downloadFinished(wine) { + return !fileExists(wine.prefixDirectory() + "/drive_c/" + wine.programFiles() + "/Ubisoft/Ubisoft Game Launcher/data/" + this._appId + "/manifests"); } - var setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature()); + go() { + // default executable args if not specified + if (!this._executableArgs) { + this._executableArgs = ["uplay://launch/" + this._appId + "/0"]; + } - setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author); + const setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature()); - var tempFile = createTempFile("exe"); + setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author); - new Downloader() - .wizard(setupWizard) - .url("https://ubistatic3-a.akamaihd.net/orbit/launcher_installer/UplayInstaller.exe") - .to(tempFile) - .get(); + const tempFile = createTempFile("exe"); - var wine = new Wine() - .wizard(setupWizard) - .prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion) - .luna(); + new Downloader() + .wizard(setupWizard) + .url("https://ubistatic3-a.akamaihd.net/orbit/launcher_installer/UplayInstaller.exe") + .to(tempFile) + .get(); - wine.corefonts(); + const wine = new Wine() + .wizard(setupWizard) + .prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion) + .luna(); - setupWizard.message(tr("Please ensure that winbind is installed before you continue.")); - setupWizard.wait(tr("Please follow the steps of the Uplay setup.\n\nUncheck \"Run Uplay\" or close Uplay completely after the setup so that the installation of \"{0}\" can continue.", this._name)); - wine.run(tempFile, [], null, false, true); + wine.corefonts(); - wine.setOsForApplication().set("upc.exe", "winvista").do(); - wine.setOsForApplication().set("UbisoftGameLauncher.exe", "winvista").do(); + setupWizard.message(tr("Please ensure that winbind is installed before you continue.")); + setupWizard.wait(tr("Please follow the steps of the Uplay setup.\n\nUncheck \"Run Uplay\" or close Uplay completely after the setup so that the installation of \"{0}\" can continue.", this._name)); + wine.run(tempFile, [], null, false, true); - // Uplay installation has finished - setupWizard.wait(tr("Please wait...")); + wine.setOsForApplication().set("upc.exe", "winvista").do(); + wine.setOsForApplication().set("UbisoftGameLauncher.exe", "winvista").do(); - this._preInstall(wine, setupWizard); + // Uplay installation has finished + setupWizard.wait(tr("Please wait...")); - // back to generic wait (might have been changed in preInstall) - setupWizard.wait(tr("Please wait...")); + this._preInstall(wine, setupWizard); - this._createShortcut(wine.prefix()); + // back to generic wait (might have been changed in preInstall) + setupWizard.wait(tr("Please wait...")); - wine.runInsidePrefix(wine.programFiles() + "/Ubisoft/Ubisoft Game Launcher/Uplay.exe", ["uplay://launch/" + this._appId + "/0"], true); + this._createShortcut(wine.prefix()); - // wait until download is finished - setupWizard.wait(tr("Please wait until Uplay has finished the download...")); - while (!this.downloadStarted(wine)) { - java.lang.Thread.sleep(100); - } - while (!this.downloadFinished(wine)) { - java.lang.Thread.sleep(1000); - } + wine.runInsidePrefix(wine.programFiles() + "/Ubisoft/Ubisoft Game Launcher/Uplay.exe", ["uplay://launch/" + this._appId + "/0"], true); - setupWizard.message(tr("Please close Uplay.")); + // wait until download is finished + setupWizard.wait(tr("Please wait until Uplay has finished the download...")); + while (!this.downloadStarted(wine)) { + java.lang.Thread.sleep(100); + } + while (!this.downloadFinished(wine)) { + java.lang.Thread.sleep(1000); + } - this._postInstall(wine, setupWizard); + setupWizard.message(tr("Please close Uplay.")); - // back to generic wait (might have been changed in postInstall) - setupWizard.wait(tr("Please wait...")); + this._postInstall(wine, setupWizard); - setupWizard.close(); -}; + // back to generic wait (might have been changed in postInstall) + setupWizard.wait(tr("Please wait...")); + + setupWizard.close(); + } +} diff --git a/Engines/Wine/QuickScript/Zip Script/script.js b/Engines/Wine/QuickScript/Zip Script/script.js index 73c85894e8..e6a08a30d3 100644 --- a/Engines/Wine/QuickScript/Zip Script/script.js +++ b/Engines/Wine/QuickScript/Zip Script/script.js @@ -4,67 +4,64 @@ include("engines.wine.engine.object"); include("utils.functions.filesystem.extract"); include("engines.wine.verbs.luna"); +class ZipScript extends QuickScript { + constructor() { + super(); + } -function ZipScript() { - QuickScript.call(this); -} - -ZipScript.prototype = Object.create(QuickScript.prototype); - -ZipScript.prototype.constructor = ZipScript; - -ZipScript.prototype.url = function (url) { - this._url = url; - return this; -}; - -ZipScript.prototype.checksum = function (checksum) { - this._checksum = checksum; - return this; -}; - -ZipScript.prototype.go = function () { - var setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature()); - - setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author); + url(url) { + this._url = url; + return this; + } - var wine = new Wine() - .wizard(setupWizard) - .prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion) - .create() - .luna() - .wait(); + checksum(checksum) { + this._checksum = checksum; + return this; + } - this._preInstall(wine, setupWizard); + go() { + const setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature()); - // back to generic wait (might have been changed in preInstall) - setupWizard.wait(tr("Please wait...")); + setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author); - var archive = ""; - if (!this._url) { - archive = setupWizard.browse(tr("Please select the .zip file."), wine.prefixDirectory(), ["zip"]); - } else { - archive = wine.prefixDirectory() + "/drive_c/archive.zip"; - new Downloader() + const wine = new Wine() .wizard(setupWizard) - .url(this._url) - .checksum(this._checksum) - .to(archive) - .get(); - } - - new Extractor() - .wizard(setupWizard) - .archive(archive) - .to(wine.prefixDirectory() + "/drive_c/" + this._name) - .extract(); + .prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion) + .create() + .luna() + .wait(); + + this._preInstall(wine, setupWizard); + + // back to generic wait (might have been changed in preInstall) + setupWizard.wait(tr("Please wait...")); + + let archive = ""; + if (!this._url) { + archive = setupWizard.browse(tr("Please select the .zip file."), wine.prefixDirectory(), ["zip"]); + } else { + archive = wine.prefixDirectory() + "/drive_c/archive.zip"; + new Downloader() + .wizard(setupWizard) + .url(this._url) + .checksum(this._checksum) + .to(archive) + .get(); + } + + new Extractor() + .wizard(setupWizard) + .archive(archive) + .to(wine.prefixDirectory() + "/drive_c/" + this._name) + .extract(); - this._postInstall(wine, setupWizard); + this._postInstall(wine, setupWizard); - this._createShortcut(wine.prefix()); + this._createShortcut(wine.prefix()); - // back to generic wait (might have been changed in postInstall) - setupWizard.wait(tr("Please wait...")); + // back to generic wait (might have been changed in postInstall) + setupWizard.wait(tr("Please wait...")); - setupWizard.close(); -}; + setupWizard.close(); + } +}