Skip to content

Commit

Permalink
Add Easter Eggs...
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Nov 24, 2021
1 parent d2f8398 commit b657377
Show file tree
Hide file tree
Showing 9 changed files with 1,387 additions and 104 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Removes an extra debug log to console introduced in the previous release.
Adds a few new Easter Eggs...
7 changes: 7 additions & 0 deletions indexPreload.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ window.addEventListener("DOMContentLoaded", () => {
}))
})

// Set holiday
ipcRenderer.on("set-holiday", (_, holiday) => {
window.dispatchEvent(new CustomEvent("set-holiday", {
detail: holiday
}))
})

// State management
ipcRenderer.on("restore-state", (_, state) => {
window.dispatchEvent(new CustomEvent("restore-state", {
Expand Down
9 changes: 8 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ const { app, BrowserWindow, Menu, MenuItem, shell, dialog, ipcMain, nativeTheme
const WindowStateKeeper = require("./windowState.js")
const { setUpdateNotification } = require("electron-update-notifier")
const jsonfile = require("jsonfile")
const Holidays = require("date-holidays")
const path = require("path")
const fs = require("fs")
const os = require("os")

const repository = "Mechanical-Advantage/AdvantageScope"
const prefsFileName = path.join(app.getPath("userData"), "prefs.json")
const stateFileName = "state-" + app.getVersion().replaceAll(".", '_') + ".json"
const holidays = new Holidays("US")
var iconPath = null
const defaultPrefs = {
address: "10.63.28.2",
Expand Down Expand Up @@ -177,11 +179,16 @@ function createWindow() {
indexWindows.push(window)

// Finish setup
if (process.defaultApp) window.webContents.openDevTools()
// if (process.defaultApp) window.webContents.openDevTools()
window.once("ready-to-show", window.show)
window.webContents.on("dom-ready", () => {
window.send("set-fullscreen", window.isFullScreen())
window.send("set-preferences", jsonfile.readFileSync(prefsFileName))
var holidayToday = holidays.isHoliday(new Date())
console.log(holidayToday)
if (holidayToday) {
window.send("set-holiday", holidayToday[holidayToday.length - 1].name)
}
})
window.on("enter-full-screen", () => window.send("set-fullscreen", true))
window.on("leave-full-screen", () => window.send("set-fullscreen", false))
Expand Down
Loading

0 comments on commit b657377

Please sign in to comment.