Compare commits

..

1 commit

Author SHA1 Message Date
larzie
a30673c6df
Merge d86830028e into 7bcf50da57 2024-11-18 15:12:25 +01:00
16 changed files with 33 additions and 111 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View file

@ -1079,7 +1079,7 @@ void Loader::Impl::installModManuallyFromFile(std::filesystem::path const& path,
createQuickPopup( createQuickPopup(
"Already Installed", "Already Installed",
fmt::format( fmt::format(
"The mod <cy>{}</c> <cj>{}</c> has already been installed " "The mod <cy>{}</c> <cj>v{}</c> has already been installed "
"as version <cl>{}</c>. Do you want to <co>replace the " "as version <cl>{}</c>. Do you want to <co>replace the "
"installed version with the file</c>?", "installed version with the file</c>?",
meta.getID(), meta.getVersion(), meta.getID(), meta.getVersion(),

View file

@ -19,8 +19,6 @@
#include "ui/mods/sources/ModListSource.hpp" #include "ui/mods/sources/ModListSource.hpp"
#include <loader/LoaderImpl.hpp> #include <loader/LoaderImpl.hpp>
static ModListDisplay MOD_LIST_DISPLAY = ModListDisplay::SmallList;
bool ModsStatusNode::init() { bool ModsStatusNode::init() {
if (!CCNode::init()) if (!CCNode::init())
return false; return false;
@ -651,7 +649,7 @@ void ModsLayer::gotoTab(ModListSource* src) {
m_currentSource = src; m_currentSource = src;
// Update the state of the current list // Update the state of the current list
m_lists.at(m_currentSource)->updateDisplay(MOD_LIST_DISPLAY); m_lists.at(m_currentSource)->updateDisplay(m_display);
m_lists.at(m_currentSource)->activateSearch(m_showSearch); m_lists.at(m_currentSource)->activateSearch(m_showSearch);
m_lists.at(m_currentSource)->updateState(); m_lists.at(m_currentSource)->updateState();
} }
@ -713,7 +711,7 @@ void ModsLayer::updateState() {
// Update display button // Update display button
for (auto btn : m_displayBtns) { for (auto btn : m_displayBtns) {
static_cast<GeodeSquareSprite*>(btn->getNormalImage())->setState( static_cast<GeodeSquareSprite*>(btn->getNormalImage())->setState(
static_cast<ModListDisplay>(btn->getTag()) == MOD_LIST_DISPLAY static_cast<ModListDisplay>(btn->getTag()) == m_display
); );
} }
} }
@ -746,11 +744,10 @@ void ModsLayer::onGoToPage(CCObject*) {
popup->show(); popup->show();
} }
void ModsLayer::onDisplay(CCObject* sender) { void ModsLayer::onDisplay(CCObject* sender) {
MOD_LIST_DISPLAY = static_cast<ModListDisplay>(sender->getTag()); m_display = static_cast<ModListDisplay>(sender->getTag());
// Make sure to avoid a crash // Make sure to avoid a crash
if (m_currentSource) { if (m_currentSource) {
m_lists.at(m_currentSource)->updateDisplay(MOD_LIST_DISPLAY); m_lists.at(m_currentSource)->updateDisplay(m_display);
m_lists.at(m_currentSource)->reloadPage();
} }
this->updateState(); this->updateState();
} }

View file

@ -66,6 +66,7 @@ protected:
ModsStatusNode* m_statusNode; ModsStatusNode* m_statusNode;
EventListener<UpdateModListStateFilter> m_updateStateListener; EventListener<UpdateModListStateFilter> m_updateStateListener;
bool m_showSearch = true; bool m_showSearch = true;
ModListDisplay m_display = ModListDisplay::SmallList;
std::vector<CCMenuItemSpriteExtra*> m_displayBtns; std::vector<CCMenuItemSpriteExtra*> m_displayBtns;
bool init(); bool init();

View file

@ -53,10 +53,6 @@ bool ModItem::init(ModSource&& source) {
m_versionLabel->setID("version-label"); m_versionLabel->setID("version-label");
m_versionLabel->setLayoutOptions(AxisLayoutOptions::create()->setScaleLimits(std::nullopt, .7f)); m_versionLabel->setLayoutOptions(AxisLayoutOptions::create()->setScaleLimits(std::nullopt, .7f));
m_titleContainer->addChild(m_versionLabel); m_titleContainer->addChild(m_versionLabel);
m_versionDownloadSeparator = CCLabelBMFont::create("", "bigFont.fnt");
m_versionDownloadSeparator->setOpacity(155);
m_titleContainer->addChild(m_versionDownloadSeparator);
m_titleContainer->setLayout( m_titleContainer->setLayout(
RowLayout::create() RowLayout::create()
@ -184,7 +180,10 @@ bool ModItem::init(ModSource&& source) {
} }
} }
auto viewBtn = CCMenuItemSpriteExtra::create(spr, this, menu_selector(ModItem::onView)); auto viewBtn = CCMenuItemSpriteExtra::create(
spr,
this, menu_selector(ModItem::onView)
);
viewBtn->setID("view-button"); viewBtn->setID("view-button");
m_viewMenu->addChild(viewBtn); m_viewMenu->addChild(viewBtn);
@ -230,23 +229,10 @@ bool ModItem::init(ModSource&& source) {
m_badgeContainer->addChild(CCSprite::createWithSpriteFrameName("tag-featured.png"_spr)); m_badgeContainer->addChild(CCSprite::createWithSpriteFrameName("tag-featured.png"_spr));
} }
if (metadata.tags.contains("paid")) { if (metadata.tags.contains("paid")) {
auto shortVer = CCSprite::createWithSpriteFrameName("tag-paid.png"_spr); m_badgeContainer->addChild(CCSprite::createWithSpriteFrameName("tag-paid.png"_spr));
shortVer->setTag(1);
m_badgeContainer->addChild(shortVer);
auto longVer = CCSprite::createWithSpriteFrameName("tag-paid-long.png"_spr);
longVer->setTag(2);
m_badgeContainer->addChild(longVer);
}
if (metadata.tags.contains("joke")) {
m_badgeContainer->addChild(CCSprite::createWithSpriteFrameName("tag-joke.png"_spr));
} }
if (metadata.tags.contains("modtober24")) { if (metadata.tags.contains("modtober24")) {
auto shortVer = CCSprite::createWithSpriteFrameName("tag-modtober.png"_spr); m_badgeContainer->addChild(CCSprite::createWithSpriteFrameName("tag-modtober.png"_spr));
shortVer->setTag(1);
m_badgeContainer->addChild(shortVer);
auto longVer = CCSprite::createWithSpriteFrameName("tag-modtober-long.png"_spr);
longVer->setTag(2);
m_badgeContainer->addChild(longVer);
} }
// Show mod download count here already so people can make informed decisions // Show mod download count here already so people can make informed decisions
@ -256,18 +242,17 @@ bool ModItem::init(ModSource&& source) {
auto downloads = CCLabelBMFont::create(numToAbbreviatedString(metadata.downloadCount).c_str(), "bigFont.fnt"); auto downloads = CCLabelBMFont::create(numToAbbreviatedString(metadata.downloadCount).c_str(), "bigFont.fnt");
downloads->setID("downloads-label"); downloads->setID("downloads-label");
downloads->setColor("mod-list-version-label"_cc3b); downloads->setColor("mod-list-version-label"_cc3b);
downloads->limitLabelWidth(125, 1.f, .1f); downloads->limitLabelWidth(80, .5f, .1f);
m_downloadCountContainer->addChildAtPosition(downloads, Anchor::Right, ccp(-0, 0), ccp(1, .5f)); m_downloadCountContainer->addChildAtPosition(downloads, Anchor::Right, ccp(-0, 0), ccp(1, .5f));
auto downloadsIcon = CCSprite::createWithSpriteFrameName("GJ_downloadsIcon_001.png"); auto downloadsIcon = CCSprite::createWithSpriteFrameName("GJ_downloadsIcon_001.png");
downloadsIcon->setID("downloads-icon-sprite"); downloadsIcon->setID("downloads-icon-sprite");
downloadsIcon->setScale(1.2f); downloadsIcon->setScale(.75f);
m_downloadCountContainer->addChildAtPosition(downloadsIcon, Anchor::Left, ccp(8, 0)); m_downloadCountContainer->addChildAtPosition(downloadsIcon, Anchor::Left, ccp(5, 0));
// m_downloadCountContainer scale is controlled in updateState
m_downloadCountContainer->setContentSize({ m_downloadCountContainer->setContentSize({
downloads->getScaledContentWidth() + downloadsIcon->getScaledContentWidth(), downloads->getScaledContentWidth() + downloadsIcon->getScaledContentWidth(),
30 25
}); });
m_downloadCountContainer->updateLayout(); m_downloadCountContainer->updateLayout();
@ -353,7 +338,7 @@ void ModItem::updateState() {
// Update the size of the mod cell itself // Update the size of the mod cell itself
if (m_display == ModListDisplay::Grid) { if (m_display == ModListDisplay::Grid) {
auto widthWithoutGaps = m_targetWidth - 7.5f; auto widthWithoutGaps = m_targetWidth - 10;
this->setContentSize(ccp(widthWithoutGaps / roundf(widthWithoutGaps / 80), 100)); this->setContentSize(ccp(widthWithoutGaps / roundf(widthWithoutGaps / 80), 100));
m_bg->setContentSize(m_obContentSize / m_bg->getScale()); m_bg->setContentSize(m_obContentSize / m_bg->getScale());
} }
@ -373,19 +358,14 @@ void ModItem::updateState() {
m_titleContainer->insertBefore(m_titleLabel, nullptr); m_titleContainer->insertBefore(m_titleLabel, nullptr);
} }
// Show download separator if there is something to separate and we're in grid view
m_versionDownloadSeparator->setVisible(m_downloadCountContainer && m_display == ModListDisplay::Grid);
// Download counts go next to the version like on the website on grid view // Download counts go next to the version like on the website on grid view
if (m_downloadCountContainer) { if (m_downloadCountContainer) {
m_downloadCountContainer->removeFromParent(); m_downloadCountContainer->removeFromParent();
if (m_display == ModListDisplay::Grid) { if (m_display == ModListDisplay::Grid) {
m_titleContainer->insertAfter(m_downloadCountContainer, m_versionDownloadSeparator); m_titleContainer->insertAfter(m_downloadCountContainer, m_versionLabel);
m_downloadCountContainer->setLayoutOptions(AxisLayoutOptions::create()->setScaleLimits(.1f, .7f));
} }
else { else {
m_viewMenu->addChild(m_downloadCountContainer); m_viewMenu->addChild(m_downloadCountContainer);
m_downloadCountContainer->setLayoutOptions(AxisLayoutOptions::create()->setScaleLimits(.1f, .6f));
} }
} }
@ -393,31 +373,14 @@ void ModItem::updateState() {
if (m_badgeContainer) { if (m_badgeContainer) {
m_badgeContainer->removeFromParent(); m_badgeContainer->removeFromParent();
if (m_display == ModListDisplay::Grid) { if (m_display == ModListDisplay::Grid) {
m_badgeContainer->setLayout( m_badgeContainer->setLayout(ColumnLayout::create()->setAutoGrowAxis(true));
ColumnLayout::create() m_badgeContainer->setScale(.25f);
->setAxisReverse(true) this->addChildAtPosition(m_badgeContainer, Anchor::TopLeft, ccp(5, -5), ccp(0, 1));
->setAutoGrowAxis(true)
->setAxisAlignment(AxisAlignment::Start)
);
m_badgeContainer->getLayout()->ignoreInvisibleChildren(true);
m_badgeContainer->setScale(.3f);
this->addChildAtPosition(m_badgeContainer, Anchor::TopLeft, ccp(5, -2), ccp(0, 1));
} }
else { else {
m_badgeContainer->setLayout( m_badgeContainer->setLayout(RowLayout::create()->setAutoGrowAxis(true));
RowLayout::create()
->setAutoGrowAxis(true)
);
m_badgeContainer->getLayout()->ignoreInvisibleChildren(true);
m_titleContainer->addChild(m_badgeContainer); m_titleContainer->addChild(m_badgeContainer);
} }
// Long tags don't fit in the grid UI
for (auto child : CCArrayExt<CCNode*>(m_badgeContainer->getChildren())) {
if (child->getTag() > 0) {
child->setVisible(child->getTag() == (m_display == ModListDisplay::Grid ? 1 : 2));
}
}
m_badgeContainer->updateLayout();
} }
// On Grid View logo has constant size // On Grid View logo has constant size
@ -595,9 +558,6 @@ void ModItem::updateState() {
m_recommendedBy->updateLayout(); m_recommendedBy->updateLayout();
} }
limitNodeWidth(m_downloadWaiting, m_titleContainer->getContentWidth(), 1.f, .1f);
limitNodeWidth(m_downloadBarContainer, m_titleContainer->getContentWidth(), 1.f, .1f);
// Update positioning (jesus) // Update positioning (jesus)
switch (m_display) { switch (m_display) {
case ModListDisplay::Grid: { case ModListDisplay::Grid: {

View file

@ -48,7 +48,6 @@ protected:
Ref<CCNode> m_downloadCountContainer; Ref<CCNode> m_downloadCountContainer;
ModListDisplay m_display = ModListDisplay::SmallList; ModListDisplay m_display = ModListDisplay::SmallList;
float m_targetWidth = 300; float m_targetWidth = 300;
CCLabelBMFont* m_versionDownloadSeparator;
/** /**
* @warning Make sure `getMetadata` and `createModLogo` are callable * @warning Make sure `getMetadata` and `createModLogo` are callable

View file

@ -6,22 +6,6 @@
#include "../ModsLayer.hpp" #include "../ModsLayer.hpp"
#include "../popups/ModtoberPopup.hpp" #include "../popups/ModtoberPopup.hpp"
static size_t getDisplayPageSize(ModListSource* src, ModListDisplay display) {
if (src->isLocalModsOnly() && Mod::get()->template getSettingValue<bool>("infinite-local-mods-list")) {
return std::numeric_limits<size_t>::max();
}
return display == ModListDisplay::Grid ? 16 : 10;
}
$execute {
listenForSettingChanges("infinite-local-mods-list", [](bool value) {
InstalledModListSource::get(InstalledModListType::All)->reset();
InstalledModListSource::get(InstalledModListType::OnlyErrors)->reset();
InstalledModListSource::get(InstalledModListType::OnlyOutdated)->reset();
// Updates is technically a server mod list :-) So I left it out here
});
}
bool ModList::init(ModListSource* src, CCSize const& size) { bool ModList::init(ModListSource* src, CCSize const& size) {
if (!CCNode::init()) if (!CCNode::init())
return false; return false;
@ -195,7 +179,7 @@ bool ModList::init(ModListSource* src, CCSize const& size) {
m_searchInput->setCallback([this](auto const&) { m_searchInput->setCallback([this](auto const&) {
// If the source is already in memory, we can immediately update the // If the source is already in memory, we can immediately update the
// search query // search query
if (m_source->isLocalModsOnly()) { if (typeinfo_cast<InstalledModListSource*>(m_source)) {
m_source->search(m_searchInput->getString()); m_source->search(m_searchInput->getString());
return; return;
} }
@ -566,7 +550,6 @@ void ModList::updateTopContainer() {
void ModList::updateDisplay(ModListDisplay display) { void ModList::updateDisplay(ModListDisplay display) {
m_display = display; m_display = display;
m_source->setPageSize(getDisplayPageSize(m_source, m_display));
// Update all BaseModItems that are children of the list // Update all BaseModItems that are children of the list
// There may be non-BaseModItems there (like separators) so gotta be type-safe // There may be non-BaseModItems there (like separators) so gotta be type-safe
@ -587,7 +570,7 @@ void ModList::updateDisplay(ModListDisplay display) {
m_list->m_contentLayer->setLayout( m_list->m_contentLayer->setLayout(
RowLayout::create() RowLayout::create()
->setGrowCrossAxis(true) ->setGrowCrossAxis(true)
->setAxisAlignment(AxisAlignment::Start) ->setAxisAlignment(AxisAlignment::Center)
->setGap(2.5f) ->setGap(2.5f)
); );
} }
@ -651,9 +634,6 @@ void ModList::gotoPage(size_t page, bool update) {
// Clear list contents // Clear list contents
m_list->m_contentLayer->removeAllChildren(); m_list->m_contentLayer->removeAllChildren();
m_page = page; m_page = page;
// Update page size (if needed)
m_source->setPageSize(getDisplayPageSize(m_source, m_display));
// Start loading new page with generic loading message // Start loading new page with generic loading message
this->showStatus(ModListUnkProgressStatus(), "Loading..."); this->showStatus(ModListUnkProgressStatus(), "Loading...");

View file

@ -137,8 +137,11 @@ bool InstalledModListSource::isDefaultQuery() const {
return m_query.isDefault(); return m_query.isDefault();
} }
bool InstalledModListSource::isLocalModsOnly() const { $execute {
return m_type == InstalledModListType::All || listenForSettingChanges("infinite-local-mods-list", [](bool value) {
m_type == InstalledModListType::OnlyErrors || auto size = value ? std::numeric_limits<size_t>::max() : 10;
m_type == InstalledModListType::OnlyOutdated; InstalledModListSource::get(InstalledModListType::All)->setPageSize(size);
InstalledModListSource::get(InstalledModListType::OnlyErrors)->setPageSize(size);
// Updates is technically a server mod list :-) So I left it out here
});
} }

View file

@ -62,10 +62,8 @@ std::optional<size_t> ModListSource::getItemCount() const {
return m_cachedItemCount; return m_cachedItemCount;
} }
void ModListSource::setPageSize(size_t size) { void ModListSource::setPageSize(size_t size) {
if (m_pageSize != size) { m_pageSize = size;
m_pageSize = size; this->reset();
this->reset();
}
} }
void ModListSource::reset() { void ModListSource::reset() {

View file

@ -77,8 +77,6 @@ public:
std::optional<size_t> getPageCount() const; std::optional<size_t> getPageCount() const;
std::optional<size_t> getItemCount() const; std::optional<size_t> getItemCount() const;
void setPageSize(size_t size); void setPageSize(size_t size);
virtual bool isLocalModsOnly() const = 0;
static void clearAllCaches(); static void clearAllCaches();
}; };
@ -141,8 +139,6 @@ public:
InstalledModsQuery const& getQuery() const; InstalledModsQuery const& getQuery() const;
InvalidateQueryAfter<InstalledModsQuery> getQueryMut(); InvalidateQueryAfter<InstalledModsQuery> getQueryMut();
bool isDefaultQuery() const override; bool isDefaultQuery() const override;
bool isLocalModsOnly() const override;
}; };
enum class ServerModListType { enum class ServerModListType {
@ -175,8 +171,6 @@ public:
bool isDefaultQuery() const override; bool isDefaultQuery() const override;
server::ModsQuery createDefaultQuery() const; server::ModsQuery createDefaultQuery() const;
ServerModListType getType() const; ServerModListType getType() const;
bool isLocalModsOnly() const override;
}; };
class ModPackListSource : public ModListSource { class ModPackListSource : public ModListSource {
@ -193,8 +187,6 @@ public:
std::unordered_set<std::string> getModTags() const override; std::unordered_set<std::string> getModTags() const override;
void setModTags(std::unordered_set<std::string> const& tags) override; void setModTags(std::unordered_set<std::string> const& tags) override;
bool isDefaultQuery() const override; bool isDefaultQuery() const override;
bool isLocalModsOnly() const override;
}; };
bool weightedFuzzyMatch(std::string const& str, std::string const& kw, double weight, double& out); bool weightedFuzzyMatch(std::string const& str, std::string const& kw, double weight, double& out);

View file

@ -21,7 +21,3 @@ void ModPackListSource::setModTags(std::unordered_set<std::string> const& set) {
bool ModPackListSource::isDefaultQuery() const { bool ModPackListSource::isDefaultQuery() const {
return true; return true;
} }
bool ModPackListSource::isLocalModsOnly() const {
return false;
}

View file

@ -115,7 +115,3 @@ server::ModsQuery ServerModListSource::createDefaultQuery() const {
ServerModListType ServerModListSource::getType() const { ServerModListType ServerModListSource::getType() const {
return m_type; return m_type;
} }
bool ServerModListSource::isLocalModsOnly() const {
return false;
}