Skip to content

Commit

Permalink
fix: Wine accidently swapped to flatpak
Browse files Browse the repository at this point in the history
feat: Improved platform app paths
  • Loading branch information
colin969 committed Mar 17, 2024
1 parent 7181f06 commit 5d2c4cc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/back/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import {
deleteCuration,
exit, getCwd, getTempFilename,
openFlashpointManager,
pathExists, procToService, promiseSleep, removeService,
pathExists, procToService, processPlatformAppPaths, promiseSleep, removeService,
runService
} from './util/misc';
import { uuid } from './util/uuid';
Expand Down Expand Up @@ -183,7 +183,7 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise<v
/** Ignore */
}

state.platformAppPaths = await fpDatabase.findPlatformAppPaths();
state.platformAppPaths = processPlatformAppPaths(await fpDatabase.findPlatformAppPaths());

const res: GetRendererLoadedDataResponse = {
gotdList: gotdList,
Expand Down Expand Up @@ -393,7 +393,7 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise<v
applicationPath: await fpDatabase.findAllGameApplicationPaths(),
library: await fpDatabase.findAllGameLibraries(),
};
state.platformAppPaths = await fpDatabase.findPlatformAppPaths(); // Update cache
state.platformAppPaths = processPlatformAppPaths(await fpDatabase.findPlatformAppPaths()); // Update cache
const total = await fpDatabase.countGames();
const cats = await fpDatabase.findAllTagCategories();
state.socketServer.broadcast(BackOut.POST_SYNC_CHANGES, state.suggestions.library, state.suggestions, state.platformAppPaths, cats, total);
Expand Down Expand Up @@ -433,8 +433,7 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise<v
applicationPath: await fpDatabase.findAllGameApplicationPaths(),
library: await fpDatabase.findAllGameLibraries(),
};
// const appPaths: PlatformAppPathSuggestions = await GameManager.findPlatformsAppPaths();
state.platformAppPaths = await fpDatabase.findPlatformAppPaths(); // Update cache
state.platformAppPaths = processPlatformAppPaths(await fpDatabase.findPlatformAppPaths()); // Update cache
return {
suggestions: suggestions,
platformAppPaths: {},
Expand Down Expand Up @@ -2614,7 +2613,7 @@ function createCommand(filename: string, useWine: boolean, noshell: boolean): st
case 'darwin':
case 'linux':
if (useWine) {
return `flatpak --env="WINEPREFIX=/home/colin/fpwinepfx" run org.winehq.Wine start /wait /unix "${filename}"`;
return `wine start /wait /unix "${filename}"`;
}
return noshell ? filename : `"${filename}"`;
default:
Expand Down
28 changes: 28 additions & 0 deletions src/back/util/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { promisify } from 'util';
import { uuid } from './uuid';
import { AdditionalApp, Game, Tag } from 'flashpoint-launcher';
import { newGame } from '@shared/utils/misc';
import { PlatformAppPath, PlatformAppPathSuggestions } from '@shared/curate/types';

const unlink = promisify(fs.unlink);

Expand Down Expand Up @@ -491,3 +492,30 @@ export async function promiseSleep(ms: number) {
setTimeout(resolve, ms);
});
}

export function processPlatformAppPaths(suggs: PlatformAppPathSuggestions): PlatformAppPathSuggestions {
const newSuggs: PlatformAppPathSuggestions = {};

for (const platform of Object.keys(suggs)) {
// For each platform group, process and remove duplicates
const group: PlatformAppPath[] = [];
const exists: string[] = [];

for (const value of suggs[platform]) {
const processedValue = value.appPath
.toLowerCase() // Lower case
.replace(/\//g, '\\'); // Fix slashes

if (exists.includes(processedValue)) {
continue; // Skip adding to group if processed value already seen
}

exists.push(processedValue);
group.push(value);
}

newSuggs[platform] = group;
}

return newSuggs;
}
2 changes: 1 addition & 1 deletion src/renderer/components/CurateBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ function createAppPathDropdownItems(platformAppPaths: PlatformAppPathSuggestions
let values: string[] = [];
// Sort current platform seperately and put on top
values = values.concat(platformAppPaths[currentPlatform].map(a => a.appPath));

values.push('-- All Platform App Paths --');
// Sort rest
let appPaths: string[] = [];
for (const oKey of Object.keys(platformAppPaths)) {
Expand Down

0 comments on commit 5d2c4cc

Please sign in to comment.