mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Compare commits
No commits in common. "d8fe49df3f80d4aeebc11d5f61915af195ccf8ee" and "1a7af5168da878caf9db5e31e0724743637b2171" have entirely different histories.
d8fe49df3f
...
1a7af5168d
28 changed files with 202 additions and 198 deletions
5
.idea/.gitignore
generated
vendored
5
.idea/.gitignore
generated
vendored
|
@ -1,5 +0,0 @@
|
||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
12
.idea/ArmCord.iml
generated
12
.idea/ArmCord.iml
generated
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="WEB_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/ArmCord.iml" filepath="$PROJECT_DIR$/.idea/ArmCord.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -18,7 +18,6 @@
|
||||||
"settings-theme-native": "Native",
|
"settings-theme-native": "Native",
|
||||||
"settings-tray": "Minimize to tray",
|
"settings-tray": "Minimize to tray",
|
||||||
"settings-patches": "Automatic Patches",
|
"settings-patches": "Automatic Patches",
|
||||||
"settings-mobileMode": "Mobile mode",
|
|
||||||
"settings-channel": "Discord channel:",
|
"settings-channel": "Discord channel:",
|
||||||
"settings-invitewebsocket": "Invite Websocket",
|
"settings-invitewebsocket": "Invite Websocket",
|
||||||
"settings-mod": "Client mod:",
|
"settings-mod": "Client mod:",
|
||||||
|
|
|
@ -26,6 +26,5 @@
|
||||||
"settings-prfmMode-battery": "Batería",
|
"settings-prfmMode-battery": "Batería",
|
||||||
"settings-none": "Ninguna",
|
"settings-none": "Ninguna",
|
||||||
"settings-save": "Guardar ajustes",
|
"settings-save": "Guardar ajustes",
|
||||||
"settings-updater": "Buscar una actualización",
|
"settings-updater": "Buscar una actualización"
|
||||||
"settings-mobileMode": "Mobile mode"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,5 @@
|
||||||
"settings-prfmMode-battery": "ذخیره برای باتری",
|
"settings-prfmMode-battery": "ذخیره برای باتری",
|
||||||
"settings-none": "هیچکدام",
|
"settings-none": "هیچکدام",
|
||||||
"settings-save": "ذخیره تنظیمات",
|
"settings-save": "ذخیره تنظیمات",
|
||||||
"settings-updater": "بررسی برای بروزرسانی",
|
"settings-updater": "بررسی برای بروزرسانی"
|
||||||
"settings-mobileMode": "Mobile mode"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,5 @@
|
||||||
"settings-prfmMode": "Mode performance :",
|
"settings-prfmMode": "Mode performance :",
|
||||||
"settings-prfmMode-performance": "Performance",
|
"settings-prfmMode-performance": "Performance",
|
||||||
"settings-prfmMode-battery": "Batterie",
|
"settings-prfmMode-battery": "Batterie",
|
||||||
"settings-none": "Aucun",
|
"settings-none": "Aucun"
|
||||||
"settings-mobileMode": "Mobile mode"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,5 @@
|
||||||
"settings-prfmMode": "mode kinerja:",
|
"settings-prfmMode": "mode kinerja:",
|
||||||
"settings-prfmMode-performance": "kinerja",
|
"settings-prfmMode-performance": "kinerja",
|
||||||
"settings-prfmMode-battery": "Baterai",
|
"settings-prfmMode-battery": "Baterai",
|
||||||
"settings-none": "tidak ada",
|
"settings-none": "tidak ada"
|
||||||
"settings-mobileMode": "Mobile mode"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,5 @@
|
||||||
"settings-prfmMode": "Performance mode:",
|
"settings-prfmMode": "Performance mode:",
|
||||||
"settings-prfmMode-performance": "Performance",
|
"settings-prfmMode-performance": "Performance",
|
||||||
"settings-prfmMode-battery": "Battery",
|
"settings-prfmMode-battery": "Battery",
|
||||||
"settings-none": "None",
|
"settings-none": "None"
|
||||||
"settings-mobileMode": "Mobile mode"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,5 @@
|
||||||
"settings-prfmMode": "Performance mode:",
|
"settings-prfmMode": "Performance mode:",
|
||||||
"settings-prfmMode-performance": "Performance",
|
"settings-prfmMode-performance": "Performance",
|
||||||
"settings-prfmMode-battery": "Battery",
|
"settings-prfmMode-battery": "Battery",
|
||||||
"settings-none": "None",
|
"settings-none": "None"
|
||||||
"settings-mobileMode": "Mobile mode"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,5 @@
|
||||||
"settings-none": "None",
|
"settings-none": "None",
|
||||||
"settings-prfmMode": "Performance mode:",
|
"settings-prfmMode": "Performance mode:",
|
||||||
"settings-prfmMode-performance": "Performance",
|
"settings-prfmMode-performance": "Performance",
|
||||||
"settings-prfmMode-battery": "Battery",
|
"settings-prfmMode-battery": "Battery"
|
||||||
"settings-mobileMode": "Mobile mode"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,5 @@
|
||||||
"settings-prfmMode": "Tryb wydajności:",
|
"settings-prfmMode": "Tryb wydajności:",
|
||||||
"settings-prfmMode-performance": "Wydajny",
|
"settings-prfmMode-performance": "Wydajny",
|
||||||
"settings-prfmMode-battery": "Bateria",
|
"settings-prfmMode-battery": "Bateria",
|
||||||
"settings-none": "Nic/Brak",
|
"settings-none": "Nic/Brak"
|
||||||
"settings-mobileMode": "Mobile mode"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
{
|
{
|
||||||
"no": "Não",
|
"no": "No",
|
||||||
"loading_screen_start": "Iniciando ArmCord…",
|
"loading_screen_start": "Starting ArmCord…",
|
||||||
"loading_screen_offline": "Você parece estar offline. Conecte-se à internet e tente novamente.",
|
"loading_screen_offline": "You appear to be offline. Please connect to the Internet and try again.",
|
||||||
"loading_screen_update": "Uma nova versão do ArmCord está disponível. Atualize para a versão mais recente.",
|
"loading_screen_update": "A new version of ArmCord is available. Please update to the latest version.",
|
||||||
"setup_question1": "Selecione que tipo de instação você quer fazer:",
|
"setup_question1": "Select what kind of setup you want to perform:",
|
||||||
"setup_question1_answer1": "Instalação rápida",
|
"setup_question1_answer1": "Express Setup",
|
||||||
"setup_question1_answer2": "Instalação completa",
|
"setup_question1_answer2": "Full Setup",
|
||||||
"setup_offline": "Você parece estar offline. Conecte-se à internet e tente novamente.",
|
"setup_offline": "You appear to be offline. Please connect to the internet and restart ArmCord.",
|
||||||
"setup_question2": "Escolha o canal/instância do seu Discord",
|
"setup_question2": "Choose your Discord channel/instance:",
|
||||||
"setup_question3": "O ArmCord deve suportar a instalação dos mods de cliente?",
|
"setup_question3": "Should ArmCord handle client mods installation?",
|
||||||
"yes": "Sim",
|
"yes": "Yes",
|
||||||
"next": "Próximo",
|
"next": "Next",
|
||||||
"setup_question4": "Selecione um mod de cliente que você quer instalar:",
|
"setup_question4": "Select a client mod you want to install:",
|
||||||
"setup_question4_clientmodnotice": "Por que não todos eles? Tendo vários mods de cliente ao mesmo tempo pode causar problemas, Se você realmente quer fazer isso mesmo assim, veja o nosso Discord.",
|
"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.",
|
||||||
"settings-theme": "Tema do ArmCord:",
|
"settings-theme": "ArmCord theme:",
|
||||||
"settings-theme-default": "Padrão",
|
"settings-theme-default": "Default",
|
||||||
"settings-theme-native": "Nativo",
|
"settings-theme-native": "Native",
|
||||||
"settings-tray": "Minimizar para a bandeja",
|
"settings-tray": "Minimize to tray",
|
||||||
"settings-patches": "Patches automáticos",
|
"settings-patches": "Automatic Patches",
|
||||||
"settings-channel": "Tipo de Discord:",
|
"settings-channel": "Discord channel:",
|
||||||
"settings-invitewebsocket": "Invite Websocket",
|
"settings-invitewebsocket": "Invite Websocket",
|
||||||
"settings-mod": "Client mod:",
|
"settings-mod": "Client mod:",
|
||||||
"settings-prfmMode": "Performance mode:",
|
"settings-prfmMode": "Performance mode:",
|
||||||
|
@ -26,6 +26,5 @@
|
||||||
"settings-prfmMode-battery": "Battery",
|
"settings-prfmMode-battery": "Battery",
|
||||||
"settings-none": "None",
|
"settings-none": "None",
|
||||||
"settings-save": "Save Settings",
|
"settings-save": "Save Settings",
|
||||||
"settings-updater": "Check for updates",
|
"settings-updater": "Check for updates"
|
||||||
"settings-mobileMode": "Mobile mode"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,5 @@
|
||||||
"settings-prfmMode-battery": "Батарея",
|
"settings-prfmMode-battery": "Батарея",
|
||||||
"settings-none": "Ничего",
|
"settings-none": "Ничего",
|
||||||
"settings-save": "Сохранить настройки",
|
"settings-save": "Сохранить настройки",
|
||||||
"settings-updater": "Проверить наличие обновлений",
|
"settings-updater": "Проверить наличие обновлений"
|
||||||
"settings-mobileMode": "Mobile mode"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,5 @@
|
||||||
"settings-mod": "ไคลแอนต์มอด:",
|
"settings-mod": "ไคลแอนต์มอด:",
|
||||||
"settings-none": "ไม่มี",
|
"settings-none": "ไม่มี",
|
||||||
"settings-save": "บันทึกการตั้งค่า",
|
"settings-save": "บันทึกการตั้งค่า",
|
||||||
"settings-updater": "ตรวจหาการอัปเดต",
|
"settings-updater": "ตรวจหาการอัปเดต"
|
||||||
"settings-mobileMode": "Mobile mode"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[aria-label~="Mute"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
[aria-label~="Deafen"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
|
@ -31,6 +31,7 @@
|
||||||
<option value="stable">Stable</option>
|
<option value="stable">Stable</option>
|
||||||
<option value="canary">Canary</option>
|
<option value="canary">Canary</option>
|
||||||
<option value="ptb">PTB</option>
|
<option value="ptb">PTB</option>
|
||||||
|
<option value="foss">Fosscord</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-center setup-ask" id="setup_question3">
|
<p class="text-center setup-ask" id="setup_question3">
|
||||||
|
@ -120,7 +121,6 @@
|
||||||
automaticPatches: false,
|
automaticPatches: false,
|
||||||
mods: "cumcord",
|
mods: "cumcord",
|
||||||
inviteWebsocket: true,
|
inviteWebsocket: true,
|
||||||
mobileMode: false,
|
|
||||||
trayIcon: "ac_plug_colored",
|
trayIcon: "ac_plug_colored",
|
||||||
performanceMode: "none"
|
performanceMode: "none"
|
||||||
});
|
});
|
||||||
|
@ -148,8 +148,8 @@
|
||||||
windowStyle: "default",
|
windowStyle: "default",
|
||||||
channel: options.channel,
|
channel: options.channel,
|
||||||
armcordCSP: true,
|
armcordCSP: true,
|
||||||
|
autoLaunch: true,
|
||||||
minimizeToTray: true,
|
minimizeToTray: true,
|
||||||
mobileMode: false,
|
|
||||||
automaticPatches: false,
|
automaticPatches: false,
|
||||||
performanceMode: "none",
|
performanceMode: "none",
|
||||||
trayIcon: "ac_plug_colored",
|
trayIcon: "ac_plug_colored",
|
||||||
|
@ -165,7 +165,7 @@
|
||||||
armcordCSP: true,
|
armcordCSP: true,
|
||||||
minimizeToTray: true,
|
minimizeToTray: true,
|
||||||
automaticPatches: false,
|
automaticPatches: false,
|
||||||
mobileMode: false,
|
autoLaunch: true,
|
||||||
mods: "none",
|
mods: "none",
|
||||||
performanceMode: "none",
|
performanceMode: "none",
|
||||||
trayIcon: "ac_plug_colored",
|
trayIcon: "ac_plug_colored",
|
||||||
|
|
|
@ -58,6 +58,9 @@
|
||||||
case "ptb":
|
case "ptb":
|
||||||
window.location.replace("https://ptb.discord.com/app");
|
window.location.replace("https://ptb.discord.com/app");
|
||||||
break;
|
break;
|
||||||
|
case "foss":
|
||||||
|
window.location.replace("https://dev.fosscord.com/app");
|
||||||
|
break;
|
||||||
case undefined:
|
case undefined:
|
||||||
window.location.replace("https://discord.com/app");
|
window.location.replace("https://discord.com/app");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -50,7 +50,7 @@ export function registerIpc() {
|
||||||
var height= await getWindowState("height") ?? 600;
|
var height= await getWindowState("height") ?? 600;
|
||||||
var isMaximized = await getWindowState("isMaximized") ?? false;
|
var isMaximized = await getWindowState("isMaximized") ?? false;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("[Window state manager] No window state file found. Fallbacking to default values.")
|
console.log("No window state file found. Fallbacking to default values.")
|
||||||
mainWindow.setSize(800, 600);
|
mainWindow.setSize(800, 600);
|
||||||
}
|
}
|
||||||
if (isMaximized) {
|
if (isMaximized) {
|
||||||
|
@ -58,7 +58,7 @@ export function registerIpc() {
|
||||||
mainWindow.maximize()
|
mainWindow.maximize()
|
||||||
} else {
|
} else {
|
||||||
mainWindow.setSize(width, height);
|
mainWindow.setSize(width, height);
|
||||||
console.log("[Window state manager] Not maximized.")
|
console.log("Not maximized.")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ipcMain.on("restart", (event, arg) => {
|
ipcMain.on("restart", (event, arg) => {
|
||||||
|
@ -83,9 +83,6 @@ export function registerIpc() {
|
||||||
ipcMain.on("titlebar", (event, arg) => {
|
ipcMain.on("titlebar", (event, arg) => {
|
||||||
event.returnValue = customTitlebar;
|
event.returnValue = customTitlebar;
|
||||||
});
|
});
|
||||||
ipcMain.on("mobileMode", async (event, arg) => {
|
|
||||||
event.returnValue = await getConfig("mobileMode");
|
|
||||||
});
|
|
||||||
ipcMain.on("shouldPatch", async (event, arg) => {
|
ipcMain.on("shouldPatch", async (event, arg) => {
|
||||||
event.returnValue = await getConfig("automaticPatches");
|
event.returnValue = await getConfig("automaticPatches");
|
||||||
});
|
});
|
||||||
|
|
53
src/main.ts
53
src/main.ts
|
@ -26,25 +26,22 @@ if (process.platform == "linux") {
|
||||||
checkIfConfigExists();
|
checkIfConfigExists();
|
||||||
injectElectronFlags();
|
injectElectronFlags();
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
async function init() {
|
switch (await getConfig("windowStyle")) {
|
||||||
switch (await getConfig("windowStyle")) {
|
case "default":
|
||||||
case "default":
|
createCustomWindow();
|
||||||
createCustomWindow();
|
customTitlebar = true;
|
||||||
customTitlebar = true;
|
break;
|
||||||
break;
|
case "native":
|
||||||
case "native":
|
createNativeWindow();
|
||||||
createNativeWindow();
|
break;
|
||||||
break;
|
case "basic":
|
||||||
case "basic":
|
createNativeWindow();
|
||||||
createNativeWindow();
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
createCustomWindow();
|
||||||
createCustomWindow();
|
customTitlebar = true;
|
||||||
customTitlebar = true;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
await init()
|
|
||||||
session.fromPartition("some-partition").setPermissionRequestHandler((webContents, permission, callback) => {
|
session.fromPartition("some-partition").setPermissionRequestHandler((webContents, permission, callback) => {
|
||||||
if (permission === "notifications") {
|
if (permission === "notifications") {
|
||||||
// Approves the permissions request
|
// Approves the permissions request
|
||||||
|
@ -57,6 +54,24 @@ app.whenReady().then(async () => {
|
||||||
});
|
});
|
||||||
app.on("activate", async function () {
|
app.on("activate", async function () {
|
||||||
if (BrowserWindow.getAllWindows().length === 0)
|
if (BrowserWindow.getAllWindows().length === 0)
|
||||||
await init()
|
switch (await getConfig("windowStyle")) {
|
||||||
|
case "default":
|
||||||
|
createCustomWindow();
|
||||||
|
break;
|
||||||
|
case "native":
|
||||||
|
createNativeWindow();
|
||||||
|
break;
|
||||||
|
case "discord":
|
||||||
|
createNativeWindow();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
createCustomWindow();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
console.log("userDataPath = " + app.getPath("userData"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.on("window-all-closed", function () {
|
||||||
|
if (process.platform !== "darwin") app.quit();
|
||||||
|
});
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
import {ipcRenderer} from "electron";
|
|
||||||
import {addStyle} from "../utils";
|
|
||||||
import * as fs from "fs";
|
|
||||||
import * as path from "path";
|
|
||||||
export function injectMobileStuff() {
|
|
||||||
document.addEventListener("DOMContentLoaded", function (event) {
|
|
||||||
const mobileCSS = path.join(__dirname, "../", "/content/css/mobile.css");
|
|
||||||
addStyle(fs.readFileSync(mobileCSS, "utf8"));
|
|
||||||
|
|
||||||
var logo = document.getElementById("window-title");
|
|
||||||
logo!.addEventListener("click", () => {
|
|
||||||
if (ipcRenderer.sendSync("minimizeToTray") === true) {
|
|
||||||
ipcRenderer.send("win-hide");
|
|
||||||
} else if (ipcRenderer.sendSync("minimizeToTray") === false) {
|
|
||||||
ipcRenderer.send("win-quit");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -6,7 +6,6 @@ import * as path from "path";
|
||||||
import {injectTitlebar} from "./titlebar";
|
import {injectTitlebar} from "./titlebar";
|
||||||
import {sleep, addStyle, injectJS, addScript} from "../utils";
|
import {sleep, addStyle, injectJS, addScript} from "../utils";
|
||||||
import {ipcRenderer} from "electron";
|
import {ipcRenderer} from "electron";
|
||||||
import {injectMobileStuff} from "./mobile";
|
|
||||||
var version = ipcRenderer.sendSync("get-app-version", "app-version");
|
var version = ipcRenderer.sendSync("get-app-version", "app-version");
|
||||||
async function updateLang() {
|
async function updateLang() {
|
||||||
if (window.location.href.indexOf("setup.html") > -1) {
|
if (window.location.href.indexOf("setup.html") > -1) {
|
||||||
|
@ -38,9 +37,6 @@ if (window.location.href.indexOf("splash.html") > -1) {
|
||||||
if (ipcRenderer.sendSync("titlebar")) {
|
if (ipcRenderer.sendSync("titlebar")) {
|
||||||
injectTitlebar();
|
injectTitlebar();
|
||||||
}
|
}
|
||||||
if (ipcRenderer.sendSync("mobileMode")) {
|
|
||||||
injectMobileStuff();
|
|
||||||
}
|
|
||||||
sleep(5000).then(async () => {
|
sleep(5000).then(async () => {
|
||||||
const cssPath = path.join(__dirname, "../", "/content/css/discord.css");
|
const cssPath = path.join(__dirname, "../", "/content/css/discord.css");
|
||||||
addStyle(fs.readFileSync(cssPath, "utf8"));
|
addStyle(fs.readFileSync(cssPath, "utf8"));
|
||||||
|
|
|
@ -40,17 +40,12 @@
|
||||||
<input class="tgl tgl-light left" id="websocket" type="checkbox" />
|
<input class="tgl tgl-light left" id="websocket" type="checkbox" />
|
||||||
<label class="tgl-btn left" for="websocket"></label>
|
<label class="tgl-btn left" for="websocket"></label>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
|
||||||
<div class="switch">
|
|
||||||
<label class="header" id="settings-mobileMode">Mobile mode</label>
|
|
||||||
<input class="tgl tgl-light left" id="mobile" type="checkbox" />
|
|
||||||
<label class="tgl-btn left" for="mobile"></label>
|
|
||||||
</div>
|
|
||||||
<div class="switch">
|
<div class="switch">
|
||||||
<select name="channel" id="channel" class="left">
|
<select name="channel" id="channel" class="left">
|
||||||
<option value="stable">Stable</option>
|
<option value="stable">Stable</option>
|
||||||
<option value="canary">Canary</option>
|
<option value="canary">Canary</option>
|
||||||
<option value="ptb">PTB</option>
|
<option value="ptb">PTB</option>
|
||||||
|
<option value="foss">Fosscord</option>
|
||||||
</select>
|
</select>
|
||||||
<p class="header" id="settings-channel">Discord channel:</p>
|
<p class="header" id="settings-channel">Discord channel:</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -94,7 +89,6 @@
|
||||||
);
|
);
|
||||||
document.getElementById("settings-patches").innerHTML = await settings.getLang("settings-patches");
|
document.getElementById("settings-patches").innerHTML = await settings.getLang("settings-patches");
|
||||||
document.getElementById("settings-tray").innerHTML = await settings.getLang("settings-tray");
|
document.getElementById("settings-tray").innerHTML = await settings.getLang("settings-tray");
|
||||||
document.getElementById("settings-mobileMode").innerHTML = await settings.getLang("settings-mobileMode");
|
|
||||||
document.getElementById("settings-theme").innerHTML = await settings.getLang("settings-theme");
|
document.getElementById("settings-theme").innerHTML = await settings.getLang("settings-theme");
|
||||||
//select stuff
|
//select stuff
|
||||||
document.getElementById("mod").options[3].text = await settings.getLang("settings-none");
|
document.getElementById("mod").options[3].text = await settings.getLang("settings-none");
|
||||||
|
@ -113,7 +107,6 @@
|
||||||
document.getElementById("csp").checked = await settings.get("armcordCSP");
|
document.getElementById("csp").checked = await settings.get("armcordCSP");
|
||||||
document.getElementById("tray").checked = await settings.get("minimizeToTray");
|
document.getElementById("tray").checked = await settings.get("minimizeToTray");
|
||||||
document.getElementById("websocket").checked = await settings.get("inviteWebsocket");
|
document.getElementById("websocket").checked = await settings.get("inviteWebsocket");
|
||||||
document.getElementById("mobile").checked = await settings.get("mobileMode");
|
|
||||||
document.getElementById("patches").value = await settings.get("automaticPatches");
|
document.getElementById("patches").value = await settings.get("automaticPatches");
|
||||||
document.getElementById("mod").value = await settings.get("mods");
|
document.getElementById("mod").value = await settings.get("mods");
|
||||||
document.getElementById("channel").value = await settings.get("channel");
|
document.getElementById("channel").value = await settings.get("channel");
|
||||||
|
@ -130,7 +123,6 @@
|
||||||
minimizeToTray: document.getElementById("tray").checked,
|
minimizeToTray: document.getElementById("tray").checked,
|
||||||
automaticPatches: document.getElementById("patches").checked,
|
automaticPatches: document.getElementById("patches").checked,
|
||||||
mods: document.getElementById("mod").value,
|
mods: document.getElementById("mod").value,
|
||||||
mobileMode: document.getElementById("mobile").checked,
|
|
||||||
inviteWebsocket: document.getElementById("websocket").checked,
|
inviteWebsocket: document.getElementById("websocket").checked,
|
||||||
performanceMode: document.getElementById("prfmMode").value,
|
performanceMode: document.getElementById("prfmMode").value,
|
||||||
trayIcon: document.getElementById("trayIcon").value,
|
trayIcon: document.getElementById("trayIcon").value,
|
||||||
|
|
|
@ -2,4 +2,22 @@ import {app} from "electron";
|
||||||
import {mainWindow} from "./window";
|
import {mainWindow} from "./window";
|
||||||
//https://github.com/electron/electron/issues/1334#issuecomment-716080005
|
//https://github.com/electron/electron/issues/1334#issuecomment-716080005
|
||||||
// TO-DO add more
|
// TO-DO add more
|
||||||
|
app.on("web-contents-created", (webContentsCreatedEvent, webContents) => {
|
||||||
|
webContents.on("before-input-event", (beforeInputEvent, input) => {
|
||||||
|
// console.log('Main console::', input)
|
||||||
|
const {code, alt, control, shift, meta} = input;
|
||||||
|
// Shortcut: toggle devTools
|
||||||
|
if (shift && control && !alt && !meta && code === "KeyI") {
|
||||||
|
mainWindow.webContents.toggleDevTools();
|
||||||
|
}
|
||||||
|
// Shortcut: window reload
|
||||||
|
if (shift && control && !alt && !meta && code === "KeyR") {
|
||||||
|
mainWindow.reload();
|
||||||
|
}
|
||||||
|
// Shortcut: app reload
|
||||||
|
if (alt && control && !shift && !meta && code === "KeyR") {
|
||||||
|
app.relaunch();
|
||||||
|
app.exit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
12
src/tray.ts
12
src/tray.ts
|
@ -1,5 +1,5 @@
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { app, Menu, Tray, nativeImage} from "electron";
|
import { app, Menu, Tray } from "electron";
|
||||||
import { mainWindow } from "./window";
|
import { mainWindow } from "./window";
|
||||||
import { getConfig, getConfigLocation, setWindowState } from "./utils";
|
import { getConfig, getConfigLocation, setWindowState } from "./utils";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
@ -7,13 +7,10 @@ import { createSettingsWindow } from "./settings/main";
|
||||||
let tray: any = null;
|
let tray: any = null;
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
let finishedSetup = (await getConfig("doneSetup"));
|
let finishedSetup = (await getConfig("doneSetup"));
|
||||||
var trayIcon = (await getConfig("trayIcon")) ?? "ac_plug_colored";
|
|
||||||
let trayPath = nativeImage.createFromPath(path.join(__dirname, "../", `/assets/${trayIcon}.png`));
|
|
||||||
if(process.platform === "darwin" && trayPath.getSize().height > 22)
|
|
||||||
trayPath = trayIcon.resize({height: 22});
|
|
||||||
if ((await getConfig("windowStyle")) == "basic") {
|
if ((await getConfig("windowStyle")) == "basic") {
|
||||||
var clientName = (await getConfig("clientName")) ?? "ArmCord";
|
var clientName = (await getConfig("clientName")) ?? "ArmCord";
|
||||||
tray = new Tray(trayPath);
|
var trayIcon = (await getConfig("trayIcon")) ?? "ac_plug_colored";
|
||||||
|
tray = new Tray(path.join(__dirname, "../", `/assets/${trayIcon}.png`));
|
||||||
const contextMenu = function () {
|
const contextMenu = function () {
|
||||||
if (finishedSetup == false) {
|
if (finishedSetup == false) {
|
||||||
return Menu.buildFromTemplate([
|
return Menu.buildFromTemplate([
|
||||||
|
@ -60,7 +57,8 @@ app.whenReady().then(async () => {
|
||||||
tray.setContextMenu(contextMenu);
|
tray.setContextMenu(contextMenu);
|
||||||
} else {
|
} else {
|
||||||
var clientName = (await getConfig("clientName")) ?? "ArmCord";
|
var clientName = (await getConfig("clientName")) ?? "ArmCord";
|
||||||
tray = new Tray(trayPath);
|
var trayIcon = (await getConfig("trayIcon")) ?? "ac_plug_colored";
|
||||||
|
tray = new Tray(path.join(__dirname, "../", `/assets/${trayIcon}.png`));
|
||||||
if (finishedSetup == false) {
|
if (finishedSetup == false) {
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
{
|
{
|
||||||
|
|
105
src/utils.ts
105
src/utils.ts
|
@ -4,7 +4,7 @@ import path from "path";
|
||||||
export var firstRun: boolean;
|
export var firstRun: boolean;
|
||||||
export var isSetup: boolean;
|
export var isSetup: boolean;
|
||||||
export var contentPath: string;
|
export var contentPath: string;
|
||||||
//utility functions that are used all over the codebase or just too obscure to be put in the file used in
|
//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) {
|
export function addStyle(styleString: string) {
|
||||||
const style = document.createElement("style");
|
const style = document.createElement("style");
|
||||||
style.textContent = styleString;
|
style.textContent = styleString;
|
||||||
|
@ -43,7 +43,6 @@ export function setup() {
|
||||||
mods: "cumcord",
|
mods: "cumcord",
|
||||||
performanceMode: "none",
|
performanceMode: "none",
|
||||||
inviteWebsocket: true,
|
inviteWebsocket: true,
|
||||||
mobileMode: false,
|
|
||||||
trayIcon: "ac_plug_colored",
|
trayIcon: "ac_plug_colored",
|
||||||
doneSetup: false
|
doneSetup: false
|
||||||
};
|
};
|
||||||
|
@ -105,7 +104,9 @@ export async function injectElectronFlags() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export async function setLang(language: string) {
|
export async function setLang(language: string) {
|
||||||
const langConfigFile = path.join(app.getPath("userData"), "/storage/") + "lang.json";
|
const userDataPath = app.getPath("userData");
|
||||||
|
const storagePath = path.join(userDataPath, "/storage/");
|
||||||
|
const langConfigFile = storagePath + "lang.json";
|
||||||
if (!fs.existsSync(langConfigFile)) {
|
if (!fs.existsSync(langConfigFile)) {
|
||||||
fs.writeFileSync(langConfigFile, "{}", "utf-8");
|
fs.writeFileSync(langConfigFile, "{}", "utf-8");
|
||||||
}
|
}
|
||||||
|
@ -139,15 +140,7 @@ export async function getLang(object: string) {
|
||||||
}
|
}
|
||||||
let rawdata = fs.readFileSync(langPath, "utf-8");
|
let rawdata = fs.readFileSync(langPath, "utf-8");
|
||||||
let parsed = JSON.parse(rawdata);
|
let parsed = JSON.parse(rawdata);
|
||||||
if (parsed[object] == undefined) {
|
return parsed[object];
|
||||||
console.log(object + " is undefined in " + language)
|
|
||||||
langPath = path.join(__dirname, "../", "/assets/lang/en-US.json");
|
|
||||||
rawdata = fs.readFileSync(langPath, "utf-8");
|
|
||||||
parsed = JSON.parse(rawdata);
|
|
||||||
return parsed[object]
|
|
||||||
} else {
|
|
||||||
return parsed[object];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//ArmCord Window State manager
|
//ArmCord Window State manager
|
||||||
|
@ -172,8 +165,9 @@ export async function getWindowState(object: string) {
|
||||||
const settingsFile = storagePath + "window.json";
|
const settingsFile = storagePath + "window.json";
|
||||||
let rawdata = fs.readFileSync(settingsFile, "utf-8");
|
let rawdata = fs.readFileSync(settingsFile, "utf-8");
|
||||||
let returndata = JSON.parse(rawdata);
|
let returndata = JSON.parse(rawdata);
|
||||||
console.log("[Window state manager] " + object + ": " + returndata[object]);
|
console.log(object + ": " + returndata[object]);
|
||||||
return returndata[object];
|
return returndata[object];
|
||||||
|
|
||||||
}
|
}
|
||||||
//ArmCord Settings/Storage manager
|
//ArmCord Settings/Storage manager
|
||||||
|
|
||||||
|
@ -184,36 +178,65 @@ export interface Settings {
|
||||||
minimizeToTray: boolean;
|
minimizeToTray: boolean;
|
||||||
automaticPatches: boolean;
|
automaticPatches: boolean;
|
||||||
mods: string;
|
mods: string;
|
||||||
mobileMode: boolean,
|
|
||||||
performanceMode: string;
|
performanceMode: string;
|
||||||
inviteWebsocket: boolean;
|
inviteWebsocket: boolean;
|
||||||
trayIcon: string;
|
trayIcon: string;
|
||||||
doneSetup: boolean;
|
doneSetup: boolean;
|
||||||
}
|
}
|
||||||
export function getConfigLocation() {
|
|
||||||
const userDataPath = app.getPath("userData");
|
|
||||||
const storagePath = path.join(userDataPath, "/storage/");
|
|
||||||
return storagePath + "settings.json";
|
|
||||||
}
|
|
||||||
export async function getConfig(object: string) {
|
export async function getConfig(object: string) {
|
||||||
let rawdata = fs.readFileSync(getConfigLocation(), "utf-8");
|
try {
|
||||||
let returndata = JSON.parse(rawdata);
|
const userDataPath = app.getPath("userData");
|
||||||
console.log("[Config manager] " + object + ": " + returndata[object]);
|
const storagePath = path.join(userDataPath, "/storage/");
|
||||||
return returndata[object];
|
const settingsFile = storagePath + "settings.json";
|
||||||
|
let rawdata = fs.readFileSync(settingsFile, "utf-8");
|
||||||
|
let returndata = JSON.parse(rawdata);
|
||||||
|
console.log(object + ": " + returndata[object]);
|
||||||
|
return returndata[object];
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Config probably doesn't exist yet. Returning setup value.");
|
||||||
|
firstRun = true;
|
||||||
|
return "setup";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export async function getConfigLocation() {
|
||||||
|
try {
|
||||||
|
const userDataPath = app.getPath("userData");
|
||||||
|
const storagePath = path.join(userDataPath, "/storage/");
|
||||||
|
return storagePath + "settings.json";
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Config probably doesn't exist yet. Returning setup value.");
|
||||||
|
firstRun = true;
|
||||||
|
return "setup";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export async function setConfig(object: string, toSet: any) {
|
export async function setConfig(object: string, toSet: any) {
|
||||||
let rawdata = fs.readFileSync(getConfigLocation(), "utf-8");
|
try {
|
||||||
let parsed = JSON.parse(rawdata);
|
const userDataPath = app.getPath("userData");
|
||||||
parsed[object] = toSet;
|
const storagePath = path.join(userDataPath, "/storage/");
|
||||||
let toSave = JSON.stringify(parsed);
|
const settingsFile = storagePath + "settings.json";
|
||||||
fs.writeFileSync(getConfigLocation(), toSave, "utf-8");
|
let rawdata = fs.readFileSync(settingsFile, "utf-8");
|
||||||
|
let parsed = JSON.parse(rawdata);
|
||||||
|
parsed[object] = toSet;
|
||||||
|
let toSave = JSON.stringify(parsed);
|
||||||
|
fs.writeFileSync(settingsFile, toSave, "utf-8");
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Config probably doesn't exist yet. Returning setup value.");
|
||||||
|
firstRun = true;
|
||||||
|
return "setup";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export async function setConfigBulk(object: Settings) {
|
export async function setConfigBulk(object: Settings) {
|
||||||
const userDataPath = app.getPath("userData");
|
try {
|
||||||
const storagePath = path.join(userDataPath, "/storage/");
|
const userDataPath = app.getPath("userData");
|
||||||
const settingsFile = storagePath + "settings.json";
|
const storagePath = path.join(userDataPath, "/storage/");
|
||||||
let toSave = JSON.stringify(object);
|
const settingsFile = storagePath + "settings.json";
|
||||||
fs.writeFileSync(settingsFile, toSave, "utf-8");
|
let toSave = JSON.stringify(object);
|
||||||
|
fs.writeFileSync(settingsFile, toSave, "utf-8");
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Config probably doesn't exist yet. Returning setup value.");
|
||||||
|
firstRun = true;
|
||||||
|
return "setup";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export async function checkIfConfigExists() {
|
export async function checkIfConfigExists() {
|
||||||
const userDataPath = app.getPath("userData");
|
const userDataPath = app.getPath("userData");
|
||||||
|
@ -227,14 +250,26 @@ export async function checkIfConfigExists() {
|
||||||
}
|
}
|
||||||
console.log("First run of the ArmCord. Starting setup.");
|
console.log("First run of the ArmCord. Starting setup.");
|
||||||
setup();
|
setup();
|
||||||
firstRun = true;
|
isSetup = true;
|
||||||
|
contentPath = path.join(__dirname, "/content/setup.html");
|
||||||
|
if (!contentPath.includes("ts-out")) {
|
||||||
|
contentPath = path.join(__dirname, "/ts-out/content/setup.html");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((await getConfig("doneSetup")) == false) {
|
if ((await getConfig("doneSetup")) == false) {
|
||||||
console.log("First run of the ArmCord. Starting setup.");
|
console.log("First run of the ArmCord. Starting setup.");
|
||||||
setup();
|
setup();
|
||||||
firstRun = true;
|
isSetup = true;
|
||||||
|
contentPath = path.join(__dirname, "/content/setup.html");
|
||||||
|
if (!contentPath.includes("ts-out")) {
|
||||||
|
contentPath = path.join(__dirname, "/ts-out/content/setup.html");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("ArmCord has been run before. Skipping setup.");
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,16 +25,12 @@ async function doAfterDefiningTheWindow() {
|
||||||
var ignoreProtocolWarning = await getConfig("ignoreProtocolWarning");
|
var ignoreProtocolWarning = await getConfig("ignoreProtocolWarning");
|
||||||
checkIfConfigIsBroken();
|
checkIfConfigIsBroken();
|
||||||
registerIpc();
|
registerIpc();
|
||||||
if (await getConfig("mobileMode")) {
|
|
||||||
mainWindow.webContents.userAgent = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.149 Mobile Safari/537.36"
|
|
||||||
} else {
|
|
||||||
// A little sloppy but it works :p
|
|
||||||
if (osType == 'Windows_NT') {
|
|
||||||
osType = "Windows " + os.release().split('.')[0] + " (" + os.release() + ")";
|
|
||||||
}
|
|
||||||
mainWindow.webContents.userAgent = `Mozilla/5.0 (X11; ${osType} ${os.arch()}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36`; //fake useragent for screenshare to work
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// A little sloppy but it works :p
|
||||||
|
if (osType == 'Windows_NT') {
|
||||||
|
osType = "Windows " + os.release().split('.')[0] + " (" + os.release() + ")";
|
||||||
|
}
|
||||||
|
mainWindow.webContents.userAgent = `Mozilla/5.0 (X11; ${osType} ${os.arch()}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36`; //fake useragent for screenshare to work
|
||||||
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
|
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
|
||||||
if (url.startsWith("https:" || url.startsWith("http:") || url.startsWith("mailto:"))) {
|
if (url.startsWith("https:" || url.startsWith("http:") || url.startsWith("mailto:"))) {
|
||||||
shell.openExternal(url);
|
shell.openExternal(url);
|
||||||
|
@ -118,14 +114,36 @@ async function doAfterDefiningTheWindow() {
|
||||||
})
|
})
|
||||||
console.log(contentPath);
|
console.log(contentPath);
|
||||||
if ((await getConfig("inviteWebsocket")) == true) {
|
if ((await getConfig("inviteWebsocket")) == true) {
|
||||||
await startServer();
|
startServer();
|
||||||
}
|
}
|
||||||
if (firstRun) {
|
try {
|
||||||
await setLang(Intl.DateTimeFormat().resolvedOptions().locale)
|
mainWindow.loadFile(contentPath);
|
||||||
mainWindow.setSize(390, 470);
|
if (isSetup) {
|
||||||
await mainWindow.loadFile(path.join(__dirname, "/content/setup.html"));
|
await setLang(Intl.DateTimeFormat().resolvedOptions().locale)
|
||||||
} else {
|
mainWindow.setSize(390, 470);
|
||||||
await mainWindow.loadFile(path.join(__dirname, "/content/splash.html"));
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(
|
||||||
|
"Major error detected while starting up. User is most likely on Windows platform. Fallback to alternative startup."
|
||||||
|
);
|
||||||
|
console.log(process.platform);
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
if (firstRun) {
|
||||||
|
await setLang(Intl.DateTimeFormat().resolvedOptions().locale)
|
||||||
|
mainWindow.setSize(390, 470);
|
||||||
|
mainWindow.loadURL(`file://${__dirname}/content/setup.html`);
|
||||||
|
} else {
|
||||||
|
mainWindow.loadURL(`file://${__dirname}/content/splash.html`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (firstRun) {
|
||||||
|
await setLang(Intl.DateTimeFormat().resolvedOptions().locale)
|
||||||
|
mainWindow.setSize(390, 470);
|
||||||
|
mainWindow.loadURL(`file://${__dirname}/ts-out/content/setup.html`);
|
||||||
|
} else {
|
||||||
|
mainWindow.loadURL(`file://${__dirname}/ts-out/content/splash.html`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export function createCustomWindow() {
|
export function createCustomWindow() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue