diff --git a/components/book/settings/BookSettingOption.tsx b/components/book/settings/BookSettingOption.tsx index b6e6c71..36971a7 100644 --- a/components/book/settings/BookSettingOption.tsx +++ b/components/book/settings/BookSettingOption.tsx @@ -7,6 +7,7 @@ import {RefObject, useRef} from "react"; import PanelHeader from "@/components/PanelHeader"; import LocationComponent from "@/components/book/settings/locations/LocationComponent"; import CharacterComponent from "@/components/book/settings/characters/CharacterComponent"; +import SpellComponent from "@/components/book/settings/spells/SpellComponent"; import QuillSenseSetting from "@/components/book/settings/quillsense/QuillSenseSetting"; import {useTranslations} from "next-intl"; // Ajouté pour la traduction @@ -36,6 +37,9 @@ export default function BookSettingOption( const characterRef: RefObject<{ handleSave: () => Promise } | null> = useRef<{ handleSave: () => Promise }>(null); + const spellRef: RefObject<{ handleSave: () => Promise } | null> = useRef<{ + handleSave: () => Promise + }>(null); const quillSenseRef: RefObject<{ handleSave: () => Promise } | null> = useRef<{ handleSave: () => Promise }>(null); @@ -54,6 +58,8 @@ export default function BookSettingOption( return t("bookSettingOption.yourLocations"); case 'characters': return t("bookSettingOption.characters"); + case 'spells': + return t("bookSettingOption.spells"); case 'objects': return t("bookSettingOption.objectsList"); case 'goals': @@ -85,6 +91,9 @@ export default function BookSettingOption( case 'characters': characterRef.current?.handleSave(); break; + case 'spells': + spellRef.current?.handleSave(); + break; case 'quillsense': quillSenseRef.current?.handleSave(); break; @@ -118,6 +127,8 @@ export default function BookSettingOption( ) : setting === 'characters' ? ( + ) : setting === 'spells' ? ( + ) : setting === 'quillsense' ? ( ) :
Promise } | null> = useRef<{ handleSave: () => Promise }>(null); const locationRef: RefObject<{ handleSave: () => Promise } | null> = useRef<{ handleSave: () => Promise }>(null); const characterRef: RefObject<{ handleSave: () => Promise } | null> = useRef<{ handleSave: () => Promise }>(null); + const spellRef: RefObject<{ handleSave: () => Promise } | null> = useRef<{ handleSave: () => Promise }>(null); async function handleSaveClick(): Promise { switch (currentPanel?.id) { @@ -40,11 +42,14 @@ export default function ComposerRightBar() { case 4: characterRef.current?.handleSave(); break; + case 5: + spellRef.current?.handleSave(); + break; default: break; } } - + function togglePanel(component: PanelComponent): void { if (panelHidden) { if (currentPanel?.id === component.id) { @@ -93,8 +98,15 @@ export default function ComposerRightBar() { badge: t("composerRightBar.editorComponents.characters.badge"), icon: faUsers }, - /*{ + { id: 5, + title: t("composerRightBar.editorComponents.spells.title"), + description: t("composerRightBar.editorComponents.spells.description"), + badge: t("composerRightBar.editorComponents.spells.badge"), + icon: faHatWizard + }, + /*{ + id: 6, title: t("composerRightBar.editorComponents.items.title"), description: t("composerRightBar.editorComponents.items.description"), badge: t("composerRightBar.editorComponents.items.badge"), @@ -148,7 +160,7 @@ export default function ComposerRightBar() { description={currentPanel?.description ?? ''} badge={currentPanel?.badge ?? ''} icon={currentPanel?.icon} - secondActionCallback={currentPanel?.id === 2 || currentPanel?.id === 3 || currentPanel?.id === 4 ? handleSaveClick : undefined} + secondActionCallback={currentPanel?.id === 2 || currentPanel?.id === 3 || currentPanel?.id === 4 || currentPanel?.id === 5 ? handleSaveClick : undefined} callBackAction={async () => setPanelHidden(!panelHidden)} />
@@ -164,6 +176,9 @@ export default function ComposerRightBar() { {currentPanel?.id === 4 && ( )} + {currentPanel?.id === 5 && ( + + )}
@@ -192,6 +207,10 @@ export default function ComposerRightBar() { if (component.id === 4 && !book?.tools?.characters) { return false; } + // Filter Spells if tools.spells is disabled + if (component.id === 5 && !book?.tools?.spells) { + return false; + } return true; }) .map((component: PanelComponent) => ( diff --git a/lib/locales/en.json b/lib/locales/en.json index 04ebfa1..44f9dc5 100644 --- a/lib/locales/en.json +++ b/lib/locales/en.json @@ -241,6 +241,11 @@ "description": "Create and manage your characters, their relationships, and story arcs.", "badge": "CHAR" }, + "spells": { + "title": "Spell Book", + "description": "Create and manage spells, magic systems, and supernatural abilities.", + "badge": "SPELL" + }, "items": { "title": "Items", "description": "Manage important items in your story.", @@ -548,6 +553,7 @@ "manageWorlds": "Manage worlds", "yourLocations": "Your locations", "characters": "Characters", + "spells": "Spell Book", "objectsList": "Objects list", "bookGoals": "Book goals", "quillsense": "QuillSense Settings", @@ -869,6 +875,7 @@ "world": "Worlds", "locations": "Locations", "characters": "Characters", + "spells": "Spells", "objects": "Objects", "goals": "Goals", "quillsense": "QuillSense" diff --git a/lib/locales/fr.json b/lib/locales/fr.json index c2b7a00..36390dc 100644 --- a/lib/locales/fr.json +++ b/lib/locales/fr.json @@ -241,6 +241,11 @@ "description": "Créez et gérez vos personnages, leurs relations et leurs arcs narratifs.", "badge": "CHAR" }, + "spells": { + "title": "Livre des sortilèges", + "description": "Créez et gérez les sortilèges, systèmes de magie et capacités surnaturelles.", + "badge": "SPELL" + }, "items": { "title": "Objets", "description": "Gérez les objets importants de votre histoire.", @@ -548,6 +553,7 @@ "manageWorlds": "Gérer les mondes", "yourLocations": "Vos lieux", "characters": "Les personnages", + "spells": "Livre des sortilèges", "objectsList": "Liste des objets", "bookGoals": "Objectifs du livre", "quillsense": "Parametres QuillSense", @@ -870,6 +876,7 @@ "world": "Mondes", "locations": "Emplacements", "characters": "Personnages", + "spells": "Sortilèges", "objects": "Objets", "goals": "Buts", "quillsense": "QuillSense"