You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.7 KiB
80 lines
1.7 KiB
15 years ago
|
#include <tqpixmap.h>
|
||
|
#include <tqpainter.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
15 years ago
|
#include <kiconloader.h>
|
||
|
|
||
|
#include "minimap.h"
|
||
|
#include "minimap.moc"
|
||
|
|
||
13 years ago
|
MiniMap::MiniMap( TQWidget *parent, const char *name )
|
||
|
: TQGridView( parent, name ),
|
||
15 years ago
|
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 );
|
||
|
|
||
15 years ago
|
connect( map, TQT_SIGNAL( update() ), this, TQT_SLOT( mapUpdate() ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
MiniMap::~MiniMap()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
|
||
|
void
|
||
15 years ago
|
MiniMap::paintCell( TQPainter *p, int row, int col )
|
||
15 years ago
|
{
|
||
|
drawSector( p, map->getSector( row, col ) );
|
||
|
}
|
||
|
|
||
|
void
|
||
|
MiniMap::mapUpdate()
|
||
|
{
|
||
|
updateContents();
|
||
|
}
|
||
|
|
||
|
|
||
|
void
|
||
15 years ago
|
MiniMap::drawSector( TQPainter *p, Sector §or )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQRect r( 0, 0, SECTOR_WIDTH, SECTOR_HEIGHT );
|
||
15 years ago
|
|
||
|
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 );
|
||
|
}
|
||
|
}
|
||
|
|