Skip to content

Commit

Permalink
mle v7 meets geode v4
Browse files Browse the repository at this point in the history
  • Loading branch information
user95401 committed Nov 16, 2024
1 parent df6a6d2 commit 349f54d
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 114 deletions.
8 changes: 4 additions & 4 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"geode": "3.6.0",
"geode": "4.0.0-beta.1",
"gd": {
"win": "2.206",
"android": "2.206"
"win": "2.2074",
"android": "2.2074"
},
"version": "v7.0.0-beta.15",
"version": "v7.0.1-beta.15",
"id": "user95401.mainlevelseditor",
"name": "Main Levels Editor",
"developer": "user95401",
Expand Down
16 changes: 8 additions & 8 deletions src/_a_autoupdate.ncpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using namespace geode::prelude;

#include <_fs.hpp>

inline auto repo = Mod::get()->getMetadata().getLinks().getSourceURL().value_or("");
inline auto repo = Mod::get()->getMetadata().getLinks().getSourceURL(].unwrapOr("");
inline auto raw_repo_content = string::replace(repo, "github.com", "raw.githubusercontent.com") + "/main/";
inline auto latest_release = repo + "/releases/latest/download/";

Expand Down Expand Up @@ -35,11 +35,11 @@ inline void download(std::string url = "", fs::path path = "", std::function<voi
listener->bind(
[path, onDownloadingEnd, layer, downloadingLabel](web::WebTask::Event* e) {
if (web::WebProgress* prog = e->getProgress()) {
double a100 = 100 - prog->downloadProgress().value_or(0.0);
double a100 = 100 - prog->downloadProgress(].unwrapOr(0.0);
if (downloadingLabel and (a100 > 0.0)) downloadingLabel->setOpacity((a100 / 100) * 255);
}
if (web::WebResponse* res = e->getValue()) {
std::string data = res->string().unwrapOr("no res");
std::string data = res->string(].unwrapOr("no res");
if (res->code() < 399) {
res->into(path);
if (layer) SceneManager::get()->forget(layer);
Expand Down Expand Up @@ -89,17 +89,17 @@ class $modify(MenuLayerExt, MenuLayer) {
[this](web::WebTask::Event* e) {
if (web::WebResponse* res = e->getValue()) {

auto str = res->string().value_or("");
auto str = res->string(].unwrapOr("");

auto err = std::string();
auto parse = matjson::parse(str, err);
if (not parse.has_value())
if (not parse.isOk())
return log::error("parse err: {}", err);
auto actualMetaDataResult = ModMetadata::create(parse.value());
if (not actualMetaDataResult.has_value())
auto actualMetaDataResult = ModMetadata::create(parse.unwrapOrDefault());
if (not actualMetaDataResult.isOk())
return log::error("actualMetaDataResult: {}", actualMetaDataResult.error());

auto actualMetaData = actualMetaDataResult.value();
auto actualMetaData = actualMetaDataResult.unwrapOrDefault();

if (actualMetaData.getVersion() == Mod::get()->getVersion()) return;

Expand Down
181 changes: 95 additions & 86 deletions src/_main.hpp

Large diffs are not rendered by default.

27 changes: 18 additions & 9 deletions src/control_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,40 @@ class $modify(LevelPageExt, LevelPage) {
CCMenuItemSpriteExtra* deleteLevel; {
deleteLevel = CCMenuItemSpriteExtra::create(mle_ui::deleteButtonSprite(), this, menu_selector(LevelPageExt::deleteLevel));
deleteLevel->setID("deleteLevel"_spr);
deleteLevel->setPosition(CCPoint(190, 30));
deleteLevel->m_baseScale = 0.8f;
deleteLevel->setScale(deleteLevel->m_baseScale);
};
CCMenuItemSpriteExtra* editLevel; {
editLevel = CCMenuItemSpriteExtra::create(mle_ui::settingsButtonSprite(), this, menu_selector(LevelPageExt::editLevel));
editLevel->setID("editLevel"_spr);
editLevel->setPosition(CCPoint(190, 0));
editLevel->m_baseScale = 0.8f;
editLevel->setScale(editLevel->m_baseScale);
};
if (auto levelMenu = getChildByIDRecursive("level-menu")) {
levelMenu->addChild(deleteLevel);
levelMenu->addChild(editLevel);
//levelMenu->addChild(deleteLevel);
//levelMenu->addChild(editLevel);
{
levelMenu->addChild(editLevel);

auto view = CCDirector::get()->getVisibleSize();
auto viewCenter = view / 2;
auto worldPos = viewCenter + CCPointMake((view.width / 2) - 68, 90);
editLevel->setPosition(levelMenu->convertToNodeSpace(worldPos));
}
{
levelMenu->addChild(deleteLevel);

auto view = CCDirector::get()->getVisibleSize();
auto viewCenter = view / 2;
auto worldPos = viewCenter + CCPointMake((view.width / 2) - 68, 60);
deleteLevel->setPosition(levelMenu->convertToNodeSpace(worldPos));
}
};
}
return rtn;
};
$override void updateDynamicPage(GJGameLevel* p0) {
LevelPage::updateDynamicPage(p0);
//my menu_for_level_page
if (auto pCCMenu = this->getChildByIDRecursive("menu_for_level_page"_spr)) {
pCCMenu->setVisible(p0->m_levelID >= 1);
pCCMenu->setZOrder(p0->m_levelID);
}
}
};

Expand Down
5 changes: 3 additions & 2 deletions src/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class $modify(EditorPauseLayerExt, EditorPauseLayer) {
$override void saveLevel() {
EditorPauseLayer::saveLevel();
if (not this->m_editorLayer->getChildByIDRecursive("IsMainLevelEditor")) return;
this->m_editorLayer->m_level->m_levelType = GJLevelType::Local;
mle_leveltools::updateLevelDataAndMetaFiles(
this->m_editorLayer->getLevelString(),
this->m_editorLayer->m_level
Expand Down Expand Up @@ -79,7 +80,7 @@ class $modify(EditorUIExt, EditorUI) {
class $modify(LevelSettingsLayerExt, FLAlertLayer) {
auto audioIdFromLabel(CCLabelBMFont * songLabel) {
auto str_expl = string::explode(":", songLabel->getString());
auto audioID = utils::numFromString<int>(str_expl[0]).value_or(0);
auto audioID = utils::numFromString<int>(str_expl[0]).unwrapOr(0);
return audioID;
}
auto getCurrentAudioNode() {
Expand Down Expand Up @@ -192,7 +193,7 @@ class $modify(LevelSettingsLayerExt, FLAlertLayer) {
audioList->setID("audioList");
audioList->setVisible(0);
for (auto file : availableAudioFiles) {
auto id = utils::numFromString<int>(file.filename().string()).value_or(0);
auto id = utils::numFromString<int>(file.filename().string()).unwrapOr(0);
auto audio = createDataNode(
"audio",
fmt::format("{}: {}", id, LevelTools::getAudioTitle(id).data()).data(),
Expand Down
4 changes: 2 additions & 2 deletions src/level_listing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class $modify(BoomScrollLayerExt, BoomScrollLayer) {
//special_ids
for (auto strID : string::explode(",", SETTING(std::string, "special_ids"))) {
auto id_num = utils::numFromString<int>(strID);
if (id_num.has_value())
myLevelsArray->addObject(LevelTools::getLevel(id_num.value(), 0));
if (id_num.isOk())
myLevelsArray->addObject(LevelTools::getLevel(id_num.unwrapOrDefault(), 0));
}

//the_tower
Expand Down
7 changes: 4 additions & 3 deletions src/songs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class $modify(SongsLayerExt, SongsLayer) {
auto menu = CCMenu::createWithItem(
CCMenuItemSpriteExtra::create(viewBtnSprite, this, menu_selector(SongsLayerExt::onView))
);
cocos::getChildOfType<CCMenuItemSpriteExtra>(menu, 0)->setTag(id);
menu->getChildByType<CCMenuItemSpriteExtra>(0)->setTag(id);
menu->getChildByType<CCMenuItemSpriteExtra>(0)->setTag(id);
menu->setLayoutOptions(
AnchorLayoutOptions::create()
->setAnchor(Anchor::Right)
Expand Down Expand Up @@ -157,7 +158,7 @@ class $modify(SongsLayerExt, SongsLayer) {
//songs_special_ids
for (auto strID : string::explode(",", SETTING(std::string, "songs_special_ids"))) {
auto id_num = utils::numFromString<int>(strID);
if (id_num.has_value()) addSongCell(id_num.value(), altBg, contentLayer);
if (id_num.isOk()) addSongCell(id_num.unwrapOrDefault(), altBg, contentLayer);
}
//practice
if (SETTING(bool, "practice_music")) addSongCell(-1, altBg, contentLayer);
Expand Down Expand Up @@ -197,7 +198,7 @@ class $modify(CustomSongWidgetExt, CustomSongWidget) {
openedJustNowPop->setTag(this->m_customSongID);
if (this->m_isRobtopSong) openedJustNowPop->addChild(createDataNode("m_isRobtopSong"));
if (this->m_isMusicLibrary) openedJustNowPop->addChild(createDataNode("m_isMusicLibrary"));
if (m_songInfoObject->m_isUnkownSong) openedJustNowPop->addChild(createDataNode("m_isUnkownSong"));
if (m_songInfoObject->m_isUnknownSong) openedJustNowPop->addChild(createDataNode("m_isUnknownSong"));
openedJustNowPop->addChild(createDataNode("m_songID", "", m_songInfoObject->m_songID));
openedJustNowPop->addChild(createDataNode("m_songName", m_songInfoObject->m_songName.data()));
openedJustNowPop->addChild(createDataNode("m_artistName", m_songInfoObject->m_artistName.data()));
Expand Down

0 comments on commit 349f54d

Please sign in to comment.