Skip to content

Commit

Permalink
update!
Browse files Browse the repository at this point in the history
- 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
solvedDev committed May 19, 2019
1 parent b8d5be6 commit 4984f6b
Show file tree
Hide file tree
Showing 15 changed files with 271 additions and 149 deletions.
39 changes: 39 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@
"@mdi/font": "^3.3.92",
"clean-css": "^4.2.1",
"comment-json": "^1.1.3",
"dataurl": "^0.1.0",
"deepmerge": "^3.0.0",
"dir-to-json": "0.0.3",
"dirtree2json": "^1.0.0",
"discord-rich-presence": "0.0.8",
"highlightjs": "^9.12.0",
"js-yaml": "^3.13.1",
"mime": "^2.4.2",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>bridge</title>
<title>bridge.</title>
<% if (htmlWebpackPlugin.options.nodeModules) { %>
<!-- Add `node_modules/` to global paths so `require` works properly in development -->
<script>
Expand Down
22 changes: 11 additions & 11 deletions src/main/Discord.js
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,
});
222 changes: 103 additions & 119 deletions src/main/index.js
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, "");
}
})
Loading

0 comments on commit 4984f6b

Please sign in to comment.