Exemplo n.º 1
0
void EmoteShortcutContainer::safeDraw(Graphics *graphics)
{
    if (!emoteShortcut)
        return;

    BLOCK_START("EmoteShortcutContainer::draw")
    if (settings.guiAlpha != mAlpha)
    {
        if (mBackgroundImg)
            mBackgroundImg->setAlpha(mAlpha);
        mAlpha = settings.guiAlpha;
    }

    Font *const font = getFont();
    safeDrawBackground(graphics);

    unsigned sz = static_cast<unsigned>(mEmoteImg.size());
    if (sz > mMaxItems)
        sz = mMaxItems;
    for (unsigned i = 0; i < sz; i++)
    {
        const EmoteSprite *const emoteImg = mEmoteImg[i];
        if (emoteImg)
        {
            const AnimatedSprite *const sprite = emoteImg->sprite;
            if (sprite)
            {
                sprite->draw(graphics,
                    (i % mGridWidth) * mBoxWidth + 2,
                    (i / mGridWidth) * mBoxHeight + 10);
            }
        }
    }
    for (unsigned i = 0; i < mMaxItems; i++)
    {
        const int emoteX = (i % mGridWidth) * mBoxWidth;
        const int emoteY = (i / mGridWidth) * mBoxHeight;

        // Draw emote keyboard shortcut.
        const std::string key = inputManager.getKeyValueString(
            InputAction::EMOTE_1 + i);

        font->drawString(graphics,
            mForegroundColor,
            mForegroundColor2,
            key,
            emoteX + 2, emoteY + 2);
    }

    BLOCK_END("EmoteShortcutContainer::draw")
}
Exemplo n.º 2
0
void SpellShortcutContainer::safeDraw(Graphics *const graphics)
{
    if (spellShortcut == nullptr)
        return;

    BLOCK_START("SpellShortcutContainer::draw")
    if (settings.guiAlpha != mAlpha)
    {
        mAlpha = settings.guiAlpha;
        if (mBackgroundImg != nullptr)
            mBackgroundImg->setAlpha(mAlpha);
    }

    Font *const font = getFont();

    const int selectedId = spellShortcut->getSelectedItem();
    graphics->setColor(mForegroundColor);
    safeDrawBackground(graphics);

    // +++ in future need reorder images and string drawing.
    for (unsigned i = 0; i < mMaxItems; i++)
    {
        const int itemX = (i % mGridWidth) * mBoxWidth;
        const int itemY = (i / mGridWidth) * mBoxHeight;

        const int itemId = getItemByIndex(i);
        if (selectedId >= 0 && itemId == selectedId)
        {
            graphics->drawRectangle(Rect(itemX + 1, itemY + 1,
                mBoxWidth - 1, mBoxHeight - 1));
        }

        if (spellManager == nullptr)
            continue;

        const TextCommand *const spell = spellManager->getSpell(itemId);
        if (spell != nullptr)
        {
            if (!spell->isEmpty())
            {
                Image *const image = spell->getImage();

                if (image != nullptr)
                {
                    image->setAlpha(1.0F);
                    graphics->drawImage(image,
                        itemX + mImageOffsetX,
                        itemY + mImageOffsetY);
                }
            }

            font->drawString(graphics,
                mForegroundColor,
                mForegroundColor2,
                spell->getSymbol(),
                itemX + mTextOffsetX,
                itemY + mTextOffsetY);
        }
    }

    BLOCK_END("SpellShortcutContainer::draw")
}