mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Rework setup and tray
This commit is contained in:
parent
4937a2cddf
commit
fdd9855065
11 changed files with 247 additions and 196 deletions
|
@ -2,9 +2,7 @@
|
||||||
"loading_screen_start": "Starting ArmCord…",
|
"loading_screen_start": "Starting ArmCord…",
|
||||||
"loading_screen_offline": "You appear to be offline. Please connect to the Internet and try again.",
|
"loading_screen_offline": "You appear to be offline. Please connect to the Internet and try again.",
|
||||||
"loading_screen_update": "A new version of ArmCord is available. Please update to the latest version.",
|
"loading_screen_update": "A new version of ArmCord is available. Please update to the latest version.",
|
||||||
"setup_question1": "Select what kind of setup you want to perform:",
|
"setup_question1": "Welcome to the ArmCord Setup",
|
||||||
"setup_question1_answer1": "Express Setup",
|
|
||||||
"setup_question1_answer2": "Full Setup",
|
|
||||||
"setup_offline": "You appear to be offline. Please connect to the internet and restart ArmCord.",
|
"setup_offline": "You appear to be offline. Please connect to the internet and restart ArmCord.",
|
||||||
"setup_question2": "Choose your Discord channel/instance:",
|
"setup_question2": "Choose your Discord channel/instance:",
|
||||||
"setup_question3": "Should ArmCord handle client mods installation?",
|
"setup_question3": "Should ArmCord handle client mods installation?",
|
||||||
|
@ -12,7 +10,7 @@
|
||||||
"no": "No",
|
"no": "No",
|
||||||
"next": "Next",
|
"next": "Next",
|
||||||
"setup_question4": "Select a client mod you want to install:",
|
"setup_question4": "Select a client mod you want to install:",
|
||||||
"setup_question4_clientmodnotice": "Why not all of them? Having many client mods at the same time can cause issues. If you really want to do it though, check our Discord.",
|
"setup_question5": "Do you want to use a tray icon?",
|
||||||
"settings-theme": "ArmCord theme",
|
"settings-theme": "ArmCord theme",
|
||||||
"settings-theme-desc1": "ArmCord \"themes\" manage apps behaviour and looks.",
|
"settings-theme-desc1": "ArmCord \"themes\" manage apps behaviour and looks.",
|
||||||
"settings-theme-desc2": "this is how ArmCord looks when you first launch it. It includes recreation of Discord's\n custom titlebar and ArmCord specific styles injected into Discord.",
|
"settings-theme-desc2": "this is how ArmCord looks when you first launch it. It includes recreation of Discord's\n custom titlebar and ArmCord specific styles injected into Discord.",
|
||||||
|
@ -21,8 +19,8 @@
|
||||||
"settings-theme-native": "Native",
|
"settings-theme-native": "Native",
|
||||||
"settings-theme-transparent": "Transparent (Experimental)",
|
"settings-theme-transparent": "Transparent (Experimental)",
|
||||||
"settings-csp-desc": "ArmCord CSP is our system that manages loading custom content loading into the Discord app. Stuff like\n client mods and themes depend on it. Disable if you want to get rid of mods and custom styles.",
|
"settings-csp-desc": "ArmCord CSP is our system that manages loading custom content loading into the Discord app. Stuff like\n client mods and themes depend on it. Disable if you want to get rid of mods and custom styles.",
|
||||||
"settings-tray": "Minimize to tray",
|
"settings-mintoTray": "Minimize to tray",
|
||||||
"settings-tray-desc": "When disabled, ArmCord will close like any other window when closed, otherwise it'll sit back and relax\n in your system tray for later.",
|
"settings-mintoTray-desc": "When disabled, ArmCord will close like any other window when closed, otherwise it'll sit back and relax\n in your system tray for later.",
|
||||||
"settings-startMinimized": "Start minimized",
|
"settings-startMinimized": "Start minimized",
|
||||||
"settings-startMinimized-desc": "ArmCord starts in background and remains out of your way.",
|
"settings-startMinimized-desc": "ArmCord starts in background and remains out of your way.",
|
||||||
"settings-patches": "Automatic Patches",
|
"settings-patches": "Automatic Patches",
|
||||||
|
@ -35,6 +33,8 @@
|
||||||
"settings-dynamicIcon-desc": "Following Discord's behaviour on Windows, this shows unread messages/pings count on ArmCord's icon instead of it's tray.",
|
"settings-dynamicIcon-desc": "Following Discord's behaviour on Windows, this shows unread messages/pings count on ArmCord's icon instead of it's tray.",
|
||||||
"settings-spellcheck": "Spellcheck",
|
"settings-spellcheck": "Spellcheck",
|
||||||
"settings-spellcheck-desc": "Helps you correct misspelled words by highlighting them.",
|
"settings-spellcheck-desc": "Helps you correct misspelled words by highlighting them.",
|
||||||
|
"settings-tray": "Tray",
|
||||||
|
"settings-tray-desc": "ArmCord's tray menu is a place where you can easily and quickly access ArmCord's settings and allows you to quickly show up Discord window.",
|
||||||
"settings-channel": "Discord channel",
|
"settings-channel": "Discord channel",
|
||||||
"settings-channel-desc1": "You can use this setting to change current instance of Discord:",
|
"settings-channel-desc1": "You can use this setting to change current instance of Discord:",
|
||||||
"settings-channel-desc2": "you're probably most familiar with this one. It's the one you see in default Discord\n client!",
|
"settings-channel-desc2": "you're probably most familiar with this one. It's the one you see in default Discord\n client!",
|
||||||
|
|
|
@ -74,7 +74,6 @@ ipcRenderer.on("rpc", (_event, data: object) => {
|
||||||
if (window.location.href.indexOf("splash.html") > -1 || window.location.href.indexOf("setup.html") > -1) {
|
if (window.location.href.indexOf("splash.html") > -1 || window.location.href.indexOf("setup.html") > -1) {
|
||||||
contextBridge.exposeInMainWorld("armcordinternal", {
|
contextBridge.exposeInMainWorld("armcordinternal", {
|
||||||
restart: () => ipcRenderer.send("restart"),
|
restart: () => ipcRenderer.send("restart"),
|
||||||
installState: ipcRenderer.sendSync("modInstallState"),
|
installState: ipcRenderer.sendSync("modInstallState")
|
||||||
saveSettings: (...args: any) => ipcRenderer.send("saveSettings", ...args)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,9 @@ if (ipcRenderer.sendSync("legacyCapturer")) {
|
||||||
|
|
||||||
const version = ipcRenderer.sendSync("displayVersion");
|
const version = ipcRenderer.sendSync("displayVersion");
|
||||||
async function updateLang(): Promise<void> {
|
async function updateLang(): Promise<void> {
|
||||||
if (window.location.href.indexOf("setup.html") > -1) {
|
const value = `; ${document.cookie}`;
|
||||||
console.log("Setup, skipping lang update");
|
const parts: any = value.split(`; locale=`);
|
||||||
} else {
|
if (parts.length === 2) ipcRenderer.send("setLang", parts.pop().split(";").shift());
|
||||||
const value = `; ${document.cookie}`;
|
|
||||||
const parts: any = value.split(`; locale=`);
|
|
||||||
if (parts.length === 2) ipcRenderer.send("setLang", parts.pop().split(";").shift());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
|
|
|
@ -33,7 +33,11 @@ export function injectTitlebar(): void {
|
||||||
const quit = document.getElementById("quit");
|
const quit = document.getElementById("quit");
|
||||||
|
|
||||||
minimize!.addEventListener("click", () => {
|
minimize!.addEventListener("click", () => {
|
||||||
ipcRenderer.send("win-minimize");
|
if (window.location.href.indexOf("setup.html") > -1) {
|
||||||
|
ipcRenderer.send("setup-minimize");
|
||||||
|
} else {
|
||||||
|
ipcRenderer.send("win-minimize");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
maximize!.addEventListener("click", () => {
|
maximize!.addEventListener("click", () => {
|
||||||
|
@ -46,10 +50,14 @@ export function injectTitlebar(): void {
|
||||||
});
|
});
|
||||||
|
|
||||||
quit!.addEventListener("click", () => {
|
quit!.addEventListener("click", () => {
|
||||||
if (ipcRenderer.sendSync("minimizeToTray") === true) {
|
if (window.location.href.indexOf("setup.html") > -1) {
|
||||||
ipcRenderer.send("win-hide");
|
ipcRenderer.send("setup-quit");
|
||||||
} else if (ipcRenderer.sendSync("minimizeToTray") === false) {
|
} else {
|
||||||
ipcRenderer.send("win-quit");
|
if (ipcRenderer.sendSync("minimizeToTray") === true) {
|
||||||
|
ipcRenderer.send("win-hide");
|
||||||
|
} else if (ipcRenderer.sendSync("minimizeToTray") === false) {
|
||||||
|
ipcRenderer.send("win-quit");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -45,10 +45,10 @@
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<div class="switch acTray">
|
<div class="switch acTray">
|
||||||
<label class="header" data-string="settings-tray"></label>
|
<label class="header" data-string="settings-mintoTray"></label>
|
||||||
<input id="tray" class="tgl tgl-light left" data-setting="minimizeToTray" type="checkbox" />
|
<input id="minimizeToTray" class="tgl tgl-light left" data-setting="minimizeToTray" type="checkbox" />
|
||||||
<label class="tgl-btn left" for="tray"></label>
|
<label class="tgl-btn left" for="tray"></label>
|
||||||
<p class="description" data-string="settings-tray-desc"></p>
|
<p class="description" data-string="settings-mintoTray-desc"></p>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
@ -60,6 +60,14 @@
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
<div class="switch acTray">
|
||||||
|
<label class="header" data-string="settings-tray"></label>
|
||||||
|
<input id="tray" class="tgl tgl-light left" data-setting="tray" type="checkbox" />
|
||||||
|
<label class="tgl-btn left" for="tray"></label>
|
||||||
|
<p class="description" data-string="settings-tray-desc"></p>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
|
||||||
<div class="switch acPatches">
|
<div class="switch acPatches">
|
||||||
<label class="header" data-string="settings-patches"></label>
|
<label class="header" data-string="settings-patches"></label>
|
||||||
<input id="patches" class="tgl tgl-light left" data-setting="automaticPatches" type="checkbox" />
|
<input id="patches" class="tgl tgl-light left" data-setting="automaticPatches" type="checkbox" />
|
||||||
|
|
42
src/setup/main.ts
Normal file
42
src/setup/main.ts
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import {BrowserWindow, app, ipcMain} from "electron";
|
||||||
|
import path from "path";
|
||||||
|
import * as fs from "fs";
|
||||||
|
import * as os from "os";
|
||||||
|
import {iconPath} from "../main";
|
||||||
|
import {Settings, getConfigLocation, setConfigBulk} from "../utils";
|
||||||
|
let setupWindow: BrowserWindow;
|
||||||
|
export function createSetupWindow(): void {
|
||||||
|
setupWindow = new BrowserWindow({
|
||||||
|
width: 390,
|
||||||
|
height: 470,
|
||||||
|
title: "ArmCord Setup",
|
||||||
|
darkTheme: true,
|
||||||
|
icon: iconPath,
|
||||||
|
frame: false,
|
||||||
|
autoHideMenuBar: true,
|
||||||
|
webPreferences: {
|
||||||
|
sandbox: false,
|
||||||
|
spellcheck: false,
|
||||||
|
preload: path.join(__dirname, "preload.js")
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ipcMain.on("saveSettings", (_event, args: Settings) => {
|
||||||
|
console.log(args);
|
||||||
|
setConfigBulk(args);
|
||||||
|
});
|
||||||
|
ipcMain.on("setup-minimize", () => {
|
||||||
|
setupWindow.minimize();
|
||||||
|
});
|
||||||
|
ipcMain.on("setup-getOS", (event) => {
|
||||||
|
event.returnValue = process.platform;
|
||||||
|
});
|
||||||
|
ipcMain.on("setup-quit", async () => {
|
||||||
|
fs.unlink(await getConfigLocation(), (err) => {
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
|
console.log('Closed during setup. "settings.json" was deleted');
|
||||||
|
app.quit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
setupWindow.loadURL(`file://${__dirname}/setup.html`);
|
||||||
|
}
|
12
src/setup/preload.ts
Normal file
12
src/setup/preload.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import {contextBridge, ipcRenderer} from "electron";
|
||||||
|
import {injectTitlebar} from "../preload/titlebar";
|
||||||
|
injectTitlebar();
|
||||||
|
contextBridge.exposeInMainWorld("armcordinternal", {
|
||||||
|
restart: () => ipcRenderer.send("restart"),
|
||||||
|
getOS: ipcRenderer.sendSync("setup-getOS"),
|
||||||
|
saveSettings: (...args: any) => ipcRenderer.send("saveSettings", ...args),
|
||||||
|
getLang: (toGet: string) =>
|
||||||
|
ipcRenderer.invoke("getLang", toGet).then((result) => {
|
||||||
|
return result;
|
||||||
|
})
|
||||||
|
});
|
|
@ -7,9 +7,10 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>ArmCord Setup</title>
|
<title>ArmCord Setup</title>
|
||||||
<style>
|
<style>
|
||||||
@import url("css/setup.css");
|
@import url("../content/css/setup.css");
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div id="warning" class="hidden">
|
<div id="warning" class="hidden">
|
||||||
|
@ -18,10 +19,9 @@
|
||||||
<div id="setup">
|
<div id="setup">
|
||||||
<div id="logo" class="hidden"></div>
|
<div id="logo" class="hidden"></div>
|
||||||
<div id="page1" class="hidden">
|
<div id="page1" class="hidden">
|
||||||
<p id="setup_question1">Select the type of setup you want to perform.</p>
|
<p id="setup_question1">Welcome to the ArmCord Setup</p>
|
||||||
<div id="buttons">
|
<div id="buttons">
|
||||||
<button id="express" class="center">Express</button>
|
<button id="full" class="center">Next</button>
|
||||||
<button id="full" class="center">Full</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -34,17 +34,8 @@
|
||||||
<option value="ptb">PTB</option>
|
<option value="ptb">PTB</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-center setup-ask" id="setup_question3">
|
|
||||||
Should ArmCord handle client mods installation?
|
|
||||||
</p>
|
|
||||||
<div class="center">
|
|
||||||
<select name="csp" id="csp" class="dropdown-button">
|
|
||||||
<option value="true">Yes</option>
|
|
||||||
<option value="false">No</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div id="buttons">
|
<div id="buttons">
|
||||||
<button id="next" class="center">Next</button>
|
<button id="next-page2" class="center">Next</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -57,32 +48,36 @@
|
||||||
<option value="none">None</option>
|
<option value="none">None</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-center" id="setup_question4_clientmodnotice">
|
|
||||||
Why not all of them? Having many client mods at the same time can cause issues. If you really
|
|
||||||
want to do it though, check our Discord ;)
|
|
||||||
</p>
|
|
||||||
<div id="buttons">
|
<div id="buttons">
|
||||||
<button id="next" class="center">Next</button>
|
<button id="next-page3" class="center">Next</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="page4" class="hidden">
|
||||||
|
<p class="text-center setup-ask" id="setup_question5">Do you want to use a tray icon?</p>
|
||||||
|
<div class="center">
|
||||||
|
<select name="tray" id="tray" class="dropdown-button">
|
||||||
|
<option value="true">Yes</option>
|
||||||
|
<option value="false">No</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<p class="text-center" id="linuxNotice"></p>
|
||||||
|
<div id="buttons">
|
||||||
|
<button id="next-page4" class="center">Next</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
async function loadLang() {
|
async function loadLang() {
|
||||||
document.getElementById("next").innerHTML = await armcord.getLang("next");
|
document.getElementById("next").innerHTML = await armcordinternal.getLang("next");
|
||||||
document.getElementById("setup_offline").innerHTML = await armcord.getLang("setup_offline");
|
document.getElementById("setup_offline").innerHTML = await armcordinternal.getLang("setup_offline");
|
||||||
document.getElementById("setup_question1").innerHTML = await armcord.getLang("setup_question1");
|
document.getElementById("setup_question1").innerHTML = await armcordinternal.getLang("setup_question1");
|
||||||
document.getElementById("express").innerHTML = await armcord.getLang("setup_question1_answer1");
|
document.getElementById("express").innerHTML = await armcordinternal.getLang("setup_question1_answer1");
|
||||||
document.getElementById("full").innerHTML = await armcord.getLang("setup_question1_answer2");
|
document.getElementById("full").innerHTML = await armcordinternal.getLang("setup_question1_answer2");
|
||||||
document.getElementById("setup_question2").innerHTML = await armcord.getLang("setup_question2");
|
document.getElementById("setup_question2").innerHTML = await armcordinternal.getLang("setup_question2");
|
||||||
document.getElementById("setup_question3").innerHTML = await armcord.getLang("setup_question3");
|
document.getElementById("setup_question3").innerHTML = await armcordinternal.getLang("setup_question3");
|
||||||
document.getElementById("setup_question4").innerHTML = await armcord.getLang("setup_question4");
|
document.getElementById("setup_question4").innerHTML = await armcordinternal.getLang("setup_question4");
|
||||||
document.getElementById("setup_question4_clientmodnotice").innerHTML = await armcord.getLang(
|
document.getElementById("setup_question5").innerHTML = await armcordinternal.getLang("setup_question5");
|
||||||
"setup_question4_clientmodnotice"
|
|
||||||
);
|
|
||||||
//select stuff1
|
|
||||||
document.getElementById("csp").options[1].text = await armcord.getLang("no");
|
|
||||||
document.getElementById("csp").options[0].text = await armcord.getLang("yes");
|
|
||||||
}
|
}
|
||||||
loadLang();
|
loadLang();
|
||||||
</script>
|
</script>
|
||||||
|
@ -108,68 +103,31 @@
|
||||||
|
|
||||||
let page2 = document.getElementById("page2");
|
let page2 = document.getElementById("page2");
|
||||||
let page3 = document.getElementById("page3");
|
let page3 = document.getElementById("page3");
|
||||||
|
let page4 = document.getElementById("page4");
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
// Express
|
|
||||||
page1.buttons[0].addEventListener("click", () => {
|
|
||||||
window.armcordinternal.saveSettings({
|
|
||||||
windowStyle: "default",
|
|
||||||
channel: "stable",
|
|
||||||
armcordCSP: true,
|
|
||||||
minimizeToTray: true,
|
|
||||||
alternativePaste: false,
|
|
||||||
automaticPatches: false,
|
|
||||||
mods: "none",
|
|
||||||
useLegacyCapturer: false,
|
|
||||||
inviteWebsocket: true,
|
|
||||||
mobileMode: false,
|
|
||||||
dynamicIcon: false,
|
|
||||||
trayIcon: "default",
|
|
||||||
startMinimized: false,
|
|
||||||
spellcheck: true,
|
|
||||||
performanceMode: "none"
|
|
||||||
});
|
|
||||||
setTimeout(() => window.armcordinternal.restart(), 500);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Full
|
// Full
|
||||||
page1.buttons[1].addEventListener("click", () => {
|
page1.buttons[0].addEventListener("click", () => {
|
||||||
page1.classList.add("hidden");
|
page1.classList.add("hidden");
|
||||||
page2.classList.remove("hidden");
|
page2.classList.remove("hidden");
|
||||||
});
|
});
|
||||||
|
|
||||||
page2.buttons = document.querySelectorAll("#page2 > #buttons > button");
|
document.getElementById("next-page2").addEventListener("click", () => {
|
||||||
page2.buttons[0].addEventListener("click", () => {
|
|
||||||
options.channel = document.getElementById("channel").value;
|
options.channel = document.getElementById("channel").value;
|
||||||
options.csp = document.getElementById("csp").value;
|
options.mod = document.getElementById("mod").value;
|
||||||
page2.classList.add("hidden");
|
page2.classList.add("hidden");
|
||||||
|
page3.classList.remove("hidden");
|
||||||
page3.buttons = document.querySelectorAll("#page3 > #buttons > button");
|
document.getElementById("next-page3").addEventListener("click", () => {
|
||||||
if (options.csp === "true") {
|
page3.classList.add("hidden");
|
||||||
page3.classList.remove("hidden");
|
page4.classList.remove("hidden");
|
||||||
page3.buttons[0].addEventListener("click", () => {
|
});
|
||||||
options.mod = document.getElementById("mod").value;
|
if (window.armcordinternal.getOS == "win32") {
|
||||||
window.armcordinternal.saveSettings({
|
document.getElementById("tray").value = "false";
|
||||||
windowStyle: "default",
|
document.getElementById(
|
||||||
channel: options.channel,
|
"linuxNotice"
|
||||||
armcordCSP: true,
|
).innerHTML = `Linux may not work well with tray icons. Depending on your system configuration, you may not be able to see the tray icon. Enable at your own risk. Can be changed later.`;
|
||||||
minimizeToTray: true,
|
}
|
||||||
mobileMode: false,
|
document.getElementById("next-page4").addEventListener("click", () => {
|
||||||
automaticPatches: false,
|
|
||||||
performanceMode: "none",
|
|
||||||
useLegacyCapturer: false,
|
|
||||||
alternativePaste: false,
|
|
||||||
dynamicIcon: false,
|
|
||||||
spellcheck: true,
|
|
||||||
disableAutogain: false,
|
|
||||||
startMinimized: false,
|
|
||||||
trayIcon: "default",
|
|
||||||
mods: options.mod,
|
|
||||||
inviteWebsocket: true
|
|
||||||
});
|
|
||||||
setTimeout(() => window.armcordinternal.restart(), 500);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
window.armcordinternal.saveSettings({
|
window.armcordinternal.saveSettings({
|
||||||
windowStyle: "default",
|
windowStyle: "default",
|
||||||
channel: options.channel,
|
channel: options.channel,
|
||||||
|
@ -179,9 +137,10 @@
|
||||||
mobileMode: false,
|
mobileMode: false,
|
||||||
spellcheck: true,
|
spellcheck: true,
|
||||||
disableAutogain: false,
|
disableAutogain: false,
|
||||||
mods: "none",
|
mods: options.mod,
|
||||||
dynamicIcon: false,
|
dynamicIcon: false,
|
||||||
useLegacyCapturer: false,
|
useLegacyCapturer: false,
|
||||||
|
tray: /true/i.test(document.getElementById("tray").value),
|
||||||
startMinimized: false,
|
startMinimized: false,
|
||||||
alternativePaste: false,
|
alternativePaste: false,
|
||||||
performanceMode: "none",
|
performanceMode: "none",
|
||||||
|
@ -189,7 +148,7 @@
|
||||||
inviteWebsocket: true
|
inviteWebsocket: true
|
||||||
});
|
});
|
||||||
setTimeout(() => window.armcordinternal.restart(), 500);
|
setTimeout(() => window.armcordinternal.restart(), 500);
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
document.body.setAttribute("insetup", "");
|
document.body.setAttribute("insetup", "");
|
||||||
</script>
|
</script>
|
186
src/tray.ts
186
src/tray.ts
|
@ -1,7 +1,7 @@
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {Menu, Tray, app, nativeImage} from "electron";
|
import {Menu, Tray, app, dialog, nativeImage} from "electron";
|
||||||
import {createInviteWindow, mainWindow} from "./window";
|
import {createInviteWindow, mainWindow} from "./window";
|
||||||
import {getConfig, getConfigLocation, getDisplayVersion, setWindowState} from "./utils";
|
import {getConfig, getConfigLocation, getDisplayVersion, setConfig, setWindowState} from "./utils";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import {createSettingsWindow} from "./settings/main";
|
import {createSettingsWindow} from "./settings/main";
|
||||||
export let tray: any = null;
|
export let tray: any = null;
|
||||||
|
@ -25,13 +25,61 @@ app.whenReady().then(async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (process.platform == "darwin" && trayPath.getSize().height > 22) trayPath = trayPath.resize({height: 22});
|
if (process.platform == "darwin" && trayPath.getSize().height > 22) trayPath = trayPath.resize({height: 22});
|
||||||
|
if (await getConfig("tray")) {
|
||||||
|
let clientName = (await getConfig("clientName")) ?? "ArmCord";
|
||||||
|
if ((await getConfig("windowStyle")) == "basic") {
|
||||||
|
tray = new Tray(trayPath);
|
||||||
|
function contextMenu(): Electron.Menu {
|
||||||
|
if (finishedSetup == false) {
|
||||||
|
return Menu.buildFromTemplate([
|
||||||
|
{
|
||||||
|
label: `Finish the setup first!`,
|
||||||
|
enabled: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: `Quit ${clientName}`,
|
||||||
|
async click() {
|
||||||
|
fs.unlink(await getConfigLocation(), (err) => {
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
let clientName = (await getConfig("clientName")) ?? "ArmCord";
|
console.log('Closed during setup. "settings.json" was deleted');
|
||||||
if ((await getConfig("windowStyle")) == "basic") {
|
app.quit();
|
||||||
tray = new Tray(trayPath);
|
});
|
||||||
function contextMenu(): Electron.Menu {
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return Menu.buildFromTemplate([
|
||||||
|
{
|
||||||
|
label: `Open ${clientName}`,
|
||||||
|
click() {
|
||||||
|
mainWindow.show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: `Quit ${clientName}`,
|
||||||
|
click() {
|
||||||
|
let [width, height] = mainWindow.getSize();
|
||||||
|
setWindowState({
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
isMaximized: mainWindow.isMaximized(),
|
||||||
|
x: mainWindow.getPosition()[0],
|
||||||
|
y: mainWindow.getPosition()[1]
|
||||||
|
});
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tray.setToolTip(clientName);
|
||||||
|
tray.setContextMenu(contextMenu);
|
||||||
|
} else {
|
||||||
|
tray = new Tray(trayPath);
|
||||||
if (finishedSetup == false) {
|
if (finishedSetup == false) {
|
||||||
return Menu.buildFromTemplate([
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
{
|
{
|
||||||
label: `Finish the setup first!`,
|
label: `Finish the setup first!`,
|
||||||
enabled: false
|
enabled: false
|
||||||
|
@ -48,98 +96,78 @@ app.whenReady().then(async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
tray.setContextMenu(contextMenu);
|
||||||
} else {
|
} else {
|
||||||
return Menu.buildFromTemplate([
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
|
{
|
||||||
|
label: `${clientName} ${getDisplayVersion()}`,
|
||||||
|
icon: trayVerIcon(),
|
||||||
|
enabled: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "separator"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: `Open ${clientName}`,
|
label: `Open ${clientName}`,
|
||||||
click() {
|
click() {
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Open Settings",
|
||||||
|
click() {
|
||||||
|
createSettingsWindow();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Support Discord Server",
|
||||||
|
click() {
|
||||||
|
createInviteWindow("TnhxcqynZ2");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "separator"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: `Quit ${clientName}`,
|
label: `Quit ${clientName}`,
|
||||||
click() {
|
click() {
|
||||||
let [width, height] = mainWindow.getSize();
|
|
||||||
setWindowState({
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
isMaximized: mainWindow.isMaximized(),
|
|
||||||
x: mainWindow.getPosition()[0],
|
|
||||||
y: mainWindow.getPosition()[1]
|
|
||||||
});
|
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
tray.setContextMenu(contextMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tray.setToolTip(clientName);
|
tray.setToolTip(clientName);
|
||||||
tray.setContextMenu(contextMenu);
|
tray.on("click", function () {
|
||||||
|
mainWindow.show();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
tray = new Tray(trayPath);
|
if ((await getConfig("tray")) == undefined) {
|
||||||
if (finishedSetup == false) {
|
if (process.platform == "win32") {
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
const options = {
|
||||||
{
|
type: "question",
|
||||||
label: `Finish the setup first!`,
|
buttons: ["Yes, please", "No, I don't"],
|
||||||
enabled: false
|
defaultId: 1,
|
||||||
},
|
title: "Tray icon choice",
|
||||||
{
|
message: `Do you want to use tray icons?`,
|
||||||
label: `Quit ${clientName}`,
|
detail: "Linux may not work well with tray icons. Depending on your system configuration, you may not be able to see the tray icon. Enable at your own risk. Can be changed later."
|
||||||
async click() {
|
};
|
||||||
fs.unlink(await getConfigLocation(), (err) => {
|
|
||||||
if (err) throw err;
|
|
||||||
|
|
||||||
console.log('Closed during setup. "settings.json" was deleted');
|
dialog.showMessageBox(mainWindow, options).then(({response}) => {
|
||||||
app.quit();
|
if (response == 0) {
|
||||||
});
|
setConfig("tray", true);
|
||||||
|
} else {
|
||||||
|
setConfig("tray", false);
|
||||||
}
|
}
|
||||||
}
|
app.relaunch();
|
||||||
]);
|
app.exit();
|
||||||
tray.setContextMenu(contextMenu);
|
});
|
||||||
} else {
|
} else {
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
setConfig("tray", true);
|
||||||
{
|
app.relaunch();
|
||||||
label: `${clientName} ${getDisplayVersion()}`,
|
app.exit();
|
||||||
icon: trayVerIcon(),
|
}
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "separator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: `Open ${clientName}`,
|
|
||||||
click() {
|
|
||||||
mainWindow.show();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Open Settings",
|
|
||||||
click() {
|
|
||||||
createSettingsWindow();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Support Discord Server",
|
|
||||||
click() {
|
|
||||||
createInviteWindow("TnhxcqynZ2");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "separator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: `Quit ${clientName}`,
|
|
||||||
click() {
|
|
||||||
app.quit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
tray.setContextMenu(contextMenu);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tray.setToolTip(clientName);
|
|
||||||
tray.on("click", function () {
|
|
||||||
mainWindow.show();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -52,6 +52,7 @@ export function setup(): void {
|
||||||
inviteWebsocket: true,
|
inviteWebsocket: true,
|
||||||
startMinimized: false,
|
startMinimized: false,
|
||||||
dynamicIcon: false,
|
dynamicIcon: false,
|
||||||
|
tray: true,
|
||||||
disableAutogain: false,
|
disableAutogain: false,
|
||||||
useLegacyCapturer: false,
|
useLegacyCapturer: false,
|
||||||
mobileMode: false,
|
mobileMode: false,
|
||||||
|
@ -260,6 +261,7 @@ export interface Settings {
|
||||||
performanceMode: string;
|
performanceMode: string;
|
||||||
startMinimized: boolean;
|
startMinimized: boolean;
|
||||||
useLegacyCapturer: boolean;
|
useLegacyCapturer: boolean;
|
||||||
|
tray: boolean;
|
||||||
inviteWebsocket: boolean;
|
inviteWebsocket: boolean;
|
||||||
disableAutogain: boolean;
|
disableAutogain: boolean;
|
||||||
trayIcon: string;
|
trayIcon: string;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import contextMenu from "electron-context-menu";
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import {tray} from "./tray";
|
import {tray} from "./tray";
|
||||||
import {iconPath} from "./main";
|
import {iconPath} from "./main";
|
||||||
|
import {createSetupWindow} from "./setup/main";
|
||||||
export let mainWindow: BrowserWindow;
|
export let mainWindow: BrowserWindow;
|
||||||
export let inviteWindow: BrowserWindow;
|
export let inviteWindow: BrowserWindow;
|
||||||
|
|
||||||
|
@ -256,12 +257,8 @@ async function doAfterDefiningTheWindow(): Promise<void> {
|
||||||
}
|
}
|
||||||
if (firstRun) {
|
if (firstRun) {
|
||||||
await setLang(new Intl.DateTimeFormat().resolvedOptions().locale);
|
await setLang(new Intl.DateTimeFormat().resolvedOptions().locale);
|
||||||
mainWindow.setSize(390, 470);
|
createSetupWindow();
|
||||||
await mainWindow.loadFile(path.join(__dirname, "/content/setup.html"));
|
mainWindow.close();
|
||||||
let trayPath = nativeImage.createFromPath(path.join(__dirname, "../", `/assets/ac_plug_colored.png`));
|
|
||||||
if (process.platform === "darwin" && trayPath.getSize().height > 22) trayPath = trayPath.resize({height: 22});
|
|
||||||
if (process.platform === "win32" && trayPath.getSize().height > 32) trayPath = trayPath.resize({height: 32});
|
|
||||||
tray.setImage(trayPath);
|
|
||||||
} else if ((await getConfig("skipSplash")) == true) {
|
} else if ((await getConfig("skipSplash")) == true) {
|
||||||
// It's modified elsewhere.
|
// It's modified elsewhere.
|
||||||
// eslint-disable-next-line no-unmodified-loop-condition
|
// eslint-disable-next-line no-unmodified-loop-condition
|
||||||
|
|
Loading…
Reference in a new issue