Add rename

This commit is contained in:
Brian Beck 2024-10-15 20:15:45 -07:00
parent 6e9b69fb4c
commit 685a1524f3
14 changed files with 71 additions and 11 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[240],{1273:function(c,t,a){a.d(t,{W95:function(){return r},ekl:function(){return s}});var n=a(6231);function r(c){return(0,n.w_)({tag:"svg",attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M192 0c-41.8 0-77.4 26.7-90.5 64H64C28.7 64 0 92.7 0 128V448c0 35.3 28.7 64 64 64H320c35.3 0 64-28.7 64-64V128c0-35.3-28.7-64-64-64H282.5C269.4 26.7 233.8 0 192 0zm0 64a32 32 0 1 1 0 64 32 32 0 1 1 0-64zM72 272a24 24 0 1 1 48 0 24 24 0 1 1 -48 0zm104-16H304c8.8 0 16 7.2 16 16s-7.2 16-16 16H176c-8.8 0-16-7.2-16-16s7.2-16 16-16zM72 368a24 24 0 1 1 48 0 24 24 0 1 1 -48 0zm88 0c0-8.8 7.2-16 16-16H304c8.8 0 16 7.2 16 16s-7.2 16-16 16H176c-8.8 0-16-7.2-16-16z"},child:[]}]})(c)}function s(c){return(0,n.w_)({tag:"svg",attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M16 144a144 144 0 1 1 288 0A144 144 0 1 1 16 144zM160 80c8.8 0 16-7.2 16-16s-7.2-16-16-16c-53 0-96 43-96 96c0 8.8 7.2 16 16 16s16-7.2 16-16c0-35.3 28.7-64 64-64zM128 480V317.1c10.4 1.9 21.1 2.9 32 2.9s21.6-1 32-2.9V480c0 17.7-14.3 32-32 32s-32-14.3-32-32z"},child:[]}]})(c)}}}]);

View file

