Exemple #1
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;
}
Exemple #2
0
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();
}
Exemple #3
0
void GameLoaderSaver::DialogMainLoop()
{
	Gui::Fixed *background = new Gui::Fixed(float(Gui::Screen::GetWidth()), float(Gui::Screen::GetHeight()));
	background->SetTransparency(false);
	background->SetBgColor(0,0,0,1.0);

	Gui::Fixed *outer = new Gui::Fixed(410, 410);
	outer->SetTransparency(false);
	background->Add(outer, 195, 45);

	Gui::Fixed *inner = new Gui::Fixed(400, 400);
	outer->Add(inner, 5, 5);

	FileSelectorWidget *fileSelector = new FileSelectorWidget(m_type, m_title);
	inner->Add(fileSelector, 0, 0);

	fileSelector->onClickAction.connect(sigc::mem_fun(this, &GameLoaderSaver::OnClickLoad));
	fileSelector->onClickCancel.connect(sigc::mem_fun(this, &GameLoaderSaver::OnClickBack));

	Gui::Screen::AddBaseWidget(background, 0, 0);
	background->ShowAll();

	m_done = false;
	while (!m_done)
		Gui::MainLoopIteration();

	Gui::Screen::RemoveBaseWidget(background);
	delete background;
}