Skip to content

Commit

Permalink
Add unix detection
Browse files Browse the repository at this point in the history
Opens the slimetora wiki if detecting a unix system, since some stuff needs to be done before slimetora can interact with the trackers
  • Loading branch information
JovannMC committed Nov 16, 2024
1 parent be06254 commit f403524
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@
"message": "An unexpected error occurred, please check log files for more information."
},
"onboarding": {
"unix": {
"title": "Unix detected",
"message": "It seems you are running SlimeTora on a Unix-based system, some extra setup is required before continuing.\r\n\r\nThe SlimeTora wiki will open after this dialog to guide you through the necessary steps."
},
"complete": {
"title": "Onboarding complete!",
"message": "SlimeTora has been successfully set up! You can always reopen the onboarding screen in the program settings. After this dialog, the program will open the wiki page for you to read more information.\r\n\r\nEnjoy!"
Expand Down Expand Up @@ -335,7 +339,7 @@
"title": "Update available",
"message": "New translation updates available: {files}.",
"detail": "Would you like to download them?",
"buttons":{
"buttons": {
"yes": "Download",
"no": "Cancel"
}
Expand Down
7 changes: 5 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,7 @@ async function showMessage(
type: playErrorSound ? "error" : "none",
};

show(options);
return true;
return show(options);
}

async function showError(
Expand Down Expand Up @@ -513,6 +512,10 @@ ipcMain.on("update-titles", async () => {
}
});

ipcMain.handle("get-os", () => {
return process.platform;
});

ipcMain.handle("show-message", async (_event, arg) => {
const {
title,
Expand Down
2 changes: 1 addition & 1 deletion src/static/html/onboarding.html
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ <h2 class="title is-2 has-text-centered is-spaced" data-i18n="onboarding.steps.s
/>
<img
src="../images/onboarding/zrock35.webp"
alt="ZRock35 YouTube channel & calibration"
alt="ZRock35 YouTube channel & calibration video"
style="height: 210px"
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/static/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ document.addEventListener("DOMContentLoaded", async function () {
});

window.addEventListener("storage", (event) => {
window.log(`Storage event: "${event.key}" changed to "${event.newValue}"`);
window.log(`localStorage event: "${event.key}" changed to "${event.newValue}"`);

if (event.key === "autodetect" && event.newValue === "true") {
autodetect();
Expand Down
17 changes: 13 additions & 4 deletions src/static/js/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Onboarding {
// Ensure the current step is visible
const currentStep = this.steps[index];
if (currentStep && currentStep.style.display !== "flex") {
window.log(`Step "${currentStep.id}" is not visible, forcing display`);
window.log(`Step "${currentStep.id}" is not visible (for some reason), forcing display`);
currentStep.style.display = "flex";
}
}
Expand All @@ -53,6 +53,7 @@ class Onboarding {
if (button) {
button.addEventListener("click", async () => {
window.log(`Button with ID "${buttonId}" clicked`);

if (targetStepId === "finish") {
window.log("Onboarding process complete");
await showMessageBox(
Expand All @@ -64,9 +65,10 @@ class Onboarding {
);
window.open("https://github.com/OCSYT/SlimeTora/wiki/", "_blank");
window.close();
} else {
this.goToStep(targetStepId);
return;
}

this.goToStep(targetStepId);
});
} else {
window.warn(`Button with ID "${buttonId}" not found`);
Expand Down Expand Up @@ -193,6 +195,13 @@ document.addEventListener("DOMContentLoaded", async () => {
localStorage.setItem("language", language);
await updateTranslations();
}

// Check if user is running on a Unix-based system
const os = await window.ipc.invoke("get-os", null);
if (os === "win32" || os !== "darwin") {
await showMessageBox("dialogs.onboarding.unix.title", "dialogs.onboarding.unix.message", true, true, true);
window.open("https://github.com/OCSYT/SlimeTora/wiki/Getting-Started#linux-specific-prerequisites", "_blank");
}
});

function addEventListeners() {
Expand All @@ -204,7 +213,7 @@ function addEventListeners() {
}

window.addEventListener("storage", (event) => {
window.log(`Storage event: "${event.key}" changed to: ${event.newValue}`);
window.log(`localStorage event: "${event.key}" changed to: ${event.newValue}`);

if (event.key === "status") {
const step5 = document.getElementById("step-5");
Expand Down

0 comments on commit f403524

Please sign in to comment.