Cleanup group container title localization behaviour, ryzom/ryzomcore#335

develop
kaetemi 4 years ago
parent 8dc777495a
commit 592ec2aaf1

@ -248,13 +248,6 @@ namespace NLGUI
// Get the header color draw. NB: depends if grayed, and if active.
NLMISC::CRGBA getDrawnHeaderColor () const;
std::string getTitleRaw () const;
void setTitleRaw (const std::string &title);
std::string getTitleOpenedRaw () const;
void setTitleOpenedRaw (const std::string &title);
std::string getTitleClosedRaw () const;
void setTitleClosedRaw (const std::string &title);
ucstring getUCTitleOpened () const;
void setUCTitleOpened (const ucstring &title);
ucstring getUCTitleClosed () const;
@ -295,10 +288,6 @@ namespace NLGUI
REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened);
REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed);
REFLECT_STRING("title_raw", getTitleRaw, setTitleRaw);
REFLECT_STRING("title_opened_raw", getTitleOpenedRaw, setTitleOpenedRaw);
REFLECT_STRING("title_closed_raw", getTitleClosedRaw, setTitleClosedRaw);
REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); // FIXME: Lua UTF-8
REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); // FIXME: Lua UTF-8
REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); // FIXME: Lua UTF-8
@ -315,6 +304,8 @@ namespace NLGUI
REFLECT_BOOL("lockable", isLockable, setLockable);
REFLECT_BOOL("locked", isLocked, setLocked);
REFLECT_BOOL("localize", isLocalize, setLocalize);
REFLECT_BOOL("header_active", getHeaderActive, setHeaderActive);
REFLECT_BOOL("right_button_enabled", getRightButtonEnabled, setRightButtonEnabled);
REFLECT_EXPORT_END
@ -377,7 +368,7 @@ namespace NLGUI
bool isActiveSavable() const { return _ActiveSavable; }
bool isLocalize() const { return _Localize; }
void setLocalize(bool localize) { _Localize = localize; }
void setLocalize(bool localize);
void setPopupX(sint32 x) { _PopupX = x; }
void setPopupY(sint32 y) { _PopupY = y; }
@ -649,6 +640,9 @@ namespace NLGUI
TTileClass convertTitleClass(const char *ptr);
void setTitledOpenedViewText();
void setTitledClosedViewText();
static COptionsContainerMove *getMoveOptions();
COptionsLayer *getContainerOptions(sint32 ls=-1); // Depends if overload by OptionsName or default used

@ -352,7 +352,7 @@ namespace NLGUI
// Set the title
void setTitle (const std::string &title);
std::string getTitle() const;
void setTitleRaw (const std::string &title);
void setContainerTitle (const std::string &title);
// Lookup a url in local file system
bool lookupLocalFile (std::string &result, const char *url, bool isUrl);

