Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #132 from CapitaineJSparrow/feature/repack-support
Browse files Browse the repository at this point in the history
Feature/repack support
  • Loading branch information
CapitaineJSparrow authored Oct 13, 2021
2 parents fafb86d + 27524e8 commit 81437e1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "emusak",
"productName": "emusak",
"version": "1.0.105",
"version": "1.0.106",
"description": "Saves, shaders, firmwares and keys manager for switch emulators",
"main": ".webpack/main",
"repository": "https://github.com/stromcon/emusak-ui.git",
Expand Down
1 change: 1 addition & 0 deletions src/components/ChangelogComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const ChangelogComponent = () => {
<li>Improve backend reliability</li>
<li>Fix github actions to push emusak updates to AUR (archlinux packages repository). Thanks <code>LiveLM</code> !</li>
<li>Fix an issue preventing users to display "Download keys" or "firmware" buttons when they have never launched any game in yuzu.</li>
<li>Add fitgirl repacks support, I don't recommend to use them but it's mainly to avoid people asking for support.</li>
</ul>
<br/>
<p>
Expand Down
16 changes: 8 additions & 8 deletions src/service/Ryujinx/shaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { titleIdToName } from "../EshopDBService";
const paths: string[] = [];

export const countShadersFromGames = (titleIds: string[], config: IRyujinxConfig) => Promise.all(titleIds.map(async id => {
let shaderZipPath = getRyujinxPath(config, 'games', id.toLowerCase(), 'cache', 'shader', 'guest', 'program', 'cache.zip');
let shaderZipPath = await getRyujinxPath(config, 'games', id.toLowerCase(), 'cache', 'shader', 'guest', 'program', 'cache.zip');
const exists = await fs.promises.access(shaderZipPath).then(() => true).catch(() => false);

if (exists) { // To get shaders count, we just have to count files in zip archive
Expand All @@ -38,8 +38,8 @@ const displayShadersErrorOnDownload = () => {

export const installShadersToGame = async (config: IRyujinxConfig, titleId: string) => {
progressEvent.dispatchEvent(new CustomEvent('progress', { detail: { progress: 0, open: true, downloadSpeed: 0 }}))
const shaderDestPath = getRyujinxPath(config, 'games', titleId.toLowerCase(), 'cache', 'shader', 'guest', 'program', 'cache.zip');
const infoDestPath = getRyujinxPath(config, 'games', titleId.toLowerCase(), 'cache', 'shader', 'guest', 'program', 'cache.info');
const shaderDestPath = await getRyujinxPath(config, 'games', titleId.toLowerCase(), 'cache', 'shader', 'guest', 'program', 'cache.zip');
const infoDestPath = await getRyujinxPath(config, 'games', titleId.toLowerCase(), 'cache', 'shader', 'guest', 'program', 'cache.info');

const exists = await fs.promises.access(infoDestPath).then(() => true).catch(() => false);

Expand All @@ -60,7 +60,7 @@ export const installShadersToGame = async (config: IRyujinxConfig, titleId: stri
}

// Clear compiled Shaders to avoid cache collision issue
rimraf(getRyujinxPath(config, 'games', titleId.toLowerCase(), 'cache', 'shader', 'opengl'), () => {});
rimraf(await getRyujinxPath(config, 'games', titleId.toLowerCase(), 'cache', 'shader', 'opengl'), () => {});
await fs.writeFileSync(infoDestPath, arrayBufferToBuffer(buffer));

return Swal.fire({
Expand All @@ -70,8 +70,8 @@ export const installShadersToGame = async (config: IRyujinxConfig, titleId: stri
};

export const packShaders = async (config: IRyujinxConfig, titleID: string): Promise<any> => {
const shaderZipPath = getRyujinxPath(config, 'games', titleID.toLowerCase(), 'cache', 'shader', 'guest', 'program', 'cache.zip');
const shaderInfoPath = getRyujinxPath(config, 'games', titleID.toLowerCase(), 'cache', 'shader', 'guest', 'program', 'cache.info');
const shaderZipPath = await getRyujinxPath(config, 'games', titleID.toLowerCase(), 'cache', 'shader', 'guest', 'program', 'cache.zip');
const shaderInfoPath = await getRyujinxPath(config, 'games', titleID.toLowerCase(), 'cache', 'shader', 'guest', 'program', 'cache.info');
const archive = new zip();
archive.addLocalFile(shaderZipPath);
archive.addLocalFile(shaderInfoPath);
Expand Down Expand Up @@ -161,9 +161,9 @@ export const shareShader = async (
return;
}

const ldnConfigPath = getRyujinxPath(config, 'LDNConfig.json');
const ldnConfigPath = await getRyujinxPath(config, 'LDNConfig.json');
const hasLdnConfigFile = await fs.promises.access(ldnConfigPath).then(() => true).catch(() => false);
const standardConfigPath = getRyujinxPath(config, 'Config.json');
const standardConfigPath = await getRyujinxPath(config, 'Config.json');
const hasStandardConfigFile = await fs.promises.access(standardConfigPath).then(() => true).catch(() => false);

if (hasLdnConfigFile) {
Expand Down
19 changes: 13 additions & 6 deletions src/service/Ryujinx/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ export const isRyujinxPortableMode = async (path: string): Promise<boolean> => {
/**
* Util function to get path in same way if ryu is portable or not
*/
export const getRyujinxPath = (config: IRyujinxConfig, ...paths: string[]): string => {
export const getRyujinxPath = async (config: IRyujinxConfig, ...paths: string[]): Promise<string> => {

const isFitgirlRepack = fs.promises.stat(path.resolve(config.path, '..', 'data', 'games')).then(() => true).catch(() => false);

if (isFitgirlRepack) {
return path.resolve(config.path, '..', 'data', ...paths);
}

if (config.isPortable) {
return path.resolve(config.path, 'portable', ...paths);
}
Expand Down Expand Up @@ -89,7 +96,7 @@ export const installFirmware = async () => {

export const downloadKeys = async (config: IRyujinxConfig, withAlert = true) => {
const keysContent = await getKeysContent();
const systemPath = getRyujinxPath(config, 'system');
const systemPath = await getRyujinxPath(config, 'system');
const exists = await fs.promises.stat(systemPath).catch(() => null);

if (!exists) {
Expand All @@ -113,7 +120,7 @@ export const downloadKeys = async (config: IRyujinxConfig, withAlert = true) =>
}

export const listGamesWithNameAndShadersCount = async (configs: IRyujinxConfig[]): Promise<IEmusakEmulatorConfig[]> => Promise.all(configs.map(async config => {
const gameDirectory = getRyujinxPath(config, 'games');
const gameDirectory = await getRyujinxPath(config, 'games');
const exists = await fs.promises.stat(gameDirectory).catch(() => null);

if (!exists) {
Expand Down Expand Up @@ -172,9 +179,9 @@ export const installMod = async (config: IRyujinxConfig, t: string, pickedVersio
let modPath: string;

if (kind === 'pchtxt') {
modPath = getRyujinxPath(config, 'mods', 'contents', titleID, modName, 'exefs');
modPath = await getRyujinxPath(config, 'mods', 'contents', titleID, modName, 'exefs');
} else {
modPath = getRyujinxPath(config, 'mods', 'contents', titleID);
modPath = await getRyujinxPath(config, 'mods', 'contents', titleID);
}

const exists = await fs.promises.access(modPath).then(() => true).catch(() => false);
Expand Down Expand Up @@ -204,7 +211,7 @@ export const installMod = async (config: IRyujinxConfig, t: string, pickedVersio

// Clear PTC cache as asked
if (value) {
const ptcCachePath = getRyujinxPath(config, 'games', titleID, 'cache', 'cpu');
const ptcCachePath = await getRyujinxPath(config, 'games', titleID, 'cache', 'cpu');
const cacheFiles = await asyncGlob(`${ptcCachePath}/**/*.cache`).catch(() => []) as string[];
await Promise.all(cacheFiles.map(file => fs.promises.unlink(file)));
await Swal.fire({
Expand Down

0 comments on commit 81437e1

Please sign in to comment.