Skip to content

Commit

Permalink
feat: finalize steam deck support
Browse files Browse the repository at this point in the history
  • Loading branch information
mmvanheusden committed Jan 22, 2024
1 parent 0d821c0 commit 2f78f34
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 26 deletions.
28 changes: 16 additions & 12 deletions downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function submitForm() {
document.getElementById("dotnetwarning").hidden = true
document.getElementById("dotnetwarning2").hidden = true
document.getElementById("emptywarning").hidden = true
console.info("dotnet found in PATH")
console.info("dotnet is installed and the form is filled in. 馃檶")
// create variables for the form values
const username = document.getElementById("username").value
const password = document.getElementById("password").value
Expand Down Expand Up @@ -127,19 +127,19 @@ function openRelevantPage(target) {
}
break
case "issues":
console.debug("Opened GitHub issues page")
console.debug("Opened GitHub issues page 馃悶")
void electron.shell.openExternal("https://github.com/mmvanheusden/SteamDepotDownloaderGUI/issues/new")
break
case "steamdb":
console.debug("Opened SteamDB instant search page")
console.debug("Opened SteamDB instant search page 馃攳")
void electron.shell.openExternal("https://steamdb.info/instantsearch/")
break
case "donate":
console.debug("Opened donation page")
console.debug("Opened donation page 馃挵")
void electron.shell.openExternal("https://liberapay.com/barbapapa/")
break
case "instructions":
console.debug("Opened instructions page")
console.debug("Opened instructions page 馃摎")
void electron.shell.openExternal("https://github.com/mmvanheusden/SteamDepotDownloaderGUI/#how-to-use")
break
default:
Expand All @@ -164,6 +164,7 @@ function fillDefaultValues() {
// [0]: Windows, [1]: macOS [2]: Linux [3]: manual
if (process.platform.toString().includes("linux")) {
document.getElementById("default-os").innerText = "Linux"
document.getElementById("down-dotnet").ariaDisabled = "false"
} else if (process.platform.toString().includes("win")) {
document.getElementById("default-os").innerText = "Windows"
} else if (process.platform.toString().includes("darwin")) {
Expand Down Expand Up @@ -259,7 +260,7 @@ ipcRenderer.on("ready", async () => {
}

await findDotnet().then(() => {
console.log("dotnet found in PATH!")
console.log("dotnet found in PATH/local directory!")
document.getElementById("dotnet-found").innerText = "Yes"
}).catch((error) => {
console.log(error)
Expand Down Expand Up @@ -288,19 +289,22 @@ platformpath(): ${platformpath()}
ready = false
})

async function steamDeck() {
async function downloadDotnetAuto() {
document.getElementById("down-dotnet").ariaDisabled = "true"
await download("https://download.visualstudio.microsoft.com/download/pr/5226a5fa-8c0b-474f-b79a-8984ad7c5beb/3113ccbf789c9fd29972835f0f334b7a/dotnet-sdk-8.0.100-linux-x64.tar.gz")
console.log("finish download")
console.log("Finished downloading dotnet tarball")
await runCommand(`mkdir -p ${platformpath()}/dotnet`)
await runCommand(`tar -xvf ${platformpath()}/dotnet-sdk-8.0.100-linux-x64.tar.gz -C dotnet`)
console.log("extracted")
await runCommand("./dotnet/dotnet --info")
ipcRenderer.send("ready")
console.log("Finished extracting dotnet tarball")
await findDotnet() // to make it use the newly downloaded dotnet
document.getElementById("down-dotnet").ariaDisabled = "false" // so the button can be pressed again for whatever reason
}

// Add event listeners to the buttons
window.addEventListener("DOMContentLoaded", () => {
document.getElementById("down-dotnet").addEventListener("click", steamDeck)
document.getElementById("down-dotnet").addEventListener("click", () => {
if (document.getElementById("down-dotnet").ariaDisabled === "false") downloadDotnetAuto()
})
document.getElementById("dotnetalertbtn").addEventListener("click", () => openRelevantPage("dotnet"))
document.getElementById("smbtn1").addEventListener("click", () => openRelevantPage("issues"))
document.getElementById("smbtn2").addEventListener("click", () => openRelevantPage("steamdb"))
Expand Down
12 changes: 7 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,17 @@ <h3><b>Settings</b></h3>
</div>
</div>
<hr>
<h4><b>Experimental settings</b></h4>
<div class="form-group">
<div class="form-group-header">
<label for="os-dropdown">Steam Deck</label>
<label for="os-dropdown">Automatically download dotnet binary</label><br>Linux only. Works for Steam Deck<br>system-wide dotnet has priority over local dotnet.
</div>
Found: <span class="Counter"><code id="dotnet-found" >none</code></span>
<div class="form-group-body">
<div class="btn" type="button" id="down-dotnet">
Download .NET

<div class="form-group-body" >
<div aria-disabled="true" class="btn" type="button" id="down-dotnet">
Auto Download .NET
</div>
Found: <span class="Counter"><code id="dotnet-found" >none</code></span>
</div>
</div>
</form>
Expand Down
17 changes: 13 additions & 4 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/* The grey part */
.settings-surrounding {
display: none;
display: block;
position: fixed;
z-index: 1;
left: 0;
Expand All @@ -31,19 +31,28 @@
overflow: auto;
/*noinspection CssUnresolvedCustomProperty*/
background-color: var(--bgColor-default, var(--color-canvas-default));
margin: 5%;
padding: 25px;
margin-top: 5px;
margin-left: auto;
margin-right: auto;
padding: 13px 20px 13px;
border: 1px solid #b4dede;
width: 90vw; /* 90vw -> 90% */
height: 90vh; /* 90vh -> 90% */
height: 97vh; /* 90vh -> 90% */
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1), 0 6px 20px rgba(0, 0, 0, 0.1);
}
/* Hide the stupid scrollbar */
.settings-content::-webkit-scrollbar {
display: none;

}

.hide {
display: none;
}

hr {
margin-top: 6px;
margin-bottom: 6px;
border: 0;
height: 1px;
background: #0d1117 linear-gradient(to right, #0d1117, #ccc, #0d1117);
Expand Down
11 changes: 6 additions & 5 deletions utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const {exec} = require("child_process");
const {existsSync} = require("fs");
var defaultTerminal = ""
let dotnetPath = ""

Expand All @@ -14,6 +12,7 @@ let dotnetPath = ""
* `noDotnet` -> `dotnet` has not been found in the path.
*/
function preDownloadCheck() {
const {exec} = require("child_process")
return new Promise((resolve, reject) => {
// Check if all fields are filled
const formInputs = document.forms["theform"]
Expand Down Expand Up @@ -368,25 +367,27 @@ const forceTerminals = async () => {

// checks if dotnet is found in either system path, or for linux in local path. (for steam deck)
function findDotnet() {
const {exec} = require("child_process")
const {existsSync} = require("fs")
return new Promise((resolve, reject) => {
let command
if (process.platform.toString().includes("win")) {
command = "dotnet.exe"
} else {
command = "dotnet"
}
console.log(`Command is ${command}`)
exec(`${command} --version`, (error) => {
console.log(error)
if (error !== null) { // if there was an error
console.log("Error, trying local dotnet installation")
if (process.platform.toString().includes("linux")) console.log("Dotnet not found in system, trying to detect local dotnet installation..")
if (process.platform.toString().includes("linux") && existsSync(`${platformpath()}/dotnet/dotnet`)) {
console.log("Linux, trying local dotnet installation")
exec(`${platformpath()}/dotnet/dotnet --version`, (error) => {
if (error !== null) { // if there was an error
console.log("no dotnet found at all 馃檧")
reject("noDotnet")
} else { // if there was no error
dotnetPath = `${platformpath()}/dotnet/dotnet`
console.log("Local dotnet installation found. path: " + dotnetPath)
resolve(true)
}
})
Expand Down

0 comments on commit 2f78f34

Please sign in to comment.