From bb8fd9af5e7839b9a77d3a7e4c2ef4dcfbc1c042 Mon Sep 17 00:00:00 2001 From: Noxy <107372460+noxygalaxy@users.noreply.github.com> Date: Mon, 18 Nov 2024 23:27:19 +0200 Subject: [PATCH 1/2] add: steam path auto-detect --- gui/main.js | 65 +++++++++++++++++++++++++---------- gui/src/assets/millennium.ps1 | 0 gui/src/select-theme.html | 31 +---------------- gui/src/style.css | 44 ++++++++---------------- 4 files changed, 63 insertions(+), 77 deletions(-) create mode 100644 gui/src/assets/millennium.ps1 diff --git a/gui/main.js b/gui/main.js index 4fbe34c..85dd881 100644 --- a/gui/main.js +++ b/gui/main.js @@ -3,6 +3,8 @@ const path = require('path'); const fs = require('fs'); const https = require('https'); const AdmZip = require('adm-zip'); +const { exec } = require('child_process'); +const Registry = require('winreg'); function createWindow() { const win = new BrowserWindow({ @@ -26,22 +28,27 @@ function createWindow() { const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); -ipcMain.handle('select-steam-path', async () => { - const result = await dialog.showOpenDialog({ - properties: ['openDirectory'], - title: 'Select Steam Installation Directory' - }); +ipcMain.handle('get-steam-path', async () => { + return new Promise((resolve) => { + const regKey = new Registry({ + hive: Registry.HKLM, + key: '\\SOFTWARE\\WOW6432Node\\Valve\\Steam' + }); - if (!result.canceled) { - const selectedPath = result.filePaths[0]; - const steamExePath = path.join(selectedPath, 'steam.exe'); - if (fs.existsSync(steamExePath)) { - return { success: true, path: selectedPath }; - } else { - return { success: false, error: 'Invalid Steam directory. Please select the valid Steam directory.' }; - } - } - return { success: false, error: 'Selection cancelled' }; + regKey.get('InstallPath', (err, item) => { + if (err) { + resolve({ success: false, error: 'Steam registry key not found' }); + return; + } + + const steamPath = item.value; + if (fs.existsSync(path.join(steamPath, 'steam.exe'))) { + resolve({ success: true, path: steamPath }); + } else { + resolve({ success: false, error: 'Steam installation not found at registry path' }); + } + }); + }); }); ipcMain.on('start-installation', async (event, data) => { @@ -140,9 +147,31 @@ ipcMain.on('start-installation', async (event, data) => { sendLog(`Installation failed: ${error.message}`); } - } else if (data.theme === 'SteamTheme') { +} else if (data.theme === 'SteamTheme') { await delay(1000); + if (data.millenniumInstall) { + sendLog('Starting Millennium installation...'); + const powershellCommand = `start powershell.exe -ExecutionPolicy Bypass -File "${path.join(__dirname, 'src/assets/millennium.ps1')}"`; + + try { + await new Promise((resolve, reject) => { + exec(powershellCommand, (error, stdout, stderr) => { + if (error) { + sendLog(`Millennium installation error: ${error.message}`); + reject(error); + return; + } + sendLog('Millennium installation completed successfully'); + resolve(); + }); + }); + } catch (error) { + sendLog(`Failed to install Millennium: ${error.message}`); + return; + } + } + const skinsFolder = path.join(data.steamPath, 'steamui', 'skins'); const destinationFolder = path.join(skinsFolder, 'SpaceTheme For Steam'); const tempPath = path.join(process.env.TEMP, 'SpaceTheme_for_Steam.zip'); @@ -187,7 +216,7 @@ ipcMain.on('start-installation', async (event, data) => { } if (!fs.existsSync(skinsFolder)) { - sendLog('Steam skins folder not found. Please install Millennium/Steam first.'); + sendLog('Steam skins folder not found. Please install Millennium first.'); return; } @@ -259,4 +288,4 @@ app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow(); } -}); +}); \ No newline at end of file diff --git a/gui/src/assets/millennium.ps1 b/gui/src/assets/millennium.ps1 new file mode 100644 index 0000000..e69de29 diff --git a/gui/src/select-theme.html b/gui/src/select-theme.html index 564c39d..499634f 100644 --- a/gui/src/select-theme.html +++ b/gui/src/select-theme.html @@ -32,11 +32,7 @@ - - + @@ -137,9 +133,6 @@ const installText = document.querySelector('#install-theme .theme-text'); const resetText = document.querySelector('#reset-theme .theme-text'); const uninstallText = document.querySelector('#uninstall-theme .theme-text'); - const steamPathSelector = document.querySelector('.steam-path-selector'); - const selectSteamPathButton = document.querySelector('.select-steam-path-button'); - const steamPathDisplay = document.getElementById('steam-path-display'); const millenniumInstallWrapper = document.getElementById('install-with'); const millenniumInstallCheckbox = document.getElementById('millennium-install'); millenniumInstallWrapper.style.display = 'none'; @@ -164,7 +157,6 @@ resetText.textContent = `Reset ${selectedTheme}`; uninstallText.textContent = `Uninstall ${selectedTheme}`; - steamPathSelector.style.display = selectedTheme === 'SteamTheme' ? 'flex' : 'none'; millenniumInstallWrapper.style.display = selectedTheme === 'SteamTheme' ? 'flex' : 'none'; if (selectedTheme === 'SteamTheme') { const result = await ipcRenderer.invoke('get-steam-path'); @@ -186,25 +178,6 @@ }); }); - selectSteamPathButton.addEventListener('click', async () => { - try { - const result = await ipcRenderer.invoke('select-steam-path'); - if (result.success) { - selectedSteamPath = result.path; - steamPathDisplay.placeholder = `${result.path}`; - if (selectedOption) { - nextButton.classList.add('available'); - } - } else { - steamPathDisplay.placeholder = 'Error selecting Steam path'; - } - } catch (error) { - steamPathDisplay.placeholder = 'Error selecting Steam path'; - selectedSteamPath = null; - nextButton.classList.remove('available'); - } - }); - const themeOptions = document.querySelectorAll('.theme-option'); const popup = document.getElementById('popup'); let selectedOption = null; @@ -241,8 +214,6 @@ nextButton.addEventListener('click', async () => { if (!nextButton.classList.contains('available')) return; - - const everythingObject = document.querySelector('.everything'); ipcRenderer.send('start-installation', { option: selectedOption, diff --git a/gui/src/style.css b/gui/src/style.css index 8943a0d..f7e5f86 100644 --- a/gui/src/style.css +++ b/gui/src/style.css @@ -301,35 +301,6 @@ body { } -.steam-path-selector { - gap: 6px; - justify-content: space-between; - margin: -6px 0 0; -} - -#steam-path-display { - width: 100%; - padding: 0 12px; - font-weight: 600; - border: 2px solid rgb(60, 58, 61); - border-radius: 8px; - background-color: rgb(30, 30, 30); -} - -.select-steam-path-button { - white-space: nowrap; - padding: 6px 12px; - border: 2px solid rgb(60, 58, 61); - border-radius: 8px; - color: #fff; - background-color: rgb(30, 30, 30); - cursor: pointer; -} -.select-steam-path-button:hover { - background-color: rgb(40, 40, 40); -} - - .theme-options { flex: 1; @@ -381,6 +352,21 @@ body { color: #888; } +@keyframes fadeDown { + from { + opacity: 0; + transform: translateY(-20px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +.install-with.fade-down { + animation: fadeDown 0.3s ease-out; +} + .installation-header { From 61399710791e47dc3c4ab7a3967bb82e69dfc372 Mon Sep 17 00:00:00 2001 From: Noxy <107372460+noxygalaxy@users.noreply.github.com> Date: Tue, 19 Nov 2024 01:51:58 +0200 Subject: [PATCH 2/2] update: colors & checkbox width --- gui/src/style.css | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gui/src/style.css b/gui/src/style.css index f7e5f86..917f392 100644 --- a/gui/src/style.css +++ b/gui/src/style.css @@ -315,7 +315,7 @@ body { flex-direction: column; padding: 0; border-radius: 8px; - background-color: rgb(25, 25, 25); + background-color: rgb(35, 35, 35); } .theme-text { @@ -344,10 +344,6 @@ body { padding: 0 12px 12px; } -.install-with .checkbox-wrapper { - width: 100%; -} - .install-with .checkbox-wrapper p { color: #888; }