|
2 | 2 | #include "../../utils.hpp" |
3 | 3 |
|
4 | 4 | // TODO: add "Reports" and maybe a star icon to indicate featured? |
5 | | -bool FiltersPopup::init(std::unordered_set<std::string> tags, std::unordered_set<std::string> selectedTags, int role, bool uploading, std::function<void(std::unordered_set<std::string>, bool, bool)> callback) { |
| 5 | +bool FiltersPopup::init(std::unordered_set<std::string> tags, std::unordered_set<std::string> selectedTags, bool selectedFeatured, int role, bool uploading, std::function<void(std::unordered_set<std::string>, bool, bool, bool)> callback) { |
6 | 6 | if (!Popup::init(350.f, 170.f)) return false; |
7 | 7 | m_callback = callback; |
8 | 8 | m_selectedTags = selectedTags; |
9 | 9 |
|
10 | | - this->setTitle((uploading) ? "Set Tags" : "Search Filters"); |
| 10 | + this->setTitle((uploading && role == 0) ? "Set Tags" : "Search Filters"); |
11 | 11 |
|
12 | 12 | // loader/src/ui/mods/popups/FiltersPopup.cpp |
13 | 13 | auto tagsContainer = CCNode::create(); |
@@ -39,15 +39,20 @@ bool FiltersPopup::init(std::unordered_set<std::string> tags, std::unordered_set |
39 | 39 |
|
40 | 40 | auto tagsTitle = CCLabelBMFont::create("Tags", "bigFont.fnt"); |
41 | 41 | tagsTitleMenu->addChild(tagsTitle); |
42 | | - |
43 | 42 | tagsTitleMenu->addChild(SpacerNode::create()); |
44 | | - |
45 | | - auto resetSpr = CCSprite::createWithSpriteFrameName("GJ_trashBtn_001.png"); |
46 | | - auto resetBtn = CCMenuItemSpriteExtra::create( |
47 | | - resetSpr, this, menu_selector(FiltersPopup::onResetBtn) |
48 | | - ); |
49 | | - tagsTitleMenu->addChild(resetBtn); |
50 | | - |
| 43 | + if (!uploading) { |
| 44 | + Build<CCMenuItemToggler>::createToggle( |
| 45 | + Build<CCSprite>::createSpriteName("GJ_starsIcon_001.png").scale(1.25f).collect(), |
| 46 | + Build<CCSprite>::createSpriteName("GJ_starsIcon_gray_001.png").scale(1.25f).collect(), |
| 47 | + [this](CCMenuItemToggler* toggler){ |
| 48 | + m_selectedFeatured = toggler->isOn(); |
| 49 | + } |
| 50 | + ).parent(tagsTitleMenu).toggle(!selectedFeatured); |
| 51 | + } |
| 52 | + Build<CCSprite>::createSpriteName("GJ_trashBtn_001.png").intoMenuItem([this]() { |
| 53 | + m_selectedTags.clear(); |
| 54 | + this->updateTags(); |
| 55 | + }).parent(tagsTitleMenu); |
51 | 56 | tagsTitleMenu->setLayout( |
52 | 57 | RowLayout::create() |
53 | 58 | ->setDefaultScaleLimits(.1f, .4f) |
@@ -146,20 +151,16 @@ void FiltersPopup::onSelectTag(CCObject* sender) { |
146 | 151 | } |
147 | 152 | this->updateTags(); |
148 | 153 | } |
149 | | -void FiltersPopup::onResetBtn(CCObject*) { |
150 | | - m_selectedTags.clear(); |
151 | | - this->updateTags(); |
152 | | -} |
153 | 154 |
|
154 | 155 | void FiltersPopup::onClose(CCObject* sender) { |
155 | 156 | if (m_pendingBtn) { |
156 | 157 | if (m_reportsBtn) { |
157 | | - m_callback(m_selectedTags, m_pendingBtn->isToggled(), m_reportsBtn->isToggled()); |
| 158 | + m_callback(m_selectedTags, m_selectedFeatured, m_pendingBtn->isToggled(), m_reportsBtn->isToggled()); |
158 | 159 | } else { |
159 | | - m_callback(m_selectedTags, m_pendingBtn->isToggled(), false); |
| 160 | + m_callback(m_selectedTags, m_selectedFeatured, m_pendingBtn->isToggled(), false); |
160 | 161 | } |
161 | 162 | } else { |
162 | | - m_callback(m_selectedTags, false, false); |
| 163 | + m_callback(m_selectedTags, m_selectedFeatured, false, false); |
163 | 164 | } |
164 | 165 | Popup::onClose(sender); |
165 | 166 | } |
|
0 commit comments