Skip to content

Commit

Permalink
FakeLevelPagesScroll?
Browse files Browse the repository at this point in the history
  • Loading branch information
user95401 committed Apr 18, 2024
1 parent 5e3c9fd commit ede4743
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 5 deletions.
4 changes: 4 additions & 0 deletions _Headers/Header1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#include <iostream>
#include <string>
#include "SimpleIni.h"

inline int cmp_amount = 23;
inline int start_from = 1;

std::string FilePathFromModFolder(std::string fname);
GJGameLevel* processOutLevelByConfig(int id, GJGameLevel* pGJGameLevel);
std::string saveToMainLevel(int id, GJGameLevel* pGJGameLevel);
Expand Down
187 changes: 187 additions & 0 deletions _Src/FakeLevelPagesScroll.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
#include <Geode/Geode.hpp>
using namespace geode::prelude;

#include "Header1.hpp"

#include <Geode/modify/LevelSelectLayer.hpp>
class $modify(LevelSelectLayerExt, LevelSelectLayer) {
BoomScrollLayer* m_LevelsScrollLayer;
CCSprite* m_BackgroundSprite;
GJGroundLayer* m_GJGroundLayer;
CCMenu* m_shitcodingmenu;
CCPoint m_shitcodingmenuPoint;
CCMenu* m_shitdotingmenu;
CCMenuItem* m_rightTouchZone;
CCMenuItem* m_leftTouchZone;
int m_page;
void updSchedule(float) {
//ground color
/*this->m_fields->m_GJGroundLayer->updateGround01Color(ccColor3B(
this->m_fields->m_BackgroundSprite->getColor().r,
this->m_fields->m_BackgroundSprite->getColor().g,
this->m_fields->m_BackgroundSprite->getColor().b
));*/
}
void theSchedule(float) {
//color
/*auto pageColor = this->colorForPage(m_fields->m_page);
this->m_fields->m_BackgroundSprite->runAction(CCTintTo::create(0.050f, pageColor.r, pageColor.g, pageColor.b));
*///animate
if (this->m_fields->m_shitcodingmenu->getPosition() != this->m_fields->m_shitcodingmenuPoint) {
if (!this->m_fields->m_shitcodingmenu->getActionByTag(m_fields->m_page)) {
auto moveTo = CCEaseElasticOut::create(CCMoveTo::create(0.5f, this->m_fields->m_shitcodingmenuPoint), 0.6f);
moveTo->setTag(m_fields->m_page);
this->m_fields->m_shitcodingmenu->stopAllActions();
this->m_fields->m_shitcodingmenu->runAction(moveTo);
}
}
//dots colorize
if (this->m_fields->m_shitdotingmenu) {
for (int i = 0; i < this->m_fields->m_shitdotingmenu->getChildrenCount(); i++) {
CCNode* thisdot = this->m_fields->m_shitdotingmenu->getChildByTag(i);
if (thisdot->getTag() == this->m_fields->m_page) thisdot->runAction(CCTintTo::create(0.1f, 160, 160, 160));
else thisdot->runAction(CCTintTo::create(0.1f, 255, 255, 255));
}
};
//wah
{
m_fields->m_LevelsScrollLayer->instantMoveToPage(m_fields->m_page);
}
}
void controlAndAddStuff() {
//hide away this unexplored thing
this->m_fields->m_LevelsScrollLayer->setVisible(0);
this->m_fields->m_LevelsScrollLayer->setTouchEnabled(0);
//add updates
this->schedule(schedule_selector(LevelSelectLayerExt::updSchedule));
this->schedule(schedule_selector(LevelSelectLayerExt::theSchedule), 0.1f);
//a
//levels
this->m_fields->m_shitcodingmenu = CCMenu::create();
this->m_fields->m_shitcodingmenu->setPosition(CCPointZero);
this->m_fields->m_shitcodingmenu->setAnchorPoint(CCPointZero);
this->addChild(this->m_fields->m_shitcodingmenu);
//add levels
for (int i = start_from; i <= cmp_amount; i++) {
auto lvl = GameLevelManager::sharedState()->getMainLevel(i, 0);
auto page = LevelPage::create(lvl);
page->updateDynamicPage(lvl);
this->m_fields->m_shitcodingmenu->addChild(page, i, i);
}
//Layout
this->m_fields->m_shitcodingmenu->setLayout(
ColumnLayout::create()
->setAxisAlignment(AxisAlignment::Start)
->setCrossAxisAlignment(AxisAlignment::Start)
->setCrossAxisLineAlignment(AxisAlignment::Start)
->setGrowCrossAxis(true)
->setCrossAxisReverse(true)
->setGap(0.f)
);
this->m_fields->m_shitcodingmenu->updateLayout();
//scroll to initpage
instantMoveToCurrentPage();
//nav dots
auto shitdotingmenu = CCMenu::create();
this->m_fields->m_shitdotingmenu = shitdotingmenu;
shitdotingmenu->setPosition(CCPointZero);
this->addChild(shitdotingmenu);
//add pages
for (int i = 0; i < this->m_fields->m_shitcodingmenu->getChildrenCount(); i++) {
auto dot = CCSprite::createWithSpriteFrameName("uiDot_001.png");
dot->setScale(1.15f);
CCMenuItemSpriteExtra* CCMenuItemSpriteExtra_ = CCMenuItemSpriteExtra::create(
dot, this, menu_selector(LevelSelectLayerExt::onDot)
);
CCMenuItemSpriteExtra_->setSizeMult(1.5f);
shitdotingmenu->addChild(CCMenuItemSpriteExtra_, 0, i);
}
shitdotingmenu->alignItemsHorizontallyWithPadding(6.0f);
shitdotingmenu->setPosition(
CCPoint(CCDirector::get()->getWinSize().width * 0.5f, CCDirector::get()->getScreenBottom() + 16.000f)
);

}
void mainSetup(int p0) {
m_fields->m_page = p0;
//getNodes
CCObject* obj;
CCARRAY_FOREACH(this->getChildren(), obj)
{
auto node = dynamic_cast<CCNode*>(obj);
if (node) {
auto list = typeinfo_cast<BoomScrollLayer*>(obj);
if (list) this->m_fields->m_LevelsScrollLayer = list;
auto pGJGroundLayer = typeinfo_cast<GJGroundLayer*>(obj);
if (pGJGroundLayer) this->m_fields->m_GJGroundLayer = pGJGroundLayer;
auto sprite = typeinfo_cast<CCSprite*>(obj);
if (sprite) {
if(framePath(sprite).find("GJ_gradientBG") != std::string::npos) this->m_fields->m_BackgroundSprite = sprite;
}
}
}
controlAndAddStuff();
}
void instantMoveToCurrentPage() {
float newPointX = 0.f;
for (int i = 0; i < m_fields->m_page; i++) {
newPointX = newPointX - CCDirector::get()->getScreenRight();
};
m_fields->m_shitcodingmenuPoint.x = newPointX;
m_fields->m_shitcodingmenu->setPositionX(newPointX);
}
void onDot(cocos2d::CCObject* sender) {
bool isPrev = m_fields->m_page < sender->getTag();
m_fields->m_page = sender->getTag();
instantMoveToCurrentPage();
}
void onNext(cocos2d::CCObject* sender) {
++m_fields->m_page;
if (m_fields->m_page >= m_fields->m_shitcodingmenu->getChildrenCount()) {
m_fields->m_page = 0;
m_fields->m_shitcodingmenuPoint.x = 0;
m_fields->m_shitcodingmenu->setPositionX(0 - CCDirector::get()->getScreenRight());
return;
};
auto newPointX = this->m_fields->m_shitcodingmenuPoint.x - CCDirector::get()->getScreenRight();
if (sender) {
m_fields->m_shitcodingmenuPoint.x = (newPointX);
}
else {
m_fields->m_shitcodingmenu->setPositionX(newPointX);
m_fields->m_shitcodingmenuPoint.x = (newPointX);
}
};
void onPrev(cocos2d::CCObject* sender) {
--m_fields->m_page;
if (m_fields->m_page < 0) {
m_fields->m_page = m_fields->m_shitcodingmenu->getChildrenCount() - 1;
//get page point
float newPointX = 0.f;
for (int i = 0; i < m_fields->m_page; i++) {
newPointX = newPointX - CCDirector::get()->getScreenRight();
};
m_fields->m_shitcodingmenuPoint.x = newPointX;
m_fields->m_shitcodingmenu->setPositionX(newPointX + CCDirector::get()->getScreenRight());
return;
};
auto newPointX = this->m_fields->m_shitcodingmenuPoint.x + CCDirector::get()->getScreenRight();
if (sender) {
m_fields->m_shitcodingmenuPoint.x = (newPointX);
}
else {
m_fields->m_shitcodingmenu->setPositionX(newPointX);
m_fields->m_shitcodingmenuPoint.x = (newPointX);
}
};
virtual void keyDown(cocos2d::enumKeyCodes p0) {
if (p0 == KEY_Left and m_fields->m_shitcodingmenu->numberOfRunningActions() == 0) onPrev(this);
if (p0 == KEY_Right and m_fields->m_shitcodingmenu->numberOfRunningActions() == 0) onNext(this);
return LevelSelectLayer::keyDown(p0);
}
static LevelSelectLayer* create(int p0) {
auto rtn = LevelSelectLayer::create(p0);
((LevelSelectLayerExt*)rtn)->mainSetup(p0);
return rtn;
}
};
3 changes: 0 additions & 3 deletions _Src/controllers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ std::vector<unsigned char> intToBytes(int value) {

void UpdatePagesSetup() {

int cmp_amount = 23;
int start_from = 1;

std::string MainSection = fmt::format("UpdatePagesSetup");
std::string IniPath = FilePathFromModFolder("_PagesSetupPatch.ini");

Expand Down
4 changes: 2 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"geode": "2.0.0-beta.23",
"geode": "2.0.0-beta.24",
"gd": {
"win": "2.204",
"android": "*"
},
"version": "v6.0.0-beta.5",
"version": "v6.0.0-beta.6",
"id": "user95401.mainlevelseditor",
"name": "Main Levels Editor",
"developer": "user95401",
Expand Down

0 comments on commit ede4743

Please sign in to comment.