more fixes, style tweaks, beginning of prism pack generator

This commit is contained in:
moehreag 2024-06-09 14:00:37 +02:00
parent b7bce1d2c7
commit 03262dfbdc
4 changed files with 251 additions and 50 deletions

View file

@ -137,3 +137,32 @@
--docsearch-primary-color: var(--vp-c-brand-1) !important;
}
/**
* Custom styling
* -------------------------------------------------------------------------- */
button {
background-color: var(--vp-button-brand-bg);
color: var(--vp-button-brand-text);
border-color: var(--vp-button-brand-border);
padding: 4px;
border-radius: 14px;
}
button:hover {
background-color: var(--vp-button-brand-hover-bg);
color: var(--vp-button-brand-hover-text);
border-color: var(--vp-button-brand-hover-border);
}
select, input {
margin-left: 15px;
margin-right: 15px;
padding: 1px 8px;
border-radius: 12px;
}
select {
text-align: center;
}
input {
border: 4px solid var(--vp-c-brand-soft);
}

View file

@ -11,9 +11,123 @@ Insert section about the installer here
### PrismLauncher/MultiMC
*put an instance generator here*
<script setup>
import JSZip from 'jszip'
import { ref, onMounted } from 'vue'
import { saveAs } from 'file-saver'
const assetBaseUrl = "/resources/prism"
const instanceNameRef = ref()
const showSnapshots = ref()
const versionSelector = ref()
let releases = []
let snapshots = []
let versions = []
async function getGameVersions() {
const response = await fetch("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json")
return await response.json()
}
function getVersions() {
versionSelector.value.innerHTML = ""
for (let version of releases) {
versionSelector.value.innerHTML += "<option value=\""+version.id+"\">"+version.id+"</option>"
}
if (showSnapshots.value) {
for (let version of snapshots) {
versionSelector.value.innerHTML += "<option value=\""+version.id+"\">"+version.id+"</option>"
}
}
}
onMounted(() => {
getGameVersions().then((v) => {
versions = v.versions
for (let version of versions){
if (version.type === "snapshot"){
snapshots.push(version)
} else {
releases.push(version)
}
}
getVersions()
})
})
function download(){
let missing = []
if (instanceNameRef.value === undefined){
missing.push("Instance Name")
}
if (missing.length > 0) {
let html = "<div class=\"danger custom-block\"><p class=\"custom-block-title\">Missing Inputs</p><p>"
html += missing.join("</p><p>")
html += "</p></div>"
document.getElementById("missingBox").innerHTML = html
return
}
let zip = JSZip()
let promises = []
Promise.all(promises).then((values) => {
zip.generateAsync({type:"blob"}).then(function (blob) {
saveAs(blob, instanceNameRef.value+".zip")
}, function (err) {
alert("Failed to download generated zip file, please report this!")
})
})
}
async function readAsset(path){
const response = await fetch(assetBaseUrl+path)
return await response.text().then((data) => {
data = data.replaceAll("$instance_name", instanceNameRef.value)
return data
})
}
function inputsChanged() {
document.getElementById("missingBox").innerHTML = ""
}
</script>
::: warning Dependencies for a generator here
- loader libraries in meta
:::
Add an instance generator to the installer and describe it here\
**or**\
PR direct support to Prism
<div id="inputs">
<table>
<tbody>
<tr>
<td>Instance Name</td>
<td><input v-model="instanceNameRef" @input="inputsChanged" /></td>
</tr>
<tr>
<td>Minecraft Version</td>
<td>
<select ref="versionSelector">
<option value="loading">Loading Versions...</option>
</select>
<input type="checkbox" v-model="showSnapshots" @change="getVersions">Show Snapshots</input>
</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<div id="missingBox"></div>
<button @click="download">Download</button>
</div>

View file

@ -0,0 +1,82 @@
{
"formatVersion": 1,
"name": "FrogLoader",
"uid": "dev.frogmc.frogloader",
"version": "0.0.1-SNAPSHOT",
"libraries": [
{
"downloads": {
"artifact": {
"size": 120676,
"sha1": "9bf1d861a97bdd799ba1ae614a5a1b4f4f86d1d1",
"url": "https://maven.frogmc.dev/snapshots/dev/frogmc/frogloader/0.0.1-SNAPSHOT/frogloader-0.0.1-20240608.093414-3.jar"
}
},
"name": "dev.frogmc:frogloader:0.0.1-SNAPSHOT"
},
{
"name": "dev.frogmc:thyroxine:1.0.0-SNAPSHOT",
"downloads": {
"artifact": {
"size": 36102,
"sha1": "9fd87f91ccaf70f818b1f564101feb75306f99a9",
"url": "https://maven.frogmc.dev/snapshots/dev/frogmc/thyroxine/1.0.0-SNAPSHOT/thyroxine-1.0.0-20240607.131732-1.jar"
}
}
},
{
"name": "net.fabricmc:sponge-mixin:0.14.0+mixin.0.8.6",
"url": "https://maven.fabricmc.net"
},
{
"name": "io.github.llamalad7:mixinextras-common:0.3.6",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "com.electronwill.night-config:toml:3.7.2",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "com.electronwill.night-config:core:3.7.2",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.ow2.asm:asm:9.7",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.ow2.asm:asm-commons:9.7",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.ow2.asm:asm-tree:9.7",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.ow2.asm:asm-util:9.7",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.ow2.asm:asm-analysis:9.7",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.slf4j:slf4j-api:2.0.13",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.apache.logging.log4j:log4j-slf4j2-impl:2.23.1",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.apache.logging.log4j:log4j-api:2.23.1",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.apache.logging.log4j:log4j-core:2.23.1",
"url": "https://repo.maven.apache.org/maven2"
}
],
"mainClass": "dev.frogmc.frogloader.impl.launch.client.FrogClient",
"type": "snapshot"
}

