mirror of
https://github.com/zoriya/EAU.git
synced 2025-12-05 22:26:14 +00:00
Adding local game search js.
This commit is contained in:
15
.vscode/launch.json
vendored
15
.vscode/launch.json
vendored
@@ -1,14 +1,19 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"program": "${workspaceFolder}\\main.js"
|
||||
"cwd": "${workspaceRoot}",
|
||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
|
||||
"windows": {
|
||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
|
||||
},
|
||||
"args": [
|
||||
"."
|
||||
],
|
||||
"outputCapture": "std"
|
||||
}
|
||||
]
|
||||
}
|
||||
7
.vscode/tasks.json
vendored
7
.vscode/tasks.json
vendored
@@ -38,13 +38,6 @@
|
||||
"command": "npm run build",
|
||||
"group": "build",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Start app",
|
||||
"type": "shell",
|
||||
"command": "npm start",
|
||||
"group": "build",
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
||||
8
main.js
8
main.js
@@ -1,5 +1,7 @@
|
||||
const { app, BrowserWindow, protocol } = require('electron')
|
||||
|
||||
const LocalGameDiscovery = require("./src/js/LocalGameSearch");
|
||||
|
||||
var win;
|
||||
|
||||
function createWindow()
|
||||
@@ -39,4 +41,8 @@ app.on("activate", () =>
|
||||
{
|
||||
if (win === null)
|
||||
createWindow();
|
||||
});
|
||||
});
|
||||
|
||||
console.log(typeof LocalGameDiscovery.init);
|
||||
LocalGameDiscovery.init();
|
||||
|
||||
|
||||
865
package-lock.json
generated
865
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,8 @@
|
||||
"bootstrap": "^4.3.1",
|
||||
"fs": "0.0.1-security",
|
||||
"jquery": "^3.3.1",
|
||||
"popper.js": "^1.14.7"
|
||||
"popper.js": "^1.14.7",
|
||||
"electron-log": "^3.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^4.1.1",
|
||||
|
||||
70
src/js/LocalGameSearch.js
Normal file
70
src/js/LocalGameSearch.js
Normal file
@@ -0,0 +1,70 @@
|
||||
/* This script is for managing local game discovery */
|
||||
|
||||
const fs = require('fs');
|
||||
const vdf = require('simple-vdf');
|
||||
const path = require("path");
|
||||
const Registery = require('winreg');
|
||||
|
||||
module.exports = {
|
||||
init: function () { GetGameLocation(); }
|
||||
}
|
||||
|
||||
function GetGameLocation()
|
||||
{
|
||||
//64bit regObj path
|
||||
RegSteamPath = new Registery({
|
||||
hive: Registery.HKLM,
|
||||
key: '\\SOFTWARE\\Wow6432Node\\Valve\\Steam'
|
||||
});
|
||||
|
||||
//32bit regObj path
|
||||
RegSteamPathx86 = new Registery({
|
||||
hive: Registery.HKLM,
|
||||
key: 'HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam'
|
||||
});
|
||||
|
||||
//read steam install folder key value (32bit steam)
|
||||
RegSteamPathx86.get("InstallPath", GetLibrary);
|
||||
|
||||
//read steam install folder key value (64bit steam)
|
||||
RegSteamPath.get("InstallPath", GetLibrary );
|
||||
}
|
||||
|
||||
|
||||
|
||||
function GetLibrary(err, data)
|
||||
{
|
||||
//Error handling (trust me)
|
||||
if (err)
|
||||
return;
|
||||
|
||||
|
||||
//normalise path
|
||||
|
||||
|
||||
let NormalisedSteamPath = path.normalize(data.value + "/steamapps/libraryfolders.vdf");
|
||||
console.log("normalised path: " + NormalisedSteamPath);
|
||||
|
||||
//read game library location
|
||||
|
||||
fs.readFile(NormalisedSteamPath, (err, data) =>
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (err) throw err;
|
||||
let str = data.toString();
|
||||
let raw = vdf.parse(str);
|
||||
let SteamJSONobj = JSON.parse( JSON.stringify(raw) );
|
||||
console.log(SteamJSONobj.LibraryFolders["1"]);
|
||||
|
||||
if (SteamJSONobj === null){console.warn("can't read json")}
|
||||
|
||||
for (let i = 0; i > 10; i++ )
|
||||
{
|
||||
console.log(SteamJSONobj.LibraryFolders);
|
||||
}
|
||||
//console.log(SteamJSONobj.LibraryFolders.1);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
/** This script is for managing local game discovery */
|
||||
function GetGameLocation()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import { populateGrid } from "./Library"
|
||||
$(function ()
|
||||
{
|
||||
home();
|
||||
|
||||
document.getElementById("title").onclick = () => { home() };
|
||||
document.getElementById("searchBtn").onclick = () => { openSearch() };
|
||||
document.getElementById("settingsBtn").onclick = () => { openSettings() };
|
||||
@@ -37,6 +38,6 @@ function openSettings()
|
||||
document.getElementById("title").innerHTML = "<i class='icon fas fa-arrow-left'></i> Settings";
|
||||
}
|
||||
|
||||
|
||||
require("./Library");
|
||||
require("./Carousel");
|
||||
require("./LocalGameSearch");
|
||||
require("./Carousel");
|
||||
37
store.js
Normal file
37
store.js
Normal file
@@ -0,0 +1,37 @@
|
||||
require("elecron");
|
||||
require("path");
|
||||
require("fs");
|
||||
|
||||
class Store
|
||||
{
|
||||
constructor(name)
|
||||
{
|
||||
this.path = path.join((Electron.app || Electron.remote.app).getPath("userData"), name + ".json");
|
||||
this.data = readFile(this.path);
|
||||
}
|
||||
|
||||
get(key)
|
||||
{
|
||||
return this.data[key];
|
||||
}
|
||||
|
||||
set(key, value)
|
||||
{
|
||||
this.data[key] = value;
|
||||
fs.writeFileSync(this.path, JSON.stringify(this.data));
|
||||
}
|
||||
}
|
||||
|
||||
function readFile(path)
|
||||
{
|
||||
try
|
||||
{
|
||||
return JSON.parse(fs.readFileSync(path));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Store;
|
||||
Reference in New Issue
Block a user