diff --git a/src/main.cpp b/src/main.cpp index 22158c2..ec7863d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -310,12 +310,14 @@ class $modify(CCSprite) { // better code, thanks camila! if (!strcmp(name, "GJ_gradientBG.png") && Mod::get()->getSettingValue("activate-background")) { Loader::get()->queueInMainThread([=] { - if (ret->getColor() == ccc3(0, 102, 255)) { - auto scene = CCDirector::sharedDirector()->getRunningScene(); - if (scene->getChildrenCount() == 0) return; - auto layer = scene->getChildren()->objectAtIndex(0); - std::string layerName = misc::getNodeName(layer); - ret->setColor(Mod::get()->getSettingValue("background")); + if (ret != nullptr) { + if (ret->getColor() == ccc3(0, 102, 255)) { + auto scene = CCDirector::sharedDirector()->getRunningScene(); + if (scene->getChildrenCount() == 0) return; + auto layer = scene->getChildren()->objectAtIndex(0); + std::string layerName = misc::getNodeName(layer); + ret->setColor(Mod::get()->getSettingValue("background")); + } } }); @@ -332,72 +334,74 @@ class $modify(CCScale9Sprite) { // better code, thanks camila! if ((!strcmp(name, "square02b_001.png") || !strcmp(name, "square02b_small.png")) && Mod::get()->getSettingValue("activate-background")) { Loader::get()->queueInMainThread([=] { - // jouca waht - if (ret->getColor() == ccc3(0, 56, 141)) { - ccColor3B new_color = Mod::get()->getSettingValue("child-background"); - if (Mod::get()->getSettingValue("syncBGcolor")) { - new_color = Mod::get()->getSettingValue("background"); - } - if (Mod::get()->getSettingValue("addChildBDGradient")) { - new_color = ccc3(new_color.r * 0.79, new_color.g * 0.79, new_color.b * 0.79); - } - if (Mod::get()->getSettingValue("bgchild-transparency")) { - int opacity = Mod::get()->getSettingValue("bgchild-transparency-scroll"); - ret->setOpacity(opacity); - } - ret->setColor(new_color); - } else if (ret->getColor() == ccc3(0, 39, 98)) { - ccColor3B new_color = Mod::get()->getSettingValue("child-background"); - if (Mod::get()->getSettingValue("syncBGcolor")) { - new_color = Mod::get()->getSettingValue("background"); - } - if (Mod::get()->getSettingValue("addChildBDGradient")) { - new_color = ccc3(new_color.r * 0.71, new_color.g * 0.71, new_color.b * 0.71); - } - if (Mod::get()->getSettingValue("bgchild-transparency")) { - int opacity = Mod::get()->getSettingValue("bgchild-transparency-scroll"); - ret->setOpacity(opacity); - } - ret->setColor(new_color); - } else if (ret->getColor() == ccc3(0, 46, 117)) { - ccColor3B new_color = Mod::get()->getSettingValue("child-background"); - if (Mod::get()->getSettingValue("syncBGcolor")) { - new_color = Mod::get()->getSettingValue("background"); - } - if (Mod::get()->getSettingValue("addChildBDGradient")) { - new_color = ccc3(new_color.r * 0.74, new_color.g * 0.74, new_color.b * 0.74); - } - if (Mod::get()->getSettingValue("bgchild-transparency")) { - int opacity = Mod::get()->getSettingValue("bgchild-transparency-scroll"); - ret->setOpacity(opacity); - } - ret->setColor(new_color); - } else if (ret->getColor() == ccc3(0, 36, 91)) { - ccColor3B new_color = Mod::get()->getSettingValue("child-background"); - if (Mod::get()->getSettingValue("syncBGcolor")) { - new_color = Mod::get()->getSettingValue("background"); - } - if (Mod::get()->getSettingValue("addChildBDGradient")) { - new_color = ccc3(new_color.r * 0.70, new_color.g * 0.70, new_color.b * 0.70); - } - if (Mod::get()->getSettingValue("bgchild-transparency")) { - int opacity = Mod::get()->getSettingValue("bgchild-transparency-scroll"); - ret->setOpacity(opacity); - } - ret->setColor(new_color); - } else if (ret->getColor() == ccc3(0, 31, 79)) { - ccColor3B new_color = Mod::get()->getSettingValue("child-background"); - if (Mod::get()->getSettingValue("syncBGcolor")) { - new_color = Mod::get()->getSettingValue("background"); - } - if (Mod::get()->getSettingValue("addChildBDGradient")) { - new_color = ccc3(new_color.r * 0.67, new_color.g * 0.67, new_color.b * 0.67); - } - if (Mod::get()->getSettingValue("bgchild-transparency")) { - int opacity = Mod::get()->getSettingValue("bgchild-transparency-scroll"); - ret->setOpacity(opacity); + if (ret != nullptr) { + // jouca waht + if (ret->getColor() == ccc3(0, 56, 141)) { + ccColor3B new_color = Mod::get()->getSettingValue("child-background"); + if (Mod::get()->getSettingValue("syncBGcolor")) { + new_color = Mod::get()->getSettingValue("background"); + } + if (Mod::get()->getSettingValue("addChildBDGradient")) { + new_color = ccc3(new_color.r * 0.79, new_color.g * 0.79, new_color.b * 0.79); + } + if (Mod::get()->getSettingValue("bgchild-transparency")) { + int opacity = Mod::get()->getSettingValue("bgchild-transparency-scroll"); + ret->setOpacity(opacity); + } + ret->setColor(new_color); + } else if (ret->getColor() == ccc3(0, 39, 98)) { + ccColor3B new_color = Mod::get()->getSettingValue("child-background"); + if (Mod::get()->getSettingValue("syncBGcolor")) { + new_color = Mod::get()->getSettingValue("background"); + } + if (Mod::get()->getSettingValue("addChildBDGradient")) { + new_color = ccc3(new_color.r * 0.71, new_color.g * 0.71, new_color.b * 0.71); + } + if (Mod::get()->getSettingValue("bgchild-transparency")) { + int opacity = Mod::get()->getSettingValue("bgchild-transparency-scroll"); + ret->setOpacity(opacity); + } + ret->setColor(new_color); + } else if (ret->getColor() == ccc3(0, 46, 117)) { + ccColor3B new_color = Mod::get()->getSettingValue("child-background"); + if (Mod::get()->getSettingValue("syncBGcolor")) { + new_color = Mod::get()->getSettingValue("background"); + } + if (Mod::get()->getSettingValue("addChildBDGradient")) { + new_color = ccc3(new_color.r * 0.74, new_color.g * 0.74, new_color.b * 0.74); + } + if (Mod::get()->getSettingValue("bgchild-transparency")) { + int opacity = Mod::get()->getSettingValue("bgchild-transparency-scroll"); + ret->setOpacity(opacity); + } + ret->setColor(new_color); + } else if (ret->getColor() == ccc3(0, 36, 91)) { + ccColor3B new_color = Mod::get()->getSettingValue("child-background"); + if (Mod::get()->getSettingValue("syncBGcolor")) { + new_color = Mod::get()->getSettingValue("background"); + } + if (Mod::get()->getSettingValue("addChildBDGradient")) { + new_color = ccc3(new_color.r * 0.70, new_color.g * 0.70, new_color.b * 0.70); + } + if (Mod::get()->getSettingValue("bgchild-transparency")) { + int opacity = Mod::get()->getSettingValue("bgchild-transparency-scroll"); + ret->setOpacity(opacity); + } + ret->setColor(new_color); + } else if (ret->getColor() == ccc3(0, 31, 79)) { + ccColor3B new_color = Mod::get()->getSettingValue("child-background"); + if (Mod::get()->getSettingValue("syncBGcolor")) { + new_color = Mod::get()->getSettingValue("background"); + } + if (Mod::get()->getSettingValue("addChildBDGradient")) { + new_color = ccc3(new_color.r * 0.67, new_color.g * 0.67, new_color.b * 0.67); + } + if (Mod::get()->getSettingValue("bgchild-transparency")) { + int opacity = Mod::get()->getSettingValue("bgchild-transparency-scroll"); + ret->setOpacity(opacity); + } + ret->setColor(new_color); } - ret->setColor(new_color); } }); }