Cowzy Friday: Toolbar UI & Interfaces
- Wesley Chartrand
- Feb 28
- 3 min read
Welcome back to another Cowzy Friday update! This week will be much more technical! My major accomplishment has been making my Toolbar button preview mode use an Interface! Let's see how that works.

For those that may not know, Unreal describes Interfaces as follows: "When a class inherits from an Unreal Interface class, the interface ensures that the new class implements a common set of functions. This is useful when certain functionality might be shared by large, complex classes that are otherwise dissimilar." For more info: Interfaces in Unreal Engine.
How does Cowzy use it for the Toolbar?
In the case of Cowzy, Toolbar previews are implemented as an Interface. Here is how it works:
We have a base class BP_ToolbarPreviewMode.
BP_ToolbarPreviewMode implements the interface IToolbarPreviewMode.

Each mode, such as "Building" or "Path making" are children of BP_ToolbarPreviewMode.
BP_BuildingPreview
BP_ToolbarPathPreview
Each BP now implements the different functions defined in the IToolbarPreviewMode.

Getting more technical
For our BuildMode BP, you can see below that we have the LeftClickAction function which calls our PlaceBuilding event. In our Path BP, we have a similar function (that is not yet implemented).

We do this because in our PlayerController, we take the following steps when activating an option on the Toolbar:
We have an active control scheme for each Toolbar mode. Usually this is just a left click to override our Townsfolk option
We also have a BP_PlayerToolbarComponent that defines some functionality for changing which Toolbar mode is active
Function for removing a specific control scheme Check what our current option is set too
If we have an option selected and it's == to our current selection, then clear out our current selection, else, clear and add in our new one.
Note: We have an option for "None" so we can pass in None and it will clear everything.

Then, we update our input settings, activate the preview mode (stored as a variable implementing the interface), and update the Toolbar Enum to reflect the selected mode.
But Why?.gif
The biggest advantage to implementing an Interface is that we need to do the following now to implement a new Toolbar option:
Create the BP for it as a child of BP_ToolbarPreviewMode
Create the mapping context for the new BP
Implement the keypress for the Player controller as well
Create an entry in our Database
Implement the keypress functionality
And that's it! The PlayerController can handle any implementation from there because it's generic. Then we can focus purely on implementation. If we didn't use an Interface, then we'd still have to do all of the above, but we'd have to add additional functionality in the PlayerController to handle all of the different options.
The downsides to implementing an Interface is that it can be very time consuming upfront. However, this will help us reduce debugging in the future.
What else needs to be done?
I'd like to have when you press the associated key with a Toolbar option, or just click on it, it will visually activate the button. This won't be difficult to do.
More clear visual representation that something is happening when we activate path mode, but this isn't a high priority right now.
I'd like to add in a sub-menu for the building preview to show what can be built. This will help players quickly see available structures without extra UI clutter.
I may include a "cycle" option when pressing on the toolbar key to cycle through available options. Tiny Glade does this!!

What's next?
I want to define a little more functionality in the Toolbar before changing focus
Villagers will be able to work on actually building our buildings!!
Thanks for joining me this Cowzy Friday!! 🏗️🐄🔥
Comments