Back to index

extremetuxracer  0.5beta
graphicsconfig.cpp
Go to the documentation of this file.
00001 /* 
00002  * Extreme Tux Racer
00003  * Copyleft 2007-2008 The ETR Team <http://www.extremetuxracer.com/>
00004  * 
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (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; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019  
00020  
00021 #include "graphicsconfig.h"
00022 
00023 #include "game_config.h"
00024 #include "game_mgr.h"
00025 #include "ppgltk/ui_mgr.h"
00026 
00027 
00028 GraphicsConfig::GraphicsConfig()
00029 {
00030        setTitle(_("Graphics Configuration"));    
00031        
00032        pp::Vec2d pos(0,0);
00033 
00034        m_modelList = ModelHndl->l_models;
00035        std::list<model_t>::iterator modelit=m_modelList.begin();
00036 
00037        /*m_langList=translation.LanguageList();
00038        std::list<language_t>::iterator langit,iter;
00039        
00040        bool found=false;
00041 
00042        for (iter=m_langList.begin();iter != m_langList.end(); ++iter) {
00043               if ((*iter).language==getparam_ui_language()) {
00044                      langit=iter;
00045                      found=true;
00046               }
00047        }
00048               
00049        if(!found) langit = m_langList.begin();*/
00050      
00051      for(int i=0;i<ModelHndl->cur_model;i++) {
00052        modelit++;
00053      }
00054      
00055 //     mp_modelListBox = new pp::Listbox<model_t>( pos, pp::Vec2d(240, 32), "listbox_item", m_modelList);
00056 //     mp_modelListBox->setCurrentItem( modelit );
00057  
00058 //     mp_langListBox = new pp::Listbox<language_t>( pos, pp::Vec2d(240, 32), "listbox_item", m_langList);
00059 //     mp_langListBox->setCurrentItem( langit );
00060            
00061        
00062        mp_uiSnowBox = new pp::CheckBox(pos, pp::Vec2d(32, 32) );
00063        mp_uiSnowBox->setState( getparam_ui_snow() );
00064 
00065        mp_fpsBox = new pp::CheckBox(pos, pp::Vec2d(32, 32) );
00066        mp_fpsBox->setState( getparam_display_fps() );
00067 
00068        mp_coursePercentageBox = new pp::CheckBox(pos, pp::Vec2d(32, 32) );
00069        mp_coursePercentageBox->setState( getparam_display_course_percentage() );
00070        
00071        mp_fogBox = new pp::CheckBox(pos, pp::Vec2d(32, 32) );
00072        mp_fogBox->setState( !getparam_disable_fog() );
00073 
00074        mp_reflectionsBox = new pp::CheckBox(pos, pp::Vec2d(32, 32) );
00075        mp_reflectionsBox->setState( getparam_terrain_envmap() );
00076 
00077        mp_shadowsBox = new pp::CheckBox(pos, pp::Vec2d(32, 32) );
00078        mp_shadowsBox->setState( getparam_draw_tux_shadow() );
00079 
00080        mp_backgroundBox = new pp::CheckBox(pos, pp::Vec2d(32, 32) );
00081        mp_backgroundBox->setState( !getparam_disable_background() );
00082 }
00083 
00084 GraphicsConfig::~GraphicsConfig()
00085 {
00086 //     delete mp_modelListBox;
00087 //     delete mp_langListBox;
00088        delete mp_uiSnowBox;
00089        delete mp_fpsBox;
00090        delete mp_coursePercentageBox;
00091        delete mp_fogBox;
00092        delete mp_reflectionsBox;
00093        delete mp_shadowsBox;
00094        delete mp_backgroundBox;
00095 }
00096 
00097 void
00098 GraphicsConfig::setWidgetPositions()
00099 {
00100        int width = 550;
00101        int height = 280;
00102               
00103        pp::Vec2d pos(getparam_x_resolution()/2 - width/2,
00104                               getparam_y_resolution()/2 + height/2);
00105        
00106        pp::Font* font = pp::Font::get("button_label");
00107 
00108 //     font->draw(_("Model:"),pos);
00109 //     mp_modelListBox->setPosition(pp::Vec2d(pos.x+width-204,pos.y));
00110 
00111        pos.y-=40;    
00112 
00113 //     font->draw(_("Language:"),pos);
00114 //     mp_langListBox->setPosition(pp::Vec2d(pos.x+width-204,pos.y));
00115 
00116        pos.y-=40;    
00117        font->draw(_("Show UI Snow:"),pos);
00118        mp_uiSnowBox->setPosition(pp::Vec2d(pos.x+width-32,pos.y));
00119        
00120        pos.y-=40;
00121        font->draw(_("Display FPS:"),pos);
00122        mp_fpsBox->setPosition(pp::Vec2d(pos.x+width-32,pos.y));
00123        
00124        pos.y-=40;
00125        font->draw(_("Display Progress Bar:"),pos);
00126        mp_coursePercentageBox->setPosition(pp::Vec2d(pos.x+width-32,pos.y));
00127        
00128        pos.y-=40;
00129        font->draw(_("Draw Fog:"),pos);
00130        mp_fogBox->setPosition(pp::Vec2d(pos.x+width-32,pos.y));
00131        
00132        pos.y-=40;
00133        font->draw(_("Reflections:"),pos);
00134        mp_reflectionsBox->setPosition(pp::Vec2d(pos.x+width-32,pos.y));
00135        
00136        pos.y-=40;
00137        font->draw(_("Shadows:"),pos);
00138        mp_shadowsBox->setPosition(pp::Vec2d(pos.x+width-32,pos.y));
00139 
00140        pos.y-=40;
00141        font->draw(_("Draw Background:"),pos);
00142        mp_backgroundBox->setPosition(pp::Vec2d(pos.x+width-32,pos.y));
00143 }
00144 
00145 void
00146 GraphicsConfig::apply()
00147 {
00148 //     std::list<language_t>::iterator langit = mp_langListBox->getCurrentItem();
00149 //     translation.load((*langit).language.c_str());    
00150 //     std::list<model_t>::iterator modelit = mp_modelListBox->getCurrentItem();
00151 //     ModelHndl->load_model((*modelit).id);     
00152 //     setparam_ui_language((char*)(*langit).language.c_str());
00153        setparam_ui_snow(bool( mp_uiSnowBox->getState() ));
00154        setparam_display_fps(bool( mp_fpsBox->getState() ));
00155        setparam_display_course_percentage(bool( mp_coursePercentageBox->getState() ));
00156        setparam_disable_fog(!bool( mp_fogBox->getState() ));
00157        setparam_terrain_envmap(bool( mp_reflectionsBox->getState() ));
00158        setparam_draw_tux_shadow(bool( mp_shadowsBox->getState() ));
00159        setparam_disable_background(!bool( mp_backgroundBox->getState() )); 
00160        
00161        write_config_file();
00162        set_game_mode( GameMode::prevmode );
00163     UIMgr.setDirty();       
00164 }