@ -21,7 +21,6 @@
#define STRING_CASE_H
#include "nel/misc/types_nl.h"
#include "nel/misc/ucstring.h"
namespace NLGUI
{

@ -84,7 +84,7 @@ namespace NLGUI
/// Set
void setText(const std::string &text);
void setText(const std::string &text); //< Not localized. Use setHardText to localize strings starting with "ui". TODO: Add a Localize flag, like title in group container. HardText then simply sets localize to true.
void setTextAsUtf16 (const ucstring &text);
void setFontName (const std::string &name);
void setFontSize (sint nFontSize, bool coef = true);
@ -178,7 +178,7 @@ namespace NLGUI
void getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const;
std::string getHardText() const { return _HardText.empty() ? _Text : _HardText; }
void setHardText (const std::string &ht);
void setHardText (const std::string &ht); //< Localizes strings starting with "ui"
void setHardTextAsUtf16(const ucstring &ht);
std::string getColorAsString() const;

@ -3744,7 +3744,7 @@ namespace NLGUI
_TitleOpened->setY (pLayer->getValSInt32 ("title_offset_y"));
}
_TitleOpened->setFontSize (pLayer->getValSInt32 ("title_font_size"));
if (_TitleClass==TitleText) _TitleOpened->setText (_TitleTextOpened);
if (_TitleClass == TitleText) setTitledOpenedViewText();
_TitleOpened->setActive (_Opened);
// Title when the container is closed
@ -3796,7 +3796,7 @@ namespace NLGUI
_TitleClosed->setY (pLayer->getValSInt32 ("title_offset_y"));
}
_TitleClosed->setFontSize (pLayer->getValSInt32 ("title_font_size"));
if (_TitleClass==TitleText) _TitleClosed->setText (_TitleTextClosed);
if (_TitleClass == TitleText) setTitledClosedViewText();
_TitleClosed->setActive(!_Opened);
@ -3946,6 +3946,15 @@ namespace NLGUI
}
}
// ***************************************************************************
void CGroupContainer::setLocalize(bool localize)
{
_Localize = localize;
setTitledOpenedViewText();
setTitledClosedViewText();
invalidateCoords();
}
// ***************************************************************************
std::string CGroupContainer::getTitle () const
{
@ -3955,8 +3964,8 @@ namespace NLGUI
// ***************************************************************************
void CGroupContainer::setTitle (const std::string &title)
{
if (_Localize) setTitleRaw (CI18N::get(title));
else setTitleRaw (title);
setTitleOpened(title);
setTitleClosed(title);
}
// ***************************************************************************
@ -3968,8 +3977,9 @@ namespace NLGUI
// ***************************************************************************
void CGroupContainer::setTitleOpened (const std::string &title)
{
if (_Localize) setTitleOpenedRaw (CI18N::get(title));
else setTitleOpenedRaw (title);
_TitleTextOpened = title;
setTitledOpenedViewText();
invalidateCoords();
}
// ***************************************************************************
@ -3980,88 +3990,70 @@ namespace NLGUI
// ***************************************************************************
void CGroupContainer::setTitleClosed (const std::string &title)
{
if (_Localize) setTitleClosedRaw (CI18N::get(title));
else setTitleClosedRaw (title);
}
// ***************************************************************************
void CGroupContainer::setTitleOpenedRaw(const std::string &title)
{
_TitleTextOpened = title;
if (_TitleOpened != NULL)
_TitleOpened->setText (title);
invalidateCoords();
}
// ***************************************************************************
void CGroupContainer::setTitleClosedRaw(const std::string &title)
{
_TitleTextClosed = title;
if (_TitleClosed != NULL)
_TitleClosed->setText (_TitleTextClosed);
setTitledClosedViewText();
invalidateCoords();
}
// ***************************************************************************
void CGroupContainer::setTitleRaw(const std::string &title)
void CGroupContainer::setTitledOpenedViewText()
{
setTitleOpenedRaw(title);
setTitleClosedRaw(title);
}
// ***************************************************************************
std::string CGroupContainer::getTitleRaw () const
{
return getTitleOpened();
}
// ***************************************************************************
std::string CGroupContainer::getTitleOpenedRaw () const
{
return _TitleTextOpened;
if (_TitleOpened != NULL)
{
if (_Localize && NLMISC::startsWith(_TitleTextOpened, "ui"))
_TitleOpened->setHardText(_TitleTextOpened);
else
_TitleOpened->setText(_TitleTextOpened);
}
}
// ***************************************************************************
std::string CGroupContainer::getTitleClosedRaw () const
void CGroupContainer::setTitledClosedViewText()
{
return _TitleTextClosed;
if (_TitleClosed != NULL)
{
if (_Localize && NLMISC::startsWith(_TitleTextClosed, "ui"))
_TitleClosed->setHardText(_TitleTextClosed);
else
_TitleClosed->setText(_TitleTextClosed);
}
}
// ***************************************************************************
void CGroupContainer::setUCTitleOpened(const ucstring &title)
{
setTitleOpenedRaw(title.toUtf8());
setTitleOpened(title.toUtf8());
}
// ***************************************************************************
void CGroupContainer::setUCTitleClosed(const ucstring &title)
{
setTitleClosedRaw(title.toUtf8());
setTitleClosed(title.toUtf8());
}
// ***************************************************************************
void CGroupContainer::setUCTitle(const ucstring &title)
{
setTitleRaw(title.toUtf8());
setTitle(title.toUtf8());
}
// ***************************************************************************
ucstring CGroupContainer::getUCTitle () const
{
return ucstring::makeFromUtf8(getTitleRaw());
return ucstring::makeFromUtf8(getTitle());
}
// ***************************************************************************
ucstring CGroupContainer::getUCTitleOpened () const
{
return ucstring::makeFromUtf8(getTitleOpenedRaw());
return ucstring::makeFromUtf8(getTitleOpened());
}
// ***************************************************************************
ucstring CGroupContainer::getUCTitleClosed () const
{
return ucstring::makeFromUtf8(getTitleClosedRaw());
return ucstring::makeFromUtf8(getTitleClosed());
}
// ***************************************************************************

@ -3401,7 +3401,7 @@ namespace NLGUI
// ***************************************************************************
void CGroupHTML::setTitleRaw (const std::string &title)
void CGroupHTML::setContainerTitle (const std::string &title)
{
CInterfaceElement *parent = getParent();
if (parent)
@ -3411,7 +3411,7 @@ namespace NLGUI
CGroupContainer *container = dynamic_cast<CGroupContainer*>(parent);
if (container)
{
container->setTitleRaw (title);
container->setTitle(title);
}
}
}
@ -3426,7 +3426,7 @@ namespace NLGUI
}
_TitleString += title;
setTitleRaw(_TitleString);
setContainerTitle(_TitleString);
}
std::string CGroupHTML::getTitle() const {

Loading…
Cancel
Save