Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

planetinfodlg.cpp

Go to the documentation of this file.
00001 #include "../borqueror.h"
00002 
00003 void PlanetImageObject::Draw( void )
00004 {
00005         XBox::Draw();
00006 
00007         XRect   r( 0 , 0 , -1 , -1 );
00008         SDL_Surface     *planets = Graf::Img( id , &r );
00009 
00010         XRect   src( r.h * atPlanet , 0 , r.h , r.h );
00011         
00012         Graf::SDL_StretchBlt( planets , &src , GetGDI() , this );
00013 }
00014 
00016 PlanetInfoDlg::PlanetInfoDlg( StarSystem *&aSs , Window *aParent )
00017 : ss( aSs ) , BqBase( ePlanetInfoDlg , aParent )
00018 {
00019         f = Load( "PlanetInfoDlg" , ePlanetInfoDlg );
00020 }
00021 
00022 PlanetInfoDlg::~PlanetInfoDlg( void )
00023 {
00024 }
00025 
00026 const bool PlanetInfoDlg::SetupWindow( const Message &aMsg )
00027 {
00028         BqBase::SetupWindow( aMsg );
00029 
00030         return true;
00031 }
00032 
00033 void PlanetInfoDlg::SetupInfo( Planet *aPl )
00034 {
00035         if( f )
00036         {
00037                 PlanetImageObject       *pio = dynamic_cast<PlanetImageObject *>( f->GetArsObject( 10 ) );
00038                 pio->SetImageId( Graf::LoadImg( "Planets" , "Planets" , "@Images" ) );
00039                 pio->SetPlanetIndex( aPl->planetType );
00040                 map<int,PlanetInfo *>::iterator pos = Parameters::plIndice.find( aPl->planetType );
00041                 if( pos == Parameters::plIndice.end() )
00042                 {
00043                         for( int i = 20 ; i < 41 ; 20 )
00044                                 f->GetArsObject( i )->SetWndText( "" );
00045                 }
00046                 else
00047                 {
00048                         char    temp[128];
00049                         int i = 20;
00050                         f->GetArsObject( 20 )->SetWndText( string( " " ) + aPl->planetName );
00051                         f->GetArsObject( 21 )->SetWndText( string( " " ) + pos->second->type );
00052                         f->GetArsObject( 22 )->SetWndText( string( " " ) + pos->second->surface );
00053                         f->GetArsObject( 23 )->SetWndText( string( " " ) + pos->second->athmosphere );
00054 
00055                         sprintf( temp , " between %d and %d" , pos->second->sizeMin , pos->second->sizeMax );           f->GetArsObject( 24 )->SetWndText( temp );
00056                         sprintf( temp , " between %d and %d million years" , pos->second->ageMin , pos->second->ageMax );               f->GetArsObject( 25 )->SetWndText( temp );
00057                         sprintf( temp , " %4.1f" , aPl->GetTotalHumidity() );           f->GetArsObject( 26 )->SetWndText( temp );
00058                         sprintf( temp , " %4.1f" , aPl->GetTotalPressure() );           f->GetArsObject( 27 )->SetWndText( temp );
00059                         sprintf( temp , " %4.1f" , aPl->GetTotalSurfaceTemperature() );         f->GetArsObject( 28 )->SetWndText( temp );
00060                         sprintf( temp , " %5.2f" , aPl->GetSurfaceGravity() );          f->GetArsObject( 29 )->SetWndText( temp );
00061 
00062                         sprintf( temp , "  %d" , (int)aPl->GetOre() );          f->GetArsObject( 30 )->SetWndText( temp );
00063                         sprintf( temp , "  %d" , (int)aPl->GetDeuterium() );            f->GetArsObject( 31 )->SetWndText( temp );
00064                         sprintf( temp , "  %d" , (int)aPl->GetLithium() );              f->GetArsObject( 32 )->SetWndText( temp );
00065                         sprintf( temp , "  %d" , (int)aPl->GetEnergy() );               f->GetArsObject( 33 )->SetWndText( temp );
00066                         sprintf( temp , "  %d" , (int)aPl->GetSunFactor() );            f->GetArsObject( 34 )->SetWndText( temp );
00067                         f->GetArsObject( 35 )->SetWndText( string( " " ) + pos->second->lifeForm );
00068                         sprintf( temp , "  %d" , (int)aPl->GetSoil() );         f->GetArsObject( 36 )->SetWndText( temp );
00069                         sprintf( temp , "  %d" , (int)aPl->GetFlora() );                f->GetArsObject( 37 )->SetWndText( temp );
00070                         sprintf( temp , "  %d" , (int)aPl->GetFauna() );                f->GetArsObject( 38 )->SetWndText( temp );
00071                         sprintf( temp , "  %d" , (int)aPl->GetWater() );                f->GetArsObject( 39 )->SetWndText( temp );
00072                         XLabel  *lbl = dynamic_cast<XLabel *>( f->GetArsObject( 40 ) );
00073                         lbl->SetWndText( "" );
00074                         if( !pos->second->Description.empty() )
00075                                 lbl->SetWndText( string( " " ) + pos->second->Description + "\n\n" );
00076                         if( !pos->second->example.empty() )
00077                                 lbl->AppendWindowText( string( "Examples are:\n" ) + pos->second->example );
00078                 }
00079         }
00080 }
00081 
00082 const bool PlanetInfoDlg::MainLoop( void )
00083 {
00084         SetupDialog( "PlanetInfoDlg" );
00085         ans = true;
00086         BqBase::MainLoop();
00087 
00088         return ans;
00089 }
00090 
00091 const bool PlanetInfoDlg::evMouseLClick( const CtrlMessage &msg )
00092 {
00093         BqBase::evMouseLClick( msg );
00094 
00095         if( isDisplayed )
00096                 if( ((Window *)msg.source)->GetId() == 1 )
00097                         isDisplayed= false;     
00098                 else if( ((Window *)msg.source)->GetId() == 2 )
00099                 {
00100                         vector<Planet *>::iterator pos = find_if( ss->begin() , ss->end() , bind2nd( mem_fun( &Planet::ClickedOn ) , &ArsApplication::mousexy ) );
00101                         if( pos != ss->end() )
00102                         {
00103                                 SetupInfo( *pos );
00104                                 f->Draw();
00105                         }
00106                         else
00107                                 ans = isDisplayed= false;       
00108                 }
00109 
00110         return true;
00111 }

Generated on Fri Dec 5 04:06:00 2003 for Borqueror by doxygen 1.3.3