Exemple #1
0
void GameManager::ShowInfoBar(string id, string msg, int duration, string imageFile)
{
	rect r;

	//if (mInfoBar)
//		mInfoBar->Die();

    if (mMap)
    {
    	Frame* f = new Frame(mMap, id, rect(175, 0, 450, 30), "", false, false, false, true);
    		f->mBoxRender = false;
    		f->SetImage("assets/infobar.png");

    	Label* l = new Label(f, "", rect(0, 8), msg);
    		l->mFontColor = color(255, 255, 255);

    		r = l->GetPosition();
    		r.x = f->Width()/2 - r.w/2;
    		if (!imageFile.empty())
    			r.x += 25;
    		r.y = f->Height()/2 - r.h/2 + 2;
    		l->SetPosition( r );

    	if (!imageFile.empty())
    	{
    		r.x -= 25;
    		r.w = 20;
    		r.h = 20;
    		r.y = f->Height()/2 - 8;

    		// Add a button that just acts as an image
    		Button* b = new Button(f, "", r, "", NULL);
    			b->mUsesImageOffsets = false;
    			b->SetImage(imageFile);
    	}

    	timers->Add("", duration, false, timer_DestroyInfoBar, NULL, f);
    }
}