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>2010-09-15 21:29:18 +0000
committerStijn Buys <ingar@osirion.org>2010-09-15 21:29:18 +0000
commite55638d081e2e1ff6fbc06e0e8ac0381a04308e7 (patch)
tree511ccb478adf2acd3cc93f66d217b09f3e3a06dc /src/client/map.cc
parentf612f19e095b8d0ba49f5bcdec6a582824315d69 (diff)
updated comments, updated buy menu, info support for map window, added const to target selection
Diffstat (limited to 'src/client/map.cc')
-rw-r--r--src/client/map.cc76
1 files changed, 62 insertions, 14 deletions
diff --git a/src/client/map.cc b/src/client/map.cc
index 7a6fedc..34dcb40 100644
--- a/src/client/map.cc
+++ b/src/client/map.cc
@@ -32,8 +32,13 @@ Map::Map(ui::Widget *parent) : ui::Window(parent)
map_targetlabel->set_border(false);
map_targetlabel->set_font(ui::root()->font_large());
map_targetlabel->set_alignment(ui::AlignCenter);
+
+ map_scrollpane = new ui::ScrollPane(this, map_infotext);
+ map_scrollpane->set_background(false);
+ map_scrollpane->set_border(false);
+ map_scrollpane->set_alignment(ui::AlignTop);
- map_target = 0;
+ set_target(0);
map_hover = 0;
hide();
}
@@ -68,14 +73,29 @@ void Map::toggle()
show();
}
+void Map::resize()
+{
+ const float fontmargin = map_targetlabel->font()->height();
+
+ // resize label
+ map_targetlabel->set_size(width() - fontmargin * 2.0f, fontmargin);
+ map_targetlabel->set_location(fontmargin, fontmargin);
+
+ // resize infotext pane
+ map_scrollpane->set_size(width() - ui::UI::elementsize.width() * 1.5f - fontmargin * 3.0f,
+ height() - ui::UI::elementsize.height() * 2.0f - fontmargin * 3.0f);
+ map_scrollpane->set_location(ui::UI::elementsize.width() * 1.5f + fontmargin * 2.0f, fontmargin * 3.0f);
+}
+
void Map::draw()
{
- const float margin = font()->width() * 2.0f;
- const float s = ui::UI::elementsize.width() * 2.0f;
+ const float fontmargin = map_targetlabel->font()->height();
+ const float s = ui::UI::elementsize.width() * 1.5f;
+
const float blue = 0.8f;
const float gridsize = 16;
- core::Entity *entity;
+ const core::Entity *entity;
const core::Entity *current_target = map_target;
map_target = 0;
@@ -84,8 +104,8 @@ void Map::draw()
math::Vector2f v(global_location());
math::Vector2f l;
- v[0] += margin;
- v[1] += (height() - s - 2.0f * margin) * 0.5f;
+ v[0] += fontmargin;
+ v[1] += fontmargin + (height() - s) * 0.5f;
map_hover = 0;
gl::color(0, 0, blue);
@@ -147,20 +167,20 @@ void Map::draw()
if (draw_icon) {
if (entity->type() == core::Entity::Globe) {
if (entity->flag_is_set(core::Entity::Bright)) {
- if (texture_current != texture_bright) {
+ if (texture_current != texture_bright) {
gl::end();
texture_current = render::Textures::bind(texture_bright);
gl::begin(gl::Quads);
}
} else {
- if (texture_current != texture_globe) {
+ if (texture_current != texture_globe) {
gl::end();
texture_current = render::Textures::bind(texture_globe);
gl::begin(gl::Quads);
}
}
} else {
- if (texture_current != texture_entity) {
+ if (texture_current != texture_entity) {
gl::end();
texture_current = render::Textures::bind(texture_entity);
gl::begin(gl::Quads);
@@ -224,13 +244,42 @@ void Map::draw()
gl::end();
gl::disable(GL_TEXTURE_2D);
+ if (map_target != current_target) {
+ // this makes sure the map target exists
+ set_target(current_target);
+
+ } else if (map_infotimestamp && map_inforecord && (map_infotimestamp != map_inforecord->timestamp())) {
+ set_target(map_target);
+ }
+}
+
+void Map::set_target(const core::Entity *entity) {
+
+ map_target = entity;
+ map_infotimestamp = 0;
+ map_inforecord = 0;
+ map_infotext.clear();
+
if (map_target) {
- map_targetlabel->set_size(width() - s - margin * 3.0f, map_targetlabel->font()->height() * 2.0f);
- map_targetlabel->set_location(s + margin * 2.0f, 4);
+ // set title label to target name
map_targetlabel->set_text(map_target->name());
map_targetlabel->show();
+
+ map_inforecord = map_target->info();
+
+ if (map_inforecord) {
+ for (core::Info::Text::const_iterator it = map_inforecord->text().begin(); it != map_inforecord->text().end(); it++) {
+ map_infotext.push_back((*it));
+ }
+ map_infotimestamp = map_inforecord->timestamp();
+ } else {
+ map_infotext.push_back("Information is not available");
+ }
+
+ map_scrollpane->show();
} else {
map_targetlabel->hide();
+ map_scrollpane->hide();
}
}
@@ -240,9 +289,8 @@ bool Map::on_keypress(const int key, const unsigned int modifier)
if (hover()) {
core::Entity *target = core::localplayer()->zone()->find_entity(hover());
if (targets::is_valid_map_target(target)) {
- map_target = target;
- targets::select_target(map_target);
- //audio::play("ui/target");
+ set_target(target);
+ targets::set_target(map_target);
}
}
return true;