As I am thinking on how to solve the buttons problems, one thought came to my mind, but I wonder if it is actually safe to do so, or can it cause some problem.
In layers approach, my buttons work so that they are calling a Function called for example "VirtualButtonFunction1"'.
This VirtualButtonFunction is very simple:
Code: Select all
Function VirtualButtonFunction()
RealButtonFunction1()
EndFunction
Reason for this was because sometimes I wanted to change the button function on fly. That lets say normally I wanted a button click to shoot, but then suddenly I wanted the same button to instead shoot a missile or not even do anything at all. Since Hollywood dont let you change button functions on fly, I made this call to another function, since this RealButtonFunction could be changed on fly.
Since I like to have this same functionality of changing buttons on fly in this non layer approach too, what I have in my mind is following:
I would have a table called "table_Buttons".
then when ever I want some button to exist, i would throw it to that list of buttons.
Then there be a command like ButtonsCreate() which would create all those buttons currently in that list of buttons.
If I want to change function of one button, I would first use ChangeButtonFunction() command, which would affect Teble_button.ID.function
and then I would call ButtonsCreate() again, which would first delete all currently existing button, and then create them again based upon all on that button list.
From progamming point of view this seems to me like a good solution for my problems, but I am worried will it be a problem if I continuously keep deleting and creating buttons? As example, if one button is removed (for example some game menu closed) it means all buttons would be created again after to be deleted ones are removed from list first.