Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-04-26 15:52:37 +0000
committerStijn Buys <ingar@osirion.org>2009-04-26 15:52:37 +0000
commitada263d9924c9014b445d0b855f52f1ef75d39dd (patch)
tree1298500ca196dcbda4c3aaf7913609d93dee6e9a /src/client
parent8861bf21e9821f7adcbbafcb9f72e0f1b8f59344 (diff)
added worldview icons, updated map
Diffstat (limited to 'src/client')
-rw-r--r--src/client/map.cc70
-rw-r--r--src/client/map.h3
-rw-r--r--src/client/playerview.cc36
-rw-r--r--src/client/playerview.h3
-rw-r--r--src/client/worldview.cc22
-rw-r--r--src/client/worldview.h5
6 files changed, 74 insertions, 65 deletions
diff --git a/src/client/map.cc b/src/client/map.cc
index f10b03c..805957c 100644
--- a/src/client/map.cc
+++ b/src/client/map.cc
@@ -40,6 +40,13 @@ Map::Map(ui::Widget *parent) : ui::Window(parent)
set_background(true);
set_font(ui::root()->font_small());
+ map_targetlabel = new ui::Label(this);
+ map_targetlabel->set_label("targetlabel");
+ map_targetlabel->set_background(false);
+ map_targetlabel->set_border(false);
+ map_targetlabel->set_font(ui::root()->font_large());
+ map_targetlabel->set_alignment(ui::AlignCenter);
+
map_target = 0;
map_hover = 0;
hide();
@@ -60,7 +67,11 @@ void Map::show()
{
ui::Window::show();
map_hover = 0;
- map_target = targets::current();
+ if (core::localplayer()->view()) {
+ map_target = core::localplayer()->view();
+ } else {
+ map_target = targets::current();
+ }
}
void Map::toggle()
@@ -74,9 +85,7 @@ void Map::toggle()
void Map::draw()
{
const float margin = font()->width() * 2.0f;
- const float w = width() - margin * 2.0f;
- const float h = height() - margin * 2.0f;
- const float s = math::min(w, h);
+ const float s = ui::UI::elementsize.width() * 2.0f;
const float blue = 0.8f;
const float gridsize=16;
@@ -90,20 +99,13 @@ void Map::draw()
math::Vector2f l;
v.x += margin;
- v.y += margin;
+ v.y += (height() - s - 2.0f * margin) * 0.5f;
map_hover = 0;
- if (h > s ) {
- v.y += (h-s) * 0.5f;
- } else {
- //v.x += (w-s) * 0.5f;
- }
-
gl::color(0,0,blue);
gl::begin(gl::Lines);
- for (int i=0; i <= gridsize; i++) {
-
+ for (int i=0; i <= gridsize; i++) {
gl::vertex(v.x, v.y + s / gridsize * i);
gl::vertex(v.x + s, v.y + s / gridsize * i);
@@ -153,13 +155,7 @@ void Map::draw()
if (core::application()->time() - floorf(core::application()->time()) < 0.5f) {
draw_icon = false;
}
- }
-
- if (entity == core::localplayer()->view()) {
- if (core::application()->time() - floorf(core::application()->time()) > 0.5f) {
- draw_icon = false;
- }
- }
+ }
}
if (draw_icon) {
@@ -211,7 +207,7 @@ void Map::draw()
// draw localcontrol icon
entity = core::localcontrol();
- if (core::localcontrol()->state() != core::Entity::Docked) {
+ //if (core::localcontrol()->state() != core::Entity::Docked) {
l.assign(v);
l.x -= s / scale * entity->location().y;
l.y -= s / scale * entity->location().x;
@@ -237,35 +233,19 @@ void Map::draw()
glTexCoord2f(0.0f, 1.0f);
gl::vertex(l.x-r, l.y+r);
}
- }
+ //}
gl::end();
-
+ gl::disable(GL_TEXTURE_2D);
if (map_target) {
- l.assign(v);
-
- if (h > s ) {
- // target information below
- l.x -= s * 0.5f;
- l.y += s * 0.5f;
-
- l.y += margin;
- } else {
- // target information right
- l.x += s * 0.5f;
- l.y -= s * 0.5f;
-
- l.x += margin;
- }
-
- render::Text::setcolor('B');
- render::Text::setfont(font()->name().c_str(), font()->width(), font()->height());
- render::Text::draw(l.x, l.y, map_target->name());
- render::Text::setcolor('N');
+ map_targetlabel->set_size(width() - s - margin * 3.0f, map_targetlabel->font()->height() * 2.0f );
+ map_targetlabel->set_location(s + margin * 2.0f, 4);
+ map_targetlabel->set_text(map_target->name());
+ map_targetlabel->show();
+ } else {
+ map_targetlabel->hide();
}
-
- gl::disable(GL_TEXTURE_2D);
}
bool Map::on_keypress(const int key, const unsigned int modifier)
diff --git a/src/client/map.h b/src/client/map.h
index 2ddab57..a3d8709 100644
--- a/src/client/map.h
+++ b/src/client/map.h
@@ -8,6 +8,7 @@
#define __INCLUDED_CLIENT_MAP_H__
#include "ui/window.h"
+#include "ui/label.h"
#include "core/entity.h"
namespace client {
@@ -36,7 +37,9 @@ protected:
virtual void draw();
unsigned int map_hover;
+
core::Entity *map_target;
+ ui::Label *map_targetlabel;
};
diff --git a/src/client/playerview.cc b/src/client/playerview.cc
index e4a889a..c7e50ff 100644
--- a/src/client/playerview.cc
+++ b/src/client/playerview.cc
@@ -21,11 +21,6 @@ PlayerView::PlayerView(ui::Widget *parent) : ui::Widget(parent)
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);
@@ -171,11 +166,11 @@ void PlayerView::resize()
view_notify->set_geometry(view_map->location(), view_map->size());
// reposition labels
- label_viewname->set_size(ui::UI::elementsize.width() * 1.5f, ui::UI::elementsize.height());
- label_viewname->set_location(smallmargin, smallmargin * 0.5f);
+ //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() * 1.5f, ui::UI::elementsize.height());
- label_zonename->set_location(width() - label_zonename->width() - smallmargin, height() - label_zonename->height() - smallmargin * 0.5f);
+ label_viewname->set_size(ui::UI::elementsize.width() * 1.5f, ui::UI::elementsize.height());
+ label_viewname->set_location(width() - label_viewname->width() - smallmargin, height() - label_viewname->height() - smallmargin * 0.5f);
}
void PlayerView::draw()
@@ -191,11 +186,15 @@ void PlayerView::draw()
if (core::localplayer()->view()->menus().size()) {
// entity with menus
+
+ if (map()->visible()) {
+ label_viewname->set_text(core::localplayer()->zone()->name());
+ } else {
+ label_viewname->set_text(core::localplayer()->view()->name());
+ }
+
label_viewname->show();
- label_viewname->set_text(core::localplayer()->view()->name());
- label_zonename->show();
-
if (view_lastentity != core::localplayer()->view()) {
// initially show the menu
show_menu("main");
@@ -233,16 +232,17 @@ void PlayerView::draw()
view_buymenu->hide();
}
- label_viewname->hide();
- label_zonename->set_visible(view_map->visible());
+ if (map()->visible()) {
+ label_viewname->set_text(core::localplayer()->zone()->name());
+ label_viewname->show();
+ } else {
+ label_viewname->hide();
+ }
+
view_hud->show();
view_lastentity = 0;
}
- if (label_zonename->visible()) {
- label_zonename->set_text(core::localplayer()->zone()->name());
- }
-
// reposition chat widget
if (view_chat->small_view()) {
view_chat->set_size(width() - smallmargin * 2, font()->height() * 2);
diff --git a/src/client/playerview.h b/src/client/playerview.h
index a09f5ca..855e671 100644
--- a/src/client/playerview.h
+++ b/src/client/playerview.h
@@ -64,9 +64,8 @@ private:
core::Entity *view_lastentity;
- ui::Label *label_zonename;
+ //ui::Label *label_zonename;
ui::Label *label_viewname;
-
};
}
diff --git a/src/client/worldview.cc b/src/client/worldview.cc
index cde7c37..dc8370d 100644
--- a/src/client/worldview.cc
+++ b/src/client/worldview.cc
@@ -25,6 +25,11 @@ WorldView::WorldView(ui::Widget *parent) : ui::Widget(parent)
view_playerview = new PlayerView(this);
view_playerview->raise();
view_playerview->hide();
+
+ // icon buttons
+ view_menubutton = new ui::IconButton(this, "icons/button_menu", "ui_menu");
+ view_chatbutton = new ui::IconButton(this, "icons/button_chat", "ui_chat");
+ view_mapbutton = new ui::IconButton(this, "icons/button_map", "ui_map");
}
WorldView::~WorldView()
@@ -54,6 +59,17 @@ void WorldView::resize()
view_keyinfo->set_size(font()->width()*12, font()->height()*1);
view_keyinfo->set_location(width() - view_keyinfo->width() - smallmargin,
height() - view_keyinfo->height() - smallmargin);
+
+ // icons
+ const float icon_margin = 4.0f;
+ const float icon_size = 48.0f;
+ const float icon_count = 4;
+ const float l = (width() -((icon_count +1) * icon_margin) - (icon_count * icon_size)) * 0.5f;
+
+ view_menubutton->set_geometry(l, icon_margin, icon_size, icon_size);
+ // spacer
+ view_chatbutton->set_geometry( l + 2.0f * (icon_margin + icon_size), icon_margin, icon_size, icon_size);
+ view_mapbutton->set_geometry( l + 3.0f * (icon_margin + icon_size), icon_margin, icon_size, icon_size);
}
void WorldView::clear()
@@ -77,8 +93,14 @@ void WorldView::draw()
if (ui::root()->active() || !core::game()->interactive() || !core::localcontrol()) {
view_playerview->hide();
+ view_menubutton->hide();
+ view_chatbutton->hide();
+ view_mapbutton->hide();
} else {
view_playerview->show();
+ view_menubutton->show();
+ view_chatbutton->show();
+ view_mapbutton->show();
}
}
diff --git a/src/client/worldview.h b/src/client/worldview.h
index 7921da2..1889186 100644
--- a/src/client/worldview.h
+++ b/src/client/worldview.h
@@ -10,6 +10,7 @@
#include "ui/widget.h"
#include "client/playerview.h"
#include "client/infowidget.h"
+#include "ui/iconbutton.h"
namespace client {
@@ -36,6 +37,10 @@ private:
KeyInfoWidget *view_keyinfo;
Notifications *view_notify;
PlayerView *view_playerview;
+
+ ui::IconButton *view_menubutton;
+ ui::IconButton *view_chatbutton;
+ ui::IconButton *view_mapbutton;
};
}