// mainwin3.cpp -- main window // // Written by Frederic Bouvier, started February 2004. // // Copyright (C) 2004 Frederic Bouvier - fredb@users.sourceforge.net // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // // $Id: mainwin3.cpp,v 1.4 2005/05/09 07:02:08 fredb Exp $ #ifdef _MSC_VER #pragma warning( disable : 4786 4800 4503 ) #endif #include #include #include "mainwin.hpp" #include "scenerytools.hpp" #include "sdutil.hpp" extern FGSD_Preferences generalPreferences; void FGSD_MainWindow::open_cb(Fl_Widget*) { if ( checkModified() ) { std::string curdir = generalPreferences.currentMainDirectory(); const char *fileName = flu_file_chooser( "Select a project ...", "*.sdp", curdir.c_str() ); if ( fileName ) { setCursor( FL_CURSOR_WAIT ); cleanProject(); load( fileName ); curdir = FGSD_Util::getDirectoryFromFile( fileName ); generalPreferences.currentMainDirectory( curdir ); _posx = _minx; _posy = _miny; layout_(); if ( _fragmentList.empty() ) { _fbutton->deactivate(); setButtonImage( _fbutton, Fragments_i, true ); } else { _fbutton->activate(); setButtonImage( _fbutton, Fragments_i, false ); } if ( _tileList.empty() ) { _sbutton->value( 0 ); _sbutton->deactivate(); setButtonImage( _sbutton, Scenery_i, true ); _sceneryTools->drawTiles( false ); } else { _sbutton->activate(); setButtonImage( _sbutton, Scenery_i, false ); if ( _fragmentList.empty() ) { _sceneryTools->noFragmentPresent(); } else { _sceneryTools->fragmentPresent(); } } _vscroll->activate(); _hscroll->activate(); _area->valid( 0 ); _area->redraw(); _fileName = fileName; setTitle(); generalPreferences.addFileToHistory( _fileName ); generalPreferences.save(); refreshRecentFiles(); setCursor( FL_CURSOR_DEFAULT ); } } } bool FGSD_MainWindow::saveProject( bool __saveAs) { bool ret = false; bool chosen = false; const char *fileName = 0; if ( __saveAs || _fileName.empty() ) chosen = true, fileName = flu_file_chooser( "Save As", "*.sdp", _fileName.c_str() ); else fileName = _fileName.c_str(); if ( fileName ) { save( fileName ); if ( chosen ) { _fileName = fileName; generalPreferences.addFileToHistory( _fileName ); generalPreferences.save(); refreshRecentFiles(); } setTitle(); ret = true; } return ret; }