Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/menu.cc')
-rw-r--r--src/ui/menu.cc47
1 files changed, 24 insertions, 23 deletions
diff --git a/src/ui/menu.cc b/src/ui/menu.cc
index af9929c..2a1829f 100644
--- a/src/ui/menu.cc
+++ b/src/ui/menu.cc
@@ -10,22 +10,23 @@
#include "ui/menu.h"
#include "ui/ui.h"
-namespace ui {
+namespace ui
+{
Menu::Menu(Window *parent, const char *label) : Window(parent)
{
set_label(label);
set_border(false);
-
+
menu_element_width = 256.0f;
menu_element_height = 48.0f;
menu_element_margin = 24.0f;
-
+
menu_background = new Bitmap(this);
menu_container = new Window(this);
menu_container->set_border(true);
menu_container->set_background(true);
-
+
menu_container->set_label("container");
}
@@ -38,41 +39,41 @@ void Menu::load()
{
std::string filename("menus/");
filename.append(label());
-
+
filesystem::IniFile ini;
-
+
ini.open(filename);
-
+
if (!ini.is_open()) {
con_error << "Could not open " << ini.name() << std::endl;
return;
}
-
+
std::string strval;
Button *button = 0;
Label *label = 0;
while (ini.getline()) {
if (ini.got_section()) {
-
+
//con_debug << " " << ini.name() << " [" << ini.section() << "]" << std::endl;
-
+
if (ini.got_section("menu")) {
} else if (ini.got_section("button")) {
button = add_button();
-
+
} else if (ini.got_section("label")) {
label = add_label();
-
+
} else if (ini.got_section()) {
ini.unknown_section();
}
-
+
} else if (ini.got_key()) {
-
+
//con_debug << " " << ini.name() << " " << ini.key() << "=" << ini.value() << std::endl;
-
+
if (ini.in_section("menu")) {
if (ini.got_key_string("background", strval)) {
set_background(strval.c_str());
@@ -88,10 +89,10 @@ void Menu::load()
} else if (ini.in_section("button")) {
if (ini.got_key_string("text", strval)) {
button->set_text(strval);
-
+
} else if (ini.got_key_string("command", strval)) {
button->set_command(strval);
-
+
} else if (ini.got_key_string("align", strval)) {
aux::to_label(strval);
if (strval.compare("left") == 0) {
@@ -99,7 +100,7 @@ void Menu::load()
} else if (strval.compare("center") == 0) {
button->set_alignment(AlignCenter);
} else if (strval.compare("right") == 0) {
- button->set_alignment(AlignRight | AlignVCenter);
+ button->set_alignment(AlignRight | AlignVCenter);
} else {
ini.unknown_value();
}
@@ -124,10 +125,10 @@ void Menu::load()
ini.unkown_key();
}
}
-
+
}
}
-
+
con_debug << " " << ini.name() << " " << children().size() << " widgets" << std::endl;
ini.close();
}
@@ -153,9 +154,9 @@ Button *Menu::add_button(char const *text, char const *command)
void Menu::resize()
{
- size().assign(parent()->size());
- menu_background->size().assign(size());
-
+ set_size(parent()->size());
+ menu_background->set_size(size());
+
float n = (float) menu_container->children().size();
menu_container->set_size(1.5f * menu_element_width, n * (menu_element_height + menu_element_margin) + menu_element_height);
menu_container->set_location(menu_element_width * 0.25, (height() - menu_container->height()) / 2.0f);