Skip to content

Commit

Permalink
add app
Browse files Browse the repository at this point in the history
  • Loading branch information
prevzzy committed May 9, 2022
1 parent cb2b15e commit a504af1
Show file tree
Hide file tree
Showing 60 changed files with 13,381 additions and 0 deletions.
93 changes: 93 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock
.DS_Store

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Webpack
.webpack/

# Electron-Forge
out/

# Other
src/renderer/js/game/offsets.js
combos/
97 changes: 97 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"name": "combo-tracker",
"productName": "Combo Tracker",
"version": "1.0.0",
"description": "THUGPRO Combo Tracker",
"main": "./.webpack/main",
"keywords": [],
"author": {
"name": "prevzzy"
},
"license": "MIT",
"config": {
"forge": {
"packagerConfig": {
"asar": true,
"icon": "./src/static/combo-tracker-icon.ico"
},
"makers": [
{
"name": "@electron-forge/maker-zip"
}
],
"plugins": [
[
"@electron-forge/plugin-webpack",
{
"mainConfig": "./webpack.main.config.js",
"renderer": {
"config": "./webpack.renderer.config.js",
"entryPoints": [
{
"html": "./src/renderer/index.html",
"js": "./src/renderer.js",
"name": "main_window",
"nodeIntegration": true
},
{
"html": "./src/renderer/toast.html",
"js": "./src/renderer/js/toasts/index.js",
"name": "toast_window",
"nodeIntegration": true
}
]
}
}
]
]
}
},
"watch": {
"restart-electron-app": {
"patterns": [
"src"
],
"extensions": "js,css,html"
}
},
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"devDependencies": {
"@electron-forge/cli": "^6.0.0-beta.63",
"@electron-forge/maker-zip": "^6.0.0-beta.63",
"@electron-forge/plugin-webpack": "^6.0.0-beta.63",
"@vercel/webpack-asset-relocator-loader": "^1.7.1",
"copy-webpack-plugin": "^10.2.4",
"css-loader": "^6.7.1",
"electron": "4.0.4",
"native-ext-loader": "^2.3.0",
"style-loader": "^3.3.1"
},
"dependencies": {
"base-64": "^1.0.0",
"binary-search": "^1.3.6",
"bootstrap": "^4.5.0",
"bootstrap-select": "^1.13.18",
"bootswatch": "4.5.0",
"chart.js": "2.9.4",
"dotenv-webpack": "^7.1.0",
"electron-settings": "^4.0.2",
"electron-squirrel-startup": "^1.0.0",
"eslint": "^7.3.0",
"file-loader": "^6.2.0",
"jquery": "^3.5.1",
"material-icons": "^1.10.8",
"memoryjs": "^3.4.0",
"node-gyp-build": "^4.3.0",
"popper.js": "^1.16.1",
"rimraf": "^3.0.2",
"source-map-support": "^0.5.16",
"stream-browserify": "^3.0.0"
}
}
62 changes: 62 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { app, globalShortcut } from 'electron'
import { initIpcEvents } from './main/events/listeners'
import { createAppWindows } from './main/browserWindows/browserWindows'
import { initSettings } from './main/settings/settings'

let mainWindow
let toastWindow

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
app.quit();
}

app.allowRendererProcessReuse = false
const gotTheLock = app.requestSingleInstanceLock()

if (!gotTheLock) {
app.quit()
} else {
app.on('second-instance', (event, commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore()
}
mainWindow.focus()
}
})

// Create mainWindow, load the rest of the app, etc...
app.whenReady().then(async () => {
({
mainWindow,
toastWindow,
} = createAppWindows())

await initSettings(mainWindow, toastWindow)
initIpcEvents(mainWindow, toastWindow)

mainWindow.on('close', () => {
toastWindow.close()
})
})
}

app.on('will-quit', () => {
globalShortcut.unregisterAll()
})

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
37 changes: 37 additions & 0 deletions src/main/browserWindows/browserWindows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

import url from 'url'
import electron from 'electron'
import { BrowserWindow } from 'electron'
import { mainWindowConfig, toastWindowConfig } from './windowsConfig'

function createBrowserWindow(config) {
// needed for relative window position
const display = electron.screen.getPrimaryDisplay()

let win = new BrowserWindow(config.getBrowserWindowConfig(display))
win.loadURL(url.format(config.url))

if (config.showOnAppLaunch) {
win.once('ready-to-show', () => {
win.show()
})
}

if (config.preventMultiple) {
win.webContents.on('new-window', (event, url) => {
event.preventDefault()
})
}

return win
}

export function createAppWindows() {
const mainWindow = createBrowserWindow(mainWindowConfig)
const toastWindow = createBrowserWindow(toastWindowConfig)

return {
mainWindow,
toastWindow,
}
}
46 changes: 46 additions & 0 deletions src/main/browserWindows/windowsConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
export const mainWindowConfig = {
getBrowserWindowConfig(display) {
return {
width: 1280,
height: 768,
minWidth: 600,
minHeight: 500,
frame: false,
webPreferences: {
nodeIntegration: true,
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY
},
}
},
url: {
pathname: MAIN_WINDOW_WEBPACK_ENTRY,
},
showOnAppLaunch: true,
preventMultiple: true,
}

export const toastWindowConfig = {
getBrowserWindowConfig(display) {
return {
height: 700,
width: 300,
x: display.bounds.width - 300,
y: 150,
frame: false,
alwaysOnTop: true,
resizable: false,
movable: false,
show: false,
skipTaskbar: true,
transparent: true,
webPreferences: {
nodeIntegration: true,
preload: TOAST_WINDOW_PRELOAD_WEBPACK_ENTRY,
},
}
},
url: {
pathname: TOAST_WINDOW_WEBPACK_ENTRY,
},
preventMultiple: true,
}
Loading

0 comments on commit a504af1

Please sign in to comment.