Skip to content

Commit

Permalink
Merge pull request #11 from noxygalaxy/main
Browse files Browse the repository at this point in the history
fix: Steam path not found
  • Loading branch information
SpaceEnergy authored Nov 13, 2024
2 parents 6cb6a0f + fdc6d74 commit ef8417e
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 9 deletions.
26 changes: 22 additions & 4 deletions gui/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, BrowserWindow, ipcMain } = require('electron');
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
const path = require('path');
const fs = require('fs');
const https = require('https');
Expand Down Expand Up @@ -26,6 +26,24 @@ 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'
});

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' };
});

ipcMain.on('start-installation', async (event, data) => {
const appData = process.env.APPDATA;

Expand Down Expand Up @@ -125,8 +143,8 @@ ipcMain.on('start-installation', async (event, data) => {
} else if (data.theme === 'SteamTheme') {
await delay(1000);

const skinsFolder = 'C:\\Program Files (x86)\\Steam\\steamui\\skins';
const destinationFolder = path.join(skinsFolder, 'SpaceTheme for Steam');
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');
const extractedFolderPath = path.join(skinsFolder, 'Steam-main');

Expand Down Expand Up @@ -169,7 +187,7 @@ ipcMain.on('start-installation', async (event, data) => {
}

if (!fs.existsSync(skinsFolder)) {
sendLog('Steam skins folder not found. Please install Steam first.');
sendLog('Steam skins folder not found. Please install Millennium/Steam first.');
return;
}

Expand Down
2 changes: 1 addition & 1 deletion gui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "spacetheme-installer",
"private": true,
"version": "1.0.1",
"version": "1.0.2",
"main": "main.js",
"scripts": {
"start": "electron .",
Expand Down
39 changes: 37 additions & 2 deletions gui/src/select-theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
<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 class="popup" id="popup">You didn't select the theme.</div>

Expand Down Expand Up @@ -127,6 +131,10 @@
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');
let selectedSteamPath = null;

themeSelector.addEventListener('click', (e) => {
if (e.target.closest('.dropdown-item')) {
Expand All @@ -146,11 +154,32 @@
resetText.textContent = `Reset ${selectedTheme}`;
uninstallText.textContent = `Uninstall ${selectedTheme}`;

steamPathSelector.style.display = selectedTheme === 'SteamTheme' ? 'flex' : 'none';

dropdownMenu.classList.remove('active');
themeSelector.classList.remove('active');
});
});

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 All @@ -176,7 +205,12 @@
option.classList.add('active');
selectedOption = option.id;
selectedTheme = currentTheme;
nextButton.classList.add('available');

if (currentTheme === 'SteamTheme' && selectedSteamPath) {
nextButton.classList.add('available');
} else if (currentTheme !== 'SteamTheme') {
nextButton.classList.add('available');
}
});
});

Expand All @@ -187,7 +221,8 @@

ipcRenderer.send('start-installation', {
option: selectedOption,
theme: selectedTheme
theme: selectedTheme,
steamPath: selectedSteamPath
});
window.location.href = 'logs.html';
});
Expand Down
32 changes: 31 additions & 1 deletion gui/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,36 @@ 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);
}



.installation-header {
display: flex;
Expand Down Expand Up @@ -494,4 +524,4 @@ body {
.nav-button.next.available {
cursor: pointer;
opacity: 1;
}
}
2 changes: 1 addition & 1 deletion gui/src/version.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const version = 'v1.0.1';
const version = 'v1.0.2';
document.getElementById('version-number').textContent = version;

0 comments on commit ef8417e

Please sign in to comment.