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>2008-12-07 09:03:10 +0000
committerStijn Buys <ingar@osirion.org>2008-12-07 09:03:10 +0000
commit7de62efc14d0e0f037051bd887c96f28fd9a3215 (patch)
treec3e792bc7feaaa73d69eb417d2b2424195206818 /src/client
parent94a368b734911abe5cab7c61a23e8c225354df85 (diff)
add system map,
prepare source tree for dataset reorganization
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Makefile.am9
-rw-r--r--src/client/client.cc10
-rw-r--r--src/client/client.h1
-rw-r--r--src/client/keyboard.cc2
-rw-r--r--src/client/map.cc161
-rw-r--r--src/client/map.h30
-rw-r--r--src/client/view.cc49
-rw-r--r--src/client/view.h3
8 files changed, 240 insertions, 25 deletions
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 1d015a3..4f78bbe 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -7,12 +7,13 @@ else
noinst_LTLIBRARIES = libclient.la
endif
-libclient_la_SOURCES = action.cc chat.cc client.cc clientext.cc input.cc joystick.cc key.cc \
- keyboard.cc notifications.cc soundext.cc targets.cc video.cc view.cc
+libclient_la_SOURCES = action.cc chat.cc client.cc clientext.cc input.cc \
+ joystick.cc key.cc keyboard.cc map.cc notifications.cc soundext.cc targets.cc \
+ video.cc view.cc
libclient_la_CFLAGS = $(LIBSDL_CFLAGS) $(GL_CFLAGS)
libclient_la_LDFLAGS = -avoid-version -no-undefined $(GL_LIBS) $(LIBSDL_LIBS)
-noinst_HEADERS = action.h chat.h client.h clientext.h input.h joystick.h key.h keyboard.h \
- notifications.h soundext.h targets.h video.h view.h
+noinst_HEADERS = action.h chat.h client.h clientext.h input.h joystick.h key.h \
+ keyboard.h map.h notifications.h soundext.h targets.h video.h view.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
diff --git a/src/client/client.cc b/src/client/client.cc
index 650813c..769aacb 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -117,6 +117,9 @@ void Client::init(int count, char **arguments)
func = core::Func::add("ui_chatsmall", Client::func_ui_chatsmall);
func->set_info("toggle small chat window");
+ func = core::Func::add("ui_map", Client::func_ui_map);
+ func->set_info("toggle map");
+
func = core::Func::add("snd_restart", Client::func_snd_restart);
func->set_info("restart audio subsystem");
@@ -352,5 +355,12 @@ void Client::func_ui_chatsmall(std::string const &args)
}
}
+void Client::func_ui_map(std::string const &args)
+{
+ if (core::application()->connected()) {
+ client()->view()->map()->toggle();
+ }
+}
+
} // namespace client
diff --git a/src/client/client.h b/src/client/client.h
index 8dd00cb..607c7f0 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -71,6 +71,7 @@ private:
static void func_r_restart(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_map(std::string const &args);
View *client_view;
diff --git a/src/client/keyboard.cc b/src/client/keyboard.cc
index ad96856..9c35771 100644
--- a/src/client/keyboard.cc
+++ b/src/client/keyboard.cc
@@ -184,7 +184,7 @@ Keyboard::Keyboard()
key->assign(Key::Alt, "quit");
#endif
add_key("f5", SDLK_F5);
- add_key("f6", SDLK_F6);
+ add_key("f6", SDLK_F6, 0, "ui_map");
add_key("f7", SDLK_F7);
add_key("f8", SDLK_F8);
add_key("f9", SDLK_F9);
diff --git a/src/client/map.cc b/src/client/map.cc
new file mode 100644
index 0000000..1183457
--- /dev/null
+++ b/src/client/map.cc
@@ -0,0 +1,161 @@
+
+/*
+ client/map.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#include "core/application.h"
+#include "client/map.h"
+#include "client/targets.h"
+#include "ui/paint.h"
+#include "render/gl.h"
+#include "render/textures.h"
+
+namespace client {
+
+Map::Map(ui::Widget *parent) : ui::Widget(parent)
+{
+ set_label("map");
+ set_border(true);
+ set_background(true);
+ hide();
+}
+
+Map::~Map()
+{
+}
+
+void Map::toggle()
+{
+ if (visible())
+ hide();
+ else
+ show();
+}
+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 blue = 0.8f;
+ const float gridsize=16;
+
+ math::Vector2f v(global_location());
+ v.x += margin;
+ v.y += margin;
+
+ 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++) {
+
+ gl::vertex(v.x, v.y + s / gridsize * i);
+ gl::vertex(v.x + s, v.y + s / gridsize * i);
+
+ gl::vertex(v.x + s / gridsize * i, v.y);
+ gl::vertex(v.x + s / gridsize * i, v.y+s);
+ }
+ gl::end();
+
+ const size_t texture_entity = render::Textures::load("bitmaps/icons/entity_default");
+ const size_t texture_globe = render::Textures::load("bitmaps/icons/entity_globe");
+ const size_t texture_bright = render::Textures::load("bitmaps/icons/entity_bright");
+
+ size_t texture_current = render::Textures::bind(texture_entity);
+
+ v.x += s * 0.5f;
+ v.y += s * 0.5f;
+
+ core::Zone *zone = core::localplayer()->zone();
+
+ const float r = 24.0f;
+ float scale = 2048.0f;
+ scale *= 2;
+
+ gl::enable(GL_TEXTURE_2D);
+ gl::begin(gl::Quads);
+
+ for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) {
+ core::Entity *entity = (*it);
+
+ bool draw_icon = false;
+ if ((entity->model()) || (entity->type() == core::Entity::Globe)) {
+ draw_icon = true;
+
+ if ((entity->type() == core::Entity::Dynamic) || (entity->type() == core::Entity::Controlable)) {
+ core::EntityDynamic *ed = dynamic_cast<core::EntityDynamic *>(entity);
+ if (ed->eventstate() ==core::Entity::Docked) {
+ draw_icon = false;
+ }
+ }
+
+ if (entity == core::localcontrol()) {
+ if (core::application()->time() - floorf(core::application()->time()) < 0.5f) {
+ draw_icon = false;
+ }
+ }
+
+ if (entity == targets::current()) {
+ if (core::application()->time() - floorf(core::application()->time()) < 0.5f) {
+ draw_icon = false;
+ }
+ }
+ }
+
+ if (draw_icon) {
+ if (entity->type() == core::Entity::Globe) {
+ if ((entity->flags() & core::Entity::Bright) == core::Entity::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) {
+ gl::end();
+ texture_current = render::Textures::bind(texture_globe);
+ gl::begin(gl::Quads);
+ }
+ }
+ } else {
+ if (texture_current != texture_entity) {
+ gl::end();
+ texture_current = render::Textures::bind(texture_entity);
+ gl::begin(gl::Quads);
+ }
+ }
+
+ math::Vector2f l(v);
+ l.x -= s / scale * entity->location().y;
+ l.y -= s / scale * entity->location().x;
+
+ math::Color color(entity->color());
+ color.a = 1.0f;
+ gl::color(color);
+ glTexCoord2f(0.0f, 0.0f);
+ gl::vertex(l.x, l.y);
+
+ glTexCoord2f(1.0f, 0.0f);
+ gl::vertex(l.x+r, l.y);
+
+ glTexCoord2f(1.0f, 1.0f);
+ gl::vertex(l.x+r, l.y+r);
+
+ glTexCoord2f(0.0f, 1.0f);
+ gl::vertex(l.x, l.y+r);
+
+ }
+ }
+ gl::end();
+ gl::disable(GL_TEXTURE_2D);
+}
+
+} \ No newline at end of file
diff --git a/src/client/map.h b/src/client/map.h
new file mode 100644
index 0000000..cbdc216
--- /dev/null
+++ b/src/client/map.h
@@ -0,0 +1,30 @@
+/*
+ client/map.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_MAP_H__
+#define __INCLUDED_CLIENT_MAP_H__
+
+#include "ui/widget.h"
+
+namespace client {
+
+class Map : public ui::Widget
+{
+public:
+ Map(ui::Widget *parent = 0);
+ virtual ~Map();
+
+ void toggle();
+
+protected:
+ virtual void draw();
+};
+
+
+} // namespace client
+
+
+#endif // __INCLUDED_CLIENT_MAP_H__
diff --git a/src/client/view.cc b/src/client/view.cc
index de867c0..e7704f2 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -210,6 +210,7 @@ View::View(ui::Widget *parent) : ui::Widget(parent)
view_keypress = new KeyPress(this);
view_notify = new Notifications(this);
view_chat = new Chat(this);
+ view_map = new Map(this);
// make sure the view is at the bottom of the draw stack
lower();
@@ -232,6 +233,10 @@ void View::resize()
view_keypress->set_location(width() - view_keypress->width() - font()->width() * 0.5,
height() - view_keypress->height() - font()->height() * 0.5f);
+ // reposition map
+ view_map->set_size(width() - font()->width() * 8, height() - font()->height() * 8);
+ view_map->set_location(font()->width() * 4, font()->height() * 4);
+
// reposition center
view_center->set_size(ui::pointer_size, ui::pointer_size);
view_center->set_location((size() - view_center->size()) * 0.5f);
@@ -268,6 +273,9 @@ void View::draw()
}
} else {
view_notify->set_visible(false);
+
+ view_chat->set_visible(false);
+ view_map->set_visible(false);
}
if (core::localcontrol() && (input::mouse_control || input::joystick_control) &&
@@ -462,18 +470,18 @@ void draw_entity_target(core::Entity *entity, bool is_active_target)
// outer square shadow
gl::color(0, 0, 0, 1);
gl::begin(gl::LineLoop);
- glVertex3f(cx+r, cy+2, 0);
- glVertex3f(cx, cy+r+2, 0);
- glVertex3f(cx-r, cy+2, 0);
- glVertex3f(cx, cy-r+2, 0);
+ gl::vertex(cx+r, cy+2);
+ gl::vertex(cx, cy+r+2);
+ gl::vertex(cx-r, cy+2);
+ gl::vertex(cx, cy-r+2);
gl::end();
if ((entity->flags() & core::Entity::Dockable) == core::Entity::Dockable) {
gl::begin(gl::LineLoop);
- glVertex3f(cx+ (r*0.25f), cy+2, 0);
- glVertex3f(cx, cy+(r*0.25f)+2, 0);
- glVertex3f(cx-(r*0.25f), cy+2, 0);
- glVertex3f(cx, cy-(r*0.25f)+2, 0);
+ gl::vertex(cx+ (r*0.25f), cy+2);
+ gl::vertex(cx, cy+(r*0.25f)+2);
+ gl::vertex(cx-(r*0.25f), cy+2);
+ gl::vertex(cx, cy-(r*0.25f)+2);
gl::end();
}
@@ -487,18 +495,18 @@ void draw_entity_target(core::Entity *entity, bool is_active_target)
// outer square0
gl::begin(gl::LineLoop);
- glVertex3f(cx+r, cy, 0);
- glVertex3f(cx, cy+r, 0);
- glVertex3f(cx-r, cy, 0);
- glVertex3f(cx, cy-r, 0);
+ gl::vertex(cx+r, cy);
+ gl::vertex(cx, cy+r);
+ gl::vertex(cx-r, cy);
+ gl::vertex(cx, cy-r);
gl::end();
if ((entity->flags() & core::Entity::Dockable) == core::Entity::Dockable) {
gl::begin(gl::LineLoop);
- glVertex3f(cx+(r*0.25f), cy, 0);
- glVertex3f(cx, cy+(r*0.25f), 0);
- glVertex3f(cx-(r*0.25f), cy, 0);
- glVertex3f(cx, cy-(r*0.25f), 0);
+ gl::vertex(cx+(r*0.25f), cy);
+ gl::vertex(cx, cy+(r*0.25f));
+ gl::vertex(cx-(r*0.25f), cy);
+ gl::vertex(cx, cy-(r*0.25f));
gl::end();
}
@@ -682,7 +690,7 @@ void draw_hud()
}
}
-void draw_cursor()
+void set_cursor()
{
if (ui::console()->visible()) {
ui::root()->set_pointer();
@@ -757,9 +765,6 @@ void frame(float elapsed)
// draw the user interface
if (draw_ui->value()) {
- draw_cursor();
- ui::root()->frame();
-
// draw the hud - TODO move as much as possible into ui::
if (draw_ui->value() && !ui::root()->active()) {
gl::enable(GL_TEXTURE_2D);
@@ -769,6 +774,10 @@ void frame(float elapsed)
// draw the hud
draw_hud();
}
+
+ set_cursor();
+ ui::root()->frame();
+
} else if (ui::console()->visible()) {
ui::console()->event_draw();
}
diff --git a/src/client/view.h b/src/client/view.h
index c9c9156..250fa2d 100644
--- a/src/client/view.h
+++ b/src/client/view.h
@@ -9,6 +9,7 @@
#include "core/zone.h"
#include "client/chat.h"
+#include "client/map.h"
#include "client/notifications.h"
#include "ui/widget.h"
#include "ui/bitmap.h"
@@ -72,6 +73,7 @@ class View : public ui::Widget
public:
View(ui::Widget *parent=0);
+ inline Map *map() { return view_map; }
inline Chat *chat() { return view_chat; }
inline Notifications *notify() { return view_notify; }
@@ -87,6 +89,7 @@ private:
Stats *view_stats;
KeyPress *view_keypress;
Notifications *view_notify;
+ Map *view_map;
ui::Bitmap *view_center;
};