Skip to content

Commit

Permalink
Switched out ps-node for lcu-connector
Browse files Browse the repository at this point in the history
  • Loading branch information
Pupix committed Dec 11, 2017
1 parent e34043a commit 11ee1d6
Show file tree
Hide file tree
Showing 5 changed files with 442 additions and 113 deletions.
72 changes: 36 additions & 36 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
const electron = require('electron');
const LCUConnector = require('lcu-connector');

const electron = require('electron');
const {app} = electron;
const {BrowserWindow} = electron;
const root = __dirname + '/app';
const connector = new LCUConnector();
const { app } = electron;
const { BrowserWindow } = electron;
const root = __dirname + '/app';

const UX = require('./lib/ux');
let mainWindow = null;

let mainWindow = null;
app.commandLine.appendSwitch('--ignore-certificate-errors');

app.commandLine.appendSwitch('--ignore-certificate-errors');
app.on('ready', () => {

app.on('ready', () => {

mainWindow = new BrowserWindow({
center: true,
height: 720,
show: false,
title: 'League API',
width: 1280
});

// Remove default menu
mainWindow.setMenu(null);

mainWindow.loadURL('file://' + root + '/index.html');
mainWindow = new BrowserWindow({
center: true,
height: 720,
show: false,
title: 'Rift Explorer',
width: 1280
});

// Check if dev env FIXME
//mainWindow.openDevTools();
// Remove default menu
mainWindow.setMenu(null);
mainWindow.loadURL('file://' + root + '/index.html');

// Avoid white page on load.
mainWindow.webContents.on('did-finish-load', () => {
UX.getArguments()
.then((result) => mainWindow.webContents.send('arguments-load', result))
.catch((error) => mainWindow.webContents.send('arguments-error', error.message));
// Check if dev env FIXME
//mainWindow.openDevTools();

mainWindow.show();
// Avoid white page on load.
mainWindow.webContents.on('did-finish-load', () => {
connector.on('connect', (data) => {
mainWindow.webContents.send('lcu-load', data);
});

mainWindow.on('closed', () => {
mainWindow = null;
});
connector.start();
mainWindow.show();
});

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
mainWindow.on('closed', () => {
mainWindow = null;
});
});

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
16 changes: 5 additions & 11 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
const shell = require('electron').shell;
const REMOTE = require('electron').remote;

IPC.on('arguments-load', (event, args) => {
IPC.on('lcu-load', (event, data) => {

const password = args['remoting-auth-token'];
const port = args['app-port'];
const { username, password, address, port } = data;

window.swaggerUi = new SwaggerUi({
url: `https://riot:${password}@localhost:${port}/v2/swagger.json`,
url: `https://${username}:${password}@${address}:${port}/v2/swagger.json`,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete(swaggerApi, swaggerUi) {
Expand All @@ -47,7 +46,7 @@
hljs.highlightBlock(e)
});

const header = `Basic ${btoa(`riot:${password}`)}`;
const header = `Basic ${btoa(`${username}:${password}`)}`;
const auth = new SwaggerClient.ApiKeyAuthorization("Authorization", header, "header");

window.swaggerUi.api.clientAuthorizations.add("riot", auth);
Expand All @@ -67,11 +66,6 @@

});

IPC.on('arguments-error', (event, arg) => {
alert('Trouble finding the client. Make sure your League is running.');
REMOTE.getCurrentWindow().close();
});

function _handleGithubLink(event) {
shell.openExternal('https://github.com/pupix/rift-explorer');
}
Expand All @@ -80,7 +74,7 @@
</head>

<body class="swagger-section">
<div id="message-bar" class="swagger-ui-wrap" data-sw-translate>Searching for League process...</div>
<div id="message-bar" class="swagger-ui-wrap" data-sw-translate>Waiting for League to start...</div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>
</html>
35 changes: 0 additions & 35 deletions lib/ux.js

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rift-explorer",
"version": "1.0.0",
"version": "1.0.1",
"description": "Explore the API of the League of Legends client",
"main": "app.js",
"scripts": {
Expand All @@ -10,7 +10,7 @@
"author": "Robert Manolea <[email protected]>",
"license": "MIT",
"dependencies": {
"ps-node": "^0.1.1"
"lcu-connector": "^1.0.0"
},
"devDependencies": {
"electron": "^1.7.9",
Expand All @@ -19,5 +19,5 @@
"build": {
"productName": "Rift Explorer",
"appId": "com.rift-explorer"
}
}
}
Loading

0 comments on commit 11ee1d6

Please sign in to comment.