Skip to content

Commit

Permalink
feat: Open screenshot / logo
Browse files Browse the repository at this point in the history
refactor: Removed redundant duplicate / export buttons
  • Loading branch information
colin969 committed Mar 14, 2024
1 parent f931968 commit 59f6b6e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 61 deletions.
4 changes: 3 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,9 @@
"menu": {
"viewThumbnailInFolder": "View Thumbnail in Folder",
"viewScreenshotInFolder": "View Screenshot in Folder",
"openFileLocation": "Open File Location",
"openFileLocation": "Show Game in Explorer",
"openLogoLocation": "Show Logo in Explorer",
"openScreenshotLocation": "Show Screenshot in Explorer",
"addToFavorites": "Add to Favorites",
"addToPlaylist": "Add to Playlist",
"duplicateMetaOnly": "Duplicate (Meta Only)",
Expand Down
8 changes: 4 additions & 4 deletions src/back/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export async function syncGames(source: GameMetadataSource, dataPacksFolder: str
}

// -- Deleted Games -- //
const reqUrl = `${deletedUrl}?after=${source.games.latestUpdateTime}`;
const reqUrl = `${deletedUrl}`;
const res = await axios.get(reqUrl)
.catch((err) => {
throw 'Failed to search deleted games';
Expand All @@ -139,11 +139,11 @@ export async function syncRedirects(source: GameMetadataSource): Promise<void> {
throw 'Failed to search game redirects';
});

const data = res.data.map((d: any) => { return {
const data: Array<GameRedirect> = res.data.map((d: any) => { return {
sourceId: d.source_id,
destId: d.id
};}) as any as Array<GameRedirect>;
console.log('applying redirects');
};});
console.log(`applying ${data.length} redirects`);
await fpDatabase.updateApplyRedirects(data);
}

Expand Down
104 changes: 48 additions & 56 deletions src/renderer/app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as remote from '@electron/remote';
import { BackIn, BackInit, BackOut, FetchedGameInfo, FpfssUser } from '@shared/back/types';
import { APP_TITLE, VIEW_PAGE_SIZE } from '@shared/constants';
import { APP_TITLE, LOGOS, SCREENSHOTS, VIEW_PAGE_SIZE } from '@shared/constants';
import { CustomIPC, IService, ProcessState, WindowIPC } from '@shared/interfaces';
import { LangContainer } from '@shared/lang';
import { memoizeOne } from '@shared/memoize';
Expand Down Expand Up @@ -50,7 +50,7 @@ import { MainActionType, RequestState } from './store/main/enums';
import { RANDOM_GAME_ROW_COUNT } from './store/main/reducer';
import { MainAction, MainState } from './store/main/types';
import { SearchQuery } from './store/search';
import { getBrowseSubPath, getGamePath, joinLibraryRoute } from './Util';
import { getBrowseSubPath, getGameImagePath, getGameImageURL, getGamePath, joinLibraryRoute } from './Util';
import { LangContext } from './util/lang';
import { queueOne } from './util/queue';
import uuid = require('uuid');
Expand Down Expand Up @@ -1231,6 +1231,21 @@ export class App extends React.Component<AppProps> {
(playlistId) => window.Shared.back.send(BackIn.ADD_PLAYLIST_GAME, playlistId, gameId),
selectedPlaylistId)
}, {
/* Copy Shortcut URL */
label: strings.menu.copyShortcutURL,
enabled: true,
click: () => {
clipboard.writeText(`flashpoint://run/${gameId}`);
}
},
{
/* Copy Game UUID */
label: strings.menu.copyGameUUID,
enabled: true,
click: () => {
clipboard.writeText(gameId);
}
}, { type: 'separator'}, {
/* File Location */
label: strings.menu.openFileLocation,
enabled: !window.Shared.isBackRemote, // (Local "back" only)
Expand Down Expand Up @@ -1280,36 +1295,48 @@ export class App extends React.Component<AppProps> {
},
},
{
/* Copy Shortcut URL */
label: strings.menu.copyShortcutURL,
enabled: true,
/* Logo Location */
label: strings.menu.openLogoLocation,
enabled: !window.Shared.isBackRemote, // (Local "back" only)
click: () => {
clipboard.writeText(`flashpoint://run/${gameId}`);
const logoPath = getGameImagePath(LOGOS, gameId);
fs.promises.access(logoPath, fs.constants.R_OK)
.then(() => {
/* Downloaded, open */
remote.shell.showItemInFolder(logoPath);
}).catch(() => {
/* Not downloaded, try and force it */
fetch(getGameImageURL(LOGOS, gameId))
.then(() => {
remote.shell.showItemInFolder(logoPath);
});
});
}
},
{
/* Copy Game UUID */
label: strings.menu.copyGameUUID,
enabled: true,
/* Screenshot Location */
label: strings.menu.openScreenshotLocation,
enabled: !window.Shared.isBackRemote, // (Local "back" only)
click: () => {
clipboard.writeText(gameId);
const logoPath = getGameImagePath(SCREENSHOTS, gameId);
fs.promises.access(logoPath, fs.constants.R_OK)
.then(() => {
/* Downloaded, open */
remote.shell.showItemInFolder(logoPath);
}).catch(() => {
/* Not downloaded, try and force it */
fetch(getGameImageURL(SCREENSHOTS, gameId))
.then(() => {
remote.shell.showItemInFolder(logoPath);
});
});
}
}, { type: 'separator' }];

