Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added lol sample app
- Loading branch information
Showing
5 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}] | ||
} | ||
} |