1
This commit is contained in:
@@ -64,6 +64,7 @@ function buildDefaultAnimationPromptTextByKey(defaultText: string) {
|
||||
function pickCachedAnimationPromptTextByKey(
|
||||
cache: CharacterAssetWorkflowCache,
|
||||
fallbackText: string,
|
||||
preferFreshRoleText: boolean,
|
||||
) {
|
||||
const fromCache = cache.animationPromptTextByKey ?? {};
|
||||
|
||||
@@ -73,8 +74,9 @@ function pickCachedAnimationPromptTextByKey(
|
||||
const legacyText = cache.animationPromptText?.trim();
|
||||
return {
|
||||
...result,
|
||||
[action.animation]:
|
||||
cachedText && !isLegacyGeneratedActionDescription(cachedText)
|
||||
[action.animation]: preferFreshRoleText
|
||||
? fallbackText
|
||||
: cachedText && !isLegacyGeneratedActionDescription(cachedText)
|
||||
? cachedText
|
||||
: legacyText && !isLegacyGeneratedActionDescription(legacyText)
|
||||
? legacyText
|
||||
@@ -487,6 +489,7 @@ function buildAnimationPreviewCharacter(params: {
|
||||
export interface RpgCreationRoleAssetStudioModalProps {
|
||||
role: EditableCustomWorldRole;
|
||||
roleKind: 'playable' | 'story';
|
||||
cacheScopeId?: string;
|
||||
onApply?: (nextRole: EditableCustomWorldRole) => void;
|
||||
onPublishSuccess?: (
|
||||
payload: {
|
||||
@@ -509,6 +512,7 @@ export interface RpgCreationRoleAssetStudioModalProps {
|
||||
export function RpgCreationRoleAssetStudioModal({
|
||||
role,
|
||||
roleKind,
|
||||
cacheScopeId,
|
||||
onApply,
|
||||
onPublishSuccess,
|
||||
onClose,
|
||||
@@ -746,13 +750,16 @@ export function RpgCreationRoleAssetStudioModal({
|
||||
setSaveStatus(null);
|
||||
setIsHydratingCache(true);
|
||||
|
||||
void fetchCharacterWorkflowCache(baseRole.id)
|
||||
void fetchCharacterWorkflowCache(baseRole.id, cacheScopeId)
|
||||
.then((result) => {
|
||||
if (cancelled || !result.cache) {
|
||||
return;
|
||||
}
|
||||
|
||||
const cache = result.cache;
|
||||
if (cacheScopeId && cache.cacheScopeId !== cacheScopeId) {
|
||||
return;
|
||||
}
|
||||
const nextRole = mergeRole(baseRole, {
|
||||
imageSrc: cache.imageSrc ?? baseRole.imageSrc,
|
||||
generatedVisualAssetId:
|
||||
@@ -765,7 +772,8 @@ export function RpgCreationRoleAssetStudioModal({
|
||||
});
|
||||
setWorkingRole(nextRole);
|
||||
setVisualPromptText(
|
||||
cache.visualPromptText &&
|
||||
!baseRole.visualDescription?.trim() &&
|
||||
cache.visualPromptText &&
|
||||
!isLegacyGeneratedVisualDescription(cache.visualPromptText)
|
||||
? cache.visualPromptText
|
||||
: initialPromptBundle.visualPromptText,
|
||||
@@ -774,6 +782,7 @@ export function RpgCreationRoleAssetStudioModal({
|
||||
pickCachedAnimationPromptTextByKey(
|
||||
cache,
|
||||
initialPromptBundle.animationPromptText,
|
||||
Boolean(baseRole.actionDescription?.trim()),
|
||||
),
|
||||
);
|
||||
setVisualDrafts(cache.visualDrafts ?? []);
|
||||
@@ -798,7 +807,7 @@ export function RpgCreationRoleAssetStudioModal({
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [baseRole, initialPromptBundle, roleSnapshotKey]);
|
||||
}, [baseRole, cacheScopeId, initialPromptBundle, roleSnapshotKey]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isHydratingCache) {
|
||||
@@ -808,8 +817,10 @@ export function RpgCreationRoleAssetStudioModal({
|
||||
const timer = window.setTimeout(() => {
|
||||
const payload: CharacterAssetWorkflowCache = {
|
||||
characterId: workingRole.id,
|
||||
cacheScopeId,
|
||||
visualPromptText,
|
||||
animationPromptText,
|
||||
animationPromptTextByKey,
|
||||
visualDrafts,
|
||||
selectedVisualDraftId,
|
||||
selectedAnimation,
|
||||
@@ -829,9 +840,11 @@ export function RpgCreationRoleAssetStudioModal({
|
||||
};
|
||||
}, [
|
||||
animationPromptText,
|
||||
animationPromptTextByKey,
|
||||
isHydratingCache,
|
||||
selectedAnimation,
|
||||
selectedVisualDraftId,
|
||||
cacheScopeId,
|
||||
visualDrafts,
|
||||
visualPromptText,
|
||||
workingRole.animationMap,
|
||||
@@ -1137,7 +1150,12 @@ export function RpgCreationRoleAssetStudioModal({
|
||||
workingRoleGeneratedVisualAssetId={workingRole.generatedVisualAssetId}
|
||||
workingRoleImageSrc={workingRole.imageSrc}
|
||||
workingRoleName={workingRole.name}
|
||||
onAnimationPromptChange={setAnimationPromptText}
|
||||
onAnimationPromptChange={(value) => {
|
||||
setAnimationPromptTextByKey((current) => ({
|
||||
...current,
|
||||
[selectedAnimation]: value,
|
||||
}));
|
||||
}}
|
||||
onGenerateAnimation={() => {
|
||||
void handleGenerateAnimation();
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user