diff --git a/src/index.ts b/src/index.ts index 19b8834..c7585e4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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'; @@ -17,6 +17,8 @@ import * as ScriptService from './services/ScriptService'; app.whenReady().then(start); +let marketWin; + function createOverlay() { const win = new BrowserWindow({ @@ -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) { @@ -95,7 +138,6 @@ async function start() { Watcher.startLoopCheck(); let onTickExecutor;; - Watcher.onChange = (isRunning: boolean) => { console.log('CHANGED', isRunning) diff --git a/src/ui/js/internal/app_loader.js b/src/ui/js/internal/app_loader.js index b8429f5..e1ebd60 100644 --- a/src/ui/js/internal/app_loader.js +++ b/src/ui/js/internal/app_loader.js @@ -26,6 +26,7 @@ const state = Vue.reactive({ }); const app = Vue.createApp({ + mounted, data() { return state }, methods: { forwardEvents, @@ -33,7 +34,8 @@ const app = Vue.createApp({ updateSettings, reloadScripts, closeWindow, - openDonateLink + openDonateLink, + openMarket } }); @@ -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'; @@ -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); +} diff --git a/src/ui/view/index.html b/src/ui/view/index.html index 9872f5f..d0ad9f8 100644 --- a/src/ui/view/index.html +++ b/src/ui/view/index.html @@ -50,6 +50,7 @@
+
updated
{{updated}}
@@ -62,6 +63,21 @@
+ + + +