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-19 19:44:13 +0000
committerStijn Buys <ingar@osirion.org>2010-09-19 19:44:13 +0000
commitcc18095cded14f5e7e3f049e47fca2224134b647 (patch)
tree2a057f4836925083a19988d571dc0664925c9e48 /src/ui/paint.cc
parentbadfb31888a6bd62e0a019b3f3dec517df4121ec (diff)
text rendering cleanups, inventory capacity & cargo volume
Diffstat (limited to 'src/ui/paint.cc')
-rw-r--r--src/ui/paint.cc96
1 files changed, 46 insertions, 50 deletions
diff --git a/src/ui/paint.cc b/src/ui/paint.cc
index b3d6197..6531b0e 100644
--- a/src/ui/paint.cc
+++ b/src/ui/paint.cc
@@ -11,90 +11,100 @@
#include "render/textures.h"
#include "ui/paint.h"
-namespace ui
-{
-
-// contains the interface between the user interface and the render library
-namespace paint
-{
+namespace ui {
-void assign_color(const char c, const math::Color &color)
+void Paint::set_color(float r, float g, float b, float a)
{
- render::Text::assign_color(c, color);
+ gl::color(r, g, b, a);
}
-void color(float r, float g, float b, float a)
+void Paint::set_color(math::Color const & color)
{
- gl::color(r, g, b, a);
+ gl::color(color);
}
-void color(math::Color const & color)
+void Paint::assign_system_color(const char c, const math::Color &color)
{
- gl::color(color);
+ render::Text::assign_color(c, color);
}
-void color_code(const char c)
+void Paint::set_system_color(const char c)
{
render::Text::setcolor(c);
}
-void border(const math::Vector2f &location, const math::Vector2f &size)
+void Paint::draw_border(const math::Vector2f &global_location, const math::Vector2f &size)
{
using namespace gl;
begin(LineLoop);
- vertex(location.x(), location.y());
- vertex(location.x() + size.width(), location.y());
- vertex(location.x() + size.width(), location.y() + size.height());
- vertex(location.x(), location.y() + size.height());
+ vertex(global_location.x(), global_location.y());
+ vertex(global_location.x() + size.width(), global_location.y());
+ vertex(global_location.x() + size.width(), global_location.y() + size.height());
+ vertex(global_location.x(), global_location.y() + size.height());
end();
}
-void rectangle(const math::Vector2f &location, const math::Vector2f &size)
+void Paint::draw_rectangle(const math::Vector2f &global_location, const math::Vector2f &size)
{
using namespace gl;
begin(Quads);
- vertex(location.x(), location.y());
- vertex(location.x() + size.width(), location.y());
- vertex(location.x() + size.width(), location.y() + size.height());
- vertex(location.x(), location.y() + size.height());
+ vertex(global_location.x(), global_location.y());
+ vertex(global_location.x() + size.width(), global_location.y());
+ vertex(global_location.x() + size.width(), global_location.y() + size.height());
+ vertex(global_location.x(), global_location.y() + size.height());
end();
}
// draw a bitmap
-void bitmap(const math::Vector2f &location, const math::Vector2f &size, std::string const &texture)
+void Paint::draw_bitmap(const math::Vector2f &global_location, const math::Vector2f &size, const std::string &texture)
{
- render::Textures::bind("bitmaps/" + texture);
+ render::Textures::bind(texture);
gl::enable(GL_TEXTURE_2D);
gl::begin(gl::Quads);
glTexCoord2f(0.0f, 0.0f);
- gl::vertex(location.x(), location.y());
+ gl::vertex(global_location.x(), global_location.y());
glTexCoord2f(1.0f, 0.0f);
- gl::vertex(location.x() + size.width(), location.y());
+ gl::vertex(global_location.x() + size.width(), global_location.y());
glTexCoord2f(1.0f, 1.0f);
- gl::vertex(location.x() + size.width(), location.y() + size.height());
+ gl::vertex(global_location.x() + size.width(), global_location.y() + size.height());
glTexCoord2f(0.0f, 1.0f);
- gl::vertex(location.x(), location.y() + size.height());
+ gl::vertex(global_location.x(), global_location.y() + size.height());
gl::end();
gl::disable(GL_TEXTURE_2D);
}
+
+// draw unaligned text
+void Paint::draw_text(const math::Vector2f &global_location, const Font *font, const std::string &text)
+{
+ render::Text::setfont(font->name().c_str(), font->width(), font->height());
+
+ // enable OpenGL textures
+ gl::enable(GL_TEXTURE_2D);
+
+ render::Text::draw(global_location.x(), global_location.y(), text);
+
+ // disable OpenGL textures
+ gl::disable(GL_TEXTURE_2D);
+}
+
// draw aligned text
-void label(const math::Vector2f &location, const math::Vector2f &size, const Font *font, const std::string &text, unsigned int align)
+void Paint::draw_label(const math::Vector2f &global_location, const math::Vector2f &size, const Font *font, const std::string &text, const unsigned int alignment)
{
- unsigned int align_horizontal = (align & 0x000F);
+ unsigned int align_horizontal = (alignment & 0x000F);
if (!align_horizontal)
align_horizontal = AlignLeft;
- unsigned int align_vertical = (align & 0x00F0);
+ unsigned int align_vertical = (alignment & 0x00F0);
if (!align_vertical)
align_vertical = AlignTop;
@@ -110,7 +120,7 @@ void label(const math::Vector2f &location, const math::Vector2f &size, const Fon
float text_width = (float) aux::text_strip(text).size() * font->width();
// calculate drawing position
- math::Vector2f v(location);
+ math::Vector2f v(global_location);
switch (align_horizontal) {
case AlignLeft:
@@ -143,20 +153,7 @@ void label(const math::Vector2f &location, const math::Vector2f &size, const Fon
}
-// draw unaligned text
-void text(const math::Vector2f &location, const math::Vector2f &size, const Font *font, const std::string &text)
-{
- render::Text::setfont(font->name().c_str(), font->width(), font->height());
-
- // enable OpenGL textures
- gl::enable(GL_TEXTURE_2D);
-
- render::Text::draw(location.x(), location.y(), text);
-
- // disable OpenGL textures
- gl::disable(GL_TEXTURE_2D);
-}
-
+/*
// draw unaligned text
void text(const math::Vector2f &location, const math::Vector2f &size, const Font *font, std::stringstream & textstream)
{
@@ -171,7 +168,6 @@ void text(const math::Vector2f &location, const math::Vector2f &size, const Font
// disable OpenGL textures
gl::disable(GL_TEXTURE_2D);
}
+*/
-}
-
-}
+} //namespace ui