Working dialogue images mixed with text

This commit is contained in:
Michal Pikulski
2025-10-08 11:27:27 +02:00
parent 1a05f89226
commit 5ad3ae8815
9 changed files with 485 additions and 363 deletions

View File

@@ -76,20 +76,29 @@ namespace Dialogue
{
if (speechBubble == null || !HasAnyLines()) return;
// Advance the dialogue state to move to the next content
AdvanceDialogueState();
// Check if we have DialogueContent available
// Check if we have DialogueContent available (prioritizing the new content system)
DialogueContent content = GetCurrentDialogueContent();
if (content != null)
{
// Display the content with the new method that handles both text and images
// Display the content with the method that handles both text and images
// and pass whether there are more lines available for prompt display
speechBubble.DisplayDialogueContent(content, HasAnyLines());
// Log the content type for debugging
Debug.Log($"Displaying content type: {content.ContentType} - {(content.ContentType == DialogueContentType.Text ? content.Text : content.Image?.name)}");
}
else
{
// Fall back to legacy text-only method
// Fall back to legacy text-only method if no DialogueContent is available
string line = GetCurrentDialogueLine();
speechBubble.DisplayDialogueLine(line, HasAnyLines());
// Log for debugging
Debug.Log($"Displaying legacy text: {line}");
}
}
@@ -139,6 +148,7 @@ namespace Dialogue
int index = Mathf.Clamp(currentLineIndex, 0, contentForState.Count - 1);
return contentForState[index];
}
return null; // No content for this slot state
}
else
{
@@ -281,18 +291,41 @@ namespace Dialogue
return;
}
// If we have more lines in the current node, advance to the next line
if (currentLineIndex < currentNode.dialogueLines.Count - 1)
// First check if we have any dialogueContent to process
bool hasDialogueContent = currentNode.dialogueContent != null && currentNode.dialogueContent.Count > 0;
if (hasDialogueContent)
{
currentLineIndex++;
return;
}
// If we have dialogueContent and there are more entries, advance to the next one
if (currentLineIndex < currentNode.dialogueContent.Count - 1)
{
currentLineIndex++;
return;
}
// If we should loop through lines, reset the index
if (currentNode.loopThroughLines && currentNode.dialogueLines.Count > 0)
// If we should loop through content, reset the index
if (currentNode.loopThroughLines && currentNode.dialogueContent.Count > 0)
{
currentLineIndex = 0;
return;
}
}
else
{
currentLineIndex = 0;
return;
// Fall back to legacy dialogueLines
// If we have more lines in the current node, advance to the next line
if (currentLineIndex < currentNode.dialogueLines.Count - 1)
{
currentLineIndex++;
return;
}
// If we should loop through lines, reset the index
if (currentNode.loopThroughLines && currentNode.dialogueLines.Count > 0)
{
currentLineIndex = 0;
return;
}
}
// If we're at a node that doesn't have a next node, we're done