Skip to content

Commit 1750210

Browse files
committed
feat: Run with Flash / Ruffle in dropdown
refactor: Make 'Create' view button always visible at top of left refactor: Move default to top of tags page again fix: Search view ref not updated on duplicate
1 parent bda426a commit 1750210

21 files changed

+188
-99
lines changed

extensions/core-ruffle/src/extension.ts

+17
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,23 @@ export async function activate(context: flashpoint.ExtensionContext): Promise<vo
6666
const supportedEnabled = flashpoint.getExtConfigValue('com.ruffle.enabled');
6767
const unsupportedEnabled = flashpoint.getExtConfigValue('com.ruffle.enabled-all');
6868

69+
if (launchInfo.launchInfo.override === 'flash') {
70+
return;
71+
}
72+
73+
if (launchInfo.launchInfo.override === 'ruffle') {
74+
flashpoint.log.info('Using Standalone Ruffle for overriden game...');
75+
const defaultConfig = standaloneMiddleware.getDefaultConfig(launchInfo.game);
76+
standaloneMiddleware.execute(launchInfo, {
77+
middlewareId: '',
78+
name: '',
79+
enabled: true,
80+
version: defaultConfig.version,
81+
config: defaultConfig.config,
82+
});
83+
return;
84+
}
85+
6986
if (supportedEnabled || curation) {
7087
if (launchInfo.game.ruffleSupport.toLowerCase() === 'standalone') {
7188
flashpoint.log.info('Using Standalone Ruffle for supported game...');

extensions/core-ruffle/src/util.ts

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export async function getGithubAsset(nameRegex: RegExp, logDev: (text: string) =
9393
logDev(`No binaries found for this system, checking older releases...`);
9494
}
9595
logDev(`No binaries found in 7 releases, stopping...`);
96+
return null;
9697
}
9798

9899
export function getPlatformRegex(): RegExp {

lang/en.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
"deleteOnlyBrowseView": "Delete Search View (Must have another custom view)",
212212
"renameView": "Rename Search View",
213213
"duplicateView": "Duplicate Search View",
214-
"createNewView": "Create New Search view",
214+
"createNewView": "Create New Search View",
215215
"errorLoadingServices": "An error occurred while loading services. Please check the logs for more details."
216216
},
217217
"filter": {
@@ -362,6 +362,7 @@
362362
"noLaunchCommand": "No Launch Command",
363363
"searching": "Searching...",
364364
"library": "Library",
365+
"noLibrary": "No Library",
365366
"defaultLibrary": "Default Library",
366367
"fpfssGame": "FPFSS Game",
367368
"uninstallGame": "Uninstall Game",
@@ -411,7 +412,10 @@
411412
"notArchived": "Not Archived",
412413
"archived": "Archived",
413414
"playOnline": "Play Online",
414-
"tagFilterIcon": "Tag Filter Icon"
415+
"tagFilterIcon": "Tag Filter Icon",
416+
"runWithFlashPlayer": "Run with Flash Player",
417+
"runWithRuffle": "Run with Ruffle",
418+
"runWithRuffleUnsupported": "Run with Ruffle (Unsupported)"
415419
},
416420
"tags": {
417421
"name": "Name",

src/back/GameLauncher.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { formatString } from '@shared/utils/StringFormatter';
99
import * as child_process from 'child_process';
1010
import { ChildProcess } from 'child_process';
1111
import { EventEmitter } from 'events';
12-
import { AdditionalApp, AppPathOverride, DialogStateTemplate, Game, GameConfig, GameData, GameLaunchInfo, ManagedChildProcess, Platform } from 'flashpoint-launcher';
12+
import { AdditionalApp, AppPathOverride, DialogStateTemplate, Game, GameConfig, GameData, GameLaunchInfo, GameLaunchOverride, LaunchInfo, ManagedChildProcess, Platform } from 'flashpoint-launcher';
1313
import * as fs from 'fs-extra';
1414
import * as minimist from 'minimist';
1515
import * as path from 'path';
@@ -32,15 +32,6 @@ export type LaunchGameOpts = LaunchBaseOpts & {
3232
native: boolean;
3333
}
3434

35-
export type LaunchInfo = {
36-
gamePath: string;
37-
gameArgs: string | string[];
38-
useWine: boolean;
39-
env: NodeJS.ProcessEnv;
40-
cwd?: string;
41-
noshell?: boolean;
42-
}
43-
4435
type LaunchBaseOpts = {
4536
changeServer: (server?: string) => Promise<void>;
4637
fpPath: string;
@@ -62,6 +53,7 @@ type LaunchBaseOpts = {
6253
state: BackState;
6354
activeConfig: GameConfig | null;
6455
autoClearWininetCache: boolean;
56+
override: GameLaunchOverride;
6557
}
6658

6759
export namespace GameLauncher {
@@ -109,6 +101,7 @@ export namespace GameLauncher {
109101
await handleGameDataParams(opts, serverOverride, gameData || undefined);
110102
}
111103
const launchInfo: LaunchInfo = {
104+
override: opts.override,
112105
gamePath: gamePath,
113106
gameArgs: appArgs,
114107
useWine,
@@ -168,6 +161,7 @@ export namespace GameLauncher {
168161
state: opts.state,
169162
activeConfig: opts.activeConfig,
170163
autoClearWininetCache: opts.autoClearWininetCache,
164+
override: opts.override,
171165
};
172166
for (const addApp of opts.game.addApps) {
173167
if (addApp.autoRunBefore) {
@@ -253,6 +247,7 @@ export namespace GameLauncher {
253247
game: opts.game,
254248
activeData: gameData,
255249
launchInfo: {
250+
override: opts.override,
256251
gamePath: process.execPath,
257252
gameArgs: browserLaunchArgs,
258253
useWine: false,
@@ -298,6 +293,7 @@ export namespace GameLauncher {
298293
game: opts.game,
299294
activeData: gameData,
300295
launchInfo: {
296+
override: opts.override,
301297
gamePath,
302298
gameArgs,
303299
useWine,

src/back/responses.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise<v
559559
return state.execMappings;
560560
});
561561

562-
state.socketServer.register(BackIn.LAUNCH_ADDAPP, async (event, id) => {
562+
state.socketServer.register(BackIn.LAUNCH_ADDAPP, async (event, id, override) => {
563563
const addApp = await fpDatabase.findAddAppById(id);
564564
if (addApp) {
565565
// Force load relation
@@ -614,14 +614,16 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise<v
614614
state,
615615
parentGame,
616616
runAddApp: runAddAppFactory(state),
617-
autoClearWininetCache: state.preferences.autoClearWininetCache
617+
autoClearWininetCache: state.preferences.autoClearWininetCache,
618+
override,
618619
}, false);
619620
state.apiEmitters.games.onDidLaunchAddApp.fireAlert(state, addApp, event.client, 'Error during post add app launch api event');
620621
}
621622
});
622623

623-
state.socketServer.register(BackIn.LAUNCH_GAME, async (event, id) => {
624+
state.socketServer.register(BackIn.LAUNCH_GAME, async (event, id, override) => {
624625
const game = await fpDatabase.findGame(id);
626+
console.log('override: ' + override);
625627

626628
if (game) {
627629
// Make sure Server is set to configured server - Curations may have changed it
@@ -750,6 +752,7 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise<v
750752
activeConfig: activeConfig ? activeConfig : null,
751753
state,
752754
autoClearWininetCache: state.preferences.autoClearWininetCache,
755+
override,
753756
},
754757
state.apiEmitters.games.onWillLaunchGame.fireableFactory(state, event.client, 'Error during game launch api event'), false);
755758
await state.apiEmitters.games.onDidLaunchGame.fireAlert(state, game, event.client, 'Error from post game launch api event');
@@ -1772,6 +1775,7 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise<v
17721775
activeConfig: null,
17731776
state,
17741777
autoClearWininetCache: state.preferences.autoClearWininetCache,
1778+
override: data.override,
17751779
},
17761780
state.apiEmitters.games.onWillLaunchCurationGame.fireableFactory(state, event.client, 'Error during curate game launch api event'),
17771781
state.apiEmitters.games.onDidLaunchCurationGame.fireableFactory(state, event.client, 'Error during curate post game launch api event'),
@@ -1809,6 +1813,7 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise<v
18091813
state,
18101814
parentGame: newGame(),
18111815
autoClearWininetCache: state.preferences.autoClearWininetCache,
1816+
override: data.override,
18121817
},
18131818
state.apiEmitters.games.onWillLaunchCurationAddApp.fireableFactory(state, event.client, 'Error during curate add app launch api event'),
18141819
state.apiEmitters.games.onDidLaunchCurationAddApp.fireableFactory(state, event.client, 'Error during curate post add app launch api event'));

src/renderer/components/GameGrid.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { GameGridItem } from './GameGridItem';
99
import { GameItemContainer } from './GameItemContainer';
1010
import { GameDragData, GameDragEventData } from './pages/BrowsePage';
1111
import { ScreenshotPreviewMode } from '@shared/BrowsePageLayout';
12-
import { TagFilter } from 'flashpoint-launcher';
12+
import { GameLaunchOverride, TagFilter } from 'flashpoint-launcher';
1313

1414
const RENDERER_OVERSCAN = 5;
1515

@@ -22,7 +22,7 @@ type ColumnsRows = {
2222
};
2323

2424
export type GameGridProps = {
25-
onGameLaunch: (gameId: string) => void;
25+
onGameLaunch: (gameId: string, override: GameLaunchOverride) => void;
2626
/** All games that will be shown in the grid (filter it before passing it here). */
2727
games: ViewGameSet;
2828
/** Total number of games in the results view there are. */
@@ -319,7 +319,7 @@ export class GameGrid extends React.Component<GameGridProps, GameGridState> {
319319
onKeyPress = (event: React.KeyboardEvent): void => {
320320
if (event.key === 'Enter') {
321321
if (this.props.selectedGameId) {
322-
this.props.onGameLaunch(this.props.selectedGameId);
322+
this.props.onGameLaunch(this.props.selectedGameId, null);
323323
}
324324
}
325325
};
@@ -346,7 +346,7 @@ export class GameGrid extends React.Component<GameGridProps, GameGridState> {
346346
* @param gameId ID of Game to launch
347347
*/
348348
onGameLaunch = (event: React.MouseEvent, gameId: string): void => {
349-
this.props.onGameLaunch(gameId);
349+
this.props.onGameLaunch(gameId, null);
350350
};
351351

352352
/**

src/renderer/components/GameList.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { GameItemContainer } from './GameItemContainer';
99
import { GameListHeader } from './GameListHeader';
1010
import { GameListItem } from './GameListItem';
1111
import { GameDragData, GameDragEventData } from './pages/BrowsePage';
12-
import { TagFilter } from 'flashpoint-launcher';
12+
import { GameLaunchOverride, TagFilter } from 'flashpoint-launcher';
1313

1414
/** A function that receives an HTML element. */
1515
type RefFunc<T extends HTMLElement> = (instance: T | null) => void;
@@ -41,7 +41,7 @@ export type OwnProps = {
4141
/** Called when the user attempts to select a game. */
4242
onGameSelect: (gameId?: string, row?: number) => void;
4343
/** Called when the user attempts to launch a game. */
44-
onGameLaunch: (gameId: string) => void;
44+
onGameLaunch: (gameId: string, override: GameLaunchOverride) => void;
4545
/** Called when the user attempts to open a context menu (at a game). */
4646
onContextMenu: (gameId: string) => void;
4747
/** Called when the user starts to drag a game. */
@@ -231,7 +231,7 @@ class _GameList extends React.Component<GameListProps> {
231231
onKeyPress = (event: React.KeyboardEvent): void => {
232232
if (event.key === 'Enter') {
233233
if (this.props.selectedGameId) {
234-
this.props.onGameLaunch(this.props.selectedGameId);
234+
this.props.onGameLaunch(this.props.selectedGameId, null);
235235
}
236236
}
237237
};
@@ -254,7 +254,7 @@ class _GameList extends React.Component<GameListProps> {
254254
* @param gameId ID of Game to launch
255255
*/
256256
onGameLaunch = (event: React.MouseEvent, gameId: string): void => {
257-
this.props.onGameLaunch(gameId);
257+
this.props.onGameLaunch(gameId, null);
258258
};
259259

260260
/**

src/renderer/components/Header.tsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ export class Header extends React.Component<HeaderProps, HeaderState> {
331331
link={joinLibraryRoute(view)}
332332
onContextMenu={() => {
333333
const contextButtons: MenuItemConstructorOptions[] = [
334+
{
335+
label: strings.createNewView,
336+
click: this.onCreateNewView,
337+
},
334338
{
335339
label: strings.renameView,
336340
click: () => this.onRenameView(view),
@@ -345,12 +349,6 @@ export class Header extends React.Component<HeaderProps, HeaderState> {
345349
click: () => this.onDeleteView(view),
346350
},
347351
];
348-
if (this.props.preferencesData.hideNewViewButton) {
349-
contextButtons.push({
350-
label: strings.createNewView,
351-
click: this.onCreateNewView,
352-
});
353-
}
354352
const menu = remote.Menu.buildFromTemplate(contextButtons);
355353
menu.popup({ window: remote.getCurrentWindow() });
356354
}}/>

0 commit comments

Comments
 (0)