Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 3, 2009, 5:33:31 PM (15 years ago)
Author:
rgrieder
Message:

New class: KeyBinderManager (yes, it really was necessary, I'm not such a Fan of zillions of classes as well) and moved the keybind command to it from GSLevel.
This new Singleton simply maps the keybind command to the right KeyBinder, selected by KeyBinderManager::setCurrent().
There is also a default KeyBinder (with keybindings.ini as file), which should do the Trick for now. Other Keybinders should only server special purposes (like in mini games or so).

DELETE YOUR keybindings.ini FILE! =
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/libraries/core/input/KeyBinder.cc

    r5738 r5863  
    2727 */
    2828
    29 /**
    30  @file
    31  @brief Implementation of the different input handlers.
    32  */
    33 
    3429#include "KeyBinder.h"
    3530
    3631#include "util/Convert.h"
    3732#include "util/Debug.h"
     33#include "util/Exception.h"
    3834#include "core/ConfigValueIncludes.h"
    3935#include "core/CoreIncludes.h"
     
    4844        Constructor that does as little as necessary.
    4945    */
    50     KeyBinder::KeyBinder()
     46    KeyBinder::KeyBinder(const std::string& filename)
    5147        : deriveTime_(0.0f)
     48        , filename_(filename)
    5249    {
    5350        mouseRelative_[0] = 0;
     
    103100        // set them here to use allHalfAxes_
    104101        setConfigValues();
     102
     103        // Load the bindings if filename was given
     104        if (!this->filename_.empty())
     105            this->loadBindings();
    105106    }
    106107
     
    240241    @brief
    241242        Loads the key and button bindings.
    242     @return
    243         True if loading succeeded.
    244     */
    245     void KeyBinder::loadBindings(const std::string& filename)
     243    */
     244    void KeyBinder::loadBindings()
    246245    {
    247246        COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
    248247
    249         if (filename.empty())
    250             return;
    251 
    252         if (this->configFile_ == ConfigFileType::NoType)
    253         {
    254             // Get a new ConfigFileType from the ConfigFileManager
    255             this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
    256         }
    257 
    258         ConfigFileManager::getInstance().setFilename(this->configFile_, filename);
     248        // Get a new ConfigFileType from the ConfigFileManager
     249        this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
     250
     251        ConfigFileManager::getInstance().setFilename(this->configFile_, this->filename_);
    259252
    260253        // Parse bindings and create the ConfigValueContainers if necessary
    261         clearBindings();
    262254        for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
    263255            it->second->readConfigValue(this->configFile_);
Note: See TracChangeset for help on using the changeset viewer.