Beispiel #1
0
/**\brief Draws the StatusBar
 * \param x x-coordinate
 * \param y y-coordinate
 *
 * \bug This can segfault with an empty title.
 */
void StatusBar::Draw(int x, int y) {
	int widthRemaining = this->width;
	Image *BorderLeft = Image::Get( "Resources/Graphics/hud_bar_left.png" );
	Image *BorderMiddle = Image::Get( "Resources/Graphics/hud_bar_middle.png" );
	Image *BorderRight= Image::Get( "Resources/Graphics/hud_bar_right.png" );

	if(pos==UPPER_RIGHT||pos==LOWER_RIGHT){
		x = Video::GetWidth() - BorderLeft->GetWidth() - width - BorderRight->GetWidth();
	}

	// Draw the Border
	BorderLeft->Draw(x,y);
	x += BorderLeft->GetWidth();
	BorderMiddle->DrawTiled(x,y,width, BorderMiddle->GetHeight());
	BorderRight->Draw(x+width,y);

	BitType->SetColor(1.f,1.f,1.f,1.f);

	// Draw the Title
	int wTitle = BitType->RenderTight( x, y+BorderMiddle->GetHalfHeight(), title,Font::LEFT,Font::MIDDLE );
	widthRemaining -= wTitle;
	x += wTitle + 5;

	// Draw Name
	if( !name.empty() ) {
		int wName = BitType->RenderTight( x, y+BorderMiddle->GetHalfHeight(), GetName() ,Font::LEFT,Font::MIDDLE );
		widthRemaining -= wName;
		x += wName;
	}

	// Draw the Bar
	if ( (int)(ratio*widthRemaining) > 0 ) {
		Image *BarLeft = Image::Get( "Resources/Graphics/hud_hullstr_leftbar.png" );
		Image *BarMiddle = Image::Get( "Resources/Graphics/hud_hullstr_bar.png" );
		Image *BarRight = Image::Get( "Resources/Graphics/hud_hullstr_rightbar.png" );

		int bar_y = y + BorderLeft->GetHalfHeight() - BarLeft->GetHalfHeight();
		BarLeft->Draw( x, bar_y );
		x += BarLeft->GetWidth();
		int bar_w = widthRemaining - BarLeft->GetWidth() - BarRight->GetWidth();
		BarMiddle->DrawTiled( x, bar_y,static_cast<int>(bar_w*ratio), BarMiddle->GetHeight() );
		BarRight->Draw( x + static_cast<int>(bar_w*ratio), bar_y );
	}
}
Beispiel #2
0
/**\brief Draws the StatusBar
 * \param x x-coordinate
 * \param y y-coordinate
 *
 * \bug This can segfault with an empty title.
 */
