Skip to content

Making a custom item clicker

FreemanMakesGames edited this page Sep 4, 2020 · 6 revisions

FMGInvSys provides an item clicker WBP_FMGInvSysItemClicker. By default it's shared by all items. But you can make your own ones.

Creating the widget blueprint

It's easier to start by making a copy of WBP_FMGInvSysItemClicker outside of the plugin, because it comes with some animations for highlighting various actions. Skip to the next section if you are making a copy.

To make your own item clicker from scratch, first create a widget blueprint. If the item clicker is to be shared among common items, name it something like WBP_ItemClicker. If it's for a special item, name it something like WBP_<ItemName>. Re-parent it to FMGInvSysItemClicker, the C++ base class, not the blueprint one. As the compiler shows, we need to add a button, and name it Clicker. The button will both display the item icon, and accept player's mouse click. We also need to add a text block, and name it Text_Count. The text will display the number of items in this stack.

Customization

Customization is where you have a great deal of freedom. You can add new widgets or change existing ones. To hide Text_Count though, you'll need to change its visibility. Note that at run time, in UFMGInvSysItemClicker::SetItemCore_Implementation, the item clicker will put item core's Icon onto Clicker, and set Clicker to draw as image. If these are not what you want, then you need to set the "Custom Button Style" variable to be true.

You can also have highlighting when certain actions happen. For a starting point, let's take a look at WBP_FMGInvSysItemClicker. In the Graph Editing Mode, you can see it overrides various methods from the C++ base class UFMGInvSysItemClicker. Combined with new widgets added in the blueprint, and animations, you can make any style of highlighting. Not to mention that you can add highlighting for more occasions than provided. For example, if you want an item clicker to show a piece of text upon mouse hovering, simply add the new text widget, set its "Is Variable" to be true, bind Clicker's "On Hovered" event to some blueprint nodes that toggles the text's visibility.

Putting it into use

If your item clicker is to be shared by common items, set it to be the inventory menu's "Default Item Clicker Class". If it's for a specific item, set it to be the "Item Clicker Class" in the item core.