You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/popup.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,12 +33,14 @@ This makes working with simple confirmation popups much simpler, as you don't ha
33
33
34
34
## Complex popups
35
35
36
-
However, what if you want to make a popup that's more complex? For example, something with a different background and lots of buttons and other controls, like the move trigger popup? For this, the **unrecommended** GD way is to inherit from `FLAlertLayer` and override `init` with your own code. However, this is not ideal, as most complex popups share a lot of similar base functionality like a close button and a standard `GJ_squareXX` background. For this reason, Geode provides a convenience class `Popup<...>` for creating your own complex popups.
36
+
However, what if you want to make a popup that's more complex? For example, something with a different background and lots of buttons and other controls, like the move trigger popup? For this, the **unrecommended** GD way is to inherit from `FLAlertLayer` and override `init` with your own code. However, this is not ideal, as most complex popups share a lot of similar base functionality like a close button and a standard `GJ_squareXX` background. For this reason, Geode provides a convenience class `Popup` for creating your own complex popups.
37
37
```cpp
38
-
// specify parameters for the setup function in the Popup<...> template
`Popup` contains one pure virtual member function: `setup`, whose parameters are the class template arguments. This function is called at the end of `Popup::init`, which initializes all the relevant `FLAlertLayer` members and adds a background and a close button. This abstracts away a lot of boilerplate and makes creating complex popups simple.
68
+
`Popup::init` abstracts away a lot of boilerplate and makes creating complex popups simple, by initializing all the relevant `FLAlertLayer` members and adding a background with a close button.
67
69
68
70
**This is the recommended way to create complex popups in Geode**, although as with question popups, this is not an interoperability concern and as such **you can do what fits your case**. If you are porting an existing mod that uses some other setup and it works just fine, no need to change it unless you want to make the codebase more easily refactorable.
Copy file name to clipboardExpand all lines: tutorials/touchpriority.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,8 +30,8 @@ Robtop has 3 main functions for dealing with force priority: `CCTouchDispatcher:
30
30
31
31
If you're not dealing with any popups, chances are you don't need to deal with any of these either. But if you are, you should follow these guidelines.
32
32
33
-
If your popup subclasses `geode::Popup<>`, the registering and unregistering is handled automatically.
33
+
If your popup subclasses `geode::Popup`, the registering and unregistering is handled automatically.
34
34
35
-
If you're not using `geode::Popup<>` class and directly subclassing `FLAlertLayer` instead, you should call `FLAlertLayer::init(int opacity)` inside your init. This will handle the registering of the force priority, along with creating the `m_mainLayer`. You should also override `registerWithTouchDispatcher` and call `CCTouchDispatcher::addTargetedDelegate` in it, since that will allow you to register the popup not as a prio targeted delegate. If you leave it the default, `FLAlertLayer` will have one less priority than your layers (-503 vs -502), meaning none of the touches will go to your layers since they will be consumed. And lastly, `~FLAlertLayer` handles unregistering of the force priority.
35
+
If you're not using `geode::Popup` class and directly subclassing `FLAlertLayer` instead, you should call `FLAlertLayer::init(int opacity)` inside your init. This will handle the registering of the force priority, along with creating the `m_mainLayer`. You should also override `registerWithTouchDispatcher` and call `CCTouchDispatcher::addTargetedDelegate` in it, since that will allow you to register the popup not as a prio targeted delegate. If you leave it the default, `FLAlertLayer` will have one less priority than your layers (-503 vs -502), meaning none of the touches will go to your layers since they will be consumed. And lastly, `~FLAlertLayer` handles unregistering of the force priority.
36
36
37
37
If you want to set the priorities manually (such as for an overlay), you can call `CCLayer::setTouchPriority`/`CCMenu::setHandlerPriority` on your layer with the `CCTouchDispatcher::getTargetPrio` value.
0 commit comments