Skip to content

Commit b045f1b

Browse files
committed
change bg + small stuff
1 parent ec525bb commit b045f1b

File tree

2 files changed

+32
-46
lines changed

2 files changed

+32
-46
lines changed

src/layers/GYModTile.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ bool GYModTile::init(std::string modName, std::string modAuthor, std::string mod
4444

4545
auto modNameText = CCLabelBMFont::create(modName.c_str(), "bigFont.fnt");
4646
modNameText->setPosition({ this->getContentSize().width / 2, this->getContentSize().height - winSize.height * 0.05f });
47-
modNameText->setScale(0.5f);
47+
float maxWidth = this->getContentSize().width * 0.8f;
48+
float scale = (modNameText->getContentSize().width > maxWidth) ? (this->getContentSize().width * 0.7f) / modNameText->getContentSize().width : 0.5f;
49+
modNameText->setScale(std::min(scale, 0.5f));
4850
bg->addChild(modNameText);
4951

5052
auto modAuthorText = CCLabelBMFont::create(fmt::format("By {}", modAuthor).c_str(), "goldFont.fnt");
5153
modAuthorText->setPosition({ this->getContentSize().width / 2, this->getContentSize().height - winSize.height * 0.35f });
52-
modAuthorText->setScale(0.5f);
54+
scale = (modAuthorText->getContentSize().width > maxWidth) ? (this->getContentSize().width * 0.7f) / modAuthorText->getContentSize().width : 0.5f;
55+
modAuthorText->setScale(std::min(scale, 0.5f));
5356
bg->addChild(modAuthorText);
5457

5558
auto sprite = CCNode::create();

src/layers/GYSettingSelectLayer.cpp

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ bool GYSettingSelectLayer::init() {
127127

128128
// START OF CONTENT
129129

130-
CCScale9Sprite* contentBox = CCScale9Sprite::create("GJ_square01.png");
130+
CCScale9Sprite* contentBox = CCScale9Sprite::create("square02b_001.png");
131+
contentBox->setColor(ccColor3B{0, 0, 0});
132+
contentBox->setOpacity(60);
131133
contentBox->setContentSize({ winSize.width * 0.7f, winSize.height * 0.7f });
132134
contentBox->setPosition({ winSize.width / 2, winSize.height / 2 - winSize.height * 0.05f });
133135
contentBox->setAnchorPoint({ 0.5f, 0.5f });
@@ -139,33 +141,19 @@ bool GYSettingSelectLayer::init() {
139141
scroll->setTouchEnabled(true);
140142
contentBox->addChild(scroll);
141143

142-
auto contentLeft = CCLayer::create();
143-
contentLeft->setContentSize({ winSize.width * 0.3f, 0.f });
144-
contentLeft->setID("content-left");
145-
contentLeft->setPosition({ winSize.width * 0.0125f, 0 });
146-
contentLeft->setAnchorPoint({ 0, 0 });
147-
148-
auto contentRight = CCLayer::create();
149-
contentRight->setContentSize({ winSize.width * 0.3f, 0.f });
150-
contentRight->setID("content-right");
151-
contentRight->setPosition({ winSize.width * 0.3625f, 0 });
152-
contentRight->setAnchorPoint({ 0, 0 });
153-
154-
auto leftColumn = ColumnLayout::create();
155-
leftColumn->setAxisReverse(true)
156-
->setAutoGrowAxis(scroll->getContentHeight())
157-
->setCrossAxisOverflow(false)
158-
->setAxisAlignment(AxisAlignment::End)
159-
->setGap(10.f);
160-
contentLeft->setLayout(leftColumn);
161-
162-
auto rightColumn = ColumnLayout::create();
163-
rightColumn->setAxisReverse(true)
164-
->setAutoGrowAxis(scroll->getContentHeight())
165-
->setCrossAxisOverflow(false)
166-
->setAxisAlignment(AxisAlignment::End)
167-
->setGap(10.f);
168-
contentRight->setLayout(rightColumn);
144+
auto contentLayer = CCLayer::create();
145+
contentLayer->setContentSize({ winSize.width * 0.7f, 0.f });
146+
contentLayer->setID("content-layer");
147+
contentLayer->setPosition({ 0, 0 });
148+
contentLayer->setAnchorPoint({ 0, 0 });
149+
150+
auto columnLayout = ColumnLayout::create();
151+
columnLayout->setAxisReverse(true)
152+
->setAutoGrowAxis(scroll->getContentHeight())
153+
->setCrossAxisOverflow(false)
154+
->setAxisAlignment(AxisAlignment::Center)
155+
->setGap(10.f);
156+
contentLayer->setLayout(columnLayout);
169157

170158
auto modTiles = {
171159
GYModTile::create("Geometry Dash", "RobTop", "gd"),
@@ -185,14 +173,8 @@ bool GYSettingSelectLayer::init() {
185173
GYModTile::create("Geometry Dash: Odyssey", "chumiu", "teamtcm.geometry-dash-odyssey"),
186174
};
187175

188-
bool addToLeft = true;
189176
for (auto& tile : modTiles) {
190-
if (addToLeft) {
191-
contentLeft->addChild(tile);
192-
} else {
193-
contentRight->addChild(tile);
194-
}
195-
addToLeft = !addToLeft;
177+
contentLayer->addChild(tile);
196178
}
197179

198180
auto updateContentSize = [&](CCLayer* layer) {
@@ -211,24 +193,25 @@ bool GYSettingSelectLayer::init() {
211193
layer->setContentSize({ layer->getContentSize().width, totalHeight });
212194
};
213195

214-
updateContentSize(contentLeft);
215-
updateContentSize(contentRight);
196+
updateContentSize(contentLayer);
216197

217-
scroll->m_contentLayer->addChild(contentLeft);
218-
scroll->m_contentLayer->addChild(contentRight);
198+
scroll->m_contentLayer->addChild(contentLayer);
219199

220-
contentLeft->updateLayout();
221-
contentRight->updateLayout();
200+
contentLayer->updateLayout();
222201

202+
float maxHeight = contentLayer->getContentSize().height;
223203
scroll->m_contentLayer->setContentSize({
224-
contentLeft->getContentSize().width + contentRight->getContentSize().width + 20.f,
225-
std::max(contentLeft->getContentSize().height, contentRight->getContentSize().height)
204+
contentLayer->getContentSize().width,
205+
maxHeight
226206
});
227207

228-
scroll->m_contentLayer->setAnchorPoint({ 0, 0 });
208+
scroll->m_contentLayer->setAnchorPoint({ 0, 1 });
209+
scroll->m_contentLayer->setPosition({ 0, scroll->getContentSize().height });
229210

230211
// END OF CONTENT
231212

213+
updateContentSize(contentLayer);
214+
232215

233216
CCMenu* leftMenu = CCMenu::create();
234217
leftMenu->setAnchorPoint({ 0, 0 });

0 commit comments

Comments
 (0)