Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/entitymenu.cc')
-rw-r--r--src/client/entitymenu.cc61
1 files changed, 25 insertions, 36 deletions
diff --git a/src/client/entitymenu.cc b/src/client/entitymenu.cc
index d2b3f27..ee1d373 100644
--- a/src/client/entitymenu.cc
+++ b/src/client/entitymenu.cc
@@ -4,24 +4,18 @@
the terms of the GNU General Public License version 2
*/
+#include "client/entitymenu.h"
+
#include "ui/ui.h"
-#include "ui/button.h"
#include "ui/paint.h"
-#include "client/entitymenu.h"
namespace client
{
-EntityMenu::EntityMenu(ui::Widget *parent, const char * label) : ui::Window(parent)
+EntityMenu::EntityMenu(ui::Widget *parent, const char * label) : ButtonMenu(parent, label)
{
set_border(false);
set_background(false);
- if (label)
- set_label(label);
- else
- set_label("entitymenu");
-
- menu_container = new ui::Container(this);
menu_generated_entity = 0;
hide();
}
@@ -30,21 +24,8 @@ EntityMenu::~EntityMenu()
{
}
-void EntityMenu::resize()
-{
- set_size(parent()->size());
- menu_container->set_location(ui::UI::elementsize.height(), (height() - menu_container->height()) / 2.0f);
-}
-
-void EntityMenu::clear()
-{
- remove_children();
-}
-
void EntityMenu::generate(core::Entity *entity, const char *menulabel)
{
- using namespace ui;
-
menu_generated_menu.clear();
menu_generated_entity = entity;
@@ -62,7 +43,6 @@ void EntityMenu::generate(core::Entity *entity, const char *menulabel)
//con_debug << "generating menu " << entity->label() << " " << menulabel << std::endl;
clear();
- menu_container = new Container(this);
core::MenuDescription *menudescr = 0;
for (core::Entity::Menus::iterator it = entity->menus().begin(); it != entity->menus().end(); it++) {
@@ -72,17 +52,27 @@ void EntityMenu::generate(core::Entity *entity, const char *menulabel)
}
if (!menudescr) {
- menu_container->event_resize();
- resize();
+ event_resize();
return;
}
- if (menudescr->text().size()) {
- Label *label = new Label(menu_container);
- label->set_text(menudescr->text());
- label->set_alignment(AlignCenter);
- label->set_border(false);
+ if (menudescr->text().size()) {
+ std:: string title (entity->name());
+ aux::to_uppercase(title);
+ ui::Label *label;
+
+ label = add_label(title.c_str());
+ label->set_alignment(ui::AlignCenter);
label->set_font(ui::root()->font_large());
+ label->set_border(false);
+ label->set_border(false);
+
+ label = add_label(menudescr->text().c_str());
+ label->set_alignment(ui::AlignCenter);
+ label->set_font(ui::root()->font_small());
+ label->set_border(false);
+ label->set_border(false);
+
}
for (core::MenuDescription::Buttons::iterator it = menudescr->buttons().begin(); it != menudescr->buttons().end(); it++) {
@@ -153,23 +143,22 @@ void EntityMenu::generate(core::Entity *entity, const char *menulabel)
}
- Button *button = new Button(menu_container, buttondescr->text().c_str(), result.c_str());
+ ui::Button *button = add_button(buttondescr->text().c_str(), result.c_str());
switch (buttondescr->alignment()) {
case core::ButtonDescription::Center:
- button->set_alignment(AlignCenter);
+ button->set_alignment(ui::AlignCenter);
break;
case core::ButtonDescription::Left:
- button->set_alignment(AlignLeft | AlignVCenter);
+ button->set_alignment(ui::AlignLeft | ui::AlignVCenter);
break;
case core::ButtonDescription::Right:
- button->set_alignment(AlignRight | AlignVCenter);
+ button->set_alignment(ui::AlignRight | ui::AlignVCenter);
break;
}
}
- menu_container->event_resize();
- resize();
+ event_resize();
}
bool EntityMenu::on_keypress(const int key, const unsigned int modifier)