Skip to content

Commit 3d073b0

Browse files
committed
if this still crashes windows and ios i will become jacob hill and scream
1 parent e7979e0 commit 3d073b0

File tree

4 files changed

+47
-45
lines changed

4 files changed

+47
-45
lines changed

src/MenuLayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class $modify(MenuLayerMLHook, MenuLayer) {
4949
void onHoldSongButton(CCObject*) { SongControl::holdSong(); }
5050
void onPreviousButton(CCObject*) { SongControl::previousSong(); }
5151
void onAddToPlylstBtn(CCObject*) { SongControl::addSongToPlaylist(SongManager::get().getCurrentSong()); }
52-
void onSongListButton(CCObject*) { if (SongListLayer* sll = SongListLayer::create()) sll->showLayer(true); }
52+
void onSongListButton(CCObject*) { SongListLayer::create("GJ_square05.png")->show(); }
5353
void onControlsButton(CCObject*) {
5454
if (Utils::getString("buttonMode") == "Classic") return;
5555
if (CCScene::get()->getChildByType<SongControlMenu>(0)) return;

src/ui/SongControlMenu.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
#include <Geode/ui/GeodeUI.hpp>
12
#include "SongControlMenu.hpp"
2-
#include "../SongControl.hpp"
33
#include "SongListLayer.hpp"
44
#include "../Utils.hpp"
5-
#include <Geode/ui/GeodeUI.hpp>
5+
#include "../SongControl.hpp"
66

77
#define REST_OF_THE_OWL this->m_songControlsMenu, this
88

@@ -146,10 +146,8 @@ void SongControlMenu::onPreviousButton(CCObject*) {
146146
SongControlMenu::updateCurrentLabel();
147147
}
148148
void SongControlMenu::onPlaylistButton(CCObject*) {
149-
SongListLayer* sll = SongListLayer::create();
150-
if (!sll) return;
151149
SongControlMenu::onClose(nullptr);
152-
sll->showLayer(true);
150+
SongListLayer::create("GJ_square05.png")->show();
153151
}
154152
void SongControlMenu::onAddToPlylstBtn(CCObject*) {
155153
SongManager& songManager = SongManager::get();

src/ui/SongListLayer.cpp

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,29 @@
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

143148
void SongListLayer::onSettingsButton(CCObject*) {

src/ui/SongListLayer.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#pragma once
22

3-
class SongListLayer : GJDropDownLayer {
3+
class SongListLayer final : public geode::Popup<const std::string&> {
44
public:
5-
static SongListLayer* create();
6-
virtual void customSetup();
7-
virtual void showLayer(const bool instant);
5+
static SongListLayer* create(const std::string&);
6+
bool setup(const std::string&) override;
87
void onSettingsButton(CCObject*);
98
};

0 commit comments

Comments
 (0)