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/map.cc
parent8861bf21e9821f7adcbbafcb9f72e0f1b8f59344 (diff)
added worldview icons, updated map
Diffstat (limited to 'src/client/map.cc')
-rw-r--r--src/client/map.cc70
1 files changed, 25 insertions, 45 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)