Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 3, 2016, 5:48:18 PM (8 years ago)
Author:
fvultier
Message:

Implemented a feature that was requested during PPS: Vulnerability can be switched on/off using the event system. Also: Resolved a TODO in CommandNotification.cc .

Location:
code/branches/fabienHS15/src/libraries/core/input
Files:
2 edited

Legend:

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

    r10624 r11027  
    359359    /**
    360360    @brief
     361        Return the first key name for a specific command in a human readable form
     362    */
     363    const std::string& KeyBinder::getBindingReadable(const std::string& commandName)
     364    {
     365        const std::string& binding = this->getBinding(commandName);
     366
     367        SubString substring = SubString(binding, ".");
     368        std::string name;
     369        std::string group;
     370        switch(substring.size())
     371        {
     372            case 0:
     373                return binding;
     374            case 1:
     375                return binding;
     376            case 2:
     377                group = substring[0];
     378            default:
     379                name = substring.subSet(1).join(".");
     380        }
     381
     382        std::stringstream stream;
     383        if(group.compare("Keys") == 0)
     384            stream << "Key " << name.substr(3);
     385        else if(group.compare("MouseButtons") == 0)
     386            stream << "Mouse " << name;
     387        else if(group.compare("JoyStickButtons") == 0)
     388            stream << "Joystick " << name;
     389        else if(group.compare("JoyStickAxes") == 0)
     390            stream << "Joystick Axis" << name.substr(5, 6) << name.substr(name.find("Axis")+6);
     391        else if(group.compare("MouseAxes") == 0)
     392            stream << "Mouse " << name.substr(1,3) << " " << name.substr(0, 1) << "-Axis";
     393        else
     394            return binding;
     395
     396        return *(new std::string(stream.str()));
     397    }
     398
     399    /**
     400    @brief
    361401        Get the number of different key bindings of a specific command.
    362402    @param commandName
  • code/branches/fabienHS15/src/libraries/core/input/KeyBinder.h

    r9978 r11027  
    6868        const std::string& getBinding(const std::string& commandName); //tolua_export
    6969        const std::string& getBinding(const std::string& commandName, unsigned int index); //tolua_export
     70        const std::string& getBindingReadable(const std::string& commandName); //tolua_export
    7071        unsigned int getNumberOfBindings(const std::string& commandName); //tolua_export
    7172
Note: See TracChangeset for help on using the changeset viewer.