mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
The 'Gamelist on startup' setting now shows the full system names.
This commit is contained in:
parent
152fa84529
commit
74ba7d0590
|
@ -93,14 +93,33 @@ void GuiMenu::openUISettings()
|
||||||
auto startup_system = std::make_shared<OptionListComponent<std::string>>
|
auto startup_system = std::make_shared<OptionListComponent<std::string>>
|
||||||
(mWindow, getHelpStyle(), "GAMELIST ON STARTUP", false);
|
(mWindow, getHelpStyle(), "GAMELIST ON STARTUP", false);
|
||||||
startup_system->add("NONE", "", Settings::getInstance()->getString("StartupSystem") == "");
|
startup_system->add("NONE", "", Settings::getInstance()->getString("StartupSystem") == "");
|
||||||
|
float dotsSize = Font::get(FONT_SIZE_MEDIUM)->sizeText("...").x();
|
||||||
for (auto it = SystemData::sSystemVector.cbegin();
|
for (auto it = SystemData::sSystemVector.cbegin();
|
||||||
it != SystemData::sSystemVector.cend(); it++) {
|
it != SystemData::sSystemVector.cend(); it++) {
|
||||||
if ("retropie" != (*it)->getName()) {
|
if ((*it)->getName() != "retropie") {
|
||||||
startup_system->add((*it)->getName(), (*it)->getName(),
|
// If required, abbreviate the system name so it doesn't overlap the setting name.
|
||||||
|
std::string abbreviatedString = Font::get(FONT_SIZE_MEDIUM)->
|
||||||
|
getTextMaxWidth((*it)->getFullName(), Renderer::getScreenWidth() * 0.25f);
|
||||||
|
float sizeDifference = Font::get(FONT_SIZE_MEDIUM)->sizeText((*it)->getFullName()).x() -
|
||||||
|
Font::get(FONT_SIZE_MEDIUM)->sizeText(abbreviatedString).x();
|
||||||
|
if (sizeDifference > 0) {
|
||||||
|
// It doesn't make sense to abbreviate if the number of pixels removed by
|
||||||
|
// the abbreviation is less or equal to the size of the three dots that
|
||||||
|
// would be appended to the string.
|
||||||
|
if (sizeDifference <= dotsSize) {
|
||||||
|
abbreviatedString = (*it)->getFullName();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (abbreviatedString.back() == ' ')
|
||||||
|
abbreviatedString.pop_back();
|
||||||
|
abbreviatedString += "...";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
startup_system->add(abbreviatedString, (*it)->getName(),
|
||||||
Settings::getInstance()->getString("StartupSystem") == (*it)->getName());
|
Settings::getInstance()->getString("StartupSystem") == (*it)->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s->addWithLabel("GAMELIST TO SHOW ON STARTUP", startup_system);
|
s->addWithLabel("GAMELIST ON STARTUP", startup_system);
|
||||||
s->addSaveFunc([startup_system, s] {
|
s->addSaveFunc([startup_system, s] {
|
||||||
if (startup_system->getSelected() != Settings::getInstance()->getString("StartupSystem")) {
|
if (startup_system->getSelected() != Settings::getInstance()->getString("StartupSystem")) {
|
||||||
Settings::getInstance()->setString("StartupSystem", startup_system->getSelected());
|
Settings::getInstance()->setString("StartupSystem", startup_system->getSelected());
|
||||||
|
|
|
@ -416,6 +416,16 @@ Vector2f Font::sizeText(std::string text, float lineSpacing)
|
||||||
return Vector2f(highestWidth, y);
|
return Vector2f(highestWidth, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Font::getTextMaxWidth(std::string text, float maxWidth)
|
||||||
|
{
|
||||||
|
float width = sizeText(text).x();
|
||||||
|
while (width > maxWidth) {
|
||||||
|
text.pop_back();
|
||||||
|
width = sizeText(text).x();
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
float Font::getHeight(float lineSpacing) const
|
float Font::getHeight(float lineSpacing) const
|
||||||
{
|
{
|
||||||
return mMaxGlyphHeight * lineSpacing;
|
return mMaxGlyphHeight * lineSpacing;
|
||||||
|
|
|
@ -55,6 +55,8 @@ public:
|
||||||
|
|
||||||
// Returns the expected size of a string when rendered. Extra spacing is applied to the Y axis.
|
// Returns the expected size of a string when rendered. Extra spacing is applied to the Y axis.
|
||||||
Vector2f sizeText(std::string text, float lineSpacing = 1.5f);
|
Vector2f sizeText(std::string text, float lineSpacing = 1.5f);
|
||||||
|
// Returns the portion of a string that fits within the passed argument maxWidth.
|
||||||
|
std::string getTextMaxWidth(std::string text, float maxWidth);
|
||||||
TextCache* buildTextCache(const std::string& text, float offsetX,
|
TextCache* buildTextCache(const std::string& text, float offsetX,
|
||||||
float offsetY, unsigned int color, float lineSpacing = 1.5f);
|
float offsetY, unsigned int color, float lineSpacing = 1.5f);
|
||||||
TextCache* buildTextCache(
|
TextCache* buildTextCache(
|
||||||
|
|
Loading…
Reference in a new issue