Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7358


Ignore:
Timestamp:
Sep 5, 2010, 10:26:37 PM (14 years ago)
Author:
dafrick
Message:

Adding method that puts a keybinding into a more human readable form.

Location:
code/branches/notifications
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/notifications/data/gui/scripts/KeyBindMenu.lua

    r7163 r7358  
    113113        return "Joystick " .. name
    114114    elseif( string.find(group, "JoyStickAxes") ~= nil ) then
    115         return "Joystick Axis" .. string.sub(name, 5, 6) .. string.sub(name, string.find(name, 'Axis%d%d(.*)')+6)
     115        return "Joystick Axis " .. string.sub(name, 5, 6) .. string.sub(name, string.find(name, 'Axis%d%d(.*)')+6)
    116116    elseif( group == "MouseAxes" ) then
    117117        return "Mouse " .. string.sub(name, string.find(name, '.(.*)')+1) .. " " .. string.sub(name, 1, 1) .. "-Axis"
  • code/branches/notifications/data/levels/tutorial.oxw

    r7354 r7358  
    1919  >
    2020
    21       <CommandNotification preMessage="Press '" postMessage="' to fire your primary weapon." command="fire 0">
     21      <CommandNotification preMessage="Move '" postMessage="' to look left." command="scale 1 rotateYaw">
    2222        <events>
    2323            <trigger>
  • code/branches/notifications/src/modules/notifications/dispatchers/CommandNotification.cc

    r7285 r7358  
    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 = new SubString(binding, '.');
     107        std::string name = string->getString(1);
     108        std::string group = string->getString(0);
     109
     110        std::stringstream stream;
     111        if(group.compare("Keys") == 0)
     112            stream << "Key " << name.substr(3);
     113        else if(group.compare("MouseButtons") == 0)
     114            stream << "Mouse " << name;
     115        else if(group.compare("JoyStickButtons") == 0)
     116            stream << "Joystick " << name;
     117        else if(group.compare("JoyStickAxes") == 0)
     118            stream << "Joystick Axis" << name.substr(5, 6) << name.substr(name.find("Axis")+6);
     119        else if(group.compare("MouseAxes") == 0)
     120            stream << "Mouse " << name.substr(1,3) << " " << name.substr(0, 1) << "-Axis";
     121        else
     122            stream << binding;
     123
     124        delete string;
     125        return *(new std::string(stream.str()));
    95126    }
    96127   
  • code/branches/notifications/src/modules/notifications/dispatchers/CommandNotification.h

    r7285 r7358  
    104104                 { this->postMessage_ = message; }
    105105
     106            const std::string& bindingNiceifyer(const std::string& binding);
     107
    106108    };
    107109
Note: See TracChangeset for help on using the changeset viewer.