Skip to content

Commit

Permalink
Merge branch 'release/10.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
colin969 committed Sep 22, 2021
2 parents acbd67b + e58e3ce commit f878ab8
Show file tree
Hide file tree
Showing 40 changed files with 2,509 additions and 954 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ npm-debug.log.*
# Visual Studio Code
/.vscode

# JetBrains
/.idea

# Build
/build

Expand Down
12 changes: 10 additions & 2 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
"configHeader": "Config",
"configDesc": "(You must press 'Save & Restart' for some changes to take effect)",
"preferencesHeader": "Preferences",
"extremeGames": "Extreme Content",
"extremeGamesDesc": "Allow tags inside 'Extreme' tag filter groups and corresponding games to be shown.",
"extremeGames": "Show Extreme Filters",
"extremeGamesDesc": "Allows Extreme tag filters to be toggled, created and modified to control content unsuitable for children.",
"hideExtremeScreenshots": "Hide Extreme Screenshots",
"hideExtremeScreenshotsDesc": "Hides screenshots of Extreme tagged content, can be unhidden with a click on the image box.",
"fancyAnimations": "Fancy Animations",
"fancyAnimationsDesc": "Enable fancy animations in the launcher.",
"searchLimit": "Search Limit",
"searchLimitDesc": "Limit the number of results returned in any search",
"searchLimitUnlimited": "Unlimited",
"searchLimitValue": "{0} Results",
"enableEditing": "Enable Editing",
"enableEditingDesc": "Enable editing of games and additional applications. Also shows tabs related to editing.",
"onDemandImages": "On Demand Images",
Expand All @@ -18,6 +24,7 @@
"fallbackLanguageDesc": "Which language to use in place of an incomplete current language.",
"auto": "Auto ({0})",
"none": "None",
"contentFiltersHeader": "Content Filters",
"flashpointHeader": "Flashpoint",
"flashpointPath": "Flashpoint Path",
"flashpointPathDesc": "Path to the Flashpoint folder (can be relative)",
Expand Down Expand Up @@ -81,6 +88,7 @@
"helpInfo": "Need help? {0}.",
"help": "Read the manual",
"upgradesHeader": "Upgrades",
"updateFeedHeader": "News Feed",
"installComplete": "Install Complete",
"alreadyInstalled": "Already Installed",
"download": "Download",
Expand Down
1,794 changes: 1,428 additions & 366 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flashpoint-launcher",
"version": "10.0.0",
"version": "10.1.0",
"description": "A desktop application used to browse, manage and play games from BlueMaxima's Flashpoint",
"main": "build/main/index.js",
"config": {
Expand Down Expand Up @@ -32,7 +32,10 @@
},
"license": "MIT",
"dependencies": {
"axios": "0.21.1",
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.1.15",
"axios": "0.21.2",
"connected-react-router": "6.8.0",
"electron-updater": "4.3.1",
"electron-util": "0.14.2",
Expand All @@ -44,21 +47,23 @@
"react": "16.13.1",
"react-color": "2.18.0",
"react-dom": "16.13.1",
"react-markdown": "^7.0.1",
"react-redux": "7.2.0",
"react-router-dom": "5.1.2",
"react-virtualized": "9.22.3",
"redux": "4.0.5",
"redux-devtools-extension": "2.13.8",
"reflect-metadata": "0.1.10",
"remark-gfm": "^2.0.0",
"sqlite3": "4.2.0",
"tail": "2.0.3",
"tree-kill": "1.2.2",
"typeorm": "0.2.22",
"typeorm": "0.2.37",
"typesafe-actions": "4.4.2",
"uuid": "3.3.2",
"uuid-validate": "0.0.3",
"which": "1.3.1",
"ws": "7.2.5",
"ws": "7.4.6",
"yaml": "1.10.0"
},
"devDependencies": {
Expand All @@ -69,7 +74,7 @@
"@types/fs-extra": "8.1.0",
"@types/jest": "24.0.17",
"@types/mime": "2.0.1",
"@types/node": "12.7.0",
"@types/node": "14.14.31",
"@types/react": "16.9.34",
"@types/react-color": "3.0.1",
"@types/react-dom": "16.9.7",
Expand All @@ -85,7 +90,7 @@
"@typescript-eslint/parser": "3.3.0",
"coveralls": "3.1.0",
"cross-env": "7.0.2",
"electron": "8.5.5",
"electron": "11.5.0",
"electron-builder": "22.5.1",
"electron-devtools-installer": "3.1.1",
"enzyme": "3.11.0",
Expand Down
3 changes: 2 additions & 1 deletion src/back/extensions/ApiImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export function createApiFactory(extId: string, extManifest: IExtensionManifest,
debug: (message: string) => addExtLog(newExtLog(extManifest, message, log.debug)),
info: (message: string) => addExtLog(newExtLog(extManifest, message, log.info)),
warn: (message: string) => addExtLog(newExtLog(extManifest, message, log.warn)),
error: (message: string) => addExtLog(newExtLog(extManifest, message, log.error))
error: (message: string) => addExtLog(newExtLog(extManifest, message, log.error)),
onLog: state.apiEmitters.onLog.event,
};

// Commands Namespace
Expand Down
20 changes: 14 additions & 6 deletions src/back/game/GameManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export type GetPageKeysetResult = {
total: number;
}

export async function findGamePageKeyset(filterOpts: FilterGameOpts, orderBy: GameOrderBy, direction: GameOrderReverse): Promise<GetPageKeysetResult> {
export async function findGamePageKeyset(filterOpts: FilterGameOpts, orderBy: GameOrderBy, direction: GameOrderReverse, searchLimit?: number): Promise<GetPageKeysetResult> {
// let startTime = Date.now();

validateSqlName(orderBy);
Expand All @@ -123,6 +123,10 @@ export async function findGamePageKeyset(filterOpts: FilterGameOpts, orderBy: Ga
.where('g.page_boundary = 1')
.setParameters(subQ.getParameters());

if (searchLimit) {
query = query.limit(searchLimit);
}

const raw = await query.getRawMany();
const keyset: PageKeyset = {};
for (const r of raw) {
Expand All @@ -134,10 +138,14 @@ export async function findGamePageKeyset(filterOpts: FilterGameOpts, orderBy: Ga
// Count games
let total = -1;
// startTime = Date.now();
query = await getGameQuery('sub', filterOpts, orderBy, direction, 0, undefined, undefined);
const subGameQuery = await getGameQuery('sub', filterOpts, orderBy, direction, 0, searchLimit ? searchLimit : undefined, undefined);
query = getManager().createQueryBuilder()
.select('COUNT(*)')
.from('(' + subGameQuery.getQuery() + ')', 'g')
.setParameters(subGameQuery.getParameters())
.skip(0);
if (searchLimit) { query = query.limit(searchLimit); }

query.skip(0);
query.select('COUNT(*)');
const result = await query.getRawOne();
if (result) {
total = Coerce.num(result['COUNT(*)']); // Coerce it, even though it is probably of type number or undefined
Expand Down Expand Up @@ -478,7 +486,7 @@ function doWhereTitle(alias: string, query: SelectQueryBuilder<Game>, value: str

const where = new Brackets(qb => {
const q = and ? qb : query;
const ref = `generic-${count}`;
const ref = `generic_${count}`;
q.where( `${alias}.title ${comparator} :${ref}`, { [ref]: formedValue });
q.orWhere(`${alias}.alternateTitles ${comparator} :${ref}`, { [ref]: formedValue });
q.orWhere(`${alias}.developer ${comparator} :${ref}`, { [ref]: formedValue });
Expand Down Expand Up @@ -513,7 +521,7 @@ function doWhereField(alias: string, query: SelectQueryBuilder<Game>, field: str

// console.log(`W: ${count} - C: ${comparator} - F: ${field} - V:${value}`);
// Do correct 'where' call
const ref = `field-${count}`;
const ref = `field_${count}`;
if (count === 0) {
query.where(`${alias}.${field} ${comparator} :${ref}`, { [ref]: formedValue });
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/back/game/TagManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function findTags(name?: string, flatFilters?: string[]): Promise<T
.setParameters(filterQuery.getParameters());
}

return query.orderBy('tag.categoryId DESC, primaryAlias.name', 'ASC')
return query.orderBy('tag.categoryId ASC, primaryAlias.name', 'ASC')
.getMany();
}

Expand Down
12 changes: 7 additions & 5 deletions src/back/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const state: BackState = {
apiEmitters: {
onDidInit: new ApiEmitter<void>(),
onDidConnect: new ApiEmitter<void>(),
onLog: new ApiEmitter<flashpoint.ILogEntry>(),
games: {
onWillLaunchGame: new ApiEmitter<flashpoint.GameLaunchInfo>(),
onWillLaunchAddApp: new ApiEmitter<flashpoint.AdditionalApp>(),
Expand Down Expand Up @@ -166,6 +167,7 @@ const state: BackState = {
},
extensionsService: createErrorProxy('extensionsService'),
connection: undefined,
writeLocks: 0,
};

main();
Expand Down Expand Up @@ -246,11 +248,11 @@ async function onProcessMessage(message: any, sendHandle: any): Promise<void> {

const addLog = (entry: ILogEntry): number => { return state.log.push(entry) - 1; };
global.log = {
trace: logFactory(LogLevel.TRACE, state.socketServer, addLog, state.logFile, state.verbose),
debug: logFactory(LogLevel.DEBUG, state.socketServer, addLog, state.logFile, state.verbose),
info: logFactory(LogLevel.INFO, state.socketServer, addLog, state.logFile, state.verbose),
warn: logFactory(LogLevel.WARN, state.socketServer, addLog, state.logFile, state.verbose),
error: logFactory(LogLevel.ERROR, state.socketServer, addLog, state.logFile, state.verbose)
trace: logFactory(LogLevel.TRACE, state.socketServer, addLog, state.logFile, state.verbose, state.apiEmitters.onLog),
debug: logFactory(LogLevel.DEBUG, state.socketServer, addLog, state.logFile, state.verbose, state.apiEmitters.onLog),
info: logFactory(LogLevel.INFO, state.socketServer, addLog, state.logFile, state.verbose, state.apiEmitters.onLog),
warn: logFactory(LogLevel.WARN, state.socketServer, addLog, state.logFile, state.verbose, state.apiEmitters.onLog),
error: logFactory(LogLevel.ERROR, state.socketServer, addLog, state.logFile, state.verbose, state.apiEmitters.onLog)
};

state.socketServer.secret = content.secret;
Expand Down
37 changes: 36 additions & 1 deletion src/back/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ export function registerRequestCallbacks(state: BackState): void {
// Fire after return has sent
setTimeout(() => state.apiEmitters.onDidConnect.fire(), 100);

// Fetch update feed
let updateFeedMarkdown = '';
if (state.preferences.updateFeedUrl) {
updateFeedMarkdown = await axios.get(state.preferences.updateFeedUrl, { timeout: 3000 })
.then((res) => {
return res.data;
})
.catch((err) => {
log.debug('Launcher', 'Failed to fetch update feed, ERROR: ' + err);
return '';
});
} else {
log.debug('Launcher', 'No Update Feed URL specified');
}

return {
preferences: state.preferences,
config: state.config,
Expand Down Expand Up @@ -129,6 +144,7 @@ export function registerRequestCallbacks(state: BackState): void {
logoSets: Array.from(state.registry.logoSets.values()),
extConfigs: await state.extensionsService.getContributions('configuration'),
extConfig: state.extConfig,
updateFeedMarkdown: updateFeedMarkdown,
};

});
Expand Down Expand Up @@ -620,7 +636,7 @@ export function registerRequestCallbacks(state: BackState): void {

state.socketServer.register(BackIn.BROWSE_VIEW_KEYSET, async (event, library, query) => {
query.filter = adjustGameFilter(query.filter);
const result = await GameManager.findGamePageKeyset(query.filter, query.orderBy, query.orderReverse);
const result = await GameManager.findGamePageKeyset(query.filter, query.orderBy, query.orderReverse, query.searchLimit);
return {
keyset: result.keyset,
total: result.total,
Expand Down Expand Up @@ -827,7 +843,9 @@ export function registerRequestCallbacks(state: BackState): void {
}

overwritePreferenceData(state.preferences, dif);
state.writeLocks += 1;
await PreferencesFile.saveFile(path.join(state.config.flashpointPath, PREFERENCES_FILENAME), state.preferences);
state.writeLocks -= 1;
}
state.socketServer.send(event.client, BackOut.UPDATE_PREFERENCES_RESPONSE, state.preferences);
});
Expand Down Expand Up @@ -1115,6 +1133,23 @@ export function registerRequestCallbacks(state: BackState): void {

state.socketServer.register(BackIn.QUIT, async (event) => {
// Unload all extensions before quitting
const timeoutPromise = new Promise((resolve, reject) => {
setTimeout(resolve, 20000);
});
const writePromise = new Promise((resolve, reject) => {
const loopFunc = () => {
if (state.writeLocks > 0) {
setTimeout(loopFunc, 100);
} else {
resolve();
}
};
loopFunc();
});
await Promise.race([timeoutPromise, writePromise])
.catch((err) => {
/** Bit late to really do anything here */
});
await state.extensionsService.unloadAll();
state.socketServer.send(event.client, BackOut.QUIT);
exit(state);
Expand Down
2 changes: 2 additions & 0 deletions src/back/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export type BackState = {
readonly registry: Registry;
extensionsService: ExtensionService;
connection: Connection | undefined;
writeLocks: number;
}

export type BackQueryChache = {
Expand Down Expand Up @@ -159,6 +160,7 @@ export type StatusState = {
export type ApiEmittersState = Readonly<{
onDidInit: ApiEmitter<void>;
onDidConnect: ApiEmitter<void>;
onLog: ApiEmitter<flashpoint.ILogEntry>;
games: Readonly<{
onWillLaunchGame: ApiEmitter<flashpoint.GameLaunchInfo>;
onWillLaunchAddApp: ApiEmitter<flashpoint.AdditionalApp>;
Expand Down
4 changes: 3 additions & 1 deletion src/back/util/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { BackOut } from '@shared/back/types';
import { LogFunc } from '@shared/interfaces';
import { ILogEntry, LogLevel } from '@shared/Log/interface';
import { LogFile } from './LogFile';
import { ApiEmitter } from '@back/extensions/ApiEmitter';

export function logFactory(logLevel: LogLevel, socketServer: SocketServer, addLog: (message: ILogEntry) => number, logFile: LogFile, verbose: boolean): LogFunc {
export function logFactory(logLevel: LogLevel, socketServer: SocketServer, addLog: (message: ILogEntry) => number, logFile: LogFile, verbose: boolean, apiEvent: ApiEmitter<ILogEntry>): LogFunc {
return function (source: string, content: string): ILogEntry {
const levelName: string = LogLevel[logLevel] || '?????';
const formedLog: ILogEntry = {
Expand All @@ -16,6 +17,7 @@ export function logFactory(logLevel: LogLevel, socketServer: SocketServer, addLo
const index = addLog(formedLog);
logFile.saveLog(formedLog);
socketServer.broadcast(BackOut.LOG_ENTRY_ADDED, formedLog, index);
apiEvent.fire(formedLog);
if (verbose) { console.log(`${levelName.padEnd(5)} - ${Date.now()} - ${content}`); }
return formedLog;
};
Expand Down
1 change: 1 addition & 0 deletions src/main/BrowserMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export async function startBrowserMode(init: Init): Promise<void> {
webPreferences: {
nodeIntegration: false,
plugins: true,
enableRemoteModule: true,
},
});
window.setMenu(null); // Remove the menu bar
Expand Down
3 changes: 2 additions & 1 deletion src/main/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export function main(init: Init): void {
// Wait for process to initialize
state.backProc.once('message', (port) => {
if (port >= 0) {
state.backHost.port = port;
state.backHost.port = port as string;
resolve();
} else {
reject(new Error('Failed to start server in back process. Perhaps because it could not find an available port.'));
Expand Down Expand Up @@ -368,6 +368,7 @@ export function main(init: Init): void {
webPreferences: {
preload: path.resolve(__dirname, './MainWindowPreload.js'),
nodeIntegration: true,
enableRemoteModule: true,
},
});
// Remove the menu bar
Expand Down
Loading

0 comments on commit f878ab8

Please sign in to comment.