Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
added lol sample app
  • Loading branch information
eransharv committed Jul 28, 2019
1 parent 58699d2 commit cb4b1af
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 0 deletions.
Binary file added lol-events-sample-app/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lol-events-sample-app/icon_gray.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions lol-events-sample-app/index.html
@@ -0,0 +1,11 @@
<html>
<head>
<title>Overwolf LoL Sample App</title>
</head>
<body style="background-color:rgba(255,255,255,0.0); overflow: hidden; visibility: hidden">

<script src="main.js"></script>

<div id="dvDiff" style="width:100%; height:100%"></div>
</body>
</html>
123 changes: 123 additions & 0 deletions lol-events-sample-app/main.js
@@ -0,0 +1,123 @@
// this a subset of the features that LoL events provides - however,
// when writing an app that consumes events - it is best if you request
// only those features that you want to handle.
//
// NOTE: in the future we'll have a wildcard option to allow retreiving all
// features
var g_interestedInFeatures = [
'summoner_info',
'gameMode',
'teams',
'matchState',
'kill',
'death',
'respawn',
'assist',
'minions',
'level',
'abilities',
'announcer',
'counters',
'match_info'
// 'gold'
];

function registerEvents() {
// general events errors
overwolf.games.events.onError.addListener(function(info) {
console.log("Error: " + JSON.stringify(info));
});

// "static" data changed (total kills, username, steam-id)
// This will also be triggered the first time we register
// for events and will contain all the current information
overwolf.games.events.onInfoUpdates2.addListener(function(info) {
console.log("Info UPDATE: " + JSON.stringify(info));
});

// an event triggerd
overwolf.games.events.onNewEvents.addListener(function(info) {
console.log("EVENT FIRED: " + JSON.stringify(info));
});
}

function gameLaunched(gameInfoResult) {
if (!gameInfoResult) {
return false;
}

if (!gameInfoResult.gameInfo) {
return false;
}

if (!gameInfoResult.runningChanged && !gameInfoResult.gameChanged) {
return false;
}

if (!gameInfoResult.gameInfo.isRunning) {
return false;
}

// NOTE: we divide by 10 to get the game class id without it's sequence number
if (Math.floor(gameInfoResult.gameInfo.id/10) != 5426) {
return false;
}

console.log("LoL Launched");
return true;

}

function gameRunning(gameInfo) {

if (!gameInfo) {
return false;
}

if (!gameInfo.isRunning) {
return false;
}

// NOTE: we divide by 10 to get the game class id without it's sequence number
if (Math.floor(gameInfo.id/10) != 5426) {
return false;
}

console.log("LoL running");
return true;

}


function setFeatures() {
overwolf.games.events.setRequiredFeatures(g_interestedInFeatures, function(info) {
if (info.status == "error")
{
//console.log("Could not set required features: " + info.reason);
//console.log("Trying in 2 seconds");
window.setTimeout(setFeatures, 2000);
return;
}

console.log("Set required features:");
console.log(JSON.stringify(info));
});
}


// Start here
overwolf.games.onGameInfoUpdated.addListener(function (res) {
if (gameLaunched(res)) {
registerEvents();
setTimeout(setFeatures, 1000);
}
console.log("onGameInfoUpdated: " + JSON.stringify(res));
});

overwolf.games.getRunningGameInfo(function (res) {
if (gameRunning(res)) {
registerEvents();
setTimeout(setFeatures, 1000);
}
console.log("getRunningGameInfo: " + JSON.stringify(res));
});
48 changes: 48 additions & 0 deletions lol-events-sample-app/manifest.json
@@ -0,0 +1,48 @@
{
"manifest_version": "1",
"type": "WebApp",
"meta": {
"name": "LoL Game Events Consumer Sample",
"version": "0.0.1",
"minimum-overwolf-version": "0.92.300.0",
"author": "Overwolf",
"icon": "icon.png",
"icon_gray": "icon_gray.png",
"description": "Game Events Consumer Sample"
},
"data": {
"start_window": "index",
"game_targeting": {
"type": "dedicated",
"game_ids": [5426]
},
"windows": {
"index": {
"file": "index.html",
"transparent": true,
"clickthrough": true,
"resizable": false,
"show_in_taskbar": true,
"size": {
"width": 1150,
"height": 535
},
"start_position": {
"Top": 10,
"Left": 10
}
}
},
"game_events": [5426],
"launch_events": [
{
"event": "GameLaunch",
"event_data": {
"game_ids": [
5426
]
},
"start_minimized": false
}]
}
}

0 comments on commit cb4b1af

Please sign in to comment.