From 178aae86aa6ac3e59797ff4e33523db5c6e1261d Mon Sep 17 00:00:00 2001 From: jak1 Date: Wed, 18 Mar 2020 19:17:03 +0100 Subject: added newline for every effect in itempopups --- src/gui/popups/itempopup.cpp | 16 ++++++++++++++-- src/gui/popups/itempopup.h | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp index 3cb80b7ac..f7898d91a 100644 --- a/src/gui/popups/itempopup.cpp +++ b/src/gui/popups/itempopup.cpp @@ -270,8 +270,8 @@ void ItemPopup::setItem(const ItemInfo &item, mItemName->adjustSize(); setLabelColor(mItemName, mItemType); mItemName->setPosition(space, 0); - - mItemEffect->setTextWrapped(item.getEffect(), 196); + const std::string readableEffect = replaceChar((char*)item.getEffect().c_str(), '/', '\n'); + mItemEffect->setTextWrapped(readableEffect, 196); // TRANSLATORS: popup label mItemWeight->setTextWrapped(strprintf(_("Weight: %s"), UnitsDb::formatWeight(item.getWeight()).c_str()), 196); @@ -466,3 +466,15 @@ void ItemPopup::resetPopup() mLastColor = ItemColor_one; mLastId = 0; } + +char* ItemPopup::replaceChar(char* str, char find, char replace) +{ + char *currentPos = str; + while ((currentPos = strchr(currentPos, find)) != NULL) + { + *currentPos = ' '; + *currentPos++; + *currentPos = replace; + } + return str; +} diff --git a/src/gui/popups/itempopup.h b/src/gui/popups/itempopup.h index d42bee103..b6cfd2e37 100644 --- a/src/gui/popups/itempopup.h +++ b/src/gui/popups/itempopup.h @@ -97,6 +97,8 @@ class ItemPopup final : public Popup void setLabelColor(Label *label, const ItemDbTypeT type) const A_NONNULL(2); + + char* replaceChar(char* str ,char find,char replace); }; extern ItemPopup *itemPopup; -- cgit v1.2.3-70-g09d2