-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- bridge. can now play audio - you can once again run multiple bridge. instances - fixed discord rich presence - fixed format_version position of entity template - fixed potential cache error (path === null) - fixed animation_references using cache
- Loading branch information
Showing
15 changed files
with
271 additions
and
149 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
// import DRP from "discord-rich-presence"; | ||
// import APP_VERSION from "../renderer/scripts/constants/app_version"; | ||
import DRP from "discord-rich-presence"; | ||
import APP_VERSION from "../renderer/scripts/constants/app_version"; | ||
|
||
// const client = DRP("554245594332528651"); | ||
// const START_TIME = Date.now(); | ||
const client = DRP("554245594332528651"); | ||
const START_TIME = Date.now(); | ||
|
||
// client.updatePresence({ | ||
// state: process.env.NODE_ENV === "development" ? "Developing new features..." : "Developing add-ons...", | ||
// startTimestamp: START_TIME, | ||
// largeImageKey: "big_icon", | ||
// largeImageText: "bridge. | " + APP_VERSION + (process.env.NODE_ENV === "development" ? "-dev" : ""), | ||
// instance: true, | ||
// }); | ||
client.updatePresence({ | ||
state: process.env.NODE_ENV === "development" ? "Developing new features..." : "Developing add-ons...", | ||
startTimestamp: START_TIME, | ||
largeImageKey: "big_icon", | ||
largeImageText: "bridge. | " + APP_VERSION + (process.env.NODE_ENV === "development" ? "-dev" : ""), | ||
instance: true, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,151 +1,135 @@ | ||
import { app, BrowserWindow, ipcMain, Menu } from "electron"; | ||
import "./communicator.js"; | ||
import "./Discord"; | ||
import { BP_BASE_PATH } from "../shared/paths.js"; | ||
|
||
/** | ||
* Set `__static` path to static files in production | ||
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html | ||
*/ | ||
//Set __static path to static files in production | ||
if (process.env.NODE_ENV !== "development") { | ||
global.__static = require("path").join(__dirname, "/static").replace(/\\/g, "\\\\") | ||
global.__static = require("path").join(__dirname, "/static").replace(/\\/g, "\\\\") | ||
} | ||
|
||
let mainWindow, loadingWindow, windowOptions = { | ||
height: 600, | ||
useContentSize: true, | ||
width: 1000, | ||
frame: false, | ||
minWidth: 900, | ||
minHeight: 600, | ||
show: false, | ||
webPreferences: { | ||
nodeIntegration: true | ||
} | ||
height: 600, | ||
useContentSize: true, | ||
width: 1000, | ||
frame: false, | ||
minWidth: 900, | ||
minHeight: 600, | ||
show: false, | ||
webPreferences: { | ||
nodeIntegration: true | ||
} | ||
}; | ||
const winURL = process.env.NODE_ENV === "development" | ||
? `http://localhost:9080` | ||
: `file://${__dirname}/index.html`; | ||
? `http://localhost:9080` | ||
: `file://${__dirname}/index.html`; | ||
|
||
function createWindow () { | ||
/** | ||
* Initial window options | ||
*/ | ||
mainWindow = new BrowserWindow(windowOptions); | ||
|
||
mainWindow.loadURL(winURL); | ||
|
||
mainWindow.on("closed", () => { | ||
mainWindow = null; | ||
if(loadingWindow) { | ||
loadingWindow.close(); | ||
} | ||
}); | ||
|
||
mainWindow.webContents.on("did-finish-load", () => { | ||
if(loadingWindow) { | ||
mainWindow.setPosition(...loadingWindow.getPosition()); | ||
// mainWindow.toggleDevTools(); | ||
loadingWindow.close(); | ||
mainWindow.show(); | ||
} | ||
}); | ||
|
||
if(process.env.NODE_ENV === "development") mainWindow.setMenu(Menu.buildFromTemplate([ | ||
{ | ||
label: "View", | ||
submenu: [ | ||
{ role: "reload" } | ||
] | ||
} | ||
])); | ||
if(process.env.NODE_ENV !== "development") mainWindow.setMenu(null); | ||
/** | ||
* Initial window options | ||
*/ | ||
mainWindow = new BrowserWindow(windowOptions); | ||
|
||
mainWindow.loadURL(winURL); | ||
|
||
mainWindow.on("closed", () => { | ||
mainWindow = null; | ||
if(loadingWindow) { | ||
loadingWindow.close(); | ||
} | ||
}); | ||
|
||
mainWindow.webContents.on("did-finish-load", () => { | ||
if(loadingWindow) { | ||
mainWindow.setPosition(...loadingWindow.getPosition()); | ||
// mainWindow.toggleDevTools(); | ||
loadingWindow.close(); | ||
mainWindow.show(); | ||
} | ||
}); | ||
|
||
if(process.env.NODE_ENV === "development") mainWindow.setMenu(Menu.buildFromTemplate([ | ||
{ | ||
label: "View", | ||
submenu: [ | ||
{ role: "reload" } | ||
] | ||
} | ||
])); | ||
if(process.env.NODE_ENV !== "development") mainWindow.setMenu(null); | ||
} | ||
|
||
function createSplashScreen() { | ||
loadingWindow = new BrowserWindow({ | ||
height: 300, | ||
useContentSize: true, | ||
width: 300, | ||
frame: false, | ||
resizable: false | ||
}); | ||
|
||
loadingWindow.loadURL(`file://${__static}/loading.html`); | ||
|
||
loadingWindow.on("closed", () => { | ||
loadingWindow = null; | ||
}); | ||
|
||
loadingWindow.webContents.on("did-finish-load", () => { | ||
loadingWindow.show(); | ||
|
||
if (process.platform == 'win32' && process.argv.length >= 2 && process.env.NODE_ENV !== "development") { | ||
openFile(process.argv[1]); | ||
} | ||
}); | ||
loadingWindow = new BrowserWindow({ | ||
height: 300, | ||
useContentSize: true, | ||
width: 300, | ||
frame: false, | ||
resizable: false | ||
}); | ||
|
||
loadingWindow.loadURL(`file://${__static}/loading.html`); | ||
|
||
loadingWindow.on("closed", () => { | ||
loadingWindow = null; | ||
}); | ||
|
||
loadingWindow.webContents.on("did-finish-load", () => { | ||
loadingWindow.show(); | ||
|
||
if(process.platform == 'win32' && process.argv.length >= 2 && process.env.NODE_ENV !== "development") { | ||
openFile(process.argv[1]); | ||
} | ||
}); | ||
} | ||
|
||
function openFile(file) { | ||
mainWindow.webContents.send("openFile", file) | ||
mainWindow.webContents.send("openFile", file) | ||
} | ||
|
||
const gotTheLock = app.requestSingleInstanceLock(); | ||
if (!gotTheLock) { | ||
app.quit(); | ||
if(!gotTheLock) { | ||
if(process.argv.length >= 2) | ||
app.quit(); | ||
} else { | ||
app.on("second-instance", (event, argv, working_directory) => { | ||
// Someone tried to run a second instance, we should focus our window. | ||
if(mainWindow) { | ||
if (mainWindow.isMinimized()) mainWindow.restore(); | ||
mainWindow.focus(); | ||
} | ||
if(loadingWindow) { | ||
if (loadingWindow.isMinimized()) loadingWindow.restore(); | ||
loadingWindow.focus(); | ||
} | ||
|
||
if (process.platform == 'win32' && argv.length >= 2) { | ||
openFile(argv[3]); | ||
} | ||
}); | ||
app.on("second-instance", (event, argv, working_directory) => { | ||
if(mainWindow) { | ||
if (mainWindow.isMinimized()) mainWindow.restore(); | ||
mainWindow.focus(); | ||
} | ||
if(loadingWindow) { | ||
if (loadingWindow.isMinimized()) loadingWindow.restore(); | ||
loadingWindow.focus(); | ||
} | ||
|
||
if(process.platform == 'win32' && argv.length >= 2) { | ||
openFile(argv[3]); | ||
} | ||
}); | ||
} | ||
|
||
// Create myWindow, load the rest of the app, etc... | ||
app.on('ready', () => { | ||
app.on('ready', () => { | ||
createWindow(); | ||
createSplashScreen(); | ||
}); | ||
} | ||
}); | ||
|
||
app.on("window-all-closed", () => { | ||
if (process.platform !== "darwin") { | ||
app.quit(); | ||
} | ||
if (process.platform !== "darwin") { | ||
app.quit(); | ||
} | ||
}); | ||
|
||
app.on("activate", () => { | ||
if (mainWindow === null) { | ||
createWindow(); | ||
} | ||
if (mainWindow === null) { | ||
createWindow(); | ||
} | ||
}); | ||
|
||
ipcMain.on("toggleDevTools", function() { mainWindow.toggleDevTools(); }); | ||
|
||
/** | ||
* Auto Updater | ||
* | ||
* Uncomment the following code below and install `electron-updater` to | ||
* support auto updating. Code Signing with a valid certificate is required. | ||
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-electron-builder.html#auto-updating | ||
*/ | ||
|
||
/* | ||
import { autoUpdater } from "electron-updater" | ||
autoUpdater.on("update-downloaded", () => { | ||
autoUpdater.quitAndInstall() | ||
}) | ||
app.on("ready", () => { | ||
if (process.env.NODE_ENV === "production") autoUpdater.checkForUpdates() | ||
}) | ||
*/ | ||
ipcMain.on("toggleDevTools", () => { mainWindow.toggleDevTools(); }); | ||
ipcMain.on("bridge:setOverlayIcon", (event, project) => { | ||
try { | ||
mainWindow.setOverlayIcon((BP_BASE_PATH + project + "/pack_icon.png").replace(/\//g, "\\"), project); | ||
} catch(e) { | ||
mainWindow.setOverlayIcon(null, ""); | ||
} | ||
}) |
Oops, something went wrong.