-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21624f1
commit b2e8bf2
Showing
12 changed files
with
325 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "Mods.hpp" | ||
|
||
std::vector<ModCell*> ModBackend::getMods() { | ||
// sort the list by mod name | ||
auto sort_by_name = [](Mod* a, Mod* b) { | ||
return a->getName() < b->getName(); | ||
}; | ||
|
||
std::list<Mod*> mods; | ||
std::ranges::copy(Loader::get()->getAllMods(), std::back_inserter(mods)); | ||
mods.sort(sort_by_name); | ||
|
||
std::vector<ModCell*> modCells; | ||
for (Mod* mod : mods) { | ||
modCells.push_back(ModCell::create(mod)); | ||
} | ||
|
||
mods.clear(); | ||
return modCells; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <list> | ||
|
||
#include <Geode/Geode.hpp> | ||
|
||
#include "UI/ModCell.hpp" | ||
using namespace geode::prelude; | ||
|
||
class ModBackend { | ||
public: | ||
static ModBackend* get() { | ||
static ModBackend* instance; | ||
return instance; | ||
} | ||
|
||
std::vector<ModCell*> getMods(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "ModCell.hpp" | ||
|
||
bool ModCell::init(Mod* mod) { | ||
if (!CCNode::init()) return false; | ||
|
||
this->m_mod = mod; | ||
|
||
Build<CCScale9Sprite>::create("square02b_small.png") | ||
.id(this->makeID("bg")) | ||
.ignoreAnchorPointForPos(false) | ||
.anchorPoint({0.f, 0.f}) | ||
.scale(0.7f) | ||
.color(ccWHITE) | ||
.opacity(25) | ||
.parent(this) | ||
.store(m_bg); | ||
|
||
m_logo = geode::createModLogo(mod); | ||
m_logo->setID("logo-sprite"); | ||
m_logo->setScale(0.5f); | ||
m_logo->setAnchorPoint({.0f, .0f}); | ||
m_logo->setPositionY(m_logo->getPositionY() + 2.f); | ||
this->addChild(m_logo); | ||
|
||
Build<CCNode>::create() | ||
.id(this->makeID("info-container")) | ||
.scale(.4f) | ||
.anchorPoint({0.f, 0.5f}) | ||
.layout(ColumnLayout::create() | ||
->setAxisReverse(true) | ||
->setAxisAlignment(AxisAlignment::Even) | ||
->setCrossAxisLineAlignment(AxisAlignment::Start) | ||
->setGap(0) | ||
) | ||
.parent(this) | ||
.store(m_infoContainer); | ||
|
||
this->m_infoContainer->getLayout()->ignoreInvisibleChildren(true); | ||
|
||
Build<CCNode>::create() | ||
.id(this->makeID("title-container")) | ||
.anchorPoint({0.f, 0.5f}) | ||
.layout(RowLayout::create() | ||
->setDefaultScaleLimits(.1f, 1.f) | ||
->setAxisAlignment(AxisAlignment::Start) | ||
) | ||
.store(m_titleContainer) | ||
.parent(m_infoContainer) | ||
.center() | ||
.intoNewChild(CCLabelBMFont::create(mod->getName().c_str(), "bigFont.fnt")); | ||
|
||
this->setID(mod->getID()); | ||
this->setContentSize(CCSize{m_bg->getScaledContentWidth(), m_bg->getScaledContentHeight()}); | ||
return true; | ||
} | ||
|
||
std::string ModCell::makeID(std::string id) { | ||
return fmt::format("{}-{}", this->m_mod->getID(), id); | ||
} | ||
|
||
ModCell* ModCell::create(Mod* mod) { | ||
auto ret = new ModCell(); | ||
if (ret && ret->init(mod)) { | ||
ret->autorelease(); | ||
return ret; | ||
} | ||
CC_SAFE_DELETE(ret); | ||
return nullptr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include <Geode/Geode.hpp> | ||
#include <Geode/loader/ModMetadata.hpp> | ||
#include <Geode/ui/GeodeUI.hpp> | ||
#include <UIBuilder.hpp> | ||
using namespace geode::prelude; | ||
|
||
class ModCell : public CCNode { | ||
protected: | ||
bool init(Mod* mod); | ||
void updateState(); | ||
|
||
void onEnable(CCObject*); | ||
std::string makeID(std::string id); | ||
|
||
Mod* m_mod; | ||
|
||
public: | ||
static ModCell* create(Mod* mod); | ||
void updateSize(float width, bool big); | ||
|
||
CCScale9Sprite* m_bg; | ||
CCNode* m_logo; | ||
CCNode* m_infoContainer; | ||
CCNode* m_titleContainer; | ||
CCLabelBMFont* m_titleLabel; | ||
CCLabelBMFont* m_versionLabel; | ||
CCNode* m_developers; | ||
CCLabelBMFont* m_developerLabel; | ||
CCMenu* m_viewMenu; | ||
CCMenuItemToggler* m_enableToggle = nullptr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "ModProfilesLayer.hpp" | ||
|
||
bool ModProfilesLayer::init() { | ||
if (!CCLayer::init()) { | ||
return false; | ||
} | ||
|
||
auto director = CCDirector::get(); | ||
|
||
CCSprite* backSpr = CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png"); | ||
|
||
CCMenuItemSpriteExtra* backBtn = Build<CCMenuItemSpriteExtra>::create(backSpr, this, menu_selector(ModProfilesLayer::onClose)) | ||
.id("back-button") | ||
.collect(); | ||
|
||
CCMenu* backMenu = Build<CCMenu>::create() | ||
.id("back-menu") | ||
.pos(ccp(director->getScreenLeft() + 25.f, director->getScreenTop() - 22.f)) | ||
.zOrder(1) | ||
.parent(this) | ||
.child(backBtn) | ||
.collect(); | ||
|
||
this->setKeyboardEnabled(true); | ||
this->setKeypadEnabled(true); | ||
|
||
auto bg = geode::createLayerBG(); | ||
bg->setID("content-background"); | ||
this->addChild(bg); | ||
|
||
Build<MPListLayer>::create(ModBackend::get()->getMods(), "Export Mods") | ||
.id("mp-list-layer") | ||
.parent(this) | ||
.center() | ||
.store(m_mpListLayer); | ||
|
||
return true; | ||
} | ||
|
||
void ModProfilesLayer::onClose(CCObject*) { | ||
auto mainMenu = MenuLayer::scene(false); | ||
CCDirector::sharedDirector()->pushScene(CCTransitionFlipAngular::create(0.5f, mainMenu)); | ||
} | ||
|
||
void ModProfilesLayer::keyBackClicked() { | ||
this->onClose(nullptr); | ||
} | ||
|
||
ModProfilesLayer* ModProfilesLayer::create() { | ||
auto ret = new ModProfilesLayer(); | ||
if (ret && ret->init()) { | ||
ret->autorelease(); | ||
return ret; | ||
} | ||
|
||
CC_SAFE_DELETE(ret); | ||
return nullptr; | ||
} | ||
|
||
CCScene* ModProfilesLayer::scene() { | ||
auto layer = ModProfilesLayer::create(); | ||
auto scene = CCScene::create(); | ||
scene->addChild(layer); | ||
return scene; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include <Geode/Geode.hpp> | ||
#include <UIBuilder.hpp> | ||
|
||
#include "ModCell.hpp" | ||
#include "Utils/MPListLayer.hpp" | ||
#include "Backend/Mods.hpp" | ||
|
||
using namespace geode::prelude; | ||
|
||
class ModProfilesLayer : public CCLayer { | ||
protected: | ||
CCScale9Sprite* m_bg; | ||
GJListLayer* m_listLayer; | ||
|
||
CCMenu* m_tabButtonMenu; | ||
TabButton* m_exportTab; | ||
TabButton* m_importTab; | ||
TabButton* m_packsTab; | ||
|
||
MPListLayer* m_mpListLayer; | ||
|
||
void onClose(CCObject*); | ||
|
||
void keyBackClicked() override; | ||
|
||
public: | ||
static ModProfilesLayer* create(); | ||
static CCScene* scene(); | ||
bool init() override; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.