feat: add 'save as global NPC' toggle for story characters
This commit is contained in:
@@ -714,6 +714,27 @@
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.save-global-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-top: 0.5rem;
|
||||
font-size: 0.85rem;
|
||||
color: #888;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.save-global-toggle input[type="checkbox"] {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
accent-color: #667eea;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.save-global-toggle:hover {
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
/* Подсказки */
|
||||
.hint {
|
||||
display: block;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -10,6 +10,7 @@ export interface Character {
|
||||
age?: CharacterAge; // возраст персонажа
|
||||
gender?: CharacterGender; // пол персонажа
|
||||
avatarUrl?: string; // URL аватара персонажа
|
||||
saveAsGlobal?: boolean; // сохранить как глобального NPC
|
||||
}
|
||||
|
||||
// NPC персонаж (сохранённый в БД)
|
||||
|
||||
Reference in New Issue
Block a user