From 64d6af09b4e4d1c58c966a20a7efb71901d29fa0 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Thu, 1 May 2014 14:47:33 -0500 Subject: [PATCH] Moved Alignment enum from inside TextComponent to global namespace in Font.h. Removed some old functions in Font. --- src/Window.cpp | 12 +++++-- src/components/IList.h | 5 ++- src/components/MenuComponent.cpp | 2 +- src/components/MenuComponent.h | 2 +- src/components/OptionListComponent.h | 2 +- src/components/TextComponent.h | 7 ---- src/components/TextListComponent.h | 2 -- src/guis/GuiDetectDevice.cpp | 10 +++--- src/guis/GuiFastSelect.cpp | 4 +-- src/guis/GuiGameScraper.cpp | 4 +-- src/guis/GuiInputConfig.cpp | 8 ++--- src/guis/GuiMenu.cpp | 2 +- src/guis/GuiMetaDataEd.cpp | 6 ++-- src/guis/GuiMsgBox.cpp | 2 +- src/guis/GuiScraperMulti.cpp | 6 ++-- src/guis/GuiTextEditPopup.cpp | 2 +- src/resources/Font.cpp | 40 +++++++--------------- src/resources/Font.h | 23 +++++++------ src/views/SystemView.cpp | 6 ++-- src/views/gamelist/ISimpleGameListView.cpp | 2 +- 20 files changed, 68 insertions(+), 79 deletions(-) diff --git a/src/Window.cpp b/src/Window.cpp index dc38877b7..e843eca34 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -225,9 +225,17 @@ void Window::setAllowSleep(bool sleep) void Window::renderLoadingScreen() { - Renderer::setMatrix(Eigen::Affine3f::Identity()); + Eigen::Affine3f trans = Eigen::Affine3f::Identity(); + Renderer::setMatrix(trans); Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF); - mDefaultFonts.at(2)->drawCenteredText("LOADING", 0, (Renderer::getScreenHeight() - mDefaultFonts.at(2)->getHeight()) / 2.0f , 0xFFFFFFFF); + + auto& font = mDefaultFonts.at(2); + TextCache* cache = font->buildTextCache("LOADING", 0, 0, 0xFFFFFFFF); + trans.translation() = Eigen::Vector3f((Renderer::getScreenWidth() - cache->metrics.size.x())/2, (Renderer::getScreenHeight() - cache->metrics.size.y())/2, 0); + Renderer::setMatrix(trans); + font->renderTextCache(cache); + delete cache; + Renderer::swapBuffers(); } diff --git a/src/components/IList.h b/src/components/IList.h index 683cae0f3..f6bca9dc3 100644 --- a/src/components/IList.h +++ b/src/components/IList.h @@ -254,7 +254,10 @@ protected: mGradient.setOpacity(mTitleOverlayOpacity); mGradient.render(identTrans); - mTitleOverlayFont->drawText(text, off, (mTitleOverlayColor & 0xFFFFFF00) | mTitleOverlayOpacity); // relies on mGradient's render for Renderer::setMatrix() + + TextCache* cache = mTitleOverlayFont->buildTextCache(text, off.x(), off.y(), 0xFFFFFF00 | mTitleOverlayOpacity); + mTitleOverlayFont->renderTextCache(cache); // relies on mGradient's render for Renderer::setMatrix() + delete cache; } void scroll(int amt) diff --git a/src/components/MenuComponent.cpp b/src/components/MenuComponent.cpp index 36cb2f596..9855410d5 100644 --- a/src/components/MenuComponent.cpp +++ b/src/components/MenuComponent.cpp @@ -18,7 +18,7 @@ MenuComponent::MenuComponent(Window* window, const char* title, const std::share // set up title mTitle = std::make_shared(mWindow); - mTitle->setAlignment(TextComponent::ALIGN_CENTER); + mTitle->setAlignment(ALIGN_CENTER); mTitle->setColor(0x555555FF); setTitle(title, titleFont); mGrid.setEntry(mTitle, Vector2i(0, 0), false); diff --git a/src/components/MenuComponent.h b/src/components/MenuComponent.h index a95d622c8..f1f3c096a 100644 --- a/src/components/MenuComponent.h +++ b/src/components/MenuComponent.h @@ -26,7 +26,7 @@ public: inline void addWithLabel(const std::string& label, const std::shared_ptr& comp, bool setCursorHere = false, bool invert_when_selected = true) { ComponentListRow row; - row.addElement(std::make_shared(mWindow, strToUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF), TextComponent::ALIGN_CENTER); + row.addElement(std::make_shared(mWindow, strToUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF), ALIGN_CENTER); row.addElement(comp, false, invert_when_selected); addRow(row, setCursorHere); } diff --git a/src/components/OptionListComponent.h b/src/components/OptionListComponent.h index 11a62156a..b20e9e389 100644 --- a/src/components/OptionListComponent.h +++ b/src/components/OptionListComponent.h @@ -113,7 +113,7 @@ public: auto font = Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT); mText.setFont(font); mText.setColor(0x777777FF); - mText.setAlignment(TextComponent::ALIGN_CENTER); + mText.setAlignment(ALIGN_CENTER); addChild(&mText); if(mMultiSelect) diff --git a/src/components/TextComponent.h b/src/components/TextComponent.h index 36d825c1b..db6931cd5 100644 --- a/src/components/TextComponent.h +++ b/src/components/TextComponent.h @@ -14,13 +14,6 @@ class ThemeData; class TextComponent : public GuiComponent { public: - enum Alignment - { - ALIGN_LEFT, - ALIGN_CENTER, // centers both horizontally and vertically - ALIGN_RIGHT - }; - TextComponent(Window* window); TextComponent(Window* window, const std::string& text, const std::shared_ptr& font, unsigned int color = 0x000000FF, Alignment align = ALIGN_LEFT, Eigen::Vector3f pos = Eigen::Vector3f::Zero(), Eigen::Vector2f size = Eigen::Vector2f::Zero()); diff --git a/src/components/TextListComponent.h b/src/components/TextListComponent.h index b0503d1ee..dc88f7c50 100644 --- a/src/components/TextListComponent.h +++ b/src/components/TextListComponent.h @@ -123,8 +123,6 @@ void TextListComponent::render(const Eigen::Affine3f& parentTrans) if(size() == 0) { - Renderer::setMatrix(trans); - font->drawText("The list is empty.", Eigen::Vector2f(0, 0), 0xFF0000FF); return; } diff --git a/src/guis/GuiDetectDevice.cpp b/src/guis/GuiDetectDevice.cpp index 7825270fa..70ed69401 100644 --- a/src/guis/GuiDetectDevice.cpp +++ b/src/guis/GuiDetectDevice.cpp @@ -32,7 +32,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun) : GuiComponent(w // title mTitle = std::make_shared(mWindow, firstRun ? "WELCOME" : "CONFIGURE INPUT", - Font::get(FONT_SIZE_LARGE), 0x555555FF, TextComponent::ALIGN_CENTER); + Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mTitle, Vector2i(0, 0), false, true, Vector2i(1, 1), GridFlags::BORDER_BOTTOM); // device info @@ -43,17 +43,17 @@ GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun) : GuiComponent(w deviceInfo << numDevices << " GAMEPAD" << (numDevices > 1 ? "S" : "") << " DETECTED"; else deviceInfo << "NO GAMEPADS DETECTED"; - mDeviceInfo = std::make_shared(mWindow, deviceInfo.str(), Font::get(FONT_SIZE_SMALL), 0x999999FF, TextComponent::ALIGN_CENTER); + mDeviceInfo = std::make_shared(mWindow, deviceInfo.str(), Font::get(FONT_SIZE_SMALL), 0x999999FF, ALIGN_CENTER); mGrid.setEntry(mDeviceInfo, Vector2i(0, 1), false, true); // message - mMsg1 = std::make_shared(mWindow, "HOLD A BUTTON ON YOUR DEVICE TO CONFIGURE IT.", Font::get(FONT_SIZE_SMALL), 0x777777FF, TextComponent::ALIGN_CENTER); + mMsg1 = std::make_shared(mWindow, "HOLD A BUTTON ON YOUR DEVICE TO CONFIGURE IT.", Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); mGrid.setEntry(mMsg1, Vector2i(0, 2), false, true); - mMsg2 = std::make_shared(mWindow, "PRESS F4 TO QUIT AT ANY TIME.", Font::get(FONT_SIZE_SMALL), 0x777777FF, TextComponent::ALIGN_CENTER); + mMsg2 = std::make_shared(mWindow, "PRESS F4 TO QUIT AT ANY TIME.", Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); mGrid.setEntry(mMsg2, Vector2i(0, 3), false, true); // currently held device - mDeviceHeld = std::make_shared(mWindow, "", Font::get(FONT_SIZE_MEDIUM), 0xFFFFFFFF, TextComponent::ALIGN_CENTER); + mDeviceHeld = std::make_shared(mWindow, "", Font::get(FONT_SIZE_MEDIUM), 0xFFFFFFFF, ALIGN_CENTER); mGrid.setEntry(mDeviceHeld, Vector2i(0, 4), false, true); setSize(Renderer::getScreenWidth() * 0.6f, Renderer::getScreenHeight() * 0.5f); diff --git a/src/guis/GuiFastSelect.cpp b/src/guis/GuiFastSelect.cpp index d5a36e8a6..50a3f1808 100644 --- a/src/guis/GuiFastSelect.cpp +++ b/src/guis/GuiFastSelect.cpp @@ -19,14 +19,14 @@ GuiFastSelect::GuiFastSelect(Window* window, IGameListView* gamelist) : GuiCompo addChild(&mBackground); mLetterText.setSize(mSize.x(), mSize.y() * 0.75f); - mLetterText.setAlignment(TextComponent::ALIGN_CENTER); + mLetterText.setAlignment(ALIGN_CENTER); mLetterText.applyTheme(theme, "fastSelect", "letter", FONT_PATH | COLOR); // TODO - set font size addChild(&mLetterText); mSortText.setPosition(0, mSize.y() * 0.75f); mSortText.setSize(mSize.x(), mSize.y() * 0.25f); - mSortText.setAlignment(TextComponent::ALIGN_CENTER); + mSortText.setAlignment(ALIGN_CENTER); mSortText.applyTheme(theme, "fastSelect", "subtext", FONT_PATH | COLOR); // TODO - set font size addChild(&mSortText); diff --git a/src/guis/GuiGameScraper.cpp b/src/guis/GuiGameScraper.cpp index 0a40d84af..6430ebf6f 100644 --- a/src/guis/GuiGameScraper.cpp +++ b/src/guis/GuiGameScraper.cpp @@ -21,13 +21,13 @@ GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std:: // row 0 is a spacer mGameName = std::make_shared(mWindow, strToUpper(mSearchParams.game->getPath().filename().generic_string()), - Font::get(FONT_SIZE_MEDIUM), 0x777777FF, TextComponent::ALIGN_CENTER); + Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); mGrid.setEntry(mGameName, Eigen::Vector2i(0, 1), false, true); // row 2 is a spacer mSystemName = std::make_shared(mWindow, strToUpper(mSearchParams.system->getFullName()), Font::get(FONT_SIZE_SMALL), - 0x888888FF, TextComponent::ALIGN_CENTER); + 0x888888FF, ALIGN_CENTER); mGrid.setEntry(mSystemName, Eigen::Vector2i(0, 3), false, true); // row 4 is a spacer diff --git a/src/guis/GuiInputConfig.cpp b/src/guis/GuiInputConfig.cpp index 10c56bdf7..06bbcef64 100644 --- a/src/guis/GuiInputConfig.cpp +++ b/src/guis/GuiInputConfig.cpp @@ -40,7 +40,7 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi // 0 is a spacer row mGrid.setEntry(std::make_shared(mWindow), Vector2i(0, 0), false); - mTitle = std::make_shared(mWindow, "CONFIGURING", Font::get(FONT_SIZE_LARGE), 0x555555FF, TextComponent::ALIGN_CENTER); + mTitle = std::make_shared(mWindow, "CONFIGURING", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mTitle, Vector2i(0, 1), false, true); std::stringstream ss; @@ -48,10 +48,10 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi ss << "KEYBOARD"; else ss << "GAMEPAD " << (target->getDeviceId() + 1); - mSubtitle1 = std::make_shared(mWindow, strToUpper(ss.str()), Font::get(FONT_SIZE_MEDIUM), 0x555555FF, TextComponent::ALIGN_CENTER); + mSubtitle1 = std::make_shared(mWindow, strToUpper(ss.str()), Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mSubtitle1, Vector2i(0, 2), false, true); - mSubtitle2 = std::make_shared(mWindow, "HOLD ANY BUTTON TO SKIP", Font::get(FONT_SIZE_SMALL), 0x99999900, TextComponent::ALIGN_CENTER); + mSubtitle2 = std::make_shared(mWindow, "HOLD ANY BUTTON TO SKIP", Font::get(FONT_SIZE_SMALL), 0x99999900, ALIGN_CENTER); mGrid.setEntry(mSubtitle2, Vector2i(0, 3), false, true); // 4 is a spacer row @@ -76,7 +76,7 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi auto text = std::make_shared(mWindow, inputDispName[i], Font::get(FONT_SIZE_MEDIUM), 0x777777FF); row.addElement(text, true); - auto mapping = std::make_shared(mWindow, "-NOT DEFINED-", Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT), 0x999999FF, TextComponent::ALIGN_RIGHT); + auto mapping = std::make_shared(mWindow, "-NOT DEFINED-", Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT), 0x999999FF, ALIGN_RIGHT); setNotDefined(mapping); // overrides text and color set above row.addElement(mapping, true); mMappings.push_back(mapping); diff --git a/src/guis/GuiMenu.cpp b/src/guis/GuiMenu.cpp index d13269b37..7a1089be8 100644 --- a/src/guis/GuiMenu.cpp +++ b/src/guis/GuiMenu.cpp @@ -206,7 +206,7 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN mVersion.setFont(Font::get(FONT_SIZE_SMALL)); mVersion.setColor(0xC6C6C6FF); mVersion.setText("EMULATIONSTATION V" PROGRAM_VERSION_STRING); - mVersion.setAlignment(TextComponent::ALIGN_CENTER); + mVersion.setAlignment(ALIGN_CENTER); addChild(&mMenu); addChild(&mVersion); diff --git a/src/guis/GuiMetaDataEd.cpp b/src/guis/GuiMetaDataEd.cpp index c56514ecd..ef9281bb7 100644 --- a/src/guis/GuiMetaDataEd.cpp +++ b/src/guis/GuiMetaDataEd.cpp @@ -30,9 +30,9 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector mHeaderGrid = std::make_shared(mWindow, Vector2i(1, 5)); - mTitle = std::make_shared(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), 0x333333FF, TextComponent::ALIGN_CENTER); + mTitle = std::make_shared(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), 0x333333FF, ALIGN_CENTER); mSubtitle = std::make_shared(mWindow, strToUpper(scraperParams.game->getPath().filename().generic_string()), - Font::get(FONT_SIZE_SMALL), 0x777777FF, TextComponent::ALIGN_CENTER); + Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); mHeaderGrid->setEntry(mTitle, Vector2i(0, 1), false, true); mHeaderGrid->setEntry(mSubtitle, Vector2i(0, 3), false, true); @@ -98,7 +98,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector default: { // MD_STRING - ed = std::make_shared(window, "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, TextComponent::ALIGN_RIGHT); + ed = std::make_shared(window, "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT); row.addElement(ed, true); auto spacer = std::make_shared(mWindow); diff --git a/src/guis/GuiMsgBox.cpp b/src/guis/GuiMsgBox.cpp index b929841c0..9261ab167 100644 --- a/src/guis/GuiMsgBox.cpp +++ b/src/guis/GuiMsgBox.cpp @@ -16,7 +16,7 @@ GuiMsgBox::GuiMsgBox(Window* window, const std::string& text, float width = Renderer::getScreenWidth() * 0.6f; // max width float minWidth = Renderer::getScreenWidth() * 0.3f; // minimum width - mMsg = std::make_shared(mWindow, text, Font::get(FONT_SIZE_MEDIUM), 0x777777FF, TextComponent::ALIGN_CENTER); + mMsg = std::make_shared(mWindow, text, Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); mGrid.setEntry(mMsg, Eigen::Vector2i(0, 0), false, false); // create the buttons diff --git a/src/guis/GuiScraperMulti.cpp b/src/guis/GuiScraperMulti.cpp index a4d20929b..0d4068088 100644 --- a/src/guis/GuiScraperMulti.cpp +++ b/src/guis/GuiScraperMulti.cpp @@ -25,13 +25,13 @@ GuiScraperMulti::GuiScraperMulti(Window* window, const std::queue(mWindow, "SCRAPING IN PROGRESS", Font::get(FONT_SIZE_LARGE), 0x555555FF, TextComponent::ALIGN_CENTER); + mTitle = std::make_shared(mWindow, "SCRAPING IN PROGRESS", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mTitle, Vector2i(0, 0), false, true); - mSystem = std::make_shared(mWindow, "SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, TextComponent::ALIGN_CENTER); + mSystem = std::make_shared(mWindow, "SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); mGrid.setEntry(mSystem, Vector2i(0, 1), false, true); - mSubtitle = std::make_shared(mWindow, "subtitle text", Font::get(FONT_SIZE_SMALL), 0x888888FF, TextComponent::ALIGN_CENTER); + mSubtitle = std::make_shared(mWindow, "subtitle text", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); mGrid.setEntry(mSubtitle, Vector2i(0, 2), false, true); mSearchComp = std::make_shared(mWindow, diff --git a/src/guis/GuiTextEditPopup.cpp b/src/guis/GuiTextEditPopup.cpp index 8491dfb3c..7fed7635b 100644 --- a/src/guis/GuiTextEditPopup.cpp +++ b/src/guis/GuiTextEditPopup.cpp @@ -10,7 +10,7 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window, const std::string& title, con addChild(&mBackground); addChild(&mGrid); - mTitle = std::make_shared(mWindow, strToUpper(title), Font::get(FONT_SIZE_LARGE), 0x555555FF, TextComponent::ALIGN_CENTER); + mTitle = std::make_shared(mWindow, strToUpper(title), Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); mText = std::make_shared(mWindow); mText->setValue(initValue); diff --git a/src/resources/Font.cpp b/src/resources/Font.cpp index d1150bd7d..31bdea113 100644 --- a/src/resources/Font.cpp +++ b/src/resources/Font.cpp @@ -228,14 +228,6 @@ void Font::buildAtlas(ResourceData data) } } - -void Font::drawText(std::string text, const Eigen::Vector2f& offset, unsigned int color) -{ - TextCache* cache = buildTextCache(text, offset[0], offset[1], color); - renderTextCache(cache); - delete cache; -} - void Font::renderTextCache(TextCache* cache) { if(!textureID) @@ -315,25 +307,6 @@ float Font::getLetterHeight() const return charData['S'].texH * fontScale; } -void Font::drawCenteredText(std::string text, float xOffset, float y, unsigned int color) -{ - Eigen::Vector2f pos = sizeText(text); - - pos[0] = (Renderer::getScreenWidth() - pos.x()); - pos[0] = (pos.x() / 2) + (xOffset / 2); - pos[1] = y; - - drawText(text, pos, color); -} - -//this could probably be optimized -//draws text and ensures it's never longer than xLen -void Font::drawWrappedText(std::string text, const Eigen::Vector2f& offset, float xLen, unsigned int color) -{ - text = wrapText(text, xLen); - drawText(text, offset, color); -} - //the worst algorithm ever written //breaks up a normal string with newlines to make it fit xLen std::string Font::wrapText(std::string text, float xLen) const @@ -447,6 +420,19 @@ Eigen::Vector2f Font::getWrappedTextCursorOffset(std::string text, float xLen, i //TextCache //============================================================================================================= +TextCache* Font::buildWrappedTextCache(const std::string& text, const Eigen::Vector2f& offset, float xLen, Alignment alignment, unsigned int color) +{ + if(!textureID) + { + LOG(LogError) << "Error - tried to build TextCache with Font that has no texture loaded!"; + return NULL; + } + + // todo + + return NULL; +} + TextCache* Font::buildTextCache(const std::string& text, float offsetX, float offsetY, unsigned int color) { if(!textureID) diff --git a/src/resources/Font.h b/src/resources/Font.h index c0008515c..7f52ef85c 100644 --- a/src/resources/Font.h +++ b/src/resources/Font.h @@ -19,6 +19,13 @@ class TextCache; #define FONT_PATH_LIGHT ":/opensans_hebrew_condensed_light.ttf" #define FONT_PATH_REGULAR ":/opensans_hebrew_condensed_regular.ttf" +enum Alignment +{ + ALIGN_LEFT, + ALIGN_CENTER, // centers both horizontally and vertically + ALIGN_RIGHT +}; + //A TrueType Font renderer that uses FreeType and OpenGL. //The library is automatically initialized when it's needed. class Font : public IReloadable @@ -50,20 +57,14 @@ public: GLuint textureID; + Eigen::Vector2f sizeText(std::string text) const; // Returns the expected size of a string when rendered. Extra spacing is applied to the Y axis. TextCache* buildTextCache(const std::string& text, float offsetX, float offsetY, unsigned int color); + TextCache* buildWrappedTextCache(const std::string& text, const Eigen::Vector2f& offset, float xLen, Alignment alignment, unsigned int color); void renderTextCache(TextCache* cache); - - //Create a TextCache, render with it, then delete it. Best used for short text or text that changes frequently. - void drawText(std::string text, const Eigen::Vector2f& offset, unsigned int color); - Eigen::Vector2f sizeText(std::string text) const; //Sets the width and height of a given string to supplied pointers. A dimension is skipped if its pointer is NULL. - std::string wrapText(std::string text, float xLen) const; - - void drawWrappedText(std::string text, const Eigen::Vector2f& offset, float xLen, unsigned int color); - Eigen::Vector2f sizeWrappedText(std::string text, float xLen) const; - Eigen::Vector2f getWrappedTextCursorOffset(std::string text, float xLen, int cursor) const; - - void drawCenteredText(std::string text, float xOffset, float y, unsigned int color); + std::string wrapText(std::string text, float xLen) const; // Inserts newlines into text to make it wrap properly. + Eigen::Vector2f sizeWrappedText(std::string text, float xLen) const; // Returns the expected size of a string after wrapping is applied. + Eigen::Vector2f getWrappedTextCursorOffset(std::string text, float xLen, int cursor) const; // Returns the position of of the cursor after moving "cursor" characters. float getHeight() const; float getLetterHeight() const; diff --git a/src/views/SystemView.cpp b/src/views/SystemView.cpp index f910b9b98..db1a5fa6c 100644 --- a/src/views/SystemView.cpp +++ b/src/views/SystemView.cpp @@ -13,7 +13,7 @@ #define BAND_HEIGHT (logoSize().y() * SELECTED_SCALE) SystemView::SystemView(Window* window) : IList(window, LIST_SCROLL_STYLE_SLOW, LIST_ALWAYS_LOOP), - mSystemInfo(window, "SYSTEM INFO", Font::get(FONT_SIZE_SMALL), 0x33333300, TextComponent::ALIGN_CENTER) + mSystemInfo(window, "SYSTEM INFO", Font::get(FONT_SIZE_SMALL), 0x33333300, ALIGN_CENTER) { mCamOffset = 0; @@ -58,7 +58,7 @@ void SystemView::populate() (*it)->getName(), Font::get(FONT_SIZE_LARGE), 0x000000FF, - TextComponent::ALIGN_CENTER); + ALIGN_CENTER); text->setSize(logoSize()); e.data.logo = std::shared_ptr(text); @@ -66,7 +66,7 @@ void SystemView::populate() (*it)->getName(), Font::get((int)(FONT_SIZE_LARGE * SELECTED_SCALE)), 0x000000FF, - TextComponent::ALIGN_CENTER); + ALIGN_CENTER); textSelected->setSize(logoSize()); e.data.logoSelected = std::shared_ptr(textSelected); } diff --git a/src/views/gamelist/ISimpleGameListView.cpp b/src/views/gamelist/ISimpleGameListView.cpp index ed1bf29d9..d6d5719eb 100644 --- a/src/views/gamelist/ISimpleGameListView.cpp +++ b/src/views/gamelist/ISimpleGameListView.cpp @@ -10,7 +10,7 @@ ISimpleGameListView::ISimpleGameListView(Window* window, FileData* root) : IGame mHeaderText.setText("Logo Text"); mHeaderText.setSize(mSize.x(), 0); mHeaderText.setPosition(0, 0); - mHeaderText.setAlignment(TextComponent::ALIGN_CENTER); + mHeaderText.setAlignment(ALIGN_CENTER); mHeaderImage.setResize(0, mSize.y() * 0.185f); mHeaderImage.setOrigin(0.5f, 0.0f);