2009-11-29 10:29:26 +01:00
|
|
|
#include "dialogue_box.hh"
|
|
|
|
|
2009-12-31 14:25:46 +01:00
|
|
|
void DialogueListener::escapeCallback(DialogueBox *which, int selected)
|
|
|
|
{
|
|
|
|
Gui::gui->popDialogueBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogueListener::selectCallback(DialogueBox *which, int selected)
|
|
|
|
{
|
|
|
|
Gui::gui->popDialogueBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogueBox::DialogueBox(const char *msgs[], int cancel) : Menu(NULL), ListenerManager()
|
2009-11-29 10:29:26 +01:00
|
|
|
{
|
|
|
|
this->m_cancel = cancel;
|
|
|
|
|
2009-12-31 14:25:46 +01:00
|
|
|
this->setFont(Gui::gui->default_font);
|
|
|
|
this->setSelectedBackground(NULL, NULL, NULL,
|
|
|
|
Gui::gui->bg_left, Gui::gui->bg_middle,
|
|
|
|
Gui::gui->bg_right);
|
|
|
|
|
2009-11-29 10:29:26 +01:00
|
|
|
this->setText(msgs, NULL);
|
2009-12-05 13:04:00 +01:00
|
|
|
/* Place on the second to last entry */
|
|
|
|
this->cur_sel = this->n_entries - 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
int DialogueBox::selectNext(event_t ev)
|
|
|
|
{
|
2009-12-31 14:25:46 +01:00
|
|
|
printf("Al vobb: %d!\n", ev);
|
2009-12-05 13:04:00 +01:00
|
|
|
/* No up/down movement please! */
|
|
|
|
if (ev == KEY_UP || ev == KEY_DOWN)
|
|
|
|
return this->cur_sel;
|
|
|
|
return Menu::selectNext(ev);
|
2009-11-29 10:29:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DialogueBox::selectCallback(int which)
|
|
|
|
{
|
2009-12-31 14:25:46 +01:00
|
|
|
for (int i = 0; i < this->nListeners(); i++)
|
|
|
|
if (this->listeners[i])
|
|
|
|
((DialogueListener*)this->listeners[i])->selectCallback(this,
|
|
|
|
this->p_submenus[0].sel);
|
2009-11-29 10:29:26 +01:00
|
|
|
}
|
|
|
|
|
2009-12-05 13:04:00 +01:00
|
|
|
void DialogueBox::hoverCallback(int which)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-11-29 10:29:26 +01:00
|
|
|
void DialogueBox::escapeCallback(int which)
|
|
|
|
{
|
2009-12-31 14:25:46 +01:00
|
|
|
for (int i = 0; i < this->nListeners(); i++)
|
|
|
|
if (this->listeners[i])
|
|
|
|
((DialogueListener*)this->listeners[i])->selectCallback(this,
|
|
|
|
this->p_submenus[0].sel);
|
2009-11-29 10:29:26 +01:00
|
|
|
}
|
2009-12-31 14:25:46 +01:00
|
|
|
|
|
|
|
void DialogueBox::draw(SDL_Surface *where)
|
|
|
|
{
|
|
|
|
int d_x = where->w / 2 - Gui::gui->dialogue_bg->w / 2;
|
|
|
|
int d_y = where->h / 2 - Gui::gui->dialogue_bg->h / 2;
|
|
|
|
|
|
|
|
SDL_Rect dst = (SDL_Rect){d_x, d_y,
|
|
|
|
Gui::gui->dialogue_bg->w, Gui::gui->dialogue_bg->h};
|
|
|
|
SDL_BlitSurface(Gui::gui->dialogue_bg, NULL, where, &dst);
|
|
|
|
|
|
|
|
Menu::draw(where, d_x + 10, d_y + 10,
|
|
|
|
Gui::gui->dialogue_bg->w - 10, Gui::gui->dialogue_bg->h - 10);
|
|
|
|
}
|
|
|
|
|