{localization.localize(`${localizationPath}.hints.requiresCatalysts`)}
+{truncate(unit.part.name, nameLength)}
-{truncate(unit.element.name, nameLength)}
+{truncate(unit.target.element.name, nameLength)}
+{formatQuantity(unit.actual.quantity, unit.target.quantity)}
+${localization.format(`${localizationPath}.dialog.doSalvage.content`, { componentName: craftingComponent.name})}
`, + content: `${localization.format(`${localizationPath}.dialog.doSalvage.content`, { componentName: componentSalvageManager.componentToSalvage.name })}
`, yes: async () => { confirm = true; } }); if (confirm) { - return salvageComponent(craftingComponent); + return salvageComponent(); } } - async function salvageComponent(craftingComponent) { - const salvageResult = new SuccessfulSalvageResult({ - created: craftingComponent.selectedSalvage, - consumed: Combination.of(craftingComponent, 1) - }); - await inventory.acceptSalvageResult(salvageResult); + async function salvageComponent() { + await componentSalvageManager.doSalvage(selectedSalvageAttempt.optionId); + await loadAppData(); } - function handleComponentUpdated(event) { + async function handleComponentUpdated(event) { const updatedComponent = event.detail; - if (updatedComponent.id !== craftingComponent.id) { + if (updatedComponent.id !== componentSalvageManager.componentToSalvage.id) { return; } - craftingComponent = updatedComponent; - selectedOptionName = craftingComponent.firstOptionName; - craftingComponent.selectSalvageOption(selectedOptionName); - if (!craftingComponent.isSalvageable) { + if (!updatedComponent.isSalvageable) { closeHook(); return; } + await loadAppData(); } - async function handleItemUpdated(event) { - const { sourceId, actor } = event.detail; - // If the modified item is not owned, not owned by the actor who owns this crafting component, or is not associated with this component - if (!actor || !actor.id === inventory.actor.id || sourceId !== craftingComponent.itemUuid) { - // do nothing + async function reloadApplicableInventoryEvents(event) { + const actor = event.detail.actor; + const sourceId = event.detail.sourceId; + if (!actor) { + throw new Error("No actor provided in event detail"); + } + if (!sourceId) { + throw new Error("No sourceId provided in event detail"); + } + // If the modified item is not owned, or not owned by the actor who owns this crafting component + if (actor.id !== componentSalvageManager.actor.id) { return; } // if it is, we need to re-index the inventory - return reIndex(); + return loadAppData(); } - async function handleItemCreated(event) { - const {sourceId, actor} = event.detail; - if (!actor?.id === inventory.actor.id || sourceId !== craftingComponent.itemUuid) { - return; - } - return reIndex(); + async function handleItemUpdated(event) { + await reloadApplicableInventoryEvents(event); } - async function handleItemDeleted(event) { - const {sourceId, actor} = event.detail; - if (!actor?.id === inventory.actor.id || sourceId !== craftingComponent.itemUuid) { - return; - } - await reIndex(); - if (ownedComponentsOfType.isEmpty()) { - closeHook(); - } + async function handleItemCreated(event) { + await reloadApplicableInventoryEvents(event); } - async function reIndex() { - await inventory.index(); - const ownedComponents = inventory.ownedComponents; - ownedComponentsOfType = ownedComponents.just(craftingComponent); + async function handleItemDeleted(event) { + await reloadApplicableInventoryEvents(event); } -{localization.localize(`${localizationPath}.hints.doSalvage`)}:
-{localization.localize(`${localizationPath}.hints.doSalvage`)}:
+{localization.localize(`${localizationPath}.hints.requiresCatalysts`)}
+{localization.localize(`${localizationPath}.hints.doSalvage`)}:
- - {:else} -{localization.localize(`${localizationPath}.errors.notSalvageable`)}
-{localization.localize(`${localizationPath}.errors.notSalvageable`)}
+{localization.localize(`${localizationPath}.errors.notSalvageable`)}
+${this._localization.format(`${CraftingSystemEditor._dialogLocalizationPath}.deleteSystemConfirm.content`, {systemName: craftingSystemToDelete.name})}
`, + content: `${this._localization.format(`${CraftingSystemEditor._dialogLocalizationPath}.deleteSystemConfirm.content`, {systemName: craftingSystemToDelete.details.name})}
`, yes: async () => { - await this._systemRegistry.deleteCraftingSystemById(craftingSystemToDelete.id); - const message = this._localization.format(`${CraftingSystemEditor._dialogLocalizationPath}.deleteCraftingSystem.success`, { systemName: craftingSystemToDelete.name}); + await this._fabricateAPI.deleteAllByCraftingSystemId(craftingSystemToDelete.id); this._craftingSystems.update((craftingSystems) => { - const filtered = craftingSystems.filter(craftingSystem => craftingSystem.id !== craftingSystemToDelete.id); - ui.notifications.info(message); - return filtered; + return craftingSystems.filter(craftingSystem => craftingSystem.id !== craftingSystemToDelete.id); }); } }); } - async importCraftingSystem(onSuccess?: (craftingSystem: CraftingSystem) => void, targetSystem?: CraftingSystem): Promise{localization.format(`${localizationPath}.component.info.noAvailableEssences`, { systemName: $selectedCraftingSystem.name, componentName: selectedComponent.name })}
{localization.format(`${localizationPath}.component.info.noAvailableEssences`, { systemName: $selectedCraftingSystem.details.name, componentName: $selectedComponent.name })}
{component.name}
- {#if component.hasErrors}{/if} -{component.name}
+{component.name}
+{localization.localize(`${localizationPath}.noneFound`)}
- {#if !$selectedCraftingSystem.isLocked}{localization.localize(`${localizationPath}.create`)}
{/if} + {#if !$selectedCraftingSystem.isEmbedded}{localization.localize(`${localizationPath}.create`)}
{/if}{localization.localize(`${localizationPath}.labels.name`)}:
- {#if !$selectedCraftingSystem?.isLocked} + {#if !$selectedCraftingSystem?.isEmbedded}{localization.localize(`${localizationPath}.labels.summary`)}:
{localization.localize(`${localizationPath}.labels.description`)}:
{localization.localize(`${localizationPath}.settings.enabled.label`)}:
+{localization.localize(`${localizationPath}.settings.disabled.label`)}:
{localization.localize(`${localizationPath}.settings.enabled.description`)}
+{localization.localize(`${localizationPath}.settings.disabled.description`)}