diff --git a/Engines/Wine/QuickScript/Quick Script/script.js b/Engines/Wine/QuickScript/Quick Script/script.js index ae025ad3dd..8fd5338a74 100644 --- a/Engines/Wine/QuickScript/Quick Script/script.js +++ b/Engines/Wine/QuickScript/Quick Script/script.js @@ -1,9 +1,9 @@ -const {LATEST_STABLE_VERSION} = include("engines.wine.engine.versions"); +const { getLatestStableVersion } = include("engines.wine.engine.versions"); const WineShortcut = include("engines.wine.shortcuts.wine"); module.default = class QuickScript { constructor() { - this._wineVersion = LATEST_STABLE_VERSION; + this._wineVersionFunction = getLatestStableVersion; this._wineArchitecture = "x86"; this._wineDistribution = "upstream"; this._wineUserSettings = false; @@ -20,6 +20,12 @@ module.default = class QuickScript { this._miniature = java.util.Optional.empty(); if (application) { this._miniature = application.getMainMiniature(); + + // category icon + const category = appsManager.getCategory([TYPE_ID, CATEGORY_ID]); + if (category != null) { + this._categoryIcon = category.getIcon(); + } } } @@ -56,6 +62,7 @@ module.default = class QuickScript { /** * get/set miniature (for the installation and the shortcut) * @param {URI} [miniature] path to the miniature file + * @returns {java.util.Optional} path to miniature (if used as getter), else QuickScript object */ miniature(miniature) { // get @@ -70,8 +77,9 @@ module.default = class QuickScript { /** * set executable - * @param executable executable without path (e.g. "Steam.exe") - * @param args use array (e.g. ["-applaunch", 409160]) + * @param {string} executable executable without path (e.g. "Steam.exe") + * @param {array} args use array (e.g. ["-applaunch", 409160]) + * @returns {QuickScript} QuickScript object */ executable(executable, args) { this._executable = executable; @@ -90,7 +98,11 @@ module.default = class QuickScript { } wineVersion(wineVersion) { - this._wineVersion = wineVersion; + if (wineVersion && wineVersion instanceof Function) { + this._wineVersionFunction = wineVersion; + } else { + this._wineVersionFunction = function () { return wineVersion; }; + } return this; } @@ -120,14 +132,18 @@ module.default = class QuickScript { * @param {string} environment variables * @returns {QuickScript} QuickScript object */ - environment(environment) { - this._environment = environment; + environment(environmentFunc) { + if (environmentFunc && environmentFunc instanceof Function) { + this._environmentFunc= environmentFunc; + } else { + throw new Error(tr("The argument of environment() should be a function !")); + } return this; } /** * set trust level - * @param {string} trustlevel + * @param {string} trustLevel trust level * @returns {QuickScript} QuickScript object */ trustLevel(trustLevel) { @@ -135,9 +151,20 @@ module.default = class QuickScript { return this; } + /** + * determines which Wine version should be used + * required in case the version is computed by a function + * @param {wizard} wizard setup wizard (e.g. to show download progress of versions json) + * @returns {void} + */ + _determineWineVersion(wizard) { + this._wineVersion = this._wineVersionFunction(wizard, this._wineArchitecture); + } + /** * creates shortcut * @param {string} [prefix] prefix name + * @returns {void} */ _createShortcut(prefix) { const shortcut = new WineShortcut() @@ -154,6 +181,10 @@ module.default = class QuickScript { shortcut.miniature(this.miniature().get()) } + if (this._categoryIcon) { + shortcut.categoryIcon(this._categoryIcon) + } + shortcut.create(); } } diff --git a/Engines/Wine/QuickScript/Steam Script/script.js b/Engines/Wine/QuickScript/Steam Script/script.js index 3b7a7d9784..874bbccc5e 100644 --- a/Engines/Wine/QuickScript/Steam Script/script.js +++ b/Engines/Wine/QuickScript/Steam Script/script.js @@ -130,6 +130,8 @@ module.default = class SteamScript extends QuickScript { .wizard(setupWizard) .prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion); + this._environment = this._environmentFunc(wine); + new Luna(wine).go(); new Corefonts(wine).go();