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')
-rw-r--r--src/client/Makefile.am7
-rw-r--r--src/client/client.cc177
-rw-r--r--src/client/client.h9
-rw-r--r--src/client/entitymenu.cc93
-rw-r--r--src/client/entitymenu.h42
-rw-r--r--src/client/hud.cc218
-rw-r--r--src/client/keyboard.cc4
-rw-r--r--src/client/map.cc9
-rw-r--r--src/client/map.h4
-rw-r--r--src/client/playerview.cc127
-rw-r--r--src/client/playerview.h20
-rw-r--r--src/client/worldview.h3
12 files changed, 556 insertions, 157 deletions
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index d617b52..e5afbb7 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -7,9 +7,9 @@ else
noinst_LTLIBRARIES = libclient.la
endif
-libclient_la_SOURCES = action.cc chat.cc client.cc clientext.cc hud.cc \
- infowidget.cc input.cc joystick.cc key.cc keyboard.cc map.cc notifications.cc \
- playerview.cc soundext.cc targets.cc video.cc worldview.cc
+libclient_la_SOURCES = action.cc chat.cc client.cc clientext.cc entitymenu.cc \
+ hud.cc infowidget.cc input.cc joystick.cc key.cc keyboard.cc map.cc \
+ notifications.cc playerview.cc soundext.cc targets.cc video.cc worldview.cc
libclient_la_CFLAGS = $(LIBSDL_CFLAGS) $(GL_CFLAGS)
libclient_la_LDFLAGS = -avoid-version -no-undefined $(GL_LIBS) $(LIBSDL_LIBS)
@@ -19,3 +19,4 @@ noinst_HEADERS = action.h chat.h client.h clientext.h hud.h input.h joystick.h \
libclient_la_LIBADD = $(top_builddir)/src/core/libcore.la $(top_builddir)/src/audio/libaudio.la \
$(top_builddir)/src/render/librender.la $(top_builddir)/src/ui/libui.la
+_SOURCES = entitymenu.h
diff --git a/src/client/client.cc b/src/client/client.cc
index 4533f84..df56700 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -113,11 +113,26 @@ void Client::init(int count, char **arguments)
func = core::Func::add("snd_restart", Client::func_snd_restart);
func->set_info("restart audio subsystem");
+ func = core::Func::add("list_ui", func_list_ui);
+ func->set_info("list user interface widgets");
+
+ func = core::Func::add("list_menu", func_list_menu);
+ func->set_info("list available menus");
+
+ func = core::Func::add("ui", func_ui);
+ func->set_info("[command] user interface functions");
+
+ func = core::Func::add("ui_restart", func_ui_restart);
+ func->set_info("reload user interface files");
+
+ func = core::Func::add("ui_console", func_ui_console);
+ func->set_info("toggle console");
+
func = core::Func::add("ui_chat", Client::func_ui_chat);
func->set_info("toggle chat window");
- func = core::Func::add("ui_chatsmall", Client::func_ui_chatsmall);
- func->set_info("toggle small chat window");
+ func = core::Func::add("ui_chatbar", Client::func_ui_chatbar);
+ func->set_info("toggle chat bar");
func = core::Func::add("ui_map", Client::func_ui_map);
func->set_info("toggle map");
@@ -125,6 +140,9 @@ void Client::init(int count, char **arguments)
func = core::Func::add("ui_menu", Client::func_ui_menu);
func->set_info("toggle main menu");
+ func = core::Func::add("menu", func_menu);
+ func->set_info("[command] menu functions");
+
previous_timestamp = 0;
}
@@ -199,21 +217,13 @@ void Client::frame(unsigned long timestamp)
// show the join menu when player does not control an entity
} else if (core::game()->time() && !core::localcontrol()) {
ui::root()->show_menu("join");
-
- // show the view menu when docked
- } else if (core::localcontrol() && core::localplayer()->view()) {
- ui::root()->show_menuview("main");
}
-
} else {
if (core::localcontrol()) {
+
// hide join menu
if (ui::root()->active()->label().compare("join") == 0) {
- ui::root()->hide_menu();
-
- // hide view menu
- } else if (!core::localplayer()->view() && (ui::root()->active()->label().compare("view") == 0)) {
- ui::root()->hide_menu();
+ ui::root()->hide_menu();
}
}
}
@@ -231,10 +241,16 @@ void Client::shutdown()
core::Func::remove("r_restart");
core::Func::remove("snd_restart");
+ core::Func::remove("list_menu");
+ core::Func::remove("list_ui");
+ core::Func::remove("ui");
+ core::Func::remove("ui_restart");
+ core::Func::remove("ui_console");
core::Func::remove("ui_chat");
- core::Func::remove("ui_chatsmall");
+ core::Func::remove("ui_chatbar");
core::Func::remove("ui_map");
core::Func::remove("ui_menu");
+ core::Func::remove("menu");
audio::shutdown();
@@ -362,26 +378,95 @@ void Client::func_r_restart(std::string const &args)
video::restart();
}
+/* ---- func_ui ---------------------------------------------------- */
+
+void Client::func_list_ui(std::string const &args)
+{
+ if (ui::root()) {
+ ui::root()->list();
+ }
+}
+
+void Client::func_ui_restart(std::string const &args)
+{
+ if (ui::root()) {
+ ui::root()->load_menus();
+ ui::root()->load_settings();
+ ui::root()->apply_render_options();
+ }
+}
+
+
+void Client::func_ui_console(std::string const &args)
+{
+ ui::console()->toggle();
+}
+
+void Client::func_list_menu(std::string const &args)
+{
+ if (ui::root()) {
+ ui::root()->list_menus();
+ }
+}
+
+void Client::func_ui_help()
+{
+ con_print << "^BUser interface functions" << std::endl;
+ con_print << " ui help show this help" << std::endl;
+ con_print << " ui debug toggle debug mode" << std::endl;
+ con_print << " ui list list widgets" << std::endl;
+ con_print << " ui restart reload user interface files" << std::endl;
+}
+
+void Client::func_ui(std::string const &args)
+{
+ if (!ui::root()) {
+ con_warn << "User Interface not available!" << std::endl;
+ return;
+ }
+
+ if (!args.size()) {
+ func_ui_help();
+ return;
+ }
+ std::stringstream argstr(args);
+ std::string command;
+ argstr >> command;
+ aux::to_label(command);
+
+ if (command.compare("help") == 0) {
+ func_ui_help();
+ } else if (command.compare("debug") == 0) {
+ ui::UI::ui_debug = !ui::UI::ui_debug;
+ } else if (command.compare("list") == 0) {
+ ui::root()->list();
+ } else if (command.compare("restart") == 0) {
+ ui::root()->load_menus();
+ ui::root()->load_settings();
+ ui::root()->apply_render_options();
+ } else {
+ func_ui_help();
+ }
+}
+
void Client::func_ui_chat(std::string const &args)
{
if (client()->connected() && client()->worldview()->playerview()->visible()) {
- client()->worldview()->playerview()->chat()->set_small_view(false);
- client()->worldview()->playerview()->chat()->toggle();
+ client()->worldview()->playerview()->toggle_chat();
}
}
-void Client::func_ui_chatsmall(std::string const &args)
+void Client::func_ui_chatbar(std::string const &args)
{
if (client()->connected() && client()->worldview()->playerview()->visible()) {
- client()->worldview()->playerview()->chat()->set_small_view(true);
- client()->worldview()->playerview()->chat()->toggle();
+ client()->worldview()->playerview()->toggle_chatbar();
}
}
void Client::func_ui_map(std::string const &args)
{
if (client()->connected() && client()->worldview()->playerview()->visible()) {
- client()->worldview()->playerview()->map()->toggle();
+ client()->worldview()->playerview()->toggle_map();
}
}
@@ -403,5 +488,59 @@ void Client::func_ui_menu(std::string const &args)
}
}
+void Client::func_menu(std::string const &args)
+{
+ if (!ui::root()) {
+ con_warn << "User Interface not available!" << std::endl;
+ return;
+ }
+
+ if (!args.size()) {
+ con_print << "^Bmenu functions" << std::endl;
+ con_print << " menu help show this help" << std::endl;
+ con_print << " menu list list available menus" << std::endl;
+ con_print << " menu [name] show a menu" << std::endl;
+ con_print << " menu back return to the previous menu" << std::endl;
+ con_print << " menu previous return to the previous menu" << std::endl;
+ con_print << " menu close close the current menu" << std::endl;
+ con_print << " menu hide hide the current menu" << std::endl;
+ ui::root()->list_menus();
+ }
+
+ std::stringstream argstr(args);
+ std::string command;
+ argstr >> command;
+
+ aux::to_label(command);
+
+ if (command.compare("hide") == 0) {
+ ui::root()->hide_menu();
+
+ } else if (command.compare("close") == 0) {
+ ui::root()->hide_menu();
+
+ } else if (command.compare("back") == 0) {
+ ui::root()->previous_menu();
+
+ } else if (command.compare("previous") == 0) {
+ ui::root()->previous_menu();
+
+ } else if (command.compare("list") == 0) {
+ ui::root()->list_menus();
+
+ } else if (command.compare("view") == 0) {
+ if (client()->worldview()) {
+ std::string label;
+ if (!(argstr >> label)) {
+ label.assign("main");
+ }
+ client()->worldview()->playerview()->show_menu(label);
+ }
+ } else {
+ ui::root()->show_menu(command.c_str());
+ }
+}
+
+
} // namespace client
diff --git a/src/client/client.h b/src/client/client.h
index b873a20..375a9ce 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -72,10 +72,17 @@ private:
static void func_snd_restart(std::string const &args);
static void func_r_restart(std::string const &args);
+ static void func_list_ui(std::string const &args);
+ static void func_ui_restart(std::string const &args);
+ static void func_ui_console(std::string const &args);
+ static void func_list_menu(std::string const &args);
+ static void func_ui_help();
+ static void func_ui(std::string const &args);
static void func_ui_chat(std::string const &args);
- static void func_ui_chatsmall(std::string const &args);
+ static void func_ui_chatbar(std::string const &args);
static void func_ui_map(std::string const &args);
static void func_ui_menu(std::string const &args);
+ static void func_menu(std::string const &args);
WorldView *client_worldview;
diff --git a/src/client/entitymenu.cc b/src/client/entitymenu.cc
new file mode 100644
index 0000000..c7df7ab
--- /dev/null
+++ b/src/client/entitymenu.cc
@@ -0,0 +1,93 @@
+/*
+ client/entitymenu.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#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)
+{
+ set_border(false);
+ set_background(false);
+ set_label(label);
+
+ menu_container = new ui::Container(this);
+ hide();
+}
+
+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;
+
+ if (!menulabel)
+ return;
+
+ //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++) {
+ if ((*it)->label().compare(menulabel) == 0) {
+ menudescr = (*it);
+ }
+ }
+
+ if (!menudescr) {
+ menu_container->event_resize();
+ 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);
+ label->set_font(ui::root()->font_large());
+ }
+
+ for (core::MenuDescription::Buttons::iterator it = menudescr->buttons().begin(); it != menudescr->buttons().end(); it++) {
+ core::ButtonDescription *buttondescr = (*it);
+ Button *button = new Button(menu_container, buttondescr->text().c_str(), buttondescr->command().c_str());
+ switch (buttondescr->alignment()) {
+ case core::ButtonDescription::Center:
+ button->set_alignment(AlignCenter);
+ break;
+ case core::ButtonDescription::Left:
+ button->set_alignment(AlignLeft | AlignVCenter);
+ break;
+ case core::ButtonDescription::Right:
+ button->set_alignment(AlignRight | AlignVCenter);
+ break;
+ }
+ }
+
+ menu_container->event_resize();
+ resize();
+}
+
+}
diff --git a/src/client/entitymenu.h b/src/client/entitymenu.h
new file mode 100644
index 0000000..ac5a793
--- /dev/null
+++ b/src/client/entitymenu.h
@@ -0,0 +1,42 @@
+/*
+ client/entitymenu.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_CLIENT_ENTITYMENU_H__
+#define __INCLUDED_CLIENT_ENTITYMENU_H__
+
+#include "core/entity.h"
+#include "ui/container.h"
+#include "ui/label.h"
+#include "ui/window.h"
+
+namespace client
+{
+
+/// entity menus
+class EntityMenu : public ui::Window
+{
+public:
+ /// create a new menu
+ EntityMenu(ui::Widget *parent, const char * label = 0);
+ ~EntityMenu();
+
+ /// generate a menu from menu descriptions
+ void generate(core::Entity *entity, const char *menulabel);
+
+ /// clear the current menu
+ void clear();
+
+protected:
+ /// resize event
+ virtual void resize();
+
+private:
+ ui::Container *menu_container;
+};
+
+}
+
+#endif // __INCLUDED_CLIENT_ENTITYMENU_H__
diff --git a/src/client/hud.cc b/src/client/hud.cc
index beeefd3..014f4df 100644
--- a/src/client/hud.cc
+++ b/src/client/hud.cc
@@ -229,150 +229,142 @@ void HUD::draw()
Text::setcolor('N'); //set normal color
- if(core::localplayer()->view()) {
- Text::setcolor('N'); //set normal color
- Text::draw(render::State::width()-4-Text::fontwidth()*32, render::State::height()-Text::fontheight()*3-4, core::localcontrol()->zone()->name());
+ core::Zone *zone = core::localcontrol()->zone();
- Text::setcolor('B'); //set bold color
- Text::draw(render::State::width() - 4-Text::fontwidth()*32, render::State::height() - Text::fontheight()*2 -4, core::localplayer()->view()->name());
+ // draw targets
+ for (core::Zone::Content::iterator it=zone->content().begin(); it != zone->content().end(); it++) {
+ core::Entity *entity = (*it);
- } else if (core::localcontrol() && core::localcontrol()->zone()) {
- core::Zone *zone = core::localcontrol()->zone();
-
- // draw targets
- for (core::Zone::Content::iterator it=zone->content().begin(); it != zone->content().end(); it++) {
- core::Entity *entity = (*it);
-
- if (targets::is_legal_target(entity)) {
- if (entity == core::localplayer()->mission_target()) {
- draw_target(entity, true);
- } else if (entity == targets::current()) {
- draw_target(entity, true);
- } else if (entity->type() == core::Entity::Controlable) {
- draw_target(entity, false);
- }
+ if (targets::is_legal_target(entity)) {
+ if (entity == core::localplayer()->mission_target()) {
+ draw_target(entity, true);
+ } else if (entity == targets::current()) {
+ draw_target(entity, true);
+ } else if (entity->type() == core::Entity::Controlable) {
+ draw_target(entity, false);
}
}
+ }
- unsigned int state = core::localcontrol()->eventstate();
- if (state) {
- std::stringstream statestr;
- statestr.clear();
- if (state == core::Entity::ImpulseInitiate) {
- statestr << "^FInitializing kinetic impulse drive " << core::localcontrol()->timer();
- } else if (state == core::Entity::Impulse) {
- //statestr << "^FKinetic impulse";
- } else if (state == core::Entity::JumpInitiate) {
- statestr << "^FInitializing hyperspace jump drive "<< core::localcontrol()->timer();
- } else if (state == core::Entity::Jump) {
- statestr << "^FJumping...";
- }
-
- Text::draw(4, render::State::height() - Text::fontheight()*3-4, statestr);
+ unsigned int state = core::localcontrol()->eventstate();
+ if (state) {
+ std::stringstream statestr;
+ statestr.clear();
+ if (state == core::Entity::ImpulseInitiate) {
+ statestr << "^FInitializing kinetic impulse drive " << core::localcontrol()->timer();
+ } else if (state == core::Entity::Impulse) {
+ //statestr << "^FKinetic impulse";
+ } else if (state == core::Entity::JumpInitiate) {
+ statestr << "^FInitializing hyperspace jump drive "<< core::localcontrol()->timer();
+ } else if (state == core::Entity::Jump) {
+ statestr << "^FJumping...";
}
- core::Entity *target = targets::current();
- std::stringstream strdistance;
+ Text::draw(4, render::State::height() - Text::fontheight()*3-4, statestr);
+ }
- if (target) {
- std::stringstream strtarget;
- strtarget << "^B" << target->name() << "\n^B";
+ core::Entity *target = targets::current();
+ std::stringstream strdistance;
- float d = math::distance(core::localcontrol()->location(), target->location())
- - target->radius() - core::localcontrol()->radius();
+ if (target) {
+ std::stringstream strtarget;
+ strtarget << "^B" << target->name() << "\n^B";
- if (d > 0 ) {
- strtarget << "^Ndist:^B ";
- if (d > 100.0f) {
- strtarget << roundf(d * 0.1f) << "km";
- } else {
- strtarget << roundf(d * 100.0f) << "m";
- }
+ float d = math::distance(core::localcontrol()->location(), target->location())
+ - target->radius() - core::localcontrol()->radius();
- if (core::localcontrol()->speed() > 0.1f) {
- strtarget << "^N eta:^B ";
- float eta = floorf(d / core::localcontrol()->speed() );
- if (eta > 60.0f) {
- float etamin = floorf(eta / 60.0f);
- strtarget << etamin << "min ";
- eta -= etamin * 60;
- }
- strtarget << eta << "sec";
- }
+ if (d > 0 ) {
+ strtarget << "^Ndist:^B ";
+ if (d > 100.0f) {
+ strtarget << roundf(d * 0.1f) << "km";
} else {
- strtarget << " --";
+ strtarget << roundf(d * 100.0f) << "m";
}
- strtarget << '\n';
- Text::draw(width() - 4-Text::fontwidth()*30, height() - Text::fontheight()*2 -4, strtarget);
+
+ if (core::localcontrol()->speed() > 0.1f) {
+ strtarget << "^N eta:^B ";
+ float eta = floorf(d / core::localcontrol()->speed() );
+ if (eta > 60.0f) {
+ float etamin = floorf(eta / 60.0f);
+ strtarget << etamin << "min ";
+ eta -= etamin * 60;
+ }
+ strtarget << eta << "sec";
+ }
+ } else {
+ strtarget << " --";
}
+ strtarget << '\n';
+ Text::draw(width() - 4-Text::fontwidth()*30, height() - Text::fontheight()*2 -4, strtarget);
+ }
- // draw player info
- std::stringstream playerinfostr;
- playerinfostr <<"^B" << core::localcontrol()->name() << '\n' << "^Ncredits: " << core::localplayer()->credits();
- Text::draw(width() - 4-Text::fontwidth()*52, height() - Text::fontheight()*2 -4, playerinfostr);
+ // draw player info
+ std::stringstream playerinfostr;
+ playerinfostr <<"^B" << core::localcontrol()->name() << '\n' << "^Ncredits: " << core::localplayer()->credits();
+ Text::draw(width() - 4-Text::fontwidth()*52, height() - Text::fontheight()*2 -4, playerinfostr);
- Textures::bind("bitmaps/hud/thruster_base"); // 316 x 32 bitmap
- gl::color(1, 1, 1, 1);
- gl::begin(gl::Quads);
+ Textures::bind("bitmaps/hud/thruster_base"); // 316 x 32 bitmap
+ gl::color(1, 1, 1, 1);
+ gl::begin(gl::Quads);
- glTexCoord2f(0, 0);
- gl::vertex(4, height() - 4 - 32, 0);
+ glTexCoord2f(0, 0);
+ gl::vertex(4, height() - 4 - 32, 0);
- glTexCoord2f(1, 0);
- gl::vertex(4 + 316, height() - 4 - 32, 0);
+ glTexCoord2f(1, 0);
+ gl::vertex(4 + 316, height() - 4 - 32, 0);
- glTexCoord2f(1, 1);
- gl::vertex(4 + 316, height() - 4 , 0);
+ glTexCoord2f(1, 1);
+ gl::vertex(4 + 316, height() - 4 , 0);
- glTexCoord2f(0, 1);
- gl::vertex(4, height() - 4 , 0);
+ glTexCoord2f(0, 1);
+ gl::vertex(4, height() - 4 , 0);
- gl::end();
+ gl::end();
- float u = core::localcontrol()->thrust();
- if (core::localcontrol()->eventstate() == core::Entity::Impulse) {
- u = 1.0;
- }
+ float u = core::localcontrol()->thrust();
+ if (core::localcontrol()->eventstate() == core::Entity::Impulse) {
+ u = 1.0;
+ }
- if (( u > 0) || (core::localcontrol()->eventstate() == core::Entity::Impulse)) {
+ if (( u > 0) || (core::localcontrol()->eventstate() == core::Entity::Impulse)) {
- if (core::localcontrol()->eventstate() == core::Entity::Impulse) {
- gl::color(0, .8, 0);
- } else {
- float d = math::absf(input::local_thrust - u);
- if (d > 0.1) {
- d = 0.1f;
- }
- gl::color(1, 1, .5f + d * 5.0f);
+ if (core::localcontrol()->eventstate() == core::Entity::Impulse) {
+ gl::color(0, .8, 0);
+ } else {
+ float d = math::absf(input::local_thrust - u);
+ if (d > 0.1) {
+ d = 0.1f;
}
- Textures::bind("bitmaps/hud/thruster_indicator"); // 316 x 32 bitmap
- gl::begin(gl::Quads);
- glTexCoord2f(0, 0);
- gl::vertex(4, height() - 4 - 32, 0);
-
- glTexCoord2f(u, 0);
- gl::vertex(4.0f + u * 316.0f, height() - 4 - 32, 0);
-
- glTexCoord2f(u, 1);
- gl::vertex(4.0f + u * 316.0f, height() - 4 , 0);
-
- glTexCoord2f(0, 1);
- gl::vertex(4, height() - 4 , 0);
-
- gl::end();
+ gl::color(1, 1, .5f + d * 5.0f);
}
+ Textures::bind("bitmaps/hud/thruster_indicator"); // 316 x 32 bitmap
+ gl::begin(gl::Quads);
+ glTexCoord2f(0, 0);
+ gl::vertex(4, height() - 4 - 32, 0);
+
+ glTexCoord2f(u, 0);
+ gl::vertex(4.0f + u * 316.0f, height() - 4 - 32, 0);
- Text::setfont("gui", 14, 24);
- Text::setcolor('B'); //set normal color
+ glTexCoord2f(u, 1);
+ gl::vertex(4.0f + u * 316.0f, height() - 4 , 0);
- std::stringstream speedstr;
- speedstr << "^B" << roundf(core::localcontrol()->speed() * 100.0f);
- Text::draw( 316+4+10, height() - 6 -16 - render::Text::fontwidth() /2, speedstr);
+ glTexCoord2f(0, 1);
+ gl::vertex(4, height() - 4 , 0);
- Text::setfont("gui", 12, 18);
- Text::setcolor('N'); //set normal color
+ gl::end();
}
+ Text::setfont("gui", 14, 24);
+ Text::setcolor('B'); //set normal color
+
+ std::stringstream speedstr;
+ speedstr << "^B" << roundf(core::localcontrol()->speed() * 100.0f);
+ Text::draw( 316+4+10, height() - 6 -16 - render::Text::fontwidth() /2, speedstr);
+
+ Text::setfont("gui", 12, 18);
+ Text::setcolor('N'); //set normal color
+
+
gl::disable(GL_TEXTURE_2D);
}
diff --git a/src/client/keyboard.cc b/src/client/keyboard.cc
index 9c35771..ba67395 100644
--- a/src/client/keyboard.cc
+++ b/src/client/keyboard.cc
@@ -135,7 +135,7 @@ Keyboard::Keyboard()
add_key("q", SDLK_q, 'q', "+rollleft");
add_key("r", SDLK_r, 'r');
add_key("s", SDLK_s, 's', "+reverse");
- add_key("t", SDLK_t, 't', "ui_chatsmall");
+ add_key("t", SDLK_t, 't', "ui_chatbar");
add_key("u", SDLK_u, 'u');
key = add_key("v", SDLK_v, 'v', "view_next");
key->assign(Key::Shift, "view_prev");
@@ -176,7 +176,7 @@ Keyboard::Keyboard()
add_key("pageup", SDLK_PAGEUP);
add_key("pagedown", SDLK_PAGEDOWN);
- add_key("f1", SDLK_F1);
+ add_key("f1", SDLK_F1, 0, "ui_menu");
add_key("f2", SDLK_F2);
add_key("f3", SDLK_F3, 0, "@dock");
key = add_key("f4", SDLK_F4);
diff --git a/src/client/map.cc b/src/client/map.cc
index 7d1536d..35fb6d1 100644
--- a/src/client/map.cc
+++ b/src/client/map.cc
@@ -15,7 +15,7 @@
namespace client {
-Map::Map(ui::Widget *parent) : ui::Widget(parent)
+Map::Map(ui::Widget *parent) : ui::Window(parent)
{
set_label("map");
set_border(true);
@@ -29,7 +29,7 @@ Map::~Map()
void Map::hide()
{
- ui::Widget::hide();
+ ui::Window::hide();
map_hover = 0;
}
@@ -182,6 +182,11 @@ bool Map::on_keypress(const int key, const unsigned int modifier)
if ((hover()) && (key == 512 + SDL_BUTTON_LEFT)) {
targets::select_target(hover());
return true;
+ } else if (key == SDLK_ESCAPE) {
+ if (visible()) {
+ hide();
+ return true;
+ }
}
return false;
diff --git a/src/client/map.h b/src/client/map.h
index c7c1c29..d75024a 100644
--- a/src/client/map.h
+++ b/src/client/map.h
@@ -7,11 +7,11 @@
#ifndef __INCLUDED_CLIENT_MAP_H__
#define __INCLUDED_CLIENT_MAP_H__
-#include "ui/widget.h"
+#include "ui/window.h"
namespace client {
-class Map : public ui::Widget
+class Map : public ui::Window
{
public:
Map(ui::Widget *parent = 0);
diff --git a/src/client/playerview.cc b/src/client/playerview.cc
index 703f392..f129a1e 100644
--- a/src/client/playerview.cc
+++ b/src/client/playerview.cc
@@ -4,6 +4,7 @@
the terms and conditions of the GNU General Public License version 2
*/
+#include "audio/audio.h"
#include "client/playerview.h"
#include "ui/ui.h"
@@ -14,20 +15,27 @@ PlayerView::PlayerView(ui::Widget *parent) : ui::Widget(parent)
set_label("playerview");
set_border(false);
set_background(false);
+
+ view_lastentity = 0;
label_zonename = new ui::Label(this);
label_zonename->set_alignment(ui::AlignCenter);
label_zonename->set_background(true);
+ label_zonename->set_font(ui::root()->font_large());
label_viewname = new ui::Label(this);
label_viewname->set_alignment(ui::AlignCenter);
label_viewname->set_background(true);
+ label_viewname->set_font(ui::root()->font_large());
view_notify = new Notifications(this);
view_chat = new Chat(this);
view_map = new Map(this);
view_hud = new HUD(this);
+ view_menu = new EntityMenu(this);
+
view_hud->lower();
+ view_menu->raise();
}
PlayerView::~PlayerView()
@@ -41,6 +49,9 @@ void PlayerView::clear()
view_chat->hide();
view_map->hide();
+ view_menu->hide();
+
+ view_lastentity = 0;
}
void PlayerView::event_text(const std::string & text)
@@ -49,6 +60,60 @@ void PlayerView::event_text(const std::string & text)
view_notify->event_text(text);
}
+void PlayerView::toggle_map()
+{
+
+ if (!map()->visible()) {
+ if(chat()->visible() && !chat()->small_view())
+ chat()->hide();
+
+ if (view_menu->visible())
+ view_menu->hide();
+ }
+
+ map()->toggle();
+ audio::play("ui/menu");
+
+ if (map()->visible() && chat()->visible() && chat()->small_view()) {
+ chat()->raise();
+ }
+}
+
+void PlayerView::toggle_chat()
+{
+ if (!chat()->visible()) {
+ if(map()->visible())
+ map()->hide();
+
+ if (view_menu->visible())
+ view_menu->hide();
+ }
+ chat()->set_small_view(false);
+ chat()->toggle();
+ audio::play("ui/menu");
+}
+
+void PlayerView::toggle_chatbar()
+{
+ chat()->set_small_view(true);
+ chat()->toggle();
+}
+
+void PlayerView::show_menu(const std::string & label)
+{
+ if (!core::localplayer()->view())
+ return;
+
+ if (!core::localplayer()->view()->menus().size())
+ return;
+
+ view_menu->generate(core::localplayer()->view(), label.c_str());
+ view_menu->show();
+
+ if (chat()->visible() && chat()->small_view())
+ chat()->raise();
+}
+
void PlayerView::resize()
{
//const float largemargin = ui::UI::elementsize.width() * 0.25;
@@ -68,15 +133,62 @@ void PlayerView::resize()
view_notify->set_geometry(view_map->location(), view_map->size());
// reposition labels
- label_viewname->set_size(ui::UI::elementsize.width(), ui::UI::elementsize.height());
+ label_viewname->set_size(ui::UI::elementsize.width() * 1.5f, ui::UI::elementsize.height());
label_viewname->set_location(smallmargin, smallmargin * 0.5f);
- label_zonename->set_size(ui::UI::elementsize.width(), ui::UI::elementsize.height());
+ label_zonename->set_size(ui::UI::elementsize.width() * 1.5f, ui::UI::elementsize.height());
label_zonename->set_location(width() - label_zonename->width() - smallmargin, height() - label_zonename->height() - smallmargin * 0.5f);
}
void PlayerView::draw()
{
+ if (core::localplayer()->view()) {
+
+ // docking view
+ if (core::localplayer()->view()->menus().size()) {
+
+ // entity with menus
+ label_viewname->show();
+ label_viewname->set_text(core::localplayer()->view()->name());
+
+ label_zonename->show();
+
+ if (view_lastentity != core::localplayer()->view()) {
+ // initialy show the menu
+ show_menu("main");
+ map()->hide();
+ chat()->hide();
+ audio::play("ui/menu");
+ } else if (!view_menu->visible() && !map()->visible() && (!chat()->visible() || chat()->small_view()) ) {
+ // show the menu if there's no other window open
+ menu()->show();
+ audio::play("ui/menu");
+ }
+
+ } else {
+ // entity without menus, plain view
+ this->hide();
+ return;
+ }
+
+ view_hud->hide();
+ view_lastentity = core::localplayer()->view();
+
+ } else {
+ if (view_menu->visible()) {
+ view_menu->hide();
+ }
+
+ label_viewname->hide();
+ label_zonename->set_visible(view_map->visible());
+ view_hud->show();
+ view_lastentity = 0;
+ }
+
+ if (label_zonename->visible()) {
+ label_zonename->set_text(core::localplayer()->zone()->name());
+ }
+
//const float largemargin = ui::UI::elementsize.width() * 0.25;
const float smallmargin = ui::UI::elementsize.height();
@@ -88,17 +200,6 @@ void PlayerView::draw()
view_chat->set_geometry(view_map->location(), view_map->size());
}
view_chat->event_resize();
-
- if (core::localplayer()->view()) {
- label_viewname->show();
- label_zonename->show();
- } else {
- label_viewname->hide();
- label_zonename->set_visible(view_map->visible());
- }
-
- if (label_zonename->visible())
- label_zonename->set_text(core::localplayer()->zone()->name());
}
}
diff --git a/src/client/playerview.h b/src/client/playerview.h
index e5cb238..9cf8a94 100644
--- a/src/client/playerview.h
+++ b/src/client/playerview.h
@@ -8,6 +8,7 @@
#define __INCLUDED_CLIENT_PLAYERVIEW_H__
#include "client/chat.h"
+#include "client/entitymenu.h"
#include "client/hud.h"
#include "client/map.h"
#include "client/notifications.h"
@@ -27,18 +28,35 @@ public:
void event_text(const std::string & text);
+ /// toggle map window
+ void toggle_map();
+
+ /// togge chat window
+ void toggle_chat();
+
+ /// toggle chat bar
+ void toggle_chatbar();
+
+ /// show entity menus
+ void show_menu(const std::string & label);
+
inline Map *map() { return view_map; }
inline Chat *chat() { return view_chat; }
inline Notifications *notify() { return view_notify; }
+ inline EntityMenu *menu() { return view_menu; }
protected:
virtual void draw();
virtual void resize();
+
private:
Notifications *view_notify;
HUD *view_hud;
Chat *view_chat;
Map *view_map;
+ EntityMenu *view_menu;
+
+ core::Entity *view_lastentity;
ui::Label *label_zonename;
ui::Label *label_viewname;
@@ -48,4 +66,4 @@ private:
}
-#endif // __INCLUDED_CLIENT_PLAYERVIEW_H__ \ No newline at end of file
+#endif // __INCLUDED_CLIENT_PLAYERVIEW_H__
diff --git a/src/client/worldview.h b/src/client/worldview.h
index a83fb81..7921da2 100644
--- a/src/client/worldview.h
+++ b/src/client/worldview.h
@@ -40,4 +40,5 @@ private:
}
-#endif // __INCLUDED_CLIENT_PLAYERVIEW_H__ \ No newline at end of file
+#endif // __INCLUDED_CLIENT_PLAYERVIEW_H__
+