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.
162 lines
3.7 KiB
162 lines
3.7 KiB
15 years ago
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
|
#include <tqpalette.h>
|
||
15 years ago
|
#include <tqcolor.h>
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
|
#include "planet_info.h"
|
||
12 years ago
|
#include <tdeglobal.h>
|
||
15 years ago
|
#include "planet_info.moc"
|
||
|
|
||
14 years ago
|
PlanetInfo::PlanetInfo( TQWidget *parent, TQPalette palette )
|
||
|
: TQFrame( parent )
|
||
15 years ago
|
{
|
||
|
setPalette( palette );
|
||
|
|
||
15 years ago
|
name = new TQLabel( this );
|
||
15 years ago
|
name->setMinimumWidth( 100 );
|
||
15 years ago
|
owner = new TQLabel( this );
|
||
15 years ago
|
owner->setMinimumWidth( 100 );
|
||
15 years ago
|
ships = new TQLabel( this );
|
||
15 years ago
|
ships->setMinimumWidth( 100 );
|
||
15 years ago
|
production = new TQLabel( this );
|
||
15 years ago
|
production->setMinimumWidth( 100 );
|
||
15 years ago
|
kill_percent = new TQLabel( this );
|
||
15 years ago
|
kill_percent->setMinimumWidth( 100 );
|
||
|
|
||
|
clearDisplay();
|
||
|
|
||
13 years ago
|
TQVBoxLayout *layout1 = new TQVBoxLayout( this );
|
||
|
|
||
|
layout1->addWidget( name );
|
||
|
layout1->addWidget( owner );
|
||
|
layout1->addWidget( ships );
|
||
|
layout1->addWidget( production );
|
||
|
layout1->addWidget( kill_percent );
|
||
|
layout1->addStretch(1);
|
||
15 years ago
|
|
||
|
setMouseTracking( true );
|
||
|
|
||
13 years ago
|
setMinimumSize( sizeHint() );
|
||
|
setMaximumHeight( sizeHint().height() );
|
||
15 years ago
|
}
|
||
|
|
||
|
PlanetInfo::~PlanetInfo()
|
||
|
{
|
||
|
emptyPlanetInfoList();
|
||
|
}
|
||
|
|
||
13 years ago
|
TQSize PlanetInfo::sizeHint() const
|
||
15 years ago
|
{
|
||
|
int height;
|
||
|
|
||
13 years ago
|
height = name->sizeHint().height() +
|
||
|
owner->sizeHint().height() +
|
||
|
ships->sizeHint().height() +
|
||
|
production->sizeHint().height()+
|
||
|
kill_percent->sizeHint().height();
|
||
15 years ago
|
|
||
15 years ago
|
return TQSize( 100, height );
|
||
15 years ago
|
}
|
||
|
|
||
|
void PlanetInfo::setPlanetList( PlanetList &newPlanets )
|
||
|
{
|
||
|
emptyPlanetInfoList();
|
||
|
|
||
|
PlanetListIterator itr( newPlanets );
|
||
|
|
||
|
Planet *p;
|
||
|
while( (p = itr()) ) {
|
||
|
planet_info_buffer *stats = new planet_info_buffer;
|
||
|
stats->planet = p;
|
||
|
planet_stats.append( stats );
|
||
|
}
|
||
|
|
||
|
rescanPlanets();
|
||
|
}
|
||
|
|
||
|
void PlanetInfo::rescanPlanets()
|
||
|
{
|
||
|
PlanetInfoListIterator itr( planet_stats );
|
||
|
planet_info_buffer *p;
|
||
|
|
||
|
while( (p = itr()) ) {
|
||
|
p->production = p->planet->getProduction();
|
||
|
p->ships = p->planet->getFleet().getShipCount();
|
||
|
p->killRate = p->planet->getKillPercentage();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void PlanetInfo::clearDisplay()
|
||
|
{
|
||
15 years ago
|
TQString temp;
|
||
15 years ago
|
|
||
|
temp = "<qt>" + i18n("Planet name: ");
|
||
|
name->setText( temp );
|
||
|
|
||
|
temp = "<qt>" + i18n("Owner: ");
|
||
|
owner->setText( temp );
|
||
|
|
||
|
temp = "<qt>" + i18n("Ships: ");
|
||
|
ships->setText( temp );
|
||
|
|
||
|
temp = "<qt>" + i18n("Production: ");
|
||
|
production->setText( temp );
|
||
|
|
||
|
temp = "<qt>" + i18n("Kill percent: ");
|
||
|
kill_percent->setText( temp );
|
||
|
}
|
||
|
|
||
|
void PlanetInfo::emptyPlanetInfoList()
|
||
|
{
|
||
|
planet_stats.first();
|
||
|
|
||
|
planet_info_buffer *p;
|
||
|
while( (p = planet_stats.take()) ) {
|
||
|
delete p;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
void PlanetInfo::showPlanet( Planet *planet )
|
||
|
{
|
||
|
if( planet->getPlayer()->isNeutral() ) {
|
||
|
clearDisplay();
|
||
|
|
||
15 years ago
|
TQString temp;
|
||
15 years ago
|
|
||
13 years ago
|
temp = "<qt>" + i18n("Planet name: %1").arg(planet->getName());
|
||
15 years ago
|
name->setText( temp );
|
||
|
return;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString nameToShow = planet->getName();
|
||
15 years ago
|
|
||
|
PlanetInfoListIterator itr( planet_stats );
|
||
|
planet_info_buffer *p;
|
||
|
|
||
|
while( (p = itr()) ) {
|
||
|
if( p->planet == planet ) {
|
||
|
|
||
15 years ago
|
TQString temp;
|
||
15 years ago
|
|
||
13 years ago
|
temp = "<qt>" + i18n("Planet name: %1").arg(p->planet->getName());
|
||
15 years ago
|
name->setText( temp );
|
||
|
|
||
13 years ago
|
temp = "<qt>" + i18n("Owner: %1").arg(p->planet->getPlayer()->getColoredName());
|
||
15 years ago
|
owner->setText( temp );
|
||
|
|
||
12 years ago
|
temp = "<qt>" + i18n("Ships: %1").arg( TDEGlobal::locale()->formatNumber(p->ships, 0) );
|
||
15 years ago
|
ships->setText( temp );
|
||
|
|
||
12 years ago
|
temp = "<qt>" + i18n("Production: %1").arg( TDEGlobal::locale()->formatNumber(p->production, 0) );
|
||
15 years ago
|
production->setText( temp );
|
||
|
|
||
12 years ago
|
temp = "<qt>" + i18n("Kill percent: %1").arg( TDEGlobal::locale()->formatNumber(p->killRate, 3) );
|
||
15 years ago
|
kill_percent->setText( temp );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|