forked from PhoenicisOrg/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
94 lines (70 loc) · 3.48 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
include("engines.wine.quick_script.quick_script");
include("utils.functions.net.download");
const Wine = include("engines.wine.engine.object");
include("utils.functions.filesystem.extract");
const {ls, mkdir, fileExists, cat, cp, getFileSize, fileName, lns, remove, touch, writeToFile, createTempFile, createTempDir, chmod, Checksum} = include("utils.functions.filesystem.files");
include("engines.wine.verbs.luna");
include("engines.wine.verbs.corefonts");
include("engines.wine.plugins.windows_version");
class UplayScript extends QuickScript {
constructor() {
super();
this._executable = "Uplay.exe";
this._category = "Games";
this._gameOverlay = true;
}
appId(appId) {
this._appId = appId;
return this;
}
downloadStarted(wine) {
return fileExists(wine.prefixDirectory() + "/drive_c/" + wine.programFiles() + "/Ubisoft/Ubisoft Game Launcher/data/" + this._appId + "/manifests");
}
downloadFinished(wine) {
return !fileExists(wine.prefixDirectory() + "/drive_c/" + wine.programFiles() + "/Ubisoft/Ubisoft Game Launcher/data/" + this._appId + "/manifests");
}
go() {
// default executable args if not specified
if (!this._executableArgs) {
this._executableArgs = ["uplay://launch/" + this._appId + "/0"];
}
const setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature());
setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author);
const tempFile = createTempFile("exe");
new Downloader()
.wizard(setupWizard)
.url("https://ubistatic3-a.akamaihd.net/orbit/launcher_installer/UplayInstaller.exe")
.to(tempFile)
.get();
const wine = new Wine()
.wizard(setupWizard)
.prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion)
.luna();
wine.corefonts();
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.setOsForApplication().set("upc.exe", "winvista").do();
wine.setOsForApplication().set("UbisoftGameLauncher.exe", "winvista").do();
// Uplay installation has finished
setupWizard.wait(tr("Please wait..."));
this._preInstall(wine, setupWizard);
// back to generic wait (might have been changed in preInstall)
setupWizard.wait(tr("Please wait..."));
this._createShortcut(wine.prefix());
wine.runInsidePrefix(wine.programFiles() + "/Ubisoft/Ubisoft Game Launcher/Uplay.exe", ["uplay://launch/" + this._appId + "/0"], true);
// 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);
}
setupWizard.message(tr("Please close Uplay."));
this._postInstall(wine, setupWizard);
// back to generic wait (might have been changed in postInstall)
setupWizard.wait(tr("Please wait..."));
setupWizard.close();
}
}