I have recently discovered the SUDS Pro dialogue system and was amazed by how many of my concerns regarding game dialogue it resolves. Not only that, SUDS Pro also takes care of a lot of related tasks that I did not even think of yet, such as triggering camera shake from dialogues. All in all, one can say that I am very happy with the purchase.
In this article series, I am documenting my way of adapting the dialogue system. It does not aim at developing basic understanding for SUDS Pro. There is an excellent documentation page as well as a great example project that will help you with that.
This article will be about the boilerplate code that is necessary to allow for a C++ based user interface for SUDS Pro.
Custom integration
By default, SUDS Pro assumes that you keep the dialogue UI in Blueprint. The reason is that default way of connecting your UserWidget to the dialogue is by implementing the Blueprint interface BP_SudsProDialogueWidgetInterface, an act only possible in Blueprint. You cannot implement a Blueprint interface in C++.
Probably, most people will be just fine with that. However, I like to keep all the logic of my UIs in C++ for better maintainability and diff-ability.
The interface itself is straightforward since there is nothing to do except declaring the interface methods. However, the Unreal interface system has some peculiarities. Leaving the interface methods unimplemented and declaring them PURE_VIRTUAL will lead to an error when the corresponding method is called of a class implementing this interface.
An alternative would be to mark the methods BlueprintNativeEvents. However, this would allow implementing them in Blueprint. For Blueprint usage we already have BP_SudsProDialogueWidgetInterface.
The solution is to include an empty definition for each method.
CodoDialogueWidgetInterface.h:
C++ based UI Widget Link
There is nothing wrong with the BP_SudsProUiWidgetLink. A simple re-implementation of it with the references to the dialogue widget interface changed to UCodoDialogueWidgetInterface is enough.
CodoDialogueUiLink.h:
CodoDialogueUiLink.cpp:
Tying everything together
We need to make our classes known to SUDS Pro. This can be done by settings the CodoDialogueUiLink class as the default UI class in the SUDS Pro part of the project settings.
Lastly, the only thing missing is an actual widget for the dialogue. The next article will be about how to use the newly created interface in a UserWidget (once it is ready).