-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b08d0ad
commit e5a78e1
Showing
23 changed files
with
606 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<script lang="ts"> | ||
import { outputEverything } from "$lib/resourcepack/exporter"; | ||
import { ProgressBar, ProgressRadial } from '@skeletonlabs/skeleton'; | ||
import { writable } from "svelte/store"; | ||
import loading from '$lib/assets/loading.webp'; | ||
import { resourcePackStore } from "$lib/config"; | ||
import MinecraftButton from "./MinecraftButton.svelte"; | ||
import { saveAs } from "$lib/utils"; | ||
import minecraft_logo from '$lib/assets/minecraft_logo.webp'; | ||
import geyser_logo from '$lib/assets/geyser_logo.png'; | ||
const progressStore = writable<{ | ||
total?: number, | ||
current?: number | ||
}>({ | ||
total: undefined, | ||
current: undefined | ||
}); | ||
let javaRp: Blob|undefined = undefined; | ||
let bedrockRp: Blob|undefined = undefined; | ||
outputEverything(rp => { | ||
setTimeout(() => { | ||
javaRp = rp; | ||
}, 500); | ||
}, (total, current) => { | ||
console.log(total, current) | ||
progressStore.set({ total, current }) | ||
}, rp => { | ||
bedrockRp = rp; | ||
}); | ||
</script> | ||
|
||
<main class="bg-surface-500 rounded-md p-2 h-[50%] overflow-y-auto w-[90%] sm:w-[80%] lg:w-[50%] flex items-center justify-center gap-4 flex-col"> | ||
{#if javaRp} | ||
<h4 class="h4 mt-2 font-minecraft">Your resourcepack is ready!</h4> | ||
<div class="flex gap-4"> | ||
<div class="card flex flex-col gap-4 p-4 rounded-lg"> | ||
<div class="card-header w-full p-0"> | ||
<img src={minecraft_logo} alt="resourcepackicon" class="aspect-square object-contain w-52" style="image-rendering: optimizeQuality;"> | ||
</div> | ||
<MinecraftButton on:click={() => saveAs(javaRp, 'resourcepack.zip')}>Download for<br>Minecraft: Java Edition</MinecraftButton> | ||
</div> | ||
|
||
<div class="card flex flex-col gap-4 p-4 rounded-lg"> | ||
<div class="card-header w-full p-0"> | ||
<img src={geyser_logo} alt="resourcepackicon" class="w-52 aspect-square object-contain" style="image-rendering: optimizeQuality;"> | ||
</div> | ||
<MinecraftButton enabled={bedrockRp != undefined} on:click={() => saveAs(bedrockRp, 'resourcepack-geysermc.mcpack')}> | ||
{#if bedrockRp == undefined} | ||
Generating for<br>GeyserMC... | ||
{:else} | ||
Download for<br>GeyserMC | ||
{/if} | ||
</MinecraftButton> | ||
</div> | ||
</div> | ||
{:else} | ||
<h4 class="h4 mt-2 font-minecraft">Generating your assets...</h4> | ||
<img src={loading} alt="loading"> | ||
<ProgressBar bind:max={$progressStore.total} bind:value={$progressStore.current} /> | ||
{/if} | ||
</main> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<script lang="ts"> | ||
import { resourcePackStore, versions } from "$lib/config"; | ||
import { inputFile, dropFile } from "$lib/directives"; | ||
import MinecraftComboBox from "./MinecraftComboBox.svelte"; | ||
import MinecraftTextbox from "./MinecraftTextbox.svelte"; | ||
const setTexture = async (files?: File[]) => { | ||
if(files && files.length > 0 && files[0]) { | ||
$resourcePackStore.icon = files[0]; | ||
} | ||
} | ||
</script> | ||
|
||
<!-- TODO: continue working on this --> | ||
|
||
<main class="flex p-5"> | ||
<img class="bg-[#202020] p-3 cursor-pointer h-28 sm:h-32 h-max-32 aspect-square border border-transparent hover:border-white" src={URL.createObjectURL($resourcePackStore.icon)} alt="disc icon" use:inputFile={{ | ||
accept: 'image/*', | ||
cb: setTexture | ||
}} use:dropFile={{ | ||
accept: 'image/*', | ||
cb: setTexture | ||
}} /> | ||
|
||
<MinecraftComboBox bind:value={$resourcePackStore.version} values={Array.from(versions.keys())} labels={Array.from(versions.values())} /> | ||
|
||
<MinecraftTextbox placeholder="The resource pack description" bind:value={$resourcePackStore.description} /> | ||
|
||
<div class="flex"> | ||
{#each $resourcePackStore.packs as pack} | ||
{/each} | ||
</div> | ||
</main> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ import { FFmpeg } from "@ffmpeg/ffmpeg"; | |
import { arrayBufferToBase64, base64ToArrayBuffer, blobToArraBuffer } from "./utils"; | ||
import { invoke } from '@tauri-apps/api/tauri' | ||
import { get, writable } from "svelte/store"; | ||
import { listen } from "@tauri-apps/api/event"; | ||
import { getDuration } from "./resourcepack/utils"; | ||
|
||
const baseURL = 'https://unpkg.com/@ffmpeg/[email protected]/dist/esm'; | ||
const baseMTURL = 'https://unpkg.com/@ffmpeg/[email protected]/dist/esm'; | ||
|
@@ -17,7 +19,6 @@ const qualityArgs = { | |
export const localFFmpegStore = writable(false); | ||
|
||
export const prepareAudio = async (blob: Blob, data: FFmpegData, onProgress?: (percent: number) => unknown) : Promise<Blob|null> => { | ||
|
||
const args = ['-vn', '-acodec', 'libvorbis']; | ||
|
||
if (data.mono) args.push('-ac', '1'); | ||
|
@@ -27,19 +28,27 @@ export const prepareAudio = async (blob: Blob, data: FFmpegData, onProgress?: (p | |
args.push(...qualityArgs[data.quality]); | ||
|
||
if (window.__TAURI__ && get(localFFmpegStore)) { | ||
const duration = await getDuration(blob); | ||
|
||
const unregister = await listen<string>('ffmpeg-progress', async event => { | ||
const [hours, minutes, seconds] = event.payload.split(':').map(Number); | ||
|
||
onProgress?.((hours * 3600 + minutes * 60 + seconds) / duration * 100); | ||
}) | ||
|
||
const result = <string>(await invoke('ffmpeg', { | ||
input: arrayBufferToBase64(await blob.arrayBuffer()), | ||
args | ||
})) | ||
|
||
unregister(); | ||
|
||
if(result === "") return null; | ||
|
||
return new Blob([base64ToArrayBuffer(result)], { type: 'audio/ogg' }); | ||
} else { | ||
const ffmpeg = new FFmpeg(); | ||
|
||
// import file from node modules | ||
|
||
if(!ffmpeg.loaded) await ffmpeg.load(crossOriginIsolated ? { | ||
coreURL: `${baseMTURL}/ffmpeg-core.js`, | ||
wasmURL: `${baseMTURL}/ffmpeg-core.wasm`, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.