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/ui.cc')
-rw-r--r--src/ui/ui.cc48
1 files changed, 46 insertions, 2 deletions
diff --git a/src/ui/ui.cc b/src/ui/ui.cc
index 4774387..7d57ce0 100644
--- a/src/ui/ui.cc
+++ b/src/ui/ui.cc
@@ -16,6 +16,7 @@
#include "ui/button.h"
#include "ui/label.h"
#include "ui/menu.h"
+#include "ui/menuview.h"
#include "ui/paint.h"
#include "ui/ui.h"
#include "ui/widget.h"
@@ -27,6 +28,9 @@ namespace ui
bool UI::ui_debug = false;
+float UI::elementmargin = 16;
+math::Vector2f UI::elementsize(256, 48);
+
UI *global_ui = 0;
void func_list_ui(std::string const &args)
@@ -137,6 +141,12 @@ void func_menu(std::string const &args)
} else if (command.compare("list") == 0) {
root()->list_menus();
+ } else if (command.compare("view") == 0) {
+ std::string label;
+ if (!(argstr >> label)) {
+ label.assign("main");
+ }
+ root()->show_menuview(label);
} else {
root()->show_menu(command.c_str());
}
@@ -244,6 +254,8 @@ void UI::load()
}
ui_menus.clear();
+ add_menu(new MenuView(this, "view"));
+
ui_mouse_focus = this;
ui_active_menu = 0;
@@ -261,6 +273,11 @@ void UI::load()
std::string strval;
math::Color color;
Menu *menu = 0;
+
+ float w = elementsize.width();
+ float h = elementsize.height();
+ float m = elementmargin;
+
while (ini.getline()) {
@@ -291,6 +308,12 @@ void UI::load()
add_menu(menu);
menu->load();
continue;
+ } else if (ini.got_key_float("elementwidth", w)) {
+ elementsize.assign(w, h);
+ } else if (ini.got_key_float("elementheight", h)) {
+ elementsize.assign(w, h);
+ } else if (ini.got_key_float("elementmargin", m)) {
+ elementmargin = m;
} else {
ini.unkown_key();
}
@@ -402,6 +425,20 @@ void UI::add_menu(Window *menu)
}
+void UI::show_menuview(const std::string &label)
+{
+ if (!core::localplayer()->view())
+ return;
+
+ if (!core::localplayer()->view()->menus().size())
+ return;
+
+ MenuView *menuview = static_cast<MenuView *>(find_menu("view"));
+ menuview->generate(core::localplayer()->view(), label.c_str());
+
+ show_menu("view");
+}
+
void UI::show_menu(const char *label)
{
Window *menu = find_menu(label);
@@ -501,8 +538,15 @@ bool UI::on_keypress(const int key, const unsigned int modifier)
case SDLK_ESCAPE:
if (active()) {
- hide_menu();
- audio::play("ui/menu");
+ if (active()->label().compare("view") == 0) {
+ if (core::application()->connected()) {
+ show_menu("game");
+ audio::play("ui/menu");
+ }
+ } else {
+ hide_menu();
+ audio::play("ui/menu");
+ }
} else {
if (core::application()->connected()) {
show_menu("game");