|
3 | 3 | #include "FileWatcher.hpp" |
4 | 4 | #include "Utils.hpp" |
5 | 5 | #include "nodes/CCLabelBMFont.hpp" |
6 | | -#include "nodes/CCMenuItemSpriteExtra.hpp" |
7 | 6 | #include "nodes/FLAlertLayer.hpp" |
8 | 7 | #include "nodes/CCNode.hpp" |
9 | 8 | #include "UIModding.hpp" |
@@ -579,11 +578,13 @@ void UIModding::setColor(CCNode* node, const matjson::Value& attributes) { |
579 | 578 | std::string colorStr = color.asString().unwrapOr(""); |
580 | 579 |
|
581 | 580 | if (colorStr == "reset") { |
582 | | - if (auto node1 = static_cast<EventCCMenuItemSpriteExtra*>(typeinfo_cast<CCMenuItemSpriteExtra*>(node))) { |
583 | | - auto originalColor = node1->m_fields->originalColor; |
584 | | - node1->setColor(originalColor); |
585 | | - if (auto buttonNode = node1->getChildByType<ButtonSprite>(0)) { |
586 | | - buttonNode->setColor(originalColor); |
| 581 | + if (auto node1 = typeinfo_cast<CCNodeRGBA*>(node)) { |
| 582 | + if (auto color = static_cast<ObjWrapper<ccColor3B>*>(node1->getUserObject("orig-color"_spr))) { |
| 583 | + auto originalColor = color->getValue(); |
| 584 | + node1->setColor(originalColor); |
| 585 | + if (auto buttonNode = node1->getChildByType<ButtonSprite>(0)) { |
| 586 | + buttonNode->setColor(originalColor); |
| 587 | + } |
587 | 588 | } |
588 | 589 | } |
589 | 590 | } |
@@ -840,11 +841,13 @@ void UIModding::setOpacity(CCNode* node, const matjson::Value& attributes) { |
840 | 841 | } |
841 | 842 |
|
842 | 843 | if (opacity.isString() && opacity.asString().unwrapOr("") == "reset") { |
843 | | - if (auto node1 = static_cast<EventCCMenuItemSpriteExtra*>(typeinfo_cast<CCMenuItemSpriteExtra*>(node))) { |
844 | | - auto original = node1->m_fields->originalOpacity; |
845 | | - node1->setOpacity(original); |
846 | | - if (auto node2 = node1->getChildByType<ButtonSprite>(0)) { |
847 | | - node2->setOpacity(original); |
| 844 | + if (auto node1 = typeinfo_cast<CCNodeRGBA*>(node)) { |
| 845 | + if (auto opacity = static_cast<CCInteger*>(node1->getUserObject("orig-opacity"_spr))) { |
| 846 | + auto originalOpacity = opacity->getValue(); |
| 847 | + node1->setOpacity(originalOpacity); |
| 848 | + if (auto buttonNode = node1->getChildByType<ButtonSprite>(0)) { |
| 849 | + buttonNode->setOpacity(originalOpacity); |
| 850 | + } |
848 | 851 | } |
849 | 852 | } |
850 | 853 | } |
@@ -1415,9 +1418,10 @@ void UIModding::handleModifications(CCNode* node, matjson::Value nodeObject, boo |
1415 | 1418 |
|
1416 | 1419 | void UIModding::reloadChildren(CCNode* parentNode, bool transition) { |
1417 | 1420 | if (!parentNode) return; |
| 1421 | + if (!checkNodeValidity(parentNode)) return; |
| 1422 | + |
1418 | 1423 | MyCCNode* myParentNode = static_cast<MyCCNode*>(parentNode); |
1419 | | - if (!checkNodeValidity(myParentNode)) return; |
1420 | | - |
| 1424 | + |
1421 | 1425 | for (const matjson::Value& value : myParentNode->getAttributes()) { |
1422 | 1426 | handleModifications(myParentNode, value, transition); |
1423 | 1427 | } |
|
0 commit comments