diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | c90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch) | |
tree | 6d8391395bce9eaea4ad78958617edb20c6a7573 /konquest/minimap.cc | |
download | tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'konquest/minimap.cc')
-rw-r--r-- | konquest/minimap.cc | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/konquest/minimap.cc b/konquest/minimap.cc new file mode 100644 index 00000000..eee1237b --- /dev/null +++ b/konquest/minimap.cc @@ -0,0 +1,79 @@ +#include <qpixmap.h> +#include <qpainter.h> + +#include <kapplication.h> +#include <kiconloader.h> + +#include "minimap.h" +#include "minimap.moc" + +MiniMap::MiniMap( QWidget *parent, const char *name ) + : QGridView( parent, name ), + SECTOR_HEIGHT( 12 ), SECTOR_WIDTH( 12 ), + BOARD_HEIGHT( 10 * SECTOR_HEIGHT ), + BOARD_WIDTH( 10 * SECTOR_WIDTH ), + map( 0 ) +{ + setFrameStyle( NoFrame ); + setPaletteBackgroundColor( black ); + setMinimumSize( BOARD_HEIGHT, BOARD_WIDTH ); + + setCellWidth( SECTOR_WIDTH ); + setCellHeight( SECTOR_HEIGHT ); + setNumRows( 10 ); + setNumCols( 10 ); + + setMinimumSize( BOARD_HEIGHT, BOARD_WIDTH ); + setMaximumSize( BOARD_HEIGHT, BOARD_WIDTH ); +} + +void +MiniMap::setMap(Map *newMap) +{ + map = newMap; + BOARD_HEIGHT = map->getRows() * SECTOR_HEIGHT; + BOARD_WIDTH = map->getColumns() * SECTOR_WIDTH; + setNumRows( map->getRows() ); + setNumCols( map->getColumns() ); + + setMinimumSize( BOARD_HEIGHT, BOARD_WIDTH ); + setMaximumSize( BOARD_HEIGHT, BOARD_WIDTH ); + + connect( map, SIGNAL( update() ), this, SLOT( mapUpdate() ) ); +} + +MiniMap::~MiniMap() +{ +} + + +void +MiniMap::paintCell( QPainter *p, int row, int col ) +{ + drawSector( p, map->getSector( row, col ) ); +} + +void +MiniMap::mapUpdate() +{ + updateContents(); +} + + +void +MiniMap::drawSector( QPainter *p, Sector §or ) +{ + QRect r( 0, 0, SECTOR_WIDTH, SECTOR_HEIGHT ); + + p->setPen( black ); + p->setBrush( black ); + p->drawRect( r ); + + if( sector.hasPlanet() ) { + p->setPen( sector.getPlanet()->getPlayer()->getColor() ); + p->setBrush( sector.getPlanet()->getPlayer()->getColor() ); + + p->drawPie( r, 0, (360 * 16)-1 ); + } +} + |