From dc9418ab4ca9de3c4cf47c8636c3d42da9614807 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sun, 29 Nov 2009 09:29:26 +0000 Subject: [PATCH] Added dialogue box implementation --- Makefile | 4 +++- dialogue_box.cpp | 19 +++++++++++++++++++ dialogue_box.hh | 24 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 dialogue_box.cpp create mode 100644 dialogue_box.hh diff --git a/Makefile b/Makefile index 1135373..5a4ae89 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 +dialogue_box.oo: dialogue_box.cpp dialogue_box.hh menu.hh Makefile + main.oo: menu.hh utils.hh sdl_ttf_font.hh Makefile menu: $(OBJS) diff --git a/dialogue_box.cpp b/dialogue_box.cpp new file mode 100644 index 0000000..ee95640 --- /dev/null +++ b/dialogue_box.cpp @@ -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; +} diff --git a/dialogue_box.hh b/dialogue_box.hh new file mode 100644 index 0000000..a112669 --- /dev/null +++ b/dialogue_box.hh @@ -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__ */