Skip to content

Conversation

Chs000-00
Copy link

No description provided.

Fix no return statement
@Chs000-00 Chs000-00 requested review from Kingminer7 and matcool March 6, 2025 18:48
Copy link
Member

@dankmeme01 dankmeme01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely needs more polishing, also not entirely sure what to do with the searching through the docs page, not saying to remove it but I personally don't see the idea as very useful

Comment on lines +32 to +36
static MyVeryOriginalLayer* scene() {
auto layer = MyVeryOriginalLayer::create();
switchToScene(layer);
return layer;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

making a function that returns the layer yet switches to it is misleading, this would be better if it just created a scene with the layer and returned it

additionally, switchToScene uses CCDirector::replaceScene so I would suggest to just manually call pushScene

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heck i would recommend just the geode utils geode::cocos::switchToScene i think? needs a double check
we are in 2025 imo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this function i mean, just call switchToScene where you need it, never liked ::scene funcs anyway

#include <Geode/ui/General.hpp>
bool init() override {
log::info("Hi from my very original layer");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should still call original here

}

void onBack(CCObject* sender) {
CCDirector::get()->replaceScene(CCTransitionFade::create(0.5, MenuLayer::scene()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a popScene

Comment on lines +116 to +167
class MyVeryOriginalLayer : public CCLayer {
protected:
bool init() override {
log::info("Hi from my very original layer");
// Create a new menu. UI elemnts should be added to here!
menu = CCMenu::create();
// Add side art to the layer
addSideArt(this, SideArt::All, SideArtStyle::Layer);
// And a background to the layer
auto background = createLayerBG();
background->setID("background");
this->addChild(background);
return true;
}
// This function is called when the escape key is pressed!
void keyBackClicked() override {
this->onBack(nullptr);
}
public:
static MyVeryOriginalLayer* create() {
auto ret = new MyVeryOriginalLayer;
if (ret->init()) {
ret->autorelease();
return ret;
}
CC_SAFE_DELETE(ret);
return nullptr;
}
static MyVeryOriginalLayer* MyVeryOriginalLayer::scene() {
auto layer = MyVeryOriginalLayer::create();
switchToScene(layer);
return layer;
}
void onBack(CCObject* sender) {
CCDirector::get()->replaceScene(CCTransitionFade::create(0.5, MenuLayer::scene()));
}
}
class $modify(MenuLayer) {
void onMoreGames(CCObject* target) {
MyVeryOriginalLayer::scene();
}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the same things as before, should use geode:: when calling global geode functions, call original CCLayer::init, cc safe delete, scene and onBack fixes

return nullptr;
}
static MyVeryOriginalLayer* MyVeryOriginalLayer::scene() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suspicious extra qualification before the function name

Comment on lines +114 to +131
```cpp
// This is where geode is located!
auto geodeDir = dirs::getGeodeDir();

// This is where geodes resources are stored!
auto geodeResourcesDir = dirs::getGeodeResourcesDir();

// This is where geodes saves its files!
auto geodeSaveDir = dirs::getGeodeSaveDir();

// This is where mod's save files are!
auto modSaveDir = dirs::getModsSaveDir();

// This is where GD saves its files!
auto saveDir = dirs::getSaveDir();

// Other directories also exist
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments are not really useful because you can already make these conclusions from the function names. it would be much more useful if there were examples of paths, "This is where geode is located" can be interpreted as either the geode/ subfolder or as the folder where Geode.dll is located.

}
```
This code will create a new layer called MyVeryOriginalLayer. When we start up the game, we will not see the layer as we do transition to it. Calling `MyVeryOriginalLayer::create()` will not transition to the layer, as it only creates it, not replaces the current layer. To be able to transition to the layer, we can use `switchToScene(layer)`. We can create a static function to easily create and switch to the scene:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not replace

Comment on lines +32 to +36
static MyVeryOriginalLayer* scene() {
auto layer = MyVeryOriginalLayer::create();
switchToScene(layer);
return layer;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heck i would recommend just the geode utils geode::cocos::switchToScene i think? needs a double check
we are in 2025 imo

Comment on lines +32 to +36
static MyVeryOriginalLayer* scene() {
auto layer = MyVeryOriginalLayer::create();
switchToScene(layer);
return layer;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this function i mean, just call switchToScene where you need it, never liked ::scene funcs anyway

auto backBtn = CCMenuItemSpriteExtra::create(
CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png"),
this,
menu_selector(MyVeryOriginalLayer::onBack)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might alao recommend just using CCMenuItemExt::createSpriteExtra, its important to kill off old habits slowly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants