From cb4b1af8cf4c120409f8983bc92a0e0e0d7044ce Mon Sep 17 00:00:00 2001 From: Eran Date: Sun, 28 Jul 2019 16:13:00 +0300 Subject: [PATCH] Add files via upload added lol sample app --- lol-events-sample-app/icon.png | Bin 0 -> 2001 bytes lol-events-sample-app/icon_gray.png | Bin 0 -> 2111 bytes lol-events-sample-app/index.html | 11 +++ lol-events-sample-app/main.js | 123 ++++++++++++++++++++++++++++ lol-events-sample-app/manifest.json | 48 +++++++++++ 5 files changed, 182 insertions(+) create mode 100644 lol-events-sample-app/icon.png create mode 100644 lol-events-sample-app/icon_gray.png create mode 100644 lol-events-sample-app/index.html create mode 100644 lol-events-sample-app/main.js create mode 100644 lol-events-sample-app/manifest.json diff --git a/lol-events-sample-app/icon.png b/lol-events-sample-app/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..4edf7097995cf0b262e93700fae56332148b1a60 GIT binary patch literal 2001 zcmaJ?Yg7|w8jgw^OIN|7q>6_f5)c|-a=(&*F$oeS97qBr1tF0P5JNIC8BBsbuGqzj zP;R=4fE2B+LR*DGHFzm8f{L^U3N7t=p{t8Z*)A#y2=THLD|UY@`<7HHD(AS(88M_Kw{A3 zKr%?9wQuQ$co@urFr7k)D5de-EZ6{QJQ&bsFrjP=h8JTqX|nVX0&IeEbVfe@!MP4R zpwsg4sSGJuY7#=Zy0`)}Brix%WEJSMI9hy6G{CcQQ2_&lXaJib&uHP=`1n`4Ty*U@ zCgFis5Jb<%|CW?eng|GCGXyX|W@HwHMg>?Lkiy_l+4Km2N~SPLWIBn$iKNiD=tCz1 zuLmBDX4YnNWun;EvCthKpNk+SE{SBdT0tufgv~i9m%|~EsU#{j5=BH>>_$Xmi!@pY zvkD@}l4aJJ5FKm;Jc^o4a6ZDvqnZA81%v60tkLqiOlZMKHjRly0m+^#%>t#;{|_}7 z-k>dr4EjCa|0!%y*i8^g23g>Ia~9gTY=S40i7PZi8U!{gU^s8Kiix=}0$Xxn6Cf0N zs>T2rKv=5IsD-VT_g=B2Qm({kK{UoJNFw6nQ5{gH({dRM7L7)UCDYN$Qz&94M@SK} znQSqI%wkd5EY>Vn1ZU+NAR{u%)&9<<%*pi_!eBxpiy*UZE2NDz!v^5h#ksmUa}kT@ z)O*d<&Y6oic1|t{O@`!Y?|-#>_6YTmXZgmw=;n?6AtUN}GivVSkFi%U7_S(KNT9G? z|6Y|AmY4Ky1`XVs7D@}D`BYW)?CrZPmL(iXwDs-dRhYfsTVH+LGJa&=9a|+XKkz0# z#K*6y-@c{TTt|4!JX!h8$nN*=XP)D`f8}pGbz!i+q^={n_21J!o{7nSi_uZ)T){B}o7k}nQ(d+RP@Gi{G+=XW}V`fidBAoey1xO4mK|;D%>Q?SXEN*)U13oF~JzR zapRIor3xzP>FvFOj;HtT#rDG0tNWU8_sh!49u5rbT{G0zr&gw?r3HN5(Sc(x!Vwa# zw|Sj?64?CJS0NQxGLyM0NK7rNJXTjQcT1o5F(uzi0i^ivE?BaG&Z*OnSi|+33MV*ITuC?Gvpl4Z$ zujC)0gNq{j$Ht7qkEg#swnVW`uh)k~Mb*}BxJ0}=e}i)9z<~pMerB;)-}U!b{q0oG z-L+j^T{qL0$-hxA>2Xg^rYv3Ko|&OP?;jXQf?*QtK-t}E3%Sanj8my+Gcqz_LqkJr zwhM*AtD9O(mS3tjg5=`68&gw5HWZo@}>?duU{0V!1RvzF~UWu03-jNu^q`*n zj+w(5jAUXhl}cUqb8>2`rG&65<+C45?M0pVN;?_O%TwG+Q!3Togs!GRWy(cj{HLF@ zgc zqocuFgdfNMu7_b(zoA+5MK*cS>cl!(gS&#<;p!zHeYrU;GxPXNLU6QxKNc+3duRu8Vq?_xg^no+(mZF8V>lx-j);;j`sxOq)hf`uNJq Q2G37cB2EyUT&v#sABUeNqW}N^ literal 0 HcmV?d00001 diff --git a/lol-events-sample-app/icon_gray.png b/lol-events-sample-app/icon_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..d677881bcd02e7d4854b119e727506ca2bf1086a GIT binary patch literal 2111 z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}dX#Mj?7#V$fB#m2O? z&+IKID>J@&^{TeRR@3v8*IRB>mKlZIaD1~@#B9f#n_+`EXXi`j7&)(BA9r$d8_pZ; z?+<3jX3o#;u&^19KOKe^mVp`97S7*8ySSj{=H}ug5>81~lW~XG?K;o=*I6~cD%YT_ z$YL_oG&(D`{Ym$3o2|vY#J-1peIZ{pk}@a1rd2fI1L-r*&O^x`zS?}|Ug;e(hD?S# z78V-X_RB9<9$SDQh^VTn(pq?>y=W=k)7{lL{zqzfeO+D0QTR?`Z!9V)8QyKhotn64 zZ!+s$8w*17UmEFkb#>X2`I0CH`sTEXALBDL65;ey+d@%F%2GrbCu_kst+0E`;G37r zSe|9kN3nnChvazsFQdXEIqfYBRozc6exEolR!x~s^fe~qwG8i-sW(|K_owS2o|Zir Us`xF)Uw5T*m_dwcTHL4q0lVT}ZU6uP literal 0 HcmV?d00001 diff --git a/lol-events-sample-app/index.html b/lol-events-sample-app/index.html new file mode 100644 index 0000000..332666b --- /dev/null +++ b/lol-events-sample-app/index.html @@ -0,0 +1,11 @@ + + + Overwolf LoL Sample App + + + + + +
+ + \ No newline at end of file diff --git a/lol-events-sample-app/main.js b/lol-events-sample-app/main.js new file mode 100644 index 0000000..a60b660 --- /dev/null +++ b/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)); +}); diff --git a/lol-events-sample-app/manifest.json b/lol-events-sample-app/manifest.json new file mode 100644 index 0000000..d9f562f --- /dev/null +++ b/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 + }] +} +}