Change the contents of an array and have it affect only one instance of a widget

I am making a simple cooking game for local multiplayer and i’ve run into an issue when it comes to customizing the orders. I have a widget that contains a horizontal box, when a new order arrives a child widget is added to that widget that contains a text block that is bound to a text variable. I am using a ForEachLoop to create as many widgets as the indexes of my array (ingredients) and populate that text value. So basically it keeps adding children in that horizontal box and assigning the names, so far it works. When a new order comes in both orders now show the ingredients of the latest order even though each time a new order is registered, a whole batch of new widgets is created and so on so forth.
What would be the best way to go about saving the order that comes in so it corresponds with only 1 widget?
I thought about saving it into another array and assigning that, but this way i’d have to manually make a ton of “Save” arrays and also have a limit to the amount of orders it can accept.

I know it’s kind of hard to follow, i apologize for that. Any insight would be great!

What I would recommend is a setup somewhat like this:

You have a struct that stores the Data for an order, a widget for displaying said order in a box, and a widget for display every order in a vertical box.

The OrderData could look something like this:
image
Needless to say, they should not be booleans.

The UI_Order just has one thing: the order data.


This widgets only job is to display the order. You also should make CurrentOrderData exposed on spawn.

Then, finally, we have the OrderDisplay. This has two functions/events- one for removing and one for adding orders. This is the widget that is directly added to the player.


As well as this, the class has a Pawn to UI_Order map to store which UI corresponds to which customer.
image
Remove order simply finds what UI element corresponds to the customer, removes it from the display, and then removes the customer from the CustomerOrders map. You may also want to add a success boolean if you’re going to add some failure/success animations to the UI.

This sure is way simpler than how i tried to do it… Thank you!

1 Like