Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/core/input/InputCommands.cc @ 5727

Last change on this file since 5727 was 3196, checked in by rgrieder, 15 years ago

Merged pch branch back to trunk.

  • Property svn:eol-style set to native
File size: 2.6 KB
RevLine 
[1526]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Reto Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
[1755]30@file
31@brief
32    Implementation of the different input handlers.
33*/
[1526]34
35#include "InputCommands.h"
[2087]36#include "util/Math.h"
[1526]37
38namespace orxonox
39{
[1755]40    // ###############################
41    // ###  BufferedParamCommand   ###
42    // ###############################
[1526]43
[1755]44    /**
45    @brief
46        Executes a buffered command. This is used for commands with additional
47        parameters.
48    @return
49        True if command execution was successful or value was zero.
50    */
51    bool BufferedParamCommand::execute()
[1526]52    {
[2087]53        if (this->abs_ != 0.0f || this->rel_ != 0.0f)
[1755]54        {
[2087]55            evaluation_.setEvaluatedParameter(paramIndex_, Vector2(abs_, rel_));
[1755]56            // reset
[2087]57            rel_ = 0.0;
58            abs_ = 0.0;
59            return evaluation_.execute();
[1755]60        }
61        else
62            return true;
[1526]63    }
64
[1755]65    // ###############################
66    // #####    ParamCommand     #####
67    // ###############################
[1526]68
[1755]69    /**
70    @brief
71        Executes a parameter command. The commmand string is not directly executed,
72        but instead stored in a buffer list so that values can be combined.
73    @return
74        Always true.
75    */
76    bool ParamCommand::execute(float abs, float rel)
[1526]77    {
[1755]78        BufferedParamCommand& cmd = *paramCommand_;
79        // command has an additional parameter
[2087]80        if (rel != 0.0f)
[1755]81        {
[2087]82            // calculate relative movement.
83            // scale_ says how much one keystroke is
84            cmd.rel_ += scale_ * rel;
[1755]85        }
[2087]86
87        if (abs != 0.0f)
[1755]88        {
[2087]89            cmd.abs_ += scale_ * abs;
90            if (cmd.abs_ > 1.0)
91                cmd.abs_ = 1.0;
92            if (cmd.abs_ < -1.0)
93                cmd.abs_ = -1.0;
[1755]94        }
95        return true;
[1526]96    }
97}
Note: See TracBrowser for help on using the repository browser.