Add keybind maker button

This commit is contained in:
smartfrigde 2023-06-22 12:12:29 +02:00
parent 6fd260608a
commit 9607a36c3e
5 changed files with 49 additions and 2 deletions

View file

@ -70,7 +70,7 @@ class WSServer {
if ( if (
origin !== "" && origin !== "" &&
!["https://discord.com", "https://ptb.discord.com", "https://canary.discord.com/"].includes(origin) !["https://discord.com", "https://ptb.discord.com", "https://canary.discord.com"].includes(origin)
) { ) {
log("disallowed origin", origin); log("disallowed origin", origin);

View file

@ -32,7 +32,8 @@
div#acThemes:after, div#acThemes:after,
div#acSettings:after, div#acSettings:after,
div#acForceQuit:after { div#acForceQuit:after,
div#acKeybinds:after {
content: url("https://raw.githubusercontent.com/ArmCord/BrandingStuff/main/ac_white_plug16x.png"); content: url("https://raw.githubusercontent.com/ArmCord/BrandingStuff/main/ac_white_plug16x.png");
margin-right: 5px; margin-right: 5px;
} }

View file

@ -18,6 +18,7 @@ import os from "os";
import path from "path"; import path from "path";
import {createTManagerWindow} from "./themeManager/main"; import {createTManagerWindow} from "./themeManager/main";
import {splashWindow} from "./splash/main"; import {splashWindow} from "./splash/main";
import {createKeybindWindow} from "./keybindMaker/main";
export function registerIpc(): void { export function registerIpc(): void {
ipcMain.on("get-app-path", (event) => { ipcMain.on("get-app-path", (event) => {
event.reply("app-path", app.getAppPath()); event.reply("app-path", app.getAppPath());
@ -130,6 +131,9 @@ export function registerIpc(): void {
ipcMain.on("openManagerWindow", () => { ipcMain.on("openManagerWindow", () => {
createTManagerWindow(); createTManagerWindow();
}); });
ipcMain.on("openKeybindWindow", () => {
createKeybindWindow();
});
ipcMain.on("setting-armcordCSP", async (event) => { ipcMain.on("setting-armcordCSP", async (event) => {
if (await getConfig("armcordCSP")) { if (await getConfig("armcordCSP")) {
event.returnValue = true; event.returnValue = true;

View file

@ -0,0 +1,37 @@
import {BrowserWindow, app, shell} from "electron";
import path from "path";
let keybindWindow: BrowserWindow;
let instance = 0;
export function createKeybindWindow(): void {
console.log("Creating keybind maker window.");
instance += 1;
if (instance > 1) {
if (keybindWindow) {
keybindWindow.show();
keybindWindow.restore();
}
} else {
keybindWindow = new BrowserWindow({
width: 660,
height: 670,
title: `ArmCord Global Keybinds Maker`,
darkTheme: true,
frame: true,
backgroundColor: "#2f3136",
autoHideMenuBar: true,
webPreferences: {
sandbox: false,
preload: path.join(__dirname, "preload.js")
}
});
async function makerLoadPage(): Promise<void> {
keybindWindow.loadURL(`file://${__dirname}/maker.html`);
}
keybindWindow.webContents.setWindowOpenHandler(({url}) => {
shell.openExternal(url);
return {action: "deny"};
});
makerLoadPage();
}
}

View file

@ -94,16 +94,21 @@ setInterval(() => {
const acSettings = advanced.cloneNode(true) as HTMLElement; const acSettings = advanced.cloneNode(true) as HTMLElement;
const tManager = advanced.cloneNode(true) as HTMLElement; const tManager = advanced.cloneNode(true) as HTMLElement;
const fQuit = advanced.cloneNode(true) as HTMLElement; const fQuit = advanced.cloneNode(true) as HTMLElement;
const keybindMaker = advanced.cloneNode(true) as HTMLElement;
acSettings.textContent = "ArmCord"; acSettings.textContent = "ArmCord";
acSettings.id = "acSettings"; acSettings.id = "acSettings";
acSettings.onclick = () => ipcRenderer.send("openSettingsWindow"); acSettings.onclick = () => ipcRenderer.send("openSettingsWindow");
tManager.textContent = "Themes"; tManager.textContent = "Themes";
tManager.id = "acThemes"; tManager.id = "acThemes";
tManager.onclick = () => ipcRenderer.send("openManagerWindow"); tManager.onclick = () => ipcRenderer.send("openManagerWindow");
keybindMaker.textContent = "Global keybinds";
keybindMaker.id = "acKeybinds";
keybindMaker.onclick = () => ipcRenderer.send("openKeybindWindow");
fQuit.textContent = "Force Quit"; fQuit.textContent = "Force Quit";
fQuit.id = "acForceQuit"; fQuit.id = "acForceQuit";
fQuit.onclick = () => ipcRenderer.send("win-quit"); fQuit.onclick = () => ipcRenderer.send("win-quit");
advanced.insertAdjacentElement("afterend", acSettings); advanced.insertAdjacentElement("afterend", acSettings);
advanced.insertAdjacentElement("afterend", tManager); advanced.insertAdjacentElement("afterend", tManager);
advanced.insertAdjacentElement("afterend", keybindMaker);
advanced.insertAdjacentElement("afterend", fQuit); advanced.insertAdjacentElement("afterend", fQuit);
}, 1000); }, 1000);