Mana
Loading...
Searching...
No Matches
setup_joystick.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * 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, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "gui/setup_joystick.h"
23
24#include "configuration.h"
25#include "joystick.h"
26
27#include "gui/widgets/button.h"
29#include "gui/widgets/label.h"
30
31#include "utils/gettext.h"
32
33extern Joystick *joystick;
34
36 mCalibrateLabel(new Label(_("Press the button to start calibration"))),
37 mCalibrateButton(new Button(_("Calibrate"), "calibrate", this)),
38 mJoystickCheckBox(new CheckBox(_("Enable joystick")))
39{
40 setName(_("Joystick"));
41
44
45 mJoystickCheckBox->addActionListener(this);
46
47 // Do the layout
48 place(0, 0, mJoystickCheckBox, 2);
49 place(0, 1, mCalibrateLabel, 2);
51}
52
53void Setup_Joystick::action(const gcn::ActionEvent &event)
54{
55 if (!joystick)
56 {
57 return;
58 }
59
60 if (event.getSource() == mJoystickCheckBox)
61 {
63 }
64 else
65 {
67 {
68 mCalibrateButton->setCaption(_("Calibrate"));
69 mCalibrateLabel->setCaption
70 (_("Press the button to start calibration"));
72 }
73 else
74 {
75 mCalibrateButton->setCaption(_("Stop"));
76 mCalibrateLabel->setCaption(_("Rotate the stick"));
78 }
79 }
80}
81
90
Button widget.
Definition button.h:38
Check box widget.
Definition checkbox.h:32
LayoutCell & place(int x, int y, gcn::Widget *wg, int w=1, int h=1)
Adds a widget to the container and sets it at given cell.
Definition container.cpp:46
void finishCalibration()
Definition joystick.cpp:134
bool isCalibrating() const
Definition joystick.h:79
bool isEnabled() const
Definition joystick.h:66
void startCalibration()
Definition joystick.cpp:108
void setEnabled(bool enabled)
Definition joystick.h:68
Label widget.
Definition label.h:34
void setName(const std::string &name)
Sets the name displayed on the tab.
Definition setuptab.h:54
void apply() override
Called when the Apply button is pressed in the setup window.
void action(const gcn::ActionEvent &event) override
void cancel() override
Called when the Cancel button is pressed in the setup window.
gcn::CheckBox * mJoystickCheckBox
gcn::Label * mCalibrateLabel
gcn::Button * mCalibrateButton
Config config
Global settings (config.xml)
Definition client.cpp:97
Joystick * joystick
Definition game.cpp:87
#define _(s)
Definition gettext.h:38
Joystick * joystick
Definition game.cpp:87
bool joystickEnabled