Skip to content
This repository was archived by the owner on Mar 9, 2025. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceEnergy committed Nov 19, 2024
2 parents 740389a + 630f92c commit a38d0a0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 77 deletions.
65 changes: 47 additions & 18 deletions gui/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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) => {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -259,4 +288,4 @@ app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
Empty file added gui/src/assets/millennium.ps1
Empty file.
31 changes: 1 addition & 30 deletions gui/src/select-theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@
<div class="dropdown-item" id="discord-theme">DiscordTheme</div>
<div class="dropdown-item" id="steam-theme">SteamTheme</div>
</div>
</div>
<div class="steam-path-selector" style="display: none;">
<input id="steam-path-display" placeholder="" disabled></input>
<button class="select-steam-path-button">Select Steam Path</button>
</div>
</div>

<div class="popup" id="popup">You didn't select the theme.</div>

Expand Down Expand Up @@ -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';
Expand All @@ -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');
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
44 changes: 15 additions & 29 deletions gui/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -377,6 +348,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 {
Expand Down

0 comments on commit a38d0a0

Please sign in to comment.