SuperTuxKart
binding.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2010-2015 Marianne Gagnon
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 
20 #ifndef BINDING_HPP
21 #define BINDING_HPP
22 
23 
24 #include "input/input.hpp"
25 #include "utils/no_copy.hpp"
26 
27 #include "irrString.h"
28 
29 #include <fstream>
30 
31 class XMLNode;
32 
36 class Binding : public NoCopy
37 {
38 private:
39  Input::InputType m_type;
40  int m_id;
41  Input::AxisDirection m_dir;
42  Input::AxisRange m_range;
43  wchar_t m_character;
44 public:
46  Input::InputType getType() const {return m_type; }
47  // ------------------------------------------------------------------------
49  int getId() const {return m_id;}
50  // ------------------------------------------------------------------------
52  Input::AxisDirection getDirection() const {return m_dir;}
53  // ------------------------------------------------------------------------
55  Input::AxisRange getRange() const {return m_range;}
56  // ------------------------------------------------------------------------
58  void set(Input::InputType type, int id,
59  Input::AxisDirection dir,
60  Input::AxisRange range,
61  wchar_t character)
62  {
63  m_type = type; m_id=id; m_dir=dir; m_range=range; m_character=character;
64  } // set
65 
66  // ------------------------------------------------------------------------
67  void save(std::ofstream& stream) const;
68  bool load(const XMLNode *action);
69  irr::core::stringw getAsString() const;
70 };
71 #endif
irr::core::stringw getAsString() const
Returns a string representing this binding, which can be displayed on the screen.
Definition: binding.cpp:87
int getId() const
Returns the id this binding is using.
Definition: binding.hpp:49
Input::AxisRange getRange() const
Returns the range this binding is using.
Definition: binding.hpp:55
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:25
Definition: binding.hpp:36
void save(std::ofstream &stream) const
Convert this binding to XML attributes.
Definition: binding.cpp:30
void set(Input::InputType type, int id, Input::AxisDirection dir, Input::AxisRange range, wchar_t character)
Defines all values of this binding.
Definition: binding.hpp:58
Input::InputType getType() const
Returns the type of device this binding is using.
Definition: binding.hpp:46
utility class used to parse XML files
Definition: xml_node.hpp:47
Input::AxisDirection getDirection() const
Returns the direction this binding is using.
Definition: binding.hpp:52