Looking into variables and logic block for multi popup project

Special forum to share and discuss skins for Pano2VR and Object2VR
Post Reply
User avatar
Hopki
Gnome
Posts: 12999
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

Hi,
This was a question in support, some time back we were asked about a simple way to add many popups but as one shows the other hides.
The simplest way was to use a skin numbered variable. Then each popup had a visible logic block that states that when its number equals true it will show.
As each popup has its own number, when the number is not true it hides, so there can only be one popup that shows.

Here is the original post: viewtopic.php?p=55935#p55935

But then the question came in, how can you make it show and hide the popup with the same button?


This was a good opportunity to make a project that uses variables and logic blocks to help understand how you can do some really clever things within Pano2VR, but only if you want to.


On support, we then have to think about the next questions that may be asked.
For example, if no popups are showing, a button clicked must show and hide its popup, but what happens if a popup is already showing?

The attached project has three popups and three buttons, and two helper text boxes so you can see what is going on with the variables, these can be deleted.

Like the above post, the project is using a numbered variable with a visible logic block to show and hide each popup.
But it also has another true/false variable so it knows the state of the popup, this is the key to making this work.

This is 100% scalable, all you need to do to add more popups is add your popup, under the visible logic block give it its variable number, so in the case of the attached project, 4, make sure visible is deselected.

Then copy one of the buttons, and edit the ID so it's Text 4.
Go to the first action and set the action filter to:

1.png
1.png (18.93 KiB) Viewed 20076 times

Then go to the last action and set

22.png
22.png (34.09 KiB) Viewed 20076 times

Also in this project, the active popup button uses the numbers available to change its colours, so just go into the colour logic blocks for the background and text and set them to 4 as well.
That's it, you can add as many as you want.


#### The next part covers how this works, if you are not worried about it then the above is enough to get you going
The following is NOT programming, it is knowing actions work from the top-down and thinking about actions and filters.

But how does it work?
Download the attached project and open the skin.

Each button has four actions, now you have to remember that actions are triggered from the top down, this is important to understand how this works.
So starting with no popup showing so the numbered variable, var_popup is 0 and the true false variable, var_popup_active is false.

Button 1 to open popup 1
The first action

a1.png
a1.png (141.04 KiB) Viewed 20076 times

This sets the var_popup_active variable to false, but only if the variable var_popup is NOT 1


The next action

a2.png
a2.png (106.9 KiB) Viewed 20076 times

This sets the variable var_popup to 0, but only if var_popup_active is true.


The third action just toggles the var_popup_actiave variable, so if it's true, it changes it to false and if it is false changes it to true.

a3.png
a3.png (33.54 KiB) Viewed 20076 times



The last action changes the var_popup to the number required to show its popup, but only if the var_popup_active is true.

a4.png
a4.png (124.89 KiB) Viewed 20076 times

So with nothing showing and on click button Text 1 to show the popup, the actions are:
1 Set Variable Value var_popup_active to false because the var_popup variable is 0 so it's NOT (≠) 1
2 The second action is not triggered as the variable var_popup_active is false
3 The next action toggles the variable var_popup_active to true as it was false
4 The variable var_popup is set to 1 because the var_popup_active is true
Popup 1 shows.

Click the same button to hide popup 1.
1 The first action is ignored because the variable var_popup = 1
2 The second action sets the variable var_popup to 0 as the variable var_popup_active is now true so hides popup 1
3 The variable var_popup_active is toggled to false because the first click set this to true
4 The variable var_popup is ignored as the var_popup_actice is false
Popup 1 hides.

With popup 2 showing, var_popup is set to 2 and var_popup_active is true, click Text 1.
1 The first action sets the variable value of var_popup_active to false because the var_popup variable is 2 so it's NOT (≠) 1
2 The second action is ignored to set var_popup to 0 as the variable var_popup_active is false
3 The next action toggles the variable var_popup_active to true as it was false
4 The variable var_popup is set to 1 because the var_popup_active is true
Popup 1 shows without having to have a button to close popup 2 first.

Hope you all get something out of this project.
Attachments
multi_popups.zip
(13.44 KiB) Downloaded 264 times
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
Post Reply