44#include " ../Utils.hpp"
55#include " ../SongManager.hpp"
66
7- SongListLayer* SongListLayer::create () {
7+ SongListLayer* SongListLayer::create (const std::string& id ) {
88 auto * ret = new SongListLayer ();
9- if (ret->init ( " Menu Loop Randomizer - Your Songs " )) {
9+ if (ret->initAnchored ( 420 . f , 300 . f , id )) {
1010 ret->autorelease ();
1111 return ret;
1212 }
1313 delete ret;
1414 return nullptr ;
1515}
1616
17- void SongListLayer::customSetup () {
17+ bool SongListLayer::setup (const std::string&) {
18+ this ->m_noElasticity = true ;
19+ this ->setTitle (" Menu Loop Randomizer - Your Songs" );
20+ this ->m_title ->setID (" song-list-title" _spr);
21+
22+ const cocos2d::CCSize layerSize = this ->m_mainLayer ->getContentSize ();
23+ cocos2d::extension::CCScale9Sprite* background = this ->m_bgSprite ;
24+ CCLayer* mainLayer = this ->m_mainLayer ;
25+ mainLayer->setID (" main-layer" _spr);
26+
27+ background->initWithFile (" GJ_square05.png" );
28+ background->setContentSize (layerSize);
29+
1830 cocos2d::CCMenu* infoMenu = cocos2d::CCMenu::create ();
1931 infoMenu->setLayout (
2032 geode::RowLayout::create ()
@@ -35,7 +47,7 @@ void SongListLayer::customSetup() {
3547 1 .f
3648 );
3749 infoMenu->addChildAtPosition (infoBtn, geode::Anchor::Center);
38- infoMenu->setPosition ({437 . f , 282 .f });
50+ infoMenu->setPosition ({layerSize - 3 .f });
3951 infoMenu->setID (" songlayerlist-info-menu" _spr);
4052 infoBtn->setID (" songlayerlist-info-button" _spr);
4153 this ->m_mainLayer ->addChild (infoMenu);
@@ -51,7 +63,7 @@ void SongListLayer::customSetup() {
5163 settingsMenu->setID (" songlayerlist-controls-menu" _spr);
5264 Utils::addButton (" settings" , menu_selector (SongListLayer::onSettingsButton), settingsMenu, this );
5365 if (CCMenuItemSpriteExtra* button = settingsMenu->getChildByType <CCMenuItemSpriteExtra>(0 )) button->setPosition (settingsMenu->getContentSize () / 2 .f );
54- settingsMenu->setPosition ({75 .f , 282 . f });
66+ settingsMenu->setPosition ({400 .f , this -> m_title -> getPositionY () });
5567 settingsMenu->setScale (.825f );
5668 this ->m_mainLayer ->addChild (settingsMenu);
5769
@@ -92,52 +104,45 @@ void SongListLayer::customSetup() {
92104 scrollLayer->m_contentLayer ->updateLayout ();
93105 scrollLayer->scrollToTop ();
94106
95- m_listLayer->addChild (scrollLayer);
96- }
97-
98- void SongListLayer::showLayer (const bool instant) {
99- cocos2d::CCScene* scene = cocos2d::CCScene::get ();
100- if (!scene) return ;
101- scene->addChild (this );
102- this ->m_mainLayer ->setPositionY (0 .f );
103- this ->setVisible (true );
104- this ->setOpacity (128 );
105-
106- this ->setID (" SongListLayer" _spr);
107- m_listLayer->setID (" list-of-songs-layer" _spr);
108-
109- CCNode* titleLabel = m_listLayer->getChildByID (" title" );
110- if (!titleLabel) return ;
111-
112- SongManager& songManager = SongManager::get ();
107+ scrollLayer->setID (" list-of-songs" _spr);
108+ scrollLayer->ignoreAnchorPointForPosition (false );
109+ this ->m_mainLayer ->addChildAtPosition (scrollLayer, geode::Anchor::Center);
113110
114111 const std::string& playlistFileName = songManager.getPlaylistIsEmpty () ? " None" : songManager.getPlaylistFileName ();
115112 cocos2d::CCLabelBMFont* currentPlaylistLabel = cocos2d::CCLabelBMFont::create (fmt::format (" Playlist: {}" , playlistFileName).c_str (), " bigFont.fnt" );
116- currentPlaylistLabel->setPosition ({83 .5f , 0 .f });
117113 currentPlaylistLabel->limitLabelWidth (279 .f * .45f , 1 .f , .0001f );
118- currentPlaylistLabel->setZOrder (titleLabel ->getZOrder ());
114+ currentPlaylistLabel->setZOrder (this -> m_title ->getZOrder ());
119115
120116 const std::string& loadPlaylistFileInstead = Utils::getBool (" loadPlaylistFile" ) ? " ON" : " OFF" ;
121117 cocos2d::CCLabelBMFont* loadPlaylistFileLabel = cocos2d::CCLabelBMFont::create (fmt::format (" Load Playlist File: {}" , loadPlaylistFileInstead).c_str (), " bigFont.fnt" );
122- loadPlaylistFileLabel->setPosition ({83 .5f , -11 .f });
123118 loadPlaylistFileLabel->limitLabelWidth (279 .f * .45f , 1 .f , .0001f );
124- loadPlaylistFileLabel->setZOrder (titleLabel ->getZOrder ());
119+ loadPlaylistFileLabel->setZOrder (this -> m_title ->getZOrder ());
125120
126121 const std::string& isConstantShuffleMode = songManager.getConstantShuffleMode () ? " ON" : " OFF" ;
127122 cocos2d::CCLabelBMFont* constantShuffleModeLabel = cocos2d::CCLabelBMFont::create (fmt::format (" Constant Shuffle Mode: {}" , isConstantShuffleMode).c_str (), " bigFont.fnt" );
128- constantShuffleModeLabel->setPosition ({272 .5f , 0 .f });
129123 constantShuffleModeLabel->limitLabelWidth (279 .f * .45f , 1 .f , .0001f );
130- constantShuffleModeLabel->setZOrder (titleLabel ->getZOrder ());
124+ constantShuffleModeLabel->setZOrder (this -> m_title ->getZOrder ());
131125
132126 cocos2d::CCLabelBMFont* platformLabel = cocos2d::CCLabelBMFont::create (fmt::format (" Platform: {}" , Utils::getPlatform ()).c_str (), " bigFont.fnt" );
133- platformLabel->setPosition ({272 .5f , -11 .f });
134127 platformLabel->limitLabelWidth (279 .f * .45f , 1 .f , .0001f );
135- platformLabel->setZOrder (titleLabel->getZOrder ());
128+ platformLabel->setZOrder (this ->m_title ->getZOrder ());
129+
130+ currentPlaylistLabel->setID (" current-playlist-label" _spr);
131+ loadPlaylistFileLabel->setID (" load-playlist-file-label" _spr);
132+ constantShuffleModeLabel->setID (" constant-shuffle-mode-label" _spr);
133+ platformLabel->setID (" platform-label" _spr);
134+
135+ currentPlaylistLabel->ignoreAnchorPointForPosition (false );
136+ loadPlaylistFileLabel->ignoreAnchorPointForPosition (false );
137+ constantShuffleModeLabel->ignoreAnchorPointForPosition (false );
138+ platformLabel->ignoreAnchorPointForPosition (false );
139+
140+ this ->m_mainLayer ->addChildAtPosition (currentPlaylistLabel, geode::Anchor::BottomLeft, {100 .5f , 15 .f });
141+ this ->m_mainLayer ->addChildAtPosition (loadPlaylistFileLabel, geode::Anchor::BottomLeft, {100 .5f , 26 .f });
142+ this ->m_mainLayer ->addChildAtPosition (constantShuffleModeLabel, geode::Anchor::BottomLeft, {320 .5f , 15 .f });
143+ this ->m_mainLayer ->addChildAtPosition (platformLabel, geode::Anchor::BottomLeft, {320 .5f , 26 .f });
136144
137- m_listLayer->addChild (currentPlaylistLabel);
138- m_listLayer->addChild (loadPlaylistFileLabel);
139- m_listLayer->addChild (constantShuffleModeLabel);
140- m_listLayer->addChild (platformLabel);
145+ return true ;
141146}
142147
143148void SongListLayer::onSettingsButton (CCObject*) {
0 commit comments