00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 }