added support to launch steam game trought the app

think to run npm i
This commit is contained in:
happy44300
2019-05-22 16:00:23 +02:00
parent 6a0a28cf15
commit fcbf366c69
7 changed files with 13166 additions and 13 deletions

4
dist/js/index.js vendored

File diff suppressed because one or more lines are too long

30
main.js
View File

@@ -1,7 +1,9 @@
const { app, BrowserWindow } = require('electron')
const { app, BrowserWindow, ipcMain } = require('electron')
const LocalGameDiscovery = require("./src/js/LocalGameSearch");
const Store = require("./src/js/store");
const log = require("electron-log");
const { execFile } = require('child_process');
const path = require("path");
var win;
@@ -43,7 +45,7 @@ else
});
LocalGameDiscovery.init();
LocalGameDiscovery.init();
}
function createWindow()
@@ -69,3 +71,27 @@ function handleArgs(arg)
store.set("steam", token);
}
}
ipcMain.on('LaunchGame', LaunchGame);
function LaunchGame(event,game)
{
game = JSON.parse(game);
if( game.isInstalled != null &&game.isInstalled == false)
{
console.error(game.name + "is not installed")
}
if(game.launcher !=null && game.launcher == 1)
{
let steampath = path.normalize(new Store("SteamGamesMetas").get("SteamPath") + "\\Steam.exe");
//let parameters = ["-applaunch " , game.appid];
//execFile(steampath, parameters );
require("openurl").open("steam://rungameid/" + game.appid)
//console.log(steampath +"===" + parameters)
}else if( game.launcher == null)
{
console.log ("game launcher is null");
}
}

13119
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -9,8 +9,10 @@
"electron-log": "^3.0.5",
"fs": "0.0.1-security",
"jquery": "^3.4.0",
"openurl": "^1.1.1",
"popper.js": "^1.15.0",
"readline-specific": "^1.0.4",
"request": "^2.88.0",
"simple-vdf": "^1.1.1",
"winreg": "^1.2.4"
},

View File

@@ -28,6 +28,8 @@
pointer-events:auto;
transition: width 0.5s;
@include media-breakpoint-up(md)
{
width: 20vw;
@@ -46,6 +48,8 @@
}
}
}
.disabled {
pointer-events: none;
opacity: 0.0;

View File

@@ -1,6 +1,9 @@
import { type } from "os";
//import {Game} from "./Library"
import { Game } from "./Game";
import { Game, launcher } from "./Game";
const { ipcRenderer } = require('electron');
var selectedIndex = 5;
var carousel: any;
@@ -40,7 +43,7 @@ function iniCallback(SelectedRecentGames : GameMeta[])
if(i < SelectedRecentGames.length )
{
list[i].src = "https://steamcdn-a.akamaihd.net/steam/apps/"+SelectedRecentGames[i].AppId+"/header.jpg";
list[i].dataset.game = SelectedRecentGames[i].AppId;
list[i].dataset.game = JSON.stringify( new Game(null,SelectedRecentGames[i].AppId.toString(),list[i].srcn, launcher.Steam,"Steam" ,null, null ) );
list[i].id= i.toString();
list[i].addEventListener("click", () =>
{
@@ -74,21 +77,17 @@ function rotateCarousel(target: any, bypass: boolean)
//Launch the game on the front of the carousel
if (selectedIndex == target.id && bypass == false) // the bypass is for ini
{
LaunchGame(target.dataset.game);
ipcRenderer.send('LaunchGame' , target.dataset.game);
return;
}
target.classList.add("higlight");// make the central cell bigger
console.log("last selected " +lastselected.id);
carousel.style.transform = "translateZ(-1000px) rotateY(" + angle + "deg)";
selectedIndex = target.id;
lastselected= target;
}
function LaunchGame(game: any)
{
console.log("launch game"+ game);
}
class GameMeta
{
@@ -102,4 +101,5 @@ class GameMeta
this.thumb = thumb;
}
}

View File

@@ -1,6 +1,8 @@
import { LoadGames, UpdateGamesJSON } from "./GameLoader";
import { Game } from "./Game";
const { ipcRenderer } = require('electron');
export function populateGrid()
{
const games: Game[] = LoadGames();
@@ -26,5 +28,5 @@ export function populateGrid()
function onGameClick(gameClicked: Game)
{
console.log(gameClicked.name);
ipcRenderer.send('LaunchGame' ,gameClicked);
}