@ -0,0 +1 @@
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[212],{8637:function(t,a,r){r.d(a,{HXH:function(){return h}});var n=r(6231);function h(t){return(0,n.w_)({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"},child:[]},{tag:"path",attr:{d:"M19 17V5a2 2 0 0 0-2-2H4"},child:[]},{tag:"path",attr:{d:"M15 8h-5"},child:[]},{tag:"path",attr:{d:"M15 12h-5"},child:[]}]})(t)}}}]);

View file

@ -0,0 +1 @@
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[51],{2744:function(t,h,n){n.d(h,{JEK:function(){return v},seb:function(){return i}});var a=n(6231);function v(t){return(0,a.w_)({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M21 9v2h-2V3h-2v2h-2V3h-2v2h-2V3H9v2H7V3H5v8H3V9H1v12h9v-3c0-1.1.9-2 2-2s2 .9 2 2v3h9V9h-2zm-10 3H9V9h2v3zm4 0h-2V9h2v3z"},child:[]}]})(t)}function i(t){return(0,a.w_)({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m14 6-3.75 5 2.85 3.8-1.6 1.2C9.81 13.75 7 10 7 10l-6 8h22L14 6z"},child:[]}]})(t)}}}]);

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 +1 @@
.Forge_Forge__dDZFe{flex:1 0 auto;display:grid;grid-template-columns:auto 1fr;grid-template-rows:1fr;align-content:stretch;font-family:var(--font-departure),monospace;color:#fff;text-shadow:2px 1px 0 #000;padding:20px;grid-gap:20px;gap:20px}.Forge_Footer__ghw3O{position:relative;display:flex;align-items:center;justify-content:center;padding:40px;background:rgba(59,55,49,.8);border-image-slice:18 26 26 23;border-image-width:16px 16px 16px 16px;border-image-outset:0 0 0 0;border-image-repeat:round repeat;border-image-source:url(/vl2-forge/_next/static/media/border.d6506fa8.png);border-style:solid;box-shadow:0 0 8px rgba(0,0,0,.3),inset 0 0 12px rgba(0,0,0,.8)}.Forge_Footer__ghw3O:before{top:-3px;left:-3px;right:-3px;bottom:-3px;border-color:rgba(255,250,234,.4) hsla(0,0%,9%,.5) hsla(0,0%,9%,.5) rgba(255,250,234,.4);border-style:solid;border-width:4px 4px 5px}.Forge_Footer__ghw3O:after,.Forge_Footer__ghw3O:before{display:block;content:"";position:absolute;pointer-events:none}.Forge_Footer__ghw3O:after{top:10px;left:10px;right:10px;bottom:10px;border-color:hsla(0,0%,9%,.5) rgba(255,250,234,.4) rgba(255,250,234,.4) hsla(0,0%,9%,.5);border-style:solid;border-width:4px}.Forge_Footer__ghw3O form{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:12px}.Forge_NameInput__lpcsg{position:relative;font-size:18px;font-family:var(--system-ui);font-weight:400;font-style:italic;line-height:1}.Forge_NameInput__lpcsg input{display:block;min-width:240px;max-width:100%;min-height:46px;background:#fff;color:#333;font-size:inherit;font-family:inherit;font-weight:inherit;font-style:inherit;line-height:inherit;padding:2px 50px 2px 10px}.Forge_NameInput__lpcsg:after{display:grid;place-content:center;content:".vl2";position:absolute;top:0;right:0;bottom:0;width:50px;color:#999}.Forge_DownloadButton__CnFTn{border:0;margin:0;padding:0 0 1px;min-width:128px;min-height:46px;font-family:var(--font-departure),monospace;font-size:18px;font-style:inherit;font-weight:inherit;line-height:1;border-radius:2px;background:url(/vl2-forge/_next/static/media/button.69ed12fe.png) transparent;background-repeat:no-repeat;background-size:150% 190%;background-position:50% 50%;border-color:rgba(255,145,105,.5) rgba(36,14,14,.7) rgba(36,14,14,.7) rgba(255,178,150,.5);border-style:solid;border-width:3px;color:#fff;text-shadow:0 0 5px rgba(255,226,82,.358),2px 3px 0 rgba(0,0,0,.5);cursor:pointer}.Forge_ListArea__OpY_R{display:flex;align-items:center;justify-content:center;padding:32px;background:rgba(2,2,84,.252);border-radius:12px}.Forge_FileList__9JOyh{width:100%;display:flex;flex-direction:column;gap:6px;margin:0;padding:0;list-style:none}.Forge_EmptyMessage__Lrlud{align-self:center;text-align:center}.Forge_AddButton__09pXD{border:0;margin:0;padding:0 0 2px;min-width:48px;min-height:48px;font-family:var(--font-departure),monospace;font-size:40px;font-style:inherit;font-weight:inherit;line-height:1;border-radius:3px;background:url(/vl2-forge/_next/static/media/button.69ed12fe.png) transparent;background-repeat:no-repeat;background-size:150% 190%;background-position:50% 50%;border-color:rgba(255,145,105,.5) rgba(36,14,14,.7) rgba(36,14,14,.7) rgba(255,178,150,.5);border-style:solid;border-width:3px;color:#fff;text-shadow:0 0 5px rgba(255,226,82,.358),2px 3px 0 rgba(0,0,0,.5);cursor:pointer;vertical-align:middle}.Forge_Header__7t3Qc{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:40px}.Forge_File__Mn05Y{display:flex;align-items:center;gap:12px}.Forge_DeleteButton__Csfdg{flex:0 0 auto;border:0;background:transparent;display:grid;place-content:center;font-size:24px;margin:0;padding:0;color:rgba(0,0,0,.4);cursor:pointer}.Forge_DeleteButton__Csfdg:hover{color:#ff5959}.Forge_DeleteButton__Csfdg svg{pointer-events:none}.Forge_IconContainer__AgM_T{flex:0 0 auto;display:grid;place-content:center;width:24px}.Forge_PreviewIcon__HFERe{width:100%;height:auto;max-height:24px;border:1px solid #000}.Forge_Path__GZs81{background:rgba(0,0,0,.3);padding:3px 8px;border-radius:8px}@media (max-width:767px){.Forge_Forge__dDZFe{grid-template-columns:1fr;grid-template-rows:auto 1fr;padding:12px;gap:12px}.Forge_Header__7t3Qc{flex-direction:row}.Forge_Header__7t3Qc img{width:auto;max-height:96px}}
.Forge_Forge__dDZFe{flex:1 0 auto;display:grid;grid-template-columns:auto 1fr;grid-template-rows:1fr;align-content:stretch;font-family:var(--font-departure),monospace;color:#fff;text-shadow:2px 1px 0 #000;padding:20px;grid-gap:20px;gap:20px}.Forge_Footer__ghw3O{position:relative;display:flex;align-items:center;justify-content:center;padding:40px;background:rgba(59,55,49,.8);border-image-slice:18 26 26 23;border-image-width:16px 16px 16px 16px;border-image-outset:0 0 0 0;border-image-repeat:round repeat;border-image-source:url(/vl2-forge/_next/static/media/border.d6506fa8.png);border-style:solid;box-shadow:0 0 8px rgba(0,0,0,.3),inset 0 0 12px rgba(0,0,0,.8)}.Forge_Footer__ghw3O:before{top:-3px;left:-3px;right:-3px;bottom:-3px;border-color:rgba(255,250,234,.4) hsla(0,0%,9%,.5) hsla(0,0%,9%,.5) rgba(255,250,234,.4);border-style:solid;border-width:4px 4px 5px}.Forge_Footer__ghw3O:after,.Forge_Footer__ghw3O:before{display:block;content:"";position:absolute;pointer-events:none}.Forge_Footer__ghw3O:after{top:10px;left:10px;right:10px;bottom:10px;border-color:hsla(0,0%,9%,.5) rgba(255,250,234,.4) rgba(255,250,234,.4) hsla(0,0%,9%,.5);border-style:solid;border-width:4px}.Forge_Footer__ghw3O form{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:12px}.Forge_NameInput__lpcsg{position:relative;font-size:18px;font-family:var(--system-ui);font-weight:400;font-style:italic;line-height:1}.Forge_NameInput__lpcsg input{display:block;min-width:240px;max-width:100%;min-height:46px;background:#fff;color:#333;font-size:inherit;font-family:inherit;font-weight:inherit;font-style:inherit;line-height:inherit;padding:2px 50px 2px 10px}.Forge_NameInput__lpcsg:after{display:grid;place-content:center;content:".vl2";position:absolute;top:0;right:0;bottom:0;width:50px;color:#999}.Forge_DownloadButton__CnFTn{border:0;margin:0;padding:0 0 1px;min-width:128px;min-height:46px;font-family:var(--font-departure),monospace;font-size:18px;font-style:inherit;font-weight:inherit;line-height:1;border-radius:2px;background:url(/vl2-forge/_next/static/media/button.69ed12fe.png) transparent;background-repeat:no-repeat;background-size:150% 190%;background-position:50% 50%;border-color:rgba(255,145,105,.5) rgba(36,14,14,.7) rgba(36,14,14,.7) rgba(255,178,150,.5);border-style:solid;border-width:3px;color:#fff;text-shadow:0 0 5px rgba(255,226,82,.358),2px 3px 0 rgba(0,0,0,.5);cursor:pointer}.Forge_ListArea__OpY_R{display:flex;align-items:center;justify-content:center;padding:32px;background:rgba(2,2,84,.252);border-radius:12px}.Forge_FileList__9JOyh{width:100%;display:flex;flex-direction:column;gap:6px;margin:0;padding:0;list-style:none}.Forge_EmptyMessage__Lrlud{align-self:center;text-align:center}.Forge_AddButton__09pXD{border:0;margin:0;padding:0 0 2px;min-width:48px;min-height:48px;font-family:var(--font-departure),monospace;font-size:40px;font-style:inherit;font-weight:inherit;line-height:1;border-radius:3px;background:url(/vl2-forge/_next/static/media/button.69ed12fe.png) transparent;background-repeat:no-repeat;background-size:150% 190%;background-position:50% 50%;border-color:rgba(255,145,105,.5) rgba(36,14,14,.7) rgba(36,14,14,.7) rgba(255,178,150,.5);border-style:solid;border-width:3px;color:#fff;text-shadow:0 0 5px rgba(255,226,82,.358),2px 3px 0 rgba(0,0,0,.5);cursor:pointer;vertical-align:middle}.Forge_Header__7t3Qc{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:40px}.Forge_File__Mn05Y{display:flex;align-items:center;gap:12px}.Forge_DeleteButton__Csfdg{flex:0 0 auto;border:0;background:transparent;display:grid;place-content:center;font-size:24px;margin:0;padding:0;color:rgba(0,0,0,.4);cursor:pointer}.Forge_DeleteButton__Csfdg:hover{color:#ff5959}.Forge_DeleteButton__Csfdg svg{pointer-events:none}.Forge_IconContainer__AgM_T{flex:0 0 auto;display:grid;place-content:center;width:24px;font-size:22px;color:hsla(0,0%,100%,.9)}.Forge_PreviewIcon__HFERe{width:100%;height:auto;max-height:24px;border:1px solid #000}.Forge_Path__GZs81{background:rgba(0,0,0,.3);padding:3px 8px;border-radius:8px;-webkit-user-select:none;-moz-user-select:none;user-select:none}@media (max-width:767px){.Forge_Forge__dDZFe{grid-template-columns:1fr;grid-template-rows:auto 1fr;padding:12px;gap:12px}.Forge_Header__7t3Qc{flex-direction:row}.Forge_Header__7t3Qc img{width:auto;max-height:96px}}

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-b02dc3190aa5562d.js"],"Forge"]
2:I[9330,["51","static/chunks/795d4814-53044e1cf9e42373.js","212","static/chunks/59650de3-d12eb82ab0e85613.js","240","static/chunks/53c13509-17317f399c482fd7.js","699","static/chunks/8e1d74a4-8e519121d6db0557.js","634","static/chunks/634-d90cc75f8d4e4c06.js","931","static/chunks/app/page-835d545c09f56ec6.js"],"Forge"]
3:I[4707,[],""]
4:I[6423,[],""]
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]]]]
0:["FgY9gJcnpj3lZXg7cOXvf",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},[["$L1",["$","$L2",null,{}],[["$","link","0",{"rel":"stylesheet","href":"/vl2-forge/_next/static/css/16a8d2abbd38d527.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

@ -218,6 +218,8 @@
display: grid;
place-content: center;
width: 24px;
font-size: 22px;
color: rgba(255, 255, 255, 0.9);
}
.PreviewIcon {
@ -231,6 +233,7 @@
background: rgba(0, 0, 0, 0.3);
padding: 3px 8px;
border-radius: 8px;
user-select: none;
}
@media (max-width: 767px) {

View file

@ -5,6 +5,9 @@ import JSZip from "jszip";
import { saveAs } from "file-saver";
import orderBy from "lodash.orderby";
import { FaTrashAlt } from "react-icons/fa";
import { MdCastle, MdTerrain } from "react-icons/md";
import { LuScrollText } from "react-icons/lu";
import { FaClipboardList, FaMapPin } from "react-icons/fa6";
import styles from "./Forge.module.css";
import { base64ArrayBuffer } from "./utils";
@ -19,11 +22,21 @@ function detectBestPath(path) {
folder = "";
basename = parts[0];
}
if (folder) {
return `${folder}/${basename}`;
}
if (
/\.(l|m|h)(male|female|bioderm)\.png$/i.test(basename) ||
/^(vehicle|weapon)_.+png$/i.test(basename)
/^(vehicle|weapon)_.+png$/i.test(basename) ||
/^dcase\d\d\.png$/i.test(basename)
) {
folder = "textures/skins";
} else if (/\.(ter|spn)$/i.test(basename)) {
folder = "terrains";
} else if (/\.mis$/i.test(basename)) {
folder = "missions";
} else if (/\.dif$/i.test(basename)) {
folder = "interiors";
}
if (folder) {
return `${folder}/${basename}`;
@ -68,7 +81,7 @@ function detectFileType(file): FileType | null {
return null;
}
function FilePreview({ file, onDelete }) {
function FilePreview({ file, onDelete, onRename }) {
let icon = null;
if (file.dataUri && file.type?.genericType === "image") {
icon = (
@ -79,11 +92,37 @@ function FilePreview({ file, onDelete }) {
alt=""
/>
);
} else if (/\.cs$/i.test(file.path)) {
icon = <LuScrollText />;
} else if (/\.mis$/i.test(file.path)) {
icon = <FaClipboardList />;
} else if (/\.dif$/i.test(file.path)) {
icon = <MdCastle />;
} else if (/\.ter$/i.test(file.path)) {
icon = <MdTerrain />;
} else if (/\.spn$/i.test(file.path)) {
icon = <FaMapPin />;
}
return (
<div className={styles.File}>
<span className={styles.IconContainer}>{icon}</span>{" "}
<span className={styles.Path}>{file.path}</span>
<span
className={styles.Path}
onDoubleClick={() => {
let newPath = window.prompt(`Rename file (${file.path}):`, file.path);
newPath = newPath
.trim()
.replace(/\/+/g, "/")
.replace(/^\//, "")
.replace(/\/$/, "")
.trim();
if (newPath !== file.path) {
onRename(file.path, newPath);
}
}}
>
{file.path}
</span>
<button
className={styles.DeleteButton}
type="button"
@ -276,6 +315,17 @@ export function Forge() {
});
}, []);
const handleRename = useCallback((oldPath, newPath) => {
setFiles((files) => {
const file = files.get(oldPath);
const newFile = { ...file, path: newPath };
const newFiles = new Map(files);
newFiles.delete(oldPath);
newFiles.set(newPath, newFile);
return newFiles;
});
}, []);
return (
<>
<section className={styles.Forge} {...getRootProps()}>
@ -295,7 +345,11 @@ export function Forge() {
{fileList.map((file) => {
return (
<li key={file.path}>
<FilePreview file={file} onDelete={handleDelete} />
<FilePreview
file={file}
onDelete={handleDelete}
onRename={handleRename}
/>
</li>
);
})}