Skip to content

Commit

Permalink
fix game detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Emily committed Sep 3, 2022
1 parent 06898a4 commit 7e61505
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 10 deletions.
46 changes: 44 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ console.log('ELECTRON', process.versions.electron, 'NODE', process.versions.node
import * as ElectronRemote from '@electron/remote/main';
ElectronRemote.initialize();

import { app, BrowserWindow, ipcMain, screen } from 'electron';
import { app, BrowserWindow, ipcMain, protocol, screen } from 'electron';

import League from './components/League';
import Watcher from './services/LeagueWatcherService';
Expand All @@ -17,6 +17,8 @@ import * as ScriptService from './services/ScriptService';

app.whenReady().then(start);

let marketWin;

function createOverlay() {

const win = new BrowserWindow({
Expand Down Expand Up @@ -47,10 +49,51 @@ function createOverlay() {
return win;
}

function createMarket() {

const win = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});

win.setAlwaysOnTop(true, 'screen-saver');
win.setMenu(null);
win.loadURL('https://www.ayayaleague.com/market');

marketWin = win;
return win;
}


async function start() {


protocol.registerFileProtocol('atom', (request, callback) => {
const url = request.url.substr(7)
callback({ path: path.normalize(`${__dirname}/${url}`) })
})

// protocol.registerHttpProtocol('ayaya', (req, callback) => {
// console.log(req);
// callback({ url: 'google.it' });
// });


const win = createOverlay();

ipcMain.on('openMarket', (e, args) => {
if (!marketWin) createMarket();
});

ipcMain.on('loaded', (e, args) => {
const isRunning = Watcher.check();
win.webContents.send('inGame', isRunning);
});


ipcMain.on('drawingContext', (e, args) => {
if (!Watcher.isRunning) {
Expand Down Expand Up @@ -95,7 +138,6 @@ async function start() {
Watcher.startLoopCheck();

let onTickExecutor;;

Watcher.onChange = (isRunning: boolean) => {
console.log('CHANGED', isRunning)

Expand Down
24 changes: 16 additions & 8 deletions src/ui/js/internal/app_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ const state = Vue.reactive({
});

const app = Vue.createApp({
mounted,
data() { return state },
methods: {
forwardEvents,
toggleSettings,
updateSettings,
reloadScripts,
closeWindow,
openDonateLink
openDonateLink,
openMarket
}
});

Expand Down Expand Up @@ -62,6 +64,9 @@ function toggleSettings() {
settingsWindow.classList.toggle('anim_enter');
}

function openMarket() {
ipcRenderer.send('openMarket');
}

const appElement = document.getElementById('app');
appElement.style.visibility = 'hidden';
Expand Down Expand Up @@ -97,13 +102,16 @@ ipcRenderer.on('inGame', (e, value) => {

app.use(ElementPlus);
app.mount('#app');

setTimeout(() => {
appElement.style.visibility = 'visible';
const loader = document.getElementsByClassName('loader')[0];
loader.style.display = 'none';
}, 1000);

ipcRenderer.send('loaded');

function mounted() {
setTimeout(() => {
appElement.style.visibility = 'visible';
const loader = document.getElementsByClassName('loader')[0];
loader.style.display = 'none';
ipcRenderer.send('loaded');
}, 1000);
}



16 changes: 16 additions & 0 deletions src/ui/view/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<div class="content" @mouseover="forwardEvents(false)" @mouseleave="forwardEvents(true)">

<div class="row" style="display: flex; gap: 10px; justify-content: flex-end; font-size: 12px; margin-right: 10px; padding-bottom: 20px">

<div class="version">
<div class="text">updated</div>
<div class="value" v-if="updated" style="background-color: green;">{{updated}}</div>
Expand All @@ -62,6 +63,21 @@
</div>
</div>

<!--
<div class="settings-title"> SCRIPTS </div>
<div class="settings-content">
<div class="setting">
<div class="setting-text"> Script marketplace </div>
<div class="setting-value" style="padding: 6px;">
<el-button @click="openMarket()" type="info" round> Get scripts </el-button>
</div>
</div>
</div>
<div class="settings-desc"></div>
-->



<template v-for="script of scripts">
<template v-for="s of script.settings">

Expand Down

0 comments on commit 7e61505

Please sign in to comment.