void StatusBar::Draw(int x, int y) {
	int widthRemaining = this->width;

	Image *BackgroundLeft = Image::Get( "data/skin/hud_bar_left.png" );
	Image *BackgroundMiddle = Image::Get( "data/skin/hud_bar_middle.png" );
	Image *BackgroundRight= Image::Get( "data/skin/hud_bar_right.png" );

	if(pos == UPPER_RIGHT || pos == LOWER_RIGHT) {
		x = Video::GetWidth() - BackgroundLeft->GetWidth() - width - BackgroundRight->GetWidth();
	}

	// Draw the Border
	BackgroundLeft->Draw(x,y);
	x += BackgroundLeft->GetWidth();
	BackgroundMiddle->DrawTiled(x, y, width, BackgroundMiddle->GetHeight());
	BackgroundRight->Draw(x + width, y);


	// Draw the Title
	int wTitle = font->RenderTight( x, y + BackgroundMiddle->GetHalfHeight(), title, Font::LEFT, Font::MIDDLE );
	widthRemaining -= wTitle;
	x += wTitle + 5;

	// Draw Name
	int wName = font->RenderTight( x, y + BackgroundMiddle->GetHalfHeight(), name, Font::LEFT, Font::MIDDLE );
	widthRemaining -= wName;
	x += wName;

	// Draw the Bar
	if ( (int)(ratio*widthRemaining) > 0 ) {
		Image *BarLeft = Image::Get( "data/skin/hud_hullstr_leftbar.png" );
		Image *BarMiddle = Image::Get( "data/skin/hud_hullstr_bar.png" );
		Image *BarRight = Image::Get( "data/skin/hud_hullstr_rightbar.png" );

		int bar_y = y + BackgroundLeft->GetHalfHeight() - BarLeft->GetHalfHeight();
		BarLeft->Draw( x, bar_y );
		x += BarLeft->GetWidth();
		int bar_w = widthRemaining - BarLeft->GetWidth() - BarRight->GetWidth();
		BarMiddle->DrawTiled( x, bar_y,static_cast<int>(bar_w*ratio), BarMiddle->GetHeight() );
		BarRight->Draw( x + static_cast<int>(bar_w*ratio), bar_y );
	}
}
Beispiel #3
0
void DataView::Draw(GLfloat x, GLfloat y,GLfloat xscale, GLfloat yscale) {
    background->Draw(x,y,xscale,yscale);
    uint32_t milliseconds = ((tv.tv_sec*1000) + (tv.tv_usec/1000));

    pthread_mutex_lock(&items_mutex);
    for(items_t::iterator i=items.begin(); i != items.end();i++) {
        i->item->Draw(i->x,i->y,i->xscale,i->yscale);
    }
    lists[current_list]->Draw(0,0,1,1);
    int i = current_list;
    boxes[i]->item->Draw(boxes[i]->x,boxes[i]->y,boxes[i]->xscale,boxes[i]->yscale);
    if(milliseconds - last_time_update > 5000) {
        char temp[128];
        time_t t;
        t = time(NULL);
        strftime(temp,sizeof(temp),"%d.%m.%y, %H:%M",localtime(&t));
        time_text->SetText(temp);
    }
    if(CurrentlyPlaying()) {
        //draw awesome animation
        
        GLfloat pos; 
        Image *chosen = NULL;
        //chosen_int = (milliseconds%6000)/1500;
        if(milliseconds - last_change > 1500) {
            last_change = milliseconds;
            chosen_int = lrand48()%3;
        }
        pos = ((GLfloat)(milliseconds%500UL))/500UL;
        float limit = 1;
        if(chosen_int == 2) {
            limit /= 4;
            pos = ((GLfloat)(milliseconds%2000UL))/2000UL;
        }
        
        chosen = waves[chosen_int];
        
        
        chosen->mTexBuffer[0] = pos;
        chosen->mTexBuffer[2] = pos;
        chosen->mTexBuffer[4] = limit+pos;
        chosen->mTexBuffer[6] = limit+pos;
        chosen->Draw(not_playing_line->x,0.25,not_playing_line->xscale,not_playing_line->yscale);
    }
    else {
        if(not_playing_line) {
            not_playing_line->item->Draw(not_playing_line->x,not_playing_line->y,not_playing_line->xscale,not_playing_line->yscale);
        } 
    }
    pthread_mutex_unlock(&items_mutex);
}
void MLIFont::DrawInternal(const string &s, Vector2 position, Color color, double scale, RectangleWH clipRect)
{
    EnsureUIThread();

    // If we're trying to draw an empty string, we can just return -
    // we're not gonna draw anything anyhow.
    if (s.length() == 0)
    {
        return;
    }

    CheckScale();

    double x = position.GetX();
    double y = position.GetY();

    for (string::const_iterator it = s.begin(); it < s.end();)
    {
        uint32_t c = 0;
        if (!GetNextFromStringIterator(it, s.end(), &c))
        {
            break;
        }

        Image *pGlyphImage = cache[c];
        if (pGlyphImage == NULL)
        {
            continue;
        }

        RectangleWH characterClipRect(0, 0, pGlyphImage->width / GetFontScale(), pGlyphImage->height / GetFontScale());
        RectangleWH originalCharacterClipRect = characterClipRect;

        if (clipRect.GetWidth() < 0 || clipRect.GetX() < originalCharacterClipRect.GetWidth())
        {
            if (clipRect.GetWidth() >= 0)
            {
                if (clipRect.GetX() > 0)
                {
                    characterClipRect.SetX(originalCharacterClipRect.GetX() + clipRect.GetX());
                    characterClipRect.SetWidth(originalCharacterClipRect.GetWidth() - clipRect.GetX());
                }

                if (clipRect.GetWidth() < characterClipRect.GetWidth())
                {
                    characterClipRect.SetWidth(clipRect.GetWidth());
                }

                if (clipRect.GetY() > 0)
                {
                    characterClipRect.SetY(min(originalCharacterClipRect.GetY() + clipRect.GetY(), originalCharacterClipRect.GetY() + originalCharacterClipRect.GetHeight()));
                    characterClipRect.SetHeight(originalCharacterClipRect.GetHeight() - (characterClipRect.GetY() - originalCharacterClipRect.GetY()));
                }

                if (clipRect.GetHeight() < characterClipRect.GetHeight())
                {
                    characterClipRect.SetHeight(clipRect.GetHeight());
                }
            }

            if (characterClipRect.GetWidth() > 0 && characterClipRect.GetHeight() > 0)
            {
                characterClipRect.SetHeight(characterClipRect.GetHeight() * GetFontScale());
                characterClipRect.SetWidth(characterClipRect.GetWidth() * GetFontScale());
                pGlyphImage->Draw(Vector2(x, y), characterClipRect, false, false, scale, scale, color);
            }
        }

        double deltaX = pGlyphImage->width;

        if (it < s.end())
        {
            uint32_t c2 = 0;
            if (PeekNextFromStringIterator(it, s.end(), &c2))
            {
                deltaX = GetKernedWidth(c, c2);
            }
        }

        x += deltaX / GetFontScale();
    }
}