View file

@ -13,7 +13,7 @@ outline: false
import JSZip from 'jszip'
import { ref, onMounted } from 'vue'
import { saveAs } from 'file-saver'
const assetBaseUrl = "/resources"
const assetBaseUrl = "/resources/template"
const showSnapshots = ref()
const versionSelector = ref()
const modIdRef = ref()
@ -123,47 +123,47 @@ outline: false
let promises = []
promises.push(
readAsset("/template/gradle/libs.versions.toml").then((data) => {
readAsset("/gradle/libs.versions.toml").then((data) => {
gradle.file("libs.versions.toml", data)
})
)
promises.push(
readAssetBinary("/template/gradle/wrapper/gradle-wrapper.properties").then((data) => {
readAssetBinary("/gradle/wrapper/gradle-wrapper.properties").then((data) => {
wrapper.file("gradle-wrapper.properties", data)
})
)
promises.push(
readAssetBinary("/template/gradle/wrapper/gradle-wrapper.jar").then((data) => {
readAssetBinary("/gradle/wrapper/gradle-wrapper.jar").then((data) => {
wrapper.file("gradle-wrapper.jar", data)
})
)
promises.push(
readAsset("/template/.gitignore").then((data) => {
readAsset("/.gitignore").then((data) => {
zip.file(".gitignore", data)
})
)
promises.push(
readAsset("/template/build.gradle.kts").then((data) => {
readAsset("/build.gradle.kts").then((data) => {
zip.file("build.gradle.kts", data)
})
)
promises.push(
readAssetBinary("/template/gradlew.sh").then((data) => {
readAssetBinary("/gradlew.sh").then((data) => {
zip.file("gradlew", data)
})
)
promises.push(
readAssetBinary("/template/gradlew.bat").then((data) => {
readAssetBinary("/gradlew.bat").then((data) => {
zip.file("gradlew.bat", data)
})
)
promises.push(
readAsset("/template/build.gradle.kts").then((data) => {
readAsset("/build.gradle.kts").then((data) => {
zip.file("build.gradle.kts", data)
})
)
promises.push(
readAsset("/template/settings.gradle.kts").then((data) => {
readAsset("/settings.gradle.kts").then((data) => {
zip.file("settings.gradle.kts", data)
})
)
@ -177,17 +177,17 @@ outline: false
}
const classFileName = modNameRef.value.replaceAll(" ", "")
promises.push(
readAsset("/template/src/main/java/Main.java").then((data) => {
readAsset("/src/main/java/Main.java").then((data) => {
classes.file(classFileName+"Main", data)
})
)
promises.push(
readAsset("/template/src/main/resources/frog.mod.toml").then((data) => {
readAsset("/src/main/resources/frog.mod.toml").then((data) => {
resources.file("frog.mod.toml", data)
})
)
promises.push(
readAsset("/template/src/main/resources/example_mod.mixins.json").then((data) => {
readAsset("/src/main/resources/example_mod.mixins.json").then((data) => {
resources.file(modIdRef.value+".mixins.json", data)
})
)
@ -215,40 +215,16 @@ outline: false
data = data.replaceAll("$maven_group", mavenGroupRef.value)
data = data.replaceAll("$license", licenseRef.value)
data = data.replaceAll("$loader_version", useSnapshots.value ? latestLoaderSnapshot : latestLoader)
data = data.replaceAll("$phytotelma_version", latestPhytotelma)
data = data.replaceAll("$phytotelma_version", useSnapshots.value ? latestPhytotelmaSnapshot : latestPhytotelma)
data = data.replaceAll("$game_version", versionSelector.value.value)
return data
})
}
function inputsChanged() {
document.getElementById("missingBox").innerHTML = ""
}
</script>
<style>
select, input {
margin-left: 15px;
margin-right: 15px;
padding: 1px 8px;
border-radius: 12px;
}
select {
text-align: center;
}
input {
border: 4px solid var(--vp-c-brand-soft);
}
button {
background-color: var(--vp-button-brand-bg);
color: var(--vp-button-brand-text);
border-color: var(--vp-button-brand-border);
}
button:hover {
background-color: var(--vp-button-brand-hover-bg);
color: var(--vp-button-brand-hover-text);
border-color: var(--vp-button-brand-hover-border);
}
.generate {
padding: 4px;
border-radius: 14px;
}
</style>
# {{ $frontmatter.title }}
@ -258,20 +234,20 @@ outline: false
<table>
<tbody>
<tr>
<td>Mod Id</td>
<td><input v-model="modIdRef" /></td>
<td>Mod ID</td>
<td><input v-model="modIdRef" @input="inputsChanged" /></td>
</tr>
<tr>
<td>Mod Name</td>
<td><input v-model="modNameRef" /></td>
<td><input v-model="modNameRef" @input="inputsChanged" /></td>
</tr>
<tr>
<td>Maven Group</td>
<td><input v-model="mavenGroupRef" /></td>
<td><input v-model="mavenGroupRef" @input="inputsChanged" /></td>
</tr>
<tr>
<td>License (SPDX)</td>
<td><input v-model="licenseRef" /></td>
<td><input v-model="licenseRef" @input="inputsChanged" /></td>
</tr>
<tr>
<td>Minecraft Version</td>
@ -291,7 +267,7 @@ outline: false
</tbody>
</table>
<div id="missingBox"></div>
<button class="generate" @click="generate">Download</button>
<button @click="generate">Download</button>
</div>
## Latest Versions