Buttons reset color to defult when widget is called again

Hi there all,

In my blueprints I have a button that I want to change the background color of once a custom event fires. (Level Finished) when then sets the background color of the button (lvl1) to either green or gold depending on the result. Then when the widget is called, the button is painted the correct color. This works great and I have no issues with it.

However whenever I load a new level the button (lvl1) resets back to its default color and once I finish the next level the next button (lvl2) is colored but the lvl1 button has reset.

Is there an option box somewhere that I am missing? Or is there a way for me to save the color of the button so that when next it is called by the widget switcher the button stays the color it has been set to.

Many thanks!

I noticed you’ve got the first button plugged into the first two options on that switch, is that the problem?

If not, maybe you have to save the level status in the save game, and re-load it each time around…

Good spot, but no not an issue, my main menu is level Zero and if there is nothing in the Zero slot the game puts up errors.

I’ll try saving the level status and let you know if that works

You have to save it and then re-load obviously… :wink:

I guess the next question is how can I save all of my button’s states?

So, your savegame is basically just big box of variables. It looks like a BP, but don’t put code in it.

When you set the color of a widget, save it’s color in the savegame.

Next time you load the widget, if it has a color in the savegame, use that otherwise use the default color.

Here’s a tuut on savegames:

[quote=“ClockworkOcean, post:6, topic:138480”]

So, your savegame is basically just big box of variables. It looks like a BP, but don’t put code in it.

When you set the color of a widget, save it’s color in the savegame.

Next time you load the widget, if it has a color in the savegame, use that otherwise use the default color.

Here’s a tuut on savegames:

Thanks, I managed to get it to work for a single button.

Next problem is for all the buttons, I’m struggling to find information on saving an array, is there anyway to make an array a variable so that I could save it?

Short answer:

Put your widget buttons in an array, and have an array of colors in the savegame. They have the same indexes.

Long answer:

Like I say, the save game is just a BP. You can make an array in the variables section of the save game BP, just like any other BP.

You need to assign ( in your widget or in your head ) each of the buttons an ID, just an integer. This will be their index in the array. So, when you come to save a button you basically say:

MySavegaveButtonColors x ] = color

where x is 0 for the first button, 1, for the second etc.

When you read them, it’s just the opposite.

You need to know which button corresponds to which ID, you do this by putting all of your buttons in an array in your widget. You have to get the type of the array right ( the type of the button ), and you make the array in the construct event with the MakeArray node.

Then it’s easy because the color of MyWidgetButtonArray[6] ( for instance ) just gets saved to MySavegameButtonColors[6]…

Fantastic, thanks going to try it now!

Tell me if you get stuck, but I wont be at a machine until tomorrow… ( just go with the two arrays / same index idea ).