snozbot / fungus

An easy to use Unity 3D library for creating illustrated Interactive Fiction games and more.
MIT License
1.63k stars 290 forks source link

Added feature: Say dialog text limits #943

Open Arylos07 opened 3 years ago

Arylos07 commented 3 years ago

Description

Who has had that moment of typing out a long bit of dialogue and forgot to see if it's too long? With me, way more than I care to admit.

So, this PR introduces Say Dialog character limits.

Screenshot_52

Say Dialogs now have new properties indicating the maximum text that can be displayed. These values are set by the developer based on how they design their dialogs; smaller text means larger text limits.

You can set the story text limits to 0 to turn off the counter. The counter will then display "[No Story Max Length]" and will not throw errors no matter how long you make it. This really shouldn't be done, but there are some cases where having a really long dialog box would be helpful.

Text tags do not count towards this limit, so {b}, {vpunch}, etc are not counted.

What is the current behavior?

As you type character/story text, there is no feedback of how long your text will be. Based on your Say Dialog set up, this can be problematic as you either split up text too much thinking there's too much in one say command, or you put too much in and you get some text cut off.

Granted, you could use an infinite text box or using Best Fit, but depending on your application, thay may not be the best option.

What is the new behavior?

Screenshot_53 Text close to the max will make the counter yellow Screenshot_54 Text over the limit will make the counter red and show an error in the summary. Screenshot_58 Screenshot_55

Screenshot_56 Screenshot_57

Screenshot_61

Backend changes

Important Notes

Other information

Important: because I did a silly, this PR includes changes from PR #934 which contains an optional boolean to Writer Audio. When merging this branch, 934 can be deleted as this already contains it.

Future updates could include having specific say commands ignore the text limits, just in case your Say Dialog is using Best Fit and you want just a couple commands to be a little longer than the rest, if such a feature is not added prior to merging this PR.

CG-Tespy commented 3 years ago

This is pretty great! ^_^

Arylos07 commented 3 years ago

This is pretty great! ^_^

Thanks! It's not the prettiest backend solution, but it was the best way I could get it to work but has been very helpful.

breadnone commented 3 years ago

Adding elipsis as an option to this would be nice. So when the text gets truncated, it will show ... (triple dots or user customizable), indicating that there's a continuation to the sentence. Just an idea, otherwise feel free to ignore it :)

Arylos07 commented 3 years ago

Adding elipsis as an option to this would be nice. So when the text gets truncated, it will show ... (triple dots or user customizable), indicating that there's a continuation to the sentence. Just an idea, otherwise feel free to ignore it :)

The built in Truncate function added that the say dialog uses does have "..." by default, so any time you call it without supplying a different suffix, it will use that instead. The reason it uses <!> is because the truncated text doesn't actually show up in a different dialog box or anything; it serves as a warning to the developer from the game that the text is too long, as a way to debug just in case the counter was missed. This can be changed in the Say command by changing what suffix it uses.

TheEmbracedOne commented 3 years ago

Thank you for this, this is exactly what I needed!