From 204051c2c30b73f2665a0c7cdc9f4f1a0ed4be1e Mon Sep 17 00:00:00 2001 From: user666 Date: Sun, 14 Jul 2024 23:42:11 +0400 Subject: [PATCH] copy levels, coin setup popup for editor, fix data and meta bugs at new levels, the tower back btn fix, set the requiredCoins --- mod.json | 2 +- src/_main.hpp | 306 +++++++++++++++++++++++++++++++++++++++++- src/control_ui.cpp | 63 +++++++-- src/editor.cpp | 50 ++++++- src/level_data.cpp | 8 +- src/level_listing.cpp | 31 +++++ src/songs.cpp | 2 + 7 files changed, 448 insertions(+), 14 deletions(-) diff --git a/mod.json b/mod.json index 01887fb..ba11512 100644 --- a/mod.json +++ b/mod.json @@ -4,7 +4,7 @@ "win": "2.206", "android": "*" }, - "version": "v7.0.0-beta.8", + "version": "v7.0.0-beta.9", "id": "user95401.mainlevelseditor", "name": "Main Levels Editor", "developer": "user95401", diff --git a/src/_main.hpp b/src/_main.hpp index 334803f..c5d4ecd 100644 --- a/src/_main.hpp +++ b/src/_main.hpp @@ -1,5 +1,6 @@ #pragma once #include +#include using namespace geode::prelude; #include @@ -88,6 +89,12 @@ namespace geode::cocos { ) return btnSpriteTry; return "CANT_GET_FRAME_NAME"; } + inline auto nodeWithID(std::string id, int tag = 0) { + auto node = CCNode::create(); + node->setID(id); + if (tag != 0) node->setTag(tag); + return node; + } }; namespace mle_leveltools { @@ -98,6 +105,7 @@ namespace mle_leveltools { level->m_creatorName = value.try_get("m_creatorName").value_or(level->m_creatorName.data()); level->m_difficulty = (GJDifficulty)value.try_get("m_difficulty").value_or((int)level->m_difficulty); level->m_stars = value.try_get("m_stars").value_or(level->m_stars.value()); + level->m_requiredCoins = value.try_get("m_requiredCoins").value_or(level->m_requiredCoins); level->m_audioTrack = value.try_get("m_audioTrack").value_or(level->m_audioTrack); level->m_songID = value.try_get("m_songID").value_or(level->m_songID); level->m_levelVersion = value.try_get("m_levelVersion").value_or(level->m_levelVersion); @@ -115,6 +123,7 @@ namespace mle_leveltools { value.try_set("m_audioTrack", level->m_audioTrack); value.try_set("m_difficulty", (int)level->m_difficulty); value.try_set("m_stars", level->m_stars.value()); + value.try_set("m_requiredCoins", level->m_requiredCoins); value.try_set("________SOME_SHIT________", " vvv vvv "); value.try_set("m_levelDesc", std::string(level->m_levelDesc.data())); value.try_set("m_creatorName", std::string(level->m_creatorName.data()));; @@ -493,6 +502,82 @@ namespace mle_ui { newArtistsLayer->m_scrollLayer->m_contentLayer->setPositionY(0.f); } }; + class LevelsListMDPopup : public FLAlertLayer, FLAlertLayerProtocol, CCScrollLayerExtDelegate { + public: + inline static CCPoint lastScrollPos = CCPoint(999.f, 0.f); + MDTextArea* m_md = nullptr; + struct FileNumbericSort { + bool operator()(const fs::path& a, const fs::path& b) const { + auto stra = std::regex_replace(a.filename().string(), std::regex(a.filename().extension().string()), ""); + auto strb = std::regex_replace(b.filename().string(), std::regex(b.filename().extension().string()), ""); + auto inta = utils::numFromString(stra).value_or(0); + auto intb = utils::numFromString(strb).value_or(0); + return inta <= intb; + } + }; + static auto create() { + auto rtn = new LevelsListMDPopup; + rtn->FLAlertLayer::init( + rtn, + "Listing all levels in dir", + "\n \n \n \n \n \n \n \n ", + "Close", nullptr, 375.000f, 0, 0.000f, 1.f + ); + rtn->setID("LevelsListMDPopup"); + rtn->customSetup(); + return rtn; + } + void customSetup() { + auto md_size = this->getChildByIDRecursive("background")->getContentSize() - 110; + auto md_str = std::string("# Dir Iter"); { + std::set aFileNumbericSortSet; + for (auto& entry : fs::directory_iterator(levels_meta_path, fs::last_err_code)) + aFileNumbericSortSet.insert(entry.path()); + for (auto& filepath : aFileNumbericSortSet) { + if (filepath.extension() == ".json") { + //json val + auto value = matjson::parse("{}"); + auto error = std::string(); + auto parse = matjson::parse(fs::read(filepath), error); + if (parse.has_value()) { + value = parse.value(); + mle_leveltools::levelFromJson(value); + md_str.append(std::format( + "\n - {}: {}", + filepath.filename().string(), + value["m_levelName"].dump() + )); + } + }; + } + for (auto& filepath : aFileNumbericSortSet) { + if (filepath.extension() == ".json") { + md_str.append( + "\n```\n" + + filepath.string().replace( + 0, Mod::get()->getConfigDir().string().size() + 1, "" + ) + + ": " + + fs::read(filepath) + + "\n```\n\n---\n\n" + ); + }; + } + }; + if (m_md = MDTextArea::create(md_str, md_size)) { + this->m_mainLayer->addChild(m_md, 1); + m_md->setPosition(this->getContentSize() / 2); + m_md->getScrollLayer()->m_delegate = this; + if (lastScrollPos.x == 0.f) + m_md->getScrollLayer()->m_contentLayer->setPosition(lastScrollPos); + } + handleTouchPriority(this); + } + virtual void scrollViewDidEndMoving(CCScrollLayerExt* p0) { + if (p0->m_contentLayer->getPositionY() < 0) + lastScrollPos = p0->m_contentLayer->getPosition(); + } + }; class LevelConfigPopup : public FLAlertLayer, FLAlertLayerProtocol, TextInputDelegate { public: GJGameLevel* m_level = nullptr; @@ -557,24 +642,36 @@ namespace mle_ui { } //addInputs auto addInput = [this, form_box](auto label = "", auto id = "", CommonFilter commonFilter = CommonFilter::Any) { + auto input_box = CCLayer::create(); + input_box->setContentSize(CCSize(255.f, 45.000f)); + //layout + auto layout = ColumnLayout::create(); + layout->setAxisReverse(1); + layout->setCrossAxisOverflow(0); + input_box->setLayout(layout); //labelNode auto labelNode = CCLabelBMFont::create(label, "bigFont.fnt"); labelNode->setID(id + std::string("/label")); - form_box->addChild(labelNode); + input_box->addChild(labelNode); //inputNode auto inputNode = TextInput::create(form_box->getContentWidth(), label, "chatFont.fnt"); inputNode->getInputNode()->setID(id); inputNode->getInputNode()->setMaxLabelScale(1.f); inputNode->setCommonFilter(commonFilter); inputNode->setDelegate(this); - form_box->addChild(inputNode); + input_box->addChild(inputNode); //upd + input_box->updateLayout(); + //add + input_box->updateLayout(); + form_box->addChild(input_box); form_box->updateLayout(); }; addInput("Name", "m_levelName"); addInput("Audio Track", "m_audioTrack", CommonFilter::Int); addInput("Difficulty", "m_difficulty", CommonFilter::Int); addInput("Stars", "m_stars", CommonFilter::Int); + addInput("Required Coins", "m_requiredCoins", CommonFilter::Int); loadInputs(); //playMusic if (auto GJ_playMusicBtn_001 = CCSprite::createWithSpriteFrameName("GJ_playMusicBtn_001.png")) { @@ -604,10 +701,12 @@ namespace mle_ui { auto m_audioTrack = typeinfo_cast(this->getChildByIDRecursive("m_audioTrack")); auto m_difficulty = typeinfo_cast(this->getChildByIDRecursive("m_difficulty")); auto m_stars = typeinfo_cast(this->getChildByIDRecursive("m_stars")); + auto m_requiredCoins = typeinfo_cast(this->getChildByIDRecursive("m_requiredCoins")); if (m_levelName) m_levelName->setString(fmt::format("{}", this->m_level->m_levelName.data())); if (m_audioTrack) m_audioTrack->setString(fmt::format("{}", this->m_level->m_audioTrack)); if (m_difficulty) m_difficulty->setString(fmt::format("{}", (int)this->m_level->m_difficulty)); if (m_stars) m_stars->setString(fmt::format("{}", this->m_level->m_stars.value())); + if (m_requiredCoins) m_requiredCoins->setString(fmt::format("{}", this->m_level->m_requiredCoins)); } void applyInputs() { if (not this->m_level) return; @@ -615,10 +714,12 @@ namespace mle_ui { auto m_audioTrack = typeinfo_cast(this->getChildByIDRecursive("m_audioTrack")); auto m_difficulty = typeinfo_cast(this->getChildByIDRecursive("m_difficulty")); auto m_stars = typeinfo_cast(this->getChildByIDRecursive("m_stars")); + auto m_requiredCoins = typeinfo_cast(this->getChildByIDRecursive("m_requiredCoins")); if (m_levelName) m_level->m_levelName = m_levelName->getString(); if (m_audioTrack) m_level->m_audioTrack = utils::numFromString(m_audioTrack->getString().data()).value_or(m_level->m_audioTrack); if (m_difficulty) m_level->m_difficulty = (GJDifficulty)utils::numFromString(m_difficulty->getString().data()).value_or((int)m_level->m_difficulty); if (m_stars) m_level->m_stars = utils::numFromString(m_stars->getString().data()).value_or(m_level->m_stars.value()); + if (m_requiredCoins) m_level->m_requiredCoins = utils::numFromString(m_requiredCoins->getString().data()).value_or(m_level->m_requiredCoins); } void textChanged(CCTextInputNode* p0) { //log::debug("{}({}) id: {}", __FUNCTION__, p0, p0->getID()); @@ -926,4 +1027,205 @@ namespace mle_ui { }; pArtistsConfigPopup->show(); }; + class CopyLevelPopup : public FLAlertLayer, FLAlertLayerProtocol, TextInputDelegate { + public: + GJGameLevel* m_level = nullptr; + std::function m_onSave = []() {}; + static auto create(GJGameLevel* for_level = LevelTools::getLevel(1, 0)) { + auto rtn = new CopyLevelPopup; + rtn->init( + rtn, + "Grab Level To \"Main Levels\"...", + "\n \n \n \n \n \n \n \n ", + "Close", "Save", 375.000f, 0, 0.000f, 1.f + ); + rtn->setID("CopyLevelPopup"); + rtn->m_level = for_level; + rtn->customSetup(); + return rtn; + } + void customSetup() { + //form_box + auto form_box = CCLayer::create(); + if (form_box) { + //base sets + form_box->setID("form_box"); + form_box->setPosition(CCPoint(0.f, 116.f)); + form_box->setContentSize(CCSize(255.f, 175.f)); + form_box->ignoreAnchorPointForPosition(false); + //add + this->m_buttonMenu->addChild(form_box); + //layout + auto layout = ColumnLayout::create(); + layout->setAxisReverse(1); + form_box->setLayout(layout); + } + //addInputs + auto addInput = [this, form_box](auto label = "", auto id = "", CommonFilter commonFilter = CommonFilter::Any) { + //labelNode + auto labelNode = CCLabelBMFont::create(label, "bigFont.fnt"); + labelNode->setID(id + std::string("/label")); + form_box->addChild(labelNode); + //inputNode + auto inputNode = TextInput::create(form_box->getContentWidth(), label, "chatFont.fnt"); + inputNode->getInputNode()->setID(id); + inputNode->getInputNode()->setMaxLabelScale(1.f); + inputNode->setCommonFilter(commonFilter); + inputNode->setDelegate(this); + form_box->addChild(inputNode); + //upd + form_box->updateLayout(); + }; + addInput("Target ID", "m_levelID"); + loadInputs(); + //help + form_box->addChild(CCLabelBMFont::create("Help", "bigFont.fnt")); + form_box->updateLayout(); + if (auto menu = CCMenu::create()) { + //layout + auto layout = RowLayout::create(); + menu->setLayout(layout); + //Levels List + menu->addChild(CCMenuItemExt::createSpriteExtra( + ButtonSprite::create("Levels List", 0.6f), + [](auto) { + LevelsListMDPopup::create()->show(); + } + )); + //Settings + menu->addChild(CCMenuItemExt::createSpriteExtra( + ButtonSprite::create("Settings", 0.6f), + [](auto) { + openSettingsPopup(Mod::get()); + } + )); + //lyupd + menu->updateLayout(); + //add + form_box->addChild(menu); + form_box->updateLayout(); + handleTouchPriority(this); + } + } + void loadInputs() { + if (not this->m_level) return; + auto m_levelID = typeinfo_cast(this->getChildByIDRecursive("m_levelID")); + if (m_levelID) m_levelID->setString(fmt::format("{}", this->m_level->m_levelID.value())); + } + void applyInputs() { + if (not this->m_level) return; + auto m_levelID = typeinfo_cast(this->getChildByIDRecursive("m_levelID")); + if (m_levelID) m_level->m_levelID = utils::numFromString(m_levelID->getString().data()).value_or(m_level->m_levelID.value()); + } + void FLAlert_Clicked(FLAlertLayer* p0, bool p1) { + if (not p1) return; + applyInputs(); + //save json + mle_leveltools::updateLevelDataAndMetaFiles(m_level->m_levelString, m_level); + //call custom func + this->m_onSave(); + }; + }; + class CopyAudioPopup : public FLAlertLayer, FLAlertLayerProtocol, TextInputDelegate { + public: + std::function m_onSave = []() {}; + mle_audiotools::Audio m_audio = mle_audiotools::Audio(0); + mle_audiotools::Artist m_artist = mle_audiotools::Artist(0); + static auto create(int audioid = 0, int artistid = 0) { + auto rtn = new CopyAudioPopup; + rtn->init( + rtn, + "Convert To Audio and Artist...", + "\n \n \n \nLATER... \n \n \n \n ", + "Close", "Save", 395.000f, 0, 0.000f, 1.f + ); + rtn->setID("CopyAudioPopup"); + rtn->m_audio = mle_audiotools::Audio(audioid); + rtn->m_artist = mle_audiotools::Artist(artistid); + //rtn->customSetup(); + return rtn; + } + /* + void customSetup() { + //form_box + auto form_box = CCLayer::create(); + if (form_box) { + //base sets + form_box->setID("form_box"); + form_box->setPosition(CCPoint(0.f, 116.f)); + form_box->setContentSize(CCSize(255.f, 175.f)); + form_box->ignoreAnchorPointForPosition(false); + //add + this->m_buttonMenu->addChild(form_box); + //layout + auto layout = ColumnLayout::create(); + layout->setAxisReverse(1); + form_box->setLayout(layout); + } + //addInputs + auto addInput = [this, form_box](auto label = "", auto id = "", CommonFilter commonFilter = CommonFilter::Any) { + //labelNode + auto labelNode = CCLabelBMFont::create(label, "bigFont.fnt"); + labelNode->setID(id + std::string("/label")); + form_box->addChild(labelNode); + //inputNode + auto inputNode = TextInput::create(form_box->getContentWidth(), label, "chatFont.fnt"); + inputNode->getInputNode()->setID(id); + inputNode->getInputNode()->setMaxLabelScale(1.f); + inputNode->setCommonFilter(commonFilter); + inputNode->setDelegate(this); + form_box->addChild(inputNode); + //upd + form_box->updateLayout(); + }; + addInput("Target ID", "m_levelID"); + //loadInputs(); + //help + form_box->addChild(CCLabelBMFont::create("Help", "bigFont.fnt")); + form_box->updateLayout(); + if (auto menu = CCMenu::create()) { + //layout + auto layout = RowLayout::create(); + menu->setLayout(layout); + //Levels List + menu->addChild(CCMenuItemExt::createSpriteExtra( + ButtonSprite::create("Levels List", 0.6f), + [](auto) { + LevelsListMDPopup::create()->show(); + } + )); + //Settings + menu->addChild(CCMenuItemExt::createSpriteExtra( + ButtonSprite::create("Settings", 0.6f), + [](auto) { + openSettingsPopup(Mod::get()); + } + )); + //lyupd + menu->updateLayout(); + //add + form_box->addChild(menu); + form_box->updateLayout(); + handleTouchPriority(this); + } + } + void loadInputs() { + if (not this->m_level) return; + auto m_levelID = typeinfo_cast(this->getChildByIDRecursive("m_levelID")); + if (m_levelID) m_levelID->setString(fmt::format("{}", this->m_level->m_levelID.value())); + } + void applyInputs() { + if (not this->m_level) return; + auto m_levelID = typeinfo_cast(this->getChildByIDRecursive("m_levelID")); + if (m_levelID) m_level->m_levelID = utils::numFromString(m_levelID->getString().data()).value_or(m_level->m_levelID.value()); + } + void FLAlert_Clicked(FLAlertLayer* p0, bool p1) { + if (not p1) return; + applyInputs(); + //save json + mle_leveltools::updateLevelDataAndMetaFiles(m_level->m_levelString, m_level); + //call custom func + this->m_onSave(); + };*/ + }; } \ No newline at end of file diff --git a/src/control_ui.cpp b/src/control_ui.cpp index dfc0207..d9ad63e 100644 --- a/src/control_ui.cpp +++ b/src/control_ui.cpp @@ -110,22 +110,69 @@ class $modify(FLAlertLayerExt, FLAlertLayer) { }; ae->show(); } - auto doSongInfoLayerSetup() { - if (not typeinfo_cast(this)) return; + auto onCopySong(CCObject*) { + auto pCopyLevelPopup = mle_ui::CopyAudioPopup::create( + 0,0 + ); + pCopyLevelPopup->show(); + } + auto songInfoLayerSetupSch(float) { //add the button ya? if (SETTING(bool, "ui")) { - CCMenuItemSpriteExtra* settings; { + log::debug("isRobtopSong: {}", this->getChildByID("isRobtopSong")); + if (this->getChildByID("isRobtopSong")) { + CCMenuItemSpriteExtra* settings; settings = CCMenuItemSpriteExtra::create(mle_ui::settingsButtonSprite(), this, menu_selector(FLAlertLayerExt::onConfigureSong)); settings->setID("settings"_spr); settings->setPosition(CCPoint(382.000f, -50.f)); settings->m_baseScale = 0.8f; - settings->setScale(settings->m_baseScale); - }; - this->m_buttonMenu->addChild(settings); + settings->setScale(settings->m_baseScale); + this->m_buttonMenu->addChild(settings); + } + else { + CCMenuItemSpriteExtra* copy; + copy = CCMenuItemSpriteExtra::create( + CCSprite::createWithSpriteFrameName("GJ_copyBtn2_001.png"), + this, menu_selector(FLAlertLayerExt::onCopySong) + ); + copy->setID("copy"_spr); + copy->setPosition(CCPoint(382.000f, -50.f)); + copy->m_baseScale = 0.8f; + copy->setScale(copy->m_baseScale); + this->m_buttonMenu->addChild(copy); + } } } $override void show() { - FLAlertLayer::show(); - doSongInfoLayerSetup(); + FLAlertLayer::show(); + if (typeinfo_cast(this)) + this->scheduleOnce(schedule_selector(FLAlertLayerExt::songInfoLayerSetupSch), 0.f); + } +}; + +#include +class $modify(PauseLayerExt, PauseLayer) { + void copyLevel(CCObject*) { + auto pCopyLevelPopup = mle_ui::CopyLevelPopup::create( + GameManager::get()->getPlayLayer()->m_level + ); + pCopyLevelPopup->show(); + } + $override void customSetup() { + PauseLayer::customSetup(); + if (auto menu = typeinfo_cast(this->getChildByIDRecursive("right-button-menu"))) { + CCMenuItemSpriteExtra* copyLevel; { + copyLevel = CCMenuItemSpriteExtra::create( + CCSprite::createWithSpriteFrameName("GJ_copyBtn_001.png"), + this, menu_selector(PauseLayerExt::copyLevel) + ); + copyLevel->setID("copyLevel"_spr); + copyLevel->m_baseScale = 0.575f; + copyLevel->setScale(copyLevel->m_baseScale); + copyLevel->setLayoutOptions(AxisLayoutOptions::create()->setAutoScale(false)); + menu->addChild(copyLevel); + menu->updateLayout(); + }; + } } }; \ No newline at end of file diff --git a/src/editor.cpp b/src/editor.cpp index 47181f8..19a2010 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -20,12 +20,60 @@ class $modify(EditorPauseLayerExt, EditorPauseLayer) { "Main Level Editor\n" "Actually saves level data to file\n" "in user95401.mainlevelseditor config.\n" - "User coins will be saved as Secret Coins!\n" + "User coins will be saved as Secret Coins!\n" + "Btw don't forget set Unique ID (in \"Edit Special\")\n" " " , "chatFont.fnt", 1.f, 600.f, { 0.5f, 0.5f }, 14.f, 0 ), -1, 6302); + if (auto firstLine = cocos::findFirstChildRecursive(node->getChildByTag(6302), [](auto) { return true; })) { + firstLine->setScale(1.5f); + firstLine->setAnchorPoint({ + firstLine->getAnchorPoint().x + (firstLine->getScale() / 10), + firstLine->getAnchorPoint().y + }); + } + node->getChildByTag(6302)->setScale(0.8f); + node->getChildByTag(6302)->setLayoutOptions(AxisLayoutOptions::create()->setAutoScale(0)); node->updateLayout(); } + return rtn; + } +}; + +#include +class $modify(EditorUIExt, EditorUI) { + struct Fields { + SEL_MenuHandler m_orgEditObjectSpecialSel; + }; + void callEditObjectSpecial() { + if (auto editSpecialButton = typeinfo_cast(this->getChildByIDRecursive("edit-special-button"))) { + editSpecialButton->m_pfnSelector = m_fields->m_orgEditObjectSpecialSel; + editSpecialButton->activate(); + editSpecialButton->m_pfnSelector = menu_selector(EditorUIExt::customEditObjectSpecial); + } + } + void customEditObjectSpecial(CCObject* p0) { + if (not this->m_selectedObject) return; + if (not this->m_editorLayer->getChildByIDRecursive("IsMainLevelEditor")) { + return callEditObjectSpecial(); + } + //user coin id 1329, 142 secret coin + if (this->m_selectedObject->m_objectID == 1329) { + this->m_selectedObject->m_objectID = 142; + this->editObject(p0); + this->m_selectedObject->m_objectID = 1329; + return; + } + }; + bool init(LevelEditorLayer* editorLayer) { + auto rtn = EditorUI::init(editorLayer); + + //wasnt bindings for that yet + if (auto editSpecialButton = typeinfo_cast(this->getChildByIDRecursive("edit-special-button"))) { + m_fields->m_orgEditObjectSpecialSel = editSpecialButton->m_pfnSelector; + editSpecialButton->m_pfnSelector = menu_selector(EditorUIExt::customEditObjectSpecial); + } + return rtn; } }; \ No newline at end of file diff --git a/src/level_data.cpp b/src/level_data.cpp index 71b0128..e7da2e3 100644 --- a/src/level_data.cpp +++ b/src/level_data.cpp @@ -15,6 +15,7 @@ class $modify(PlayLayer) { #include class $modify(LocalLevelManagerExt, LocalLevelManager) { $override gd::string getMainLevelString(int p0) { + log::debug("{}({})", __func__, p0); //LocalLevelManager::getMainLevelString(p0); auto levelID = p0; //get data file path @@ -35,10 +36,13 @@ class $modify(LocalLevelManagerExt, LocalLevelManager) { #include class $modify(LevelTools) { $override static GJGameLevel* getLevel(int levelID, bool dontGetLevelString) { - auto level = LevelTools::getLevel(levelID, dontGetLevelString); + auto level = LevelTools::getLevel(levelID, 1); + if (not dontGetLevelString) { + level->m_levelString = LocalLevelManager::get()->getMainLevelString(levelID); + } + level->m_levelID = levelID; //json meta updateLevelByJson(level); - level->m_isUnlocked = true; return level; }; $override static bool NOT_NOW___verifyLevelIntegrity(gd::string p0, int p1) { diff --git a/src/level_listing.cpp b/src/level_listing.cpp index 4ece033..51387c3 100644 --- a/src/level_listing.cpp +++ b/src/level_listing.cpp @@ -44,4 +44,35 @@ class $modify(LevelPage) { difficultySprite->setDisplayFrame(frame); } } +}; + +#include +class $modify(LevelAreaLayerExt, CCLayer) { + void onBack(CCObject*) { + GameManager::get()->playMenuMusic(); + switchToScene(LevelSelectLayer::create(SETTING(int64_t, "max_id"))); + } + auto customSetupSch(float) { + cocos::findFirstChildRecursive( + this, [](auto node) { + if (cocos::getChildBySpriteFrameName(node, "GJ_arrow_03_001.png") == nullptr) return false; + + node->m_pfnSelector = menu_selector(LevelAreaLayerExt::onBack); + node->setID("onBackBtnPatch"_spr); + + return true; + } + ); + } + $override bool init() { + if (typeinfo_cast(this)) + this->scheduleOnce(schedule_selector(LevelAreaLayerExt::customSetupSch), 0.f); + return CCLayer::init(); + } +}; +#include +class $modify(LevelAreaLayer) { + $override void keyBackClicked() { + ((LevelAreaLayerExt*)LevelAreaLayerExt::create())->onBack(this); + } }; \ No newline at end of file diff --git a/src/songs.cpp b/src/songs.cpp index c42fad1..a05c979 100644 --- a/src/songs.cpp +++ b/src/songs.cpp @@ -187,6 +187,8 @@ class $modify(CustomSongWidgetExt, CustomSongWidget) { CustomSongWidget::onMore(sender); if (auto openedJustNowPop = cocos::findFirstChildRecursive(CCDirector::get()->m_pRunningScene, [](auto) {return true; })) { openedJustNowPop->setTag(this->m_customSongID); + if (this->m_isRobtopSong) openedJustNowPop->addChild(nodeWithID("isRobtopSong")); + if (this->m_isMusicLibrary) openedJustNowPop->addChild(nodeWithID("isMusicLibrary")); } } }; \ No newline at end of file