Skip to content

Commit 56a8ced

Browse files
committed
improve MDPopup visually
1 parent fb07875 commit 56a8ced

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

loader/src/ui/nodes/MDPopup.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ bool MDPopup::setup(
88
std::string const& title, std::string const& info, char const* btn1Text, char const* btn2Text,
99
std::function<void(bool)> onClick
1010
) {
11-
this->setTitle(title.c_str(), "goldFont.fnt", .9f, 33.f);
12-
1311
m_onClick = onClick;
1412

1513
auto contentSize = CCSize {
16-
m_size.width - 70.f,
17-
m_size.height - 120.f,
14+
m_size.width - 50.f,
15+
m_size.height - 100.f,
1816
};
1917
auto content = MDTextArea::create(info, contentSize);
2018
m_mainLayer->addChildAtPosition(content, Anchor::Center, ccp(0, 0));
2119

20+
this->setTitle(title.c_str(), "goldFont.fnt", .9f, 28.f);
21+
m_title->limitLabelWidth(contentSize.width - 4.f, .9f, .1f);
22+
2223
auto btnSpr = ButtonSprite::create(btn1Text);
2324

2425
auto btn = CCMenuItemSpriteExtra::create(btnSpr, this, menu_selector(MDPopup::onBtn));
@@ -41,6 +42,8 @@ bool MDPopup::setup(
4142
menu->addChild(btn2);
4243
}
4344

45+
m_closeBtn->setVisible(false);
46+
4447
m_buttonMenu->addChildAtPosition(menu, Anchor::Bottom, ccp(0, 30));
4548
menu->updateLayout();
4649

@@ -55,7 +58,7 @@ void MDPopup::onBtn(CCObject* sender) {
5558
}
5659

5760
float MDPopup::estimateHeight(std::string const& content) {
58-
return clamp(string::count(content, '\n') * 30.f, 200.f, 280.f);
61+
return clamp(string::count(content, '\n') * 50.f, 180.f, 280.f);
5962
}
6063

6164
MDPopup* MDPopup::create(
@@ -64,12 +67,12 @@ MDPopup* MDPopup::create(
6467
) {
6568
auto ret = new MDPopup();
6669
if (ret->initAnchored(
67-
320.f, MDPopup::estimateHeight(content), title, content, btn1, btn2, onClick,
70+
400.f, MDPopup::estimateHeight(content), title, content, btn1, btn2, onClick,
6871
"square01_001.png", { 0, 0, 94, 94 }
6972
)) {
7073
ret->autorelease();
7174
return ret;
7275
}
7376
delete ret;
7477
return nullptr;
75-
}
78+
}

0 commit comments

Comments
 (0)