mirror of
				https://github.com/smartfrigde/armcord.git
				synced 2024-08-14 23:56:58 +00:00 
			
		
		
		
	Add transparency option
This commit is contained in:
		
							parent
							
								
									97589220f4
								
							
						
					
					
						commit
						f523f92367
					
				
					 9 changed files with 2338 additions and 46 deletions
				
			
		|  | @ -5,7 +5,7 @@ import {getConfig, checkIfConfigExists, injectElectronFlags} from "./utils"; | |||
| import "./extensions/mods"; | ||||
| import "./extensions/plugin"; | ||||
| import "./tray"; | ||||
| import {createCustomWindow, createNativeWindow} from "./window"; | ||||
| import {createCustomWindow, createNativeWindow, createTransparentWindow} from "./window"; | ||||
| import path from "path"; | ||||
| export var iconPath: string; | ||||
| export var settings: any; | ||||
|  | @ -40,6 +40,9 @@ app.whenReady().then(async () => { | |||
|             case "native": | ||||
|                 createNativeWindow(); | ||||
|                 break; | ||||
|             case "transparent": | ||||
|                 createTransparentWindow(); | ||||
|                 break; | ||||
|             case "basic": | ||||
|                 createNativeWindow(); | ||||
|                 break; | ||||
|  |  | |||
							
								
								
									
										36
									
								
								src/tray.ts
									
										
									
									
									
								
							
							
						
						
									
										36
									
								
								src/tray.ts
									
										
									
									
									
								
							|  | @ -20,9 +20,8 @@ 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("windowStyle")) == "basic") { | ||||
|         var clientName = (await getConfig("clientName")) ?? "ArmCord"; | ||||
|         tray = new Tray(trayPath); | ||||
|  | @ -32,13 +31,13 @@ app.whenReady().then(async () => { | |||
|                     { | ||||
|                         label: `Finish the setup first!`, | ||||
|                         enabled: false | ||||
|                     }, { | ||||
|                     }, | ||||
|                     { | ||||
|                         label: `Quit ${clientName}`, | ||||
|                         click: async function () { | ||||
|                             fs.unlink(await getConfigLocation(), (err) => { | ||||
|                                 if (err)  | ||||
|                                     throw err; | ||||
|                                  | ||||
|                                 if (err) throw err; | ||||
| 
 | ||||
|                                 console.log('Closed during setup. "settings.json" was deleted'); | ||||
|                                 app.quit(); | ||||
|                             }); | ||||
|  | @ -52,7 +51,8 @@ app.whenReady().then(async () => { | |||
|                         click: function () { | ||||
|                             mainWindow.show(); | ||||
|                         } | ||||
|                     }, { | ||||
|                     }, | ||||
|                     { | ||||
|                         label: `Quit ${clientName}`, | ||||
|                         click: function () { | ||||
|                             let [width, height] = mainWindow.getSize(); | ||||
|  | @ -74,13 +74,13 @@ app.whenReady().then(async () => { | |||
|                 { | ||||
|                     label: `Finish the setup first!`, | ||||
|                     enabled: false | ||||
|                 }, { | ||||
|                 }, | ||||
|                 { | ||||
|                     label: `Quit ${clientName}`, | ||||
|                     click: async function () { | ||||
|                         fs.unlink(await getConfigLocation(), (err) => { | ||||
|                             if (err)  | ||||
|                                 throw err; | ||||
|                              | ||||
|                             if (err) throw err; | ||||
| 
 | ||||
|                             console.log('Closed during setup. "settings.json" was deleted'); | ||||
|                             app.quit(); | ||||
|                         }); | ||||
|  | @ -109,15 +109,18 @@ app.whenReady().then(async () => { | |||
|                     click: function () { | ||||
|                         createSettingsWindow(); | ||||
|                     } | ||||
|                 }, { | ||||
|                 }, | ||||
|                 { | ||||
|                     label: "Support Discord Server", | ||||
|                     click: function () { | ||||
|                         mainWindow.show(); | ||||
|                         mainWindow.loadURL("https://discord.gg/TnhxcqynZ2"); | ||||
|                     } | ||||
|                 }, { | ||||
|                 }, | ||||
|                 { | ||||
|                     type: "separator" | ||||
|                 }, { | ||||
|                 }, | ||||
|                 { | ||||
|                     label: `Quit ${clientName}`, | ||||
|                     click: function () { | ||||
|                         app.quit(); | ||||
|  | @ -126,7 +129,8 @@ app.whenReady().then(async () => { | |||
|             ]); | ||||
|             tray.setContextMenu(contextMenu); | ||||
|         } | ||||
|     } tray.setToolTip(clientName); | ||||
|     } | ||||
|     tray.setToolTip(clientName); | ||||
|     tray.on("click", function () { | ||||
|         mainWindow.show(); | ||||
|     }); | ||||
|  |  | |||
|  | @ -1,8 +1,10 @@ | |||
| import * as fs from "fs"; | ||||
| import {app, dialog} from "electron"; | ||||
| import path from "path"; | ||||
| import vibe from "@pyke/vibe"; | ||||
| export var firstRun: boolean; | ||||
| export var contentPath: string; | ||||
| export var transparency: boolean; | ||||
| //utility 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) { | ||||
|     const style = document.createElement("style"); | ||||
|  | @ -118,6 +120,11 @@ export async function injectElectronFlags() { | |||
|         default: | ||||
|             console.log("No performance modes set"); | ||||
|     } | ||||
|     if ((await getConfig("windowStyle")) == "transparent") { | ||||
|         console.log("Transparent mode enabled"); | ||||
|         vibe.setup(app); | ||||
|         transparency = true; | ||||
|     } | ||||
| } | ||||
| export async function setLang(language: string) { | ||||
|     const langConfigFile = path.join(app.getPath("userData"), "/storage/") + "lang.json"; | ||||
|  |  | |||
|  | @ -4,7 +4,16 @@ | |||
| // I'm sorry for this mess but I'm not sure how to fix it.
 | ||||
| import {BrowserWindow, shell, app, dialog, nativeImage} from "electron"; | ||||
| import path from "path"; | ||||
| import {checkIfConfigIsBroken, firstRun, getConfig, contentPath, setConfig, setLang, setWindowState} from "./utils"; | ||||
| import { | ||||
|     checkIfConfigIsBroken, | ||||
|     firstRun, | ||||
|     getConfig, | ||||
|     contentPath, | ||||
|     setConfig, | ||||
|     setLang, | ||||
|     setWindowState, | ||||
|     transparency | ||||
| } from "./utils"; | ||||
| import {registerIpc} from "./ipc"; | ||||
| import {setMenu} from "./menu"; | ||||
| import * as fs from "fs"; | ||||
|  | @ -12,6 +21,7 @@ import startServer from "./socket"; | |||
| import contextMenu from "electron-context-menu"; | ||||
| import os from "os"; | ||||
| import {tray} from "./tray"; | ||||
| import vibe from "@pyke/vibe"; | ||||
| import {iconPath} from "./main"; | ||||
| export let mainWindow: BrowserWindow; | ||||
| export let inviteWindow: BrowserWindow; | ||||
|  | @ -41,6 +51,11 @@ contextMenu({ | |||
|     ] | ||||
| }); | ||||
| async function doAfterDefiningTheWindow() { | ||||
|     if (transparency) { | ||||
|         vibe.applyEffect(mainWindow, "acrylic"); | ||||
|         vibe.setDarkMode(mainWindow); | ||||
|         mainWindow.show(); | ||||
|     } | ||||
|     var ignoreProtocolWarning = await getConfig("ignoreProtocolWarning"); | ||||
|     await checkIfConfigIsBroken(); | ||||
|     registerIpc(); | ||||
|  | @ -54,18 +69,18 @@ async function doAfterDefiningTheWindow() { | |||
|         } | ||||
|         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
 | ||||
|     } | ||||
|     const gotTheLock = app.requestSingleInstanceLock() | ||||
|     const gotTheLock = app.requestSingleInstanceLock(); | ||||
| 
 | ||||
|     if (!gotTheLock) { | ||||
|     app.quit() | ||||
|         app.quit(); | ||||
|     } else { | ||||
|     app.on('second-instance', (event, commandLine, workingDirectory) => { | ||||
|         // i love stack overflow
 | ||||
|         if (mainWindow) { | ||||
|         mainWindow.restore() | ||||
|         mainWindow.focus() | ||||
|         } | ||||
|     }) | ||||
|         app.on("second-instance", (event, commandLine, workingDirectory) => { | ||||
|             // i love stack overflow
 | ||||
|             if (mainWindow) { | ||||
|                 mainWindow.restore(); | ||||
|                 mainWindow.focus(); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|     mainWindow.webContents.setWindowOpenHandler(({url}) => { | ||||
|         if (url.startsWith("https:" || url.startsWith("http:") || url.startsWith("mailto:"))) { | ||||
|  | @ -252,7 +267,25 @@ export function createNativeWindow() { | |||
|     }); | ||||
|     doAfterDefiningTheWindow(); | ||||
| } | ||||
| 
 | ||||
| export function createTransparentWindow() { | ||||
|     mainWindow = new BrowserWindow({ | ||||
|         width: 300, | ||||
|         height: 350, | ||||
|         title: "ArmCord", | ||||
|         darkTheme: true, | ||||
|         icon: iconPath, | ||||
|         frame: true, | ||||
|         backgroundColor: "#00000000", | ||||
|         show: false, | ||||
|         autoHideMenuBar: true, | ||||
|         webPreferences: { | ||||
|             sandbox: false, | ||||
|             preload: path.join(__dirname, "preload/preload.js"), | ||||
|             spellcheck: true | ||||
|         } | ||||
|     }); | ||||
|     doAfterDefiningTheWindow(); | ||||
| } | ||||
| export function createInviteWindow() { | ||||
|     inviteWindow = new BrowserWindow({ | ||||
|         width: 800, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue