Exemple #1
0
void Text::HandleChangeLanguage(StringHash eventType, VariantMap& eventData)
{
    auto* l10n = GetSubsystem<Localization>();
    text_ = l10n->Get(stringId_);
    DecodeToUnicode();
    ValidateSelection();
    UpdateText();
}
Exemple #2
0
void Text::ApplyAttributes()
{
    UIElement::ApplyAttributes();

    DecodeToUnicode();

    fontSize_ = Max(fontSize_, 1);
    ValidateSelection();
    UpdateText();
}
Exemple #3
0
void Text::SetText(const ea::string& text)
{
    if (autoLocalizable_)
    {
        stringId_ = text;
        auto* l10n = GetSubsystem<Localization>();
        text_ = l10n->Get(stringId_);
    }
    else
    {
        text_ = text;
    }

    DecodeToUnicode();
    ValidateSelection();
    UpdateText();
}
Exemple #4
0
void Text::ApplyAttributes()
{
    UISelectable::ApplyAttributes();

    // Localize now if attributes were loaded out-of-order
    if (autoLocalizable_ && stringId_.length())
    {
        auto* l10n = GetSubsystem<Localization>();
        text_ = l10n->Get(stringId_);
    }

    DecodeToUnicode();

    fontSize_ = Max(fontSize_, 1);
    strokeThickness_ = Abs(strokeThickness_);
    ValidateSelection();
    UpdateText();
}
Exemple #5
0
void Text::SetAutoLocalizable(bool enable)
{
    if (enable != autoLocalizable_)
    {
        autoLocalizable_ = enable;
        if (enable)
        {
            stringId_ = text_;
            auto* l10n = GetSubsystem<Localization>();
            text_ = l10n->Get(stringId_);
            SubscribeToEvent(E_CHANGELANGUAGE, URHO3D_HANDLER(Text, HandleChangeLanguage));
        }
        else
        {
            text_ = stringId_;
            stringId_ = "";
            UnsubscribeFromEvent(E_CHANGELANGUAGE);
        }
        DecodeToUnicode();
        ValidateSelection();
        UpdateText();
    }
}