mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Add auto-launch and bunch of other things
This commit is contained in:
parent
6663b6de5f
commit
5893f5bea9
8 changed files with 101 additions and 105 deletions
|
@ -96,6 +96,7 @@
|
|||
windowStyle: "default",
|
||||
channel: "stable",
|
||||
armcordCSP: true,
|
||||
autoLaunch: true,
|
||||
minimizeToTray: true,
|
||||
automaticPatches: false,
|
||||
mods: "cumcord",
|
||||
|
@ -126,6 +127,7 @@
|
|||
windowStyle: "default",
|
||||
channel: options.channel,
|
||||
armcordCSP: true,
|
||||
autoLaunch: true,
|
||||
minimizeToTray: true,
|
||||
automaticPatches: false,
|
||||
mods: options.mod,
|
||||
|
@ -141,6 +143,7 @@
|
|||
armcordCSP: true,
|
||||
minimizeToTray: true,
|
||||
automaticPatches: false,
|
||||
autoLaunch: true,
|
||||
mods: "none",
|
||||
inviteWebsocket: true,
|
||||
blurType: "acrylic"
|
||||
|
|
11
src/main.ts
11
src/main.ts
|
@ -7,6 +7,7 @@ import "./extensions/plugin";
|
|||
import "./tray";
|
||||
import {createCustomWindow, createNativeWindow, createTabsHost} from "./window";
|
||||
import "./shortcuts";
|
||||
import AutoLaunch from "easy-auto-launch";
|
||||
|
||||
export var settings: any;
|
||||
export var customTitlebar: boolean;
|
||||
|
@ -25,7 +26,17 @@ if (process.platform == "linux") {
|
|||
}
|
||||
checkIfConfigExists();
|
||||
|
||||
var AutoLauncher = new AutoLaunch({
|
||||
name: 'ArmCord',
|
||||
path: '/Applications/ArmCord.app',
|
||||
});
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
if (await getConfig("autoLaunch") == "true") {
|
||||
AutoLauncher.enable()
|
||||
} else {
|
||||
AutoLauncher.disable()
|
||||
}
|
||||
switch (await getConfig("windowStyle")) {
|
||||
case "default":
|
||||
createCustomWindow();
|
||||
|
|
|
@ -15,7 +15,7 @@ export function createSettingsWindow() {
|
|||
} else {
|
||||
settingsWindow = new BrowserWindow({
|
||||
width: 500,
|
||||
height: 500,
|
||||
height: 555,
|
||||
title: "ArmCord Settings",
|
||||
darkTheme: true,
|
||||
frame: true,
|
||||
|
|
|
@ -40,6 +40,12 @@
|
|||
<input class="tgl tgl-light left" id="websocket" type="checkbox" />
|
||||
<label class="tgl-btn left" for="websocket"></label>
|
||||
</div>
|
||||
<br />
|
||||
<div class="switch">
|
||||
<label class="header">Auto launch</label>
|
||||
<input class="tgl tgl-light left" id="autolaunch" type="checkbox" />
|
||||
<label class="tgl-btn left" for="autolaunch"></label>
|
||||
</div>
|
||||
<div class="switch">
|
||||
<select name="channel" id="channel" class="left">
|
||||
<option value="stable">Stable</option>
|
||||
|
@ -71,6 +77,7 @@
|
|||
document.getElementById("mod").value = await settings.get("mods");
|
||||
document.getElementById("channel").value = await settings.get("channel");
|
||||
document.getElementById("theme").value = await settings.get("windowStyle");
|
||||
document.getElementById("autolaunch").checked = await settings.get("autoLaunch");
|
||||
}
|
||||
loadSettings();
|
||||
document.getElementById("save").addEventListener("click", function () {
|
||||
|
@ -83,6 +90,7 @@
|
|||
automaticPatches: document.getElementById("patches").checked,
|
||||
mods: document.getElementById("mod").value,
|
||||
blurType: "acrylic",
|
||||
autoLaunch: document.getElementById("autolaunch").checked,
|
||||
inviteWebsocket: document.getElementById("websocket").checked,
|
||||
doneSetup: true
|
||||
});
|
||||
|
|
26
src/utils.ts
26
src/utils.ts
|
@ -2,6 +2,7 @@ import * as fs from "fs";
|
|||
import {app, dialog} from "electron";
|
||||
import path from "path";
|
||||
export var firstRun: boolean;
|
||||
export var isSetup: boolean;
|
||||
export var contentPath: string;
|
||||
//utillity functions that are used all over the codebase or just too obscure to be put in the file used in
|
||||
export function addStyle(styleString: string) {
|
||||
|
@ -21,7 +22,7 @@ export async function sleep(ms: number) {
|
|||
}
|
||||
|
||||
export async function checkIfConfigIsBroken() {
|
||||
if (await getConfig("0") == "d") {
|
||||
if ((await getConfig("0")) == "d") {
|
||||
console.log("Detected a corrupted config");
|
||||
setup();
|
||||
dialog.showErrorBox(
|
||||
|
@ -39,6 +40,7 @@ export function setup() {
|
|||
armcordCSP: true,
|
||||
minimizeToTray: true,
|
||||
automaticPatches: false,
|
||||
autoLaunch: true,
|
||||
mods: "cumcord",
|
||||
blurType: "acrylic",
|
||||
inviteWebsocket: true,
|
||||
|
@ -71,6 +73,7 @@ export interface Settings {
|
|||
armcordCSP: boolean;
|
||||
minimizeToTray: boolean;
|
||||
automaticPatches: boolean;
|
||||
autoLaunch: boolean;
|
||||
mods: string;
|
||||
blurType: string;
|
||||
inviteWebsocket: boolean;
|
||||
|
@ -124,7 +127,7 @@ export async function checkIfConfigExists() {
|
|||
const userDataPath = app.getPath("userData");
|
||||
const storagePath = path.join(userDataPath, "/storage/");
|
||||
const settingsFile = storagePath + "settings.json";
|
||||
|
||||
|
||||
if (!fs.existsSync(settingsFile)) {
|
||||
if (!fs.existsSync(storagePath)) {
|
||||
fs.mkdirSync(storagePath);
|
||||
|
@ -132,15 +135,26 @@ export async function checkIfConfigExists() {
|
|||
}
|
||||
console.log("First run of the ArmCord. Starting setup.");
|
||||
setup();
|
||||
isSetup = true;
|
||||
contentPath = path.join(__dirname, "/content/setup.html");
|
||||
if (!contentPath.includes("ts-out")) {
|
||||
contentPath = path.join(__dirname, "/ts-out/content/setup.html");
|
||||
}
|
||||
} else {
|
||||
console.log("ArmCord has been run before. Skipping setup.");
|
||||
contentPath = path.join(__dirname, "/content/splash.html");
|
||||
if (!contentPath.includes("ts-out")) {
|
||||
contentPath = path.join(__dirname, "/ts-out/content/splash.html");
|
||||
if (await getConfig("doneSetup") == false) {
|
||||
console.log("First run of the ArmCord. Starting setup.");
|
||||
setup();
|
||||
isSetup = true;
|
||||
contentPath = path.join(__dirname, "/content/setup.html");
|
||||
if (!contentPath.includes("ts-out")) {
|
||||
contentPath = path.join(__dirname, "/ts-out/content/setup.html");
|
||||
}
|
||||
} else {
|
||||
console.log("ArmCord has been run before. Skipping setup.");
|
||||
contentPath = path.join(__dirname, "/content/splash.html");
|
||||
if (!contentPath.includes("ts-out")) {
|
||||
contentPath = path.join(__dirname, "/ts-out/content/splash.html");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// I'm sorry for this mess but I'm not sure how to fix it.
|
||||
import {BrowserWindow, shell, app, ipcMain, dialog, clipboard} from "electron";
|
||||
import path from "path";
|
||||
import {checkIfConfigIsBroken, firstRun, getConfig, contentPath} from "./utils";
|
||||
import {checkIfConfigIsBroken, firstRun, getConfig, contentPath, isSetup} from "./utils";
|
||||
import {registerIpc} from "./ipc";
|
||||
import startServer from "./socket"
|
||||
import contextMenu from "electron-context-menu";
|
||||
|
@ -46,8 +46,12 @@ async function doAfterDefiningTheWindow() {
|
|||
if (await getConfig("inviteWebsocket") == true) {
|
||||
startServer()
|
||||
}
|
||||
|
||||
try {
|
||||
mainWindow.loadFile(contentPath);
|
||||
if (isSetup) {
|
||||
mainWindow.setSize(390, 470);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(
|
||||
"Major error detected while starting up. User is most likely on Windows platform. Fallback to alternative startup."
|
||||
|
@ -55,12 +59,14 @@ async function doAfterDefiningTheWindow() {
|
|||
console.log(process.platform);
|
||||
if (process.platform === "win32") {
|
||||
if (firstRun) {
|
||||
mainWindow.setSize(390, 470);
|
||||
mainWindow.loadURL(`file://${__dirname}/content/setup.html`);
|
||||
} else {
|
||||
mainWindow.loadURL(`file://${__dirname}/content/splash.html`);
|
||||
}
|
||||
} else {
|
||||
if (firstRun) {
|
||||
mainWindow.setSize(390, 470);
|
||||
mainWindow.loadURL(`file://${__dirname}/ts-out/content/setup.html`);
|
||||
} else {
|
||||
mainWindow.loadURL(`file://${__dirname}/ts-out/content/splash.html`);
|
||||
|
@ -70,8 +76,8 @@ async function doAfterDefiningTheWindow() {
|
|||
}
|
||||
export function createCustomWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 390,
|
||||
height: 470,
|
||||
width: 300,
|
||||
height: 350,
|
||||
title: "ArmCord",
|
||||
darkTheme: true,
|
||||
icon: path.join(__dirname, "/assets/icon_transparent.png"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue