Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit fa91817

Browse files
committed
MediaFoundation installer
1 parent 7b64798 commit fa91817

12 files changed

Lines changed: 306 additions & 57 deletions

File tree

src/src/app.js

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
1-
import _ from "lodash";
2-
import action from "./store/action";
3-
import FileSystem from "./modules/file-system";
4-
import AppFolders from "./modules/app-folders";
5-
import Config from "./modules/config";
6-
import Wine from "./modules/wine";
7-
import Command from "./modules/command";
8-
import System from "./modules/system";
9-
import Driver from "./modules/driver";
10-
import Network from "./modules/network";
11-
import Update from "./modules/update";
12-
import Monitor from "./modules/monitor";
13-
import Replaces from "./modules/replaces";
14-
import Patches from "./modules/patches";
15-
import Registry from "./modules/registry";
16-
import Utils from "./modules/utils";
17-
import WinePrefix from "./modules/wine-prefix";
18-
import Task from "./modules/task";
19-
import Prefix from "./modules/prefix";
20-
import Snapshot from "./modules/snapshot";
21-
import Diagnostics from "./modules/diagnostics";
22-
import Lutris from "./modules/lutris";
23-
import PlayOnLinux from "./modules/play-on-linux";
24-
import YandexDisk from "./modules/yandex-disk";
25-
import Mount from "./modules/mount";
26-
import Pack from "./modules/pack";
27-
import Symlink from "./modules/symlink";
28-
import Build from "./modules/build";
29-
import Dxvk from "./modules/dxvk";
30-
import Fixes from "./modules/fixes";
31-
import MangoHud from "./modules/mango-hud";
32-
import VkBasalt from "./modules/vk-basalt";
33-
import AudioButton from "./helpers/audio";
34-
import Iso from "./modules/iso";
35-
import ProtonGE from "./modules/proton-ge";
36-
import ProtonTKG from "./modules/proton-tkg";
37-
import Steam from "./modules/steam";
38-
import Errors from "./helpers/errors";
1+
import _ from "lodash";
2+
import action from "./store/action";
3+
import FileSystem from "./modules/file-system";
4+
import AppFolders from "./modules/app-folders";
5+
import Config from "./modules/config";
6+
import Wine from "./modules/wine";
7+
import Command from "./modules/command";
8+
import System from "./modules/system";
9+
import Driver from "./modules/driver";
10+
import Network from "./modules/network";
11+
import Update from "./modules/update";
12+
import Monitor from "./modules/monitor";
13+
import Replaces from "./modules/replaces";
14+
import Patches from "./modules/patches";
15+
import Registry from "./modules/registry";
16+
import Utils from "./modules/utils";
17+
import WinePrefix from "./modules/wine-prefix";
18+
import Task from "./modules/task";
19+
import Prefix from "./modules/prefix";
20+
import Snapshot from "./modules/snapshot";
21+
import Diagnostics from "./modules/diagnostics";
22+
import Lutris from "./modules/lutris";
23+
import PlayOnLinux from "./modules/play-on-linux";
24+
import YandexDisk from "./modules/yandex-disk";
25+
import Mount from "./modules/mount";
26+
import Pack from "./modules/pack";
27+
import Symlink from "./modules/symlink";
28+
import Build from "./modules/build";
29+
import Dxvk from "./modules/dxvk";
30+
import Fixes from "./modules/fixes";
31+
import MangoHud from "./modules/mango-hud";
32+
import VkBasalt from "./modules/vk-basalt";
33+
import AudioButton from "./helpers/audio";
34+
import Iso from "./modules/iso";
35+
import ProtonGE from "./modules/proton-ge";
36+
import ProtonTKG from "./modules/proton-tkg";
37+
import MediaFoundation from "./modules/media-foundation";
38+
import Steam from "./modules/steam";
39+
import Errors from "./helpers/errors";
3940

