diff --git a/loader/include/Geode/loader/SettingV3.hpp b/loader/include/Geode/loader/SettingV3.hpp index 99dce722df..1dd1e19b32 100644 --- a/loader/include/Geode/loader/SettingV3.hpp +++ b/loader/include/Geode/loader/SettingV3.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "../utils/cocos.hpp" #include "../utils/file.hpp" // this unfortunately has to be included because of C++ templates @@ -654,9 +655,9 @@ namespace geode { // Can / should be used to do alternating BG void setDefaultBGColor(cocos2d::ccColor4B color); - cocos2d::CCLabelBMFont* getNameLabel() const; + geode::Label* getNameLabel() const; CCMenuItemSpriteExtra* getDescriptionButton() const; - cocos2d::CCLabelBMFont* getStatusLabel() const; + geode::Label* getStatusLabel() const; cocos2d::CCMenu* getNameMenu() const; cocos2d::CCMenu* getButtonMenu() const; cocos2d::CCLayerColor* getBG() const; @@ -700,7 +701,7 @@ namespace geode { auto validate = this->getSetting()->isValid(m_impl->currentValue); if (!validate) { this->getStatusLabel()->setVisible(true); - this->getStatusLabel()->setString(validate.unwrapErr().c_str()); + this->getStatusLabel()->setText(validate.unwrapErr()); this->getStatusLabel()->setColor(cocos2d::ccc3(235, 35, 52)); } } diff --git a/loader/include/Geode/ui/IconButtonSprite.hpp b/loader/include/Geode/ui/IconButtonSprite.hpp index ee114568c6..451bf07867 100644 --- a/loader/include/Geode/ui/IconButtonSprite.hpp +++ b/loader/include/Geode/ui/IconButtonSprite.hpp @@ -2,6 +2,7 @@ #include #include +#include namespace geode { class GEODE_DLL IconButtonSprite : public cocos2d::CCSprite, public cocos2d::CCLabelProtocol { @@ -39,7 +40,7 @@ namespace geode { void setColor(cocos2d::ccColor3B const& color) override; void setOpacity(GLubyte opacity) override; NineSlice* getBg(); - cocos2d::CCLabelBMFont* getLabel(); + Label* getLabel(); cocos2d::CCNode* getIcon(); }; } diff --git a/loader/include/Geode/ui/Notification.hpp b/loader/include/Geode/ui/Notification.hpp index 0ee9ad62f4..55851ee887 100644 --- a/loader/include/Geode/ui/Notification.hpp +++ b/loader/include/Geode/ui/Notification.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace geode { constexpr auto NOTIFICATION_DEFAULT_TIME = 1.8f; @@ -34,7 +35,7 @@ namespace geode { void waitThenHide(); NineSlice* getBG(); - cocos2d::CCLabelBMFont* getLabel(); + geode::Label* getLabel(); cocos2d::CCNodeRGBA* getContent(); public: diff --git a/loader/include/Geode/ui/Popup.hpp b/loader/include/Geode/ui/Popup.hpp index 22704c8e86..4b65ed382e 100644 --- a/loader/include/Geode/ui/Popup.hpp +++ b/loader/include/Geode/ui/Popup.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -22,7 +23,7 @@ namespace geode { protected: cocos2d::CCSize m_size; NineSlice* m_bgSprite; - cocos2d::CCLabelBMFont* m_title = nullptr; + geode::Label* m_title = nullptr; CCMenuItemSpriteExtra* m_closeBtn; ~Popup(); diff --git a/loader/include/Geode/ui/ProgressBar.hpp b/loader/include/Geode/ui/ProgressBar.hpp index 8d8340a126..5ed4c37199 100644 --- a/loader/include/Geode/ui/ProgressBar.hpp +++ b/loader/include/Geode/ui/ProgressBar.hpp @@ -1,6 +1,8 @@ #pragma once #include +#include + namespace geode { // Enum for progress bar style enum class ProgressBarStyle { @@ -74,7 +76,7 @@ namespace geode { /** * Get the progress percentage text label node */ - cocos2d::CCLabelBMFont* getProgressLabel() const noexcept; + geode::Label* getProgressLabel() const noexcept; /** * Get the current style of the progress bar @@ -91,4 +93,4 @@ namespace geode { */ size_t getPrecision() const noexcept; }; -}; \ No newline at end of file +}; diff --git a/loader/include/Geode/ui/SelectList.hpp b/loader/include/Geode/ui/SelectList.hpp index f977c891b3..6efa487ce3 100644 --- a/loader/include/Geode/ui/SelectList.hpp +++ b/loader/include/Geode/ui/SelectList.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include namespace geode { @@ -16,7 +17,7 @@ namespace geode { std::vector m_list; size_t m_index = 0; geode::Function m_onChange; - cocos2d::CCLabelBMFont* m_label; + geode::Label* m_label; CCMenuItemSpriteExtra* m_prevBtn; CCMenuItemSpriteExtra* m_nextBtn; @@ -47,7 +48,7 @@ namespace geode { m_nextBtn->setPosition(width / 2 - 10.f, 0.f); this->addChild(m_nextBtn); - m_label = cocos2d::CCLabelBMFont::create("", "bigFont.fnt"); + m_label = geode::Label::create("", "bigFont.fnt"); this->addChild(m_label); this->updateLabel(); @@ -59,7 +60,7 @@ namespace geode { void updateLabel() { if (m_list.size()) { - m_label->setString(Stringify(m_list.at(m_index)).c_str()); + m_label->setText(Stringify(m_list.at(m_index))); m_prevBtn->setEnabled(true); m_nextBtn->setEnabled(true); } @@ -68,7 +69,7 @@ namespace geode { m_prevBtn->setEnabled(false); m_nextBtn->setEnabled(false); } - m_label->limitLabelWidth(m_obContentSize.width - 40.f, .6f, .1f); + m_label->setLimitLabelWidth(m_obContentSize.width - 40.f, .6f, .1f); } void onPrev(CCObject* sender) { diff --git a/loader/include/Geode/ui/SliderNode.hpp b/loader/include/Geode/ui/SliderNode.hpp index a86d67f92c..61dfa931df 100644 --- a/loader/include/Geode/ui/SliderNode.hpp +++ b/loader/include/Geode/ui/SliderNode.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -106,7 +107,7 @@ namespace geode { * Link a label. This will make the label automatically update whenever * the slider is dragged. */ - void linkLabel(cocos2d::CCLabelBMFont* label, unsigned int precision); + void linkLabel(geode::Label* label, unsigned int precision); /** * Unlink a linked label @@ -119,7 +120,7 @@ namespace geode { void setLabelPrecision(unsigned int precision); unsigned int getLabelPrecision(); - cocos2d::CCLabelBMFont* getLinkedLabel(); + geode::Label* getLinkedLabel(); /** * Set the slider as read only. This will hide the thumb and will disallow edits made @@ -159,7 +160,7 @@ namespace geode { bool initCustom(cocos2d::CCSprite* thumb, cocos2d::CCSprite* thumbSelected, NineSlice* groove, ZStringView bar, SliderCallback callback, cocos2d::CCSize const& barOffset); bool initStandard(SliderCallback callback, bool alt); - + void updateSize(); void updateFromTouch(cocos2d::CCTouch* touch); @@ -171,4 +172,4 @@ namespace geode { class Impl; std::unique_ptr m_impl; }; -} \ No newline at end of file +} diff --git a/loader/include/Geode/ui/TextArea.hpp b/loader/include/Geode/ui/TextArea.hpp index ca5fa944fb..413833b941 100644 --- a/loader/include/Geode/ui/TextArea.hpp +++ b/loader/include/Geode/ui/TextArea.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -50,7 +51,7 @@ namespace geode { float getScale() override; void setLinePadding(float padding); float getLinePadding(); - std::vector getLines(); + std::vector getLines(); float getHeight(); float getLineHeight(); diff --git a/loader/src/hooks/LoadingLayer.cpp b/loader/src/hooks/LoadingLayer.cpp index c7e771b976..a82d291d8c 100644 --- a/loader/src/hooks/LoadingLayer.cpp +++ b/loader/src/hooks/LoadingLayer.cpp @@ -8,14 +8,15 @@ #include #include #include +#include using namespace geode::prelude; struct CustomLoadingLayer : Modify { struct Fields { bool m_menuDisabled = false; - CCLabelBMFont* m_smallLabel = nullptr; - CCLabelBMFont* m_smallLabel2 = nullptr; + Label* m_smallLabel = nullptr; + Label* m_smallLabel2 = nullptr; int m_geodeLoadStep = 0; int m_totalMods = 0; ~Fields() { @@ -72,13 +73,13 @@ struct CustomLoadingLayer : Modify { auto winSize = CCDirector::sharedDirector()->getWinSize(); - m_fields->m_smallLabel = CCLabelBMFont::create("", "goldFont.fnt"); + m_fields->m_smallLabel = Label::create("", "goldFont.fnt"); m_fields->m_smallLabel->setPosition(winSize.width / 2, 30.f); m_fields->m_smallLabel->setScale(.45f); m_fields->m_smallLabel->setID("geode-small-label"); this->addChild(m_fields->m_smallLabel); - m_fields->m_smallLabel2 = CCLabelBMFont::create("", "goldFont.fnt"); + m_fields->m_smallLabel2 = Label::create("", "goldFont.fnt"); m_fields->m_smallLabel2->setPosition(winSize.width / 2, 15.f); m_fields->m_smallLabel2->setScale(.45f); m_fields->m_smallLabel2->setID("geode-small-label-2"); diff --git a/loader/src/hooks/MenuLayer.cpp b/loader/src/hooks/MenuLayer.cpp index df04583672..1ab991a218 100644 --- a/loader/src/hooks/MenuLayer.cpp +++ b/loader/src/hooks/MenuLayer.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -302,7 +303,7 @@ struct CustomMenuLayer : Modify { icon->setScale(.65f); if (count > 0) { - auto countLabel = CCLabelBMFont::create(std::to_string(count).c_str(), "bigFont.fnt"); + auto countLabel = Label::create(std::to_string(count), "bigFont.fnt"); countLabel->setScale(.5f); icon->addChildAtPosition(countLabel, Anchor::Center); } diff --git a/loader/src/ui/GeodeUI.cpp b/loader/src/ui/GeodeUI.cpp index 87f5e03c63..7a6ab8da89 100644 --- a/loader/src/ui/GeodeUI.cpp +++ b/loader/src/ui/GeodeUI.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -346,7 +347,7 @@ class ModLogoSprite : public CCNodeRGBA { void onLoadFailed(bool postEvent) { // Fallback to default logo if the image failed to load - auto sprite = CCLabelBMFont::create("N/A", "bigFont.fnt"); + auto sprite = Label::create("N/A", "bigFont.fnt"); sprite->setPosition(this->getScaledContentSize() / 2.f + CCSize{1.f, 2.f}); sprite->setOpacity(90); limitNodeSize(sprite, m_obContentSize, 99.f, 0.f); diff --git a/loader/src/ui/mods/GeodeStyle.cpp b/loader/src/ui/mods/GeodeStyle.cpp index d5e8c2a0be..160c152e94 100644 --- a/loader/src/ui/mods/GeodeStyle.cpp +++ b/loader/src/ui/mods/GeodeStyle.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include $on_mod(Loaded) { @@ -37,7 +38,7 @@ ColorProvider::get()->define("mod-problems-item-bg"_spr, { 255, 255, 255, 15 }); ColorProvider::get()->define("mod-developer-item-bg"_spr, { 255, 255, 255, 15 }); ColorProvider::get()->define("mod-list-paid-color"_spr, { 0, 255, 63, 255 }); - + ColorProvider::get()->define("keybinds-list-category-label"_spr, ccc3(148, 116, 155)); // Only used when GD theme is active @@ -364,8 +365,8 @@ bool GeodeTabSprite::init(const char* iconFrame, const char* text, float width, limitNodeSize(m_icon, iconSize, 3.f, .1f); this->addChildAtPosition(m_icon, Anchor::Left, ccp(16, 0), false); - m_label = CCLabelBMFont::create(text, "bigFont.fnt"); - m_label->limitLabelWidth(this->getContentWidth() - 45, std::clamp(width * .0045f, .35f, .55f), .1f); + m_label = Label::create(text, "bigFont.fnt"); + m_label->setLimitLabelWidth(this->getContentWidth() - 45, std::clamp(width * .0045f, .35f, .55f), .1f); m_label->setAnchorPoint({ .5f, .5f }); this->addChildAtPosition(m_label, Anchor::Left, ccp((itemSize.width - iconSize.width) / 2 + iconSize.width, 0), false); diff --git a/loader/src/ui/mods/GeodeStyle.hpp b/loader/src/ui/mods/GeodeStyle.hpp index 02d0c767d6..b1fbe8a441 100644 --- a/loader/src/ui/mods/GeodeStyle.hpp +++ b/loader/src/ui/mods/GeodeStyle.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -101,7 +102,7 @@ class GeodeTabSprite : public CCNode { NineSlice* m_deselectedBG; NineSlice* m_selectedBG; CCSprite* m_icon; - CCLabelBMFont* m_label; + geode::Label* m_label; bool init(const char* iconFrame, const char* text, float width, bool altColor); diff --git a/loader/src/ui/mods/ModsLayer.cpp b/loader/src/ui/mods/ModsLayer.cpp index f282f0bbce..34fd5ccec4 100644 --- a/loader/src/ui/mods/ModsLayer.cpp +++ b/loader/src/ui/mods/ModsLayer.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -38,12 +39,12 @@ bool ModsStatusNode::init() { m_statusBG->setContentSize({ 570, 40 }); m_statusBG->setScale(.5f); - m_status = CCLabelBMFont::create("", "bigFont.fnt"); + m_status = Label::create("", "bigFont.fnt"); m_status->setID("status-label"); m_status->setScale(.8f); m_statusBG->addChildAtPosition(m_status, Anchor::Center); - m_statusPercentage = CCLabelBMFont::create("", "bigFont.fnt"); + m_statusPercentage = Label::create("", "bigFont.fnt"); m_statusPercentage->setID("status-percentage-label"); m_statusPercentage->setScale(.8f); m_statusBG->addChildAtPosition(m_statusPercentage, Anchor::Right, ccp(-35, 0)); @@ -163,7 +164,7 @@ void ModsStatusNode::updateState() { // If some downloads were cancelled, show the restart button normally case DownloadState::SomeCancelled: { - m_status->setString("Download(s) Cancelled"); + m_status->setText("Download(s) Cancelled"); m_status->setColor(ccWHITE); m_status->setVisible(true); @@ -174,10 +175,10 @@ void ModsStatusNode::updateState() { // but also a "all done" status case DownloadState::AllDone: { if (downloads.size() == 1) { - m_status->setString(fmt::format("{} Mod Installed/Updated", downloads.size()).c_str()); + m_status->setText(fmt::format("{} Mod Installed/Updated", downloads.size())); } else { - m_status->setString(fmt::format("{} Mods Installed/Updated", downloads.size()).c_str()); + m_status->setText(fmt::format("{} Mods Installed/Updated", downloads.size())); } m_status->setColor("mod-list-enabled"_cc3b); m_status->setVisible(true); @@ -187,7 +188,7 @@ void ModsStatusNode::updateState() { } break; case DownloadState::SomeErrored: { - m_status->setString("Some Download(s) Failed"); + m_status->setText("Some Download(s) Failed"); m_status->setColor("mod-list-disabled"_cc3b); m_status->setVisible(true); m_statusBG->setVisible(true); @@ -205,10 +206,10 @@ void ModsStatusNode::updateState() { } } if (totalToConfirm == 1) { - m_status->setString(fmt::format("Click to Confirm {} Download", totalToConfirm).c_str()); + m_status->setText(fmt::format("Click to Confirm {} Download", totalToConfirm)); } else { - m_status->setString(fmt::format("Click to Confirm {} Downloads", totalToConfirm).c_str()); + m_status->setText(fmt::format("Click to Confirm {} Downloads", totalToConfirm)); } m_status->setColor(ccWHITE); m_status->setVisible(true); @@ -220,7 +221,7 @@ void ModsStatusNode::updateState() { } break; case DownloadState::SomeFetching: { - m_status->setString("Preparing Download(s)"); + m_status->setText("Preparing Download(s)"); m_status->setColor(ccWHITE); m_status->setVisible(true); m_loadingCircle->setVisible(true); @@ -241,7 +242,7 @@ void ModsStatusNode::updateState() { } auto percentage = totalProgress / static_cast(totalDownloading); - m_statusPercentage->setString(fmt::format("{}%", static_cast(percentage)).c_str()); + m_statusPercentage->setText(fmt::format("{}%", static_cast(percentage))); m_statusPercentage->setVisible(true); m_loadingCircle->setVisible(true); m_statusBG->setVisible(true); @@ -617,7 +618,7 @@ bool ModsLayer::init() { m_pageMenu->setAnchorPoint({ 1.f, 1.f }); m_pageMenu->setScale(.65f); - m_pageLabel = CCLabelBMFont::create("", "goldFont.fnt"); + m_pageLabel = Label::create("", "goldFont.fnt"); m_pageLabel->setID("page-label"); m_pageLabel->setAnchorPoint({ .5f, 1.f }); m_pageMenu->addChild(m_pageLabel); @@ -667,7 +668,7 @@ bool ModsLayer::init() { // add safe mode label if (isSafeMode) { - auto* label = CCLabelBMFont::create("Safe Mode Enabled", "bigFont.fnt"); + auto* label = Label::create("Safe Mode Enabled", "bigFont.fnt"); label->setPosition(winSize.width, 0); label->setAnchorPoint(ccp(1, 0)); label->setOpacity(128); @@ -765,8 +766,7 @@ void ModsLayer::updateState() { auto total = m_currentSource->getItemCount().value(); // Set the page count string - auto fmt = fmt::format("Page {}/{} (Total {})", page, count, total); - m_pageLabel->setString(fmt.c_str()); + m_pageLabel->setText(fmt::format("Page {}/{} (Total {})", page, count, total)); // Make page menu visible m_pageMenu->setVisible(true); diff --git a/loader/src/ui/mods/ModsLayer.hpp b/loader/src/ui/mods/ModsLayer.hpp index 5024c94b64..a9945f7092 100644 --- a/loader/src/ui/mods/ModsLayer.hpp +++ b/loader/src/ui/mods/ModsLayer.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -30,8 +31,8 @@ class ModsStatusNode : public CCNode { }; NineSlice* m_statusBG; - CCLabelBMFont* m_status; - CCLabelBMFont* m_statusPercentage; + geode::Label* m_status; + geode::Label* m_statusPercentage; Slider* m_progressBar; CCNode* m_loadingCircle; CCMenu* m_btnMenu; @@ -62,7 +63,7 @@ class ModsLayer : public CCLayer, public SetIDPopupDelegate { ModListSource* m_currentSource = nullptr; std::unordered_map> m_lists; CCMenu* m_pageMenu; - CCLabelBMFont* m_pageLabel; + geode::Label* m_pageLabel; CCMenuItemSpriteExtra* m_goToPageBtn; ModsStatusNode* m_statusNode; ListenerHandle m_updateStateHandle; diff --git a/loader/src/ui/mods/events/EventWinnerAnimation.cpp b/loader/src/ui/mods/events/EventWinnerAnimation.cpp index adbb4fd2fc..f59f33bd15 100644 --- a/loader/src/ui/mods/events/EventWinnerAnimation.cpp +++ b/loader/src/ui/mods/events/EventWinnerAnimation.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include static float shakeyNoise(float x) { @@ -158,7 +159,7 @@ bool EventWinnerAnimation::init() { circleWave->m_color = ccc3(255, 255, 255); this->addChildAtPosition(circleWave, Anchor::Center); - auto modtoberWinnerLabel = CCLabelBMFont::create("Modtober Winner", "goldFont.fnt"); + auto modtoberWinnerLabel = Label::create("Modtober Winner", "goldFont.fnt"); float offset = 0.f; for (auto ch : CCArrayExt(modtoberWinnerLabel->getChildren())) { ch->setScale(0.f); @@ -176,7 +177,7 @@ bool EventWinnerAnimation::init() { modtoberWinnerSpr->runAction(CCEaseInOut::create(CCScaleTo::create(.5f, .4f), 2.f)); this->addChildAtPosition(modtoberWinnerSpr, Anchor::Center, ccp(0, 45)); - auto winnerNameLabel = CCLabelBMFont::create("Geome3Dash", "bigFont.fnt"); + auto winnerNameLabel = Label::create("Geome3Dash", "bigFont.fnt"); winnerNameLabel->setScale(.7f); offset = 0.f; for (auto ch : CCArrayExt(winnerNameLabel->getChildren())) { @@ -190,7 +191,7 @@ bool EventWinnerAnimation::init() { } this->addChildAtPosition(winnerNameLabel, Anchor::Center, ccp(0, -50)); - auto winnerDevLabel = CCLabelBMFont::create("Rainix & Adaf", "goldFont.fnt"); + auto winnerDevLabel = Label::create("Rainix & Adaf", "goldFont.fnt"); winnerDevLabel->setScale(.5f); offset = 0.f; for (auto ch : CCArrayExt(winnerDevLabel->getChildren())) { diff --git a/loader/src/ui/mods/list/ModDeveloperItem.cpp b/loader/src/ui/mods/list/ModDeveloperItem.cpp index 32ad19630e..f07004423b 100644 --- a/loader/src/ui/mods/list/ModDeveloperItem.cpp +++ b/loader/src/ui/mods/list/ModDeveloperItem.cpp @@ -2,9 +2,9 @@ #include #include +#include #include #include -#include #include #include #include @@ -49,15 +49,15 @@ bool ModDeveloperItem::init( Anchor::Center ); - auto label = CCLabelBMFont::create( - displayName.has_value() ? displayName->c_str() : developer.c_str(), + auto label = Label::create( + displayName.has_value() ? std::move(*displayName) : developer, "bigFont.fnt" ); // Left + Right + Space between constexpr float paddings = 30.0f; float calc = size.width - paddings; - label->setWidth(calc); + label->setContentWidth(calc); label->setScale(0.4f); label->setAnchorPoint({0.0f, 0.5f}); @@ -122,4 +122,4 @@ ModDeveloperItem* ModDeveloperItem::create( delete ret; return nullptr; -} \ No newline at end of file +} diff --git a/loader/src/ui/mods/list/ModItem.cpp b/loader/src/ui/mods/list/ModItem.cpp index 495f2fd27c..ccaa5be9ae 100644 --- a/loader/src/ui/mods/list/ModItem.cpp +++ b/loader/src/ui/mods/list/ModItem.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -46,11 +47,11 @@ bool ModItem::init(ModSource&& source, bool listItem) { title.append("..."); } - m_titleLabel = CCLabelBMFont::create(title.c_str(), "bigFont.fnt"); + m_titleLabel = Label::create(title.str(), "bigFont.fnt"); m_titleLabel->setID("title-label"); m_titleContainer->addChild(m_titleLabel); - m_versionLabel = CCLabelBMFont::create("", "bigFont.fnt"); + m_versionLabel = Label::create("", "bigFont.fnt"); m_versionLabel->setID("version-label"); m_versionLabel->setScale(0.7f); m_versionLabel->setLayoutOptions( @@ -60,7 +61,7 @@ bool ModItem::init(ModSource&& source, bool listItem) { ); m_titleContainer->addChild(m_versionLabel); - m_versionDownloadSeparator = CCLabelBMFont::create("•", "bigFont.fnt"); + m_versionDownloadSeparator = Label::create("•", "bigFont.fnt"); m_versionDownloadSeparator->setOpacity(155); m_titleContainer->addChild(m_versionDownloadSeparator); @@ -79,7 +80,7 @@ bool ModItem::init(ModSource&& source, bool listItem) { m_developers->setAnchorPoint({ .0f, .5f }); auto by = m_source.formatDevelopers(); - m_developerLabel = CCLabelBMFont::create(by.c_str(), "goldFont.fnt"); + m_developerLabel = Label::create(by, "goldFont.fnt"); m_developerLabel->setID("developers-label"); auto developersBtn = CCMenuItemSpriteExtra::create( m_developerLabel, this, menu_selector(ModItem::onDevelopers) @@ -101,8 +102,8 @@ bool ModItem::init(ModSource&& source, bool listItem) { m_description->setOpacity(90); auto desc = m_source.getMetadata().getDescription(); - auto descLabel = CCLabelBMFont::create( - desc.value_or("[No Description Provided]").c_str(), + auto descLabel = Label::create( + desc.value_or("[No Description Provided]"), "chatFont.fnt" ); descLabel->setColor(desc ? ccWHITE : ccGRAY); @@ -172,7 +173,7 @@ bool ModItem::init(ModSource&& source, bool listItem) { m_downloadWaiting->setID("download-waiting-container"); m_downloadWaiting->setContentSize({ 225, 30 }); - auto downloadWaitingLabel = CCLabelBMFont::create("Preparing Download...", "bigFont.fnt"); + auto downloadWaitingLabel = Label::create("Preparing Download...", "bigFont.fnt"); downloadWaitingLabel->setScale(.75f); downloadWaitingLabel->setID("download-waiting-label"); m_downloadWaiting->addChildAtPosition( @@ -261,7 +262,7 @@ bool ModItem::init(ModSource&& source, bool listItem) { } m_pinToggle = CCMenuItemToggler::create( - pinOff, pinOn, + pinOff, pinOn, this, menu_selector(ModItem::onPin) ); m_pinToggle->setScale(0.75f); @@ -298,12 +299,12 @@ bool ModItem::init(ModSource&& source, bool listItem) { if (updatedAt) { m_updatedAtContainer = CCNode::create(); - auto installedLabel = CCLabelBMFont::create( - utils::timeToAgoString(updatedAt->updateTime, true).c_str(), + auto installedLabel = Label::create( + utils::timeToAgoString(updatedAt->updateTime, true), "bigFont.fnt" ); installedLabel->setID("installed-ago-label"); - installedLabel->limitLabelWidth(125, 1.f, .1f); + installedLabel->setLimitLabelWidth(125, 1.f, .1f); m_updatedAtContainer->addChildAtPosition(installedLabel, Anchor::Right, ccp(-0, 0), ccp(1, .5f)); auto installedIcon = CCSprite::createWithSpriteFrameName("GJ_timeIcon_001.png"); @@ -372,13 +373,13 @@ bool ModItem::init(ModSource&& source, bool listItem) { // on which mods to install m_downloadCountContainer = CCNode::create(); - auto downloads = CCLabelBMFont::create( - numToAbbreviatedString(metadata.downloadCount).c_str(), + auto downloads = Label::create( + numToAbbreviatedString(metadata.downloadCount), "bigFont.fnt" ); downloads->setID("downloads-label"); downloads->setColor("mod-list-version-label"_cc3b); - downloads->limitLabelWidth(125, 1.f, .1f); + downloads->setLimitLabelWidth(125, 1.f, .1f); m_downloadCountContainer->addChildAtPosition(downloads, Anchor::Right, ccp(-0, 0), ccp(1, .5f)); auto downloadsIcon = CCSprite::createWithSpriteFrameName("GJ_downloadsIcon_001.png"); @@ -414,7 +415,7 @@ bool ModItem::init(ModSource&& source, bool listItem) { // m_recommendedBy = CCNode::create(); // m_recommendedBy->setID("recommended-container"); // m_recommendedBy->setContentWidth(225); - // auto byLabel = CCLabelBMFont::create("Recommended by ", "bigFont.fnt"); + // auto byLabel = Label::create("Recommended by ", "bigFont.fnt"); // byLabel->setID("recommended-label"); // byLabel->setColor("mod-list-recommended-by"_cc3b); // m_recommendedBy->addChild(byLabel); @@ -426,7 +427,7 @@ bool ModItem::init(ModSource&& source, bool listItem) { // recommendStr = fmt::format("{} installed mods", recommends.size()); // } - // auto nameLabel = CCLabelBMFont::create(recommendStr.c_str(), "bigFont.fnt"); + // auto nameLabel = Label::create(recommendStr.c_str(), "bigFont.fnt"); // nameLabel->setID("recommended-name-label"); // nameLabel->setColor("mod-list-recommended-by-2"_cc3b); // m_recommendedBy->addChild(nameLabel); @@ -513,8 +514,8 @@ void ModItem::updateState() { } } - // Show the "Updated at" label if the installed mods list is being sorted - // by "Recently installed" (to let people know when they've installed or + // Show the "Updated at" label if the installed mods list is being sorted + // by "Recently installed" (to let people know when they've installed or // updated the mod) // Hide the enable and pin toggles to make space for install times :3 // (Pinning doesn't make sense for that sorting anyway) @@ -679,9 +680,7 @@ void ModItem::updateState() { if (update.update) { m_updateBtn->setVisible(true); - std::string updateString = ""; - updateString += m_source.getMetadata().getVersion().toVString() + " -> " + update.update->version.toVString(); - m_versionLabel->setString(updateString.c_str()); + m_versionLabel->setText(fmt::format("{} -> {}", m_source.getMetadata().getVersion().toVString(), update.update->version.toVString())); m_versionLabel->setColor(to3B(ColorProvider::get()->color("mod-list-version-label-updates-available"_spr))); m_bg->setColor(to3B(ColorProvider::get()->color("mod-list-version-bg-updates-available"_spr))); @@ -695,7 +694,7 @@ void ModItem::updateState() { } } else { - m_versionLabel->setString(m_source.getMetadata().getVersion().toVString().c_str()); + m_versionLabel->setText(m_source.getMetadata().getVersion().toVString()); m_versionLabel->setColor(to3B(ColorProvider::get()->color("mod-list-version-label"_spr))); } @@ -1034,7 +1033,7 @@ bool AnyModItem::init(ZStringView modID) { m_bg->setColor(ccRED); m_bg->setOpacity(90); - auto errorLabel = CCLabelBMFont::create(err.details.c_str(), "bigFont.fnt"); + auto errorLabel = Label::create(std::move(err.details), "bigFont.fnt"); errorLabel->setAnchorPoint(ccp(0, .5f)); errorLabel->setScale(.35f); this->addChildAtPosition(errorLabel, Anchor::Left, ccp(10, 0)); diff --git a/loader/src/ui/mods/list/ModItem.hpp b/loader/src/ui/mods/list/ModItem.hpp index 0b3eeb5c94..1eccd5bee0 100644 --- a/loader/src/ui/mods/list/ModItem.hpp +++ b/loader/src/ui/mods/list/ModItem.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -54,12 +55,12 @@ class ModItem : public ModListItem { CCNode* m_logo; CCNode* m_infoContainer; CCNode* m_titleContainer; - Ref m_titleLabel; - CCLabelBMFont* m_versionLabel; + Ref