Adding comments and cleaning up.

This commit is contained in:
Anonymus Raccoon
2019-05-26 17:32:19 +02:00
parent 73de41b2af
commit 6cfc94f818
7 changed files with 24 additions and 11 deletions

View File

@@ -7,11 +7,10 @@
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<script>if (typeof module === 'object') { window.module = module; module = undefined; }</script>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script> !-->
<script src="../../node_modules/jquery/dist/jquery.min.js"></script>
<script>if (window.module) module = window.module;</script>
<script src="../js/electron-specific.js"></script> <!--Using this script because electrons scripts cant be compiled-->
<script src="../js/electron-specific.js"></script>
<script src="../js/index.js"></script>
</head>

2
dist/js/index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -3,7 +3,8 @@ const path = require("path");
const fs = require("fs");
class Store
{
{
//Create a Store class, set the file path and read the file in order to reduce disk access.
constructor(name)
{
this.path = path.join((electron.app || electron.remote.app).getPath("userData"), name + ".json");
@@ -20,6 +21,15 @@ class Store
this.data[key] = value;
fs.writeFileSync(this.path, JSON.stringify(this.data));
}
//Was trying to create a proper method for saving the games but I don't have time.
// setGames(games)
// {
// for(i = 0; i < games.Length; i++)
// {
// this.data["games"].
// }
// }
}
function readFile(path)

View File

@@ -2,6 +2,7 @@ const Store = require("../js/store");
import * as TokenManager from "./TokenManager";
import { Game, launcher } from "./Game";
//Read the game.json file and return the list of detected games.
export function LoadGames(): Game[]
{
const userAgent = navigator.userAgent.toLowerCase();
@@ -18,12 +19,13 @@ export function LoadGames(): Game[]
}
}
//Refresh the game.json file with content from the logged in accounts
export function UpdateGamesJSON()
{
AddSteamGames();
}
//#region SteamRequests
//Add all steam games to the database.
function AddSteamGames()
{
const steamToken = TokenManager.getSteamToken();
@@ -47,5 +49,4 @@ function AddSteamGames()
const store = new Store("Games");
store.set("games", games); //SHOULDN'T DO IT LIKE THAT, It override every games in the json.
});
}
//#endregion
}

View File

@@ -1,8 +1,8 @@
import { LoadGames, UpdateGamesJSON } from "./GameLoader";
import { Game } from "./Game";
const { ipcRenderer } = require('electron');
//Will get the games in the game.json file and display them in a grid view. Will also refresh the game.json.
export function populateGrid()
{
const games: Game[] = LoadGames();
@@ -28,5 +28,6 @@ export function populateGrid()
function onGameClick(gameClicked: Game)
{
ipcRenderer.send('LaunchGame' ,gameClicked);
//Send the click event to the nodeJS process to handle game launch.
ipcRenderer.send("LaunchGame", gameClicked);
}

View File

@@ -1,3 +1,4 @@
//Will return the steam token of the user if he is logged in. Else, it will return a default steam token (for debbug)
export function getSteamToken(): string
{
const userAgent = navigator.userAgent.toLowerCase();

View File

@@ -1,9 +1,9 @@
// import $ from "jquery"; //Using global scope jquery instead beacause it make a huge file if we use this.
import { setup } from "./Carousel";
import { populateGrid } from "./Library"
const Store = require("../js/store");
//Initialization of the app (load the home page, check if the user wants to use the dark mode and add buttons clicks)
$(function ()
{
const config = new Store("config");
@@ -19,6 +19,7 @@ $(function ()
document.getElementById("settingsBtn").onclick = () => { openSettings() };
});
//Load the home page (called when the user click the home button)
function home()
{
$("#content").load("fragments/home.html", () =>
@@ -37,6 +38,7 @@ function openSearch()
input.focus();
}
//Load the settings menu and set the settings to their good state.
function openSettings()
{
$("#content").load("fragments/settings.html", () =>
@@ -59,6 +61,5 @@ function openSettings()
document.getElementById("title").innerHTML = "<i class='icon fas fa-arrow-left'></i> Settings";
}
require("./Library");
require("./Carousel");