Skip to content

Commit

Permalink
Merge branch 'release/0.1.5'
Browse files Browse the repository at this point in the history
Conflicts:
	readme.md
	src/package.json
  • Loading branch information
Marco committed Nov 12, 2015
2 parents 2a9b394 + 52ac0f0 commit 85a8f36
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 61 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"main": "gulpfile.js",
"scripts": {
"postinstall": "cd src; npm install",
"postinstall": "npm install --prefix src",
"start": "./node_modules/.bin/electron ./src",
"build": "./node_modules/.bin/gulp"
},
Expand Down
7 changes: 1 addition & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ Afterwards, you need to run
````shell
$ npm install
````
in the root directory **AND** in the source directory.

In the src directory, run
````shell
bower install
````
in the root directory.

That's it! You should be able to test the app by running
````shell
Expand Down
7 changes: 3 additions & 4 deletions src/app/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ var app = angular.module('app.controllers', ['ngSanitize']);

app.controller('MainController', ['$scope', '$rootScope', '$mdDialog',
function($scope, $rootScope, $mdDialog) {

var ipc = require('ipc');

var matchClientVersionToReplayVersion = function() {
if ($scope.lolClientVersion && $scope.replay && $scope.replay.riotVersion) {
var regex = $scope.lolClientVersion.match(/(?:.*?\s)(\d+)\.(\d+)\./);
Expand All @@ -14,7 +13,7 @@ app.controller('MainController', ['$scope', '$rootScope', '$mdDialog',
}
}
};

$scope.loading = true;
$scope.msg = "Loading...";
$scope.replay = null;
Expand All @@ -23,7 +22,7 @@ app.controller('MainController', ['$scope', '$rootScope', '$mdDialog',
$scope.lolClientVersionShort = "";
$scope.aofClientInfo = {};
$scope.replayVersionMatch = true;

$scope.settings = [ { id: 1, name: "Select LoL Client" }, { id: 2, name: "Client info" }, { id: 3, name: "Send current log to aof.gg" } ];

$scope.showAofClientInfo = function(event) {
Expand Down
16 changes: 8 additions & 8 deletions src/app/tpl/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
<tr ng-repeat="player in replay.players | filter: { 'teamNr': 0 }">
<td>{{ player.summonerName }}</td>
<td style="text-align: center;">
<img style="float: left; margin-right: 2px; margin-left: 2px;" ng-src="http://api.aof.gg/static/champion/{{player.champion.image}}" width="48" height="48" />
<img style="float: left; margin-right: 2px; margin-left: 2px;" ng-src="http://ddragon.leagueoflegends.com/cdn/5.21.1/img/champion/{{player.champion.image}}" width="48" height="48" />
<div style="float: left;">
<div class="spell1"><img ng-src="http://api.aof.gg/static/spell/{{player.d.image}}" width="23" height="23"></div>
<div class="spell2"><img ng-src="http://api.aof.gg/static/spell/{{player.f.image}}" width="23" height="23"></div>
<div class="spell1"><img ng-src="http://ddragon.leagueoflegends.com/cdn/5.21.1/img/spell/{{player.d.image}}" width="23" height="23"></div>
<div class="spell2"><img ng-src="http://ddragon.leagueoflegends.com/cdn/5.21.1/img/spell/{{player.f.image}}" width="23" height="23"></div>
</div>
</td>
<td style="text-align: center;">
<img style="margin-top: 5px;" ng-src="http://api.aof.gg/static/league/{{player.league.image}}" width="48" height="48" />
<img style="margin-top: 5px;" ng-src="http://aof.gg/{{player.league.image}}" width="48" height="48" />
<md-tooltip md-direction="right">
{{ player.league.name }} {{ player.leagueRank != 0 ? player.leagueRank : "" }}
</md-tooltip>
Expand All @@ -58,16 +58,16 @@
</thead>
<tr ng-repeat="player in replay.players | filter: { 'teamNr': 1 }">
<td style="text-align: center;">
<img style="margin-top: 5px;" ng-src="http://api.aof.gg/static/league/{{player.league.image}}" width="48" height="48" />
<img style="margin-top: 5px;" ng-src="http://aof.gg/{{player.league.image}}" width="48" height="48" />
<md-tooltip md-direction="left">
{{ player.league.name }} {{ player.leagueRank != 0 ? player.leagueRank : "" }}
</md-tooltip>
</td>
<td style="text-align: center;">
<img style="float: right; margin-right: 2px; margin-left: 2px;" ng-src="http://api.aof.gg/static/champion/{{player.champion.image}}" width="48" height="48" />
<img style="float: right; margin-right: 2px; margin-left: 2px;" ng-src="http://ddragon.leagueoflegends.com/cdn/5.21.1/img/champion/{{player.champion.image}}" width="48" height="48" />
<div style="float: right;">
<div class="spell1"><img ng-src="http://api.aof.gg/static/spell/{{player.d.image}}" width="23" height="23"></div>
<div class="spell2"><img ng-src="http://api.aof.gg/static/spell/{{player.f.image}}" width="23" height="23"></div>
<div class="spell1"><img ng-src="http://ddragon.leagueoflegends.com/cdn/5.21.1/img/spell/{{player.d.image}}" width="23" height="23"></div>
<div class="spell2"><img ng-src="http://ddragon.leagueoflegends.com/cdn/5.21.1/img/spell/{{player.f.image}}" width="23" height="23"></div>
</div>
<td style="text-align: right;">{{ player.summonerName }}</td>
</tr>
Expand Down
83 changes: 54 additions & 29 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let _ = require("underscore");
let fs = require("fs");
let winston = require("winston");

let ddragonBase = "http://ddragon.leagueoflegends.com/cdn/5.21.1/";
let replay = null;
let mainWindow = null;
let settings = {};
Expand Down Expand Up @@ -101,18 +102,19 @@ function checkForUpdates(callback) {
logger.warn("Could not check for updates, request timed out");
callback();
}, 5000);
let req = request({ url: "http://api.aof.gg/version", json: true }, function(err, response, body) {
let req = request({ url: "https://api.aof.gg/v2/client/version", json: true }, function(err, response, body) {
clearTimeout(timeout);

// Set the new version info if there is one
if (!err && response && response.statusCode == 200) {
// Set the new version info if there is one
if (version.currVersion != body.version) {
version.newVersion = body.version;
version.msg = body.msg;
}
mainWindow.webContents.send("aofUpdate", version);
} else {
logger.warn("Error while retrieving version: " + err + " " + JSON.stringify(response));
}
mainWindow.webContents.send("aofUpdate", version);

callback();
});
Expand All @@ -126,18 +128,35 @@ function getStaticData(callback) {
if (!err) {
logger.info("Reading static data from local cache");
staticData = JSON.parse(data);
staticData.extended = true;
}

logger.info("Retrieving static data from server");
request({ url: "http://api.aof.gg/static", json: true ,timeout: 10000}, function(err, response, body) {
if (!err && response && response.statusCode == 200 && !body.err && body.data) {
staticData = body.data;
staticData.extended = true;
fs.writeFileSync(app.getPath("userCache") + "/static", JSON.stringify(staticData));
} else {
request({ url: "https://api.aof.gg/v2/data/static", json: true, timeout: 10000}, function(err, response, body) {
if (err || !response || response.statusCode != 200) {
logger.warn("Error while retrieving static data: " + err + " " + JSON.stringify(response));
return;
}
staticData.regions = body.regions;
staticData.leagues = body.leagues;
fs.writeFileSync(app.getPath("userCache") + "/static", JSON.stringify(staticData));

logger.info("Getting champion info");
request({ url: ddragonBase + "data/en_US/champion.json", json: true, timeout: 10000 }, function(err, response, body) {
if (!err && response && response.statusCode == 200) {
staticData.champions = body.data;
} else {
logger.warn("Error while retrieving static data: " + err + " " + JSON.stringify(response));
}
});

logger.info("Getting summoner spell info");
request({ url: ddragonBase + "data/en_US/summoner.json", json: true, timeout: 10000 }, function(err, response, body) {
if (!err && response && response.statusCode == 200) {
staticData.summonerSpells = body.data;
} else {
logger.warn("Error while retrieving static data: " + err + " " + JSON.stringify(response));
}
});

callback();
});
Expand All @@ -147,23 +166,29 @@ function getStaticData(callback) {

// Extend the metadata of a replay with additional information
function extendReplayMetadata(meta) {
meta.region = _.find(staticData.regions, function(region) { return region.Id == meta.regionId }).ShortName;
meta.region = _.find(staticData.regions, function(region) { return region.id == meta.regionId }).shortName;

if (staticData.extended) {
for (let i = 0; i < meta.players.length; i++) {
var p = meta.players[i];

let champion = _.find(staticData.champions, function(champion) { return champion.Id == p.championId });
p.champion = { name: champion.Name, image: champion.Image };

let league = _.find(staticData.leagues, function(league) { return league.Id == p.leagueId });
p.league = { name: league.Name, image: league.Image };

let d = _.find(staticData.summonerSpells, function(spell) { return spell.Id == p.dId });
p.d = { name: d.Name, image: d.Image };

let f = _.find(staticData.summonerSpells, function(spell) { return spell.Id == p.fId });
p.f = { name: f.Name, image: f.Image };
for (let i = 0; i < meta.players.length; i++) {
var p = meta.players[i];

if (staticData.champions) {
let champion = _.find(staticData.champions, function(champion) { return champion.key == p.championId });
p.champion = { name: champion.name, image: champion.image.full };
}

if (staticData.leagues) {
let league = _.find(staticData.leagues, function(league) { return league.id == p.leagueId });
p.league = { name: league.name, image: league.name.toLowerCase() + ".png" };
}

if (staticData.summonerSpells) {
let d = _.find(staticData.summonerSpells, function(spell) { return spell.key == p.dId });
p.d = { name: d.name, image: d.image.full };
}

if (staticData.summonerSpells) {
let f = _.find(staticData.summonerSpells, function(spell) { return spell.key == p.fId });
p.f = { name: f.name, image: f.image.full };
}
}
return meta;
Expand Down Expand Up @@ -279,7 +304,7 @@ ipc.on("sendLogs", function(event, data) {
};

request({
url: "http://api.aof.gg/client/reports",
url: "https://api.aof.gg/v2/client/reports",
method: "POST",
json: true,
headers: {
Expand All @@ -288,7 +313,7 @@ ipc.on("sendLogs", function(event, data) {
body: report
}, function(err, httpResponse, body){
if (httpResponse.statusCode != 200) {
logger.error("Sending report failed.", {err: err, httpResponse: httpResponse, body: body});
logger.error("Sending report failed.", {err: err, httpResponse: httpResponse.statusCode, body: body});
event.sender.send("error", {
title: "Error sending report",
content: "Could not send error report.<br>Please report your issue to [email protected] and provide the following file: " + logFile });
Expand All @@ -307,7 +332,7 @@ app.on("ready", function() {
});

// Open the DevTools.
// mainWindow.openDevTools();
//mainWindow.openDevTools();

// Load the index.html of the app.
mainWindow.loadUrl("file://" + __dirname + "/index.html");
Expand Down
27 changes: 17 additions & 10 deletions src/modules/lol-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ let fs = require("fs");
let winreg = require("winreg");
let spawn = require("child_process").spawn;
let _ = require("underscore");
let domain = require("domain");
let logger;

let leaguePath = false;
Expand Down Expand Up @@ -58,9 +59,8 @@ function checkVersion(callback) {

// Try and find the league of legends client
function checkPath(callback) {

var errorCallback = function(err) {
logger.warn("Error checking path " + logPath + ": " + err);
logger.warn("Error checking path " + leaguePath + ": " + err);
leaguePath = false;
leagueVersion = "";
callback(false);
Expand All @@ -71,7 +71,7 @@ function checkPath(callback) {
errorCallback(err);
} else {
files.sort(function(a, b) {
return fs.statSync(logPath + b).mtime.getTime() - fs.statSync(logPath + a).mtime.getTime();
return fs.statSync(leaguePath + b).mtime.getTime() - fs.statSync(leaguePath + a).mtime.getTime();
});
fullPath = leaguePath + "/solutions/lol_game_client_sln/releases/" + files[0] + "/deploy/";

Expand All @@ -95,13 +95,20 @@ function findRegKey(hive, key, callback) {
hive: hive,
key: key
});
regKey.get("LocalRootFolder", function(err, item) {
if (err) {
logger.warn("Couldn't find registry key " + hive + key);
callback()
} else {
callback(item.value);
}

let d = domain.create();
d.on("error", function(err) {
logger.warn("Code: %s, errno: %s, syscall: %s, path: %s, spawnargs: %s", err.code, err.errno, err.syscall, err.path, JSON.stringify(err.spawnargs));
});
d.run(function() {
regKey.get("LocalRootFolder", function(err, item) {
if (err) {
logger.warn("Couldn't find registry key " + hive + key);
callback();
} else {
callback(item.value);
}
});
});
};

Expand Down
6 changes: 3 additions & 3 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "aof-replay-client",
"version": "0.1.4",
"version": "0.1.5",
"main": "./index.js",
"scripts": {
"start": "./node_modules/.bin/electron .",
"postinstall" : "./node_modules/bower/bin/bower install"
"start": "cd .. && npm start",
"postinstall" : "./node_modules/.bin/bower install"
},
"author": "Analyze Or Feed",
"license": "MIT",
Expand Down

0 comments on commit 85a8f36

Please sign in to comment.