Skip to content

Commit 711aa50

Browse files
committed
fix practice bind sprites
1 parent 442b9a6 commit 711aa50

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"geode": "4.5.0",
2+
"geode": "4.6.1",
33
"gd": {
44
"win": "2.2074",
55
"android": "2.2074",

src/UILayer.cpp

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,21 @@
1515
using namespace geode::prelude;
1616
using namespace keybinds;
1717

18-
static void addBindSprites(CCNode* target, const char* action) {
18+
static void addBindSprites(CCNodeRGBA* target, const char* action) {
19+
if (target == nullptr) return;
1920
target->removeAllChildren();
2021

21-
auto bindContainer = CCNode::create();
22-
bindContainer->setScale(.65f);
23-
bool first = true;
22+
std::vector<std::string> bindNames;
2423
for (auto& bind : BindManager::get()->getBindsFor(action)) {
25-
if (!first) {
26-
bindContainer->addChild(CCLabelBMFont::create("/", "bigFont.fnt"));
27-
}
28-
first = false;
29-
bindContainer->addChild(bind->createLabel());
24+
bindNames.push_back(bind->toString());
3025
}
31-
bindContainer->setID("binds"_spr);
32-
bindContainer->setContentSize({
33-
target->getContentSize().width / bindContainer->getScale(), 40.f
34-
});
35-
bindContainer->setLayout(RowLayout::create());
36-
bindContainer->setAnchorPoint({ .5f, .5f });
37-
bindContainer->setPosition(target->getContentSize().width / 2, -1.f);
38-
target->addChild(bindContainer);
26+
auto label = CCLabelBMFont::create(fmt::format("{}", fmt::join(bindNames, "/")).c_str(), "bigFont.fnt");
27+
label->setID("binds"_spr);
28+
label->limitLabelWidth(target->getScaledContentWidth(), 0.8f, 0.1);
29+
label->setAnchorPoint({ .5f, .5f });
30+
label->setOpacity(target->getOpacity());
31+
label->setPosition(target->getContentSize().width / 2, -1.f);
32+
target->addChild(label);
3933
}
4034

4135
struct $modify(PauseLayer) {
@@ -258,13 +252,13 @@ struct $modify(UILayer) {
258252
if (auto menu = this->getChildByID("checkpoint-menu")) {
259253
if (auto add = menu->getChildByID("add-checkpoint-button")) {
260254
addBindSprites(
261-
static_cast<CCMenuItemSpriteExtra*>(add)->getNormalImage(),
255+
typeinfo_cast<CCNodeRGBA*>(static_cast<CCMenuItemSpriteExtra*>(add)->getNormalImage()),
262256
"robtop.geometry-dash/place-checkpoint"
263257
);
264258
}
265259
if (auto rem = menu->getChildByID("remove-checkpoint-button")) {
266260
addBindSprites(
267-
static_cast<CCMenuItemSpriteExtra*>(rem)->getNormalImage(),
261+
typeinfo_cast<CCNodeRGBA*>(static_cast<CCMenuItemSpriteExtra*>(rem)->getNormalImage()),
268262
"robtop.geometry-dash/delete-checkpoint"
269263
);
270264
}

0 commit comments

Comments
 (0)