|
15 | 15 | using namespace geode::prelude; |
16 | 16 | using namespace keybinds; |
17 | 17 |
|
18 | | -static void addBindSprites(CCNode* target, const char* action) { |
| 18 | +static void addBindSprites(CCNodeRGBA* target, const char* action) { |
| 19 | + if (target == nullptr) return; |
19 | 20 | target->removeAllChildren(); |
20 | 21 |
|
21 | | - auto bindContainer = CCNode::create(); |
22 | | - bindContainer->setScale(.65f); |
23 | | - bool first = true; |
| 22 | + std::vector<std::string> bindNames; |
24 | 23 | 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()); |
30 | 25 | } |
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); |
39 | 33 | } |
40 | 34 |
|
41 | 35 | struct $modify(PauseLayer) { |
@@ -258,13 +252,13 @@ struct $modify(UILayer) { |
258 | 252 | if (auto menu = this->getChildByID("checkpoint-menu")) { |
259 | 253 | if (auto add = menu->getChildByID("add-checkpoint-button")) { |
260 | 254 | addBindSprites( |
261 | | - static_cast<CCMenuItemSpriteExtra*>(add)->getNormalImage(), |
| 255 | + typeinfo_cast<CCNodeRGBA*>(static_cast<CCMenuItemSpriteExtra*>(add)->getNormalImage()), |
262 | 256 | "robtop.geometry-dash/place-checkpoint" |
263 | 257 | ); |
264 | 258 | } |
265 | 259 | if (auto rem = menu->getChildByID("remove-checkpoint-button")) { |
266 | 260 | addBindSprites( |
267 | | - static_cast<CCMenuItemSpriteExtra*>(rem)->getNormalImage(), |
| 261 | + typeinfo_cast<CCNodeRGBA*>(static_cast<CCMenuItemSpriteExtra*>(rem)->getNormalImage()), |
268 | 262 | "robtop.geometry-dash/delete-checkpoint" |
269 | 263 | ); |
270 | 264 | } |
|
0 commit comments