Skip to content

Commit

Permalink
grid view in mod list; some minor stuff left to do
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Nov 17, 2024
1 parent 38f3385 commit 7bcf50d
Show file tree
Hide file tree
Showing 9 changed files with 335 additions and 141 deletions.
1 change: 1 addition & 0 deletions loader/include/Geode/utils/timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ namespace geode::utils {
std::string m_msg;
Timer<Clock> m_timer;

// @geode-ignore(geode-alternative)
LogPerformance(std::string const& msg = "", std::ostream& out = std::cout) :
m_msg(msg), m_output(out) {
m_timer = Timer<Clock>();
Expand Down
Binary file added loader/resources/grid-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions loader/src/platform/ios/LoaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
#include <unistd.h>

void Loader::Impl::platformMessageBox(char const* title, std::string const& info) {
// @geode-ignore(geode-alternative)
std::cout << title << ": " << info << std::endl;
}

void Loader::Impl::logConsoleMessageWithSeverity(std::string const& msg, Severity severity) {
if (m_platformConsoleOpen) {
// @geode-ignore(geode-alternative)
std::cout << msg << "\n" << std::flush;
}
}
Expand Down
58 changes: 43 additions & 15 deletions loader/src/ui/mods/ModsLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,28 +499,48 @@ bool ModsLayer::init() {

// Actions

auto listActionsMenu = CCMenu::create();
listActionsMenu->setID("list-actions-menu");
listActionsMenu->setContentHeight(100);
listActionsMenu->setAnchorPoint({ 1, 0 });
listActionsMenu->setScale(.65f);
auto listDisplayMenu = CCMenu::create();
listDisplayMenu->setID("list-actions-menu");
listDisplayMenu->setContentHeight(100);
listDisplayMenu->setAnchorPoint({ 1, 0 });
listDisplayMenu->setScale(.65f);

auto smallSizeBtn = CCMenuItemSpriteExtra::create(
GeodeSquareSprite::createWithSpriteFrameName("GJ_smallModeIcon_001.png"),
this, menu_selector(ModsLayer::onDisplay)
);
smallSizeBtn->setTag(static_cast<int>(ModListDisplay::SmallList));
smallSizeBtn->setID("list-normal-size-button");
listDisplayMenu->addChild(smallSizeBtn);
m_displayBtns.push_back(smallSizeBtn);

auto bigSizeBtn = CCMenuItemSpriteExtra::create(
GeodeSquareSprite::createWithSpriteFrameName("GJ_smallModeIcon_001.png", &m_bigView),
this, menu_selector(ModsLayer::onBigView)
GeodeSquareSprite::createWithSpriteFrameName("GJ_extendedIcon_001.png"),
this, menu_selector(ModsLayer::onDisplay)
);
bigSizeBtn->setTag(static_cast<int>(ModListDisplay::BigList));
bigSizeBtn->setID("list-size-button");
listActionsMenu->addChild(bigSizeBtn);
listDisplayMenu->addChild(bigSizeBtn);
m_displayBtns.push_back(bigSizeBtn);

auto gridBtn = CCMenuItemSpriteExtra::create(
GeodeSquareSprite::createWithSpriteFrameName("grid-view.png"_spr),
this, menu_selector(ModsLayer::onDisplay)
);
gridBtn->setTag(static_cast<int>(ModListDisplay::Grid));
gridBtn->setID("list-size-button");
listDisplayMenu->addChild(gridBtn);
m_displayBtns.push_back(gridBtn);

// auto searchBtn = CCMenuItemSpriteExtra::create(
// GeodeSquareSprite::createWithSpriteFrameName("search.png"_spr, &m_showSearch),
// this, menu_selector(ModsLayer::onSearch)
// );
// searchBtn->setID("search-button");
// listActionsMenu->addChild(searchBtn);
// listDisplayMenu->addChild(searchBtn);

listActionsMenu->setLayout(ColumnLayout::create());
m_frame->addChildAtPosition(listActionsMenu, Anchor::Left, ccp(-5, 25));
listDisplayMenu->setLayout(ColumnLayout::create()->setAxisReverse(true));
m_frame->addChildAtPosition(listDisplayMenu, Anchor::Left, ccp(-5, 25));

m_statusNode = ModsStatusNode::create();
m_statusNode->setZOrder(4);
Expand Down Expand Up @@ -629,7 +649,7 @@ void ModsLayer::gotoTab(ModListSource* src) {
m_currentSource = src;

// Update the state of the current list
m_lists.at(m_currentSource)->updateSize(m_bigView);
m_lists.at(m_currentSource)->updateDisplay(m_display);
m_lists.at(m_currentSource)->activateSearch(m_showSearch);
m_lists.at(m_currentSource)->updateState();
}
Expand Down Expand Up @@ -687,6 +707,13 @@ void ModsLayer::updateState() {
else {
m_pageMenu->setVisible(false);
}

// Update display button
for (auto btn : m_displayBtns) {
static_cast<GeodeSquareSprite*>(btn->getNormalImage())->setState(
static_cast<ModListDisplay>(btn->getTag()) == m_display
);
}
}

void ModsLayer::onTab(CCObject* sender) {
Expand Down Expand Up @@ -716,12 +743,13 @@ void ModsLayer::onGoToPage(CCObject*) {
popup->setID("go-to-page"_spr);
popup->show();
}
void ModsLayer::onBigView(CCObject*) {
m_bigView = !m_bigView;
void ModsLayer::onDisplay(CCObject* sender) {
m_display = static_cast<ModListDisplay>(sender->getTag());
// Make sure to avoid a crash
if (m_currentSource) {
m_lists.at(m_currentSource)->updateSize(m_bigView);
m_lists.at(m_currentSource)->updateDisplay(m_display);
}
this->updateState();
}
void ModsLayer::onSearch(CCObject*) {
m_showSearch = !m_showSearch;
Expand Down
5 changes: 3 additions & 2 deletions loader/src/ui/mods/ModsLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class ModsLayer : public CCLayer, public SetIDPopupDelegate {
ModsStatusNode* m_statusNode;
EventListener<UpdateModListStateFilter> m_updateStateListener;
bool m_showSearch = true;
bool m_bigView = false;
ModListDisplay m_display = ModListDisplay::SmallList;
std::vector<CCMenuItemSpriteExtra*> m_displayBtns;

bool init();

Expand All @@ -77,7 +78,7 @@ class ModsLayer : public CCLayer, public SetIDPopupDelegate {
void onTab(CCObject* sender);
void onOpenModsFolder(CCObject*);
void onAddModFromFile(CCObject*);
void onBigView(CCObject*);
void onDisplay(CCObject*);
void onSearch(CCObject*);
void onGoToPage(CCObject*);
void onRefreshList(CCObject*);
Expand Down
Loading

0 comments on commit 7bcf50d

Please sign in to comment.