00001 #include "assets.h" 00002 #include "mbuttons.h" 00003 #include "confirmquit.h" 00004 #include "errorbox.h" 00005 #include "language.h" 00006 #include "levelwindow.h" 00007 #include "levelwindowgui.h" 00008 #include "mainmenu.h" 00009 #include "mwindow.h" 00010 #include "mwindowgui.h" 00011 #include "playback3d.h" 00012 #include "quit.h" 00013 #include "record.h" 00014 #include "render.h" 00015 #include "savefile.h" 00016 #include "mainsession.h" 00017 #include "videowindow.h" 00018 #include "videowindowgui.h" 00019 00020 00021 Quit::Quit(MWindow *mwindow) 00022 : BC_MenuItem(_("Quit"), "q", 'q'), Thread() 00023 { 00024 this->mwindow = mwindow; 00025 } 00026 int Quit::create_objects(Save *save) 00027 { 00028 this->save = save; 00029 return 0; 00030 } 00031 00032 int Quit::handle_event() 00033 { 00034 00035 //printf("Quit::handle_event 1 %d\n", mwindow->session->changes_made); 00036 if(mwindow->session->changes_made || 00037 mwindow->gui->mainmenu->record->current_state || 00038 mwindow->render->in_progress) 00039 { 00040 start(); 00041 } 00042 else 00043 { // quit 00044 mwindow->gui->unlock_window(); 00045 mwindow->interrupt_indexes(); 00046 // mwindow->gui->set_done(0); 00047 // BC_WindowBase::get_resources()->synchronous->quit(); 00048 mwindow->playback_3d->quit(); 00049 mwindow->gui->lock_window(); 00050 } 00051 return 0; 00052 } 00053 00054 void Quit::run() 00055 { 00056 int result = 0; 00057 // Test execution conditions 00058 if(mwindow->gui->mainmenu->record->current_state == RECORD_CAPTURING) 00059 { 00060 ErrorBox error(PROGRAM_NAME ": Error", 00061 mwindow->gui->get_abs_cursor_x(1), 00062 mwindow->gui->get_abs_cursor_y(1)); 00063 error.create_objects(_("Can't quit while a recording is in progress.")); 00064 error.run_window(); 00065 return; 00066 } 00067 else 00068 if(mwindow->render->running()) 00069 { 00070 ErrorBox error(PROGRAM_NAME ": Error", 00071 mwindow->gui->get_abs_cursor_x(1), 00072 mwindow->gui->get_abs_cursor_y(1)); 00073 error.create_objects(_("Can't quit while a render is in progress.")); 00074 error.run_window(); 00075 return; 00076 } 00077 00078 00079 //printf("Quit::run 1\n"); 00080 00081 // Quit 00082 { 00083 //printf("Quit::run 2\n"); 00084 ConfirmQuitWindow confirm(mwindow); 00085 //printf("Quit::run 2\n"); 00086 confirm.create_objects(_("Save edit list before exiting?")); 00087 //printf("Quit::run 2\n"); 00088 result = confirm.run_window(); 00089 //printf("Quit::run 2\n"); 00090 } 00091 //printf("Quit::run 3\n"); 00092 00093 switch(result) 00094 { 00095 case 0: // quit 00096 if(mwindow->gui) 00097 { 00098 mwindow->interrupt_indexes(); 00099 // Last command in program 00100 // mwindow->gui->set_done(0); 00101 // BC_WindowBase::get_resources()->synchronous->quit(); 00102 mwindow->playback_3d->quit(); 00103 } 00104 break; 00105 00106 case 1: // cancel 00107 return; 00108 break; 00109 00110 case 2: // save 00111 save->save_before_quit(); 00112 return; 00113 break; 00114 } 00115 }
1.5.5