This commit is contained in:
Brian Beck 2024-10-15 19:25:08 -07:00
parent 46c43d9c82
commit 6e9b69fb4c
9 changed files with 33 additions and 8 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
2:I[9330,["699","static/chunks/8e1d74a4-8e519121d6db0557.js","634","static/chunks/634-d90cc75f8d4e4c06.js","931","static/chunks/app/page-960543db4d1917f1.js"],"Forge"]
2:I[9330,["699","static/chunks/8e1d74a4-8e519121d6db0557.js","634","static/chunks/634-d90cc75f8d4e4c06.js","931","static/chunks/app/page-b02dc3190aa5562d.js"],"Forge"]
3:I[4707,[],""]
4:I[6423,[],""]
0:["AaZG0PNUAl--iHAutmB3I",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{}],[["$","link","0",{"rel":"stylesheet","href":"/vl2-forge/_next/static/css/914a77656c3e670b.css","precedence":"next","crossOrigin":"$undefined"}]]],null],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/vl2-forge/_next/static/css/c50e9c221475fcb7.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","className":"__variable_6dd175","children":["$","body",null,{"children":["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L5",null]]]]
0:["VFn6qWTJj18_ybDB8NUw-",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{}],[["$","link","0",{"rel":"stylesheet","href":"/vl2-forge/_next/static/css/914a77656c3e670b.css","precedence":"next","crossOrigin":"$undefined"}]]],null],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/vl2-forge/_next/static/css/c50e9c221475fcb7.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","className":"__variable_6dd175","children":["$","body",null,{"children":["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L5",null]]]]
5:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"VL2 Forge"}],["$","meta","3",{"name":"description","content":"Create .vl2 files for Tribes 2"}],["$","meta","4",{"name":"next-size-adjust"}]]
1:null

View file

@ -7,7 +7,30 @@ import orderBy from "lodash.orderby";
import { FaTrashAlt } from "react-icons/fa";
import styles from "./Forge.module.css";
import { base64ArrayBuffer } from "./utils";
import { hasUncaughtExceptionCaptureCallback } from "process";
function detectBestPath(path) {
const parts = path.split("/");
let folder = "";
let basename = "";
if (parts.length > 1) {
folder = parts.slice(0, -1).join("/");
basename = parts[parts.length - 1];
} else {
folder = "";
basename = parts[0];
}
if (
/\.(l|m|h)(male|female|bioderm)\.png$/i.test(basename) ||
/^(vehicle|weapon)_.+png$/i.test(basename)
) {
folder = "textures/skins";
}
if (folder) {
return `${folder}/${basename}`;
} else {
return basename;
}
}
function detectFileType(file): FileType | null {
if (file.type) {
@ -94,9 +117,10 @@ type FileEntry = {
async function handleZipFile(file) {
const zip = await JSZip.loadAsync(file);
const map = new Map<string, FileEntry>();
for (const path in zip.files) {
for (let path in zip.files) {
const fileObj = zip.files[path];
if (!fileObj.dir) {
path = detectBestPath(path);
const buffer = await fileObj.async("arraybuffer");
const fileEntry = {
path,
@ -133,6 +157,7 @@ async function handleOtherFile(file) {
} else {
return map;
}
path = detectBestPath(path);
const buffer = await new Promise<ArrayBuffer>((resolve, reject) => {
const reader = new FileReader();
reader.addEventListener("load", (event) => {