Skip to content

Commit

Permalink
copy levels, coin setup popup for editor, fix data and meta bugs at n…
Browse files Browse the repository at this point in the history
…ew levels, the tower back btn fix, set the requiredCoins
  • Loading branch information
user95401 committed Jul 14, 2024
1 parent 9abf967 commit 204051c
Show file tree
Hide file tree
Showing 7 changed files with 448 additions and 14 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
306 changes: 304 additions & 2 deletions src/_main.hpp

Large diffs are not rendered by default.

63 changes: 55 additions & 8 deletions src/control_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,69 @@ class $modify(FLAlertLayerExt, FLAlertLayer) {
};
ae->show();
}
auto doSongInfoLayerSetup() {
if (not typeinfo_cast<SongInfoLayer*>(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<SongInfoLayer*>(this))
this->scheduleOnce(schedule_selector(FLAlertLayerExt::songInfoLayerSetupSch), 0.f);
}
};

#include <Geode/modify/PauseLayer.hpp>
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<CCMenu*>(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();
};
}
}
};
50 changes: 49 additions & 1 deletion src/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,60 @@ class $modify(EditorPauseLayerExt, EditorPauseLayer) {
"<co>Main Level Editor</c>\n"
"Actually <cg>saves level data</c> to file\n"
"<cy>in user95401.mainlevelseditor config</c>.\n"
"<cr>User coins</c> will be <cy>saved as Secret Coins</c>!\n"
"<co>User coins</c> will be <cg>saved as</c> <cy>Secret Coins</c>!\n"
"<cr>Btw don't forget set Unique ID (in \"Edit Special\")</c>\n"
" "
, "chatFont.fnt", 1.f, 600.f, { 0.5f, 0.5f }, 14.f, 0
), -1, 6302);
if (auto firstLine = cocos::findFirstChildRecursive<CCLabelBMFont>(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 <Geode/modify/EditorUI.hpp>
class $modify(EditorUIExt, EditorUI) {
struct Fields {
SEL_MenuHandler m_orgEditObjectSpecialSel;
};
void callEditObjectSpecial() {
if (auto editSpecialButton = typeinfo_cast<CCMenuItemSpriteExtra*>(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<CCMenuItemSpriteExtra*>(this->getChildByIDRecursive("edit-special-button"))) {
m_fields->m_orgEditObjectSpecialSel = editSpecialButton->m_pfnSelector;
editSpecialButton->m_pfnSelector = menu_selector(EditorUIExt::customEditObjectSpecial);
}

return rtn;
}
};
8 changes: 6 additions & 2 deletions src/level_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class $modify(PlayLayer) {
#include <Geode/modify/LocalLevelManager.hpp>
class $modify(LocalLevelManagerExt, LocalLevelManager) {
$override gd::string getMainLevelString(int p0) {
log::debug("{}({})", __func__, p0);
//LocalLevelManager::getMainLevelString(p0);
auto levelID = p0;
//get data file path
Expand All @@ -35,10 +36,13 @@ class $modify(LocalLevelManagerExt, LocalLevelManager) {
#include <Geode/modify/LevelTools.hpp>
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) {
Expand Down
31 changes: 31 additions & 0 deletions src/level_listing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,35 @@ class $modify(LevelPage) {
difficultySprite->setDisplayFrame(frame);
}
}
};

#include <Geode/modify/CCLayer.hpp>
class $modify(LevelAreaLayerExt, CCLayer) {
void onBack(CCObject*) {
GameManager::get()->playMenuMusic();
switchToScene(LevelSelectLayer::create(SETTING(int64_t, "max_id")));
}
auto customSetupSch(float) {
cocos::findFirstChildRecursive<CCMenuItemSpriteExtra>(
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<LevelAreaLayer*>(this))
this->scheduleOnce(schedule_selector(LevelAreaLayerExt::customSetupSch), 0.f);
return CCLayer::init();
}
};
#include <Geode/modify/LevelAreaLayer.hpp>
class $modify(LevelAreaLayer) {
$override void keyBackClicked() {
((LevelAreaLayerExt*)LevelAreaLayerExt::create())->onBack(this);
}
};
2 changes: 2 additions & 0 deletions src/songs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ class $modify(CustomSongWidgetExt, CustomSongWidget) {
CustomSongWidget::onMore(sender);
if (auto openedJustNowPop = cocos::findFirstChildRecursive<SongInfoLayer>(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"));
}
}
};

0 comments on commit 204051c

Please sign in to comment.