Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3069 was 2087, checked in by landauf, 16 years ago

merged objecthierarchy branch back to trunk

  • Property svn:eol-style set to native
File size: 2.7 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#include "core/CommandExecutor.h"
38
39namespace orxonox
40{
[1755]41    // ###############################
42    // ###  BufferedParamCommand   ###
43    // ###############################
[1526]44
[1755]45    /**
46    @brief
47        Executes a buffered command. This is used for commands with additional
48        parameters.
49    @return
50        True if command execution was successful or value was zero.
51    */
52    bool BufferedParamCommand::execute()
[1526]53    {
[2087]54        if (this->abs_ != 0.0f || this->rel_ != 0.0f)
[1755]55        {
[2087]56            evaluation_.setEvaluatedParameter(paramIndex_, Vector2(abs_, rel_));
[1755]57            // reset
[2087]58            rel_ = 0.0;
59            abs_ = 0.0;
60            return evaluation_.execute();
[1755]61        }
62        else
63            return true;
[1526]64    }
65
[1755]66    // ###############################
67    // #####    ParamCommand     #####
68    // ###############################
[1526]69
[1755]70    /**
71    @brief
72        Executes a parameter command. The commmand string is not directly executed,
73        but instead stored in a buffer list so that values can be combined.
74    @return
75        Always true.
76    */
77    bool ParamCommand::execute(float abs, float rel)
[1526]78    {
[1755]79        BufferedParamCommand& cmd = *paramCommand_;
80        // command has an additional parameter
[2087]81        if (rel != 0.0f)
[1755]82        {
[2087]83            // calculate relative movement.
84            // scale_ says how much one keystroke is
85            cmd.rel_ += scale_ * rel;
[1755]86        }
[2087]87
88        if (abs != 0.0f)
[1755]89        {
[2087]90            cmd.abs_ += scale_ * abs;
91            if (cmd.abs_ > 1.0)
92                cmd.abs_ = 1.0;
93            if (cmd.abs_ < -1.0)
94                cmd.abs_ = -1.0;
[1755]95        }
96        return true;
[1526]97    }
98}
Note: See TracBrowser for help on using the repository browser.