Skip to content

Commit 7b14240

Browse files
committed
abridged controls menu
1 parent f36bd23 commit 7b14240

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

src/ui/SongListLayer.cpp

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "SongListLayer.hpp"
33
#include "MLRSongCell.hpp"
44
#include "../Utils.hpp"
5+
#include "../SongControl.hpp"
56
#include "../SongManager.hpp"
67

78
SongListLayer* SongListLayer::create(const std::string& id) {
@@ -24,7 +25,7 @@ bool SongListLayer::setup(const std::string&) {
2425
CCLayer* mainLayer = this->m_mainLayer;
2526
mainLayer->setID("main-layer"_spr);
2627

27-
background->initWithFile("GJ_square05.png");
28+
background->initWithFile("GJ_square01.png");
2829
background->setContentSize(layerSize);
2930

3031
cocos2d::CCMenu* infoMenu = cocos2d::CCMenu::create();
@@ -60,10 +61,10 @@ bool SongListLayer::setup(const std::string&) {
6061
->setGap(.0f)
6162
);
6263
settingsMenu->setContentSize({24.f, 23.f});
63-
settingsMenu->setID("songlayerlist-controls-menu"_spr);
64+
settingsMenu->setID("songlayerlist-settings-menu"_spr);
6465
Utils::addButton("settings", menu_selector(SongListLayer::onSettingsButton), settingsMenu, this);
6566
if (CCMenuItemSpriteExtra* button = settingsMenu->getChildByType<CCMenuItemSpriteExtra>(0)) button->setPosition(settingsMenu->getContentSize() / 2.f);
66-
settingsMenu->setPosition({400.f, this->m_title->getPositionY()});
67+
settingsMenu->setPosition({395.f, this->m_title->getPositionY()});
6768
settingsMenu->setScale(.825f);
6869
this->m_mainLayer->addChild(settingsMenu);
6970

@@ -108,6 +109,12 @@ bool SongListLayer::setup(const std::string&) {
108109
scrollLayer->ignoreAnchorPointForPosition(false);
109110
this->m_mainLayer->addChildAtPosition(scrollLayer, geode::Anchor::Center);
110111

112+
geode::ListBorders* listBorder = geode::ListBorders::create();
113+
listBorder->setContentSize(scrollLayer->getContentSize());
114+
listBorder->ignoreAnchorPointForPosition(false);
115+
listBorder->setID("songs-list-border"_spr);
116+
this->m_mainLayer->addChildAtPosition(listBorder, geode::Anchor::Center);
117+
111118
constexpr float labelWidth = 280.f * .45f;
112119

113120
const std::string& playlistFileName = songManager.getPlaylistIsEmpty() ? "None" : songManager.getPlaylistFileName();
@@ -140,16 +147,42 @@ bool SongListLayer::setup(const std::string&) {
140147
constexpr float topRowYPos = 28.5f;
141148
constexpr float bottomRowYPos = 17.5f;
142149
constexpr float arbitraryPaddingValue = 10.f;
150+
constexpr float abridgedControlsMenuYPos = (bottomRowYPos + topRowYPos) / 2.f;
143151

144152
this->m_mainLayer->addChildAtPosition(currentPlaylistLabel, geode::Anchor::BottomLeft, {(layerSize.width - sllWidth) + arbitraryPaddingValue + offset, bottomRowYPos});
145153
this->m_mainLayer->addChildAtPosition(loadPlaylistFileLabel, geode::Anchor::BottomLeft, {(layerSize.width - sllWidth) + arbitraryPaddingValue + offset, topRowYPos});
146154
this->m_mainLayer->addChildAtPosition(constantShuffleModeLabel, geode::Anchor::BottomLeft, {sllWidth - offset - arbitraryPaddingValue, bottomRowYPos});
147155
this->m_mainLayer->addChildAtPosition(platformLabel, geode::Anchor::BottomLeft, {sllWidth - offset - arbitraryPaddingValue, topRowYPos});
148156

157+
cocos2d::CCMenu* abridgedControlsMenu = cocos2d::CCMenu::create();
158+
geode::Layout* layout = geode::RowLayout::create()->setDefaultScaleLimits(.0001f, 1.0f)->setGap(1.5f);
159+
abridgedControlsMenu->setLayout(layout);
160+
161+
Utils::addButton("shuffle", menu_selector(SongListLayer::onShuffleButton), abridgedControlsMenu, this);
162+
Utils::addButton("copy", menu_selector(SongListLayer::onCopyButton), abridgedControlsMenu, this);
163+
Utils::addButton("prev", menu_selector(SongListLayer::onPreviousButton), abridgedControlsMenu, this);
164+
165+
abridgedControlsMenu->setPosition({layerSize.width / 2.f, abridgedControlsMenuYPos});
166+
abridgedControlsMenu->ignoreAnchorPointForPosition(false);
167+
abridgedControlsMenu->setContentSize({80.f, 24.f});
168+
abridgedControlsMenu->updateLayout();
169+
abridgedControlsMenu->setID("abridged-controls-menu"_spr);
170+
this->m_mainLayer->addChild(abridgedControlsMenu);
171+
149172
return true;
150173
}
151174

152175
void SongListLayer::onSettingsButton(CCObject*) {
153176
this->keyBackClicked();
154177
geode::openSettingsPopup(geode::Mod::get());
178+
}
179+
180+
void SongListLayer::onShuffleButton(CCObject*) {
181+
SongControl::shuffleSong();
182+
}
183+
void SongListLayer::onCopyButton(CCObject*) {
184+
SongControl::copySong();
185+
}
186+
void SongListLayer::onPreviousButton(CCObject*) {
187+
SongControl::previousSong();
155188
}

src/ui/SongListLayer.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ class SongListLayer final : public geode::Popup<const std::string&> {
55
static SongListLayer* create(const std::string&);
66
bool setup(const std::string&) override;
77
void onSettingsButton(CCObject*);
8+
void onShuffleButton(CCObject*);
9+
void onCopyButton(CCObject*);
10+
void onFavoriteButton(CCObject*);
11+
void onPreviousButton(CCObject*);
812
};

0 commit comments

Comments
 (0)