Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 2, 2008, 12:09:55 AM (16 years ago)
Author:
rgrieder
Message:

Finally managed to have a master InputState which enables:

  • Console always opens
  • Debug overlay toggles visibility in gui mode too

Had to change several other code:

  • ConfigFileManager uses special class instead of enum for ConfigFileType
  • You can add an arbitrary config file and get the ConfigFileType
  • ConfigFileManager is an Ogre singleton too. Created in Main.cc
  • CommandLineArgument "optionsFile" specifies another file for command line arguments
  • CommandLineArgument "settingsFile" declares the file used for settings (orxonox.ini)
  • changed all fileNames to filenames
  • "Loaded config file blah" now uses COUT(3) instead of COUT(0)
  • fixed a bug in ConfigFileManager::load() that cause orxonox.ini to double its size after every call
Location:
code/branches/objecthierarchy/src/core/input
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/core/input/Button.cc

    r2001 r2101  
    8282    }
    8383
    84     void Button::readConfigValue()
     84    void Button::readConfigValue(ConfigFileType configFile)
    8585    {
    8686        // create/get ConfigValueContainer
    8787        if (!configContainer_)
    8888        {
    89             configContainer_ = new ConfigValueContainer(CFT_Keybindings, 0, groupName_, name_, "", name_);
     89            configContainer_ = new ConfigValueContainer(configFile, 0, groupName_, name_, "", name_);
    9090            configContainer_->callback(this, &Button::parse);
    9191        }
  • code/branches/objecthierarchy/src/core/input/Button.h

    r1887 r2101  
    4141#include <vector>
    4242#include "InputCommands.h"
     43#include "core/ConfigFileManager.h"
    4344
    4445namespace orxonox
     
    5253        virtual bool addParamCommand(ParamCommand* command) { return false; }
    5354        void parse();
    54         void readConfigValue();
     55        void readConfigValue(ConfigFileType configFile);
    5556        bool execute(KeybindMode::Enum mode, float abs = 1.0f, float rel = 1.0f);
    5657
  • code/branches/objecthierarchy/src/core/input/InputManager.cc

    r1887 r2101  
    395395            if (!cont)
    396396            {
    397                 cont = new ConfigValueContainer(CFT_Settings, getIdentifier(), getIdentifier()->getName(), "CoeffPos", coeffPos);
     397                cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "CoeffPos", coeffPos);
    398398                getIdentifier()->addConfigValueContainer("CoeffPos", cont);
    399399            }
     
    403403            if (!cont)
    404404            {
    405                 cont = new ConfigValueContainer(CFT_Settings, getIdentifier(), getIdentifier()->getName(), "CoeffNeg", coeffNeg);
     405                cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "CoeffNeg", coeffNeg);
    406406                getIdentifier()->addConfigValueContainer("CoeffNeg", cont);
    407407            }
     
    411411            if (!cont)
    412412            {
    413                 cont = new ConfigValueContainer(CFT_Settings, getIdentifier(), getIdentifier()->getName(), "Zero", zero);
     413                cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "Zero", zero);
    414414                getIdentifier()->addConfigValueContainer("Zero", cont);
    415415            }
  • code/branches/objecthierarchy/src/core/input/KeyBinder.cc

    r2004 r2101  
    106106        }
    107107
     108        // Get a new ConfigFileType from the ConfigFileManager
     109        this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
     110
    108111        // initialise joy sticks separatly to allow for reloading
    109112        numberOfJoySticks_ = InputManager::getInstance().numberOfJoySticks();
     
    133136    void KeyBinder::setConfigValues()
    134137    {
    135         SetConfigValue(defaultKeybindings_, "def_keybindings.ini")
    136             .description("Filename of default keybindings.");
    137138        SetConfigValue(analogThreshold_, 0.05f)
    138139            .description("Threshold for analog axes until which the state is 0.");
     
    173174
    174175        // load the bindings if required
    175         if (!configFile_.empty())
     176        if (configFile_ != ConfigFileType::NoType)
    176177        {
    177178            for (unsigned int iDev = oldValue; iDev < numberOfJoySticks_; ++iDev)
    178179            {
    179180                for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; ++i)
    180                     joyStickButtons_[iDev][i].readConfigValue();
     181                    joyStickButtons_[iDev][i].readConfigValue(this->configFile_);
    181182                for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; ++i)
    182                     joyStickAxes_[iDev][i].readConfigValue();
     183                    joyStickAxes_[iDev][i].readConfigValue(this->configFile_);
    183184            }
    184185        }
     
    250251        True if loading succeeded.
    251252    */
    252     void KeyBinder::loadBindings(const std::string& filename)
     253    void KeyBinder::loadBindings(const std::string& filename, const std::string& defaultFilename)
    253254    {
    254255        COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
    255256
    256         configFile_ = filename;
    257         if (configFile_.empty())
     257        if (filename.empty())
    258258            return;
    259259
    260260        // get bindings from default file if filename doesn't exist.
    261261        std::ifstream infile;
    262         infile.open(configFile_.c_str());
     262        infile.open(filename.c_str());
    263263        if (!infile)
    264264        {
    265             ConfigFileManager::getInstance().setFile(CFT_Keybindings, defaultKeybindings_);
    266             ConfigFileManager::getInstance().save(CFT_Keybindings, configFile_);
     265            ConfigFileManager::getInstance().setFilename(this->configFile_, defaultFilename);
     266            ConfigFileManager::getInstance().saveAs(this->configFile_, filename);
    267267        }
    268268        else
    269269            infile.close();
    270         ConfigFileManager::getInstance().setFile(CFT_Keybindings, configFile_);
     270        ConfigFileManager::getInstance().setFilename(this->configFile_, filename);
    271271
    272272        // Parse bindings and create the ConfigValueContainers if necessary
    273273        clearBindings();
    274274        for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
    275             it->second->readConfigValue();
     275            it->second->readConfigValue(this->configFile_);
    276276
    277277        COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
  • code/branches/objecthierarchy/src/core/input/KeyBinder.h

    r2001 r2101  
    4444#include "InputCommands.h"
    4545#include "JoyStickDeviceNumberListener.h"
     46#include "core/ConfigFileManager.h"
    4647
    4748namespace orxonox
     
    5960        virtual ~KeyBinder();
    6061
    61         void loadBindings(const std::string& filename);
     62        void loadBindings(const std::string& filename, const std::string& defaultFilename);
    6263        void clearBindings();
    6364        bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false);
     
    142143        float deriveTime_;
    143144
    144         //! Config file used. "" in case of KeyDetector. Also indicates whether we've already loaded.
    145         std::string configFile_;
     145        //! Config file used. ConfigFileType::NoType in case of KeyDetector. Also indicates whether we've already loaded.
     146        ConfigFileType configFile_;
    146147
    147148    private:
    148149        //##### ConfigValues #####
    149         //! Filename of default keybindings.
    150         std::string defaultKeybindings_;
    151150        //! Whether to filter small value analog input
    152151        bool bFilterAnalogNoise_;
Note: See TracChangeset for help on using the changeset viewer.