[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src smallmap.cxx,1.19,1.20 smallmap.hxx,1
From: |
torangan |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src smallmap.cxx,1.19,1.20 smallmap.hxx,1.10,1.11 |
Date: |
6 Oct 2002 09:01:34 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv13198
Modified Files:
smallmap.cxx smallmap.hxx
Log Message:
applied Gervase Lams patch
Index: smallmap.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/smallmap.cxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- smallmap.cxx 4 Oct 2002 16:54:04 -0000 1.19
+++ smallmap.cxx 6 Oct 2002 09:01:32 -0000 1.20
@@ -34,8 +34,14 @@
SmallMap::SmallMap()
{
+ max_width = 175;
+ max_height = 100;
+
+ // Don't really need to initialise these now as this values are calculated
+ // later on. However, initialise here, just in case.
width = 175;
- height = 75;
+ height = 100;
+
scroll_mode = false;
}
@@ -59,6 +65,23 @@
buffer = colmap->get_data();
//Plf* plf = world->get_plf();
+ // Scaling values used in order to keep the aspect ratio
+ int x_scaling = colmap->get_width() / max_width;
+ int y_scaling = colmap->get_height() / max_height;
+
+ // If at best one horizontal pixel in the smallmap represents more colmap
+ // pixels than one vertical pixel
+ if (x_scaling > y_scaling)
+ {
+ width = max_width;
+ height = colmap->get_height() / x_scaling;
+ }
+ else
+ {
+ width = colmap->get_width() / y_scaling;
+ height = max_height;
+ }
+
canvas = new CL_Canvas(width, height);
canvas->lock();
@@ -133,7 +156,7 @@
sur = CL_Surface(canvas, true);
- x_pos = 0;
+ x_pos = 5;
y_pos = CL_Display::get_height() - sur.get_height();
rwidth = CL_Display::get_width() * width /
client->get_server()->get_world()->get_colmap()->get_width();
@@ -155,21 +178,21 @@
int x_of = playfield->get_x_offset();
int y_of = playfield->get_y_offset();
- sur.put_screen(0, CL_Display::get_height() - sur.get_height());
+ sur.put_screen(x_pos, y_pos);
if (has_focus)
- Display::draw_rect(0, CL_Display::get_height() - sur.get_height(),
- sur.get_width (), CL_Display::get_height() -
sur.get_height() + sur.get_height () - 1,
+ Display::draw_rect(x_pos, y_pos,
+ x_pos + sur.get_width (), y_pos + sur.get_height () - 1,
1.0f, 1.0f, 1.0f, 1.0f);
- x_of = -x_of * width /
client->get_server()->get_world()->get_colmap()->get_width();
- y_of = -y_of * height /
client->get_server()->get_world()->get_colmap()->get_height();
+ x_of = x_pos - x_of * width /
client->get_server()->get_world()->get_colmap()->get_width();
+ y_of = y_pos - y_of * height /
client->get_server()->get_world()->get_colmap()->get_height();
Display::draw_rect(x_of,
- y_of + CL_Display::get_height() - sur.get_height(),
+ y_of,
x_of + Math::min(rwidth,
static_cast<int>(sur.get_width())),
- y_of + Math::min(rheight,
static_cast<int>(sur.get_height())) + CL_Display::get_height() -
sur.get_height(),
+ y_of + Math::min(rheight,
static_cast<int>(sur.get_height())),
0.0, 1.0, 0.0, 1.0);
// FIXME: This should use put_target(), but put_target(), does not
Index: smallmap.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/smallmap.hxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- smallmap.hxx 27 Sep 2002 11:26:44 -0000 1.10
+++ smallmap.hxx 6 Oct 2002 09:01:32 -0000 1.11
@@ -26,23 +26,52 @@
class CL_Key;
class Client;
+// Small Map
+/** This is the map that appears in the corner of the screen */
class SmallMap : public GUI::Component
{
private:
Client* client;
+ /// Graphic surface of the exit
CL_Surface exit_sur;
+
+ /// Graphic surface of the entrance
CL_Surface entrance_sur;
+
+ /// Graphic surface for the generated rectanglar background of the small map
CL_Surface sur;
+ /// Horizontal position of the small map
int x_pos;
+
+ /// Vertical position of the small map
int y_pos;
+
+ /// Width of the small map
int width;
+
+ /// Height of the small map
int height;
+
+ /// Max width of the small map
+ int max_width;
+
+ /// Max height of the small map
+ int max_height;
+
+ /** Indicates whether the playfield should can be scrolled around depending
+ on the position of the cursor in the small map */
bool scroll_mode;
+
+ /// Width of the rectangle displayed inside the small map
int rwidth;
+
+ /// Height of the rectangle displayed inside the small map
int rheight;
+
bool has_focus;
+
public:
SmallMap();
virtual ~SmallMap();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src smallmap.cxx,1.19,1.20 smallmap.hxx,1.10,1.11,
torangan <=