Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ads-sample/ingame.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ <h1>Ads Sample App</h1>
<button data-tab="tab-a" class="active">Tab A</button>
<button data-tab="tab-b">Tab B</button>
<button data-tab="tab-c">Tab C</button>
<button data-tab="events">Events</button>
<button data-tab="game-info">Game Info</button>
<button id="openConsole" class="bottom">Open Console</button>
</div>

Expand Down Expand Up @@ -57,6 +59,16 @@ <h2>Tab C</h2>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Quisquam nisi sit reprehenderit, repudiandae repellendus expedita numquam, quam quibusdam dolor reiciendis mollitia consectetur accusamus ad, distinctio perspiciatis cumque voluptates tenetur maxime.</p>
</main>

<main id="events" class="tab-content" hidden>
<h2>Events</h2>
<div id="events-log"></div>
</main>

<main id="game-info" class="tab-content" hidden>
<h2>Game Info</h2>
<div id="info-log"></div>
</main>

<aside class="extra-content">
<h3>Additional Content</h3>
<h6>Ads should not scroll with content</h6>
Expand Down
37 changes: 26 additions & 11 deletions ads-sample/ingame.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,36 @@ let
async function init() {
registerListeners();

overwolf.games.onGameInfoUpdated.addListener(onGameInfoUpdated);
if (typeof overwolf !== 'undefined') {
const manifest = await new Promise(r => overwolf.extensions.current.getManifest(r));
const requiredFeatures = manifest.data.game_events;
overwolf.games.events.setRequiredFeatures(requiredFeatures, console.log);

overwolf.games.events.onNewEvents.addListener(e => {
const log = document.getElementById('events-log');
log.innerHTML = `<li>${JSON.stringify(e)}</li>` + log.innerHTML;
});

overwolf.games.events.onInfoUpdates.addListener(e => {
const log = document.getElementById('info-log');
log.innerHTML = `<li>${JSON.stringify(e)}</li>` + log.innerHTML;
});

document.getElementById('openConsole').addEventListener('click', () => {
const backgroundController = overwolf.windows.getMainWindow();
backgroundController.openConsole(kWindowName);
});

overwolf.games.onGameInfoUpdated.addListener(onGameInfoUpdated);

overwolf.windows.onStateChanged.addListener(onWindowStateChanged);
overwolf.windows.onStateChanged.addListener(onWindowStateChanged);

gameInFocus = await getGameInFocus();
gameInFocus = await getGameInFocus();

windowIsOpen = await getWindowIsOpen();
windowIsOpen = await getWindowIsOpen();

updateAd();
updateAd();
}
}

function loadAdLib() {
Expand Down Expand Up @@ -172,12 +193,6 @@ function setTab(tab) {
}

function registerListeners() {
document.getElementById('openConsole').addEventListener('click', () => {
const backgroundController = overwolf.windows.getMainWindow();

backgroundController.openConsole(kWindowName);
});

document.querySelectorAll('[data-tab]').forEach(el => {
el.addEventListener('click', () => {
setTab(el.dataset.tab);
Expand Down
12 changes: 12 additions & 0 deletions ads-sample/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"window_icon": "icons/IconMouseOver.png",
"description": ""
},
"permissions": [
"Launch",
"GameInfo"
],
"data": {
"start_window": "background",
"protocol_override_domains": {
Expand All @@ -20,6 +24,14 @@
"game_targeting": {
"type": "all"
},
"game_events": [
"kill",
"death",
"assist",
"headshot",
"round_start",
"match_start"
],
"windows": {
"background": {
"file": "background.html",
Expand Down
62 changes: 32 additions & 30 deletions ads-sample/window-controls.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
document.querySelector('.app-header').addEventListener('mousedown', () => {
overwolf.windows.getCurrentWindow(result => {
if (result.success && result.window && result.window.id) {
overwolf.windows.dragMove(result.window.id, null);
}
if (typeof overwolf !== 'undefined') {
document.querySelector('.app-header').addEventListener('mousedown', () => {
overwolf.windows.getCurrentWindow(result => {
if (result.success && result.window && result.window.id) {
overwolf.windows.dragMove(result.window.id, null);
}
});
});
});

document.querySelector('.window-control').addEventListener('mousedown', e => {
e.stopPropagation();
});
document.querySelector('.window-control').addEventListener('mousedown', e => {
e.stopPropagation();
});

document.querySelector('.window-control.maximize')?.addEventListener('click', () => {
overwolf.windows.getCurrentWindow(result => {
if (result.success && result.window && result.window.id) {
if (result.window.stateEx === 'maximized') {
overwolf.windows.restore(result.window.id, null);
} else {
overwolf.windows.maximize(result.window.id, null);
document.querySelector('.window-control.maximize')?.addEventListener('click', () => {
overwolf.windows.getCurrentWindow(result => {
if (result.success && result.window && result.window.id) {
if (result.window.stateEx === 'maximized') {
overwolf.windows.restore(result.window.id, null);
} else {
overwolf.windows.maximize(result.window.id, null);
}
}
}
});
});
});

document.querySelector('.window-control.minimize').addEventListener('click', () => {
overwolf.windows.getCurrentWindow(result => {
if (result.success && result.window && result.window.id) {
overwolf.windows.minimize(result.window.id, null);
}
document.querySelector('.window-control.minimize').addEventListener('click', () => {
overwolf.windows.getCurrentWindow(result => {
if (result.success && result.window && result.window.id) {
overwolf.windows.minimize(result.window.id, null);
}
});
});
});

document.querySelector('.window-control.close').addEventListener('click', () => {
overwolf.windows.obtainDeclaredWindow('background', result => {
if (result.success && result.window && result.window.id) {
overwolf.windows.close(result.window.id, null);
}
document.querySelector('.window-control.close').addEventListener('click', () => {
overwolf.windows.obtainDeclaredWindow('background', result => {
if (result.success && result.window && result.window.id) {
overwolf.windows.close(result.window.id, null);
}
});
});
});
}
Empty file added server.log
Empty file.