MCPcopy Create free account
hub / github.com/Cpasjuste/pplay / MenuButton

Method MenuButton

src/menus/menu.cpp:12–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10using namespace c2d;
11
12MenuButton::MenuButton(Main *main, const MenuItem &item, const FloatRect &rect) : Rectangle(rect) {
13
14 this->item = item;
15 MenuButton::setOrigin(Origin::Left);
16
17 if (!item.icon.empty()) {
18 icon = new C2DTexture(main->getIo()->getRomFsPath() + "skin/" + item.icon);
19 icon->setOrigin(Origin::Left);
20 icon->setPosition(16 * main->getScaling().x, MenuButton::getSize().y / 2);
21 icon->setScale(main->getScaled(main->getSize().x / 1920, main->getSize().y / 1080));
22 icon->setFillColor(COLOR_FONT);
23 MenuButton::add(icon);
24 }
25
26 name = new Text(item.name, main->getFontSize(Main::FontSize::Medium), main->getFont());
27 name->setOrigin(Origin::Left);
28 name->setFillColor(COLOR_FONT);
29 if (!item.icon.empty()) {
30 name->setPosition((ICON_SIZE + 32) * main->getScaling().x, MenuButton::getSize().y / 2);
31 name->setSizeMax((MenuButton::getSize().x - ICON_SIZE + 32) * main->getScaling().x, 0);
32 } else {
33 name->setPosition(16 * main->getScaling().x, MenuButton::getSize().y / 2);
34 name->setSizeMax((MenuButton::getSize().x - (16 * main->getScaling().x)) * main->getScaling().x, 0);
35 }
36 MenuButton::add(name);
37}
38
39Menu::Menu(Main *m, const c2d::FloatRect &rect, const std::string &_title,
40 const std::vector<MenuItem> &items, bool left) : RectangleShape(rect) {

Callers

nothing calls this directly

Calls 6

getRomFsPathMethod · 0.80
getScalingMethod · 0.80
getScaledMethod · 0.80
getFontSizeMethod · 0.80
getFontMethod · 0.80
setFillColorMethod · 0.45

Tested by

no test coverage detected