[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/gui display_graphic_context.cxx,1.3,1
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/gui display_graphic_context.cxx,1.3,1.4 display_graphic_context.hxx,1.2,1.3 |
Date: |
18 Apr 2003 17:08:28 -0000 |
Update of /var/lib/cvs/Games/Pingus/src/gui
In directory dark:/tmp/cvs-serv23719/gui
Modified Files:
display_graphic_context.cxx display_graphic_context.hxx
Log Message:
some cleanup
Index: display_graphic_context.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/gui/display_graphic_context.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- display_graphic_context.cxx 25 Mar 2003 00:37:44 -0000 1.3
+++ display_graphic_context.cxx 18 Apr 2003 17:08:26 -0000 1.4
@@ -160,8 +160,7 @@
void
DisplayGraphicContext::draw (Sprite& sprite, const Vector& pos)
{
- Vector tmp_pos = pos;
- sprite.put_screen (tmp_pos + offset + center);
+ sprite.put_screen(pos + offset + center);
}
void
@@ -169,8 +168,8 @@
{
CL_Surface sur (sprite.get_surface ());
draw (sur,
- (int) pos.x + sprite.get_x_align (),
- (int) pos.y + sprite.get_y_align (),
+ w2s_x(pos.x + sprite.get_x_align ()),
+ w2s_y(pos.y + sprite.get_y_align ()),
frame);
}
@@ -179,13 +178,11 @@
{
if (offset.z == 1.0)
{
- sur.put_screen (int(pos.x + get_x_offset () + center.x),
- int(pos.y + get_y_offset () + center.y));
+ sur.put_screen (w2s_x(pos.x), w2s_y(pos.y));
}
else
{
- sur.put_screen (int((pos.x + get_x_offset ()) * offset.z + center.x),
- int((pos.y + get_y_offset ()) * offset.z + center.y),
+ sur.put_screen (w2s_x(pos.x), w2s_y(pos.y),
offset.z, offset.z);
}
//CL_Display::draw_line (x1, y1, x2, y2, 1.0, 1.0, 0.0);
@@ -203,14 +200,12 @@
{
if (offset.z == 1.0)
{
- sur.put_screen (int(x_pos + get_x_offset () + center.x),
- int(y_pos + get_y_offset () + center.y));
+ sur.put_screen(w2s_x(x_pos), w2s_y(y_pos));
}
else
{
- sur.put_screen (int((x_pos + get_x_offset ()) * offset.z + center.x),
- int((y_pos + get_y_offset ()) * offset.z + center.y),
- offset.z, offset.z);
+ sur.put_screen(w2s_x(x_pos), w2s_y(y_pos),
+ offset.z, offset.z);
}
}
@@ -219,16 +214,13 @@
{
if (offset.z == 1.0)
{
- sur.put_screen (int(x_pos + get_x_offset () + center.x),
- int(y_pos + get_y_offset () + center.y),
- frame);
+ sur.put_screen (w2s_x(x_pos), w2s_y(y_pos), frame);
}
else
{
- sur.put_screen (int((x_pos + get_x_offset ()) * offset.z + center.x),
- int((y_pos + get_y_offset ()) * offset.z + center.y),
+ sur.put_screen (w2s_x(x_pos), w2s_y(y_pos),
offset.z, offset.z,
- frame);
+ frame);
}
}
@@ -236,8 +228,7 @@
DisplayGraphicContext::draw (CL_Surface& sur, int x_pos, int y_pos,
float size_x, float size_y, int frame)
{
- sur.put_screen (int(x_pos + get_x_offset () + center.x),
- int(y_pos + get_y_offset () + center.y),
+ sur.put_screen (w2s_x(x_pos), w2s_y(y_pos),
size_x * offset.z,
size_y * offset.z, frame);
}
@@ -246,40 +237,34 @@
DisplayGraphicContext::draw_line (const Vector& pos1, const Vector& pos2,
float r, float g, float b, float a)
{
- draw_line (int(pos1.x), int(pos1.y), int(pos2.x), int(pos2.y), r, g, b, a);
+ draw_line(int(pos1.x), int(pos1.y), int(pos2.x), int(pos2.y), r, g, b, a);
}
void
-DisplayGraphicContext::draw_line (int x1_, int y1_, int x2_, int y2_,
+DisplayGraphicContext::draw_line (int x1, int y1, int x2, int y2,
float r, float g, float b, float a)
{
- CL_Display::draw_line (static_cast<int>((x1_ + get_x_offset()) * offset.z +
center.x),
- static_cast<int>((y1_ + get_y_offset()) * offset.z +
center.y),
- static_cast<int>((x2_ + get_x_offset()) * offset.z +
center.x),
- static_cast<int>((y2_ + get_y_offset()) * offset.z +
center.y),
- r, g, b, a);
+ CL_Display::draw_line(w2s_x(x1), w2s_y(y1),
+ w2s_x(x2), w2s_y(y2),
+ r, g, b, a);
}
void
-DisplayGraphicContext::draw_fillrect (int x1_, int y1_, int x2_, int y2_,
+DisplayGraphicContext::draw_fillrect (int x1, int y1, int x2, int y2,
float r, float g, float b, float a)
{
- CL_Display::fill_rect (static_cast<int>((x1_ + get_x_offset()) * offset.z +
center.x),
- static_cast<int>((y1_ + get_y_offset()) * offset.z +
center.y),
- static_cast<int>((x2_ + get_x_offset()) * offset.z +
center.x),
- static_cast<int>((y2_ + get_y_offset()) * offset.z +
center.y),
- r, g, b, a);
+ CL_Display::fill_rect(w2s_x(x1), w2s_y(y1),
+ w2s_x(x2), w2s_y(y2),
+ r, g, b, a);
}
void
-DisplayGraphicContext::draw_rect (int x1_, int y1_, int x2_, int y2_,
- float r, float g, float b, float a)
+DisplayGraphicContext::draw_rect (int x1, int y1, int x2, int y2,
+ float r, float g, float b, float a)
{
- CL_Display::draw_rect (static_cast<int>((x1_ + get_x_offset()) * offset.z +
center.x),
- static_cast<int>((y1_ + get_y_offset()) * offset.z +
center.y),
- static_cast<int>((x2_ + get_x_offset()) * offset.z +
center.x),
- static_cast<int>((y2_ + get_y_offset()) * offset.z +
center.y),
- r, g, b, a);
+ CL_Display::draw_rect(w2s_x(x1), w2s_y(y1),
+ w2s_x(x2), w2s_y(y2),
+ r, g, b, a);
}
void
@@ -314,25 +299,19 @@
void
DisplayGraphicContext::print_left (FontHandle font, int x_pos, int y_pos,
const std::string& str)
{
- font->print_left(int(x_pos + get_x_offset () + center.x),
- int(y_pos + get_y_offset () + center.y),
- str.c_str ());
+ font->print_left(w2s_x(x_pos), w2s_y(y_pos), str.c_str ());
}
void
DisplayGraphicContext::print_center (FontHandle font, int x_pos, int y_pos,
const std::string& str)
{
- font->print_center(int(x_pos + get_x_offset () + center.x),
- int(y_pos + get_y_offset () + center.y),
- str.c_str ());
+ font->print_center(w2s_x(x_pos), w2s_y(y_pos), str.c_str ());
}
void
DisplayGraphicContext::print_right (FontHandle font, int x_pos, int y_pos,
const std::string& str)
{
- font->print_right(int(x_pos + get_x_offset () + center.x),
- int(y_pos + get_y_offset () + center.y),
- str.c_str ());
+ font->print_right(w2s_x(x_pos), w2s_y(y_pos), str.c_str ());
}
/* EOF */
Index: display_graphic_context.hxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/gui/display_graphic_context.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- display_graphic_context.hxx 16 Mar 2003 23:07:02 -0000 1.2
+++ display_graphic_context.hxx 18 Apr 2003 17:08:26 -0000 1.3
@@ -21,6 +21,7 @@
#define HEADER_DISPLAY_GRAPHIC_CONTEXT_HXX
#include "../vector.hxx"
+#include <vector>
#include <ClanLib/Core/Math/rect.h>
#include "graphic_context.hxx"
@@ -39,6 +40,22 @@
/** center of the display */
Vector center;
+ /** Rectangles that need updating */
+ std::vector<CL_Rect> change_rects;
+
+ /** Transform worldcoordinate _x*/
+ int w2s_x(float x) {
+ return static_cast<int>((x + get_x_offset()) * offset.z + center.x);
+ }
+
+ int w2s_y(float y) {
+ return static_cast<int>((y + get_y_offset()) * offset.z + center.y);
+ }
+
+ inline void add_change_rect(int x, int y, int width, int height)
+ {
+ change_rects.push_back(CL_Rect(x, y, x + width, y + height));
+ }
public:
DisplayGraphicContext (int x1, int y1, int x2, int y2,
int /*x_offset*/, int /*y_offset*/);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/gui display_graphic_context.cxx,1.3,1.4 display_graphic_context.hxx,1.2,1.3,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src console.cxx,1.11,1.12 col_map.cxx,1.16,1.17
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/po sr.po,1.15,1.16
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src console.cxx,1.11,1.12 col_map.cxx,1.16,1.17
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/po sr.po,1.15,1.16
- Index(es):