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

Commit

Permalink
add ps5 supported games
Browse files Browse the repository at this point in the history
  • Loading branch information
Tustin committed Nov 21, 2020
1 parent 205c8b8 commit d6a69a4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"lint": "tslint --project .",
"compile": "npm run lint && tsc && sass ./assets/app.scss ./dist/app.css --style=compressed --no-source-map",
"watch": "tsc -w",
"start": "npm run compile && cross-env NODE_ENV=prod electron .",
"start": "npm run compile && cross-env NODE_ENV=dev electron .",
"build:icons": "electron-icon-maker -i ./assets/images/logo.png -o ./build/",
"build:win": "npm run compile && npm run build:icons && electron-builder build --windows",
"build:mac": "npm run compile && npm run build:icons && electron-builder build --mac",
Expand Down Expand Up @@ -87,7 +87,8 @@
"lodash": "^4.17.20",
"normalize.css": "^8.0.1",
"progress-stream": "^2.0.0",
"query-string": "^6.13.7"
"query-string": "^6.13.7",
"unorm": "^1.6.0"
},
"devDependencies": {
"@types/electron-store": "^1.3.0",
Expand Down
17 changes: 15 additions & 2 deletions src/SupportedGames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _store = require('electron-store');
import log = require('electron-log');
import axios from 'axios';
import { IBasicPresence } from './Model/PresenceModel';
const unorm = require('unorm');

interface IGame
{
Expand Down Expand Up @@ -69,10 +70,22 @@ class SupportedGames

public get(presence: IBasicPresence) : IGame
{
return this.store.get('consoles.ps4').find((game: IGame) => {
const console = presence.primaryPlatformInfo.platform.toLowerCase();
const consoleStore = `consoles.${console}`;
if (!this.store.has(consoleStore))
{
log.debug('no console found in supported games list.');

return undefined;
}

return this.store.get(consoleStore).find((game: IGame) => {
const titleInfo = presence.gameTitleInfoList[0];
if (game.titleId.toLowerCase() === titleInfo.npTitleId.toLowerCase()) {
return true;
}

return (game.titleId.toLowerCase() === titleInfo.npTitleId.toLowerCase()) || (game.name.toLowerCase() === titleInfo.titleName.toLowerCase());
return unorm.nfc(game.name.toLowerCase()).indexOf(unorm.nfc(titleInfo.titleName.toLowerCase())) !== -1;
});
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,12 @@ function spawnMainWindow() : void

playstationAccount.profile()
.then((profile) => {
log.info('Got PSN profile info', profile);
log.debug('Got PSN profile info', profile);
mainWindow.webContents.send('profile-data', profile);
}).catch((err) => {
log.error('Failed fetching PSN profile', err);
});

mainWindow.webContents.openDevTools();

appEvent.emit('start-rich-presence');
});

Expand Down Expand Up @@ -291,7 +289,6 @@ function updateRichPresence() : void
{
playstationAccount.presences()
.then((presence) => {
console.log(presence);
if (presence.primaryPlatformInfo.onlineStatus !== 'online')
{
if (discordController && discordController.running())
Expand Down Expand Up @@ -358,7 +355,7 @@ function updateRichPresence() : void
if (previousPresence === undefined || _.get(previousPresenceTitleInfo, ['npTitleId']) !== _.get(titleInfo, ['npTitleId']))
{
// See if we're actually playing a title.
if (titleInfo.npTitleId === undefined)
if (!_.get(titleInfo, ['npTitleId']))
{
discordRichPresenceData = {
details: 'Online',
Expand Down
2 changes: 0 additions & 2 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ ipcRenderer.on('presence-data', (event: any, data: any) => {
const details = document.getElementById('details');
const state = document.getElementById('state');

console.log(data);

state.innerHTML = '';
details.innerHTML = data.details;

Expand Down

0 comments on commit d6a69a4

Please sign in to comment.