00001 #include "borqueror.h"
00002
00003 #include "continue.h"
00004
00005 class SetupGalaxyScreen : public Thread {
00006 public:
00007 virtual long Run( void * )
00008 {
00009 XRect grect( 0 , 0 , GalaxyScreen::img->w , GalaxyScreen::img->h );
00010 SDL_FillRect( GalaxyScreen::img , &grect , 0xff000000 );
00011 return 1;
00012 }
00013 };
00014
00015 class LoadGalaxyData : public Thread {
00016 public:
00017 virtual long Run( void * )
00018 {
00019 if( !GetGalaxy().IsLoaded() )
00020 {
00021 ArsSendMessage( UserMessage( Message::USER , 0 , LOAD_GALAXY , 0 ) );
00022 ArsSendMessage( UserMessage( Message::USER , 0 , LOAD_SPECIES , 0 ) );
00023 return 1;
00024 }
00025 return 2;
00026 }
00027 };
00028
00030 Continue::Continue( Window *aParent )
00031 : BqBase( ePlayGame , aParent )
00032 {
00033 }
00034
00035 Continue::~Continue( void )
00036 {
00037 }
00038
00039 const bool Continue::SetupWindow( const Message &aMsg )
00040 {
00041 BqBase::SetupWindow( aMsg );
00042
00043 for( vector<Thread*>::iterator it = initTasks.begin() ;it != initTasks.end() ; ++it )
00044 (*it)->Wait();
00045
00046 for( it = initTasks.begin() ;it != initTasks.end() ; ++it )
00047 delete *it;
00048 initTasks.clear();
00049 return true;
00050 }
00051
00052 void Continue::SetupDialog( const std::string &aFormname )
00053 {
00054 if( !f )
00055 f = Load( aFormname , ePlayGame );
00056
00057 ArsSendMessage( Message( Message::SETUP_WINDOW , this ) );
00058
00059 if( f )
00060 {
00061 f->InitDialog( this );
00062 InitDialog();
00063 f->Draw();
00064 isDisplayed = true;
00065 }
00066 SetTextAlign( S_ALIGN_TOP , S_ALIGN_LEFT );
00067 }
00068
00069 const bool Continue::MainLoop( void )
00070 {
00071 initTasks.clear();
00072 initTasks.push_back( new SetupGalaxyScreen );
00073 initTasks.push_back( new LoadGalaxyData );
00074
00075 for( vector<Thread*>::iterator it = initTasks.begin() ;it != initTasks.end() ; ++it )
00076 (*it)->Start( 0 );
00077
00078 SetupDialog( "PlayGame" );
00079
00080 return BqBase::MainLoop();
00081 }
00082
00083 const bool Continue::evMouseLClick( const CtrlMessage &msg )
00084 {
00085 if( isDisplayed )
00086 if( ((Window *)msg.source)->GetId() == 11 )
00087 {
00088 isDisplayed= false;
00089 GetParent()->UpdateWindow();
00090 return !isDisplayed;
00091 }
00092
00093 return isDisplayed;
00094 }
00095