Ejemplo n.º 1
0
void InlineListWidget::draw() const
{
    const Item *   item  = items()[selection()];
    const Vector4f color = selectionFlashColor(mnRendState->textColors[this->color()]);

    DGL_Enable(DGL_TEXTURE_2D);
    FR_SetFont(mnRendState->textFonts[font()]);
    FR_SetColorAndAlpha(color.x, color.y, color.z, color.w * scrollingFadeout());
    FR_DrawTextXY3(item->text().toUtf8().constData(), geometry().topLeft.x, geometry().topLeft.y,
                   ALIGN_TOPLEFT, Hu_MenuMergeEffectWithDrawTextFlags(0));

    DGL_Disable(DGL_TEXTURE_2D);
}
Ejemplo n.º 2
0
void LabelWidget::draw() const
{
    fontid_t fontId           = mnRendState->textFonts[font()];
    Vector4f const &textColor = mnRendState->textColors[color()];
//    float t = (isFocused()? 1 : 0);

//    // Flash if focused.
//    if(isFocused() && cfg.common.menuTextFlashSpeed > 0)
//    {
//        float const speed = cfg.common.menuTextFlashSpeed / 2.f;
//        t = (1 + sin(page().timer() / (float)TICSPERSEC * speed * DD_PI)) / 2;
//    }

//    Vector4f const color = de::lerp(textColor, Vector4f(Vector3f(cfg.common.menuTextFlashColor), textColor.w), t);

    const Vector4f color = selectionFlashColor(textColor);

    const float fadeout = scrollingFadeout();
    if (fadeout < .001f) return;

    DGL_Color4f(1, 1, 1, color.w * fadeout);
    FR_SetFont(fontId);
    FR_SetColorAndAlpha(color.x, color.y, color.z, color.w * fadeout);

    if (d->patch)
    {
        String replacement;
        if(!(d->flags & MNTEXT_NO_ALTTEXT))
        {
            replacement = Hu_ChoosePatchReplacement(patchreplacemode_t(cfg.common.menuPatchReplaceMode), *d->patch, d->text);
        }

        DGL_Enable(DGL_TEXTURE_2D);
        WI_DrawPatch(*d->patch, replacement, geometry().topLeft, ALIGN_TOPLEFT, 0, Hu_MenuMergeEffectWithDrawTextFlags(0));
        DGL_Disable(DGL_TEXTURE_2D);

        return;
    }

    DGL_Enable(DGL_TEXTURE_2D);
    FR_DrawTextXY3(d->text.toUtf8().constData(), geometry().topLeft.x, geometry().topLeft.y, ALIGN_TOPLEFT, Hu_MenuMergeEffectWithDrawTextFlags(0));
    DGL_Disable(DGL_TEXTURE_2D);
}
Ejemplo n.º 3
0
void LineEditWidget::draw() const
{
    fontid_t fontId = mnRendState->textFonts[font()];

    Vector2i origin = geometry().topLeft + Vector2i(MNDATA_EDIT_OFFSET_X, MNDATA_EDIT_OFFSET_Y);

    String useText;
    float light = 1, textOpacity = mnRendState->pageAlpha;
    if(!d->text.isEmpty())
    {
        useText = d->text;
    }
    else if(!(isActive() && isFocused()))
    {
        useText = d->emptyText;
        light *= .5f;
        textOpacity = mnRendState->pageAlpha * .75f;
    }

    DGL_Enable(DGL_TEXTURE_2D);
    FR_SetFont(fontId);

    const float fadeout = scrollingFadeout();

    //int const numVisCharacters = de::clamp(0, useText.isNull()? 0 : useText.length(), d->maxVisibleChars);

    drawEditBackground(origin + Vector2i(MNDATA_EDIT_BACKGROUND_OFFSET_X, MNDATA_EDIT_BACKGROUND_OFFSET_Y),
                       geometry().width(), mnRendState->pageAlpha * fadeout);

    //if(string)
    {
//        float t = 0;
        Vector4f color = Vector4f(Vector3f(cfg.common.menuTextColors[MNDATA_EDIT_TEXT_COLORIDX]), 1.f);

        // Flash if focused?
        if (!isActive()) /* && isFocused() && cfg.common.menuTextFlashSpeed > 0)
        {
            float const speed = cfg.common.menuTextFlashSpeed / 2.f;
            t = (1 + sin(page().timer() / (float)TICSPERSEC * speed * DD_PI)) / 2;
        }*/
        {
            color = selectionFlashColor(color);
        }

//        Vector4f color = de::lerp(Vector3f(cfg.common.menuTextColors[MNDATA_EDIT_TEXT_COLORIDX]), Vector3f(cfg.common.menuTextFlashColor), t);
        color *= light;
        color.w = textOpacity;

        // Draw the text:
        FR_SetColorAndAlpha(color.x, color.y, color.z, color.w * fadeout);
        FR_DrawTextXY3(useText.toUtf8().constData(), origin.x, origin.y, ALIGN_TOPLEFT, Hu_MenuMergeEffectWithDrawTextFlags(0));

        // Are we drawing a cursor?
        if(isActive() && isFocused() && (menuTime & 8) &&
           (!d->maxLength || d->text.length() < d->maxLength))
        {
            origin.x += FR_TextWidth(useText.toUtf8().constData());
            FR_DrawCharXY3('_', origin.x, origin.y, ALIGN_TOPLEFT,  Hu_MenuMergeEffectWithDrawTextFlags(0));
        }
    }

    DGL_Disable(DGL_TEXTURE_2D);
}