// Add editing mode fields
if (this.props.preferencesData.enableEditing) {
const editingButtons: MenuItemConstructorOptions[] = [
{
/* Duplicate Meta */
label: strings.menu.duplicateMetaOnly,
enabled: this.props.preferencesData.enableEditing,
click: () => { window.Shared.back.request(BackIn.DUPLICATE_GAME, gameId, false); },
}, {
/* Duplicate Meta & Images */
label: strings.menu.duplicateMetaAndImages, // ("&&" will be shown as "&")
enabled: this.props.preferencesData.enableEditing,
click: () => { window.Shared.back.request(BackIn.DUPLICATE_GAME, gameId, true); },
}, {
/* Load as a curation */
label: strings.menu.makeCurationFromGame,
enabled: this.props.preferencesData.enableEditing,
Expand Down Expand Up @@ -1338,42 +1365,7 @@ export class App extends React.Component<AppProps> {
});
});
}
}, ...fpfssButtons, { type: 'separator' }, {
/* Export Meta */
label: strings.menu.exportMetaOnly,
enabled: !window.Shared.isBackRemote, // (Local "back" only)
click: () => {
const filePath = remote.dialog.showSaveDialogSync({
title: strings.dialog.selectFileToExportMeta,
defaultPath: 'meta.yaml',
filters: [{
name: 'Meta file',
extensions: ['yaml'],
}]
});
if (filePath) { window.Shared.back.request(BackIn.EXPORT_GAME, gameId, filePath, true); }
},
}, {
/* Export Meta & Images */
label: strings.menu.exportMetaAndImages, // ("&&" will be shown as "&")
enabled: !window.Shared.isBackRemote, // (Local "back" only)
click: () => {
const filePaths = window.Shared.showOpenDialogSync({
title: strings.dialog.selectFolderToExportMetaAndImages,
properties: ['promptToCreate', 'openDirectory']
});
if (filePaths && filePaths.length > 0) {
window.Shared.back.request(BackIn.EXPORT_GAME, gameId, filePaths[0], false);
}
},
}, {
/* Export Partial Meta */
label: strings.menu.exportMetaEdit, // ("&&" will be shown as "&")
enabled: !window.Shared.isBackRemote, // (Local "back" only)
click: () => {
this.onOpenExportMetaEdit(gameId);
},
}, { type: 'separator' }
}, ...fpfssButtons, { type: 'separator' }
];
contextButtons = contextButtons.concat(editingButtons);
}
Expand Down
2 changes: 2 additions & 0 deletions src/shared/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ const langTemplate = {
'viewThumbnailInFolder',
'viewScreenshotInFolder',
'openFileLocation',
'openLogoLocation',
'openScreenshotLocation',
'addToFavorites',
'addToPlaylist',
'duplicateMetaOnly',
Expand Down

0 comments on commit 59f6b6e

Please sign in to comment.