OptionsDisplayConsole.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <graph/OptionsDisplayConsole.h>
00022 #include <graph/OptionsDisplay.h>
00023 #include <common/OptionsScorched.h>
00024 #include <client/ScorchedClient.h>
00025 #include <client/ClientParams.h>
00026 
00027 OptionsDisplayConsole *OptionsDisplayConsole::instance_ = 0;
00028 
00029 OptionsDisplayConsole *OptionsDisplayConsole::instance()
00030 {
00031         if (!instance_)
00032         {
00033                 instance_ = new OptionsDisplayConsole;
00034         }
00035 
00036         return instance_;
00037 }
00038 
00039 OptionsDisplayConsole::OptionsDisplayConsole()
00040 
00041 {
00042 }
00043 
00044 OptionsDisplayConsole::~OptionsDisplayConsole()
00045 {       
00046 }
00047 
00048 void OptionsDisplayConsole::addDisplayToConsole()
00049 {
00050         // remove existing adapters
00051         while (!adapters_.empty())
00052         {
00053                 ConsoleRuleFnIOptionsAdapter *adapter = adapters_.front();
00054                 adapters_.pop_front();
00055                 delete adapter;
00056         }
00057 
00058         // Add all of the options to the console
00059         std::list<OptionEntry *>::iterator itor;
00060         for (itor = OptionsDisplay::instance()->getOptions().begin();
00061                 itor != OptionsDisplay::instance()->getOptions().end();
00062                 itor++)
00063         {
00064                 OptionEntry *entry = (*itor);
00065                 if ((entry->getData() & OptionsDisplay::DebugOnly) &&
00066                         !ScorchedClient::instance()->getOptionsGame().getDebugFeatures() &&
00067                         ClientParams::instance()->getConnectedToServer())
00068                 {
00069                         entry->setValueFromString(entry->getDefaultValueAsString());
00070                 }
00071                 else if (!(entry->getData() & OptionEntry::DataDepricated))
00072                 {
00073                         bool write = false;
00074                         if (entry->getData() & OptionsDisplay::RWAccess) write = true;
00075 
00076                         adapters_.push_back(new ConsoleRuleFnIOptionsAdapter(
00077                                 *entry,
00078                                 write));
00079                 }
00080         }
00081 }
00082 

Generated on Mon Feb 16 15:14:46 2009 for Scorched3D by  doxygen 1.5.3