| 10 | using namespace c2d; |
| 11 | |
| 12 | MenuButton::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 | |
| 39 | Menu::Menu(Main *m, const c2d::FloatRect &rect, const std::string &_title, |
| 40 | const std::vector<MenuItem> &items, bool left) : RectangleShape(rect) { |
nothing calls this directly
no test coverage detected