add changelog tab

This commit is contained in:
HJfod 2022-09-30 00:30:25 +03:00
parent 0118945a39
commit 64674166e8
4 changed files with 62 additions and 0 deletions

View file

@ -27,6 +27,8 @@ namespace geode {
bool vertical
);
bool ccTouchBegan(cocos2d::CCTouch*, cocos2d::CCEvent*) override;
public:
static ScrollLayer* create(
cocos2d::CCRect const& rect,

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -182,6 +182,59 @@ bool ModInfoLayer::init(ModObject* obj, ModListView* list) {
);
m_mainLayer->addChild(detailsBar);
// changelog
if (m_info.m_changelog) {
auto changelog = MDTextArea::create(
m_info.m_changelog.value(),
{ 350.f, 137.5f }
);
changelog->setPosition(
-5000.f,
winSize.height / 2 - changelog->getScaledContentSize().height / 2 - 20.f
);
changelog->setVisible(false);
m_mainLayer->addChild(changelog);
auto changelogBtnOffSpr = ButtonSprite::create(
CCSprite::createWithSpriteFrameName("changelog.png"_spr),
0x20, true, 32.f, "GJ_button_01.png", 1.f
);
changelogBtnOffSpr->setScale(.65f);
auto changelogBtnOnSpr = ButtonSprite::create(
CCSprite::createWithSpriteFrameName("changelog.png"_spr),
0x20, true, 32.f, "GJ_button_02.png", 1.f
);
changelogBtnOnSpr->setScale(.65f);
auto changelogBtn = CCMenuItemToggler::create(
changelogBtnOffSpr,
changelogBtnOnSpr,
this,
makeMenuSelector([
this, winSize, details, detailsBar, changelog
](CCMenuItemToggler* toggle) {
details->setVisible(toggle->isToggled());
// as it turns out, cocos2d is stupid and still passes touch
// events to invisible nodes
details->setPositionX(toggle->isToggled() ?
winSize.width / 2 - details->getScaledContentSize().width / 2 :
-5000.f
);
changelog->setVisible(!toggle->isToggled());
// as it turns out, cocos2d is stupid and still passes touch
// events to invisible nodes
changelog->setPositionX(!toggle->isToggled() ?
winSize.width / 2 - changelog->getScaledContentSize().width / 2 :
-5000.f
);
})
);
changelogBtn->setPosition(-size.width / 2 + 21.5f, .0f);
m_buttonMenu->addChild(changelogBtn);
}
auto infoSpr = CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
infoSpr->setScale(.85f);

View file

@ -38,6 +38,13 @@ void ScrollLayer::enableScrollWheel(bool enable) {
m_scrollWheelEnabled = enable;
}
bool ScrollLayer::ccTouchBegan(CCTouch* touch, CCEvent* event) {
if (this->isVisible()) {
return CCScrollLayerExt::ccTouchBegan(touch, event);
}
return false;
}
ScrollLayer::ScrollLayer(
CCRect const& rect,
bool scrollWheelEnabled,