Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 11, 2010, 10:20:44 AM (14 years ago)
Author:
dafrick
Message:

Merged notifications branch back to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/notifications/dispatchers/CommandNotification.cc

    r7285 r7403  
    3838#include "core/input/KeyBinderManager.h"
    3939#include "core/input/KeyBinder.h"
     40#include "util/SubString.h"
    4041
    4142#include <sstream>
     
    8889        std::stringstream stream;
    8990        stream << this->getPreMessage();
    90         //TODO: Add niceifyer.
    91         stream << KeyBinderManager::getInstance().getCurrent()->getBinding(this->getCommand());
     91        stream << this->bindingNiceifyer(KeyBinderManager::getInstance().getCurrent()->getBinding(this->getCommand()));
    9292        stream << this->getPostMessage();
    93         std::string* message = new std::string(stream.str());
    94         return *message;
     93        return *(new std::string(stream.str()));
     94    }
     95
     96    /**
     97    @brief
     98        Transforms the input binding into a human readable form.
     99    @param binding
     100        The binding to be transformed
     101    @return
     102        Returns a human readable version of the input binding.
     103    */
     104    const std::string& CommandNotification::bindingNiceifyer(const std::string& binding)
     105    {
     106        SubString string = SubString(binding, ".");
     107        std::string name;
     108        std::string group;
     109        switch(string.size())
     110        {
     111            case 0:
     112                return binding;
     113            case 1:
     114                return binding;
     115            case 2:
     116                group = string[0];
     117            default:
     118                name = string.subSet(1, string.size()).join(".");
     119        }
     120
     121        std::stringstream stream;
     122        if(group.compare("Keys") == 0)
     123            stream << "Key " << name.substr(3);
     124        else if(group.compare("MouseButtons") == 0)
     125            stream << "Mouse " << name;
     126        else if(group.compare("JoyStickButtons") == 0)
     127            stream << "Joystick " << name;
     128        else if(group.compare("JoyStickAxes") == 0)
     129            stream << "Joystick Axis" << name.substr(5, 6) << name.substr(name.find("Axis")+6);
     130        else if(group.compare("MouseAxes") == 0)
     131            stream << "Mouse " << name.substr(1,3) << " " << name.substr(0, 1) << "-Axis";
     132        else
     133            return binding;
     134
     135        return *(new std::string(stream.str()));
    95136    }
    96137   
Note: See TracChangeset for help on using the changeset viewer.