Compare commits
2 Commits
6179e669df
...
d0384b1778
Author | SHA1 | Date | |
---|---|---|---|
d0384b1778 | |||
3951af01c9 |
57
fclauncher/fabric.go
Normal file
57
fclauncher/fabric.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Fabric struct {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type FabricDefinition struct {
|
||||||
|
Separator string
|
||||||
|
Build int
|
||||||
|
Maven string
|
||||||
|
Version string
|
||||||
|
Stable bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type FabricLibrary struct {
|
||||||
|
Name string
|
||||||
|
Url string
|
||||||
|
}
|
||||||
|
|
||||||
|
type FabricLibraries struct {
|
||||||
|
Client []FabricLibrary
|
||||||
|
Common []FabricLibrary
|
||||||
|
Server []FabricLibrary
|
||||||
|
}
|
||||||
|
|
||||||
|
type FabricMeta struct {
|
||||||
|
Version int
|
||||||
|
Libraries FabricLibraries
|
||||||
|
MainClass map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
type FabricVersion struct {
|
||||||
|
Loader FabricDefinition
|
||||||
|
Intermediary FabricDefinition
|
||||||
|
LauncherMeta FabricMeta
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Fabric)GetFabricVersions(mcVersion string) ([]FabricVersion, error) {
|
||||||
|
resp, err := http.Get("https://meta.fabricmc.net/v2/versions/loader/"+mcVersion)
|
||||||
|
if err != nil {
|
||||||
|
return []FabricVersion{}, fmt.Errorf("Unable to pull fabric version manifest: %s\n", err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
data, _ := io.ReadAll(resp.Body)
|
||||||
|
versions := []FabricVersion{}
|
||||||
|
json.Unmarshal(data, &versions)
|
||||||
|
fmt.Printf("fabric versions found for %s: %+v\n", mcVersion, versions)
|
||||||
|
return versions, nil
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
import {GetModpacks, GetModpack} from '../wailsjs/go/main/ModpackManager.js'
|
import {GetModpacks, GetModpack} from '../wailsjs/go/main/ModpackManager.js'
|
||||||
import {InstallVanilla, LaunchInstance, GetInstances, CheckUpdate} from '../wailsjs/go/main/InstanceManager.js'
|
import {InstallVanilla, LaunchInstance, GetInstances, CheckUpdate} from '../wailsjs/go/main/InstanceManager.js'
|
||||||
import {GetVersions} from '../wailsjs/go/main/App.js'
|
import {GetVersions} from '../wailsjs/go/main/App.js'
|
||||||
|
import {GetFabricVersions} from '../wailsjs/go/main/Fabric.js'
|
||||||
import {onMount} from 'svelte'
|
import {onMount} from 'svelte'
|
||||||
import {loading} from './global.ts'
|
import {loading} from './global.ts'
|
||||||
import {slide} from 'svelte/transition'
|
import {slide} from 'svelte/transition'
|
||||||
@ -12,17 +13,30 @@
|
|||||||
let instance: string
|
let instance: string
|
||||||
let addingInstance: boolean = false
|
let addingInstance: boolean = false
|
||||||
let name: string = "New Modpack"
|
let name: string = "New Modpack"
|
||||||
|
let loader: string = "none"
|
||||||
|
let fabric_ver: string = ""
|
||||||
|
let fab_versions: string[] = []
|
||||||
|
|
||||||
function updateLists(){
|
function updateLists(){
|
||||||
GetVersions().then((result) => {
|
GetVersions().then((result) => {
|
||||||
modpacks = result
|
modpacks = result
|
||||||
pack = modpacks[0]
|
pack = modpacks[0]
|
||||||
name = modpacks[0]
|
name = modpacks[0]
|
||||||
|
updateLoaders()
|
||||||
})
|
})
|
||||||
GetInstances().then((result) => {
|
GetInstances().then((result) => {
|
||||||
instances = result
|
instances = result
|
||||||
instance = instances[0].InstanceName
|
instance = instances[0].InstanceName
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateLoaders(){
|
||||||
|
GetFabricVersions(pack).then((result) => {
|
||||||
|
result.forEach((ver) => {
|
||||||
|
fab_versions.push(ver.Loader.Version)
|
||||||
|
})
|
||||||
|
fabric_ver = fab_versions[0]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
@ -47,6 +61,8 @@
|
|||||||
|
|
||||||
function onchange(event){
|
function onchange(event){
|
||||||
name = event.target.value
|
name = event.target.value
|
||||||
|
pack = event.target.value
|
||||||
|
updateLoaders()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -67,8 +83,25 @@
|
|||||||
<option value={pack}>{pack}</option>
|
<option value={pack}>{pack}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
|
<input type="radio" bind:group={loader} checked id="noLoader" name="Loader" value="none" />
|
||||||
|
<label for="noLoader">None</label>
|
||||||
|
<input type="radio" bind:group={loader} id="fabric" name="Loader" value="fabric" />
|
||||||
|
<label for="fabric">Fabric</label>
|
||||||
|
<input type="radio" bind:group={loader} id="forge" name="Loader" value="forge" />
|
||||||
|
<label for="forge">Forge</label>
|
||||||
|
<input type="radio" bind:group={loader} id="neoforge" name="Loader" value="neoforge" />
|
||||||
|
<label for="neoforge">NeoForge</label>
|
||||||
|
<input type="radio" bind:group={loader} id="quilt" name="Loader" value="quilt" />
|
||||||
|
<label for="quilt">Quilt</label>
|
||||||
<br/>
|
<br/>
|
||||||
<input bind:value={name} />
|
<input bind:value={name} />
|
||||||
|
{#if loader == "fabric"}
|
||||||
|
<select id="fabric_ver" bind:value={fabric_ver} name="fabric_ver">Select Fabric Version:
|
||||||
|
{#each fab_versions as ver}
|
||||||
|
<option value={ver}>{ver}</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
{/if}
|
||||||
<br/>
|
<br/>
|
||||||
<button on:click={install}>Install</button>
|
<button on:click={install}>Install</button>
|
||||||
<button on:click={() => {addingInstance = false}}>Cancel</button>
|
<button on:click={() => {addingInstance = false}}>Cancel</button>
|
||||||
|
5
fclauncher/frontend/wailsjs/go/main/Fabric.d.ts
vendored
Executable file
5
fclauncher/frontend/wailsjs/go/main/Fabric.d.ts
vendored
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||||
|
// This file is automatically generated. DO NOT EDIT
|
||||||
|
import {main} from '../models';
|
||||||
|
|
||||||
|
export function GetFabricVersions(arg1:string):Promise<Array<main.FabricVersion>>;
|
7
fclauncher/frontend/wailsjs/go/main/Fabric.js
Executable file
7
fclauncher/frontend/wailsjs/go/main/Fabric.js
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
// @ts-check
|
||||||
|
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||||
|
// This file is automatically generated. DO NOT EDIT
|
||||||
|
|
||||||
|
export function GetFabricVersions(arg1) {
|
||||||
|
return window['go']['main']['Fabric']['GetFabricVersions'](arg1);
|
||||||
|
}
|
@ -1,5 +1,142 @@
|
|||||||
export namespace main {
|
export namespace main {
|
||||||
|
|
||||||
|
export class FabricDefinition {
|
||||||
|
Separator: string;
|
||||||
|
Build: number;
|
||||||
|
Maven: string;
|
||||||
|
Version: string;
|
||||||
|
Stable: boolean;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new FabricDefinition(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.Separator = source["Separator"];
|
||||||
|
this.Build = source["Build"];
|
||||||
|
this.Maven = source["Maven"];
|
||||||
|
this.Version = source["Version"];
|
||||||
|
this.Stable = source["Stable"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class FabricLibrary {
|
||||||
|
Name: string;
|
||||||
|
Url: string;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new FabricLibrary(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.Name = source["Name"];
|
||||||
|
this.Url = source["Url"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class FabricLibraries {
|
||||||
|
Client: FabricLibrary[];
|
||||||
|
Common: FabricLibrary[];
|
||||||
|
Server: FabricLibrary[];
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new FabricLibraries(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.Client = this.convertValues(source["Client"], FabricLibrary);
|
||||||
|
this.Common = this.convertValues(source["Common"], FabricLibrary);
|
||||||
|
this.Server = this.convertValues(source["Server"], FabricLibrary);
|
||||||
|
}
|
||||||
|
|
||||||
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||||
|
if (!a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
if (a.slice && a.map) {
|
||||||
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||||
|
} else if ("object" === typeof a) {
|
||||||
|
if (asMap) {
|
||||||
|
for (const key of Object.keys(a)) {
|
||||||
|
a[key] = new classs(a[key]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
return new classs(a);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class FabricMeta {
|
||||||
|
Version: number;
|
||||||
|
Libraries: FabricLibraries;
|
||||||
|
MainClass: {[key: string]: string};
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new FabricMeta(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.Version = source["Version"];
|
||||||
|
this.Libraries = this.convertValues(source["Libraries"], FabricLibraries);
|
||||||
|
this.MainClass = source["MainClass"];
|
||||||
|
}
|
||||||
|
|
||||||
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||||
|
if (!a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
if (a.slice && a.map) {
|
||||||
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||||
|
} else if ("object" === typeof a) {
|
||||||
|
if (asMap) {
|
||||||
|
for (const key of Object.keys(a)) {
|
||||||
|
a[key] = new classs(a[key]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
return new classs(a);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class FabricVersion {
|
||||||
|
Loader: FabricDefinition;
|
||||||
|
Intermediary: FabricDefinition;
|
||||||
|
LauncherMeta: FabricMeta;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new FabricVersion(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.Loader = this.convertValues(source["Loader"], FabricDefinition);
|
||||||
|
this.Intermediary = this.convertValues(source["Intermediary"], FabricDefinition);
|
||||||
|
this.LauncherMeta = this.convertValues(source["LauncherMeta"], FabricMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||||
|
if (!a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
if (a.slice && a.map) {
|
||||||
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||||
|
} else if ("object" === typeof a) {
|
||||||
|
if (asMap) {
|
||||||
|
for (const key of Object.keys(a)) {
|
||||||
|
a[key] = new classs(a[key]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
return new classs(a);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
export class Instance {
|
export class Instance {
|
||||||
InstanceName: string;
|
InstanceName: string;
|
||||||
ModpackId: string;
|
ModpackId: string;
|
||||||
|
@ -31,6 +31,7 @@ func main() {
|
|||||||
&app.PrismLauncher,
|
&app.PrismLauncher,
|
||||||
&app.Java,
|
&app.Java,
|
||||||
&app.Modpacks,
|
&app.Modpacks,
|
||||||
|
&Fabric{},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user