Source: Engines/Wine/Verbs/gallium9/script.js

  1. const Wine = include("engines.wine.engine.object");
  2. const { Extractor } = include("utils.functions.filesystem.extract");
  3. const { remove, lns } = include("utils.functions.filesystem.files");
  4. const { GitHubReleaseDownloader } = include("utils.functions.net.githubreleases");
  5. const Optional = Java.type("java.util.Optional");
  6. const OverrideDLL = include("engines.wine.plugins.override_dll");
  7. /**
  8. * Verb to install Gallium 9 Standalone
  9. * see: https://github.com/iXit/wine-nine-standalone/
  10. */
  11. class Gallium9 {
  12. constructor(wine) {
  13. this.wine = wine;
  14. }
  15. /**
  16. * Sets the used gallium9 version
  17. *
  18. * @param {string} gallium9Version The Gallium 9 Standalone version to download
  19. * @returns {Gallium9} The Gallium9 object
  20. */
  21. withVersion(gallium9Version) {
  22. this.gallium9Version = gallium9Version;
  23. return this;
  24. }
  25. go() {
  26. const wizard = this.wine.wizard();
  27. const prefixDirectory = this.wine.prefixDirectory();
  28. const system32directory = this.wine.system32directory();
  29. wizard.message(
  30. tr(
  31. "Using Gallium 9 requires to have a driver supporting the Gallium 9 state tracker, as well as d3dapater9.so installed (ex: libd3d9adapter-mesa package). Please be sure it is installed (both 32 and 64 bits)."
  32. )
  33. );
  34. const githubDownloader = new GitHubReleaseDownloader("iXit", "wine-nine-standalone", wizard);
  35. if (typeof this.gallium9Version !== "string") {
  36. this.gallium9Version = githubDownloader.getLatestRelease();
  37. }
  38. const [setupFile] = githubDownloader.download(this.gallium9Version);
  39. new Extractor()
  40. .wizard(wizard)
  41. .archive(setupFile)
  42. .to(prefixDirectory)
  43. .extract();
  44. remove(`${system32directory}/d3d9.dll`);
  45. lns(`${prefixDirectory}/gallium-nine-standalone/lib32/d3d9-nine.dll.so`, `${system32directory}/d3d9-nine.dll`);
  46. lns(
  47. `${prefixDirectory}/gallium-nine-standalone/bin32/ninewinecfg.exe.so`,
  48. `${system32directory}/ninewinecfg.exe`
  49. );
  50. lns(`${system32directory}/d3d9-nine.dll`, `${system32directory}/d3d9.dll`);
  51. if (this.wine.architecture() == "amd64") {
  52. const system64directory = this.wine.system64directory();
  53. remove(`${system64directory}/d3d9.dll`);
  54. lns(
  55. `${prefixDirectory}/gallium-nine-standalone/lib64/d3d9-nine.dll.so`,
  56. `${system64directory}/d3d9-nine.dll`
  57. );
  58. lns(
  59. `${prefixDirectory}/gallium-nine-standalone/bin64/ninewinecfg.exe.so`,
  60. `${system64directory}/ninewinecfg.exe`
  61. );
  62. lns(`${system64directory}/d3d9-nine.dll`, `${system64directory}/d3d9.dll`);
  63. this.wine.run(`${system64directory}/ninewinecfg.exe`, ["-e"], null, false, true);
  64. } else {
  65. this.wine.run(`${system32directory}/ninewinecfg.exe`, ["-e"], null, false, true);
  66. }
  67. new OverrideDLL(this.wine).withMode("native", ["d3d9"]).go();
  68. }
  69. static install(container) {
  70. const wine = new Wine();
  71. const wizard = SetupWizard(InstallationType.VERBS, "gallium9", Optional.empty());
  72. const githubDownloader = new GitHubReleaseDownloader("iXit", "wine-nine-standalone", wizard);
  73. const versions = githubDownloader.getReleases();
  74. const latestVersion = githubDownloader.getLatestRelease();
  75. const selectedVersion = wizard.menu(tr("Please select the version."), versions, latestVersion);
  76. wine.prefix(container);
  77. wine.wizard(wizard);
  78. // install selected version
  79. new Gallium9(wine).withVersion(selectedVersion.text).go();
  80. wizard.close();
  81. }
  82. }
  83. module.default = Gallium9;