Skip to content

Commit

Permalink
replace polymc with prismlauncher (#12)
Browse files Browse the repository at this point in the history
* replace polymc with prismlauncher

* wording tweak

---------

Co-authored-by: Kendell R <[email protected]>
  • Loading branch information
Lutitious and KTibow authored Apr 26, 2024
1 parent 482d637 commit 329747b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
31 changes: 22 additions & 9 deletions app/assets/js/elements/folderChooserApp.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
///<reference path="../api/base.js" />
import { doesFileExistNL, SEPARATOR } from "../api/fileApi.js";
export const renderFolderChooserApp = async (elem) => {
const options = html`
<ul></ul>
`;
const options = html` <ul></ul> `;
const detectedOptions = await recommendPaths();
detectedOptions.forEach((instance) => {
const option = html`
Expand All @@ -22,7 +20,9 @@ export const renderFolderChooserApp = async (elem) => {
<li>
<input type="radio" name="folder" value="" />
<span class="text-gray-200"></span>
<button class="bg-nord10 hover:bg-nord10/70 transition-all text-white p-2 rounded-md">
<button
class="bg-nord10 hover:bg-nord10/70 transition-all text-white p-2 rounded-md"
>
Choose another folder
</button>
</li>
Expand All @@ -33,7 +33,9 @@ export const renderFolderChooserApp = async (elem) => {
customOption.querySelector("span").textContent = previousPath;
}
customOption.querySelector("button").addEventListener("click", async () => {
const folder = await Neutralino.os.showFolderDialog("Choose your .minecraft folder");
const folder = await Neutralino.os.showFolderDialog(
"Choose your .minecraft folder"
);
if (folder) {
customOption.querySelector("input").checked = true;
customOption.querySelector("input").value = folder;
Expand All @@ -50,7 +52,7 @@ export const renderFolderChooserApp = async (elem) => {
detected ? "Mart found it for you." : "Choose it below."
})
<br />
Also, if you're using MultiMC/PolyMC, make a new 1.8.9 Forge instance first.
Also, if you're using a MultiMC-based launcher, make a new 1.8.9 Forge instance first.
</div>
</div>
`;
Expand All @@ -60,7 +62,12 @@ export const renderFolderChooserApp = async (elem) => {
const checkInstance = async (path) => {
const instances = await Neutralino.filesystem.readDirectory(path);
const instanceWork = instances.map(async (dir) => {
if (dir.entry.startsWith(".") || dir.entry.startsWith("_") || dir.type != "DIRECTORY") return;
if (
dir.entry.startsWith(".") ||
dir.entry.startsWith("_") ||
dir.type != "DIRECTORY"
)
return;
const instancePath = path + SEPARATOR + dir.entry;
try {
const config = await Neutralino.filesystem.readFile(
Expand All @@ -69,7 +76,9 @@ const checkInstance = async (path) => {
const configJson = JSON.parse(config);
if (
configJson.components.some(
(c) => c.cachedName == "Forge" && c.cachedRequires.some((r) => r.equals == "1.8.9")
(c) =>
c.cachedName == "Forge" &&
c.cachedRequires.some((r) => r.equals == "1.8.9")
)
)
return instancePath + SEPARATOR + ".minecraft";
Expand All @@ -87,7 +96,11 @@ const recommendPaths = async () => {
pathsFound = [
[true, home + "/.local/share/PolyMC/instances"],
[true, home + "/.local/share/PrismLauncher/instances"],
[true, home + "/.var/app/org.prismlauncher.PrismLauncher/data/PrismLauncher/instances"],
[
true,
home +
"/.var/app/org.prismlauncher.PrismLauncher/data/PrismLauncher/instances",
],
[false, home + "/.minecraft"],
[false, home + "/.var/app/com.mojang.Minecraft/data/minecraft"],
];
Expand Down
20 changes: 15 additions & 5 deletions app/assets/js/elements/folderChooserWeb.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export const renderFolderChooserWeb = async (elem) => {
your .minecraft folder here
<br />
Or
<span class="group-hover:font-bold transition-all duration-500">click</span>
<span class="group-hover:font-bold transition-all duration-500"
>click</span
>
to choose it
</div>
`;
Expand All @@ -34,12 +36,15 @@ export const renderFolderChooserWeb = async (elem) => {
e.preventDefault();
e.stopPropagation();
dropText.classList.remove("font-bold");
const dropped = Array.from(e.dataTransfer.items).find((item) => item.kind == "file");
const dropped = Array.from(e.dataTransfer.items).find(
(item) => item.kind == "file"
);
window.chosenHandle = await dropped.getAsFileSystemHandle();
recognizeFolder();
});
dropArea.addEventListener("click", async () => {
if (!elem.querySelector("details")) elem.querySelector("#result").prepend(errorExplanation);
if (!elem.querySelector("details"))
elem.querySelector("#result").prepend(errorExplanation);
window.chosenHandle = await window.showDirectoryPicker();
recognizeFolder();
});
Expand All @@ -48,7 +53,7 @@ export const renderFolderChooserWeb = async (elem) => {
<span class="mti">info</span>
<div class="inline-block flex-grow">
<p class="font-bold">Try downloading Mart as an app if the web version doesn't work.</p>
<p>Also, if you're using MultiMC/PolyMC, make a new 1.8.9 Forge instance first.</p>
<p>Also, if you're using a MultiMC-based launcher, make a new 1.8.9 Forge instance first.</p>
</div>
</div>
<p id="result"></p>
Expand Down Expand Up @@ -83,7 +88,12 @@ export const renderFolderChooserWeb = async (elem) => {
<code class="font-mono">showDirectoryPicker</code>
API.
<br />
Use Chrome, Edge, or <a class="underline" href="https://github.com/KTibow/Mart/releases/latest">download Mart as an app.</a>
Use Chrome, Edge, or
<a
class="underline"
href="https://github.com/KTibow/Mart/releases/latest"
>download Mart as an app.</a
>
</div>
</div>
`;
Expand Down

0 comments on commit 329747b

Please sign in to comment.