mirror of
https://github.com/geode-sdk/geode.git
synced 2025-04-12 21:14:41 -04:00
use setidpopup for page changes
This commit is contained in:
parent
bb64bf8bc0
commit
25fe269c68
2 changed files with 7 additions and 12 deletions
loader/src/ui/mods
|
@ -531,15 +531,11 @@ void ModsLayer::keyBackClicked() {
|
|||
this->onBack(nullptr);
|
||||
}
|
||||
|
||||
void ModsLayer::setTextPopupClosed(SetTextPopup* popup, gd::string value) {
|
||||
void ModsLayer::setIDPopupClosed(SetIDPopup* popup, int num) {
|
||||
if (popup->getID() == "go-to-page"_spr) {
|
||||
if (auto res = numFromString<size_t>(value)) {
|
||||
size_t num = res.unwrap();
|
||||
// The page indices are 0-based but people think in 1-based
|
||||
if (num > 0) num -= 1;
|
||||
if (m_currentSource) {
|
||||
m_lists.at(m_currentSource)->gotoPage(num);
|
||||
}
|
||||
if (num > 0) num -= 1;
|
||||
if (m_currentSource) {
|
||||
m_lists.at(m_currentSource)->gotoPage(num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -581,9 +577,8 @@ void ModsLayer::onBack(CCObject*) {
|
|||
ModListSource::clearAllCaches();
|
||||
}
|
||||
void ModsLayer::onGoToPage(CCObject*) {
|
||||
auto popup = SetTextPopup::create("", "Page", 5, "Go to Page", "OK", true, 60.f);
|
||||
auto popup = SetIDPopup::create(m_lists.at(m_currentSource)->getPage() + 1, 1, m_currentSource->getPageCount().value(), "Go to Page", "Go", true, 1, 60.f, false, false);
|
||||
popup->m_delegate = this;
|
||||
popup->m_input->m_allowedChars = getCommonFilterAllowedChars(CommonFilter::Uint);
|
||||
popup->setID("go-to-page"_spr);
|
||||
popup->show();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
static ModsStatusNode* create();
|
||||
};
|
||||
|
||||
class ModsLayer : public CCLayer, public SetTextPopupDelegate {
|
||||
class ModsLayer : public CCLayer, public SetIDPopupDelegate {
|
||||
protected:
|
||||
CCNode* m_frame;
|
||||
std::vector<CCMenuItemSpriteExtra*> m_tabs;
|
||||
|
@ -56,7 +56,7 @@ protected:
|
|||
bool init();
|
||||
|
||||
void keyBackClicked() override;
|
||||
void setTextPopupClosed(SetTextPopup*, gd::string value) override;
|
||||
void setIDPopupClosed(SetIDPopup*, int value) override;
|
||||
|
||||
void onTab(CCObject* sender);
|
||||
void onBigView(CCObject*);
|
||||
|
|
Loading…
Add table
Reference in a new issue