예제 #1
0
파일: GuiScreen.cpp 프로젝트: Snaar/pioneer
void Screen::ShowBadError(const char *msg)
{
	fprintf(stderr, "%s", msg);
	baseContainer->HideChildren();
	
	Gui::Fixed *f = new Gui::Fixed(6*GetWidth()/8, 6*GetHeight()/8);
	Gui::Screen::AddBaseWidget(f, GetWidth()/8, GetHeight()/8);
	f->SetTransparency(false);
	f->SetBgColor(0.4,0,0,1.0);
	f->Add(new Gui::Label(msg), 10, 10);

	Gui::Button *okButton = new Gui::LabelButton(new Gui::Label("Ok"));
	okButton->SetShortcut(SDLK_RETURN, KMOD_NONE);
	f->Add(okButton, 10, 6*GetHeight()/8 - 32);
	f->ShowAll();
	f->Show();

	do {
		Gui::MainLoopIteration();
		SDL_Delay(10);
	} while (!okButton->IsPressed());

	Gui::Screen::RemoveBaseWidget(f);
	delete f;
	baseContainer->ShowAll();
}
예제 #2
0
void Screen::ShowBadError(const char *msg)
{
    // to make things simple for ourselves, we want to hide all the existing widgets
    // however, if we do it through baseContainer->HideChildren() then we lose track of
    // which widgets should be shown again when the red-screen is cleared.
    // So to avoid this problem we don't hide anything, we just temporarily swap to
    // a different base container which is just used for this red-screen

    Gui::Fixed *oldBaseContainer = Screen::baseContainer;
    Screen::baseContainer = new Gui::Fixed();
    Screen::baseContainer->SetSize(float(Screen::width), float(Screen::height));
    Screen::baseContainer->Show();

    Gui::Fixed *f = new Gui::Fixed(6*GetWidth()/8.0f, 6*GetHeight()/8.0f);
    Gui::Screen::AddBaseWidget(f, GetWidth()/8, GetHeight()/8);
    f->SetTransparency(false);
    f->SetBgColor(0.4f,0,0,1.0f);
    f->Add(new Gui::Label(msg, TextLayout::ColourMarkupNone), 10, 10);

    Gui::Button *okButton = new Gui::LabelButton(new Gui::Label("Ok"));
    okButton->SetShortcut(SDLK_RETURN, KMOD_NONE);
    f->Add(okButton, 10.0f, 6*GetHeight()/8.0f - 32);
    f->ShowAll();
    f->Show();

    do {
        Gui::MainLoopIteration();
        SDL_Delay(10);
    } while (!okButton->IsPressed());

    delete f; // Gui::Fixed does a horrible thing and calls Gui::Screen::RemoveBaseWidget(this) in its destructor
    delete Screen::baseContainer;
    Screen::baseContainer = oldBaseContainer;
}