Skip to content

Commit

Permalink
DRY it out, readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lacymorrow committed Oct 9, 2019
1 parent 37b203c commit 7eaf895
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 44 deletions.
46 changes: 22 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const fs = require('fs')

const path = require('path')
const {app, ipcMain, globalShortcut, BrowserWindow, Menu} = require('electron')
// Const {autoUpdater} = require('electron-updater')
const {autoUpdater} = require('electron-updater')
const {is} = require('electron-util')
const unhandled = require('electron-unhandled')
const debug = require('electron-debug')
// Const contextMenu = require('electron-context-menu')

const {debounce} = require('./src/util')
const config = require('./src/config')
const menu = require('./src/menu')

Expand All @@ -28,14 +28,14 @@ app.setAppUserModelId('com.lacymorrow.CrossOver')

// Uncomment this before publishing your first version.
// It's commented out as it throws an error if there are no published versions.
// if (!is.development) {
// const FOUR_HOURS = 1000 * 60 * 60 * 4;
// setInterval(() => {
// autoUpdater.checkForUpdates();
// }, FOUR_HOURS);
//
// autoUpdater.checkForUpdates();
// }
if (!is.development) {
const FOUR_HOURS = 1000 * 60 * 60 * 4;
setInterval(() => {
autoUpdater.checkForUpdates();
}, FOUR_HOURS);

autoUpdater.checkForUpdates();
}

// Prevent window from being garbage collected
let mainWindow
Expand All @@ -49,17 +49,8 @@ const __static =
// Crosshair images
const crosshairsPath = path.join(__static, 'crosshairs')

const debounce = (func, delay) => {
let debounceTimer
return function(...args) {
const context = this
clearTimeout(debounceTimer)
debounceTimer = setTimeout(() => func.apply(context, args), delay)
}
}

// Title Case and spacing
function prettify(str) {
// Title Case and spacing
str = str
.split('-')
.map(w => w[0].toUpperCase() + w.substr(1).toLowerCase())
Expand All @@ -82,7 +73,7 @@ const setupCrosshairInput = () => {
`document.querySelector("#crosshairs").options.length = 0;`
)
mainWindow.webContents.executeJavaScript(
`document.querySelector("#crosshairs").options[0] = new Option('---', 'none');`
`document.querySelector("#crosshairs").options[0] = new Option('-----', 'none');`
)

for (let i = 0, filepath; (filepath = dir[i]); i++) {
Expand Down Expand Up @@ -201,6 +192,7 @@ const lockWindow = lock => {
console.log(`Locked: ${lock}`)

config.set('windowLocked', lock)
mainWindow.webContents.executeJavaScript(`coHidePickr()`)
mainWindow.setClosable(!lock)
mainWindow.setIgnoreMouseEvents(lock)

Expand All @@ -209,13 +201,11 @@ const lockWindow = lock => {
mainWindow.webContents.executeJavaScript(
'document.body.classList.remove("draggable")'
)
setDockVisible(false)
} else {
// Unlock
mainWindow.webContents.executeJavaScript(
'document.body.classList.add("draggable")'
)
setDockVisible(true)
mainWindow.show()
}
}
Expand Down Expand Up @@ -273,6 +263,7 @@ const setupApp = async () => {

const createMainWindow = async () => {
const win = new BrowserWindow({
type: 'toolbar',
alwaysOnTop: true,
frame: false,
closable: true,
Expand Down Expand Up @@ -348,12 +339,19 @@ app.on('ready', () => {
})

/* Global KeyListner */
// CMD/CTRL + SHIFT +

// Toggle CrossOver
globalShortcut.register('Control+Shift+X', () => {
const locked = config.get('windowLocked')
lockWindow(!locked)
})

// Hide CrossOver
globalShortcut.register('Control+Shift+C', () => {

})

// Single pixel movement
globalShortcut.register('Control+Shift+Up', () => {
moveWindow('up')
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "crossover",
"productName": "CrossOver",
"version": "0.2.0",
"description": "A configurable Crosshair Overlay for any platform.",
"description": "A configurable Crosshair Overlay for any screen.",
"license": "MIT",
"repository": "lacymorrow/crossover",
"engines": {
Expand Down
42 changes: 29 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,36 @@

> A CrossHair Overlay for any platform.
See [awesome-electron](https://github.com/sindresorhus/awesome-electron) for more useful Electron resources.
CrossOver allows you to place a customizable crosshair overlay above any application window.
Improve your aim and gain a competitive advantage with a permanant colored crosshair to mark center screen.

<!-- See [Caprine](https://github.com/sindresorhus/caprine) for a production app based on this boilerplate.
Other crosshair programs offer a single style or color option, and often don't allow you to reposition them. CrossOver is a small, unintrusive crosshair overlay which has plenty of configuration options to assist with aiming and vision of your crosshair. CrossOver offers a huge improvement to many games' default crosshairs for those with colorblindness or contrast issues.

### Features

## Features
- Choose from tons of true-to-life sights
- Cross-platform: Windows, MacOS, and Linux support
- Support for multiple monitors
- Choose between center **Dot** or **Crosshair**
- Customize crosshair size, color, and opacity
- Persistant settings remembers your choices automatically

- [`electron-builder`](https://www.electron.build) fully set up to create cross-platform builds
- [Builds the app on Travis](https://www.electron.build/multi-platform-build.html)
- [Silent auto-updates](https://www.electron.build/auto-update.html)
- App menu that adheres to the system user interface guidelines
- [Config handling](https://github.com/sindresorhus/electron-store)
- [Context menu](https://github.com/sindresorhus/electron-context-menu)
- [User-friendly handling of unhandled errors](https://github.com/sindresorhus/electron-unhandled)
- Easily publish new versions to GitHub Releases
- And much more!
-->

### Usage

> ❌ marks the spot...
Click and drag the crosshair to anywhere on any screen.

`Control` + `Shift` + `X` to toggle the crosshair lock.

`Control` + `Shift` + `C` to hide CrossOver.

While CrossOver is focused you can use `Control` + `Shift` + Arrow keys while unlocked to move single pixels.

To quit in Windows, toggle the app unlocked and right-click > `Close`.


### Bugs

Currently CrossOver only works with windowed applications, use `Windowed Fullscreen` mode if your game or application supports it. Tracked in #1.
2 changes: 1 addition & 1 deletion src/index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7eaf895

Please sign in to comment.