Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

replayrecorder.cpp

Go to the documentation of this file.
00001 /*
00002      This file is part of Advanced Strategic Command; http://www.asc-hq.de
00003      Copyright (C) 1994-1999  Martin Bickel  and  Marc Schellenberger
00004  
00005      This program is free software; you can redistribute it and/or modify
00006      it under the terms of the GNU General Public License as published by
00007      the Free Software Foundation; either version 2 of the License, or
00008      (at your option) any later version.
00009  
00010      This program is distributed in the hope that it will be useful,
00011      but WITHOUT ANY WARRANTY; without even the implied warranty of
00012      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013      GNU General Public License for more details.
00014  
00015      You should have received a copy of the GNU General Public License
00016      along with this program; see the file COPYING. If not, write to the 
00017      Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
00018      Boston, MA  02111-1307  USA
00019 */
00020 
00021 
00022 #include <sstream>
00023 #include <pgimage.h>
00024 
00025 #include "replayrecorder.h"
00026 #include "../paradialog.h"
00027 #include "../dialog.h"
00028 
00029 #include "fileselector.h"
00030 #include "../gameoptions.h"
00031 
00032 
00033 bool ReplayRecorderDialog::selectFilename()
00034 {
00035    ASCString filename = selectFile( "*.avi", false );
00036    if ( !filename.empty() )
00037       this->filename->SetText( filename );
00038    return true;
00039 }
00040       
00041 bool ReplayRecorderDialog::ok()
00042 {
00043    if ( !filename->GetText().empty() ) {
00044       tfindfile ff ( getFilename() );
00045       tfindfile::FileInfo fi;
00046       bool fileExists = false;
00047       if ( ff.getnextname( fi ))
00048          if ( fi.directoryLevel <= 0 )
00049             fileExists = true;
00050       
00051       if ( !fileExists || getAppend() || choice_dlg( "overwrite " + getFilename() +" ?", "~y~es","~n~o") == 1 ) {
00052          
00053          CGameOptions::Instance()->video.framerate = getFramerate();
00054          CGameOptions::Instance()->video.quality = getQuality();
00055          CGameOptions::Instance()->setChanged(true);
00056          
00057          QuitModal();
00058          return true;
00059       }
00060       return false;
00061    } else
00062       return false;
00063 }
00064       
00065 ReplayRecorderDialog::ReplayRecorderDialog( const ASCString& file, bool fileAlreadyOpen ) : ASC_PG_Dialog( NULL, PG_Rect( -1, -1, 400, 250 ), "Replay Recorder" ), append(NULL)
00066 {
00067    new PG_Label(this, PG_Rect(20,30,80,25),"File:");
00068    filename = new PG_LineEdit( this, PG_Rect( 120, 30, 150, 25 ));
00069    filename->SetText( file );
00070    (new PG_Button(this, PG_Rect( 290, 30, 90, 25), "Browse"))->sigClick.connect( SigC::slot( *this, &ReplayRecorderDialog::selectFilename ));
00071    
00072    if ( !file.empty() && fileAlreadyOpen ) {
00073       append = new PG_CheckButton( this, PG_Rect( 120, 70, 150, 25), "append to video");
00074       append->SetPressed();
00075    }
00076    
00077    new PG_Label(this, PG_Rect(20,100,80,25),"Framerate:");
00078    frameRate = new PG_LineEdit( this, PG_Rect( 120, 100, 150, 25 ));
00079    frameRate->SetText( ASCString::toString( CGameOptions::Instance()->video.framerate ));
00080    
00081    new PG_Label(this, PG_Rect(20,140,80,25),"Quality:");
00082    quality   = new PG_LineEdit( this, PG_Rect( 120, 140, 150, 25 ));
00083    quality->SetText( ASCString::toString( CGameOptions::Instance()->video.quality ));
00084    
00085    
00086    
00087    (new PG_Button( this, PG_Rect( 20, 200, 100, 30 ), "OK"))->sigClick.connect( SigC::slot(*this, &ReplayRecorderDialog::ok ));
00088    
00089 }
00090 
00091 ASCString ReplayRecorderDialog::getFilename()
00092 {
00093    if ( filename->GetText().find('.') == ASCString::npos ) 
00094       return filename->GetText() + ".avi";
00095    else
00096       return filename->GetText();
00097 }
00098       
00099 bool ReplayRecorderDialog::getAppend()
00100 {
00101    if ( append )
00102       return append->GetPressed();  
00103    else
00104       return false;
00105 }
00106 
00107 int ReplayRecorderDialog::getQuality()
00108 {
00109    int res = atoi(quality->GetText().c_str() );
00110    if ( res < 1 )
00111       res = 1;
00112    if ( res > 100 )
00113       res = 100;
00114    return res;
00115 }
00116 
00117 int ReplayRecorderDialog::getFramerate()
00118 {
00119    int res = atoi(frameRate->GetText().c_str() );
00120    
00121    if ( res < 1 )
00122       res = 1;
00123    if ( res > 100 )
00124       res = 100;
00125    return res;
00126    
00127 }

Generated on Tue Jun 24 01:27:51 2008 for Advanced Strategic Command by  doxygen 1.4.2