Added dialogue box implementation

This commit is contained in:
simon.kagstrom 2009-11-29 09:29:26 +00:00
parent 1989da1069
commit dc9418ab4c
3 changed files with 46 additions and 1 deletions

View File

@ -1,4 +1,4 @@
OBJS=menu.oo main.oo utils.oo frodo_menu.oo OBJS=menu.oo main.oo utils.oo frodo_menu.oo dialogue_box.oo
all: menu all: menu
@ -11,6 +11,8 @@ frodo_menu.oo: frodo_menu.cpp frodo_menu.hh font.hh menu.hh Makefile
utils.oo: utils.cpp utils.hh Makefile utils.oo: utils.cpp utils.hh Makefile
dialogue_box.oo: dialogue_box.cpp dialogue_box.hh menu.hh Makefile
main.oo: menu.hh utils.hh sdl_ttf_font.hh Makefile main.oo: menu.hh utils.hh sdl_ttf_font.hh Makefile
menu: $(OBJS) menu: $(OBJS)

19
dialogue_box.cpp Normal file
View File

@ -0,0 +1,19 @@
#include "dialogue_box.hh"
DialogueBox::DialogueBox(Font *font, const char *msgs[], int cancel) : Menu(font)
{
this->m_selected = -1;
this->m_cancel = cancel;
this->setText(msgs, NULL);
}
void DialogueBox::selectCallback(int which)
{
this->m_selected = this->p_submenus[0].sel;
}
void DialogueBox::escapeCallback(int which)
{
this->m_selected = this->m_cancel;
}

24
dialogue_box.hh Normal file
View File

@ -0,0 +1,24 @@
#ifndef __DIALOGUE_BOX_HH__
#define __DIALOGUE_BOX_HH__
#include "menu.hh"
class DialogueBox : public Menu
{
DialogueBox(Font *font, const char *msgs[], int cancel = 1);
virtual void selectCallback(int which);
virtual void escapeCallback(int which);
int selected()
{
return this->m_selected;
}
private:
int m_selected;
int m_cancel;
};
#endif /* __DIALOGUE_BOX_HH__ */