From 0283b5173bfa11d8f6ecb94c124f3cbdc08bcb4e Mon Sep 17 00:00:00 2001 From: matthieu Date: Wed, 29 Oct 2025 16:29:41 +0100 Subject: [PATCH] [ISSUE-1] Update src/App.tsx - Modular NPC refactor --- src/App.tsx | 224 ++++++++++++++-------------------------------------- 1 file changed, 58 insertions(+), 166 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 3e73d65..2cdd73b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,20 +1,11 @@ -import { useState, useEffect } from 'react'; -import { Settings, MessageSquare, Sword, Users, Code, FileText, Upload } from 'lucide-react'; -import type { NPCConfiguration, DialogueConfiguration } from './types/npc'; -import { NPCBasicSettings } from './components/NPCBasicSettings'; -import { NPCBattleConfiguration } from './components/NPCBattleConfiguration'; -import { NPCPartyBuilder } from './components/NPCPartyBuilder'; -import { NPCInteractionEditor } from './components/NPCInteractionEditor'; -import { ConfigVariablesEditor } from './components/ConfigVariablesEditor'; -import { DialogueEditor } from './components/DialogueEditor'; -import { JSONPreview } from './components/JSONPreview'; -import { ImportExport } from './components/ImportExport'; - -type Tab = 'basic' | 'battle' | 'party' | 'interaction' | 'variables' | 'dialogue' | 'preview' | 'import'; +import { useState } from 'react'; +import { Sparkles, Grid } from 'lucide-react'; +import type { NPCConfiguration } from './types/npc'; +import { NodeCanvas } from './components/NodeCanvas'; function App() { - const [activeTab, setActiveTab] = useState('basic'); - + const [viewMode, setViewMode] = useState<'modular' | 'classic'>('modular'); + const [npcConfig, setNpcConfig] = useState({ id: 'my_npc', name: 'My NPC', @@ -26,173 +17,74 @@ function App() { resourceIdentifier: 'cobblemon:my_npc' }); - const [dialogueConfig, setDialogueConfig] = useState(null); - - useEffect(() => { - if (npcConfig.interactions && npcConfig.interactions.length > 0 && npcConfig.interactions[0].type === 'dialogue' && !dialogueConfig) { - const newDialogue: DialogueConfiguration = { - speakers: { - npc: { - name: { type: 'expression', expression: 'q.npc.name' }, - face: 'q.npc.face(false);' - }, - player: { - name: { type: 'expression', expression: 'q.player.username' }, - face: 'q.player.face();' - } - }, - pages: [{ - id: 'greeting', - speaker: 'npc', - lines: ['Hello there!'], - input: 'q.dialogue.close();' - }] - }; - setDialogueConfig(newDialogue); - } - }, [npcConfig.interactions, dialogueConfig]); - - const tabs = [ - { id: 'basic', name: 'Basic Settings', icon: Settings }, - { id: 'battle', name: 'Battle Config', icon: Sword }, - { id: 'party', name: 'Pokemon Party', icon: Users }, - { id: 'interaction', name: 'Interaction', icon: MessageSquare }, - { id: 'variables', name: 'Variables', icon: Code }, - { id: 'dialogue', name: 'Dialogue', icon: MessageSquare }, - { id: 'preview', name: 'JSON Preview', icon: FileText }, - { id: 'import', name: 'Import/Export', icon: Upload } - ]; - - const renderActiveTab = () => { - switch (activeTab) { - case 'basic': - return ; - case 'battle': - return ; - case 'party': - return ; - case 'interaction': - return ; - case 'variables': - return ; - case 'dialogue': - return ; - case 'preview': - return ; - case 'import': - return ( - { - if (configs.length > 0) { - setNpcConfig(configs[0]); - } - }} - /> - ); - default: - return null; - } - }; - return (
{/* Header */} -
+
-
+

Cobblemon NPC Creator

+
+ + Modular Edition +
-
- Create and customize NPCs for your Cobblemon mod +
+
+ Build NPCs with connectable modules +
+
+ + +
-
-
- {/* Sidebar Navigation */} -
- - - {/* Quick Info Panel */} -
-

Current NPC

-
-
-
Name
-
{npcConfig.names[0] || 'Unnamed'}
-
-
-
Type
-
- {npcConfig.battleConfiguration?.canChallenge ? 'Trainer' : 'NPC'} -
-
-
-
Interaction
-
- {npcConfig.interactions && npcConfig.interactions.length > 0 - ? npcConfig.interactions[0].type - : 'none'} -
-
-
-
Variables
-
{npcConfig.config?.length || 0}
-
-
-
-
- - {/* Main Content */} -
-
-
- {renderActiveTab()} -
-
+ {/* Main Content - Full Screen Canvas */} + {viewMode === 'modular' ? ( + + ) : ( +
+
+

Classic View

+

Coming soon...

-
- - {/* Footer */} - + )}
); }