|
1 | | -// #include "../../SwelvyBG.hpp" |
2 | | -// #include <Geode/Geode.hpp> |
3 | | -// #include <Geode/modify/UIPOptionsLayer.hpp> |
| 1 | +#include "../../SwelvyBG.hpp" |
| 2 | +#include <Geode/Geode.hpp> |
| 3 | +#include <Geode/modify/CCLayer.hpp> |
4 | 4 |
|
5 | | -// using namespace geode::prelude; |
| 5 | +using namespace geode::prelude; |
6 | 6 |
|
7 | | -// class $modify(MyUIPOptionsLayer, UIPOptionsLayer) { |
8 | | -// bool init() { |
9 | | -// if (!UIPOptionsLayer::init()) { |
10 | | -// return false; |
11 | | -// } |
12 | | -// if (Mod::get()->getSettingValue<bool>("gd/UIPOptionsLayer")){ |
13 | | -// // this->setOpacity(0); |
14 | | -// auto swelvyBG = SwelvyBG::create(); |
15 | | -// swelvyBG->setZOrder(-3); |
16 | | -// |
| 7 | +class $modify(MyCCLayer, CCLayer) { |
| 8 | + void onEnter() { |
| 9 | + CCLayer::onEnter(); |
17 | 10 |
|
18 | | -// auto layer = this->getChildOfType<CCLayer*>(0); |
19 | | -// layer->addChild(swelvyBG); |
20 | | -// } |
21 | | -// return true; |
22 | | -// } |
23 | | -// }; |
| 11 | + if (auto parent = dynamic_cast<UIPOptionsLayer*>(this->getParent())) { |
| 12 | + if (Mod::get()->getSettingValue<bool>("gd/UIPOptionsLayer")) { |
| 13 | + int lowestZ = INT_MAX; |
| 14 | + CCObject* obj = nullptr; |
| 15 | + CCARRAY_FOREACH(this->getChildren(), obj) { |
| 16 | + if (auto node = dynamic_cast<CCNode*>(obj)) { |
| 17 | + lowestZ = std::min(lowestZ, node->getZOrder()); |
| 18 | + } |
| 19 | + } |
| 20 | + |
| 21 | + auto swelvyBG = SwelvyBG::create(); |
| 22 | + swelvyBG->setZOrder(lowestZ - 1); |
| 23 | + this->addChild(swelvyBG); |
| 24 | + } |
| 25 | + } |
| 26 | + } |
| 27 | +}; |
0 commit comments