feat: add 'save as global NPC' toggle for story characters
This commit is contained in:
@@ -274,7 +274,7 @@ export default function CreateStoryPage() {
|
||||
const handleCharacterChange = (
|
||||
index: number,
|
||||
field: keyof Character,
|
||||
value: string,
|
||||
value: string | boolean,
|
||||
) => {
|
||||
const newCharacters = [...form.characters];
|
||||
newCharacters[index] = { ...newCharacters[index], [field]: value };
|
||||
@@ -454,7 +454,10 @@ export default function CreateStoryPage() {
|
||||
const saveCharactersAsGlobalNPCs = async () => {
|
||||
const existingNames = savedNPCs.map((npc) => npc.name.toLowerCase());
|
||||
|
||||
for (const char of storyCharacters) {
|
||||
// Only save characters that have saveAsGlobal flag enabled
|
||||
const charsToSave = storyCharacters.filter((c) => c.saveAsGlobal);
|
||||
|
||||
for (const char of charsToSave) {
|
||||
// Skip if NPC with this name already exists
|
||||
if (existingNames.includes(char.name.toLowerCase())) {
|
||||
continue;
|
||||
@@ -1046,6 +1049,20 @@ export default function CreateStoryPage() {
|
||||
placeholder="Описание персонажа..."
|
||||
rows={2}
|
||||
/>
|
||||
<label className="save-global-toggle">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={char.saveAsGlobal || false}
|
||||
onChange={(e) =>
|
||||
handleCharacterChange(
|
||||
index,
|
||||
"saveAsGlobal",
|
||||
e.target.checked,
|
||||
)
|
||||
}
|
||||
/>
|
||||
<span>Сделать общим (добавить в библиотеку NPC)</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user