4041
class App {
4142

@@ -62,10 +63,11 @@ class App {
6263
REGISTRY = new Registry(this.PREFIX, this.FILE_SYSTEM, this.REPLACES, this.WINE);
6364
SNAPSHOT = new Snapshot(this.PREFIX, this.FILE_SYSTEM, this.REPLACES, this.WINE, this.SYSTEM);
6465
DXVK = new Dxvk(this.PREFIX, this.FILE_SYSTEM, this.NETWORK, this.WINE, this.SNAPSHOT);
66+
MF = new MediaFoundation(this.COMMAND, this.PREFIX, this.FILE_SYSTEM, this.NETWORK, this.WINE, this.SNAPSHOT);
6567
MANGO_HUD = new MangoHud(this.PREFIX, this.FILE_SYSTEM, this.NETWORK);
6668
VK_BASALT = new VkBasalt(this.PREFIX, this.FILE_SYSTEM, this.NETWORK);
6769
FIXES = new Fixes(this.PREFIX, this.WINE);
68-
WINE_PREFIX = new WinePrefix(this.PREFIX, this.CONFIG, this.SYSTEM, this.FILE_SYSTEM, this.WINE, this.REPLACES, this.REGISTRY, this.PATCHES, this.DXVK, this.FIXES);
70+
WINE_PREFIX = new WinePrefix(this.PREFIX, this.CONFIG, this.SYSTEM, this.FILE_SYSTEM, this.WINE, this.REPLACES, this.REGISTRY, this.PATCHES, this.DXVK, this.FIXES, this.MF);
6971
DIAGNOSTICS = new Diagnostics(this.PREFIX, this.COMMAND, this.SYSTEM, this.FILE_SYSTEM);
7072
MOUNT_WINE = new Mount(this.PREFIX, this.COMMAND, this.FILE_SYSTEM, this.UPDATE, this.SYSTEM, this.PREFIX.getWineDir());
7173
MOUNT_DATA = new Mount(this.PREFIX, this.COMMAND, this.FILE_SYSTEM, this.UPDATE, this.SYSTEM, this.PREFIX.getGamesDir());
@@ -371,6 +373,13 @@ class App {
371373
getSteam() {
372374
return this.STEAM;
373375
}
376+
377+
/**
378+
* @return {MediaFoundation}
379+
*/
380+
getMediaFoundation() {
381+
return this.MF;
382+
}
374383
}
375384

376385
window.app = new App();

src/src/components/Funding/Funding.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,9 @@
2828
},
2929
data() {
3030
return {
31-
index: 1,
31+
index: Utils.rand(1, 4),
3232
};
3333
},
34-
mounted() {
35-
this.index = Utils.rand(1, 4);
36-
},
3734
methods: {
3835
hover() {
3936
window.app.getAudioButton().hover();

src/src/components/Prefix/PopupEditPrefix.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,13 @@
297297
relations: 'require:libs.dxvk.install',
298298
required: false,
299299
},
300+
'libs.mf.install': {
301+
tab: 'libs',
302+
name: 'Media Foundation',
303+
description: this.$t('prefix.form-prefix.mf-desc'),
304+
type: 'bool',
305+
required: false,
306+
},
300307
'libs.mangohud.install': {
301308
tab: 'libs',
302309
name: 'MangoHud',

src/src/locales/en.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export default {
190190
'dxvk-desc': 'Speeding up dx9-11 games through Vulkan',
191191
'update-dxvk-desc': 'Auto update DXVK',
192192
'mangohud-desc': 'Beautiful HUD to display FPS\n[F12] - Show / Hide',
193+
'mf-desc': 'Multimedia framework (x86_64 only prefix)',
193194
'vkbasalt-desc': 'Texture Improvement in Vulkan Games\n[HOME] - Enable / Disable',
194195
},
195196
},

src/src/locales/ru.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export default {
190190
'dxvk-desc': 'Ускорение dx9-11 игр через Vulkan',
191191
'update-dxvk-desc': 'Автообновление DXVK',
192192
'mangohud-desc': 'Красивый HUD для отображения FPS.\n[F12] - Показать/скрыть',
193+
'mf-desc': 'Мультимедийный фреймворк (только для x86_64 префикса)',
193194
'vkbasalt-desc': 'Улучшение текстур в Vulkan играх.\n[HOME] - Включить/отключить',
194195
},
195196
},

src/src/modules/diagnostics.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,16 @@ export default class Diagnostics {
390390
packages: ['libgtk-3-0'],
391391
find: 'libgtk-3.so.0',
392392
},
393+
{
394+
name: 'libFAudio',
395+
packages: ['libfaudio0'],
396+
find: 'libFAudio.so.0',
397+
},
398+
{
399+
name: 'libvkd3d',
400+
packages: ['libvkd3d1', 'libvkd3d-utils1'],
401+
find: 'libvkd3d.so.1',
402+
},
393403
{
394404
name: 'libgstreamer1.0',
395405
packages: ['gstreamer1.0-plugins-base', 'gstreamer1.0-plugins-good', 'libgstreamer1.0-0'],

src/src/modules/file-system.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,37 @@ export default class FileSystem {
640640
return false;
641641
}
642642

643+
unpackSimpleZip(inFile, outDir) {
644+
let tmpDir = this.prefix.getCacheDir() + `/tmp_${Utils.rand(10000, 99999)}`;
645+
this.mkdir(tmpDir);
646+
647+
if (!this.exists(tmpDir)) {
648+
return false;
649+
}
650+
651+
let fileName = this.basename(inFile);
652+
let mvFile = `${tmpDir}/${fileName}`;
653+
this.mv(inFile, mvFile);
654+
655+
this.command.run(`cd "${tmpDir}" && unzip "./${fileName}"`);
656+
this.rm(mvFile);
657+
658+
let finds = this.glob(`${tmpDir}/*`);
659+
let path = tmpDir;
660+
661+
if (finds.length === 1 && this.isDirectory(finds[0])) {
662+
path = finds[0];
663+
}
664+
665+
this.mv(path, outDir);
666+
667+
if (this.exists(tmpDir)) {
668+
this.rm(tmpDir);
669+
}
670+
671+
return true;
672+
}
673+
643674
/**
644675
* @param {string} path
645676
* @return {boolean}
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
import Command from "./command";
2+
import Prefix from "./prefix";
3+
import FileSystem from "./file-system";
4+
import Network from "./network";
5+
import Wine from "./wine";
6+
import Snapshot from "./snapshot";
7+
import Patch from "./patch";
8+
9+
export default class MediaFoundation {
10+
/**
11+
* @type {string[]}
12+
*/
13+
urls = [
14+
'https://github.com/z0z0z/mf-install/archive/master.zip',
15+
'https://lutris.nyc3.cdn.digitaloceanspaces.com/games/epic-games-store/mf-install-master.zip',
16+
];
17+
18+
/**
19+
* @type {Command}
20+
*/
21+
command = null;
22+
23+
/**
24+
* @type {Prefix}
25+
*/
26+
prefix = null;
27+
28+
/**
29+
* @type {FileSystem}
30+
*/
31+
fs = null;
32+
33+
/**
34+
* @type {Network}
35+
*/
36+
network = null;
37+
38+
/**
39+
* @type {Wine}
40+
*/
41+
wine = null;
42+
43+
/**
44+
* @type {Snapshot}
45+
*/
46+
snapshot = null;
47+
48+
/**
49+
* @param {Command} command
50+
* @param {Prefix} prefix
51+
* @param {FileSystem} fs
52+
* @param {Network} network
53+
* @param {Wine} wine
54+
* @param {Snapshot} snapshot
55+
*/
56+
constructor(command, prefix, fs, network, wine, snapshot) {
57+
this.command = command;
58+
this.prefix = prefix;
59+
this.fs = fs;
60+
this.network = network;
61+
this.wine = wine;
62+
this.snapshot = snapshot;
63+
}
64+
65+
/**
66+
* @return {Promise<boolean>}
67+
*/
68+
update() {
69+
if (!this.prefix.isMediaFoundation() || this.prefix.isBlocked() || 'win32' === this.prefix.getWineArch()) {
70+
return Promise.resolve(false);
71+
}
72+
73+
let promise = Promise.resolve(false);
74+
let isInstalled = this.prefix.getWinePrefixInfo('mf');
75+
76+
if (!isInstalled) {
77+
this.snapshot.createBefore();
78+
this.prefix.setWinePrefixInfo('mf', true);
79+
80+
promise = promise
81+
.then(() => {
82+
const download = (i = 0) => {
83+
if (this.urls.length <= i) {
84+
return false;
85+
}
86+
87+
return this.download(this.urls[i]).then(f => f, () => download(i + 1));
88+
};
89+
90+
return download();
91+
})
92+
.then((filename) => {
93+
let cacheDir = this.prefix.getCacheDir();
94+
let cacheFile = `${cacheDir}/${filename}`;
95+
let cacheUnpackDir = `${cacheDir}/mf`;
96+
let cachePrefixUnpackDir = `${this.prefix.getWinePrefixCacheDir()}/mf`;
97+
98+
if (!this.fs.exists(cacheFile)) {
99+
return false;
100+
}
101+
102+
if (this.fs.exists(cacheUnpackDir)) {
103+
this.fs.rm(cacheUnpackDir);
104+
}
105+
106+
if (!this.fs.unpackSimpleZip(cacheFile, cacheUnpackDir)) {
107+
return false;
108+
}
109+
110+
let shFile = `${cachePrefixUnpackDir}/mf-install.sh`;
111+
112+
if (!this.fs.exists(shFile)) {
113+
return false;
114+
}
115+
116+
this.fs.chmod(shFile);
117+
118+
let wine = `${this.prefix.getWineDir()}`;
119+
let bin = `${wine}/bin`;
120+
let exports = {
121+
WINEPREFIX: this.prefix.getWinePrefix(),
122+
};
123+
124+
if (this.fs.exists(bin)) {
125+
exports.PATH = `${bin}:$PATH`;
126+
exports.WINESERVER = `${bin}/wineserver`;
127+
exports.WINELOADER = `${bin}/wine`;
128+
exports.WINEDLLPATH = `${wine}/lib/wine:${wine}/lib64/wine`;
129+
}
130+
131+
let env = Object.keys(exports).map(field => `${field}="${exports[field]}"`).join(' ');
132+
133+
this.command.run(`cd "${cachePrefixUnpackDir}" && env ${env} "${shFile}"`);
134+
135+
if (this.fs.exists(cacheUnpackDir)) {
136+
this.fs.rm(cacheUnpackDir);
137+
}
138+
139+
return true;
140+
})
141+
.then((status) => {
142+
if (!status) {
143+
return false;
144+
}
145+
146+
let patch = new Patch();
147+
patch.setConfigValue('name', 'MF');
148+
patch.setConfigValue('created', true);
149+
patch.save();
150+
151+
this.snapshot.createAfter();
152+
this.snapshot.moveToPatch(patch);
153+
154+
patch.save();
155+
});
156+
}
157+
158+
return promise;
159+
}
160+
161+
162+
/**
163+
* @param {string} url
164+
*/
165+
download(url) {
166+
let cacheDir = this.prefix.getCacheDir();
167+
let filename = this.fs.basename(url);
168+
169+
return this.network.download(url, `${cacheDir}/${filename}`).then(() => filename);
170+
}
171+
}

0 commit comments

Comments
 (0)