mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
feat: show furnidata diagnostics in editor
This commit is contained in:
@@ -16,7 +16,7 @@ export const FurniEditorView: FC<{}> = () =>
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
items, total, page, loading, error, clearError,
|
items, total, page, loading, error, clearError,
|
||||||
selectedItem, setSelectedItem, furniDataEntry,
|
selectedItem, setSelectedItem, furniDataEntry, furniDataDiagnostic,
|
||||||
interactions,
|
interactions,
|
||||||
searchItems, loadDetail, loadBySpriteId, updateItem, deleteItem, loadInteractions,
|
searchItems, loadDetail, loadBySpriteId, updateItem, deleteItem, loadInteractions,
|
||||||
updateFurnidata, revertFurnidata, importText, importResult
|
updateFurnidata, revertFurnidata, importText, importResult
|
||||||
@@ -151,6 +151,7 @@ export const FurniEditorView: FC<{}> = () =>
|
|||||||
<FurniEditorEditView
|
<FurniEditorEditView
|
||||||
item={ selectedItem }
|
item={ selectedItem }
|
||||||
furniDataEntry={ furniDataEntry }
|
furniDataEntry={ furniDataEntry }
|
||||||
|
furniDataDiagnostic={ furniDataDiagnostic }
|
||||||
interactions={ interactions }
|
interactions={ interactions }
|
||||||
loading={ loading }
|
loading={ loading }
|
||||||
onUpdate={ updateItem }
|
onUpdate={ updateItem }
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ interface FurniEditorEditViewProps
|
|||||||
{
|
{
|
||||||
item: FurniDetail;
|
item: FurniDetail;
|
||||||
furniDataEntry: Record<string, unknown> | null;
|
furniDataEntry: Record<string, unknown> | null;
|
||||||
|
furniDataDiagnostic: Record<string, unknown> | null;
|
||||||
interactions: string[];
|
interactions: string[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
onUpdate: (id: number, fields: Record<string, unknown>) => void;
|
onUpdate: (id: number, fields: Record<string, unknown>) => void;
|
||||||
@@ -121,7 +122,7 @@ const CopyValue: FC<{ value: string | number }> = ({ value }) =>
|
|||||||
|
|
||||||
export const FurniEditorEditView: FC<FurniEditorEditViewProps> = props =>
|
export const FurniEditorEditView: FC<FurniEditorEditViewProps> = props =>
|
||||||
{
|
{
|
||||||
const { item, furniDataEntry, interactions, loading, onUpdate, onDelete, onBack, onUpdateFurnidata, onRevertFurnidata, onImportText, importResult } = props;
|
const { item, furniDataEntry, furniDataDiagnostic, interactions, loading, onUpdate, onDelete, onBack, onUpdateFurnidata, onRevertFurnidata, onImportText, importResult } = props;
|
||||||
const saveRef = useRef<() => void>(null);
|
const saveRef = useRef<() => void>(null);
|
||||||
|
|
||||||
const [ form, setForm ] = useState({
|
const [ form, setForm ] = useState({
|
||||||
@@ -252,6 +253,14 @@ export const FurniEditorEditView: FC<FurniEditorEditViewProps> = props =>
|
|||||||
furniName !== String(furniDataEntry?.name ?? '') || furniDescription !== String(furniDataEntry?.description ?? ''),
|
furniName !== String(furniDataEntry?.name ?? '') || furniDescription !== String(furniDataEntry?.description ?? ''),
|
||||||
[ furniName, furniDescription, furniDataEntry ]);
|
[ furniName, furniDescription, furniDataEntry ]);
|
||||||
|
|
||||||
|
const furnidataMissReason = useMemo(() =>
|
||||||
|
{
|
||||||
|
const reason = String(furniDataDiagnostic?.reason ?? '');
|
||||||
|
return reason || 'not_found';
|
||||||
|
}, [ furniDataDiagnostic ]);
|
||||||
|
|
||||||
|
const furnidataSourcePath = String(furniDataDiagnostic?.sourcePath ?? '');
|
||||||
|
|
||||||
// Apply an "Import from Habbo" result into the editable fields (review then Save).
|
// Apply an "Import from Habbo" result into the editable fields (review then Save).
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
@@ -391,7 +400,7 @@ export const FurniEditorEditView: FC<FurniEditorEditViewProps> = props =>
|
|||||||
) : (
|
) : (
|
||||||
<div className="flex items-start gap-2 text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded-lg px-2.5 py-2 leading-snug">
|
<div className="flex items-start gap-2 text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded-lg px-2.5 py-2 leading-snug">
|
||||||
<span className="text-[#f59e0b] text-sm leading-none mt-px">⚠</span>
|
<span className="text-[#f59e0b] text-sm leading-none mt-px">⚠</span>
|
||||||
<span>This furni has no matching <b>furnidata</b> entry (e.g. a pet or custom item), so its display name can't be edited here. Clients fall back to the DB <b>Public Name</b> below.</span>
|
<span>This furni has no matching <b>furnidata</b> entry ({ furnidataMissReason.replace(/_/g, ' ') }), so its display name can't be edited here. Clients fall back to the DB <b>Public Name</b> below.</span>
|
||||||
</div>
|
</div>
|
||||||
) }
|
) }
|
||||||
</div>
|
</div>
|
||||||
@@ -424,6 +433,20 @@ export const FurniEditorEditView: FC<FurniEditorEditViewProps> = props =>
|
|||||||
</Section>
|
</Section>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<Section title="Furnidata Debug" defaultOpen={ false }>
|
||||||
|
<div className="grid grid-cols-2 gap-2 mb-2">
|
||||||
|
<div>
|
||||||
|
<label className={ labelClass }>Resolution</label>
|
||||||
|
<CopyValue value={ furnidataMissReason } />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className={ labelClass }>Source</label>
|
||||||
|
<CopyValue value={ furnidataSourcePath || 'unresolved' } />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<pre className="text-[10px] leading-snug text-slate-600 bg-slate-50 border border-slate-200 rounded-lg p-2 overflow-auto max-h-40 whitespace-pre-wrap break-all font-mono">{ JSON.stringify(furniDataDiagnostic ?? {}, null, 2) }</pre>
|
||||||
|
</Section>
|
||||||
|
|
||||||
<Section title="Dimensions">
|
<Section title="Dimensions">
|
||||||
<div className="grid grid-cols-3 gap-2">
|
<div className="grid grid-cols-3 gap-2">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ export const useFurniEditor = () =>
|
|||||||
const [ catalogItems, setCatalogItems ] = useState<CatalogRef[]>([]);
|
const [ catalogItems, setCatalogItems ] = useState<CatalogRef[]>([]);
|
||||||
const [ interactions, setInteractions ] = useState<string[]>([]);
|
const [ interactions, setInteractions ] = useState<string[]>([]);
|
||||||
const [ furniDataEntry, setFurniDataEntry ] = useState<Record<string, unknown> | null>(null);
|
const [ furniDataEntry, setFurniDataEntry ] = useState<Record<string, unknown> | null>(null);
|
||||||
|
const [ furniDataDiagnostic, setFurniDataDiagnostic ] = useState<Record<string, unknown> | null>(null);
|
||||||
const pendingActionRef = useRef<{ action: string; itemId: number } | null>(null);
|
const pendingActionRef = useRef<{ action: string; itemId: number } | null>(null);
|
||||||
const [ importResult, setImportResult ] = useState<{ found: boolean; name: string; description: string; classname: string; nonce: number } | null>(null);
|
const [ importResult, setImportResult ] = useState<{ found: boolean; name: string; description: string; classname: string; nonce: number } | null>(null);
|
||||||
const importNonceRef = useRef(0);
|
const importNonceRef = useRef(0);
|
||||||
@@ -152,6 +153,20 @@ export const useFurniEditor = () =>
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
setFurniDataEntry(furniData);
|
setFurniDataEntry(furniData);
|
||||||
|
|
||||||
|
let diagnostic: Record<string, unknown> | null = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(parser.furniDataDiagnosticJson && parser.furniDataDiagnosticJson !== '{}' && parser.furniDataDiagnosticJson !== '')
|
||||||
|
{
|
||||||
|
diagnostic = JSON.parse(parser.furniDataDiagnosticJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{}
|
||||||
|
|
||||||
|
setFurniDataDiagnostic(diagnostic);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle interaction types list
|
// Handle interaction types list
|
||||||
@@ -203,6 +218,7 @@ export const useFurniEditor = () =>
|
|||||||
setSelectedItem(null);
|
setSelectedItem(null);
|
||||||
setCatalogItems([]);
|
setCatalogItems([]);
|
||||||
setFurniDataEntry(null);
|
setFurniDataEntry(null);
|
||||||
|
setFurniDataDiagnostic(null);
|
||||||
|
|
||||||
if(simpleAlert)
|
if(simpleAlert)
|
||||||
{
|
{
|
||||||
@@ -295,7 +311,7 @@ export const useFurniEditor = () =>
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
items, total, page, loading, error, clearError,
|
items, total, page, loading, error, clearError,
|
||||||
selectedItem, setSelectedItem, catalogItems, furniDataEntry,
|
selectedItem, setSelectedItem, catalogItems, furniDataEntry, furniDataDiagnostic,
|
||||||
interactions,
|
interactions,
|
||||||
searchItems, loadDetail, loadBySpriteId, updateItem, deleteItem, loadInteractions,
|
searchItems, loadDetail, loadBySpriteId, updateItem, deleteItem, loadInteractions,
|
||||||
updateFurnidata, revertFurnidata, importText, importResult
|
updateFurnidata, revertFurnidata, importText, importResult
|
||||||
|
|||||||
Reference in New Issue
Block a user